power: Also calculate the construction ETA.
This ETA of course depends on the number of trucks helping with construction.master
parent
a63604fd15
commit
3f22dbc111
|
@ -1137,7 +1137,7 @@ bool droidUpdateBuild(DROID *psDroid)
|
||||||
pointsToAdd = constructPoints * (gameTime - psDroid->actionStarted) /
|
pointsToAdd = constructPoints * (gameTime - psDroid->actionStarted) /
|
||||||
GAME_TICKS_PER_SEC;
|
GAME_TICKS_PER_SEC;
|
||||||
|
|
||||||
structureBuild(psStruct, psDroid, pointsToAdd - psDroid->actionPoints);
|
structureBuild(psStruct, psDroid, pointsToAdd - psDroid->actionPoints, constructPoints);
|
||||||
|
|
||||||
//store the amount just added
|
//store the amount just added
|
||||||
psDroid->actionPoints = pointsToAdd;
|
psDroid->actionPoints = pointsToAdd;
|
||||||
|
|
|
@ -227,7 +227,12 @@ void intUpdateProgressBar(WIDGET *psWidget, W_CONTEXT *psContext)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BarGraph->text.clear(); // TODO Hard to estimate time remaining, since number of trucks can vary.
|
BarGraph->text.clear();
|
||||||
|
if (Structure->lastBuildRate > 0)
|
||||||
|
{
|
||||||
|
int timeToBuild = (Structure->pStructureType->buildPoints - Structure->currentBuildPts) / Structure->lastBuildRate;
|
||||||
|
BarGraph->text = formatTime(timeToBuild);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BuildPoints > Range)
|
if (BuildPoints > Range)
|
||||||
|
|
|
@ -866,7 +866,7 @@ int32_t getStructureDamage(const STRUCTURE *psStructure)
|
||||||
|
|
||||||
/// Add buildPoints to the structures currentBuildPts, due to construction work by the droid
|
/// Add buildPoints to the structures currentBuildPts, due to construction work by the droid
|
||||||
/// Also can deconstruct (demolish) a building if passed negative buildpoints
|
/// Also can deconstruct (demolish) a building if passed negative buildpoints
|
||||||
void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints)
|
void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints, int buildRate)
|
||||||
{
|
{
|
||||||
if (psDroid && !aiCheckAlliances(psStruct->player,psDroid->player))
|
if (psDroid && !aiCheckAlliances(psStruct->player,psDroid->player))
|
||||||
{
|
{
|
||||||
|
@ -888,7 +888,7 @@ void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
psStruct->builtThisTick = true;
|
psStruct->buildRate += buildRate; // buildRate = buildPoints/GAME_UPDATES_PER_SEC, but might be rounded up or down each tick, so can't use buildPoints to get a stable number.
|
||||||
if (psStruct->currentBuildPts <= 0 && buildPoints > 0)
|
if (psStruct->currentBuildPts <= 0 && buildPoints > 0)
|
||||||
{
|
{
|
||||||
// Just starting to build structure, need power for it.
|
// Just starting to build structure, need power for it.
|
||||||
|
@ -1845,7 +1845,7 @@ STRUCTURE* buildStructureDir(STRUCTURE_STATS *pStructureType, UDWORD x, UDWORD y
|
||||||
psBuilding->currentBuildPts = 0;
|
psBuilding->currentBuildPts = 0;
|
||||||
//start building again
|
//start building again
|
||||||
psBuilding->status = SS_BEING_BUILT;
|
psBuilding->status = SS_BEING_BUILT;
|
||||||
psBuilding->builtThisTick = true; // Don't abandon the structure first tick.
|
psBuilding->buildRate = 1; // Don't abandon the structure first tick, so set to nonzero.
|
||||||
if (psBuilding->player == selectedPlayer && !FromSave)
|
if (psBuilding->player == selectedPlayer && !FromSave)
|
||||||
{
|
{
|
||||||
intRefreshScreen();
|
intRefreshScreen();
|
||||||
|
@ -3737,11 +3737,12 @@ void structureUpdate(STRUCTURE *psBuilding, bool mission)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (psBuilding->status == SS_BEING_BUILT && psBuilding->currentBuildPts == 0 && !psBuilding->builtThisTick && !structureHasModules(psBuilding))
|
if (psBuilding->status == SS_BEING_BUILT && psBuilding->currentBuildPts == 0 && psBuilding->buildRate == 0 && !structureHasModules(psBuilding))
|
||||||
{
|
{
|
||||||
removeStruct(psBuilding, true); // If giving up on building something, remove the structure (and remove it from the power queue).
|
removeStruct(psBuilding, true); // If giving up on building something, remove the structure (and remove it from the power queue).
|
||||||
}
|
}
|
||||||
psBuilding->builtThisTick = false;
|
psBuilding->lastBuildRate = psBuilding->buildRate;
|
||||||
|
psBuilding->buildRate = 0; // Reset to 0, each truck building us will add to our buildRate.
|
||||||
|
|
||||||
/* Only add smoke if they're visible and they can 'burn' */
|
/* Only add smoke if they're visible and they can 'burn' */
|
||||||
if (!mission && psBuilding->visible[selectedPlayer] && canSmoke(psBuilding))
|
if (!mission && psBuilding->visible[selectedPlayer] && canSmoke(psBuilding))
|
||||||
|
@ -3874,7 +3875,8 @@ void structureUpdate(STRUCTURE *psBuilding, bool mission)
|
||||||
STRUCTURE::STRUCTURE(uint32_t id, unsigned player)
|
STRUCTURE::STRUCTURE(uint32_t id, unsigned player)
|
||||||
: BASE_OBJECT(OBJ_STRUCTURE, id, player)
|
: BASE_OBJECT(OBJ_STRUCTURE, id, player)
|
||||||
, pFunctionality(NULL)
|
, pFunctionality(NULL)
|
||||||
, builtThisTick(true)
|
, buildRate(1) // Initialise to 1 instead of 0, to make sure we don't get destroyed first tick due to inactivity.
|
||||||
|
, lastBuildRate(0)
|
||||||
, psCurAnim(NULL)
|
, psCurAnim(NULL)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ extern bool structureStatsShutDown(void);
|
||||||
int requestOpenGate(STRUCTURE *psStructure);
|
int requestOpenGate(STRUCTURE *psStructure);
|
||||||
|
|
||||||
int32_t structureDamage(STRUCTURE *psStructure, UDWORD damage, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, HIT_SIDE impactSide);
|
int32_t structureDamage(STRUCTURE *psStructure, UDWORD damage, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, HIT_SIDE impactSide);
|
||||||
extern void structureBuild(STRUCTURE *psStructure, DROID *psDroid, int buildPoints);
|
extern void structureBuild(STRUCTURE *psStructure, DROID *psDroid, int buildPoints, int buildRate = 1);
|
||||||
extern void structureDemolish(STRUCTURE *psStructure, DROID *psDroid, int buildPoints);
|
extern void structureDemolish(STRUCTURE *psStructure, DROID *psDroid, int buildPoints);
|
||||||
extern bool structureRepair(STRUCTURE *psStruct, DROID *psDroid, int buildPoints);
|
extern bool structureRepair(STRUCTURE *psStruct, DROID *psDroid, int buildPoints);
|
||||||
/* Set the type of droid for a factory to build */
|
/* Set the type of droid for a factory to build */
|
||||||
|
|
|
@ -253,7 +253,8 @@ struct STRUCTURE : public BASE_OBJECT
|
||||||
SWORD resistance; /* current resistance points, 0 = cannot be attacked electrically */
|
SWORD resistance; /* current resistance points, 0 = cannot be attacked electrically */
|
||||||
UDWORD lastResistance; /* time the resistance was last increased*/
|
UDWORD lastResistance; /* time the resistance was last increased*/
|
||||||
FUNCTIONALITY *pFunctionality; /* pointer to structure that contains fields necessary for functionality */
|
FUNCTIONALITY *pFunctionality; /* pointer to structure that contains fields necessary for functionality */
|
||||||
bool builtThisTick; ///< True iff someone tried building the structure this tick. If construction hasn't started, remove the structure.
|
int buildRate; ///< Rate that this structure is being built, calculated each tick. Only meaningful if status == SS_BEING_BUILT. If construction hasn't started and build rate is 0, remove the structure.
|
||||||
|
int lastBuildRate; ///< Needed if wanting the buildRate between buildRate being reset to 0 each tick and the trucks calculating it.
|
||||||
|
|
||||||
/* The weapons on the structure */
|
/* The weapons on the structure */
|
||||||
UWORD numWeaps;
|
UWORD numWeaps;
|
||||||
|
|
Loading…
Reference in New Issue