From 6cefe1d4e60432a67bcc29bd3bd252278b8ddeb6 Mon Sep 17 00:00:00 2001 From: rt Date: Fri, 16 Mar 2012 21:50:20 +0100 Subject: [PATCH] extra safety --- rts/Sim/Units/CommandAI/FactoryCAI.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rts/Sim/Units/CommandAI/FactoryCAI.cpp b/rts/Sim/Units/CommandAI/FactoryCAI.cpp index 47d3a83aa72..b6bf0cd1dc1 100644 --- a/rts/Sim/Units/CommandAI/FactoryCAI.cpp +++ b/rts/Sim/Units/CommandAI/FactoryCAI.cpp @@ -309,6 +309,7 @@ bool CFactoryCAI::RemoveBuildCommand(CCommandQueue::iterator& it) void CFactoryCAI::DecreaseQueueCount(const Command& buildCommand, BuildOption& buildOption) { // copy in case we get pop'ed + // NOTE: the queue should not be empty at this point! const Command frontCommand = commandQue.empty()? Command(CMD_STOP): commandQue.front(); if (!repeatOrders || (buildCommand.options & DONT_REPEAT)) @@ -322,7 +323,11 @@ void CFactoryCAI::DecreaseQueueCount(const Command& buildCommand, BuildOption& b if (frontCommand.GetID() == CMD_WAIT) commandQue.pop_front(); - FinishCommand(); + // can only finish the real build-command command if + // we still have it in our queue (FinishCommand also + // asserts this) + if (!commandQue.empty()) + FinishCommand(); if (frontCommand.GetID() == CMD_WAIT) commandQue.push_front(frontCommand);