Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2004:
[Freeciv-Dev] (PR#9400) miscellaneous functions take const parameters
Home

[Freeciv-Dev] (PR#9400) miscellaneous functions take const parameters

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9400) miscellaneous functions take const parameters
From: "Jason Dorje Short" <jdorje@xxxxxxxxxxx>
Date: Thu, 15 Jul 2004 20:56:41 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9400 >

This more targeted patch turns the parameters of some seemingly random 
functions const.

These functions are (some of) the ones whom, in the effects patch, are 
called by other functions that already have their parameters const.

jason

Index: common/improvement.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.c,v
retrieving revision 1.39
diff -u -r1.39 improvement.c
--- common/improvement.c        14 Jul 2004 22:50:24 -0000      1.39
+++ common/improvement.c        16 Jul 2004 03:54:24 -0000
@@ -244,7 +244,7 @@
 /**************************************************************************
  Returns 1 if the improvement is obsolete, now also works for wonders
 **************************************************************************/
-bool improvement_obsolete(struct player *pplayer, Impr_Type_id id) 
+bool improvement_obsolete(const struct player *pplayer, Impr_Type_id id) 
 {
   if (!tech_exists(improvement_types[id].obsolete_by)) {
     return FALSE;
Index: common/improvement.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.h,v
retrieving revision 1.26
diff -u -r1.26 improvement.h
--- common/improvement.h        14 Jul 2004 22:50:24 -0000      1.26
+++ common/improvement.h        16 Jul 2004 03:54:24 -0000
@@ -144,7 +144,7 @@
 /* FIXME: remove improvement_variant() when gen-impr obsoletes */
 int improvement_variant(Impr_Type_id id);  
 
-bool improvement_obsolete(struct player *pplayer, Impr_Type_id id);
+bool improvement_obsolete(const struct player *pplayer, Impr_Type_id id);
 bool improvement_redundant(struct player *pplayer, const struct city *pcity,
                           Impr_Type_id id, bool want_to_build);
 bool wonder_obsolete(Impr_Type_id id);
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.179
diff -u -r1.179 map.c
--- common/map.c        16 Jul 2004 02:10:34 -0000      1.179
+++ common/map.c        16 Jul 2004 03:54:25 -0000
@@ -1312,7 +1312,8 @@
 /***************************************************************
  Returns TRUE iff the given tile has the given special.
 ***************************************************************/
-bool tile_has_special(struct tile *ptile, enum tile_special_type special)
+bool tile_has_special(const struct tile *ptile,
+                     enum tile_special_type special)
 {
   return contains_special(ptile->special, special);
 }
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.194
diff -u -r1.194 map.h
--- common/map.h        16 Jul 2004 02:10:34 -0000      1.194
+++ common/map.h        16 Jul 2004 03:54:25 -0000
@@ -353,7 +353,7 @@
 
 /* special testing */
 bool map_has_special(int x, int y, enum tile_special_type to_test_for);
-bool tile_has_special(struct tile *ptile,
+bool tile_has_special(const struct tile *ptile,
                      enum tile_special_type to_test_for);
 bool contains_special(enum tile_special_type all,
                      enum tile_special_type to_test_for);
Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.141
diff -u -r1.141 player.c
--- common/player.c     13 Jul 2004 21:54:17 -0000      1.141
+++ common/player.c     16 Jul 2004 03:54:26 -0000
@@ -324,7 +324,8 @@
  return pointer to the city struct.  Else return NULL.
  Now always uses fast idex_lookup_city.
 ***************************************************************/
-struct city *player_find_city_by_id(struct player *pplayer, int city_id)
+struct city *player_find_city_by_id(const struct player *pplayer,
+                                   int city_id)
 {
   struct city *pcity = idex_lookup_city(city_id);
   
@@ -340,7 +341,8 @@
  return pointer to the unit struct.  Else return NULL.
  Uses fast idex_lookup_city.
 ***************************************************************/
-struct unit *player_find_unit_by_id(struct player *pplayer, int unit_id)
+struct unit *player_find_unit_by_id(const struct player *pplayer,
+                                   int unit_id)
 {
   struct unit *punit = idex_lookup_unit(unit_id);
   
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.115
diff -u -r1.115 player.h
--- common/player.h     23 Apr 2004 22:58:06 -0000      1.115
+++ common/player.h     16 Jul 2004 03:54:26 -0000
@@ -238,8 +238,10 @@
 
 bool player_owns_city(struct player *pplayer, struct city *pcity);
 
-struct city *player_find_city_by_id(struct player *pplayer, int city_id);
-struct unit *player_find_unit_by_id(struct player *pplayer, int unit_id);
+struct city *player_find_city_by_id(const struct player *pplayer,
+                                   int city_id);
+struct unit *player_find_unit_by_id(const struct player *pplayer,
+                                   int unit_id);
 
 bool player_in_city_radius(struct player *pplayer, int x, int y);
 bool player_owns_active_wonder(struct player *pplayer,
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.72
diff -u -r1.72 tech.c
--- common/tech.c       12 Jul 2004 17:22:03 -0000      1.72
+++ common/tech.c       16 Jul 2004 03:54:26 -0000
@@ -46,7 +46,8 @@
 /**************************************************************************
 ...
 **************************************************************************/
-enum tech_state get_invention(struct player *pplayer, Tech_Type_id tech)
+enum tech_state get_invention(const struct player *pplayer,
+                             Tech_Type_id tech)
 {
   assert(tech >= 0 || tech < game.num_tech_types);
 
Index: common/tech.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.h,v
retrieving revision 1.43
diff -u -r1.43 tech.h
--- common/tech.h       31 Jan 2004 17:52:41 -0000      1.43
+++ common/tech.h       16 Jul 2004 03:54:26 -0000
@@ -107,7 +107,8 @@
 
 BV_DEFINE(tech_vector, A_LAST);
 
-enum tech_state get_invention(struct player *pplayer, Tech_Type_id tech);
+enum tech_state get_invention(const struct player *pplayer,
+                             Tech_Type_id tech);
 void set_invention(struct player *pplayer, Tech_Type_id tech,
                   enum tech_state value);
 void update_research(struct player *pplayer);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9400) miscellaneous functions take const parameters, Jason Dorje Short <=