Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#8877) patch: design for generalized specialists
Home

[Freeciv-Dev] (PR#8877) patch: design for generalized specialists

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#8877) patch: design for generalized specialists
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 13 Dec 2004 09:32:37 -0800
Reply-to: bugs@xxxxxxxxxxx

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

Here is version 17 of the patch.  It is now ready to be applied as-is I
think.

-jason

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.445
diff -u -r1.445 packhand.c
--- client/packhand.c   13 Dec 2004 16:20:52 -0000      1.445
+++ client/packhand.c   13 Dec 2004 17:30:51 -0000
@@ -2594,6 +2594,9 @@
 {
   int i;
 
+  /* Must set num_specialist_types before iterating over them. */
+  game.rgame.num_specialist_types = packet->num_specialist_types;
+  game.rgame.default_specialist = packet->default_specialist;
   specialist_type_iterate(sp) {
     int *bonus = game.rgame.specialists[sp].bonus;
 
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.284
diff -u -r1.284 city.c
--- common/city.c       13 Dec 2004 16:23:30 -0000      1.284
+++ common/city.c       13 Dec 2004 17:30:51 -0000
@@ -41,7 +41,6 @@
 
 int city_tiles;
 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
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.184
diff -u -r1.184 city.h
--- common/city.h       13 Dec 2004 16:23:30 -0000      1.184
+++ common/city.h       13 Dec 2004 17:30:51 -0000
@@ -332,7 +332,6 @@
 
 extern struct citystyle *city_styles;
 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/fc_types.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/fc_types.h,v
retrieving revision 1.11
diff -u -r1.11 fc_types.h
--- common/fc_types.h   3 Dec 2004 09:39:40 -0000       1.11
+++ common/fc_types.h   13 Dec 2004 17:30:51 -0000
@@ -21,12 +21,6 @@
  * Nothing in this file should require anything else from the common/
  * directory! */
 
-enum specialist_type {
-  SP_ELVIS, SP_SCIENTIST, SP_TAXMAN, SP_LAST
-};
-#define SP_COUNT num_specialist_types
-#define SP_MAX SP_LAST /* Changing this breaks network compatibility. */
-
 enum output_type {
   O_FOOD, O_SHIELD, O_TRADE, O_GOLD, O_LUXURY, O_SCIENCE, O_LAST
 };
@@ -35,7 +29,7 @@
 
 typedef signed short Continent_id;
 typedef int Terrain_type_id;
-typedef enum specialist_type Specialist_type_id;
+typedef int Specialist_type_id;
 typedef int Impr_Type_id;
 typedef enum output_type Output_type_id;
 
@@ -45,4 +39,6 @@
 struct tile;
 struct unit;
 
+#define SP_MAX 20
+
 #endif /* FC__FC_TYPES_H */
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.164
diff -u -r1.164 game.h
--- common/game.h       7 Dec 2004 18:39:06 -0000       1.164
+++ common/game.h       13 Dec 2004 17:30:51 -0000
@@ -192,13 +192,16 @@
 
   /* values from game.ruleset */
   struct {
+    int num_specialist_types;
+    int default_specialist;
     struct specialist {
       char name[MAX_LEN_NAME];
       char short_name[MAX_LEN_NAME];
       int min_size;
       int bonus[O_MAX];
     } specialists[SP_MAX];
-#define DEFAULT_SPECIALIST SP_ELVIS
+#define SP_COUNT game.rgame.num_specialist_types
+#define DEFAULT_SPECIALIST game.rgame.default_specialist
     bool changable_tax;
     int forced_science; /* only relevant if !changable_tax */
     int forced_luxury;
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.75
diff -u -r1.75 packets.def
--- common/packets.def  13 Dec 2004 16:20:53 -0000      1.75
+++ common/packets.def  13 Dec 2004 17:30:52 -0000
@@ -967,6 +967,7 @@
 end
 
 PACKET_RULESET_GAME=97;sc,lsend
+  UINT8 default_specialist, num_specialist_types;
   STRING specialist_name[SP_MAX][MAX_LEN_NAME];
   STRING specialist_short_name[SP_MAX][MAX_LEN_NAME];
   UINT8 specialist_min_size[SP_MAX];
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.215
diff -u -r1.215 ruleset.c
--- server/ruleset.c    8 Dec 2004 16:53:53 -0000       1.215
+++ server/ruleset.c    13 Dec 2004 17:30:53 -0000
@@ -2550,11 +2550,6 @@
 
   /* Specialist options */
   specialist_names = secfile_lookup_str_vec(file, &nval, "specialist.types");
-  if (nval != SP_COUNT) {
-    freelog(LOG_FATAL, "There must be exactly %d types of specialist.",
-           SP_COUNT);
-    exit(EXIT_FAILURE);
-  }
 
   for (i = 0; i < nval; i++) {
     const char *name = specialist_names[i], *short_name;
@@ -2573,7 +2568,17 @@
                                            "specialist.%s_bonus_%s",
                                            name, get_output_identifier(o));
     } output_type_iterate_end;
+    if (game.rgame.specialists[i].min_size == 0
+       && game.rgame.default_specialist == -1) {
+      game.rgame.default_specialist = i;
+    }
   }
+  if (game.rgame.default_specialist == -1) {
+    freelog(LOG_FATAL, "You must give a min_size of 0 for at least one "
+           "specialist type (in %s).", filename);
+    exit(EXIT_FAILURE);
+  }
+  game.rgame.num_specialist_types = nval;
   free(specialist_names);
 
   game.rgame.changable_tax = 
@@ -2589,11 +2594,6 @@
     freelog(LOG_FATAL, "Forced taxes do not add up in ruleset!");
     exit(EXIT_FAILURE);
   }
-  if (game.rgame.specialists[SP_ELVIS].min_size > 0) {
-    freelog(LOG_FATAL, "Elvises must be available without a "
-           "city size restriction!");
-    exit(EXIT_FAILURE);
-  }
 
   /* City Parameters */
 
@@ -3143,6 +3143,8 @@
   int i;
   struct packet_ruleset_game misc_p;
 
+  misc_p.num_specialist_types = SP_COUNT;
+  misc_p.default_specialist = DEFAULT_SPECIALIST;
   specialist_type_iterate(sp) {
     int *bonus = game.rgame.specialists[sp].bonus;
 

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