Hello again, karadoc!
These were, in my case, CvUnitAI.AI_upgrade and CvPlayerAI.AI_doDiplo.
1. CvUnitAI.AI_upgrade had a cycle over getNumUnitInfos and, naturally, it ran extremely slow with RI assets. I've made a quick fix - changed it to cycle over getNumUnitClassInfos and it reduced the time this functions worked by 90%. I also moved canUpgrade check closer to the top to avoid the calculations of AI_unitValue for units you can't upgrade into anyway.
The function is still at the top of the list. Is it really necessary to try to upgrade every unit every turn?
2. In CvPlayerAI.AI_doDiplo the tech trading code is the culprit. RI has much more techs than regular CIV and loops over getNumTechInfos with AI_techValue being called for every tech are abundant in AI_doDiplo.
The worst part is that I play with Tech Trading turned off, so these calculations couldn't possible be of any use. I implemented a simple check for that option in places where AI_techValue is called.
In your mod they just stand there all the time. They still get their fortify modifier, but they don't look defensive.
I would prefer if all AI units on SLEEP had a fortified animation. Will make them more scary to approach.
Thank you!
Thanks for the advice. I have no real experience with C++ and profiling didn't even cross my mind. I ran the game with the profiling DLL and have easily located the most costly functions.1. Running a lot slower is certainly bad news.I think it's highly likely that it is due to a combination of something in the K-Mod dll + the increased number of assets in RI. Maybe it is unit types, maybe improvement types or something else... it's really hard to say. I suggest that you compile a 'profiling' version of the dll; then use it load a save game which you know will be slow; then end turn; then quit and check the profile log to find out what the slowest functions are. It will only list functions which have "PROFILE_FUNC()" at the top of their code, but you can just put that line in to whichever functions you think are worth checking.
If you do that, and you find the source of the slowness, please let me know. Hopefully it's something that can be fixed easily without undoing any other changes.
These were, in my case, CvUnitAI.AI_upgrade and CvPlayerAI.AI_doDiplo.
1. CvUnitAI.AI_upgrade had a cycle over getNumUnitInfos and, naturally, it ran extremely slow with RI assets. I've made a quick fix - changed it to cycle over getNumUnitClassInfos and it reduced the time this functions worked by 90%. I also moved canUpgrade check closer to the top to avoid the calculations of AI_unitValue for units you can't upgrade into anyway.
The function is still at the top of the list. Is it really necessary to try to upgrade every unit every turn?
2. In CvPlayerAI.AI_doDiplo the tech trading code is the culprit. RI has much more techs than regular CIV and loops over getNumTechInfos with AI_techValue being called for every tech are abundant in AI_doDiplo.
The worst part is that I play with Tech Trading turned off, so these calculations couldn't possible be of any use. I implemented a simple check for that option in places where AI_techValue is called.
I am pretty sure that the AI's units are fortified in vanilla Civ, at least when I come close to their cities with my armies.2. You're right. They don't look fortified in K-Mod either, so it's almost certainly my fault. I'll try to fix that soon. (I don't yet know what's causing the problem. Maybe it's something to do with the stuff changed in updateCenterUnit - but maybe not.)
[edit]
Actually, I just did a quick test without any mods loaded. I started a new game, used the world builder to create a barb city with an archer in it where I had vision, and then pressed end turn. The barb archer did not look fortified. --- So. Apparently it's not my fault after all! The problem was there right from the start. Nevertheless, I'll see if I can fix it.
[/edit]

I would prefer if all AI units on SLEEP had a fortified animation. Will make them more scary to approach.

Thank you!