Detecting errors with XML

Joined
Feb 6, 2006
Messages
796
I'm new in modding CiV (although with a certain experience with Civ 4).
I'm trying to create XMLs, and change the civs in the game, by totally replacing the existing ones with new ones.
Now, in the setup screen, I can see the correct list of civilizations, but as soon as I pick one and start the game, there's a crash and the game exits.

I thought this could be due to foreign keys from other tables (like Improvements, which have a CivilizationType field), so I'm looking for all the possible references, and deleting or updating them.
However, after a number of changes and tries, there's still the crash.
Is there a way to know WHICH is the cause of the error? (a log file, an option to display errors, etc...)
 
1> FireTuner. Use it, learn it, love it. When you start up a game it'll tell you if there's something horribly wrong with your XML when it tries to load it. The text might be hard to find, but it'll be there.
2> Turn on all of the log files. (Some are disabled by default, you have to tweak your .ini settings I think.) I never bother with these.
3> Post this in the main Creation & Customization forum, not the SDK/Lua subforum. It's a bit more active over there.
4> When all else fails, the brute-force way to debug XML is to bisect it. That is, comment out half of the XML file, like so:
Code:
uncommented stuff
<!-- commented stuff -->
and see if it works. If so, then the problem is in the commented half; if not, the problem is in the uncommented half. Lather, rinse, repeat, until you've narrowed down the problem.

But there might be a much simpler answer in your specific case: Deleting entries in ANY table does not generally work well. It's tied to two different parts of how Civ5's XML is done.
First, the autoincremented indices just don't function correctly once you start deleting. Notice how the first entry in many tables has <ID>0</ID>? That's to give the table a starting point, and then each subsequent entry's ID increases by 1. But if you delete a unit, it doesn't fill in the gap with the next added unit; they still get added to the end as normal. And if the final table has holes in it, you'd often get crashes, although I think they partially fixed that in the last patch.
Second, it's possible that you're missing a reference somewhere else. Like you deleted the Civilizations, but didn't delete the table of unique units for those civilizations, or the traits for them, or the leaders. Basically, if you delete America as a civ, then you need to make sure that absolutely nothing remaining explicitly references CIVILIZATION_AMERICA.

Deletion can be done, in certain tables and under certain conditions, if you're careful. But it's easy to get it wrong, and the general effect is what you've described.
 
Thanks a lot for all your suggestions!

By the way, I've discovered the cause of the crashes.
When I delete existing civilizations and leaders, I must be careful NOT to delete barbarians and minor civilizations as well!!
Here're the deletes I do. In this way, the game starts correctly.

Code:
	<Leaders>
		<Delete IconAtlas="LEADER_ATLAS"/>
	</Leaders>
	<Leader_Traits>
		<Delete/>
	</Leader_Traits>
	<Civilizations>
		<Delete Playable="true"/>
	</Civilizations>

note: I have also to delete all related entries too, of course!

Spoiler :

<Improvements>
<Update>
<Set CivilizationType="NULL"/>
<Where Type="IMPROVEMENT_TERRACE_FARM"/>
</Update>
<Update>
<Set CivilizationType="NULL"/>
<Where Type="IMPROVEMENT_MOAI"/>
</Update>
</Improvements>
<Civilization_BuildingClassOverrides>
<Delete/>
</Civilization_BuildingClassOverrides>
<Civilization_UnitClassOverrides>
<Delete/>
</Civilization_UnitClassOverrides>
<Leader_MajorCivApproachBiases>
<Delete/>
</Leader_MajorCivApproachBiases>
<Leader_MinorCivApproachBiases>
<Delete/>
</Leader_MinorCivApproachBiases>
<Civilization_CityNames>
<Delete/>
</Civilization_CityNames>
<Civilization_FreeTechs>
<Delete/>
</Civilization_FreeTechs>
<Civilization_DisableTechs>
<Delete/>
</Civilization_DisableTechs>
<Civilization_FreeBuildingClasses>
<Delete/>
</Civilization_FreeBuildingClasses>
<Civilization_Start_Along_Ocean>
<Delete/>
</Civilization_Start_Along_Ocean>
<Civilization_Start_Along_River>
<Delete/>
</Civilization_Start_Along_River>
<Civilization_Start_Region_Priority>
<Delete/>
</Civilization_Start_Region_Priority>
<Civilization_Start_Region_Avoid>
<Delete/>
</Civilization_Start_Region_Avoid>
<Diplomacy_Responses>
<Delete/>
</Diplomacy_Responses>
 
Back
Top Bottom