Don't crash if an order is cancelled and you still have a valid action related to that order with a NULL target stat.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7697 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2009-06-08 20:10:11 +00:00 committed by Git SVN Gateway
parent d0e023a236
commit cfbc5dec39
1 changed files with 25 additions and 2 deletions

View File

@ -1789,7 +1789,6 @@ void actionUpdateDroid(DROID *psDroid)
case DACTION_MOVETOBUILD: case DACTION_MOVETOBUILD:
if (!psDroid->psTarStats) if (!psDroid->psTarStats)
{ {
debug(LOG_ERROR, "Bad move to build action target");
psDroid->action = DACTION_NONE; psDroid->action = DACTION_NONE;
break; break;
} }
@ -1968,6 +1967,11 @@ void actionUpdateDroid(DROID *psDroid)
} }
break; break;
case DACTION_BUILD: case DACTION_BUILD:
if (!psDroid->psTarStats)
{
psDroid->action = DACTION_NONE;
break;
}
// The droid cannot be in a formation // The droid cannot be in a formation
if (psDroid->sMove.psFormation != NULL) if (psDroid->sMove.psFormation != NULL)
{ {
@ -2005,7 +2009,11 @@ void actionUpdateDroid(DROID *psDroid)
case DACTION_MOVETOREPAIR: case DACTION_MOVETOREPAIR:
case DACTION_MOVETOCLEAR: case DACTION_MOVETOCLEAR:
case DACTION_MOVETORESTORE: case DACTION_MOVETORESTORE:
if (!psDroid->psTarStats)
{
psDroid->action = DACTION_NONE;
break;
}
// The droid cannot be in a formation // The droid cannot be in a formation
if (psDroid->sMove.psFormation != NULL) if (psDroid->sMove.psFormation != NULL)
{ {
@ -2067,6 +2075,11 @@ void actionUpdateDroid(DROID *psDroid)
case DACTION_REPAIR: case DACTION_REPAIR:
case DACTION_CLEARWRECK: case DACTION_CLEARWRECK:
case DACTION_RESTORE: case DACTION_RESTORE:
if (!psDroid->psTarStats)
{
psDroid->action = DACTION_NONE;
break;
}
// set up for the specific action // set up for the specific action
switch (psDroid->action) switch (psDroid->action)
{ {
@ -2155,6 +2168,11 @@ void actionUpdateDroid(DROID *psDroid)
} }
break; break;
case DACTION_BUILD_FOUNDATION: case DACTION_BUILD_FOUNDATION:
if (!psDroid->psTarStats)
{
psDroid->action = DACTION_NONE;
break;
}
//building a structure's foundation - flattening the ground for now //building a structure's foundation - flattening the ground for now
{ {
MAPTILE* const psTile = mapTile(map_coord(psDroid->orderX), map_coord(psDroid->orderY)); MAPTILE* const psTile = mapTile(map_coord(psDroid->orderX), map_coord(psDroid->orderY));
@ -2711,6 +2729,11 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
break; break;
case DACTION_BUILD: case DACTION_BUILD:
if (!psDroid->psTarStats)
{
psDroid->action = DACTION_NONE;
break;
}
ASSERT(psDroid->order == DORDER_BUILD || psDroid->order == DORDER_HELPBUILD || ASSERT(psDroid->order == DORDER_BUILD || psDroid->order == DORDER_HELPBUILD ||
psDroid->order == DORDER_LINEBUILD, psDroid->order == DORDER_LINEBUILD,
"cannot start build action without a build order"); "cannot start build action without a build order");