Index: binaries/data/mods/public/simulation/components/ProductionQueue.js =================================================================== --- binaries/data/mods/public/simulation/components/ProductionQueue.js +++ binaries/data/mods/public/simulation/components/ProductionQueue.js @@ -357,8 +357,6 @@ // thing twice. var cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager); cmpTechnologyManager.QueuedResearch(templateName, this.entity); - if (this.queue.length == 0) - cmpTechnologyManager.StartedResearch(templateName, false); this.queue.push({ "id": this.nextID++, @@ -383,12 +381,9 @@ Engine.PostMessage(this.entity, MT_ProductionQueueChanged, { }); - // If this is the first item in the queue, start the timer + // If this is the first item in the queue. if (!this.timer) - { - var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); - this.timer = cmpTimer.SetTimeout(this.entity, IID_ProductionQueue, "ProgressTimeout", g_ProgressInterval, {}); - } + this.ProgressTimeout(); } else { @@ -729,6 +724,8 @@ item.productionStarted = true; if (item.unitTemplate) Engine.PostMessage(this.entity, MT_TrainingStarted, {"entity": this.entity}); + + break; } // If we won't finish the batch now, just update its timer @@ -747,7 +744,7 @@ { // All entities spawned, this batch finished cmpPlayer.UnReservePopulationSlots(item.population * numSpawned); - time -= item.timeRemaining; + time = 0; this.queue.shift(); // Unset flag that training is blocked cmpPlayer.UnBlockTraining(); @@ -794,8 +791,7 @@ cmpSoundManager.PlaySoundGroup(template.soundComplete, this.entity); } - time -= item.timeRemaining; - + time = 0; this.queue.shift(); Engine.PostMessage(this.entity, MT_ProductionQueueChanged, { }); } @@ -813,7 +809,7 @@ else { var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); - this.timer = cmpTimer.SetTimeout(this.entity, IID_ProductionQueue, "ProgressTimeout", g_ProgressInterval, data); + this.timer = cmpTimer.SetTimeout(this.entity, IID_ProductionQueue, "ProgressTimeout", time, {}); } };