Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11724) Constifying common/unittype (more)
Home

[Freeciv-Dev] (PR#11724) Constifying common/unittype (more)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11724) Constifying common/unittype (more)
From: "Frédéric Brière" <fbriere@xxxxxxxxxxx>
Date: Wed, 29 Dec 2004 20:30:08 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11724 >

Here's a couple more consts for common/unittype.[ch].


-- 
             Frédéric Brière    <*>    fbriere@xxxxxxxxxxx

 =>  <fbriere@xxxxxxxxxx> IS NO MORE:  <http://www.abacomsucks.com>  <=

Index: common/unittype.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.c,v
retrieving revision 1.48
diff -u -r1.48 unittype.c
--- common/unittype.c   24 Dec 2004 01:52:44 -0000      1.48
+++ common/unittype.c   30 Dec 2004 02:16:18 -0000
@@ -307,7 +307,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-int can_upgrade_unittype(struct player *pplayer, Unit_Type_id id)
+int can_upgrade_unittype(const struct player *pplayer, Unit_Type_id id)
 {
   Unit_Type_id best_upgrade = -1;
 
@@ -328,7 +328,7 @@
   other attributes (like nation or government type) of the player the unit
   belongs to.
 **************************************************************************/
-int unit_upgrade_price(const struct player *const pplayer,
+int unit_upgrade_price(const struct player *pplayer,
                       const Unit_Type_id from, const Unit_Type_id to)
 {
   return unit_buy_gold_cost(to, unit_disband_shields(from));
@@ -444,7 +444,7 @@
 ignoring whether unit is obsolete and assuming the
 player has a coastal city.
 **************************************************************************/
-bool can_player_build_unit_direct(struct player *p, Unit_Type_id id)
+bool can_player_build_unit_direct(const struct player *p, Unit_Type_id id)
 {
   Impr_Type_id impr_req;
   Tech_Type_id tech_req;
@@ -493,7 +493,7 @@
 Whether player can build given unit somewhere;
 returns 0 if unit is obsolete.
 **************************************************************************/
-bool can_player_build_unit(struct player *p, Unit_Type_id id)
+bool can_player_build_unit(const struct player *p, Unit_Type_id id)
 {  
   if (!can_player_build_unit_direct(p, id))
     return FALSE;
@@ -510,7 +510,7 @@
 returns 1 if unit is available with current tech OR will be available
 with future tech.  returns 0 if unit is obsolete.
 **************************************************************************/
-bool can_player_eventually_build_unit(struct player *p, Unit_Type_id id)
+bool can_player_eventually_build_unit(const struct player *p, Unit_Type_id id)
 {
   CHECK_UNIT_TYPE(id);
   if (unit_type_flag(id, F_NOBUILD)) {
@@ -635,7 +635,7 @@
 
 TODO: Cache the result per player?
 **************************************************************************/
-Unit_Type_id best_role_unit_for_player(struct player *pplayer, int role)
+Unit_Type_id best_role_unit_for_player(const struct player *pplayer, int role)
 {
   int j;
 
@@ -656,7 +656,7 @@
   Return first unit the player can build, with given role/flag.
   Returns U_LAST if none match.  Used eg when placing starting units.
 **************************************************************************/
-Unit_Type_id first_role_unit_for_player(struct player *pplayer, int role)
+Unit_Type_id first_role_unit_for_player(const struct player *pplayer, int role)
 {
   int j;
 
Index: common/unittype.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.h,v
retrieving revision 1.39
diff -u -r1.39 unittype.h
--- common/unittype.h   24 Dec 2004 01:52:44 -0000      1.39
+++ common/unittype.h   30 Dec 2004 02:16:18 -0000
@@ -251,8 +251,8 @@
                      const struct government *gov, Output_type_id otype);
 int utype_happy_cost(const struct unit_type *ut, const struct government *g);
 
-int can_upgrade_unittype(struct player *pplayer, Unit_Type_id id);
-int unit_upgrade_price(const struct player * const pplayer,
+int can_upgrade_unittype(const struct player *pplayer, Unit_Type_id id);
+int unit_upgrade_price(const struct player *pplayer,
                       const Unit_Type_id from, const Unit_Type_id to);
 
 Unit_Type_id find_unit_type_by_name(const char *name);
@@ -263,16 +263,16 @@
 enum unit_flag_id unit_flag_from_str(const char *s);
 enum unit_role_id unit_role_from_str(const char *s);
 
-bool can_player_build_unit_direct(struct player *p, Unit_Type_id id);
-bool can_player_build_unit(struct player *p, Unit_Type_id id);
-bool can_player_eventually_build_unit(struct player *p, Unit_Type_id id);
+bool can_player_build_unit_direct(const struct player *p, Unit_Type_id id);
+bool can_player_build_unit(const struct player *p, Unit_Type_id id);
+bool can_player_eventually_build_unit(const struct player *p, Unit_Type_id id);
 
 void role_unit_precalcs(void);
 int num_role_units(int role);
 Unit_Type_id get_role_unit(int role, int index);
 Unit_Type_id best_role_unit(const struct city *pcity, int role);
-Unit_Type_id best_role_unit_for_player(struct player *pplayer, int role);
-Unit_Type_id first_role_unit_for_player(struct player *pplayer, int role);
+Unit_Type_id best_role_unit_for_player(const struct player *pplayer, int role);
+Unit_Type_id first_role_unit_for_player(const struct player *pplayer, int 
role);
 
 void unit_types_free(void);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11724) Constifying common/unittype (more), Frédéric Brière <=