Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11287) make use of SP_MAX
Home

[Freeciv-Dev] (PR#11287) make use of SP_MAX

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11287) make use of SP_MAX
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 1 Dec 2004 11:18:11 -0800
Reply-to: rt@xxxxxxxxxxx

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

This patch:

1.  Changes SP_COUNT to be a (const) variable.
2.  Uses SP_MAX in all the static places where SP_COUNT is currently used.
3.  Makes O_COUNT const as well (just a small fix).

SP_MAX is currently 3.  Changing it will break network compatibility.

-jason

Index: client/cityrepdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/cityrepdata.c,v
retrieving revision 1.41
diff -u -r1.41 cityrepdata.c
--- client/cityrepdata.c        30 Nov 2004 08:37:02 -0000      1.41
+++ client/cityrepdata.c        1 Dec 2004 19:13:48 -0000
@@ -548,7 +548,7 @@
 
   specialist_type_iterate(sp) {
     struct city_report_spec *p = &city_report_specs[i];
-    static char explanation[SP_COUNT][128];
+    static char explanation[SP_MAX][128];
 
     p->show = FALSE;
     p->width = 2;
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.91
diff -u -r1.91 tilespec.h
--- client/tilespec.h   20 Nov 2004 17:45:52 -0000      1.91
+++ client/tilespec.h   1 Dec 2004 19:13:48 -0000
@@ -166,7 +166,7 @@
      * sprites, as defined by the tileset. */
     int count;
     struct Sprite *sprite[MAX_NUM_CITIZEN_SPRITES];
-  } citizen[NUM_TILES_CITIZEN], specialist[SP_COUNT];
+  } citizen[NUM_TILES_CITIZEN], specialist[SP_MAX];
   struct {
     struct Sprite
       *solar_panels,
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.263
diff -u -r1.263 city.c
--- common/city.c       30 Nov 2004 08:37:03 -0000      1.263
+++ common/city.c       1 Dec 2004 19:13:49 -0000
@@ -40,7 +40,8 @@
 struct citystyle *city_styles = NULL;
 
 int city_tiles;
-Output_type_id num_output_types = O_LAST;
+const Output_type_id num_output_types = O_LAST;
+const Specialist_type_id num_specialist_types = SP_LAST;
 
 /**************************************************************************
   Return TRUE if the given city coordinate pair is "valid"; that is, if it
@@ -2334,7 +2335,7 @@
 const char *specialists_string(const int *specialists)
 {
   size_t len = 0;
-  static char buf[5 * SP_COUNT];
+  static char buf[5 * SP_MAX];
 
   specialist_type_iterate(sp) {
     char *separator = (len == 0) ? "" : "/";
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.171
diff -u -r1.171 city.h
--- common/city.h       30 Nov 2004 08:37:03 -0000      1.171
+++ common/city.h       1 Dec 2004 19:13:49 -0000
@@ -25,8 +25,8 @@
 enum specialist_type {
   SP_ELVIS, SP_SCIENTIST, SP_TAXMAN, SP_LAST
 };
-#define SP_COUNT SP_LAST
-#define SP_MAX SP_LAST
+#define SP_COUNT num_specialist_types
+#define SP_MAX SP_LAST /* Changing this breaks network compatibility. */
 
 enum city_tile_type {
   C_TILE_EMPTY, C_TILE_WORKER, C_TILE_UNAVAILABLE
@@ -36,7 +36,7 @@
   O_FOOD, O_SHIELD, O_TRADE, O_GOLD, O_LUXURY, O_SCIENCE, O_LAST
 };
 #define O_COUNT num_output_types
-#define O_MAX O_LAST
+#define O_MAX O_LAST /* Changing this breaks network compatibility. */
 
 enum city_options {
   /* The first 4 are whether to auto-attack versus each unit move_type
@@ -240,7 +240,7 @@
   int ppl_happy[5], ppl_content[5], ppl_unhappy[5], ppl_angry[5];
 
   /* Specialists */
-  int specialists[SP_COUNT];
+  int specialists[SP_MAX];
 
   /* trade routes */
   int trade[NUM_TRADEROUTES], trade_value[NUM_TRADEROUTES];
@@ -346,7 +346,8 @@
 };                              /* not incl. wall and occupied tiles */
 
 extern struct citystyle *city_styles;
-extern Output_type_id num_output_types;
+extern const Output_type_id num_output_types;
+extern const Specialist_type_id num_specialist_types;
 
 /* get 'struct city_list' and related functions: */
 #define SPECLIST_TAG city
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.162
diff -u -r1.162 game.h
--- common/game.h       30 Nov 2004 06:54:06 -0000      1.162
+++ common/game.h       1 Dec 2004 19:13:49 -0000
@@ -198,7 +198,7 @@
       char short_name[MAX_LEN_NAME];
       int min_size;
       int bonus[O_MAX];
-    } specialists[SP_COUNT];
+    } specialists[SP_MAX];
 #define DEFAULT_SPECIALIST SP_ELVIS
     bool changable_tax;
     int forced_science; /* only relevant if !changable_tax */
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.61
diff -u -r1.61 packets.def
--- common/packets.def  30 Nov 2004 06:54:06 -0000      1.61
+++ common/packets.def  1 Dec 2004 19:13:49 -0000
@@ -395,7 +395,7 @@
 
   UINT8 ppl_happy[5], ppl_content[5], ppl_unhappy[5], ppl_angry[5];
 
-  UINT8 specialists[SP_COUNT];
+  UINT8 specialists[SP_MAX];
 
   UINT16 food_prod, shield_prod, trade_prod;
   SINT16 food_surplus, shield_surplus, tile_trade;
@@ -971,11 +971,11 @@
 end
 
 PACKET_RULESET_GAME=97;sc,lsend
-  STRING specialist_name[SP_COUNT][MAX_LEN_NAME];
-  STRING specialist_short_name[SP_COUNT][MAX_LEN_NAME]; add-cap(short_spec)
-  UINT8 specialist_min_size[SP_COUNT];
-  UINT8 specialist_bonus_old[SP_COUNT]; remove-cap(spec_multi)
-  UINT8 specialist_bonus[SP_COUNT * O_MAX]; add-cap(spec_multi)
+  STRING specialist_name[SP_MAX][MAX_LEN_NAME];
+  STRING specialist_short_name[SP_MAX][MAX_LEN_NAME]; add-cap(short_spec)
+  UINT8 specialist_min_size[SP_MAX];
+  UINT8 specialist_bonus_old[SP_MAX]; remove-cap(spec_multi)
+  UINT8 specialist_bonus[SP_MAX * O_MAX]; add-cap(spec_multi)
   BOOL changable_tax;
   UINT8 forced_science;
   UINT8 forced_luxury;
Index: common/aicore/cm.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.h,v
retrieving revision 1.12
diff -u -r1.12 cm.h
--- common/aicore/cm.h  26 Nov 2004 09:49:12 -0000      1.12
+++ common/aicore/cm.h  1 Dec 2004 19:13:49 -0000
@@ -47,7 +47,7 @@
   int surplus[O_MAX];
 
   bool worker_positions_used[CITY_MAP_SIZE][CITY_MAP_SIZE];
-  int specialists[SP_COUNT];
+  int specialists[SP_MAX];
 };
 
 void cm_init(void);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11287) make use of SP_MAX, Jason Short <=