How much trouble would a new XML field be?

Joined
Jun 27, 2007
Messages
2,248
Location
Hamilton, Ontario
In the global warming code it searched for features that grow to use them for global warming defence and had this comment:
Code:
// hack, but we don't want to add new XML field in the patch just for this
Now I wanted to do some more stuff which I could probably just do by adding to GlobalDefinesAlt.xml, by defining the features then defining values (specifically how much each feature adds to global warming defence) I want to use for them, but I was wondering why they didn't add a new XML field to CIV4FeatureInfos.xml and if I shouldn't either.
 
For Firaxis, adding a new XML field would have been trivial. I suspect they didn't add it because they didn't want to include a new XML file itself. Whether that was to be kinder to mods that modified that same file or some other reason, I have no idea.

This thread was created to get information about adding a few XML fields to CvTechInfos, and it should be a good place to start for information. Given the C++ work you've been doing lately, I don't anticipate that you'll have much trouble with this.
 
Main issue with Firaxis adding a new field to the XML is that they have to update all of the officially supported Mods/scenarios to account for it. That can get to be a headache and a half (especially since Firaxis likes to avoid making XML fields optional). The actual process of adding the field though is, as Emperor states, trivial work.
 
That can get to be a headache and a half (especially since Firaxis likes to avoid making XML fields optional).

This is exactly what I was alluding to, but I hadn't considered all of their other mods as well. The XML files would be so much smaller if they left out elements with default values, but I suspect they leave them in to make it easier for modders to understand their XML.
 
I went looking for where to add things to get a new xml field by searching for TurnDamage. I found three files that looked like they were for set up and not using TurnDamage for something and copied it:

CyInfoInterface2.cpp:
Code:
		.def("getTurnDamage", &CvFeatureInfo::getTurnDamage, "int ()")
		.def("getWarmingDefense", &CvFeatureInfo::getWarmingDefense, "int ()")
		
		.def("isNoCoast", &CvFeatureInfo::isNoCoast, "bool ()")

CvInfos.h:
Code:
	int m_iTurnDamage;
	int m_iWarmingDefense;
	
	bool m_bNoCoast;

CvInfos.cpp:
Code:
	pXML->GetChildXmlValByName(&m_iTurnDamage, "iTurnDamage");
	pXML->GetChildXmlValByName(&m_iWarmingDefense, "iWarmingDefense");
	pXML->GetChildXmlValByName(&m_iAppearanceProbability, "iAppearance");
It compiles fine (a complete rebuild to make sure it does everything) and the game will run it but if I try and add the field to CIV4FeatureInfos.xml:

Code:
			<iTurnDamage>0</iTurnDamage>
			<iWarmingDefense>0</iWarmingDefense>
			<bNoCoast>0</bNoCoast>
I get dozens of error messages saying something like "was expecting bNoCoast", and then the game uses no features even in the civilopedia. I put the new field after TurnDamage instead of at the end because it seems like similar fields are grouped together (integers, bools, arrays) and I didn't know if that grouping was important.
So did I miss a file or an entry I was supposed to make or was there an error in what I did make?
 
You also have to add it to the CIV4_____Schema.xml file which is referenced at the top of the XML file (for Features it is probably CIV4TerrainSchema.xml), whatever the file is, it is referenced at the head of the XML and contained in the same folder. It informs XML what to expect to find in the file
 
Top Bottom