Page 1 of 2
XML or INI
Posted: 22 Oct 2010, 23:02
by milo christiansen
If I were to write programs to convert the current data files to xml or ini format would anyone be interested?
Also, how hard would it be to make the game read a xml or ini file instead of comma delimited like it does now?
And which would be better for modders xml or ini?
Re: XML or INI
Posted: 22 Oct 2010, 23:33
by Per
It depends on the data which is more readable. Well, except that most XML is not really human readable. I think much of the data we have in CSV format is best suited in that format, and would be very verbose in any other.
Re: XML or INI
Posted: 23 Oct 2010, 00:03
by Zarel
Yeah, the only things we really need to do in that respect is rename the files to .csv (so they'll be opened automatically by spreadsheet programs), and add descriptive headers to the ones we haven't yet. Some of them might be more suited for INI, but CSV is only slightly less readable, easier to parse, and there's no real reason to change.
XML, on the other hand, is way overkill for anything we do in Warzone.
Re: XML or INI
Posted: 25 Oct 2010, 22:15
by milo christiansen
Zarel wrote:easier to parse
I agree with that

,but it would be kind of nice to have the files easier for humans to read.
After much consideration, I think that ini or renaming the files to csv would be the way to go.
It might not be that hard to set it to look for .csv files and if missing look for ini files. That way modders could use ether depending on preference and/or skill.
About descriptive headers, is there a way for me to help with that? I already did some research on the various fields for my stats editor and now that I've found the loading routines the rest should be easy to figure out.
And where are the stat files loaded? I know the routines are in stats.c, but where are they used?
Re: XML or INI
Posted: 26 Oct 2010, 23:52
by i-NoD
milo christiansen wrote:And where are the stat files loaded? I know the routines are in stats.c, but where are they used?
Short answer: they are used from
here when
this resource file (for example) is parsed.
Detailed answer: "I'm sorry. My responses are limited. You must ask the right questions." (c)

Re: XML or INI
Posted: 27 Oct 2010, 17:11
by milo christiansen
The short answer is fine

, thanks!
Re: XML or INI
Posted: 02 Nov 2010, 14:06
by Wibble199
I would be inter, I often wish to use XML to make a Flash project, related to WarZone 2100, however I gave up because of the sheer time I would need to make the XMLs (Including all the upgrades for each weapon, and which weapons go with which upgrade). Example:
Code: Select all
<Weapon>
<Name>Machinegun</Name>
<Type>Normal</Type>
<Damage>10</Damage>
<ROF>120</ROF>
<DPS>3</DPS>
<Accuracy_S>75</Accuracy_S>
<Accuracy_L>50</Accuracy_L>
<Range_S>4</Range_S>
<Range_L>6</Range_L>
<HP>75</HP>
<Weight>200</Weight>
<Descript>7.62mm machinegun\nBest Targets: Infantry, base structures, wheeled vehicles\nBody Points: Low</Descript>
<DamageUpgrade>MGDamageUpgrades</DamageUpgrade>
<ROFUpgrade>MGROFUpgrades</ROFUpgrade>
<AccuracyUpgrade>-1</AccuracyUpgrade>
</Weapon>
In the description, the '#NEWLINE#' tells flash to add a new line there.
Damage upgrade is MGDamageUpgrades because there is an XML file called MGDamageUpgrades.xml
ROF upgrade is MGROFUpgrades because there is an XML file called MGROFUpgrades.xml
Accuracy upgrade is -1 because it doesn't exist.
If you could write a program for this, I would be grateful for an eternity
Thanks, Wibble199

Re: XML or INI
Posted: 03 Nov 2010, 18:27
by MagickPanda
A lua or similar script language is more flexible and readable than both imo.
Re: XML or INI
Posted: 03 Nov 2010, 19:24
by milo christiansen
Maybe but these are stat lists not scripts. Lua is planed to replace WZScript, this would be a replacement for TXT files.
In any case this won't be done soon.
Re: XML or INI
Posted: 15 Nov 2010, 20:56
by milo christiansen
Challenges use ini don't they? Where can I get the documentation for the lib used?
Re: XML or INI
Posted: 15 Nov 2010, 22:37
by Safety0ff
milo christiansen wrote:Challenges use ini don't they? Where can I get the documentation for the lib used?
For the current lib:
http://developer.wz2100.net/browser/lib ... ctionary.h
http://developer.wz2100.net/browser/lib ... niparser.h
For the re-written/future interface:
http://developer.wz2100.net/ticket/2012
Re: XML or INI
Posted: 25 Jun 2011, 21:56
by Commander_Alt_F4
you can use QSettings for ini file or QDocDocument (requires XML module) for xml, since it uses qt
Re: XML or INI
Posted: 28 Jun 2011, 22:35
by milo christiansen
True... good idea, I sort of put a halt on this until I found time to find/write a good ini parser and now that I have one I need to find time to write a program to convert the existing CSV files.
I'm planing to use a sort of XML/INI hybrid called IML that looks something like this
Code: Select all
[section]
key:string=string value
; possible values (the part between : and =) are:
; string
; int
; float
; bool
; and DSV
; DSV is a special case. It is structured :DSV|= the char after DSV is the delimiter in this case |
; Delimiter Separated Value
; No value is considered a string
[/section]
The values are for special pre-processing and things like returning a list or vector from a read on a DSV key
so far the parser is a little incomplete and most of the value related stuff is unimplemented

but for basic reads of string values everything works.
Only one big problem, the parser was written before I learned how to write "real" parsers so its line based aka it only reads the first two chars on every line to determine the line type

so I will probably end up rewriting it before to long.
Also it heavily relies on QT so it wasn't really possible to use it until lately.
Now I just need to find the time...
Re: XML or INI
Posted: 30 Jun 2011, 00:25
by Commander_Alt_F4
well if i were you i would use QSettings instead and use a class that saves the output and initialises throught it
QSettings support grouping (you can see on the Docs)
ill use an example that i have on my free project
(think BackgroundColor and other variables as a QColor)
Code: Select all
QSettings settings(*initialisation code here*);
settings.beginGroup("Colors");
settings.setValue("Background",BackgroundColor->rgb()); //will outuput QRgb which is a typedef of unsigned int
settings.setValue("Foreground",ForegroundColor->rgb());
settings.setValue("Text",TextColor->rgb());
settings.setValue("Lines",LineColor->rgb());
settings.endGroup();
and the output will be
Code: Select all
[Colors]
Background=4281479730
Foreground=4284769380
Text=4291348680
Lines=4291348680
and
Code: Select all
QSettings settings(*initialisation code here*);
settings.beginGroup("Colors");
settings.setValue("Background",BackgroundColor->rgb()); //will outuput QRgb which is a typedef of unsigned int
settings.setValue("Foreground",ForegroundColor->rgb());
settings.setValue("Text",TextColor->rgb());
settings.setValue("Lines",LineColor->rgb());
settings.endGroup();
settings.beginGroup("Colors2"); // Same thing for example purposes
settings.setValue("Background",BackgroundColor->rgb()); //will outuput QRgb which is a typedef of unsigned int
settings.setValue("Foreground",ForegroundColor->rgb());
settings.setValue("Text",TextColor->rgb());
settings.setValue("Lines",LineColor->rgb());
settings.endGroup();
and the output will be
Code: Select all
[Colors]
Background=4281479730
Foreground=4284769380
Text=4291348680
Lines=4291348680
[Colors2]
Background=4281479730
Foreground=4284769380
Text=4291348680
Lines=4291348680
however
Code: Select all
QSettings settings(*initialisation code here*);
settings.beginGroup("Options");
settings.beginGroup("Colors");
settings.setValue("Background",BackgroundColor->rgb());
settings.setValue("Foreground",ForegroundColor->rgb());
settings.setValue("Text",TextColor->rgb());
settings.setValue("Lines",LineColor->rgb());
settings.endGroup();
settings.endGroup();
will output
Code: Select all
[Options]
Colors\Background=4281479730
Colors\Foreground=4284769380
Colors\Text=4291348680
Colors\Lines=4291348680
which can take some readability like doing this
Code: Select all
QSettings settings(*initialisation code here*);
settings.beginGroup("Options");
settings.beginGroup("Colors");
settings.setValue("Background",BackgroundColor->rgb());
settings.setValue("Foreground",ForegroundColor->rgb());
settings.setValue("Text",TextColor->rgb());
settings.setValue("Lines",LineColor->rgb());
settings.endGroup();
settings.beginGroup("Colors2"); //same thing for example purposes
settings.setValue("Background",BackgroundColor->rgb());
settings.setValue("Foreground",ForegroundColor->rgb());
settings.setValue("Text",TextColor->rgb());
settings.setValue("Lines",LineColor->rgb());
settings.endGroup();
settings.endGroup();
will output
Code: Select all
[Options]
Colors\Background=4281479730
Colors\Foreground=4284769380
Colors\Text=4291348680
Colors\Lines=4291348680
Colors2\Background=4281479730
Colors2\Foreground=4284769380
Colors2\Text=4291348680
Colors2\Lines=4291348680
note: they can be read like this (for the fist example):
Code: Select all
QSettings settings(*initialisation code here*);
settings.beginGroup("Options");
settings.beginGroup("Colors");
BackgroundColor->setRgb(settings.value("Background").toUInt());
ForegroundColor->setRgb(settings.value("Foreground").toUInt());
TextColor->setRgb(settings.value("Text").toUInt());
LineColor->setRgb(settings.value("Lines").toUInt());
settings.endGroup();
settings.endGroup();
note that is was just an idea...its always wise to have a small code to make it easier to find and fix errors
Re: XML or INI
Posted: 30 Jun 2011, 11:30
by Per
In master, the challenges are read (and written) using QSettings already.