diff --git a/binaries/data/mods/public/gui/pregame/mainmenu.js b/binaries/data/mods/public/gui/pregame/mainmenu.js index b32e241835..19deeded5b 100644 --- a/binaries/data/mods/public/gui/pregame/mainmenu.js +++ b/binaries/data/mods/public/gui/pregame/mainmenu.js @@ -25,7 +25,7 @@ function init(initData, hotloadData) // Pick a random background and initialise it g_BackgroundCode = Math.floor(Math.random() * g_BackgroundLayerData.length); var layerset = g_BackgroundLayerData[g_BackgroundCode]; - for (var i = 0; i < layerset.length; i++) + for (var i = 0; i < layerset.length; ++i) { var layer = layerset[i]; var guiObj = Engine.GetGUIObjectByName("background["+i+"]"); diff --git a/binaries/data/mods/public/simulation/components/Capturable.js b/binaries/data/mods/public/simulation/components/Capturable.js index 906bfb892e..7741c50e22 100644 --- a/binaries/data/mods/public/simulation/components/Capturable.js +++ b/binaries/data/mods/public/simulation/components/Capturable.js @@ -253,22 +253,28 @@ Capturable.prototype.OnTerritoryDecayChanged = function(msg) Capturable.prototype.OnOwnershipChanged = function(msg) { + if (this.cp.length) + { + if (!this.cp[msg.from]) + return; // nothing to change + + // Was already initialised, this happens on defeat or wololo + // transfer the points of the old owner to the new one + this.cp[msg.to] += this.cp[msg.from]; + this.cp[msg.from] = 0; + this.RegisterCapturePointsChanged(); + } + else + { + // initialise the capture points when created + var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); + for (let i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i) + if (i == msg.to) + this.cp[i] = this.maxCp; + else + this.cp[i] = 0; + } this.CheckTimer(); - - // if the new owner has no capture points, it means that either - // * it's being initialised now, or - // * it changed ownership for a different reason (defeat, atlas, ...) - if (this.cp[msg.to]) - return; - - // initialise the capture points when created - this.cp = []; - var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); - for (let i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i) - if (i == msg.to) - this.cp[i] = this.maxCp; - else - this.cp[i] = 0; }; Engine.RegisterComponentType(IID_Capturable, "Capturable", Capturable);