* Remove whitespace from the end of lines

* Add a FIXME note about needing to control the calling frequency of handleAbandonedStructures externally
 * Moved variable reductionAmount into the most local scope
 * Rename iterator `i` to `player`


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4406 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-03-29 13:27:54 +00:00
parent 29578ca90f
commit 931f87f70a
23 changed files with 64 additions and 60 deletions

View File

@ -1169,9 +1169,11 @@ BOOL structureStatsShutDown(void)
// TODO: The abandoned code needs to be factored out, see: saveMissionData
void handleAbandonedStructures()
{
// FIXME: We should control the calling frequency externally from this
// function, rather than controlling the amount of times this
// function performs work internally.
static int lastHandled = 0;
int reductionAmount = 8;
int i;
int player;
// We only need to run once every two seconds (2000ms)
if (gameTime - lastHandled < 2000)
@ -1182,11 +1184,11 @@ void handleAbandonedStructures()
// Update when we last ran
lastHandled = gameTime;
for (i = 0; i < MAX_PLAYERS; i++)
for (player = 0; player < MAX_PLAYERS; ++player)
{
STRUCTURE *psCurr, *psNext;
for (psCurr = apsStructLists[i]; psCurr; psCurr = psNext)
for (psCurr = apsStructLists[player]; psCurr; psCurr = psNext)
{
// Save the next structure in the list
psNext = psCurr->psNext;
@ -1199,7 +1201,7 @@ void handleAbandonedStructures()
bool beingBuilt = false;
// See is there are any droids building it
for (psDroid = apsDroidLists[i];
for (psDroid = apsDroidLists[player];
psDroid;
psDroid = psDroid->psNext)
{
@ -1219,12 +1221,14 @@ void handleAbandonedStructures()
// Abandoned
else
{
int reductionAmount = 8;
// Work out how much power to deduct
CLIP(reductionAmount, 0, psCurr->currentPowerAccrued);
// Do the reduction
psCurr->currentPowerAccrued -= reductionAmount;
addPower(i, reductionAmount);
addPower(player, reductionAmount);
// Remove the structure if no power is accrued
if (!psCurr->currentPowerAccrued)