Skip to content

Commit

Permalink
Allow queuing building on burning oil wells.
Browse files Browse the repository at this point in the history
Actual construction only starts after the oil well finishes burning.
  • Loading branch information
Cyp committed Jun 5, 2012
1 parent fbd757b commit 353357b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
10 changes: 7 additions & 3 deletions src/action.cpp
Expand Up @@ -1803,11 +1803,15 @@ void actionUpdateDroid(DROID *psDroid)
}

//ready to start building the structure
DroidStartBuild dsb;
if ( psDroid->action != DACTION_NONE &&
droidStartBuild(psDroid))
(dsb = droidStartBuild(psDroid)))
{
debug( LOG_NEVER, "DACTION_BUILD_FOUNDATION: start build");
psDroid->action = DACTION_BUILD;
if (dsb == DroidStartBuildSuccess) // Not if waiting for oil to finish burning.
{
debug( LOG_NEVER, "DACTION_BUILD_FOUNDATION: start build");
psDroid->action = DACTION_BUILD;
}
}
else
{
Expand Down
1 change: 0 additions & 1 deletion src/display.cpp
Expand Up @@ -1956,7 +1956,6 @@ static void dealWithLMBFeature(FEATURE* psFeature)
{
// Can't build because it's burning
AddDerrickBurningMessage();
break;
}

sendDroidInfo(psCurr, DroidOrder(DORDER_BUILD, &asStructureStats[i], removeZ(psFeature->pos), player.r.y), ctrlShiftDown());
Expand Down
13 changes: 6 additions & 7 deletions src/droid.cpp
Expand Up @@ -955,7 +955,7 @@ droidBuildStartAudioCallback( void *psObj )


/* Set up a droid to build a structure - returns true if successful */
bool droidStartBuild(DROID *psDroid)
DroidStartBuild droidStartBuild(DROID *psDroid)
{
STRUCTURE *psStruct;

Expand All @@ -974,22 +974,21 @@ bool droidStartBuild(DROID *psDroid)
{
intBuildFinished(psDroid);
cancelBuild(psDroid);
return false;
return DroidStartBuildFailed;
}
// Can't build on burning oil derricks.
if (psStructStat->type == REF_RESOURCE_EXTRACTOR && fireOnLocation(psDroid->order.pos.x,psDroid->order.pos.y))
{
intBuildFinished(psDroid);
cancelBuild(psDroid);
return false;
// Don't cancel build, since we can wait for it to stop burning.
return DroidStartBuildPending;
}
//ok to build
psStruct = buildStructureDir(psStructStat, psDroid->order.pos.x, psDroid->order.pos.y, psDroid->order.direction, psDroid->player,false);
if (!psStruct)
{
intBuildFinished(psDroid);
cancelBuild(psDroid);
return false;
return DroidStartBuildFailed;
}
psStruct->body = (psStruct->body + 9) / 10; // Structures start at 10% health. Round up.
}
Expand Down Expand Up @@ -1021,7 +1020,7 @@ bool droidStartBuild(DROID *psDroid)

CHECK_DROID(psDroid);

return true;
return DroidStartBuildSuccess;
}

static void droidAddWeldSound( Vector3i iVecEffect )
Expand Down
3 changes: 2 additions & 1 deletion src/droid.h
Expand Up @@ -134,7 +134,8 @@ int32_t droidDamage(DROID *psDroid, unsigned damage, WEAPON_CLASS weaponClass, W
extern void droidUpdate(DROID *psDroid);

/* Set up a droid to build a structure - returns true if successful */
extern bool droidStartBuild(DROID *psDroid);
enum DroidStartBuild {DroidStartBuildFailed, DroidStartBuildSuccess, DroidStartBuildPending};
DroidStartBuild droidStartBuild(DROID *psDroid);

/* Sets a droid to start demolishing - returns true if successful */
extern bool droidStartDemolishing( DROID *psDroid );
Expand Down
1 change: 0 additions & 1 deletion src/hci.cpp
Expand Up @@ -1862,7 +1862,6 @@ INT_RETVAL intRunWidgets(void)
if( ((STRUCTURE_STATS*)psPositionStats)->type == REF_RESOURCE_EXTRACTOR) {
if(fireOnLocation(structX,structY)) {
AddDerrickBurningMessage();
CanBuild = false;
}
}

Expand Down

0 comments on commit 353357b

Please sign in to comment.