Power is now used directly when building, no power is accrued anymore.

master
Gerard Krol 2009-04-04 17:02:34 +02:00
parent c6690fa894
commit 72da02cf97
3 changed files with 14 additions and 31 deletions

View File

@ -1227,13 +1227,6 @@ BOOL droidUpdateBuild(DROID *psDroid)
return false;
}
// For now wait until have enough power to build
if (psStruct->currentPowerAccrued < (SWORD) structPowerToBuild(psStruct))
{
psDroid->actionStarted = gameTime;
return true;
}
constructPoints = constructorPoints(asConstructStats + psDroid->
asBits[COMP_CONSTRUCT].nStat, psDroid->player);

View File

@ -457,30 +457,7 @@ BOOL accruePower(BASE_OBJECT *psObject)
{
case DROID_CONSTRUCT:
case DROID_CYBORG_CONSTRUCT:
//check trying to build something (and that hasn't been blown up)
if (DroidIsBuilding(psDroid) && psDroid->psTarget && !psDroid->psTarget->died)
{
powerDiff = structPowerToBuild((STRUCTURE *)psDroid->psTarget) -
((STRUCTURE *)psDroid->psTarget)->currentPowerAccrued;
//if equal then don't need power
if (powerDiff)
{
if (POWER_PER_CYCLE >= powerDiff)
{
usePower(psDroid->player, powerDiff);
((STRUCTURE *)psDroid->psTarget)->currentPowerAccrued +=
powerDiff;
bPowerUsed = true;
}
else if (powerDiff > POWER_PER_CYCLE)
{
usePower(psDroid->player, POWER_PER_CYCLE);
((STRUCTURE *)psDroid->psTarget)->currentPowerAccrued +=
POWER_PER_CYCLE;
bPowerUsed = true;
}
}
}
// power is used directly when building, in structureBuild
break;
case DROID_REPAIR:
case DROID_CYBORG_REPAIR:

View File

@ -1218,6 +1218,19 @@ float getStructureDamage(const STRUCTURE* psStructure)
void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints)
{
int before, after;
int powerNeeded;
// Check if there is enough power to perform this construction work
powerNeeded = ((psStruct->currentBuildPts + buildPoints) * structPowerToBuild(psStruct))/psStruct->pStructureType->buildPoints -
(psStruct->currentBuildPts * structPowerToBuild(psStruct))/psStruct->pStructureType->buildPoints;
powerNeeded = MIN(powerNeeded, POWER_PER_CYCLE);
if (!usePower(psDroid->player, powerNeeded))
{
return;
}
before = (9 * psStruct->currentBuildPts * structureBody(psStruct) ) / (10 * psStruct->pStructureType->buildPoints);
psStruct->currentBuildPts += buildPoints;
after = (9 * psStruct->currentBuildPts * structureBody(psStruct) ) / (10 * psStruct->pStructureType->buildPoints);