The commit to fix the unsigned int underflow (ticket 404) had as unfortunate side effect that building was possible even when out of power. This fixes it.

master
Gerard Krol 2009-04-23 01:34:23 +02:00
parent c17d6fcbd8
commit 6cb979ac1a
1 changed files with 5 additions and 0 deletions

View File

@ -1166,6 +1166,11 @@ void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints)
addPower(psStruct->player, -powerNeeded); addPower(psStruct->player, -powerNeeded);
} }
newBuildPoints = (int)psStruct->currentBuildPts;
newBuildPoints += buildPointsToAdd;
ASSERT(newBuildPoints < 3 * (int)psStruct->pStructureType->buildPoints, "unsigned int underflow?");
CLIP(newBuildPoints, 0, psStruct->pStructureType->buildPoints);
before = (9 * psStruct->currentBuildPts * structureBody(psStruct) ) / (10 * psStruct->pStructureType->buildPoints); before = (9 * psStruct->currentBuildPts * structureBody(psStruct) ) / (10 * psStruct->pStructureType->buildPoints);
psStruct->currentBuildPts = newBuildPoints; psStruct->currentBuildPts = newBuildPoints;
after = (9 * psStruct->currentBuildPts * structureBody(psStruct) ) / (10 * psStruct->pStructureType->buildPoints); after = (9 * psStruct->currentBuildPts * structureBody(psStruct) ) / (10 * psStruct->pStructureType->buildPoints);