* 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 MaxProtocols 12 // max number of returnable protocols.
#define MaxGames 12 // max number of concurrently playable games to allow.
//#define USE_DIRECTPLAY_PROTOCOL // use DX6 protocol.
#define SESSION_JOINDISABLED 1

View File

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

View File

@ -57,10 +57,10 @@ extern void cmdDroidClearDesignator(UDWORD player);
extern SDWORD cmdDroidGetIndex(DROID *psCommander);
// 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
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
extern void cmdDroidUpdateKills(DROID *psKiller);
@ -72,7 +72,7 @@ extern SDWORD cmdDroidHitMod(DROID *psDroid);
extern SDWORD cmdDroidEvasionMod(DROID *psDroid);
// 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
extern void cmdSelectSubDroids(DROID *psDroid);

View File

@ -148,31 +148,31 @@ BOOL droidInit(void)
#define UNIT_LOST_DELAY (5*GAME_TICKS_PER_SEC)
BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weaponSubClass, int angle)
{
UDWORD penDamage, armourDamage;
UDWORD armourDamage;
BOOL penetrated = FALSE;
UDWORD armour=0;
SECONDARY_STATE state;
SDWORD level, cmdLevel;
DROID_HIT_SIDE impact_side;
check_droid(psDroid);
//EMP cannons do not do body damage
if (weaponSubClass == WSC_EMP)
{
//store the time
psDroid->timeLastHit = gameTime;
psDroid->lastHitWeapon = weaponSubClass;
//quit early
return FALSE;
}
//EMP cannons do not do body damage
if (weaponSubClass == WSC_EMP)
{
//store the time
psDroid->timeLastHit = gameTime;
psDroid->lastHitWeapon = weaponSubClass;
//only overwrite if the last weapon to hit was not an EMP - need the time value for this
if (psDroid->lastHitWeapon != WSC_EMP)
{
psDroid->timeLastHit = gameTime;
psDroid->lastHitWeapon = weaponSubClass;
}
//quit early
return FALSE;
}
//only overwrite if the last weapon to hit was not an EMP - need the time value for this
if (psDroid->lastHitWeapon != WSC_EMP)
{
psDroid->timeLastHit = gameTime;
psDroid->lastHitWeapon = weaponSubClass;
}
// if(selectedPlayer==0)
if(psDroid->player != selectedPlayer)
@ -262,34 +262,32 @@ BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weapo
{
/* Damage has penetrated - reduce armour and body points */
//penDamage = damage - psDroid->armour;
penDamage = damage - armour;
unsigned int penDamage = damage - armour;
level = getDroidLevel(psDroid);
cmdLevel = cmdGetCommanderLevel(psDroid);
if (level > cmdLevel)
// Retrieve highest, applicable, experience level
unsigned int level = getDroidLevel(psDroid);
{
//penDamage = (penDamage * (100 - 5 * level)) / 100;
penDamage = (penDamage * (100 - 6 * level)) / 100;
}
else
{
//penDamage = (penDamage * (100 - 5 * cmdLevel)) / 100;
penDamage = (penDamage * (100 - 6 * cmdLevel)) / 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;
debug( LOG_ATTACK, " penetrated: %d\n", penDamage);
if (penDamage >= psDroid->body)
{
//we don't want this in multiPlayer
if (!bMultiPlayer)
{
//hack to prevent Transporter's being blown up
if (psDroid->droidType == DROID_TRANSPORTER)
{
psDroid->body = 1;
return FALSE;
}
}
//we don't want this in multiPlayer
if (!bMultiPlayer)
{
//hack to prevent Transporter's being blown up
if (psDroid->droidType == DROID_TRANSPORTER)
{
psDroid->body = 1;
return FALSE;
}
}
/* Droid destroyed */
debug( LOG_ATTACK, " DESTROYED\n");
if(psDroid->player == selectedPlayer)
@ -338,17 +336,17 @@ BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weapo
}
if (psDroid->body == 1)
{
//we don't want this in multiPlayer
if (!bMultiPlayer)
{
//hack to prevent Transporter's being blown up
if (psDroid->droidType == DROID_TRANSPORTER)
{
return FALSE;
}
}
//we don't want this in multiPlayer
if (!bMultiPlayer)
{
//hack to prevent Transporter's being blown up
if (psDroid->droidType == DROID_TRANSPORTER)
{
return FALSE;
}
}
if(psDroid->player == selectedPlayer)
if(psDroid->player == selectedPlayer)
{
CONPRINTF(ConsoleString,(ConsoleString,_("Unit Lost!")));
scoreUpdateVar(WD_UNITS_LOST);
@ -386,16 +384,16 @@ BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weapo
/* now check for auto return on droid's secondary orders */
secondaryCheckDamageLevel(psDroid);
/* now check for scripted run-away based on health */
orderHealthCheck(psDroid);
/* now check for scripted run-away based on health */
orderHealthCheck(psDroid);
//only overwrite if the last weapon to hit was not an EMP - need the time value for this
if (psDroid->lastHitWeapon != WSC_EMP)
{
psDroid->timeLastHit = gameTime;
psDroid->lastHitWeapon = weaponSubClass;
}
//only overwrite if the last weapon to hit was not an EMP - need the time value for this
if (psDroid->lastHitWeapon != WSC_EMP)
{
psDroid->timeLastHit = gameTime;
psDroid->lastHitWeapon = weaponSubClass;
}
return FALSE;