Is it possible to add new xml files?

kipkuhmi

Warlord
Joined
Aug 8, 2007
Messages
131
Hi everybody,

I've been wondering if it is possible to add new xml files for my mod. E.g. I would call it "CIV4OlympicInfos.xml", with CIV4GameInfoSchema.xml as a reference.

Now everytime I try it out I get a bunchful of xml loading errors. But I don't know if I've just made a mistake or if it is simply not possible to add such a new file. If the latter aplies, there's no sense in keeping on trying.

So if someone knows if its theoretically possible or not, or knows a mod where it has been done, I would appreciate it.

Thanks in advance!
 
The skinny of it is fairly simple: You are getting errors right now most likely because you didn't do the Schema properly. The easy approach is to create your own fresh schema file instead of trying to utilize one that already exists. Keeps you from accidentally duplicating entries which already exist.


That is just to get the XML to work nicely. To get the DLL side of things, you'll have a LOT of work to do in CvInfos and a little work to handle in CvXMLLoadUtilitySet.

As stated, the best way to approach it really is to copy how another XML file was designed. If something else contains a lot of the same information you plan to have available in the new file, copy it to save yourself some time. Otherwise, choose a small file and copy it, then refer to the bigger files when you need help on adding a specific field.

CvBonusClassInfo is about as short as you can get, that shows you the bare minimum you can get away with.



For some of the questions that will come up:

CvInfoBase::~CvInfoBase() is a good place to start looking. The functions in here are allowed in all other files "free of charge" Hence you won't see other files trying to create a load/access routine for Type, Civilopedia or the other fields listed in here, because you don't need it.


If you are only creating basic lists of things (just need a Type and a Desc, maybe a Civilopedia) you can get away with designing a BasicInfos type of file. These are special in that they don't contain anything which isn't listed in the InfoBase.


XML is done in 3 "readpasses" if needed. First pass loads the Type and all the numbers. Second pass is required if it refers to itself (promotionprereqs in promotioninfos) and the third pass is needed if it refers to another XML file which is loaded after itself during the routine in CvXMLLoadUtilitySet (typically because each file refers to the other one, so one of them has to have a 3rd pass. Otherwise you just place the new file after everything that it refers to and before anything that will refer to it).
 
Wow, guys. Thanks for all that help. I hope I have the time tonight to try out your hints.
I'll then report if it worked.
 
Back
Top Bottom