Sun 20 Mar 2011 06:20:44 PM UTC, original submission:
I've been adding a backwards compatibility layer in the form of the FileCompat class.
It culminates in a program called lordsawar-upgrade-file (src/upgrade-file.cpp)
The way it works is that various classes register support for backwards compatibility for their file types.
And then they also register support for backwards compatibility "upgrade" functions that convert a file from version X to version Y.
The FileCompat class walks the upgrade through the various version changes.
What isn't implemented is how that the files are actually upgraded.
I figure it can be done in one of two ways:
1. the XSLT way, where i do a transformation to the xml files.
2. or by putting the C++ code that reads in that version
into it's own library.
Here's an example of what i'm dealing with:
The xml format for items just changed in 0.2.1.
if <d_bonus> in <itemproto> contains a value of ItemProto::STEAL_GOLD,
then there needs to be another entity called <d_steal_gold_percent/>.
The <d_bonus> value can look like:
"ItemProto::STEAL_GOLD | ItemProto::BURN_BRIDGE"
So we're not dealing with exact text matches.
(Before I was just having the item steal 50% of an opponent's gold when it was "used", and now it can be any percent the map designer picks.)
Copying the old C++ classes into a library doesn't scale well. The tarball would get really huge if I were doing backwards compatibility of 10 versions.
Also, the xslt transformations would require another build and run-time dependency. And lastly, I'm not familiar with xslt at all.
|