Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2000:
[Freeciv-Dev] patches: versioned ruleset indices (units) (PR#558)
Home

[Freeciv-Dev] patches: versioned ruleset indices (units) (PR#558)

[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] patches: versioned ruleset indices (units) (PR#558)
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Mon, 11 Sep 2000 00:29:57 -0700 (PDT)

Looking in data/civ1/buildings.ruleset, I noticed some lines like:

> name            = _("Airport")
> tech_req        = "Never"       ; remove when may have indefinite count of 
> improvements

However the issue of removing such entries raises issues with savegame
compatbility, because the savegame includes raw indices (in various
guises).  Eg, for this reason, data/civ1/units.ruleset says, of units:

; The number can be variable, up to 200.  
; However for the "official" rulesets, units should not be removed 
; because that would break backward compatability with savegames.

So far this restriction hasn't been too onerous, since the official
rulesets are rather static (at least as far as adding/removing units
etc), and there isn't a big problem having "placeholder" entries in
the civ1 rulesets.

But I got to thinking that it would be nice to remove this restriction
in a reasonably general way, which could be useful also for modpacks
etc.

The first attached patch (rs_indexing_units1a.diff) starts doing this
- in this patch just for units, as proof-of-concept etc, but the
machinery is fairly general, and this should be readily applicable to
all rulesets which have a "table" of elements.

The second patch (reindex_civ1_units.diff) removes the unused (civ2)
units from the civ1/units.ruleset, as an example of use.

The method used is that the ruleset file includes a version number
(small integer) for the current indexing scheme, and for each previous
version there is a vector of strings (maintained in the current
ruleset file) mapping the previous indicies to the current element
names.  The savegame includes the indexing version number at the time
the savegame was written, and when loading the savefile the
appropriate mapping is applied where necessary.

This scheme is fairly general (eg, allows adding, removing, renaming,
re-ordering) while making it easy to maintain backwards compatibility.
The main possible problem I see is that it could get a bit unwieldy if
the number of indexing versions get large - so don't do that :-)

-- David

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

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


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] patches: versioned ruleset indices (units) (PR#558), David Pfitzner <=