Ticket #963: training_queue.diff

File training_queue.diff, 1.2 KB (added by fcxSanya, 13 years ago)
  • TrainingQueue.js

     
    349349        }
    350350
    351351        var numSpawned = this.SpawnUnits(item.template, item.count, item.metadata);
    352         if (numSpawned > 0)
     352        if (numSpawned == item.count)
    353353        {
    354             // This could be only partially finised
     354            // All entities spawned, this batch finished
    355355            cmpPlayer.UnReservePopulationSlots(item.population * numSpawned);
    356             item.count -= numSpawned;
    357             Engine.PostMessage(this.entity, MT_TrainingQueueChanged, { });
    358         }
    359        
    360         if (item.count == 0)
    361         {
    362             // All entities spawned, this batch finished
     356            item.count = 0;
     357
    363358            time -= item.timeRemaining;
    364359            this.queue.shift();
    365360            // Unset flag that training queue is blocked
    366361            cmpPlayer.UnBlockTrainingQueue();
    367362            this.spawnNotified = false;
     363            Engine.PostMessage(this.entity, MT_TrainingQueueChanged, { });
    368364        }
     365       
     366        else if (numSpawned > 0)
     367        {
     368            // Only partially finished
     369            cmpPlayer.UnReservePopulationSlots(item.population * numSpawned);
     370            item.count -= numSpawned;
     371            Engine.PostMessage(this.entity, MT_TrainingQueueChanged, { });
     372        }
    369373        else
    370374        {
    371375            // Some entities failed to spawn