[BTS] Separate XML files for Civilizations

Inthegrave

Warlord
Joined
May 28, 2019
Messages
165
Couldn't find a answer for this using the forum search function.
I want to create separate XML files for Civs, like for example America_CIV4CivilizationInfos.xml, America_CIV4LeaderHeadInfos, America_CIV4ArtDefines and so on.
Every attempt I did at this doesn't seem to work. I want to do this for better file management while modding.
Some of these files get huge and it would be nice to be able to manage Civs better doing it this way.
Currently the only way that works for me is to add civs into the normal files.

I am using ROM AND from http://anewdawn.sourceforge.net/ as my base.
 

Thanks a lot for this, this is a godsend. And it's simple to do.
Although I'm having a very small problem, my leaders are not alphabetized in the dropdown menu when selecting a custom game. Is there any way to fix this?
For example John Curtin appears near the top of the list with the A's.

Another question I have is can it affect performance using multiple XMLs via Modular loading instead of having all information in one XML?
If so what method is better for performance?
 
Last edited:
I suspect that that the leaders are not sorted (unless you do it manually) so they are probably ordered the same way as their entries in XML.

Problem is I'm using separate leader XML's for each civilization, so I'm guessing I'm screwed. Funnily enough the Civilopedia alphabetizes everything just fine.

I have the same problem with units in the world builder menu, the units added through modular loading get thrown at the end of the list.
I like how they are organized by class but it seems you can only do that if you do it by having all your added units in the CIV4UnitInfos.
 
I suspect that that the leaders are not sorted (unless you do it manually) so they are probably ordered the same way as their entries in XML.
Problem is I'm using separate leader XML's for each civilization, so I'm guessing I'm screwed.
Regarding order, the game does the same for all xml files meaning what I write here applies to units, buildings and so on as well as leaders. At runtime the game has one ordered list. If the order matter to the game or not depends entirely on the game, but the xml loading code makes an ordered list for each file.

The order is simple: whenever a new leader is read, it will add that leader to the end of the list. It starts by reading the main file (not a module. Will read vanilla if none is supplied). Here it will read the leaders in the order they are written.

Modules are then read and I think they are read alphabetically based on their path names. In each file it adds leaders in the order they are written.

This means "American leaders.xml" will be read before "British Leaders" even if the first leader's name is Washington and the next is Alfred the Great. It's the filename, not the leader name, which matters. At least that's how I remember the code. I didn't actually look it up right now.

There is one exception to this rule. If Type is already in use, the new leader will replace the old one using the same Type string. This will allow you to reuse vanilla leaders and only replace a single one if you like. The same applies to units and all that. Be careful though. It doesn't check if the Type you enter is for the correct file. If you write the 4th building class type and you add a building, it will overwrite the 4th building regardless of which type it has. I once spent ages searching for a vanishing unit due to a bug of this nature.

Another question I have is can it affect performance using multiple XMLs via Modular loading instead of having all information in one XML?
If so what method is better for performance?
What matters to performance while playing is the final list. If it's 10 files with one leader in each or one file with 10 leaders doesn't matter because it will result in the same single list in the game with 10 leaders.

What does matter for performance is the fact that the game scans all files at startup, which is why it can take minutes to load a mod. However it seems time spend scanning xml files is insignificant compared to scanning graphic files. If you worry about startup times, you should keep your custom graphics at a minimum. That will matter perhaps thousands of times more than the number of xml files.

And even the number of graphic files seems unrelated to game performance once you have reached the main menu. That too is purely a startup time issue.
 
Well if it ain't the legend Nightinggale, been seeing you around the forums for years before I was a member.
Anyways thanks for taking the time to make that exhaustive post.

Modules are then read and I think they are read alphabetically based on their path names. In each file it adds leaders in the order they are written.

This means "American leaders.xml" will be read before "British Leaders" even if the first leader's name is Washington and the next is Alfred the Great. It's the filename, not the leader name, which matters. At least that's how I remember the code. I didn't actually look it up right now.

This helps a lot. Now I can properly setup the order.

If you worry about startup times, you should keep your custom graphics at a minimum

Not really worried about that, I have a pretty modern system. AND has a startup time on my machine of less than 10 seconds and C2C loads in less than 30.
Although I don't play C2C anymore because the turn times are ridiculous.

Speaking of turn times do you or anyone else know what the biggest contributors to turn times are? Currently I know that the number of building types can increase turn times, although
I'm not sure exactly why, I'm guessing because the ai has to decide production for each city. And the number of units because each one needs ai decision making every turn.

Also can forcing a building to become obsolete help with turn times? I'm not sure how buildings effect turn times but I suspect it's because of the ai having to choose between several
or it's the bonuses having to be applied every turn.
 
Last edited:
The primary slowdown in late game is unit pathfinding (at least unmodded. Not sure about C2C or similar big mods). While it depends linearly on the number of units (10 is twice as fast as 20), it also depends on the map size. In fact the options there are for a unit, both for where to move to and how to move for each option, the slower the game is. This mean map size has a dramatic effect on speed. This is however not really something you can touch from xml files.

The number of buildings has an impact on performance since the code loops the list. I'm not sure how big the impact is from rendering buildings obsolete, but naturally the less build options you give the AI, the less time it will take it to test each to find the best candidate. That's true for all looped files, such as units, wonders etc. When moving around, if a unit can build, it is slowed by build as it loops all entries in the file. I'm not sure how much of an impact it has overall though as the majority of units aren't workers.

While you can affect performance from xml, the biggest impact on performance generally comes from DLL modding.
 
both for where to move to and how to move for each option, the slower the game is. This mean map size has a dramatic effect on speed.

This is interesting because I always thought the problem with really big maps was that the ai had more room to go nuts along with the already higher amount of ai players selected by default.

While you can affect performance from xml, the biggest impact on performance generally comes from DLL modding.

Yeah I figured, this is something I would need to take baby steps with. I have scripted in several other game engines before but never in python and I definitely
never worked with a DLL before. The thought is a bit nerve racking because I feel like I would break something.

Know of any good Civ 4 DLL modding tutorials you could link me to? Written or in Video form, preferably both if possible.
 
Last edited:
Back
Top Bottom