From 0da62cbc99e5f6aa1d48c754a26933b60e04b69e Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Mon, 8 Feb 2010 20:45:38 +0000 Subject: [PATCH] When canceling or completing build orders, make sure we clear the complete droid state, otherwise other parts of the code can become confused and think they are busy. git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@9748 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/droid.c | 3 +++ src/structure.c | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/droid.c b/src/droid.c index 6fbe0a765..deb18b593 100644 --- a/src/droid.c +++ b/src/droid.c @@ -120,6 +120,9 @@ void droidUpdateRecoil( DROID *psDroid ); static void cancelBuild(DROID *psDroid) { psDroid->action = DACTION_NONE; + psDroid->order = DORDER_NONE; + setDroidTarget(psDroid, NULL); + setDroidActionTarget(psDroid, NULL, 0); /* Notify scripts we just became idle */ psScrCBOrderDroid = psDroid; diff --git a/src/structure.c b/src/structure.c index 0f3e6ac11..5a0cab77d 100644 --- a/src/structure.c +++ b/src/structure.c @@ -1196,14 +1196,15 @@ void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints) intRefreshScreen(); // update any open interface bars. } - /* Not needed, but left for backward compatibility */ - structureCompletedCallback(psStruct->pStructureType); - /* must reset here before the callback, droid must have DACTION_NONE in order to be able to start a new built task, doubled in actionUpdateDroid() */ if (psDroid) { psDroid->action = DACTION_NONE; + psDroid->order = DORDER_NONE; + setDroidTarget(psDroid, NULL); + setDroidActionTarget(psDroid, NULL, 0); + psDroid->psTarStats = NULL; /* Notify scripts we just finished building a structure, pass builder and what was built */ psScrCBNewStruct = psStruct; @@ -1212,6 +1213,9 @@ void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints) audio_StopObjTrack( psDroid, ID_SOUND_CONSTRUCTION_LOOP ); } + + /* Not needed, but left for backward compatibility */ + structureCompletedCallback(psStruct->pStructureType); } else {