Complete.Org: Mailing Lists: Archives: freeciv-dev: July 1999:
Re: [Freeciv-Dev] rulesets; was terrain ruleset implementation
Home

Re: [Freeciv-Dev] rulesets; was terrain ruleset implementation

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jjm@xxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] rulesets; was terrain ruleset implementation
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sun, 18 Jul 1999 00:30:26 +1000 (EST)

Jeff Mallatt wrote:

> I started off to make the various terrain types more like those in Civ2...
> .. What I wound up doing was implementing the terrain ruleset!

Wow.  Huge ;-)

> This is a very involved patch, touching around fifty files and modifying
> the network protocol.  The work was based on a CVS update I did on July
> 14th -- hopefully the code hasn't migrated too far in three days ;-)

Yeah right ;-)  There is lots changing right now, but its also a
good time to make changes!  And I'm in a "check it in" mood :-)

But one thing I regret about rulesets was making each ruleset
_require_ a separate directory.  So before a data/civ2 dir gets
added, I suggest the attached patch, which allows just adding 
data/civ2_terrain.ruleset (while still also allowing
the old form too, for existing rulesets/modpacks).

(Actually, the attached patch is not complete, because the new 
alternative should also be documented; eg in stdinhand.c, 
README.rulesets etc.)

There is also another thing I regret about the ruleset 
implementation: the format...

I used a "tabular" format, which is compact and allows
getting a good overview of the data.  But it falls down
when the table gets too big, as is often the case.  Then
either the table has long lines (ugly), or must be split 
into multiple tables (ditto ugly, and the data for a single
item gets spread around).  It also makes it hard to make 
clean changes, since changing or adding an entry or column 
causes diff to replace the whole line/table.

I'm now inclined to favour a less compact format, eg, 
something more like the old-style savefile format:

[unit0]
name = "Settlers"
tech_req = "None"
obsolete_by = "Engineers"
graphic = 24
move_type = "land"
...
flags = "Settlers", "NonMil"

[unit50]
name = "Explorer"

etc.

Actually due to some magic in the registry stuff you could
almost do something like this without even breaking ruleset 
file compatability, but the names would be a bit strange, 
eg I think:

[units]
u10.name = "Settlers"
u10.tech_required = "None"
u20.graphics = 24
...
u150.name = "Explorer"

etc.

Whether this is worth changing for existing ruleset files
is questionable (but maybe, since there are not many modpacks
out there and they would be easy to convert), but for new 
rulesets (or when breaking compatability) I would like to 
consider not repeating past mistakes...  Or was I right the 
first time and now I'm going crazy? :-)

(Luckily this issue is all pretty trivial and well-confined 
compared to the othe changes involved in actually implementing
a new ruleset such as governments/terrain.)

Regards,
-- David
diff -u -r --exclude-from exclude freeciv-cvs/server/ruleset.c 
fc-adv/server/ruleset.c
--- freeciv-cvs/server/ruleset.c        Sat Jun 12 17:40:12 1999
+++ fc-adv/server/ruleset.c     Sun Jul 18 00:09:49 1999
@@ -55,17 +55,22 @@
 static char *openload_ruleset_file(struct section_file *file,
                                   char *subdir, char *whichset)
 {
-  char filename[512], *dfilename;
+  char filename1[512], filename2[512], *dfilename;
 
-  sprintf(filename, "%s/%s.ruleset", subdir, whichset);
-  dfilename = datafilename(filename);
+  sprintf(filename1, "%s_%s.ruleset", subdir, whichset);
+  dfilename = datafilename(filename1);
   if (!dfilename) {
-    freelog(LOG_FATAL, "Could not find readable ruleset file \"%s\""
-                      " in data path", filename);
-    freelog(LOG_FATAL, "The data path may be set via"
-                      " the environment variable FREECIV_PATH");
-    freelog(LOG_FATAL, "Current data path is: \"%s\"", datafilename(NULL));
-    exit(1);
+    sprintf(filename2, "%s/%s.ruleset", subdir, whichset);
+    dfilename = datafilename(filename2);
+    if (!dfilename) {
+      freelog(LOG_FATAL, "Could not find readable ruleset file \"%s\"",
+             filename1);
+      freelog(LOG_FATAL, "or \"%s\" in data path", filename2);
+      freelog(LOG_FATAL, "The data path may be set via"
+             " the environment variable FREECIV_PATH");
+      freelog(LOG_FATAL, "Current data path is: \"%s\"", datafilename(NULL));
+      exit(1);
+    }
   }
   if (!section_file_load(file,dfilename)) {
     freelog(LOG_FATAL, "Could not load ruleset file %s", dfilename);

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