* Remove unused parameters
 * Fix several "comparison between signed and unsigned" warnings
 * Move some variables into a more local scope
 * Mark several unused parameters with WZ_DECL_UNUSED for callback functions
 * Give some variables decent names (e.g. 'j' is ''not'' a good name for a variable holding a player number)

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6170 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-10-15 20:01:02 +00:00
parent bc5396e8ed
commit d1308a59f6
15 changed files with 52 additions and 42 deletions

View File

@ -840,7 +840,7 @@ void droidUpdate(DROID *psDroid)
// May need power // May need power
if (droidUsesPower(psDroid)) if (droidUsesPower(psDroid))
{ {
if (checkPower(psDroid->player, POWER_PER_CYCLE, false)) if (checkPower(psDroid->player, POWER_PER_CYCLE))
{ {
// Check if this droid is due some power // Check if this droid is due some power
if (getLastPowered((BASE_OBJECT *)psDroid)) if (getLastPowered((BASE_OBJECT *)psDroid))

View File

@ -1480,7 +1480,7 @@ static void intProcessEditStats(UDWORD id)
if (psPositionStats->ref >= REF_STRUCTURE_START && if (psPositionStats->ref >= REF_STRUCTURE_START &&
psPositionStats->ref < REF_STRUCTURE_START + REF_RANGE) psPositionStats->ref < REF_STRUCTURE_START + REF_RANGE)
{ {
if (!checkPower(selectedPlayer, ((STRUCTURE_STATS*)psPositionStats)->powerToBuild, true)) if (!checkPower(selectedPlayer, ((STRUCTURE_STATS*)psPositionStats)->powerToBuild))
{ {
return; return;
} }
@ -1490,7 +1490,7 @@ static void intProcessEditStats(UDWORD id)
if (psPositionStats->ref >= REF_TEMPLATE_START && if (psPositionStats->ref >= REF_TEMPLATE_START &&
psPositionStats->ref < REF_TEMPLATE_START + REF_RANGE) psPositionStats->ref < REF_TEMPLATE_START + REF_RANGE)
{ {
if (!checkPower(selectedPlayer, ((DROID_TEMPLATE*)psPositionStats)->powerPoints, true)) if (!checkPower(selectedPlayer, ((DROID_TEMPLATE*)psPositionStats)->powerPoints))
{ {
return; return;
} }
@ -6351,8 +6351,7 @@ static BOOL setManufactureStats(BASE_OBJECT *psObj, BASE_STATS *psStats)
//check if its because there isn't enough power - warning if it is //check if its because there isn't enough power - warning if it is
if (psStats) if (psStats)
{ {
(void)checkPower(selectedPlayer, ((DROID_TEMPLATE *)psStats)-> (void)checkPower(selectedPlayer, ((DROID_TEMPLATE *)psStats)->powerPoints);
powerPoints, true);
} }
return false; return false;
} }
@ -6368,7 +6367,7 @@ static BOOL setManufactureStats(BASE_OBJECT *psObj, BASE_STATS *psStats)
/* check power if factory not on infinte production*/ /* check power if factory not on infinte production*/
if (ProductionRun != NON_STOP_PRODUCTION) if (ProductionRun != NON_STOP_PRODUCTION)
{ {
if (!checkPower(selectedPlayer, ((DROID_TEMPLATE *)psStats)->powerPoints, true)) if (!checkPower(selectedPlayer, ((DROID_TEMPLATE *)psStats)->powerPoints))
{ {
return false; return false;
} }

View File

@ -757,7 +757,7 @@ void saveMissionData(void)
if (inc > 0) if (inc > 0)
{ {
// not accrued enough power, so check if there is enough available // not accrued enough power, so check if there is enough available
if (checkPower(selectedPlayer, inc, false)) if (checkPower(selectedPlayer, inc))
{ {
// enough - so use it and set to complete // enough - so use it and set to complete
usePower(selectedPlayer, inc); usePower(selectedPlayer, inc);

View File

@ -344,7 +344,7 @@ void createLimitSet(void)
void applyLimitSet(void) void applyLimitSet(void)
{ {
MULTISTRUCTLIMITS *pEntry = ingame.pStructureLimits; MULTISTRUCTLIMITS *pEntry = ingame.pStructureLimits;
int i, j; unsigned int i;
if (ingame.numStructureLimits == 0) if (ingame.numStructureLimits == 0)
{ {
@ -352,14 +352,15 @@ void applyLimitSet(void)
} }
// Get the limits and decode // Get the limits and decode
for (i = 0; i < ingame.numStructureLimits; i++) for (i = 0; i < ingame.numStructureLimits; ++i)
{ {
UBYTE id = pEntry[i].id; UBYTE id = pEntry[i].id;
// So long as the ID is valid // So long as the ID is valid
if (id < numStructureStats) if (id < numStructureStats)
{ {
for (j = 0; j < MAX_PLAYERS; j++) unsigned int j;
for (j = 0; j < MAX_PLAYERS; ++j)
{ {
asStructLimits[j][id].limit = pEntry[i].limit; asStructLimits[j][id].limit = pEntry[i].limit;
} }
@ -377,7 +378,7 @@ void applyLimitSet(void)
// //////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////////
static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
{ {
UDWORD x = xOffset+psWidget->x; UDWORD x = xOffset+psWidget->x;
UDWORD y = yOffset+psWidget->y; UDWORD y = yOffset+psWidget->y;

View File

@ -66,7 +66,7 @@ extern char buildTime[8];
// dpid == 0 for no new players. // dpid == 0 for no new players.
void sendOptions(uint32_t dest, uint32_t play) void sendOptions(uint32_t dest, uint32_t play)
{ {
int i, j; unsigned int i;
NETbeginEncode(NET_OPTIONS, NET_ALL_PLAYERS); NETbeginEncode(NET_OPTIONS, NET_ALL_PLAYERS);
@ -112,6 +112,8 @@ void sendOptions(uint32_t dest, uint32_t play)
// Same goes for the alliances // Same goes for the alliances
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
{ {
unsigned int j;
for (j = 0; j < MAX_PLAYERS; j++) for (j = 0; j < MAX_PLAYERS; j++)
{ {
NETuint8_t(&alliances[i][j]); NETuint8_t(&alliances[i][j]);
@ -167,7 +169,7 @@ static BOOL checkGameWdg(const char *nm)
// options for a game. (usually recvd in frontend) // options for a game. (usually recvd in frontend)
void recvOptions() void recvOptions()
{ {
int i, j; unsigned int i;
UDWORD play; UDWORD play;
UDWORD newPl; UDWORD newPl;
@ -219,6 +221,8 @@ void recvOptions()
// Alliances // Alliances
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
{ {
unsigned int j;
for (j = 0; j < MAX_PLAYERS; j++) for (j = 0; j < MAX_PLAYERS; j++)
{ {
NETuint8_t(&alliances[i][j]); NETuint8_t(&alliances[i][j]);
@ -758,7 +762,6 @@ static BOOL campInit(void)
{ {
UDWORD player; UDWORD player;
UBYTE newPlayerArray[MAX_PLAYERS]; UBYTE newPlayerArray[MAX_PLAYERS];
UDWORD i,j,lastAI;
SDWORD newPlayerTeam[MAX_PLAYERS] = {-1,-1,-1,-1,-1,-1,-1,-1}; SDWORD newPlayerTeam[MAX_PLAYERS] = {-1,-1,-1,-1,-1,-1,-1,-1};
// if this is from a savegame, stop here! // if this is from a savegame, stop here!
@ -777,35 +780,45 @@ static BOOL campInit(void)
//Convert skirmish GUI player ids to in-game ids //Convert skirmish GUI player ids to in-game ids
if(game.type == SKIRMISH) if(game.type == SKIRMISH)
{ {
lastAI = 0; //last used AI slot unsigned int i;
unsigned int lastAI = 0; // last used AI slot
memset(newPlayerArray,1,MAX_PLAYERS * sizeof(newPlayerArray[0])); //'1' for humans memset(newPlayerArray,1,MAX_PLAYERS * sizeof(newPlayerArray[0])); //'1' for humans
for(i=0;i<MAX_PLAYERS;i++) for(i = 0; i < MAX_PLAYERS; ++i)
{ {
if(game.skDiff[i] < UBYTE_MAX ) //slot with enabled or disabled AI if(game.skDiff[i] < UBYTE_MAX ) //slot with enabled or disabled AI
{ {
unsigned int player;
//find first unused slot //find first unused slot
for(j=lastAI;j<MAX_PLAYERS && isHumanPlayer(j);j++); //skip humans for (player = lastAI;
player < MAX_PLAYERS && isHumanPlayer(player); // skip humans
++player);
ASSERT(j<MAX_PLAYERS,"campInit: couldn't find free slot while assigning AI %d , lastAI=%d", i, lastAI); ASSERT(player < MAX_PLAYERS, "couldn't find free slot while assigning AI %u, lastAI=%u", i, lastAI);
newPlayerArray[j] = game.skDiff[i]; //copy over newPlayerArray[player] = game.skDiff[i]; //copy over
newPlayerTeam[j] = playerTeamGUI[i]; newPlayerTeam[player] = playerTeamGUI[i];
//remove player if it was disabled in menus //remove player if it was disabled in menus
if(game.skDiff[i] == 0) if(game.skDiff[i] == 0)
clearPlayer(j,true,false); clearPlayer(player,true,false);
lastAI = j; lastAI = player;
lastAI++; lastAI++;
} }
else if(game.skDiff[i] == UBYTE_MAX) //human player else if(game.skDiff[i] == UBYTE_MAX) //human player
{ {
unsigned int player;
//find player net id //find player net id
for(j=0;(j < MAX_PLAYERS) && (player2dpid[j] != NetPlay.players[i].dpid);j++); for (player = 0;
player < MAX_PLAYERS && player2dpid[player] != NetPlay.players[i].dpid;
++player);
ASSERT(j<MAX_PLAYERS,"campInit: couldn't find player id for GUI id %d", i); ASSERT(player < MAX_PLAYERS, "couldn't find player id for GUI id %u", i);
newPlayerTeam[j] = playerTeamGUI[i]; newPlayerTeam[player] = playerTeamGUI[i];
} }
} }

View File

@ -99,7 +99,7 @@ BOOL recvBuildStarted()
STRUCTURE_STATS *psStats; STRUCTURE_STATS *psStats;
DROID *psDroid; DROID *psDroid;
UDWORD actionX,actionY; UDWORD actionX,actionY;
int typeIndex; unsigned int typeIndex;
uint8_t player; uint8_t player;
uint16_t x, y, z; uint16_t x, y, z;
int32_t order; int32_t order;

View File

@ -440,7 +440,7 @@ void orderUpdateDroid(DROID *psDroid)
if (psDroid->player == selectedPlayer && getDroidsToSafetyFlag() && if (psDroid->player == selectedPlayer && getDroidsToSafetyFlag() &&
missionDroidsRemaining(selectedPlayer)) missionDroidsRemaining(selectedPlayer))
{ {
resetTransporter(psDroid); resetTransporter();
} }
else else
{ {

View File

@ -86,7 +86,7 @@ void releasePlayerPower(void)
} }
/*check the current power - if enough return true, else return false */ /*check the current power - if enough return true, else return false */
BOOL checkPower(UDWORD player, UDWORD quantity, BOOL playAudio) BOOL checkPower(UDWORD player, UDWORD quantity)
{ {
ASSERT(player < MAX_PLAYERS, "checkPower: Bad player"); ASSERT(player < MAX_PLAYERS, "checkPower: Bad player");

View File

@ -56,7 +56,7 @@ extern BOOL resetPlayerPower(UDWORD player, STRUCTURE *psStruct);
extern void releasePlayerPower(void); extern void releasePlayerPower(void);
/** Check the available power. */ /** Check the available power. */
extern BOOL checkPower(UDWORD player, UDWORD quantity, BOOL playAudio); extern BOOL checkPower(UDWORD player, UDWORD quantity);
/** Subtract the power required. */ /** Subtract the power required. */
extern BOOL usePower(UDWORD player, UDWORD quantity); extern BOOL usePower(UDWORD player, UDWORD quantity);

View File

@ -485,16 +485,13 @@ static SDWORD getDistanceAdjust( void )
static SDWORD getLengthAdjust( void ) static SDWORD getLengthAdjust( void )
{ {
SDWORD pitch; const int pitch = 360 - (player.r.x/DEG_1);
UDWORD lookingDown,lookingFar;
SDWORD dif;
pitch = 360 - (player.r.x/DEG_1);
// Max at // Max at
lookingDown = (0 - MIN_PLAYER_X_ANGLE); const int lookingDown = (0 - MIN_PLAYER_X_ANGLE);
lookingFar = (0 - MAX_PLAYER_X_ANGLE); const int lookingFar = (0 - MAX_PLAYER_X_ANGLE);
dif = MAX(pitch - lookingFar, 0);
int dif = MAX(pitch - lookingFar, 0);
if (dif > (lookingDown - lookingFar)) if (dif > (lookingDown - lookingFar))
{ {
dif = (lookingDown - lookingFar); dif = (lookingDown - lookingFar);

View File

@ -86,7 +86,7 @@ static bool getTileHighestCallback(Vector3i pos, int distSq, void* data)
if (clipXY(pos.x, pos.y)) if (clipXY(pos.x, pos.y))
{ {
unsigned int height = map_Height(pos.x, pos.y), dist = sqrtf(distSq); int height = map_Height(pos.x, pos.y), dist = sqrtf(distSq);
if (height > help->highestHeight && dist >= help->minDist) if (height > help->highestHeight && dist >= help->minDist)
{ {
int heightDif = height - help->origHeight; int heightDif = height - help->origHeight;

View File

@ -2898,7 +2898,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure)
//check if any power available //check if any power available
if (structUsesPower(psStructure)) if (structUsesPower(psStructure))
{ {
if (checkPower(psStructure->player, POWER_PER_CYCLE, false)) if (checkPower(psStructure->player, POWER_PER_CYCLE))
{ {
//check if this structure is due some power //check if this structure is due some power
if (getLastPowered((BASE_OBJECT *)psStructure)) if (getLastPowered((BASE_OBJECT *)psStructure))

View File

@ -75,7 +75,7 @@ void targetCloseList(void)
{ {
} }
void targetAdd(BASE_OBJECT *psObj) void targetAdd(WZ_DECL_UNUSED BASE_OBJECT* psObj)
{ {
} }

View File

@ -1890,7 +1890,7 @@ DROID * transporterGetScriptCurrent( void )
} }
/*called when a Transporter has arrived back at the LZ when sending droids to safety*/ /*called when a Transporter has arrived back at the LZ when sending droids to safety*/
void resetTransporter(DROID *psTransporter) void resetTransporter()
{ {
W_CLICKFORM *psForm; W_CLICKFORM *psForm;

View File

@ -89,7 +89,7 @@ extern DROID * transporterGetScriptCurrent( void );
//extern BOOL transporterOnMission( void ); //extern BOOL transporterOnMission( void );
/*called when a Transporter has arrived back at the LZ when sending droids to safety*/ /*called when a Transporter has arrived back at the LZ when sending droids to safety*/
extern void resetTransporter(DROID *psTransporter); extern void resetTransporter(void);
/* get time transporter launch button was pressed */ /* get time transporter launch button was pressed */
extern UDWORD transporterGetLaunchTime( void ); extern UDWORD transporterGetLaunchTime( void );