Wrap several access to asPower with getPower().

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3792 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2008-02-15 21:48:51 +00:00
parent f2098a60ee
commit a07da6772c
5 changed files with 6 additions and 12 deletions

View File

@ -2275,13 +2275,9 @@ static void intRunStats(void)
{
//get the template build points
Power = calcTemplatePower((DROID_TEMPLATE *)apsTemplateList[statID - IDSTAT_START]);
/*if(Power * Quantity > asPower[selectedPlayer]->availablePower)
if (Power * Quantity > getPower(selectedPlayer))
{
Quantity = asPower[selectedPlayer]->availablePower / Power;
}*/
if(Power * Quantity > asPower[selectedPlayer]->currentPower)
{
Quantity = (UBYTE)(asPower[selectedPlayer]->currentPower / Power);
Quantity = (UBYTE)(getPower(selectedPlayer) / Power);
}
}
}

View File

@ -313,7 +313,7 @@ void giftPower(uint8_t from, uint8_t to, BOOL send)
else
{
// Give 1/3 of our power away
gifval = asPower[from]->currentPower / 3;
gifval = getPower(from) / 3;
usePower(from, gifval);
}
@ -579,8 +579,7 @@ void addLoserGifts(void)
lastgift = 0; // might be a restart
// Player has no power, so give the player some oil
if (apsStructLists[selectedPlayer]
&& asPower[selectedPlayer]->currentPower < 10)
if (apsStructLists[selectedPlayer] && getPower(selectedPlayer) < 10)
{
// Only proceed if it's been a while
if (gameTime - lastgift < GIFTFREQ)

View File

@ -876,7 +876,7 @@ void displayMultiPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIG
iV_DrawText(str, x+MULTIMENU_C10, y+MULTIMENU_FONT_OSET);
//c11: Player power
sprintf(str,"%d",asPower[player]->currentPower);
sprintf(str, "%u", getPower(player));
iV_DrawText(str, MULTIMENU_FORM_X+MULTIMENU_C11, y+MULTIMENU_FONT_OSET);
}

View File

@ -337,7 +337,6 @@ void setPower(UDWORD player, UDWORD avail)
asPower[player]->currentPower = avail;
}
// only used in multiplayer games.
UDWORD getPower(UDWORD player)
{
ASSERT(player < MAX_PLAYERS, "setPower: Bad player (%u)", player);

View File

@ -248,7 +248,7 @@ BOOL scrPlayerPower(void)
return FALSE;
}
scrFunctionResult.v.ival = asPower[player]->currentPower;
scrFunctionResult.v.ival = getPower(player);
if (!stackPushResult(VAL_INT, &scrFunctionResult))
{
return FALSE;