Skip to content

Commit

Permalink
extra safety
Browse files Browse the repository at this point in the history
  • Loading branch information
rt committed Mar 16, 2012
1 parent abdf7b2 commit 6cefe1d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rts/Sim/Units/CommandAI/FactoryCAI.cpp
Expand Up @@ -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))
Expand All @@ -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);
Expand Down

0 comments on commit 6cefe1d

Please sign in to comment.