summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2007-09-25 13:41:22 +0000
committerTim Angus <tim@ngus.net>2007-09-25 13:41:22 +0000
commitef5690eecfe614cee99b56d32b3634980b9a0e9d (patch)
treeba3dc9966502bb5bb4b67a8bc17823af9a579998
parent1b2c5b4e113fb1f182158f7c7b191717b79e3836 (diff)
* Replace "powerups" state data with "misc"
* Remove ps->ammo[ ] and replace with ps->ammo and ps->clips; this means only one ammo using weapon may be carried at once, but this is the case anyway * No need for BG_(Un)PackAmmoArray anymore, so remove them
-rw-r--r--src/cgame/cg_animmapobj.c4
-rw-r--r--src/cgame/cg_draw.c31
-rw-r--r--src/cgame/cg_ents.c4
-rw-r--r--src/cgame/cg_players.c8
-rw-r--r--src/cgame/cg_predict.c8
-rw-r--r--src/cgame/cg_scanner.c2
-rw-r--r--src/cgame/cg_tutorial.c5
-rw-r--r--src/cgame/cg_weapons.c27
-rw-r--r--src/game/bg_misc.c56
-rw-r--r--src/game/bg_pmove.c40
-rw-r--r--src/game/bg_public.h4
-rw-r--r--src/game/g_active.c22
-rw-r--r--src/game/g_client.c7
-rw-r--r--src/game/g_cmds.c14
-rw-r--r--src/game/g_combat.c4
-rw-r--r--src/game/g_main.c2
-rw-r--r--src/game/g_misc.c6
-rw-r--r--src/game/g_mover.c4
-rw-r--r--src/game/g_team.c4
-rw-r--r--src/game/g_trigger.c19
-rw-r--r--src/game/g_weapon.c8
-rw-r--r--src/qcommon/msg.c65
-rw-r--r--src/qcommon/q_shared.h9
23 files changed, 110 insertions, 243 deletions
diff --git a/src/cgame/cg_animmapobj.c b/src/cgame/cg_animmapobj.c
index 2e80b7e9..12253149 100644
--- a/src/cgame/cg_animmapobj.c
+++ b/src/cgame/cg_animmapobj.c
@@ -75,7 +75,7 @@ void CG_ModelDoor( centity_t *cent )
ent.nonNormalizedAxes = qtrue;
//setup animation
- anim.firstFrame = es->powerups;
+ anim.firstFrame = es->misc;
anim.numFrames = es->weapon;
anim.reversed = !es->legsAnim;
anim.flipflop = qfalse;
@@ -168,7 +168,7 @@ void CG_AnimMapObj( centity_t *cent )
}
//setup animation
- anim.firstFrame = es->powerups;
+ anim.firstFrame = es->misc;
anim.numFrames = es->weapon;
anim.reversed = qfalse;
anim.flipflop = qfalse;
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 61745111..cb990e4a 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -841,7 +841,7 @@ static void CG_DrawPlayerPoisonBarbs( rectDef_t *rect, vec4_t color, qhandle_t s
qboolean vertical;
int iconsize, numBarbs, i;
- BG_UnpackAmmoArray( ps->weapon, ps->ammo, ps->powerups, &numBarbs, NULL );
+ numBarbs = ps->ammo;
if( height > width )
{
@@ -926,7 +926,7 @@ static void CG_DrawPlayerAmmoValue( rectDef_t *rect, vec4_t color )
break;
default:
- BG_UnpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, &value, NULL );
+ value = ps->ammo;
break;
}
@@ -1085,7 +1085,7 @@ static void CG_DrawPlayerClipsValue( rectDef_t *rect, vec4_t color )
break;
default:
- BG_UnpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, NULL, &value );
+ value = ps->clips;
if( value > -1 )
{
@@ -1410,25 +1410,11 @@ float CG_GetValue( int ownerDraw )
{
case CG_PLAYER_AMMO_VALUE:
if( cent->currentState.weapon )
- {
- int value;
-
- BG_UnpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups,
- &value, NULL );
-
- return value;
- }
+ return ps->ammo;
break;
case CG_PLAYER_CLIPS_VALUE:
if( cent->currentState.weapon )
- {
- int value;
-
- BG_UnpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups,
- NULL, &value );
-
- return value;
- }
+ return ps->clips;
break;
case CG_PLAYER_HEALTH:
return ps->stats[ STAT_HEALTH ];
@@ -2378,14 +2364,13 @@ CG_DrawWeaponIcon
*/
void CG_DrawWeaponIcon( rectDef_t *rect, vec4_t color )
{
- int ammo, clips, maxAmmo;
+ int maxAmmo;
centity_t *cent;
playerState_t *ps;
cent = &cg_entities[ cg.snap->ps.clientNum ];
ps = &cg.snap->ps;
- BG_UnpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, &ammo, &clips );
BG_FindAmmoForWeapon( cent->currentState.weapon, &maxAmmo, NULL );
// don't display if dead
@@ -2397,9 +2382,9 @@ void CG_DrawWeaponIcon( rectDef_t *rect, vec4_t color )
CG_RegisterWeapon( cent->currentState.weapon );
- if( clips == 0 && !BG_FindInfinteAmmoForWeapon( cent->currentState.weapon ) )
+ if( ps->clips == 0 && !BG_FindInfinteAmmoForWeapon( cent->currentState.weapon ) )
{
- float ammoPercent = (float)ammo / (float)maxAmmo;
+ float ammoPercent = (float)ps->ammo / (float)maxAmmo;
if( ammoPercent < 0.33f )
{
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c
index 2d2e8089..17f1a7d3 100644
--- a/src/cgame/cg_ents.c
+++ b/src/cgame/cg_ents.c
@@ -581,7 +581,7 @@ static void CG_Portal( centity_t *cent )
CrossProduct( ent.axis[ 0 ], ent.axis[ 1 ], ent.axis[ 2 ] );
ent.reType = RT_PORTALSURFACE;
- ent.oldframe = s1->powerups;
+ ent.oldframe = s1->misc;
ent.frame = s1->frame; // rotation speed
ent.skinNum = s1->clientNum / 256.0 * 360; // roll offset
@@ -799,7 +799,7 @@ static void CG_Lev2ZapChain( centity_t *cent )
if( es->time <= 0 )
continue;
- source = &cg_entities[ es->powerups ];
+ source = &cg_entities[ es->misc ];
target = &cg_entities[ es->time ];
break;
diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c
index b594330e..bc3aaa47 100644
--- a/src/cgame/cg_players.c
+++ b/src/cgame/cg_players.c
@@ -2012,7 +2012,7 @@ void CG_Player( centity_t *cent )
qboolean shadow = qfalse;
float shadowPlane;
entityState_t *es = &cent->currentState;
- pClass_t class = ( es->powerups >> 8 ) & 0xFF;
+ pClass_t class = ( es->misc >> 8 ) & 0xFF;
float scale;
vec3_t tempAxis[ 3 ], tempAxis2[ 3 ];
vec3_t angles;
@@ -2379,7 +2379,7 @@ void CG_Corpse( centity_t *cent )
legs.nonNormalizedAxes = qtrue;
}
- //CG_AddRefEntityWithPowerups( &legs, es->powerups, ci->team );
+ //CG_AddRefEntityWithPowerups( &legs, es->misc, ci->team );
trap_R_AddRefEntityToScene( &legs );
// if the model failed, allow the default nullmodel to be displayed
@@ -2404,7 +2404,7 @@ void CG_Corpse( centity_t *cent )
torso.shadowPlane = shadowPlane;
torso.renderfx = renderfx;
- //CG_AddRefEntityWithPowerups( &torso, es->powerups, ci->team );
+ //CG_AddRefEntityWithPowerups( &torso, es->misc, ci->team );
trap_R_AddRefEntityToScene( &torso );
//
@@ -2423,7 +2423,7 @@ void CG_Corpse( centity_t *cent )
head.shadowPlane = shadowPlane;
head.renderfx = renderfx;
- //CG_AddRefEntityWithPowerups( &head, es->powerups, ci->team );
+ //CG_AddRefEntityWithPowerups( &head, es->misc, ci->team );
trap_R_AddRefEntityToScene( &head );
}
}
diff --git a/src/cgame/cg_predict.c b/src/cgame/cg_predict.c
index e34fe8df..59a1641b 100644
--- a/src/cgame/cg_predict.c
+++ b/src/cgame/cg_predict.c
@@ -138,7 +138,7 @@ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins,
bmaxs[ 2 ] = zu;
if( i == cg_numSolidEntities )
- BG_FindBBoxForClass( ( ent->powerups >> 8 ) & 0xFF, bmins, bmaxs, NULL, NULL, NULL );
+ BG_FindBBoxForClass( ( ent->misc >> 8 ) & 0xFF, bmins, bmaxs, NULL, NULL, NULL );
cmodel = trap_CM_TempBoxModel( bmins, bmaxs );
VectorCopy( vec3_origin, angles );
@@ -504,12 +504,6 @@ static int CG_IsUnacceptableError( playerState_t *ps, playerState_t *pps )
return 16;
}
- for( i = 0; i < MAX_WEAPONS; i++ )
- {
- if( pps->ammo[ i ] != ps->ammo[ i ] )
- return 18;
- }
-
if( pps->generic1 != ps->generic1 ||
pps->loopSound != ps->loopSound )
{
diff --git a/src/cgame/cg_scanner.c b/src/cgame/cg_scanner.c
index 0711c1db..195b6d76 100644
--- a/src/cgame/cg_scanner.c
+++ b/src/cgame/cg_scanner.c
@@ -82,7 +82,7 @@ void CG_UpdateEntityPositions( void )
}
else if( cent->currentState.eType == ET_PLAYER )
{
- int team = cent->currentState.powerups & 0x00FF;
+ int team = cent->currentState.misc & 0x00FF;
if( team == PTE_ALIENS )
{
diff --git a/src/cgame/cg_tutorial.c b/src/cgame/cg_tutorial.c
index e5fc9eb5..888e9e1a 100644
--- a/src/cgame/cg_tutorial.c
+++ b/src/cgame/cg_tutorial.c
@@ -396,7 +396,6 @@ CG_HumanText
static void CG_HumanText( char *text, playerState_t *ps )
{
char *name;
- int ammo, clips;
upgrade_t upgrade = UP_NONE;
if( cg.weaponSelect <= 32 )
@@ -407,9 +406,7 @@ static void CG_HumanText( char *text, playerState_t *ps )
upgrade = cg.weaponSelect - 32;
}
- BG_UnpackAmmoArray( ps->weapon, ps->ammo, ps->powerups, &ammo, &clips );
-
- if( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( ps->weapon ) )
+ if( !ps->ammo && !ps->clips && !BG_FindInfinteAmmoForWeapon( ps->weapon ) )
{
//no ammo
switch( ps->weapon )
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index deae4e0b..613cddb2 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -1109,14 +1109,6 @@ CG_WeaponSelectable
*/
static qboolean CG_WeaponSelectable( weapon_t weapon )
{
- //int ammo, clips;
- //
- //BG_UnpackAmmoArray( i, cg.snap->ps.ammo, cg.snap->ps.powerups, &ammo, &clips );
- //
- // this is a pain in the ass
- //if( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( i ) )
- // return qfalse;
-
if( !BG_InventoryContainsWeapon( weapon, cg.snap->ps.stats ) )
return qfalse;
@@ -1201,18 +1193,11 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color )
{
if( !BG_InventoryContainsWeapon( i, cg.snap->ps.stats ) )
continue;
-
- {
- int ammo, clips;
-
- BG_UnpackAmmoArray( i, cg.snap->ps.ammo, cg.snap->ps.powerups, &ammo, &clips );
-
- if( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( i ) )
- colinfo[ numItems ] = 1;
- else
- colinfo[ numItems ] = 0;
-
- }
+
+ if( !ps->ammo && !ps->clips && !BG_FindInfinteAmmoForWeapon( i ) )
+ colinfo[ numItems ] = 1;
+ else
+ colinfo[ numItems ] = 0;
if( i == cg.weaponSelect )
selectedItem = numItems;
@@ -1229,7 +1214,7 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color )
colinfo[ numItems ] = 0;
if( !BG_FindUsableForUpgrade ( i ) )
colinfo[ numItems ] = 2;
-
+
if( i == cg.weaponSelect - 32 )
selectedItem = numItems;
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 8286b51d..2319f31f 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -4785,8 +4785,8 @@ void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean
}
}
- // use powerups field to store team/class info:
- s->powerups = ps->stats[ STAT_PTEAM ] | ( ps->stats[ STAT_PCLASS ] << 8 );
+ // use misc field to store team/class info:
+ s->misc = ps->stats[ STAT_PTEAM ] | ( ps->stats[ STAT_PCLASS ] << 8 );
// have to get the surfNormal through somehow...
VectorCopy( ps->grapplePoint, s->angles2 );
@@ -4895,8 +4895,8 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s
}
}
- // use powerups field to store team/class info:
- s->powerups = ps->stats[ STAT_PTEAM ] | ( ps->stats[ STAT_PCLASS ] << 8 );
+ // use misc field to store team/class info:
+ s->misc = ps->stats[ STAT_PTEAM ] | ( ps->stats[ STAT_PCLASS ] << 8 );
// have to get the surfNormal through somehow...
VectorCopy( ps->grapplePoint, s->angles2 );
@@ -4914,62 +4914,16 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s
/*
========================
-BG_UnpackAmmoArray
-
-Extract the ammo quantity from the array
-========================
-*/
-void BG_UnpackAmmoArray( int weapon, int psAmmo[ ], int psAmmo2[ ], int *ammo, int *clips )
-{
- int ammoarray[ 32 ];
- int i;
-
- for( i = 0; i <= 15; i++ )
- ammoarray[ i ] = psAmmo[ i ];
-
- for( i = 16; i <= 31; i++ )
- ammoarray[ i ] = psAmmo2[ i - 16 ];
-
- if( ammo != NULL )
- *ammo = ammoarray[ weapon ] & 0x0FFF;
-
- if( clips != NULL )
- *clips = ( ammoarray[ weapon ] >> 12 ) & 0x0F;
-}
-
-/*
-========================
-BG_PackAmmoArray
-
-Pack the ammo quantity into the array
-========================
-*/
-void BG_PackAmmoArray( int weapon, int psAmmo[ ], int psAmmo2[ ], int ammo, int clips )
-{
- int weaponvalue;
-
- weaponvalue = ammo | ( clips << 12 );
-
- if( weapon <= 15 )
- psAmmo[ weapon ] = weaponvalue;
- else if( weapon >= 16 )
- psAmmo2[ weapon - 16 ] = weaponvalue;
-}
-
-/*
-========================
BG_WeaponIsFull
Check if a weapon has full ammo
========================
*/
-qboolean BG_WeaponIsFull( weapon_t weapon, int stats[ ], int psAmmo[ ], int psAmmo2[ ] )
+qboolean BG_WeaponIsFull( weapon_t weapon, int stats[ ], int ammo, int clips )
{
int maxAmmo, maxClips;
- int ammo, clips;
BG_FindAmmoForWeapon( weapon, &maxAmmo, &maxClips );
- BG_UnpackAmmoArray( weapon, psAmmo, psAmmo2, &ammo, &clips );
if( BG_InventoryContainsUpgrade( UP_BATTPACK, stats ) )
maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER );
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c
index a3f05b74..ae9e3073 100644
--- a/src/game/bg_pmove.c
+++ b/src/game/bg_pmove.c
@@ -2670,7 +2670,7 @@ Generates weapon events and modifes the weapon counter
static void PM_Weapon( void )
{
int addTime = 200; //default addTime - should never be used
- int ammo, clips, maxClips;
+ int maxClips;
qboolean attack1 = qfalse;
qboolean attack2 = qfalse;
qboolean attack3 = qfalse;
@@ -2768,11 +2768,10 @@ static void PM_Weapon( void )
// start the animation even if out of ammo
- BG_UnpackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, &ammo, &clips );
BG_FindAmmoForWeapon( pm->ps->weapon, NULL, &maxClips );
// check for out of ammo
- if( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) )
+ if( !pm->ps->ammo && !pm->ps->clips && !BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) )
{
PM_AddEvent( EV_NOAMMO );
pm->ps->weaponTime += 200;
@@ -2788,15 +2787,13 @@ static void PM_Weapon( void )
{
if( maxClips > 0 )
{
- clips--;
- BG_FindAmmoForWeapon( pm->ps->weapon, &ammo, NULL );
+ pm->ps->clips--;
+ BG_FindAmmoForWeapon( pm->ps->weapon, &pm->ps->ammo, NULL );
}
if( BG_FindUsesEnergyForWeapon( pm->ps->weapon ) &&
BG_InventoryContainsUpgrade( UP_BATTPACK, pm->ps->stats ) )
- ammo = (int)( (float)ammo * BATTPACK_MODIFIER );
-
- BG_PackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, ammo, clips );
+ pm->ps->ammo = (int)( (float)pm->ps->ammo * BATTPACK_MODIFIER );
//allow some time for the weapon to be raised
pm->ps->weaponstate = WEAPON_RAISING;
@@ -2806,7 +2803,7 @@ static void PM_Weapon( void )
}
// check for end of clip
- if( ( !ammo || pm->ps->pm_flags & PMF_WEAPON_RELOAD ) && clips )
+ if( ( !pm->ps->ammo || pm->ps->pm_flags & PMF_WEAPON_RELOAD ) && pm->ps->clips )
{
pm->ps->pm_flags &= ~PMF_WEAPON_RELOAD;
@@ -2925,7 +2922,7 @@ static void PM_Weapon( void )
if( BG_WeaponHasThirdMode( pm->ps->weapon ) )
{
//hacky special case for slowblob
- if( pm->ps->weapon == WP_ALEVEL3_UPG && !ammo )
+ if( pm->ps->weapon == WP_ALEVEL3_UPG && !pm->ps->ammo )
{
PM_AddEvent( EV_NOAMMO );
pm->ps->weaponTime += 200;
@@ -3047,22 +3044,19 @@ static void PM_Weapon( void )
//special case for lcannon
if( pm->ps->weapon == WP_LUCIFER_CANNON && attack1 && !attack2 )
{
- ammo -= (int)( ceil( ( (float)pm->ps->stats[ STAT_MISC ] / (float)LCANNON_TOTAL_CHARGE ) * 10.0f ) );
+ pm->ps->ammo -= (int)( ceil( ( (float)pm->ps->stats[ STAT_MISC ] / (float)LCANNON_TOTAL_CHARGE ) * 10.0f ) );
//stay on the safe side
- if( ammo < 0 )
- ammo = 0;
+ if( pm->ps->ammo < 0 )
+ pm->ps->ammo = 0;
}
else
- ammo--;
-
- BG_PackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, ammo, clips );
+ pm->ps->ammo--;
}
else if( pm->ps->weapon == WP_ALEVEL3_UPG && attack3 )
{
//special case for slowblob
- ammo--;
- BG_PackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, ammo, clips );
+ pm->ps->ammo--;
}
//FIXME: predicted angles miss a problem??
@@ -3264,12 +3258,8 @@ void trap_SnapVector( float *v );
void PmoveSingle( pmove_t *pmove )
{
- int ammo, clips;
-
pm = pmove;
- BG_UnpackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, &ammo, &clips );
-
// this counter lets us debug movement problems with a journal
// by setting a conditional breakpoint fot the previous frame
c_pmove++;
@@ -3296,7 +3286,7 @@ void PmoveSingle( pmove_t *pmove )
// set the firing flag for continuous beam weapons
if( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION &&
( pm->cmd.buttons & BUTTON_ATTACK ) &&
- ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) )
+ ( ( pm->ps->ammo > 0 || pm->ps->clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) )
pm->ps->eFlags |= EF_FIRING;
else
pm->ps->eFlags &= ~EF_FIRING;
@@ -3304,7 +3294,7 @@ void PmoveSingle( pmove_t *pmove )
// set the firing flag for continuous beam weapons
if( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION &&
( pm->cmd.buttons & BUTTON_ATTACK2 ) &&
- ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) )
+ ( ( pm->ps->ammo > 0 || pm->ps->clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) )
pm->ps->eFlags |= EF_FIRING2;
else
pm->ps->eFlags &= ~EF_FIRING2;
@@ -3312,7 +3302,7 @@ void PmoveSingle( pmove_t *pmove )
// set the firing flag for continuous beam weapons
if( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION &&
( pm->cmd.buttons & BUTTON_USE_HOLDABLE ) &&
- ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) )
+ ( ( pm->ps->ammo > 0 || pm->ps->clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) )
pm->ps->eFlags |= EF_FIRING3;
else
pm->ps->eFlags &= ~EF_FIRING3;
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 038dd86a..36e6a0aa 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -1098,9 +1098,7 @@ typedef struct
WUTeam_t team;
} upgradeAttributes_t;
-void BG_UnpackAmmoArray( int weapon, int psAmmo[ ], int psAmmo2[ ], int *ammo, int *clips );
-void BG_PackAmmoArray( int weapon, int psAmmo[ ], int psAmmo2[ ], int ammo, int clips );
-qboolean BG_WeaponIsFull( weapon_t weapon, int stats[ ], int psAmmo[ ], int psAmmo2[ ] );
+qboolean BG_WeaponIsFull( weapon_t weapon, int stats[ ], int ammo, int clips );
void BG_AddWeaponToInventory( int weapon, int stats[ ] );
void BG_RemoveWeaponFromInventory( int weapon, int stats[ ] );
qboolean BG_InventoryContainsWeapon( int weapon, int stats[ ] );
diff --git a/src/game/g_active.c b/src/game/g_active.c
index d8d7a3d8..ce60daff 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -648,18 +648,14 @@ void ClientTimerActions( gentity_t *ent, int msec )
//client is charging up an lcannon
if( client->ps.weapon == WP_LUCIFER_CANNON )
{
- int ammo;
-
- BG_UnpackAmmoArray( WP_LUCIFER_CANNON, client->ps.ammo, client->ps.powerups, &ammo, NULL );
-
if( client->ps.stats[ STAT_MISC ] < LCANNON_TOTAL_CHARGE && ucmd->buttons & BUTTON_ATTACK )
client->ps.stats[ STAT_MISC ] += ( 100.0f / LCANNON_CHARGE_TIME ) * LCANNON_TOTAL_CHARGE;
if( client->ps.stats[ STAT_MISC ] > LCANNON_TOTAL_CHARGE )
client->ps.stats[ STAT_MISC ] = LCANNON_TOTAL_CHARGE;
- if( client->ps.stats[ STAT_MISC ] > ( ammo * LCANNON_TOTAL_CHARGE ) / 10 )
- client->ps.stats[ STAT_MISC ] = ammo * LCANNON_TOTAL_CHARGE / 10;
+ if( client->ps.stats[ STAT_MISC ] > ( client->ps.ammo * LCANNON_TOTAL_CHARGE ) / 10 )
+ client->ps.stats[ STAT_MISC ] = client->ps.ammo * LCANNON_TOTAL_CHARGE / 10;
}
switch( client->ps.weapon )
@@ -802,8 +798,8 @@ void ClientTimerActions( gentity_t *ent, int msec )
if( ent->health > client->ps.stats[ STAT_MAX_HEALTH ] )
ent->health = client->ps.stats[ STAT_MAX_HEALTH ];
}
-
- // turn off life support when a team admits defeat
+
+ // turn off life support when a team admits defeat
if( client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS &&
level.surrenderTeam == PTE_ALIENS )
{
@@ -824,16 +820,12 @@ void ClientTimerActions( gentity_t *ent, int msec )
if( client->ps.weapon == WP_ALEVEL3_UPG )
{
- int ammo, maxAmmo;
+ int maxAmmo;
BG_FindAmmoForWeapon( WP_ALEVEL3_UPG, &maxAmmo, NULL );
- BG_UnpackAmmoArray( WP_ALEVEL3_UPG, client->ps.ammo, client->ps.powerups, &ammo, NULL );
- if( ammo < maxAmmo )
- {
- ammo++;
- BG_PackAmmoArray( WP_ALEVEL3_UPG, client->ps.ammo, client->ps.powerups, ammo, 0 );
- }
+ if( client->ps.ammo < maxAmmo )
+ client->ps.ammo++;
}
}
}
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 27dcb0fc..bed2fefd 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -582,7 +582,7 @@ void BodySink( gentity_t *ent )
ent->active = qtrue;
//sinking bodies can't be infested
- ent->killedBy = ent->s.powerups = MAX_CLIENTS;
+ ent->killedBy = ent->s.misc = MAX_CLIENTS;
ent->timestamp = level.time;
}
@@ -656,7 +656,7 @@ void SpawnCorpse( gentity_t *ent )
else
body->classname = "alienCorpse";
- body->s.powerups = MAX_CLIENTS;
+ body->s.misc = MAX_CLIENTS;
body->think = BodySink;
body->nextthink = level.time + 20000;
@@ -1493,7 +1493,8 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles
BG_FindAmmoForWeapon( weapon, &maxAmmo, &maxClips );
BG_AddWeaponToInventory( weapon, client->ps.stats );
- BG_PackAmmoArray( weapon, client->ps.ammo, client->ps.powerups, maxAmmo, maxClips );
+ client->ps.ammo = maxAmmo;
+ client->ps.clips = maxClips;
ent->client->ps.stats[ STAT_PCLASS ] = ent->client->pers.classSelection;
ent->client->ps.stats[ STAT_PTEAM ] = ent->client->pers.teamSelection;
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index fc5a95af..f1525f3f 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -52,7 +52,7 @@ void G_SanitiseName( char *in, char *out )
spaces = 0;
skip = qfalse;
}
-
+
if( *in == 27 || *in == '^' )
{
in += 2; // skip color code
@@ -67,7 +67,7 @@ void G_SanitiseName( char *in, char *out )
*out++ = tolower( *in++ );
}
- out -= spaces;
+ out -= spaces;
*out = 0;
}
@@ -380,7 +380,8 @@ void Cmd_Give_f( gentity_t *ent )
BG_InventoryContainsUpgrade( UP_BATTPACK, client->ps.stats ) )
maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER );
- BG_PackAmmoArray( client->ps.weapon, client->ps.ammo, client->ps.powerups, maxAmmo, maxClips );
+ client->ps.ammo = maxAmmo;
+ client->ps.clips = maxClips;
}
}
@@ -2052,8 +2053,8 @@ void Cmd_Buy_f( gentity_t *ent )
BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) )
maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER );
- BG_PackAmmoArray( weapon, ent->client->ps.ammo, ent->client->ps.powerups,
- maxAmmo, maxClips );
+ ent->client->ps.ammo = maxAmmo;
+ ent->client->ps.clips = maxClips;
G_ForceWeaponChange( ent, weapon );
@@ -2305,7 +2306,8 @@ void Cmd_Sell_f( gentity_t *ent )
BG_FindUsesEnergyForWeapon( j ) &&
!BG_FindInfinteAmmoForWeapon( j ) )
{
- BG_PackAmmoArray( j, ent->client->ps.ammo, ent->client->ps.powerups, 0, 0 );
+ ent->client->ps.ammo = 0;
+ ent->client->ps.clips = 0;
}
}
}
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index e4c5d143..5f889b0e 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -394,8 +394,8 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
// g_forcerespawn may force spawning at some later time
self->client->respawnTime = level.time + 1700;
- // remove powerups
- memset( self->client->ps.powerups, 0, sizeof( self->client->ps.powerups ) );
+ // clear misc
+ memset( self->client->ps.misc, 0, sizeof( self->client->ps.misc ) );
{
// normal death
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 84209315..dd258c13 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -1421,7 +1421,7 @@ void MoveClientToIntermission( gentity_t *ent )
ent->client->ps.pm_type = PM_INTERMISSION;
// clean up powerup info
- memset( ent->client->ps.powerups, 0, sizeof( ent->client->ps.powerups ) );
+ memset( ent->client->ps.misc, 0, sizeof( ent->client->ps.misc ) );
ent->client->ps.eFlags = 0;
ent->s.eFlags = 0;
diff --git a/src/game/g_misc.c b/src/game/g_misc.c
index 5352dbe3..5c551104 100644
--- a/src/game/g_misc.c
+++ b/src/game/g_misc.c
@@ -163,10 +163,10 @@ void locateCamera( gentity_t *ent )
if( owner->spawnflags & 4 )
{
// set to 0 for no rotation at all
- ent->s.powerups = 0;
+ ent->s.misc = 0;
}
else
- ent->s.powerups = 1;
+ ent->s.misc = 1;
// clientNum holds the rotate offset
ent->s.clientNum = owner->s.clientNum;
@@ -327,7 +327,7 @@ Spawn function for anim model
*/
void SP_misc_anim_model( gentity_t *self )
{
- self->s.powerups = (int)self->animation[ 0 ];
+ self->s.misc = (int)self->animation[ 0 ];
self->s.weapon = (int)self->animation[ 1 ];
self->s.torsoAnim = (int)self->animation[ 2 ];
self->s.legsAnim = (int)self->animation[ 3 ];
diff --git a/src/game/g_mover.c b/src/game/g_mover.c
index 2eda08b7..856f8cd5 100644
--- a/src/game/g_mover.c
+++ b/src/game/g_mover.c
@@ -1707,8 +1707,8 @@ void SP_func_door_model( gentity_t *ent )
ent->s.apos.trDuration = 0;
VectorClear( ent->s.apos.trDelta );
- ent->s.powerups = (int)ent->animation[ 0 ]; //first frame
- ent->s.weapon = abs( (int)ent->animation[ 1 ] ); //number of frames
+ ent->s.misc = (int)ent->animation[ 0 ]; //first frame
+ ent->s.weapon = abs( (int)ent->animation[ 1 ] ); //number of frames
//must be at least one frame -- mapper has forgotten animation key
if( ent->s.weapon == 0 )
diff --git a/src/game/g_team.c b/src/game/g_team.c
index 881ed35a..f2293922 100644
--- a/src/game/g_team.c
+++ b/src/game/g_team.c
@@ -145,7 +145,7 @@ static int QDECL SortClients( const void *a, const void *b )
TeamplayLocationsMessage
Format:
- clientNum location health armor weapon powerups
+ clientNum location health armor weapon misc
==================
*/
@@ -198,7 +198,7 @@ void TeamplayInfoMessage( gentity_t *ent )
" %i %i %i %i %i %i",
// level.sortedClients[i], player->client->pers.teamState.location, h, a,
i, player->client->pers.teamState.location, h, a,
- player->client->ps.weapon, player->s.powerups );
+ player->client->ps.weapon, player->s.misc );
j = strlen( entry );
diff --git a/src/game/g_trigger.c b/src/game/g_trigger.c
index 2b5b25af..18af97c0 100644
--- a/src/game/g_trigger.c
+++ b/src/game/g_trigger.c
@@ -1073,7 +1073,7 @@ trigger_ammo_touch
*/
void trigger_ammo_touch( gentity_t *self, gentity_t *other, trace_t *trace )
{
- int ammo, clips, maxClips, maxAmmo;
+ int maxClips, maxAmmo;
if( !other->client )
return;
@@ -1099,24 +1099,19 @@ void trigger_ammo_touch( gentity_t *self, gentity_t *other, trace_t *trace )
self->timestamp = level.time + FRAMETIME;
BG_FindAmmoForWeapon( other->client->ps.weapon, &maxAmmo, &maxClips );
- BG_UnpackAmmoArray( other->client->ps.weapon, other->client->ps.ammo, other->client->ps.powerups,
- &ammo, &clips );
- if( ( ammo + self->damage ) > maxAmmo )
+ if( ( other->client->ps.ammo + self->damage ) > maxAmmo )
{
- if( clips < maxClips )
+ if( other->client->ps.clips < maxClips )
{
- clips++;
- ammo = 1;
+ other->client->ps.clips++;
+ other->client->ps.ammo = 1;
}
else
- ammo = maxAmmo;
+ other->client->ps.ammo = maxAmmo;
}
else
- ammo += self->damage;
-
- BG_PackAmmoArray( other->client->ps.weapon, other->client->ps.ammo, other->client->ps.powerups,
- ammo, clips );
+ other->client->ps.ammo += self->damage;
}
/*
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index f1d23e8a..9d015e8b 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -93,7 +93,7 @@ void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo )
if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) &&
weaponType && !BG_FindInfinteAmmoForWeapon( i ) &&
!BG_WeaponIsFull( i, ent->client->ps.stats,
- ent->client->ps.ammo, ent->client->ps.powerups ) )
+ ent->client->ps.ammo, ent->client->ps.clips ) )
{
BG_FindAmmoForWeapon( i, &maxAmmo, &maxClips );
@@ -105,8 +105,8 @@ void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo )
maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER );
}
- BG_PackAmmoArray( i, ent->client->ps.ammo, ent->client->ps.powerups,
- maxAmmo, maxClips );
+ ent->client->ps.ammo = maxAmmo;
+ ent->client->ps.clips = maxClips;
restoredAmmo = qtrue;
}
@@ -1090,7 +1090,7 @@ static void G_UpdateZapEffect( zap_t *zap )
effect->s.eType = ET_LEV2_ZAP_CHAIN;
effect->classname = "lev2zapchain";
G_SetOrigin( effect, zap->creator->s.origin );
- effect->s.powerups = zap->creator->s.number;
+ effect->s.misc = zap->creator->s.number;
effect->s.time = effect->s.time2 = effect->s.constantLight = -1;
diff --git a/src/qcommon/msg.c b/src/qcommon/msg.c
index d46c2a3b..ac581b9e 100644
--- a/src/qcommon/msg.c
+++ b/src/qcommon/msg.c
@@ -823,7 +823,7 @@ netField_t entityStateFields[] =
{ NETF(origin[1]), 0 },
{ NETF(origin[2]), 0 },
{ NETF(solid), 24 },
-{ NETF(powerups), MAX_POWERUPS },
+{ NETF(misc), MAX_MISC },
{ NETF(modelindex), 8 },
{ NETF(otherEntityNum2), GENTITYNUM_BITS },
{ NETF(loopSound), 8 },
@@ -1143,6 +1143,8 @@ netField_t playerStateFields[] =
{ PSF(damageYaw), 8 },
{ PSF(damagePitch), 8 },
{ PSF(damageCount), 8 },
+{ PSF(ammo), 12 },
+{ PSF(clips), 4 },
{ PSF(generic1), 16 },
{ PSF(pm_type), 8 },
{ PSF(delta_angles[0]), 16 },
@@ -1171,8 +1173,7 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
playerState_t dummy;
int statsbits;
int persistantbits;
- int ammobits;
- int powerupbits;
+ int miscbits;
int numFields;
int c;
netField_t *field;
@@ -1252,20 +1253,14 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
persistantbits |= 1<<i;
}
}
- ammobits = 0;
- for (i=0 ; i<MAX_WEAPONS ; i++) {
- if (to->ammo[i] != from->ammo[i]) {
- ammobits |= 1<<i;
- }
- }
- powerupbits = 0;
- for (i=0 ; i<MAX_POWERUPS ; i++) {
- if (to->powerups[i] != from->powerups[i]) {
- powerupbits |= 1<<i;
+ miscbits = 0;
+ for (i=0 ; i<MAX_MISC ; i++) {
+ if (to->misc[i] != from->misc[i]) {
+ miscbits |= 1<<i;
}
}
- if (!statsbits && !persistantbits && !ammobits && !powerupbits) {
+ if (!statsbits && !persistantbits && !miscbits) {
MSG_WriteBits( msg, 0, 1 ); // no change
oldsize += 4;
return;
@@ -1294,23 +1289,12 @@ void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct p
}
- if ( ammobits ) {
- MSG_WriteBits( msg, 1, 1 ); // changed
- MSG_WriteBits( msg, ammobits, MAX_WEAPONS );
- for (i=0 ; i<MAX_WEAPONS ; i++)
- if (ammobits & (1<<i) )
- MSG_WriteShort (msg, to->ammo[i]);
- } else {
- MSG_WriteBits( msg, 0, 1 ); // no change
- }
-
-
- if ( powerupbits ) {
+ if ( miscbits ) {
MSG_WriteBits( msg, 1, 1 ); // changed
- MSG_WriteBits( msg, powerupbits, MAX_POWERUPS );
- for (i=0 ; i<MAX_POWERUPS ; i++)
- if (powerupbits & (1<<i) )
- MSG_WriteLong( msg, to->powerups[i] );
+ MSG_WriteBits( msg, miscbits, MAX_MISC );
+ for (i=0 ; i<MAX_MISC ; i++)
+ if (miscbits & (1<<i) )
+ MSG_WriteLong( msg, to->misc[i] );
} else {
MSG_WriteBits( msg, 0, 1 ); // no change
}
@@ -1424,24 +1408,13 @@ void MSG_ReadDeltaPlayerstate (msg_t *msg, playerState_t *from, playerState_t *t
}
}
- // parse ammo
- if ( MSG_ReadBits( msg, 1 ) ) {
- LOG("PS_AMMO");
- bits = MSG_ReadBits (msg, MAX_WEAPONS);
- for (i=0 ; i<MAX_WEAPONS ; i++) {
- if (bits & (1<<i) ) {
- to->ammo[i] = MSG_ReadShort(msg);
- }
- }
- }
-
- // parse powerups
+ // parse misc data
if ( MSG_ReadBits( msg, 1 ) ) {
- LOG("PS_POWERUPS");
- bits = MSG_ReadBits (msg, MAX_POWERUPS);
- for (i=0 ; i<MAX_POWERUPS ; i++) {
+ LOG("PS_MISC");
+ bits = MSG_ReadBits (msg, MAX_MISC);
+ for (i=0 ; i<MAX_MISC ; i++) {
if (bits & (1<<i) ) {
- to->powerups[i] = MSG_ReadLong(msg);
+ to->misc[i] = MSG_ReadLong(msg);
}
}
}
diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h
index 8c61aa7d..3622097b 100644
--- a/src/qcommon/q_shared.h
+++ b/src/qcommon/q_shared.h
@@ -1013,7 +1013,7 @@ typedef struct {
// bit field limits
#define MAX_STATS 16
#define MAX_PERSISTANT 16
-#define MAX_POWERUPS 16
+#define MAX_MISC 16
#define MAX_WEAPONS 16
#define MAX_PS_EVENTS 2
@@ -1085,8 +1085,9 @@ typedef struct playerState_s {
int stats[MAX_STATS];
int persistant[MAX_PERSISTANT]; // stats that aren't cleared on death
- int powerups[MAX_POWERUPS]; // level.time that the powerup runs out
- int ammo[MAX_WEAPONS];
+ int misc[MAX_MISC]; // misc data
+ int ammo; // ammo held
+ int clips; // clips held
int generic1;
int loopSound;
@@ -1204,7 +1205,7 @@ typedef struct entityState_s {
int eventParm;
// for players
- int powerups; // bit flags
+ int misc; // bit flags
int weapon; // determines weapon and flash model, etc
int legsAnim; // mask off ANIM_TOGGLEBIT
int torsoAnim; // mask off ANIM_TOGGLEBIT