Skip to content

Commit

Permalink
Make destroyed half built structures burn half time.
Browse files Browse the repository at this point in the history
Except in the case of derricks, or in the case of adding oil wells in debug mode where
the structure was, this is just a visual change.

Clean up destroyStruct() slightly.
  • Loading branch information
Cyp committed Mar 10, 2012
1 parent 42017f5 commit f6ddbf1
Showing 1 changed file with 18 additions and 32 deletions.
50 changes: 18 additions & 32 deletions src/structure.cpp
Expand Up @@ -4613,8 +4613,6 @@ bool removeStruct(STRUCTURE *psDel, bool bDestroy)
bool destroyStruct(STRUCTURE *psDel, unsigned impactTime)
{
UDWORD widthScatter,breadthScatter,heightScatter;
bool resourceFound = false;
bool bMinor;

const unsigned burnDurationWall = 1000;
const unsigned burnDurationOilWell = 60000;
Expand All @@ -4623,7 +4621,15 @@ bool destroyStruct(STRUCTURE *psDel, unsigned impactTime)
CHECK_STRUCTURE(psDel);

/* Firstly, are we dealing with a wall section */
bMinor = psDel->pStructureType->type == REF_WALL || psDel->pStructureType->type == REF_WALLCORNER;
const bool bMinor = psDel->pStructureType->type == REF_WALL || psDel->pStructureType->type == REF_WALLCORNER;
const bool bDerrick = psDel->pStructureType->type == REF_RESOURCE_EXTRACTOR;
const bool bPowerGen = psDel->pStructureType->type == REF_POWER_GEN;

unsigned burnDuration = bMinor? burnDurationWall : bDerrick? burnDurationOilWell : burnDurationOther;
if (psDel->status == SS_BEING_BUILT || psDel->status == SS_BEING_DEMOLISHED)
{
burnDuration = burnDuration * psDel->currentBuildPts / psDel->pStructureType->buildPoints;
}

/* Only add if visible */
if(psDel->visible[selectedPlayer])
Expand All @@ -4650,36 +4656,28 @@ bool destroyStruct(STRUCTURE *psDel, unsigned impactTime)
pos.y = map_Height(pos.x, pos.z);

// Set off a fire, provide dimensions for the fire
if(bMinor)
if (bMinor)
{
effectGiveAuxVar(world_coord(psDel->pStructureType->baseWidth) / 4);
}
else
{
effectGiveAuxVar(world_coord(psDel->pStructureType->baseWidth) / 3);
}
if (bMinor) // walls
{
/* Give a duration */
effectGiveAuxVarSec(burnDurationWall);
/* Normal fire - no smoke */
addEffect(&pos, EFFECT_FIRE, FIRE_TYPE_LOCALISED, false, NULL, 0, impactTime);
}
else if(psDel->pStructureType->type == REF_RESOURCE_EXTRACTOR) // oil resources
/* Give a duration */
effectGiveAuxVarSec(burnDuration);
if (bDerrick) // oil resources
{
/* Oil resources burn AND puff out smoke AND for longer*/
effectGiveAuxVarSec(burnDurationOilWell);
addEffect(&pos, EFFECT_FIRE, FIRE_TYPE_SMOKY, false, NULL, 0, impactTime);
}
else // everything else
else // everything else
{
/* Give a duration */
effectGiveAuxVarSec(burnDurationOther);
addEffect(&pos, EFFECT_FIRE, FIRE_TYPE_LOCALISED, false, NULL, 0, impactTime);
}

/* Power stations have their own desctruction sequence */
if(psDel->pStructureType->type == REF_POWER_GEN)
if (bPowerGen)
{
addEffect(&pos, EFFECT_DESTRUCTION, DESTRUCTION_TYPE_POWER_STATION, false, NULL, 0, impactTime);
pos.y += SHOCK_WAVE_HEIGHT;
Expand All @@ -4706,21 +4704,9 @@ bool destroyStruct(STRUCTURE *psDel, unsigned impactTime)
}

// Actually set the tiles on fire - even if the effect is not visible.
if (bMinor) // walls
{
tileSetFire(psDel->pos.x, psDel->pos.y, burnDurationWall);
}
else if(psDel->pStructureType->type == REF_RESOURCE_EXTRACTOR) // oil resources
{
/* Oil resources burn AND puff out smoke AND for longer*/
tileSetFire(psDel->pos.x, psDel->pos.y, burnDurationOilWell);
}
else // everything else
{
tileSetFire(psDel->pos.x, psDel->pos.y, burnDurationOther);
}
tileSetFire(psDel->pos.x, psDel->pos.y, burnDuration);

resourceFound = removeStruct(psDel, true);
const bool resourceFound = removeStruct(psDel, true);
psDel->died = impactTime;

// Leave burn marks in the ground where building once stood
Expand Down Expand Up @@ -4748,7 +4734,7 @@ bool destroyStruct(STRUCTURE *psDel, unsigned impactTime)
}

// updates score stats only if not wall
if(psDel->pStructureType->type != REF_WALL && psDel->pStructureType->type != REF_WALLCORNER)
if (bMinor)
{
if(psDel->player == selectedPlayer)
{
Expand Down

0 comments on commit f6ddbf1

Please sign in to comment.