* 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

@ -31,7 +31,7 @@
typedef struct _bridge_info
{
UDWORD startX,startY,endX,endY; // Copy of coordinates of bridge.
UDWORD startX,startY,endX,endY; // Copy of coordinates of bridge.
UDWORD heightChange; // How much to raise lowest end by.
UDWORD bridgeHeight; // How high are the sections?
UDWORD bridgeLength; // How many tiles long?

View File

@ -52,7 +52,7 @@ extern void combFire(WEAPON *psWeap, BASE_OBJECT *psAttacker, BASE_OBJECT *psTar
if any support a counter battery sensor*/
extern void counterBatteryFire(BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget);
extern float objDamage(BASE_OBJECT *psObj, UDWORD damage, UDWORD originalhp, UDWORD weaponClass,
extern float objDamage(BASE_OBJECT *psObj, UDWORD damage, UDWORD originalhp, UDWORD weaponClass,
UDWORD weaponSubClass, HIT_SIDE impactSide);
#endif // __INCLUDED_SRC_COMBAT_H__

View File

@ -294,7 +294,7 @@ static BOOL _addConsoleMessage(const char *messageText, CONSOLE_TEXT_JUSTIFICATI
}
/// Wrapper for _addConsoleMessage
BOOL addConsoleMessage(const char *messageText, CONSOLE_TEXT_JUSTIFICATION jusType,
BOOL addConsoleMessage(const char *messageText, CONSOLE_TEXT_JUSTIFICATION jusType,
CONSOLE_TEXT_TYPE textType)
{
return _addConsoleMessage(messageText, jusType, textType);

View File

@ -1037,7 +1037,7 @@ FPATH_RETVAL fpathRoute(BASE_OBJECT *psObj, MOVE_CONTROL *psMoveCntl,
// Does this code work? - Per
targetX = clearX;
targetY = clearY;
objTrace(LOG_MOVEMENT, psObj->id, "Unit %d: end point is blocked, going to (%d, %d) instead",
objTrace(LOG_MOVEMENT, psObj->id, "Unit %d: end point is blocked, going to (%d, %d) instead",
(int)psObj->id, (int)clearX, (int)clearY);
}
@ -1046,7 +1046,7 @@ FPATH_RETVAL fpathRoute(BASE_OBJECT *psObj, MOVE_CONTROL *psMoveCntl,
{
if (psPartialRouteObj != NULL)
{
objTrace(LOG_MOVEMENT, psObj->id, "fpathRoute droid %d: found existing route during multi-frame path",
objTrace(LOG_MOVEMENT, psObj->id, "fpathRoute droid %d: found existing route during multi-frame path",
(int)psObj->id);
}
else

View File

@ -64,7 +64,7 @@ extern void fpathSetBlockingTile( UBYTE ubPropulsionType );
extern void fpathSetCurrentObject( BASE_OBJECT *psDroid );
/**
* Set direct path to position. Plan a path from psObj's current position to given position
* Set direct path to position. Plan a path from psObj's current position to given position
* without taking obstructions into consideration. Used for instance by VTOLs.
*/
extern void fpathSetDirectRoute(BASE_OBJECT *psObj, SDWORD targetX, SDWORD targetY);

View File

@ -241,7 +241,7 @@
/* maximum array sizes */
#define MAXSTRUCTURES 200 //bumped up from 80. NOTE: was used for max # in build menus.
#define MAXRESEARCH 200 //was 80 topic displayed " "
#define MAXTEMPLATES 80 //was 20
#define MAXTEMPLATES 80 //was 20
#define MAXFEATURES 80
#define MAXCOMPONENT 80
#define MAXEXTRASYS 80

View File

@ -24,7 +24,7 @@
#ifndef __INCLUDED_SRC_INGAMEOP_H__
#define __INCLUDED_SRC_INGAMEOP_H__
// functions
// functions
extern BOOL intAddInGameOptions (void);
extern BOOL intCloseInGameOptions (BOOL bPutUpLoadSave, BOOL bResetMissionWidgets);
extern void intCloseInGameOptionsNoAnim (BOOL bResetMissionWidgets);
@ -49,7 +49,7 @@ extern BOOL InGameOpUp;
// game options
// initial options
#define INTINGAMEOP_W 120
#define INTINGAMEOP_W 120
#define INTINGAMEOP_H 124
#define INTINGAMEOP_HS 88

View File

@ -400,7 +400,7 @@ void kf_ToggleSamples(void) //Displays number of sound sample in the sound queue
/* Writes out the frame rate */
void kf_FrameRate( void )
{
CONPRINTF(ConsoleString,(ConsoleString, _("FPS %d; FPS-Limit: %d; PIEs %d; polys %d; Terr. polys %d; States %d"),
CONPRINTF(ConsoleString,(ConsoleString, _("FPS %d; FPS-Limit: %d; PIEs %d; polys %d; Terr. polys %d; States %d"),
frameGetAverageRate(), getFramerateLimit(), loopPieCount, loopPolyCount, loopTileCount, loopStateChanges));
if (runningMultiplayer()) {
CONPRINTF(ConsoleString,(ConsoleString,
@ -2260,13 +2260,13 @@ float available_speed[] = {
// Since some of these values can ruin a SP game, we disallow them in normal mode.
1.f / 8.f, // n
1.f / 5.f, // n
1.f / 3.f, // p
1.f / 3.f, // p
3.f / 4.f, // p
1.f / 1.f, // p
1.f / 1.f, // p
5.f / 4.f, // p
3.f / 2.f, // p
2.f / 1.f, // p (in debug mode only)
5.f / 2.f, // n
5.f / 2.f, // n
3.f / 1.f, // n
10.f / 1.f, // n
20.f / 1.f // n
@ -2296,7 +2296,7 @@ void kf_SpeedUp( void )
mod = available_speed[i];
// only in debug/cheat mode do we enable all time compression speeds.
if (!getDebugMappingStatus())
{
{
if (mod >= 2.f / 1.f) // max officialy allowed time compression
break;
}
@ -2337,7 +2337,7 @@ void kf_SlowDown( void )
mod = available_speed[i];
// only in debug/cheat mode do we enable all time compression speeds.
if( !getDebugMappingStatus() )
{
{
if (mod < 1.f / 3.f)
break;
}

View File

@ -59,7 +59,7 @@ char *pName;
struct _keyMapping *psNext;
} KEY_MAPPING;
extern KEY_MAPPING *keyAddMapping ( KEY_STATUS status, KEY_CODE metaCode, KEY_CODE subcode,
extern KEY_MAPPING *keyAddMapping ( KEY_STATUS status, KEY_CODE metaCode, KEY_CODE subcode,
KEY_ACTION action, void (*pKeyMapFunc)(void), const char *name );
extern BOOL keyRemoveMapping ( KEY_CODE metaCode, KEY_CODE subCode );
extern KEY_MAPPING *keyGetMappingFromFunction(void *function);
@ -80,8 +80,8 @@ extern void keySetMappingStatus ( KEY_MAPPING *psMapping, BOOL state );
extern void processDebugMappings ( BOOL val );
extern BOOL getDebugMappingStatus ( void );
extern BOOL keyReAssignMappingName(char *pName, KEY_CODE newMetaCode, KEY_CODE newSubCode);
extern BOOL keyReAssignMapping( KEY_CODE origMetaCode, KEY_CODE origSubCode,
extern BOOL keyReAssignMapping( KEY_CODE origMetaCode, KEY_CODE origSubCode,
KEY_CODE newMetaCode, KEY_CODE newSubCode );
extern KEY_MAPPING *getKeyMapFromName(char *pName);

View File

@ -1931,7 +1931,7 @@ SDWORD moveCalcDroidSpeed(DROID *psDroid)
speed = (MAX_SPEED_PITCH - pitch) * speed / MAX_SPEED_PITCH;
if (speed <= 0)
{
// Very nasty hack to deal with buggy maps, where some cliffs are
// Very nasty hack to deal with buggy maps, where some cliffs are
// not properly marked as being cliffs, but too steep to drive over.
// This confuses the heck out of the path-finding code! - Per
speed = 10;

View File

@ -41,7 +41,7 @@ extern BOOL objInitialise(void);
/* Shutdown the object system */
extern BOOL objShutdown(void);
/*goes thru' the list passed in reversing the order so the first entry becomes
/*goes thru' the list passed in reversing the order so the first entry becomes
the last and the last entry becomes the first!*/
extern void reverseObjectList(BASE_OBJECT **ppsList);

View File

@ -78,7 +78,7 @@ void killStruct(STRUCTURE *psDel);
extern void freeAllStructs(void);
/*Remove a single Structure from a list*/
extern void removeStructureFromList(STRUCTURE *psStructToRemove,
extern void removeStructureFromList(STRUCTURE *psStructToRemove,
STRUCTURE *pList[MAX_PLAYERS]);
/* Create a new Feature */

View File

@ -236,7 +236,7 @@ extern const char* getDroidOrderName(DROID_ORDER order);
extern DROID *FindATransporter(void);
/*For a given constructor droid, check if there are any damaged buildings within
/*For a given constructor droid, check if there are any damaged buildings within
a defined range*/
extern BASE_OBJECT * checkForDamagedStruct(DROID *psDroid, STRUCTURE *psTarget);

View File

@ -71,7 +71,7 @@ extern UDWORD updateExtractedPower(STRUCTURE *psBuilding);
extern void updatePlayerPower(UDWORD player);
/** Used in multiplayer to force power levels. */
extern void setPower(UDWORD player, UDWORD avail);
extern void setPower(UDWORD player, UDWORD avail);
/** Get the amount of power current held by the given player. */
extern UDWORD getPower(UDWORD player);

View File

@ -327,7 +327,7 @@ static void proj_UpdateKills(PROJECTILE *psObj, float experienceInc)
/***************************************************************************/
BOOL proj_SendProjectile(WEAPON *psWeap, BASE_OBJECT *psAttacker, int player, int tarX, int tarY, int tarZ,
BOOL proj_SendProjectile(WEAPON *psWeap, BASE_OBJECT *psAttacker, int player, int tarX, int tarY, int tarZ,
BASE_OBJECT *psTarget, BOOL bVisible, BOOL bPenetrate, int weapon_slot)
{
PROJECTILE *psObj = malloc(sizeof(PROJECTILE));

View File

@ -59,7 +59,7 @@ PROJECTILE * proj_GetFirst( void );
PROJECTILE * proj_GetNext( void );
void proj_FreeAllProjectiles( void );
BOOL proj_SendProjectile(WEAPON *psWeap, BASE_OBJECT *psAttacker, int player, int tarX, int tarY, int tarZ,
BOOL proj_SendProjectile(WEAPON *psWeap, BASE_OBJECT *psAttacker, int player, int tarX, int tarY, int tarZ,
BASE_OBJECT *psTarget, BOOL bVisible, BOOL bPenetrate, int weapon_slot);
// return whether a weapon is direct or indirect

View File

@ -60,7 +60,7 @@ extern SDWORD rayPointDist(SDWORD x1,SDWORD y1, SDWORD x2,SDWORD y2,
// point to the edge of the grid
extern void getBestPitchToEdgeOfGrid(UDWORD x, UDWORD y, UDWORD direction, SDWORD *pitch);
extern void getPitchToHighestPoint( UDWORD x, UDWORD y, UDWORD direction,
extern void getPitchToHighestPoint( UDWORD x, UDWORD y, UDWORD direction,
UDWORD thresholdDistance, SDWORD *pitch );
#endif // __INCLUDED_SRC_RAYCAST_H__

View File

@ -124,15 +124,15 @@ static PIELIGHT getColour(int id)
switch (id)
{
case STR_MR_STR_LOST :
case STR_MR_UNITS_LOST :
case STR_MR_UNITS_LOST :
return WZCOL_MENU_SCORE_LOSS;
case STR_MR_STR_BLOWN_UP :
case STR_MR_UNITS_KILLED :
case STR_MR_UNITS_KILLED :
return WZCOL_MENU_SCORE_DESTROYED;
case STR_MR_UNITS_BUILT :
case STR_MR_UNITS_NOW :
case STR_MR_STR_BUILT :
case STR_MR_STR_NOW :
case STR_MR_STR_NOW :
return WZCOL_MENU_SCORE_BUILT;
case STR_MR_LEVEL_ROOKIE :
case STR_MR_LEVEL_GREEN :

View File

@ -30,7 +30,7 @@ extern BOOL scrGroupAddDroid(void);
// Add droids in an area to a group
extern BOOL scrGroupAddArea(void);
// Add groupless droids in an area to a group
// Add groupless droids in an area to a group
extern BOOL scrGroupAddAreaNoGroup(void);
// Move the droids from one group to another

View File

@ -845,7 +845,7 @@ BOOL scrCallConsole(void)
SDWORD *player;
char **ConsoleText = NULL;
if (!stackPopParams(2, VAL_REF | VAL_INT, &player, VAL_REF | VAL_STRING, &ConsoleText) )
if (!stackPopParams(2, VAL_REF | VAL_INT, &player, VAL_REF | VAL_STRING, &ConsoleText) )
{
debug(LOG_ERROR, "scrCallConsole(): stack failed");
return false;
@ -881,7 +881,7 @@ BOOL scrCallBeacon(void)
if (!stackPopParams(5, VAL_INT, &playerTo, VAL_REF | VAL_INT, &playerFrom,
VAL_REF | VAL_INT, &locX, VAL_REF | VAL_INT, &locY,
VAL_REF | VAL_STRING, &BeaconText))
VAL_REF | VAL_STRING, &BeaconText))
{
debug(LOG_ERROR, "scrCallBeacon() - failed to pop parameters.");
return false;
@ -902,7 +902,7 @@ BOOL scrCallBeacon(void)
if(MultiMsgPlayerTo == playerTo)
{
strcpy(*BeaconText,MultiplayMsg);
*playerFrom = MultiMsgPlayerFrom;
*locX = beaconX;
*locY = beaconY;
@ -935,7 +935,7 @@ BOOL scrCallBeacon(void)
{
return false;
}
return true;
}
@ -946,7 +946,7 @@ BOOL scrCallMultiMsg(void)
SDWORD *player, playerTo;
char **ConsoleText = NULL;
if (!stackPopParams(3, VAL_INT, &playerTo, VAL_REF | VAL_INT, &player, VAL_REF | VAL_STRING, &ConsoleText) )
if (!stackPopParams(3, VAL_INT, &playerTo, VAL_REF | VAL_INT, &player, VAL_REF | VAL_STRING, &ConsoleText) )
{
debug(LOG_ERROR, "scrCallMultiMsg() failed to pop parameters.");
return false;
@ -963,7 +963,7 @@ BOOL scrCallMultiMsg(void)
if(MultiMsgPlayerTo == playerTo)
{
strcpy(*ConsoleText,MultiplayMsg);
*player = MultiMsgPlayerFrom;
scrFunctionResult.v.bval = true;
@ -995,7 +995,7 @@ BOOL scrCallMultiMsg(void)
debug(LOG_ERROR, "scrCallMultiMsg: stackPushResult failed");
return false;
}
return true;
}
@ -1010,7 +1010,7 @@ BOOL scrCBStructBuilt(void)
BOOL triggered = false;
DROID **ppsDroid;
if (!stackPopParams(3, VAL_INT, &player, VAL_REF|ST_DROID, &ppsDroid, VAL_REF|ST_STRUCTURE, &ppsStructure) )
if (!stackPopParams(3, VAL_INT, &player, VAL_REF|ST_DROID, &ppsDroid, VAL_REF|ST_STRUCTURE, &ppsStructure) )
{
debug(LOG_ERROR, "scrCBStructBuilt() failed to pop parameters.");
return false;

View File

@ -1476,7 +1476,7 @@ BOOL scrValDefLoad(SDWORD version, INTERP_VAL *psVal, char *pBuffer, UDWORD size
{
// find empty id and set track vals
index = audio_SetTrackVals(pName, false, 100, 1800);
if (!index) //this is a NON fatal error.
if (!index) //this is a NON fatal error.
{
// We can't find filename of the sound for some reason.
debug(LOG_ERROR, "Sound ID not available %s not found", pName);

View File

@ -41,7 +41,7 @@ DST_ALL_SAME
} SELECTIONTYPE;
// EXTERNALLY REFERENCED FUNCTIONS
extern UDWORD selDroidSelection( UDWORD player, SELECTION_CLASS droidClass,
extern UDWORD selDroidSelection( UDWORD player, SELECTION_CLASS droidClass,
SELECTIONTYPE droidType, BOOL bOnScreen );
extern UDWORD selDroidDeselect ( UDWORD player );
extern UDWORD selNumSelected ( UDWORD player );

View File

@ -1169,37 +1169,39 @@ 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)
{
return;
}
// 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;
// We are only interested in structures accruing
if (psCurr->status == SS_BEING_BUILT
&& psCurr->currentPowerAccrued < structPowerToBuild(psCurr))
{
DROID *psDroid;
bool beingBuilt = false;
bool beingBuilt = false;
// See is there are any droids building it
for (psDroid = apsDroidLists[i];
for (psDroid = apsDroidLists[player];
psDroid;
psDroid = psDroid->psNext)
{
@ -1210,7 +1212,7 @@ void handleAbandonedStructures()
break;
}
}
// Being worked on, nothing to see here
if (beingBuilt)
{
@ -1219,13 +1221,15 @@ 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)
{
@ -5133,7 +5137,7 @@ SDWORD getStructStatFromName(char *pName)
{
UDWORD inc;
STRUCTURE_STATS *psStat;
for (inc = 0; inc < numStructureStats; inc++)
{
psStat = &asStructureStats[inc];
@ -6191,7 +6195,7 @@ BOOL electronicDamage(BASE_OBJECT *psTarget, UDWORD damage, UBYTE attackPlayer)
if (bMultiPlayer)
{
uint8_t giftType = DROID_GIFT, droid_count = 1;
NETbeginEncode(NET_GIFT, NET_ALL_PLAYERS);
{
// We need to distinguish between gift types
@ -6855,10 +6859,10 @@ void factoryProdAdjust(STRUCTURE *psStructure, DROID_TEMPLATE *psTemplate, BOOL
{
if (asProductionRun[factoryType][factoryInc][inc].psTemplate == psTemplate)
{
//adjust the prod run
//adjust the prod run
if (add) //user left clicked, so increase # in queue
{
// Allows us to queue up more units up to MAX_IN_RUN instead of ignoring how many we have built from that queue
// Allows us to queue up more units up to MAX_IN_RUN instead of ignoring how many we have built from that queue
quantity = ++asProductionRun[factoryType][factoryInc][inc].quantity;
built = asProductionRun[factoryType][factoryInc][inc].built;
remaining = quantity - built;