Database order from several mods?

Serp

King
Joined
Apr 1, 2015
Messages
666
First mod adds a new promotion. (short "ProMod")
The second mod introduces new icons and changes (update) the icon of the previous promotion. ("iconmod").

The ProMod is of course in the depencies of the iconmod in the modinfo file.
So I always activate the ProMod before the Iconmod.

Both mods have the relevant xml file in Actions:
<Actions>
<OnModActivated>
<UpdateDatabase>XML/ProMod.xml</UpdateDatabase>
</OnModActivated>
</Actions>

It seems it is absolutely random, which xml entries are written first into the database. Because it already worked the right way.
But now the iconmod is obviously written in the database, before the ProMod.
At least the icon of the promotion is not changed. (the iconmod does work, since it also changes some standard promotion icons, which does work)
.. But there are no errors in the database log. I thought there would be something like "promotion not found to update" or simular.

So what can I do and check and add, to guarantee, that one mod is written in the database before the other?
 
Are you sure you have your dependancy set up correctly in the 'iconmod' ?

I've never found the dependancy system to not work correctly. Nor the mod 'reference' system either. But without link (or attachment) to the mods themselves it will be oujia-boarding to hit the correct answer for where your problem lies.
 
Are you sure you have your dependancy set up correctly in the 'iconmod' ?

I've never found the dependancy system to not work correctly. Nor the mod 'reference' system either. But without link (or attachment) to the mods themselves it will be oujia-boarding to hit the correct answer for where your problem lies.


I will upload them.

The "Promotions - Terrain Crossing (v 3)" adds e.g. a "Alpine Corp" (german "Bergsteiger") promotion.
The "FlagPromotions ModSupport (v 4)" adds some new icons and places the icons of promotions above the unit flag. And changes the icon from Alpine Corp from an tripple arrow, to an mountain.

other useful info:
the level - promotions mod also adds alot of new promotions. These icons are succesfully change by flagpromo.
The Goody Hut mod adds another new promotion, but this mod was not in the depencies of flagpromo.

When starting a game with all mods enabled, the alpine corps promotion icon was still the tripple arrow and it did no appaer over the unfitflag.
Also the new prmotion in The Goody Hut mod was not shown in unitflag.
But all promotion from Promotions-Levels mod were fine.
-> it was loaded in the wrong order

I "solved" it that way now:
I just added the Goody hut mod into the depencies of Flagpromo and tried again... and now the order seems to be correct, at least everything is fine now.
I removed it again from the depencies, but still everything is fine in the game.

That is why I don't have a clue what is or was wrong and it apaears totally random to me. Because regardless of my changes, sometimes it works, and sometimes not.

AH, I just found out:
It has to do with the cache...


Yesterday I added the a new promotion to the Goody Hut mod. Before that moment, everything was fine.
And even after that, the loading order was also okay, because I had the same cache.
To deactive all mods at once, I deleted the modding cache. And from now on it did not work.
The only strange thing is, that only because of this single new promotion, also the Terrain-Crossing mod was loaded wrong.
Now after adding the Goody Hut mod into the Depencies and deleting the cache, everything is fine again.

So the reason for the randomness is the cache -.-

Now, after testing, I wanted everything to work. So I deleted Mod cache and added the Goody Hut mod to the depencies.
After starting the game, the Goody Hut promotion is shown over the unfitflag, so this is correct.
But again the icon from the Alpine corps is wrong -.- ?!
Why? It is in the depencies...
 
I don't have time at the moment to look at your pack, so I'm not sure this is the issue, but note that the dependencies and references only affect database load order, not the order of VFS "overwrites" (i.e., where a mod replaces a file from the base game or another mod). There is apparently no way to guarantee that order (though you might try to ensure the file date of the "winner" is the newest; that seems to help for DLC mods, anyway). Otherwise, you can just delete the conflicting file. In any event, another method can often be used to get the same result without replacing files (though it's sometimes quite a bit more effort).
 
I don't have time at the moment to look at your pack, so I'm not sure this is the issue, but note that the dependencies and references only affect database load order, not the order of VFS "overwrites" (i.e., where a mod replaces a file from the base game or another mod). There is apparently no way to guarantee that order (though you might try to ensure the file date of the "winner" is the newest; that seems to help for DLC mods, anyway). Otherwise, you can just delete the conflicting file. In any event, another method can often be used to get the same result without replacing files (though it's sometimes quite a bit more effort).
thanks :)

Yes the problem is, that the iconmod "updates" a non existing promotion -> nothing.
And then the new promotion is added.
But it should be the other way round.

Luckily I saved my cache while it was working, so now I was able to compile my modpack.

The date of which file is the one to look at? The modinfo file? Or the xml/sql that updates/adds something?
 
thanks :)

Yes the problem is, that the iconmod "updates" a non existing promotion -> nothing.
And then the new promotion is added.
But it should be the other way round.

Luckily I saved my cache while it was working, so now I was able to compile my modpack.

The date of which file is the one to look at? The modinfo file? Or the xml/sql that updates/adds something?
If it's a pure database update (OnModActivated) and not a VFS update, then the date shouldn't matter, assuming you have properly set the Dependencies or References in the Associations tab of the mod's properties. Another option, rather than Associations, is to use SQL triggers, which has the benefit of potentially working with any mod, known, unknown, or made in the future.
 
If it's a pure database update (OnModActivated) and not a VFS update, then the date shouldn't matter, assuming you have properly set the Dependencies or References in the Associations tab of the mod's properties. Another option, rather than Associations, is to use SQL triggers, which has the benefit of potentially working with any mod, known, unknown, or made in the future.

Thank you for the advise.
Next time I will try to teach myself about sql triggers ;)
 

Hmm.. the following did not help, is there something wrong?
I just want to change the icon right after the new promotion was inserted.


Code:
CREATE TRIGGER TerrainIconsFlagPromo1
AFTER INSERT ON UnitPromotions  
WHEN 'PROMOTION_CAN_CROSS_MOUNTAINS'=NEW.Type
BEGIN
  UPDATE UnitPromotions
    SET PortraitIndex = 2, IconAtlas = 'NEW_ICON_ATLAS'
    WHERE Type = 'PROMOTION_CAN_CROSS_MOUNTAINS';   
END;

CREATE TRIGGER TerrainIconsFlagPromo2
AFTER INSERT ON UnitPromotions  
WHEN 'PROMOTION_CAN_CROSS_MOUNTAINS_SCOUT'=NEW.Type
BEGIN
  UPDATE UnitPromotions
    SET PortraitIndex = 2, IconAtlas = 'NEW_ICON_ATLAS'
    WHERE Type = 'PROMOTION_CAN_CROSS_MOUNTAINS_SCOUT';    
END;

CREATE TRIGGER TerrainIconsFlagPromo3
AFTER INSERT ON UnitPromotions  
WHEN 'PROMOTION_CAN_CROSS_ICE'=NEW.Type
BEGIN
  UPDATE UnitPromotions
    SET PortraitIndex = 2, IconAtlas = 'NEW_PROMOTION_ATLAS'
    WHERE Type = 'PROMOTION_CAN_CROSS_ICE';  
END;

CREATE TRIGGER TerrainIconsFlagPromo4
AFTER INSERT ON UnitPromotions  
WHEN 'PROMOTION_ICEBREAKER'=NEW.Type
BEGIN
  UPDATE UnitPromotions
    SET PortraitIndex = 2, IconAtlas = 'NEW_PROMOTION_ATLAS'
    WHERE Type = 'PROMOTION_ICEBREAKER';    
END;

edit:
also removing the WHEN line does not help.. hm...
edit2:
the terraincrossing promotions are in a xml file with just "Row". Is this an INSERT?
 
FYI, SQL triggers won't catch changes that have occurred prior to the trigger (as you've seen, we don't know beforehand the order they're applied), so you'll want to run your updates inside the triggers ALSO outside (and prior to) the triggers.

And XML <Row> is translated to a SQL INSERT, yes.
 
FYI, SQL triggers won't catch changes that have occurred prior to the trigger (as you've seen, we don't know beforehand the order they're applied), so you'll want to run your updates inside the triggers ALSO outside (and prior to) the triggers.

And XML <Row> is translated to a SQL INSERT, yes.
Thanks :)

so simply put
Code:
UPDATE UnitPromotions
SET PortraitIndex = 2, IconAtlas = 'NEW_ICON_ATLAS'
WHERE Type = 'PROMOTION_CAN_CROSS_MOUNTAINS';   

UPDATE UnitPromotions
SET PortraitIndex = 2, IconAtlas = 'NEW_ICON_ATLAS'
WHERE Type = 'PROMOTION_CAN_CROSS_MOUNTAINS_SCOUT';   

UPDATE UnitPromotions
SET PortraitIndex = 2, IconAtlas = 'NEW_PROMOTION_ATLAS'
WHERE Type = 'PROMOTION_CAN_CROSS_ICE';  

UPDATE UnitPromotions
SET PortraitIndex = 2, IconAtlas = 'NEW_PROMOTION_ATLAS'
WHERE Type = 'PROMOTION_ICEBREAKER';
before the triggers in the same script? How could this help? (if the IconChangeMod is done before the Promotion Mod?)
Or do I need another script or another mod?

edit:
I added this before and after the triggers in the same script, but it did not help =/

edit2:
this update and the introduce of the new atlas is done in two sperate scripts within the icon-change-mod. Therefore I also wrote the update in the atlas script, but this also did not help...
I also tried to change the icon to a one with an exisiting atlas, which did not work, so the atlas is not the problem.
 
You really should not need anything other than a correct dependency in one of the mods

Is this for two mods for use in single player, or for two mods which you then merge into a multi-player mod pack?

If the former, just attach the two mods as snippets of SQL out of context are difficult to debug.

If the latter, are you sure the merging tool a) understands dependancies and b) copes with SQL. And if the latter, why not just merge the two mods manually and then include the combined mod via the MP mod-pack making tool?
 
Thank all of you for your help. I learned about depencies and Triggers :)

But maybe the problem is something else you were not able to solve without the mods (although I attached them in my second post. I deleted this now and uploaded again only the mods of interest)

You really should not need anything other than a correct dependency in one of the mods

Is this for two mods for use in single player, or for two mods which you then merge into a multi-player mod pack?

If the former, just attach the two mods as snippets of SQL out of context are difficult to debug.

If the latter, are you sure the merging tool a) understands dependancies and b) copes with SQL. And if the latter, why not just merge the two mods manually and then include the combined mod via the MP mod-pack making tool?
I could merge them of course, but if possible I want them to stay standalone mods. And this should be possible. And also without knowing the reason for this issue, there could be more problems with other mods I did not see yet.

So here are the mods:
http://www.file-upload.net/download-11374506/MODS.zip.html

I just found out the real problem is a third mod. My "Level Promotions" mod. It does not change the icon, but when this mod is in the depencies of the other mods, the issue happens. When I remove the "Level Promotions" Mod from all the depencies of the other mods, then the icon change does work.

To test it, simply start a game with any settings. Your units should receive XP in the first round (in lua of Level Promotions and in UnitFlagManager.lua of Flagpromotions mod, to test). In the second round you can choose promotions.
Without icon change, the alpine corp promotion is a tripple arrow. With icon change, it should be a mountain.

Another "strange" thing is, in the lua.log my "Level Promotions" mod is shown like:
Code:
[87819.031] \Users\Serp\Documents\My Games\Sid Meier's Civilization 5\MODS\Promotions - Level Promotions (v 3)\Promotions - Level Promotions: Promotions - Level Promotions Active
Why is there the path shown?

edit:
Yes I want to make a modpack with these mods, but this has nothing to do with the problem itself, since it happens when just loading the mods via the mods menu.
 
If the lua-file is at the root level of the mod instead of within a sub-folder of the mod, the lua log will do this.

I get this sort of full file-path-string all the time with a tester-mod I use where all the files are at the root level of the mod because I was too lazy to make any sub-folders within the mod.
 
If the lua-file is at the root level of the mod instead of within a sub-folder of the mod, the lua log will do this.

I get this sort of full file-path-string all the time with a tester-mod I use where all the files are at the root level of the mod because I was too lazy to make any sub-folders within the mod.

ah, thanks. Yes it is like you said :)
So I guess this has nothing to do with the problem itself, okay...
 
Check database.log - you have SQL errors. One is benign, the final update to the LoadedFile table, the other is fatal - you're missing the ; after the END of the triggers, so the triggers are not being created. Add four missing semi-colons and the SQL executes and the promotions get the new icons (only checked by looking in the database with SQLiteSpy)

The other interesting thing is that Firaxis appear to have written the database execution mod dependency code as "any of these mods" and not "all of these mods".

This is causing the Flag Promotion mod to load after either of the Terrain Crossing or Level Promotions mod has loaded and not (as you'd reasonably expect) both of them to have loaded. You can fix this for these 4 mods by making Flag Promo depend on Terrain Crossing depend on Level Promo depend on DLL VMC, but for many mods it's going to be a right PITA to get the required order, so TRIGGERS (with the final semi-colon) will definitely be required.
 
Check database.log - you have SQL errors. One is benign, the final update to the LoadedFile table, the other is fatal - you're missing the ; after the END of the triggers, so the triggers are not being created. Add four missing semi-colons and the SQL executes and the promotions get the new icons (only checked by looking in the database with SQLiteSpy)

The other interesting thing is that Firaxis appear to have written the database execution mod dependency code as "any of these mods" and not "all of these mods".

This is causing the Flag Promotion mod to load after either of the Terrain Crossing or Level Promotions mod has loaded and not (as you'd reasonably expect) both of them to have loaded. You can fix this for these 4 mods by making Flag Promo depend on Terrain Crossing depend on Level Promo depend on DLL VMC, but for many mods it's going to be a right PITA to get the required order, so TRIGGERS (with the final semi-colon) will definitely be required.
Thank you very much for taking the time to look into that.
Yes the ";" ... I thought they are optional like they are in lua :D

Ah good to know that this works like "any" ! Thank you very much! :)

The triggers do work perfectly, thanks :)
 
Back
Top Bottom