Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11602) Const-ifying common/unit.c
Home

[Freeciv-Dev] (PR#11602) Const-ifying common/unit.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11602) Const-ifying common/unit.c
From: "Frédéric Brière" <fbriere@xxxxxxxxxxx>
Date: Sun, 19 Dec 2004 04:45:04 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch adds consts to most pointer arguments in common/unit.[hc].


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

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

Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.223
diff -u -r1.223 unit.c
--- common/unit.c       7 Dec 2004 18:01:12 -0000       1.223
+++ common/unit.c       19 Dec 2004 11:18:05 -0000
@@ -40,7 +40,7 @@
 FIXME: Use generalised improvements code instead of hardcoded
 wonder effects --RK
 ***************************************************************/
-int unit_move_rate(struct unit *punit)
+int unit_move_rate(const struct unit *punit)
 {
   int move_rate = 0;
   int base_move_rate = unit_type(punit)->move_rate 
@@ -95,7 +95,7 @@
 Whether a diplomat can move to a particular tile and perform a
 particular action there.
 **************************************************************************/
-bool diplomat_can_do_action(struct unit *pdiplomat,
+bool diplomat_can_do_action(const struct unit *pdiplomat,
                            enum diplomat_actions action, 
                            const struct tile *ptile)
 {
@@ -120,7 +120,7 @@
 If the action is DIPLOMAT_ANY_ACTION, checks whether there is any
 action the diplomat can perform at the tile.
 **************************************************************************/
-bool is_diplomat_action_available(struct unit *pdiplomat,
+bool is_diplomat_action_available(const struct unit *pdiplomat,
                                  enum diplomat_actions action, 
                                  const struct tile *ptile)
 {
@@ -185,7 +185,7 @@
 /**************************************************************************
 FIXME: Maybe we should allow airlifts between allies
 **************************************************************************/
-bool unit_can_airlift_to(struct unit *punit, struct city *pcity)
+bool unit_can_airlift_to(const struct unit *punit, const struct city *pcity)
 {
   if(punit->moves_left == 0)
     return FALSE;
@@ -210,7 +210,7 @@
 /****************************************************************************
   Return TRUE iff the unit is following client-side orders.
 ****************************************************************************/
-bool unit_has_orders(struct unit *punit)
+bool unit_has_orders(const struct unit *punit)
 {
   return punit->has_orders;
 }
@@ -218,7 +218,8 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool unit_can_help_build_wonder(struct unit *punit, struct city *pcity)
+bool unit_can_help_build_wonder(const struct unit *punit,
+                               const struct city *pcity)
 {
   if (!is_tiles_adjacent(punit->tile, pcity->tile)
       && !same_pos(punit->tile, pcity->tile))
@@ -235,7 +236,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool unit_can_help_build_wonder_here(struct unit *punit)
+bool unit_can_help_build_wonder_here(const struct unit *punit)
 {
   struct city *pcity = map_get_city(punit->tile);
   return pcity && unit_can_help_build_wonder(punit, pcity);
@@ -245,7 +246,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool unit_can_est_traderoute_here(struct unit *punit)
+bool unit_can_est_traderoute_here(const struct unit *punit)
 {
   struct city *phomecity, *pdestcity;
 
@@ -258,7 +259,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool unit_can_defend_here(struct unit *punit)
+bool unit_can_defend_here(const struct unit *punit)
 {
   if (is_ground_unit(punit)
       && is_ocean(map_get_terrain(punit->tile))) {
@@ -272,7 +273,7 @@
 Returns the number of free spaces for ground units. Can be 0 or negative.
 **************************************************************************/
 int ground_unit_transporter_capacity(const struct tile *ptile,
-                                    struct player *pplayer)
+                                    const struct player *pplayer)
 {
   int availability = 0;
 
@@ -295,7 +296,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-int get_transporter_capacity(struct unit *punit)
+int get_transporter_capacity(const struct unit *punit)
 {
   return unit_type(punit)->transport_capacity;
 }
@@ -303,7 +304,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool is_ground_units_transport(struct unit *punit)
+bool is_ground_units_transport(const struct unit *punit)
 {
   return (get_transporter_capacity(punit) > 0
          && !unit_flag(punit, F_MISSILE_CARRIER)
@@ -313,7 +314,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool is_air_units_transport(struct unit *punit)
+bool is_air_units_transport(const struct unit *punit)
 {
   return (get_transporter_capacity(punit) > 0
          && (unit_flag(punit, F_MISSILE_CARRIER)
@@ -323,7 +324,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool is_sailing_unit(struct unit *punit)
+bool is_sailing_unit(const struct unit *punit)
 {
   return (unit_type(punit)->move_type == SEA_MOVING);
 }
@@ -331,7 +332,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool is_air_unit(struct unit *punit)
+bool is_air_unit(const struct unit *punit)
 {
   return (unit_type(punit)->move_type == AIR_MOVING);
 }
@@ -339,7 +340,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool is_heli_unit(struct unit *punit)
+bool is_heli_unit(const struct unit *punit)
 {
   return (unit_type(punit)->move_type == HELI_MOVING);
 }
@@ -347,7 +348,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool is_ground_unit(struct unit *punit)
+bool is_ground_unit(const struct unit *punit)
 {
   return (unit_type(punit)->move_type == LAND_MOVING);
 }
@@ -355,7 +356,7 @@
 /**************************************************************************
   Is the unit capable of attacking?
 **************************************************************************/
-bool is_attack_unit(struct unit *punit)
+bool is_attack_unit(const struct unit *punit)
 {
   return (unit_type(punit)->attack_strength > 0);
 }
@@ -365,7 +366,7 @@
   and heli units can occupy empty cities -- see COULD_OCCUPY(punit).
   Some military units, like the Galleon, have no attack strength.
 **************************************************************************/
-bool is_military_unit(struct unit *punit)
+bool is_military_unit(const struct unit *punit)
 {
   return !unit_flag(punit, F_NONMIL);
 }
@@ -373,7 +374,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool is_diplomat_unit(struct unit *punit)
+bool is_diplomat_unit(const struct unit *punit)
 {
   return (unit_flag(punit, F_DIPLOMAT));
 }
@@ -381,7 +382,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-static bool is_ground_threat(struct player *pplayer, struct unit *punit)
+static bool is_ground_threat(struct player *pplayer, const struct unit *punit)
 {
   return (pplayers_at_war(pplayer, unit_owner(punit))
          && (unit_flag(punit, F_DIPLOMAT)
@@ -407,7 +408,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool is_field_unit(struct unit *punit)
+bool is_field_unit(const struct unit *punit)
 {
   return unit_flag(punit, F_FIELDUNIT);
 }
@@ -429,7 +430,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool kills_citizen_after_attack(struct unit *punit)
+bool kills_citizen_after_attack(const struct unit *punit)
 {
   return TEST_BIT(game.killcitizen, (int) (unit_type(punit)->move_type) - 1);
 }
@@ -503,7 +504,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool can_unit_change_homecity(struct unit *punit)
+bool can_unit_change_homecity(const struct unit *punit)
 {
   return punit->tile->city && punit->tile->city->owner == punit->owner;
 }
@@ -516,7 +517,7 @@
 
   The speed is multiplied by ACTIVITY_COUNT.
 **************************************************************************/
-int get_activity_rate(struct unit *punit)
+int get_activity_rate(const struct unit *punit)
 {
   int fact = get_unit_type(punit->type)->veteran[punit->veteran].power_fact;
 
@@ -537,7 +538,7 @@
 
   The speed is multiplied by ACTIVITY_COUNT.
 **************************************************************************/
-int get_activity_rate_this_turn(struct unit *punit)
+int get_activity_rate_this_turn(const struct unit *punit)
 {
   /* This logic is also coded in client/goto.c. */
   if (punit->moves_left > 0) {
@@ -552,7 +553,7 @@
   complete the activity at the given location.  This assumes no other
   worker units are helping out.
 **************************************************************************/
-int get_turns_for_activity_at(struct unit *punit,
+int get_turns_for_activity_at(const struct unit *punit,
                              enum unit_activity activity,
                              const struct tile *ptile)
 {
@@ -572,7 +573,7 @@
 Return whether the unit can be put in auto-mode.
 (Auto-settler for settlers, auto-attack for military units.)
 **************************************************************************/
-bool can_unit_do_auto(struct unit *punit) 
+bool can_unit_do_auto(const struct unit *punit) 
 {
   if (unit_flag(punit, F_SETTLERS)) {
     return TRUE;
@@ -638,7 +639,7 @@
 /****************************************************************************
   Return TRUE iff the given unit can be loaded into the transporter.
 ****************************************************************************/
-bool can_unit_load(struct unit *pcargo, struct unit *ptrans)
+bool can_unit_load(const struct unit *pcargo, const struct unit *ptrans)
 {
   /* This function needs to check EVERYTHING. */
 
@@ -694,7 +695,7 @@
   can_unit_exist_at_tile() to check this, unless the unit is unloading and
   moving at the same time.
 ****************************************************************************/
-bool can_unit_unload(struct unit *pcargo, struct unit *ptrans)
+bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
 {
   if (!pcargo || !ptrans) {
     return FALSE;
@@ -720,7 +721,7 @@
 special, have enough movepoints left and have not paradropped
 before in this turn.
 **************************************************************************/
-bool can_unit_paradrop(struct unit *punit)
+bool can_unit_paradrop(const struct unit *punit)
 {
   struct unit_type *utype;
 
@@ -751,7 +752,7 @@
   Basically if it is a bombarder, isn't being transported, and hasn't 
   moved this turn.
 **************************************************************************/
-bool can_unit_bombard(struct unit *punit)
+bool can_unit_bombard(const struct unit *punit)
 {
   if (!unit_flag(punit, F_BOMBARDER)) {
     return FALSE;
@@ -789,7 +790,8 @@
 /**************************************************************************
 ...
 **************************************************************************/
-bool can_unit_do_activity(struct unit *punit, enum unit_activity activity)
+bool can_unit_do_activity(const struct unit *punit,
+                         enum unit_activity activity)
 {
   return can_unit_do_activity_targeted(punit, activity, S_NO_SPECIAL);
 }
@@ -798,7 +800,7 @@
   Return whether the unit can do the targeted activity at its current
   location.
 **************************************************************************/
-bool can_unit_do_activity_targeted(struct unit *punit,
+bool can_unit_do_activity_targeted(const struct unit *punit,
                                   enum unit_activity activity,
                                   enum tile_special_type target)
 {
@@ -814,7 +816,7 @@
   autosettlers in server/settler.c. The code there does not use this
   function as it would be a major CPU hog.
 **************************************************************************/
-bool can_unit_do_activity_targeted_at(struct unit *punit,
+bool can_unit_do_activity_targeted_at(const struct unit *punit,
                                      enum unit_activity activity,
                                      enum tile_special_type target,
                                      const struct tile *ptile)
@@ -1050,7 +1052,7 @@
 /**************************************************************************
   Return text describing the current unit's activity.
 **************************************************************************/
-const char *unit_activity_text(struct unit *punit)
+const char *unit_activity_text(const struct unit *punit)
 {
   static char text[64];
   const char *moves_str;
@@ -1128,7 +1130,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-struct unit *unit_list_find(struct unit_list *This, int id)
+struct unit *unit_list_find(const struct unit_list *This, int id)
 {
   unit_list_iterate(*This, punit) {
     if (punit->id == id) {
@@ -1206,7 +1208,7 @@
 ****************************************************************************/
 static void count_carrier_capacity(int *airall, int *misonly,
                                   const struct tile *ptile,
-                                  struct player *pplayer,
+                                  const struct player *pplayer,
                                   bool count_units_with_extra_fuel)
 {
   *airall = *misonly = 0;
@@ -1241,7 +1243,7 @@
 Returns the number of free spaces for missiles. Can be 0 or negative.
 **************************************************************************/
 int missile_carrier_capacity(const struct tile *ptile,
-                            struct player *pplayer,
+                            const struct player *pplayer,
                             bool count_units_with_extra_fuel)
 {
   int airall, misonly;
@@ -1259,7 +1261,7 @@
 Can be 0 or negative.
 **************************************************************************/
 int airunit_carrier_capacity(const struct tile *ptile,
-                            struct player *pplayer,
+                            const struct player *pplayer,
                             bool count_units_with_extra_fuel)
 {
   int airall, misonly;
@@ -1420,7 +1422,8 @@
 /**************************************************************************
 ...
 **************************************************************************/
-static bool zoc_ok_move_gen(struct unit *punit, const struct tile *ptile1,
+static bool zoc_ok_move_gen(const struct unit *punit,
+                           const struct tile *ptile1,
                            const struct tile *ptile2)
 {
   return can_step_taken_wrt_to_zoc(punit->type, unit_owner(punit),
@@ -1431,7 +1434,7 @@
   Convenience wrapper for zoc_ok_move_gen(), using the unit's (x,y)
   as the starting point.
 **************************************************************************/
-bool zoc_ok_move(struct unit *punit, const struct tile *ptile)
+bool zoc_ok_move(const struct unit *punit, const struct tile *ptile)
 {
   return zoc_ok_move_gen(punit, punit->tile, ptile);
 }
@@ -1440,7 +1443,8 @@
   Return TRUE iff the unit can "exist" at this location.  This means it can
   physically be present on the tile (without the use of a transporter).
 ****************************************************************************/
-bool can_unit_exist_at_tile(struct unit *punit, const struct tile *ptile)
+bool can_unit_exist_at_tile(const struct unit *punit,
+                           const struct tile *ptile)
 {
   if (ptile->city) {
     return TRUE;
@@ -1465,7 +1469,8 @@
   indefinitely on its own (without a transporter).  Units that require fuel
   or have a danger of drowning are examples of non-survivable units.
 ****************************************************************************/
-bool can_unit_survive_at_tile(struct unit *punit, const struct tile *ptile)
+bool can_unit_survive_at_tile(const struct unit *punit,
+                             const struct tile *ptile)
 {
   if (!can_unit_exist_at_tile(punit, ptile)) {
     return FALSE;
@@ -1492,7 +1497,8 @@
 /**************************************************************************
   Convenience wrapper for test_unit_move_to_tile.
 **************************************************************************/
-bool can_unit_move_to_tile(struct unit *punit, const struct tile *dst_tile,
+bool can_unit_move_to_tile(const struct unit *punit,
+                          const struct tile *dst_tile,
                           bool igzoc)
 {
   return MR_OK == test_unit_move_to_tile(punit->type, unit_owner(punit),
@@ -1595,7 +1601,7 @@
   base_unsafe_terrain_loss_pct directly.
 **************************************************************************/
 int unit_loss_pct(struct player *pplayer, const struct tile *ptile,
-                 struct unit *punit)
+                 const struct unit *punit)
 {
   int loss_pct = 0;
 
@@ -1624,7 +1630,7 @@
   Triremes have a varying loss percentage based on tech and veterancy
   level.
 **************************************************************************/
-int base_trireme_loss_pct(struct player *pplayer, struct unit *punit)
+int base_trireme_loss_pct(struct player *pplayer, const struct unit *punit)
 {
   if (get_player_bonus(pplayer, EFT_NO_SINK_DEEP) > 0) {
     return 0;
@@ -1640,7 +1646,8 @@
 /**************************************************************************
   All units except air units have a flat 15% chance of being lost.
 **************************************************************************/
-int base_unsafe_terrain_loss_pct(struct player *pplayer, struct unit *punit)
+int base_unsafe_terrain_loss_pct(struct player *pplayer,
+                                const struct unit *punit)
 {
   return is_air_unit(punit) ? 0 : 15;
 }
@@ -1776,7 +1783,7 @@
 /****************************************************************************
   Expensive function to check how many units are in the transport.
 ****************************************************************************/
-int get_transporter_occupancy(struct unit *ptrans)
+int get_transporter_occupancy(const struct unit *ptrans)
 {
   int occupied = 0;
 
@@ -1792,7 +1799,7 @@
 /****************************************************************************
   Find a transporter at the given location for the unit.
 ****************************************************************************/
-struct unit *find_transporter_for_unit(struct unit *pcargo,
+struct unit *find_transporter_for_unit(const struct unit *pcargo,
                                       const struct tile *ptile)
 { 
   unit_list_iterate(ptile->units, ptrans) {
@@ -1813,7 +1820,8 @@
 
   Note that this function is strongly tied to unittools.c:upgrade_unit().
 ***************************************************************************/
-enum unit_upgrade_result test_unit_upgrade(struct unit *punit, bool is_free)
+enum unit_upgrade_result test_unit_upgrade(const struct unit *punit,
+                                          bool is_free)
 {
   struct player *pplayer = unit_owner(punit);
   Unit_Type_id to_unittype = can_upgrade_unittype(pplayer, punit->type);
@@ -1856,7 +1864,7 @@
   most callers can use directly.
 **************************************************************************/
 enum unit_upgrade_result get_unit_upgrade_info(char *buf, size_t bufsz,
-                                              struct unit *punit)
+                                              const struct unit *punit)
 {
   struct player *pplayer = unit_owner(punit);
   enum unit_upgrade_result result = test_unit_upgrade(punit, FALSE);
Index: common/unit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v
retrieving revision 1.131
diff -u -r1.131 unit.h
--- common/unit.h       7 Dec 2004 18:01:12 -0000       1.131
+++ common/unit.h       19 Dec 2004 11:18:05 -0000
@@ -208,38 +208,40 @@
   } \
 }
 
-struct unit *unit_list_find(struct unit_list *This, int id);
+struct unit *unit_list_find(const struct unit_list *This, int id);
 
 void unit_list_sort_ord_map(struct unit_list *This);
 void unit_list_sort_ord_city(struct unit_list *This);
 
-bool diplomat_can_do_action(struct unit *pdiplomat,
+bool diplomat_can_do_action(const struct unit *pdiplomat,
                            enum diplomat_actions action,
                            const struct tile *ptile);
-bool is_diplomat_action_available(struct unit *pdiplomat,
+bool is_diplomat_action_available(const struct unit *pdiplomat,
                                  enum diplomat_actions action,
                                  const struct tile *ptile);
 
-int unit_move_rate(struct unit *punit);
-bool unit_can_help_build_wonder(struct unit *punit, struct city *pcity);
-bool unit_can_help_build_wonder_here(struct unit *punit);
-bool unit_can_est_traderoute_here(struct unit *punit);
-bool unit_can_defend_here(struct unit *punit);
-bool unit_can_airlift_to(struct unit *punit, struct city *pcity);
-bool unit_has_orders(struct unit *punit);
-
-bool can_unit_load(struct unit *punit, struct unit *ptrans);
-bool can_unit_unload(struct unit *punit, struct unit *ptrans);
-bool can_unit_paradrop(struct unit *punit);
-bool can_unit_bombard(struct unit *punit);
-bool can_unit_change_homecity(struct unit *punit);
+int unit_move_rate(const struct unit *punit);
+bool unit_can_help_build_wonder(const struct unit *punit,
+                               const struct city *pcity);
+bool unit_can_help_build_wonder_here(const struct unit *punit);
+bool unit_can_est_traderoute_here(const struct unit *punit);
+bool unit_can_defend_here(const struct unit *punit);
+bool unit_can_airlift_to(const struct unit *punit, const struct city *pcity);
+bool unit_has_orders(const struct unit *punit);
+
+bool can_unit_load(const struct unit *punit, const struct unit *ptrans);
+bool can_unit_unload(const struct unit *punit, const struct unit *ptrans);
+bool can_unit_paradrop(const struct unit *punit);
+bool can_unit_bombard(const struct unit *punit);
+bool can_unit_change_homecity(const struct unit *punit);
 const char *get_activity_text(enum unit_activity activity);
 bool can_unit_continue_current_activity(struct unit *punit);
-bool can_unit_do_activity(struct unit *punit, enum unit_activity activity);
-bool can_unit_do_activity_targeted(struct unit *punit,
+bool can_unit_do_activity(const struct unit *punit,
+                         enum unit_activity activity);
+bool can_unit_do_activity_targeted(const struct unit *punit,
                                   enum unit_activity activity,
                                   enum tile_special_type target);
-bool can_unit_do_activity_targeted_at(struct unit *punit,
+bool can_unit_do_activity_targeted_at(const struct unit *punit,
                                      enum unit_activity activity,
                                      enum tile_special_type target,
                                      const struct tile *ptile);
@@ -247,44 +249,44 @@
 void set_unit_activity_targeted(struct unit *punit,
                                enum unit_activity new_activity,
                                enum tile_special_type new_target);
-int get_activity_rate(struct unit *punit);
-int get_activity_rate_this_turn(struct unit *punit);
-int get_turns_for_activity_at(struct unit *punit,
+int get_activity_rate(const struct unit *punit);
+int get_activity_rate_this_turn(const struct unit *punit);
+int get_turns_for_activity_at(const struct unit *punit,
                              enum unit_activity activity,
                              const struct tile *ptile);
-bool can_unit_do_auto(struct unit *punit); 
+bool can_unit_do_auto(const struct unit *punit); 
 bool is_unit_activity_on_tile(enum unit_activity activity,
                              const struct tile *ptile);
 enum tile_special_type get_unit_tile_pillage_set(const struct tile *ptile);
-bool is_attack_unit(struct unit *punit);
-bool is_military_unit(struct unit *punit);           /* !set !dip !cara */
-bool is_diplomat_unit(struct unit *punit);
+bool is_attack_unit(const struct unit *punit);
+bool is_military_unit(const struct unit *punit);           /* !set !dip !cara 
*/
+bool is_diplomat_unit(const struct unit *punit);
 bool is_square_threatened(struct player *pplayer, const struct tile *ptile);
-bool is_field_unit(struct unit *punit);              /* ships+aero */
+bool is_field_unit(const struct unit *punit);              /* ships+aero */
 bool is_hiding_unit(const struct unit *punit);
-bool is_sailing_unit(struct unit *punit);
-bool is_air_unit(struct unit *punit);
-bool is_heli_unit(struct unit *punit);
-bool is_ground_unit(struct unit *punit);
+bool is_sailing_unit(const struct unit *punit);
+bool is_air_unit(const struct unit *punit);
+bool is_heli_unit(const struct unit *punit);
+bool is_ground_unit(const struct unit *punit);
 #define COULD_OCCUPY(punit) \
   ((is_ground_unit(punit) || is_heli_unit(punit)) && is_military_unit(punit))
 bool can_unit_add_to_city (struct unit *punit);
 bool can_unit_build_city (struct unit *punit);
 bool can_unit_add_or_build_city (struct unit *punit);
 enum add_build_city_result test_unit_add_or_build_city(struct unit *punit);
-bool kills_citizen_after_attack(struct unit *punit);
+bool kills_citizen_after_attack(const struct unit *punit);
 
-const char *unit_activity_text(struct unit *punit);
+const char *unit_activity_text(const struct unit *punit);
 int ground_unit_transporter_capacity(const struct tile *ptile,
-                                    struct player *pplayer);
-int get_transporter_capacity(struct unit *punit);
-bool is_ground_units_transport(struct unit *punit);
-bool is_air_units_transport(struct unit *punit);
+                                    const struct player *pplayer);
+int get_transporter_capacity(const struct unit *punit);
+bool is_ground_units_transport(const struct unit *punit);
+bool is_air_units_transport(const struct unit *punit);
 int missile_carrier_capacity(const struct tile *ptile,
-                            struct player *pplayer,
+                            const struct player *pplayer,
                             bool count_units_with_extra_fuel);
 int airunit_carrier_capacity(const struct tile *ptile,
-                            struct player *pplayer,
+                            const struct player *pplayer,
                             bool count_units_with_extra_fuel);
 
 struct player *unit_owner(const struct unit *punit);
@@ -299,19 +301,20 @@
                                     struct player *pplayer);
 
 int unit_loss_pct(struct player *pplayer, const struct tile *ptile,
-                 struct unit *punit);
-int base_trireme_loss_pct(struct player *pplayer, struct unit *punit);
+                 const struct unit *punit);
+int base_trireme_loss_pct(struct player *pplayer, const struct unit *punit);
 int base_unsafe_terrain_loss_pct(struct player *pplayer,
-                                struct unit *punit);
+                                const struct unit *punit);
 
 bool is_my_zoc(struct player *unit_owner, const struct tile *ptile);
 bool unit_being_aggressive(struct unit *punit);
 bool can_step_taken_wrt_to_zoc(Unit_Type_id type, struct player *unit_owner,
                               const struct tile *src_tile,
                               const struct tile *dst_tile);
-bool can_unit_exist_at_tile(struct unit *punit, const struct tile *ptile);
-bool can_unit_survive_at_tile(struct unit *punit, const struct tile *ptile);
-bool can_unit_move_to_tile(struct unit *punit, const struct tile *ptile,
+bool can_unit_exist_at_tile(const struct unit *punit, const struct tile 
*ptile);
+bool can_unit_survive_at_tile(const struct unit *punit,
+                             const struct tile *ptile);
+bool can_unit_move_to_tile(const struct unit *punit, const struct tile *ptile,
                           bool igzoc);
 enum unit_move_result test_unit_move_to_tile(Unit_Type_id type,
                                             struct player *unit_owner,
@@ -320,7 +323,7 @@
                                             const struct tile *dst_tile,
                                             bool igzoc);
 bool unit_type_really_ignores_zoc(Unit_Type_id type);
-bool zoc_ok_move(struct unit *punit, const struct tile *ptile);
+bool zoc_ok_move(const struct unit *punit, const struct tile *ptile);
 
 bool is_build_or_clean_activity(enum unit_activity activity);
 
@@ -329,12 +332,13 @@
 void destroy_unit_virtual(struct unit *punit);
 void free_unit_orders(struct unit *punit);
 
-int get_transporter_occupancy(struct unit *ptrans);
-struct unit *find_transporter_for_unit(struct unit *pcargo,
+int get_transporter_occupancy(const struct unit *ptrans);
+struct unit *find_transporter_for_unit(const struct unit *pcargo,
                                       const struct tile *ptile);
 
-enum unit_upgrade_result test_unit_upgrade(struct unit *punit, bool is_free);
+enum unit_upgrade_result test_unit_upgrade(const struct unit *punit,
+                                          bool is_free);
 enum unit_upgrade_result get_unit_upgrade_info(char *buf, size_t bufsz,
-                                              struct unit *punit);
+                                              const struct unit *punit);
 
 #endif  /* FC__UNIT_H */

[Prev in Thread] Current Thread [Next in Thread]