Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2000:
[Freeciv-Dev] patch: allow includes in registry files (PR#240)
Home

[Freeciv-Dev] patch: allow includes in registry files (PR#240)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] patch: allow includes in registry files (PR#240)
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sat, 29 Jan 2000 05:34:12 -0800 (PST)

I'm not sure if this is the best time for this, with the 
impending feature freeze, but I've written the code and I think 
its interesting, so here it is.

These patches allow generic "include" lines in registry files.  
The main intention is to allow reduced duplication in ruleset 
files, potentially both in the distribution and for personal 
modified rulesets.  Eg, after these patches I can have modified
Settlers by having a file, eg, ~/.freeciv/my_units.ruleset, 
containing just:
 
| !include "default/units.ruleset"
| 
| [unit_settlers]
| graphic       = "u.fanatics"
| graphic_alt   = "u.settlers"
| build_cost    = 10
| attack        = 5

(BTW, not "#include", because '#' is a comment character in these 
files; specified filename is searched in FREECIV_PATH.)

Another useful application I think is nations.ruleset, where 
having the individual nations (and misc city names) in individual 
files (via includes) would allow easy variants with civ1_nations, 
civ2_nations, my_favourite_nations, etc.

On the other hand there are pros and cons for both duplication 
and include-by-reference.  Eg, if we had civ1 units as default
plus changes via includes, then:
 - eg, fix to helptext doesn't have to be made twice;
but:
 - eg, someone adds a new "default" unit, then have to remember 
to disable that unit (by an override to tech req, bit ugly) in 
the "civ1" ruleset or it won't by "civ1" any more. 

That is, not using includes means more duplication, including
duplication of work when making changes, but reduces the risk 
of accidently inheriting inappropriate changes when an included 
file is changed.  So includes are not necessarily a good thing 
in all instances... 

The patches:

reg_includes.diff
   - Allow includes, mainly implemented internally in inputfile.c; 
one complication is that this means datafilename() static buffer 
(iffy interface...) can change during section_file_load(), so 
some small changes elsewhere to account for that.

reg_dup_sections.diff
   - As in above example with Settlers, will be useful to allow 
"introducing" the same section multiple times, and this patch 
allows this.  (Ie, [unit_settlers] tag multiple times to mean
the same section.)

reg_dup_entries.diff
   - Recent change to allow duplicate tags in tilespec files
didn't actually allow duplicate entries in general in registry
files.  This patch allows duplicate entries in general (eg, to 
override entries for Settlers in above example), except when 
reading savefiles (where a duplicate entry probably indicates 
that something is wrong in the code which writes the savefiles).

Regards,
-- David

Attachment: reg_includes.diff.gz
Description: GNU Zip compressed data

Attachment: reg_dup_sections.diff.gz
Description: GNU Zip compressed data

Attachment: reg_dup_entries.diff.gz
Description: GNU Zip compressed data


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] patch: allow includes in registry files (PR#240), David Pfitzner <=