Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] Re: (PR#8795) change specialists into an array
Home

[Freeciv-Dev] Re: (PR#8795) change specialists into an array

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#8795) change specialists into an array
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 21 May 2004 14:24:37 -0700
Reply-to: rt@xxxxxxxxxxx

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

Jason Short wrote:

> This patch takes a step or two in that direction.  The ppl_elvis, 
> ppl_scientist, ppl_taxman fields of the city structure and city packet 
> are replaced with an array.  The specialist enum is used to index into 
> this array.

This patch does the same thing, but just changes the data structure not 
any of the code logic.

The first patch changes city.h and packets.def to use the array 
structure.  The conversion script makes the substitution.

The correctness of the results should be obvious.  But before committing 
the style should be fixed.

jason

Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.23
diff -u -r1.23 packets.def
--- common/packets.def  21 May 2004 19:03:43 -0000      1.23
+++ common/packets.def  21 May 2004 21:14:44 -0000
@@ -381,7 +381,7 @@
 
   UINT8 ppl_happy[5], ppl_content[5], ppl_unhappy[5], ppl_angry[5];
 
-  UINT8 ppl_elvis, ppl_scientist, ppl_taxman;
+  UINT8 specialists[SP_COUNT];
 
   UINT16 food_prod, shield_prod, trade_prod;
   SINT16 food_surplus, shield_surplus, tile_trade;
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.143
diff -u -r1.143 city.h
--- common/city.h       20 May 2004 21:38:53 -0000      1.143
+++ common/city.h       21 May 2004 21:14:44 -0000
@@ -26,7 +26,7 @@
 };
 
 enum specialist_type {
-  SP_ELVIS, SP_SCIENTIST, SP_TAXMAN
+  SP_ELVIS, SP_SCIENTIST, SP_TAXMAN, SP_COUNT
 };
 
 enum city_tile_type {
@@ -231,7 +231,7 @@
   int ppl_happy[5], ppl_content[5], ppl_unhappy[5], ppl_angry[5];
 
   /* Specialists */
-  int ppl_elvis, ppl_scientist, ppl_taxman;
+  int specialists[SP_COUNT];
 
   /* trade routes */
   int trade[NUM_TRADEROUTES], trade_value[NUM_TRADEROUTES];

Attachment: convert.sh
Description: Bourne shell script


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