[eINFO] Folder and filename priority

One thing that was noticed in E:wom, and still holds true in the FE mod folder is the following details

1) If two files have the same filename, then only one gets read by the game. The other one is completely ignored (it is not read into the engine at all). This is both a danger and an opportunity for us modders. It is a danger because we must ensure that our filenames aren't the same by mistake. It is an opportunity because it allows us to release mods that purposefully have a higher priority than previous mod-files without overwriting them. (Edit: Note that filenames in the Mod folder do NOT cause conflicts with identical filenames from the core installation folder)

2) In order to understand what file gets read if there are multiple files with the same filename, we also have to understand the order the engine reads in the folders. If you have some experience of folder structure this should come as no surprise. The folders are read in hierarchy, numeric and then alphabetical order:

Mods\TestMod_V1\
Mods\TestMod_V1\Coremod\
Mods\TestMod_V1\Zzzmod\
Mods\TestMod_V1\Zzzmod\folder1\
Mods\TestMod_V1\Zzzmod\folder2\
Mods\Testmod_V2\
Mods\Testmod_V2\Coremod\
Mods\TestMod_V2\Zzzmod\
Mods\TestMod_V2\Zzzmod\folder1\
Mods\TestMod_V2\Zzzmod\folder2\
Mods\Testmod_VA\
Mods\Testmod_VB\

Note that, unlike filenames, sub-folders can have the same name without causing a conflict. But files within still cause conflict if they share filename.

Example one:

Mods\TestMod_V1\Test.xml
Mods\TestMod_V2\Test.xml

The second file in the V2 folder is read.

Example two:

Mods\TestMod_V1\Coremod\Test.xml
Mods\TestMod_V2\Test.xml

The second file in the V2 folder is read.

Example three:

Mods\TestMod_V1\Coremod\Test1.xml
Mods\TestMod_V1\Coremod\Test.xml
Mods\TestMod_V2\Coremod\Test.xml

The second file in the V2\Coremod folder is read, and Test1.xml is also read.

22,900 views 8 replies
Reply #1 Top

An example of how I will be using this information:

Imagine that I release a library mod called Lib_Example (in a folder called Lib_Example that has a single Lib_example.xml file). It contains information that is only relevant to version 0.77 of Fallen Enchantress. When 0.78 is released, I want to update the library. So, I update the files in the folder Lib_Example and release it.

Now a problem occurs. The user installs two mods that both contain the library mod. Mod A contains the 0.77 version of my library. Mod B contains the 0.78 version of my library. I don't know which order the player installs Mod A and Mod B in. And I can't depend on every mod always being updated instantly when I release a new version of the library. Imagine if he installs Mod B first, then Mod A - the library version will be 0.77! That's bad.

What is the solution? Instead of using the same folder name for both versions of my library mod, I do this instead:
Lib_Example_Version_A = 0.77 version
Lib_Example_Version_B = 0.78 version

Back to the problem. The user installs Mod A and Mod B, and they contain respective library versions. But no matter what order the player installs the mods in, he will end up with two separate folders for the library. And as we know from above, as long as the filenames intentionally have a conflict, only one will be read. In other words, regardless of what order he installs Mod A and Mod B in, the game will always read information from the Lib_Example_Version_B = 0.78 version.

Yeah, it's magic. And useful.

 

Reply #2 Top

Do you think this capability was deliberate by Stardock or just a fortunate piece of coding?

Reply #3 Top

Could be either. It is certainly a mistake I could have made if I scanned a certain folder like \Mods\ for .xml files. But then again, they are professionals.

 

Reply #4 Top

A question for the master:

Adding new spells and weapons is just a matter of making a new xml with the new items using new internal names.

What if I want to replace a spell, trait, weapon, etc?

What is the best way to do this?

For example, I have a modifed Fireball spell that I want to use in game to replace the one in CoreSpells. What is the best way to replace this?

 

I'm also seeing in cases where I have a small file for Abilities in the mod folder called CoreAbilities I'm geting a merging of tags both mine and the one in the main data folder. Oddly spells I have in the same folder called CoreSpells, are not overwriting at all.

Confused as hell. Maybe too long a work day.

 

Thanks.


 

Reply #5 Top

1) Depending on the type, it is either overwritten or modified when you have xml for it.

For example, if you are attempting to modify a weapon, all you need to do is copy the GameItemType, keep the same internalname, and tweak what you want. It will save none of the old values - they are all overwritten and deleted.

But if you are changing, say, an ImprovementType, things work differently. Even if you use the same internalname, the old data that has been inserted into that ImprovementType will not be overwritten and deleted. Instead, you are modifying it.

GameItemTypes, SpellDefs and UnitTypes can be overwritten. Abilitybonuses, abilitybonusoption and ImprovementTypes and Raceconfigs cannot.

SpellDefs can be overwritten, BUT anything inside SpellResourceCost tags are NOT forgotten.

 

If you want to alter an existing abilitybonusoption, you have three choices.

1) Insert gamemodifiers to counter the old ones. For example, if a trait has +3 accuracy, insert a gamemodifier that gives -3 accuracy. This does not always work (for example you can't counter a gamemodifier that unlocks an ability).

2) Disable the old trait by making it unselectable at level-up / unit design. You do this by inserting a prereq that can never be fulfilled. This doesn't work for custom sov creation.

3) Make it a core mod instead of a normal mod.

 

 

It is possible that there is another file named CoreSpells.xml in your mod folder. I know I have one in the UnitStat background mod. Try renaming your Corespells.xml file.

Reply #6 Top

It's weird. My spells are in a newly names xml file to avoid a conflict. My edits to the Eagle Eye spell show up (the spell itself is still broken in 86). Fireball is in the same file, same name as the core version, but it is not overwritting the core effects. Baffling as all hell. All my new spells work just fine out of the file. All I can think is the "autounlock" tag is causing grief since Eagle eye does not have it.

The floor is open for thoughts. I can see about posting my file or I will e-mail it if interested.

Thanks.

Reply #7 Top

No idea what's wrong.

Reply #8 Top

Posting for inclusion in my threads page (and also for reference to other modders - this information is still current for LH).