Index: ps/trunk/binaries/data/mods/public/gui/session/session.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/session.js +++ ps/trunk/binaries/data/mods/public/gui/session/session.js @@ -483,6 +483,8 @@ updateGameSpeedControl(); // Update GUI and clear player-dependent cache + g_TemplateData = {}; + Engine.GuiInterfaceCall("ResetTemplateModified"); onSimulationUpdate(); if (g_IsDiplomacyOpen) @@ -783,10 +785,14 @@ function onSimulationUpdate() { - // Templates change depending on technologies and auras, so they have to be reloaded every turn. + // Templates change depending on technologies and auras, so they have to be reloaded after such a change. // g_TechnologyData data never changes, so it shouldn't be deleted. g_EntityStates = {}; - g_TemplateData = {}; + if (Engine.GuiInterfaceCall("IsTemplateModified")) + { + g_TemplateData = {}; + Engine.GuiInterfaceCall("ResetTemplateModified"); + } g_SimState = undefined; if (!GetSimState()) Index: ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js +++ ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -34,6 +34,7 @@ this.entsRallyPointsDisplayed = []; this.entsWithAuraAndStatusBars = new Set(); this.enabledVisualRangeOverlayTypes = {}; + this.templateModified = {}; }; /* @@ -634,6 +635,25 @@ }; /** + * State of the templateData (player dependent): true when some template values have been modified + * and need to be reloaded by the gui. + */ +GuiInterface.prototype.OnTemplateModification = function(msg) +{ + this.templateModified[msg.player] = true; +}; + +GuiInterface.prototype.IsTemplateModified = function(player) +{ + return this.templateModified[player] || false; +}; + +GuiInterface.prototype.ResetTemplateModified = function() +{ + this.templateModified = {}; +}; + +/** * Add a timed notification. * Warning: timed notifacations are serialised * (to also display them on saved games or after a rejoin) @@ -1919,6 +1939,8 @@ "GetTraderNumber": 1, "GetTradingGoods": 1, + "IsTemplateModified": 1, + "ResetTemplateModified": 1 }; GuiInterface.prototype.ScriptCall = function(player, name, args)