Page 1 of 1
Suggested extensions for switches.xml
Posted: 22 Jul 2006 10:05
by AndersI
There are no textual descriptions for the 'Category' field in 'switches.xml'. Would it be possible to extend the xml file to contain this? Maybe like:
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<categories>
...
<INFST_ROADS num="11" name="Infrastructure, roads"/>
<DIFFICULTY num="16" name="Difficulty"/>
...
</categories>
<switches version="2.5 beta 6 (Windows)" ID="0250003C">
<range name="abandonedroads" min="0" max="2" default="0" cmdline="-YA" defstate="on" category="INFST_ROADS" desc=... />
<range name="aibuildairchance" min="0" max="65535" default="5041" cmdline="" defstate="off" category="DIFFICULTY" desc=... />
...
</switches>
This would make it easier to produce a configuration program driven completely by the 'switches.xml' file, no hardcoded dependencies in the program...
Posted: 22 Jul 2006 16:10
by Patchman
OK, since categories are supposed to be a tree, how about something like this:
Code: Select all
<category id="INFST" parent="" name="Infrastructure" />
<category id="INFST_RAIL" parent="INFST" name="Rails" />
<category id="INFST_RAIL_SIGNAL" parent="INFST_RAIL" name="Signalling" />
Posted: 22 Jul 2006 17:05
by AndersI
I'm not completely sure I understand where this would come in, but I still have some comments/questions:
Why code a tree structure with a 'parent' ref. when we have a tree structured language (XML)?
This would let INSTF_RAIL be both a leaf and a root, is that good?
The CategoryNum is stored in every switch, shouldn't it be a part of the individual category (database normalization)?
Posted: 22 Jul 2006 17:11
by Patchman
OK, then like this?
Code: Select all
...
<category num="7" name="INFST" desc="Infrastructure">
<category num="8" name="INFST_BRIDGE" desc="Bridges" />
<category num="9" name="INFST_RAIL" desc="Rails">
<category num="10" name="INFST_RAIL_SIGNAL" desc="Signalling" />
</category>
</category>
Posted: 22 Jul 2006 17:35
by AndersI
Yes, that looks better to me. The logical continuation would be to have the switches inside the categories - then everything is the tree from the very beginning

but that's maybe too big a change of the xml file? Which tools are currently using this file?
Posted: 22 Jul 2006 17:37
by Patchman
That would break TTDXC though, I'm pretty sure... well, it would break worse than it already is.
Posted: 22 Jul 2006 17:39
by AndersI
Does it survive a switches.xml with 'category' tags in it?
Posted: 22 Jul 2006 18:35
by Patchman
Probably not, so to get category info now, you have to start TTDPatch with "-!S-S-", i.e. double the S- debug switch. This will start working in the next nightly/beta, with older versions this will give you the old format, which you may complain about and abort
Sample switches.xml is attached. It also has the name of the manual page on the wiki, so you can create a "click here for more info" link by opening "
http://wiki.ttdpatch.net/tiki-index.php?page=%s" where %s is the manpage property.
Posted: 28 Jul 2006 21:11
by AndersI
DaleStan in the TTDPC thread wrote:Put the tgr* and towngrowth* switches (except for towngrowthratemode) in their own category,
I agree on this.
It is possible to enter invalid digts into the mountains and curves field"
Each digit of moresteam must be in the range 0..5, rather than the number as a whole being limited to fifty-five
This would need a new kind of switch type descriptor, like a bitswitch but with (single digit?) decimal values for each part.
It is invalid to have the sum of the three aibuild*chance switches exceed 65535.
The XML today has no information about dependencies between switches. Is this desirable/doable?
Posted: 28 Jul 2006 22:05
by Patchman
AndersI wrote:DaleStan in the TTDPC thread wrote:Put the tgr* and towngrowth* switches (except for towngrowthratemode) in their own category,
I agree on this.
Done.
It is possible to enter invalid digts into the mountains and curves field"
Each digit of moresteam must be in the range 0..5, rather than the number as a whole being limited to fifty-five
This would need a new kind of switch type descriptor, like a bitswitch but with (single digit?) decimal values for each part.
Something like a "validdigits" property might work. If present, only the given digits may be used in the value. Is that acceptable?
It is invalid to have the sum of the three aibuild*chance switches exceed 65535.
The XML today has no information about dependencies between switches. Is this desirable/doable?
Technically it's not invalid, it just won't work as intended. I wouldn't worry about it too much.
Posted: 29 Jul 2006 00:56
by Andrex
The attached switches.xml with categories is perfectly valid for TTDXC, of course. To test it, replace current switches.xml with it and TTDXC will retrieve the info from it, the file is rebuilt only with a new version detection.
Posted: 29 Jul 2006 09:48
by AndersI
Patchman wrote:Something like a "validdigits" property might work. If present, only the given digits may be used in the value. Is that acceptable?
Sounds good enough for me.
Andrex wrote:The attached switches.xml with categories is perfectly valid for TTDXC, of course. To test it, replace current switches.xml with it and TTDXC will retrieve the info from it, the file is rebuilt only with a new version detection.
Great, then there's really no need for the -!S-S- kludge, is there, Patchman? Just let -!S- generate the new kind of XML?
Posted: 29 Jul 2006 16:31
by Patchman
AndersI wrote:Andrex wrote:The attached switches.xml with categories is perfectly valid for TTDXC, of course. To test it, replace current switches.xml with it and TTDXC will retrieve the info from it, the file is rebuilt only with a new version detection.
Great, then there's really no need for the -!S-S- kludge, is there, Patchman? Just let -!S- generate the new kind of XML?
OK. I can't run TTDXC on Wine so I couldn't test it with the new format, but if you say it works with the <category> tags then I'll just make that the default from now on.
I'm just wondering if Andrex really means the <category> tags and not just the categorynum="11" category="INFST_ROADS" properties in the switch tags, as beta 7 writes it.
I've added the "validdigits" now:
Code: Select all
<range name="curves" min="0" max="3333" default="120" cmdline="-c" defstate="on" validdigits="0123" manpage="NewCurveAndMountainHandling" desc="`%s' (%s) sets curve speeds to normal (0), faster (1), fastest (2) or realistic (3). One digit for each of railroad, monorail, maglev and road vehicles. Default 0120."/>
Posted: 30 Jul 2006 21:50
by Andrex
Patchman wrote:I'm just wondering if Andrex really means the <category> tags and not just the categorynum="11" category="INFST_ROADS" properties in the switch tags, as beta 7 writes it.
The XML parsing from TTDXC is quite standard, and will keep working as long as the initial switch structure is mantained, this is:
Code: Select all
<bool name="switchname"... >
<range name="switchname" ... >