WarswordConquestTeam / Warsword-Conquest

Warsword Conquest Winds of Magic Edition - Unofficial
10 stars 7 forks source link

Further optimize world map lag #11

Open burstonsoftware opened 4 years ago

burstonsoftware commented 4 years ago

Map optimization notes:

Simple trigger # 29 # Decide vassal ai
init_ai_calculation: super heavy calculate_troop_ai: heavy

Simple trigger # 25 #diplomatic indices
randomly_start_war_peace_new: quite heavy

Simple trigger # 35 # Process alarms process_alarm: Super heavy

Simple trigger #38 # recalculate_ais recalculate_ais:heavy, causing stuttering recalculate_ai calls: decide_faction_ai init_ai_calculation calculate_troop_ai

it appears these are being called twice from different triggers init_ai_calculation calculate_troop_ai

Thoughts: These all seem to scale on party/faction/city amounts. So that explains why the problem has gotten worse over time. They share a common flaw of looping a huge script over a big range i.e parties/towns/factions all at once. This results in the stuttering as the cpu is busy in the loop.

Solutions: Optimize the scripts as much a possible. Call the triggers much more frequently but for only one party/town/faction in the loop at a time. Spreading the load over a greater amount of time.

The removal/reduction of these triggers in testing resulted in almost no world map lag. So if we can adequately optimize these scripts I see no reason why adding more factions/parties/cities in the future would be off the table.

burstonsoftware commented 4 years ago

Went well but now getting vassal join errors

burstonsoftware commented 4 years ago

Fixed script errors however it is unclear if the changes are having a detrimental impact on the world map ai. If alterations are difficult to notice, then the very good increase in world map performance is easily justified.

burstonsoftware commented 4 years ago

Need to do the war peace script. Its very slow