* turn some usages of WinAPI types (*WORD) into their native C counterparts (e.g. int, unsigned int, etc.)

* make integers unsigned at places where we never, ever use signed values for their values
 * move some variables into a more local scope (i.e. the only scope where they're used)
 * turn some mixed tab/spaces indentation usage into tabs-only
 * remove unused (and commented out) conditional compilation macro USE_DIRECTPLAY_PROTOCOL


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1798 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-06-03 15:51:56 +00:00
parent 8e2837ab97
commit dcb2c3350f
4 changed files with 71 additions and 69 deletions

View File

@ -36,7 +36,6 @@
#define ConnectionSize 255 // max size of a connection description. #define ConnectionSize 255 // max size of a connection description.
#define MaxProtocols 12 // max number of returnable protocols. #define MaxProtocols 12 // max number of returnable protocols.
#define MaxGames 12 // max number of concurrently playable games to allow. #define MaxGames 12 // max number of concurrently playable games to allow.
//#define USE_DIRECTPLAY_PROTOCOL // use DX6 protocol.
#define SESSION_JOINDISABLED 1 #define SESSION_JOINDISABLED 1

View File

@ -171,7 +171,7 @@ void cmdDroidMultiExpBoost(BOOL bDoit)
// get the experience level of a command droid // get the experience level of a command droid
SDWORD cmdDroidGetLevel(DROID *psCommander) unsigned int cmdDroidGetLevel(DROID *psCommander)
{ {
SDWORD numKills = psCommander->numKills; SDWORD numKills = psCommander->numKills;
@ -180,6 +180,7 @@ SDWORD cmdDroidGetLevel(DROID *psCommander)
{ {
numKills *= 2; numKills *= 2;
} }
if (numKills > 2047) if (numKills > 2047)
{ {
return 8; return 8;
@ -217,7 +218,7 @@ SDWORD cmdDroidGetLevel(DROID *psCommander)
} }
// get the maximum group size for a command droid // get the maximum group size for a command droid
SDWORD cmdDroidMaxGroup(DROID *psCommander) unsigned int cmdDroidMaxGroup(DROID *psCommander)
{ {
return cmdDroidGetLevel(psCommander) * 2 + 6; return cmdDroidGetLevel(psCommander) * 2 + 6;
} }
@ -239,22 +240,26 @@ void cmdDroidUpdateKills(DROID *psKiller)
} }
// get the level of a droids commander, if any // get the level of a droids commander, if any
SDWORD cmdGetCommanderLevel(DROID *psDroid) unsigned int cmdGetCommanderLevel(DROID *psDroid)
{ {
DROID *psCommander; DROID *psCommander;
ASSERT( psDroid != NULL, ASSERT( psDroid != NULL,
"cmdGetCommanderLevel: invalid droid pointer" ); "cmdGetCommanderLevel: invalid droid pointer" );
if ( (psDroid->psGroup != NULL) && // If this droid is not the member of a Commander's group
(psDroid->psGroup->type == GT_COMMAND) ) // Return an experience level of 0
if ((psDroid->psGroup == NULL) ||
(psDroid->psGroup->type != GT_COMMAND))
{ {
psCommander = psDroid->psGroup->psCommander; return 0;
return cmdDroidGetLevel(psCommander);
} }
return 0; // Retrieve this group's commander
psCommander = psDroid->psGroup->psCommander;
// Return the experience level of this commander
return cmdDroidGetLevel(psCommander);
} }
// Selects all droids for a given commander // Selects all droids for a given commander

View File

@ -57,10 +57,10 @@ extern void cmdDroidClearDesignator(UDWORD player);
extern SDWORD cmdDroidGetIndex(DROID *psCommander); extern SDWORD cmdDroidGetIndex(DROID *psCommander);
// get the experience level of a command droid // get the experience level of a command droid
extern SDWORD cmdDroidGetLevel(DROID *psCommander); extern unsigned int cmdDroidGetLevel(DROID *psCommander);
// get the maximum group size for a command droid // get the maximum group size for a command droid
extern SDWORD cmdDroidMaxGroup(DROID *psCommander); extern unsigned int cmdDroidMaxGroup(DROID *psCommander);
// update the kills of a command droid if psKiller is in a command group // update the kills of a command droid if psKiller is in a command group
extern void cmdDroidUpdateKills(DROID *psKiller); extern void cmdDroidUpdateKills(DROID *psKiller);
@ -72,7 +72,7 @@ extern SDWORD cmdDroidHitMod(DROID *psDroid);
extern SDWORD cmdDroidEvasionMod(DROID *psDroid); extern SDWORD cmdDroidEvasionMod(DROID *psDroid);
// get the level of a droids commander, if any // get the level of a droids commander, if any
extern SDWORD cmdGetCommanderLevel(DROID *psDroid); extern unsigned int cmdGetCommanderLevel(DROID *psDroid);
// Select all droids assigned to the passed in command droids // Select all droids assigned to the passed in command droids
extern void cmdSelectSubDroids(DROID *psDroid); extern void cmdSelectSubDroids(DROID *psDroid);

View File

@ -148,11 +148,10 @@ BOOL droidInit(void)
#define UNIT_LOST_DELAY (5*GAME_TICKS_PER_SEC) #define UNIT_LOST_DELAY (5*GAME_TICKS_PER_SEC)
BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weaponSubClass, int angle) BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weaponSubClass, int angle)
{ {
UDWORD penDamage, armourDamage; UDWORD armourDamage;
BOOL penetrated = FALSE; BOOL penetrated = FALSE;
UDWORD armour=0; UDWORD armour=0;
SECONDARY_STATE state; SECONDARY_STATE state;
SDWORD level, cmdLevel;
DROID_HIT_SIDE impact_side; DROID_HIT_SIDE impact_side;
check_droid(psDroid); check_droid(psDroid);
@ -163,6 +162,7 @@ BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weapo
//store the time //store the time
psDroid->timeLastHit = gameTime; psDroid->timeLastHit = gameTime;
psDroid->lastHitWeapon = weaponSubClass; psDroid->lastHitWeapon = weaponSubClass;
//quit early //quit early
return FALSE; return FALSE;
} }
@ -262,20 +262,17 @@ BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weapo
{ {
/* Damage has penetrated - reduce armour and body points */ /* Damage has penetrated - reduce armour and body points */
//penDamage = damage - psDroid->armour; //penDamage = damage - psDroid->armour;
penDamage = damage - armour; unsigned int penDamage = damage - armour;
level = getDroidLevel(psDroid); // Retrieve highest, applicable, experience level
cmdLevel = cmdGetCommanderLevel(psDroid); unsigned int level = getDroidLevel(psDroid);
if (level > cmdLevel)
{ {
//penDamage = (penDamage * (100 - 5 * level)) / 100; unsigned int cmdLevel = cmdGetCommanderLevel(psDroid);
level = MAX(level, cmdLevel);
}
// Reduce damage taken by 6% for each experience level
penDamage = (penDamage * (100 - 6 * level)) / 100; penDamage = (penDamage * (100 - 6 * level)) / 100;
}
else
{
//penDamage = (penDamage * (100 - 5 * cmdLevel)) / 100;
penDamage = (penDamage * (100 - 6 * cmdLevel)) / 100;
}
debug( LOG_ATTACK, " penetrated: %d\n", penDamage); debug( LOG_ATTACK, " penetrated: %d\n", penDamage);
if (penDamage >= psDroid->body) if (penDamage >= psDroid->body)
@ -290,6 +287,7 @@ BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weapo
return FALSE; return FALSE;
} }
} }
/* Droid destroyed */ /* Droid destroyed */
debug( LOG_ATTACK, " DESTROYED\n"); debug( LOG_ATTACK, " DESTROYED\n");
if(psDroid->player == selectedPlayer) if(psDroid->player == selectedPlayer)