Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#13046) clean up specialists in the ruleset
Home

[Freeciv-Dev] (PR#13046) clean up specialists in the ruleset

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#13046) clean up specialists in the ruleset
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Wed, 11 May 2005 15:05:13 -0700
Reply-to: bugs@xxxxxxxxxxx

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

> [jdorje - Wed May 11 20:53:16 2005]:
> 
> This patch cleans up the specialists in the cities.ruleset to use a
> grid, like every other type of element does.  This makes the ruleset
> more readible and the loading code shorter.
> 
> The non-specialist-related parameters that were in the [specialist]
> section I moved into the [parameters] section.
> 
> (Note, this patch is a few days old.  I don't know if it still applies.)

Here is an updated patch that works on current CVS. Will commit ASAP.



Index: data/default/cities.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/cities.ruleset,v
retrieving revision 1.18
diff -u -u -r1.18 cities.ruleset
--- data/default/cities.ruleset 10 May 2005 19:08:55 -0000      1.18
+++ data/default/cities.ruleset 11 May 2005 22:01:26 -0000
@@ -11,44 +11,55 @@
 description="Cities data for Freeciv"
 options="1.9"
 
-; Configure the effect of specialists. Each specialist contributes
-; the given amount of its special kind of value (luxury for elvis,
-; research for scientist and gold for taxman). You can set
-; changable_tax to zero to disallow players setting the taxrate
-; for themselves. In this case, the values in the forced_ fields
-; apply instead, modified by government restrictions. The min_size
-; fields restrict setting specialists to this type before the
-; the city is of a certain size.
-[specialist]
-
-types = _("elvis"), _("scientist"), _("taxman")
-elvis_short_name = _("?Elvis:E")
-elvis_req      =
+; A specialist is a city citizen who is not a tile worker.  Usually the
+; player can control what specialist each citizen is, so long as the
+; requirements for that specialist are met.
+;
+; Below are the entries for the specialists, one per specialist type.
+; The tag name (in [specialist_*]) doesn't matter so long as it's unique.
+; For each specialist the following fields may be set:
+;
+; 
+; name         = name as seen by user 
+; short_name    = one-character "short name" used (for instance) in cityrep
+; reqs         = requirements to have the specialist pick (see
+;                effects.ruleset and README.effects for help on requirements)
+
+[specialist_elvis]
+name           = _("elvis")
+short_name     = _("?Elvis:E")
+reqs           =
     { "type", "name", "range"
 ; Nothing
     }
-scientist_short_name = _("?Scientist:S")
-scientist_req  =
+
+[specialist_scientist]
+name           = _("scientist")
+short_name     = _("?Scientist:S")
+reqs           =
     { "type", "name", "range"
       "MinSize", "5", "City"
     }
 
-taxman_short_name = _("?Taxman:T")
-taxman_req     =
+[specialist_taxman]
+name           = _("taxman")
+short_name     = _("?Taxman:T")
+reqs           =
     { "type", "name", "range"
       "MinSize", "5", "City"
     }
 
-changable_tax = 1
-;forced_science = 0
-;forced_luxury = 100
-;forced_gold = 0
-
 [parameters]
 add_to_size_limit  = 8         ; cities >= this cannot be added to.
 angry_citizens = 1              ; set to zero to disable angry citizens
 celebrate_size_limit = 3        ; cities >= can celebrate
 
+changable_tax = 1              ; set to zero to disallow changing of tax rates
+
+;forced_science = 0            ; set these fields when changeable_tax is 
turned off
+;forced_luxury = 100
+;forced_gold = 0
+
 ;
 ; City styles define the way cities are drawn
 ;
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.263
diff -u -u -r1.263 ruleset.c
--- server/ruleset.c    11 May 2005 20:03:10 -0000      1.263
+++ server/ruleset.c    11 May 2005 22:01:28 -0000
@@ -2248,31 +2248,27 @@
 **************************************************************************/
 static void load_ruleset_cities(struct section_file *file)
 {
-  char **styles, *replacement;
+  char **styles, **sec, *replacement;
   int i, nval;
   const char *filename = secfile_filename(file);
-  char **specialist_names;
+  char *item;
 
   (void) check_ruleset_capabilities(file, "+1.9", filename);
 
   /* Specialist options */
-  specialist_names = secfile_lookup_str_vec(file, &nval, "specialist.types");
+  sec = secfile_get_secnames_prefix(file, "specialist_", &nval);
 
   for (i = 0; i < nval; i++) {
-    const char *name = specialist_names[i], *short_name;
     struct specialist *s = &specialists[i];
     struct requirement_vector *reqs;
-    char sub[MAX_LEN_NAME + 4];
 
-    sz_strlcpy(s->name, name);
-    short_name
-      = secfile_lookup_str_default(file, name,
-                                  "specialist.%s_short_name", name);
-    sz_strlcpy(s->short_name, short_name);
+    item = secfile_lookup_str(file, "%s.name", sec[i]);
+    sz_strlcpy(s->name, item);
 
-    my_snprintf(sub, sizeof(sub), "%s_req", name);
-    reqs = lookup_req_list(file, "specialist", sub);
+    item = secfile_lookup_str_default(file, s->name, "%s.short_name", sec[i]);
+    sz_strlcpy(s->short_name, item);
 
+    reqs = lookup_req_list(file, sec[i], "reqs");
     requirement_vector_copy(&s->reqs, reqs);
 
     if (requirement_vector_size(&s->reqs) == 0 && DEFAULT_SPECIALIST == -1) {
@@ -2285,37 +2281,32 @@
     exit(EXIT_FAILURE);
   }
   SP_COUNT = nval;
-  free(specialist_names);
+  free(sec);
+
+  /* City Parameters */
 
   game.info.celebratesize = 
     secfile_lookup_int_default(file, GAME_DEFAULT_CELEBRATESIZE,
                                "parameters.celebratesize");
-
+  game.info.add_to_size_limit =
+    secfile_lookup_int_default(file, 9, "parameters.add_to_size_limit");
+  game.info.angrycitizen =
+    secfile_lookup_bool_default(file, GAME_DEFAULT_ANGRYCITIZEN,
+                                "parameters.angry_citizens");
   game.info.changable_tax = 
-    secfile_lookup_bool_default(file, TRUE, "specialist.changable_tax");
+    secfile_lookup_bool_default(file, TRUE, "parameters.changable_tax");
   game.info.forced_science = 
-    secfile_lookup_int_default(file, 0, "specialist.forced_science");
+    secfile_lookup_int_default(file, 0, "parameters.forced_science");
   game.info.forced_luxury = 
-    secfile_lookup_int_default(file, 100, "specialist.forced_luxury");
+    secfile_lookup_int_default(file, 100, "parameters.forced_luxury");
   game.info.forced_gold = 
-    secfile_lookup_int_default(file, 0, "specialist.forced_gold");
+    secfile_lookup_int_default(file, 0, "parameters.forced_gold");
   if (game.info.forced_science + game.info.forced_luxury
       + game.info.forced_gold != 100) {
     freelog(LOG_FATAL, "Forced taxes do not add up in ruleset!");
     exit(EXIT_FAILURE);
   }
 
-  /* City Parameters */
-
-  game.info.add_to_size_limit =
-    secfile_lookup_int_default(file, 9, "parameters.add_to_size_limit");
-
-  /* Angry citizens */
-
-  game.info.angrycitizen =
-    secfile_lookup_bool_default(file, GAME_DEFAULT_ANGRYCITIZEN,
-                                "parameters.angry_citizens");
-
   /* City Styles ... */
 
   styles = secfile_get_secnames_prefix(file, "citystyle_", &nval);

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