Suggested extensions for switches.xml

Get help, info, news and advice about the Transport Tycoon Deluxe patch.

Moderator: TTDPatch Moderators

Post Reply
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Suggested extensions for switches.xml

Post 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...
Last edited by AndersI on 28 Jul 2006 11:25, edited 1 time in total.
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post 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" />
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Post 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)?
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post 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>
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Post 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?
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post by Patchman »

That would break TTDXC though, I'm pretty sure... well, it would break worse than it already is.
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Post by AndersI »

Does it survive a switches.xml with 'category' tags in it?
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post 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.
Attachments
switches.xml
(47.84 KiB) Downloaded 293 times
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Post 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?
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post 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.
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
Andrex
Tycoon
Tycoon
Posts: 1308
Joined: 22 Nov 2002 05:08
Location: AR
Contact:

Post 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.
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Post 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?
Patchman
Tycoon
Tycoon
Posts: 7575
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post 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."/>
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
Andrex
Tycoon
Tycoon
Posts: 1308
Joined: 22 Nov 2002 05:08
Location: AR
Contact:

Post 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" ... >
Post Reply

Return to “General TTDPatch”

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest