summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeff Kent <jeff@jkent.net>2017-04-13 11:30:00 +0000
committer/dev/humancontroller <devhc@example.com>2017-04-15 17:20:41 +0200
commit26e25997647bfcc8692a2209e5670d4c0119ea8c (patch)
treebe69b2f824a6b749e12849a8b6da32e6ca59d1a0 /src
parentb4c0348da140348f3cbb48cfe544c5682c9e5d34 (diff)
multi-protocol: change the playerState_t and entityState_t structs to the versions in the latest code base
this includes changing how ammo and clips r stored
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_draw.c23
-rw-r--r--src/cgame/cg_predict.c7
-rw-r--r--src/cgame/cg_tutorial.c3
-rw-r--r--src/cgame/cg_weapons.c6
-rw-r--r--src/game/bg_misc.c48
-rw-r--r--src/game/bg_pmove.c16
-rw-r--r--src/game/bg_public.h4
-rw-r--r--src/game/g_active.c7
-rw-r--r--src/game/g_admin.c4
-rw-r--r--src/game/g_client.c3
-rw-r--r--src/game/g_cmds.c10
-rw-r--r--src/game/g_trigger.c8
-rw-r--r--src/game/g_weapon.c6
-rw-r--r--src/qcommon/q_shared.h12
14 files changed, 57 insertions, 100 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 82df413..1a3ecae 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -855,7 +855,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 )
{
@@ -940,7 +940,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;
}
@@ -1099,7 +1099,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 )
{
@@ -1425,23 +1425,13 @@ 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:
@@ -2404,7 +2394,8 @@ void CG_DrawWeaponIcon( rectDef_t *rect, vec4_t color )
cent = &cg_entities[ cg.snap->ps.clientNum ];
ps = &cg.snap->ps;
- BG_UnpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, &ammo, &clips );
+ ammo = ps->ammo;
+ clips = ps->clips;
BG_FindAmmoForWeapon( cent->currentState.weapon, &maxAmmo, NULL );
// don't display if dead
diff --git a/src/cgame/cg_predict.c b/src/cgame/cg_predict.c
index 34f00c4..e20eb1d 100644
--- a/src/cgame/cg_predict.c
+++ b/src/cgame/cg_predict.c
@@ -504,11 +504,8 @@ 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->ammo != ps->ammo || pps->clips != ps->clips )
+ return 18;
if( pps->generic1 != ps->generic1 ||
pps->loopSound != ps->loopSound )
diff --git a/src/cgame/cg_tutorial.c b/src/cgame/cg_tutorial.c
index 5ad29b7..c418726 100644
--- a/src/cgame/cg_tutorial.c
+++ b/src/cgame/cg_tutorial.c
@@ -407,7 +407,8 @@ static void CG_HumanText( char *text, playerState_t *ps )
upgrade = cg.weaponSelect - 32;
}
- BG_UnpackAmmoArray( ps->weapon, ps->ammo, ps->powerups, &ammo, &clips );
+ ammo = ps->ammo;
+ clips = ps->clips;
if( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( ps->weapon ) )
{
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index deae4e0..135e441 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -1111,7 +1111,8 @@ static qboolean CG_WeaponSelectable( weapon_t weapon )
{
//int ammo, clips;
//
- //BG_UnpackAmmoArray( i, cg.snap->ps.ammo, cg.snap->ps.powerups, &ammo, &clips );
+ //ammo = cg.snap->ps.ammo;
+ //clips = cg.snap->ps.clips
//
// this is a pain in the ass
//if( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( i ) )
@@ -1205,7 +1206,8 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color )
{
int ammo, clips;
- BG_UnpackAmmoArray( i, cg.snap->ps.ammo, cg.snap->ps.powerups, &ammo, &clips );
+ ammo = cg.snap->ps.ammo;
+ clips = cg.snap->ps.clips;
if( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( i ) )
colinfo[ numItems ] = 1;
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 1a55ed0..2641305 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -4959,62 +4959,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 88707bd..73ee6d9 100644
--- a/src/game/bg_pmove.c
+++ b/src/game/bg_pmove.c
@@ -2796,8 +2796,8 @@ 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 );
+ ammo = pm->ps->ammo;
+ clips = pm->ps->clips;
BG_FindAmmoForWeapon( pm->ps->weapon, NULL, &maxClips );
// check for out of ammo
@@ -2825,7 +2825,8 @@ static void PM_Weapon( void )
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 = ammo;
+ pm->ps->clips = clips;
//allow some time for the weapon to be raised
pm->ps->weaponstate = WEAPON_RAISING;
@@ -3079,13 +3080,15 @@ static void PM_Weapon( void )
else
ammo--;
- BG_PackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, ammo, clips );
+ pm->ps->ammo = ammo;
+ pm->ps->clips = clips;
}
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 = ammo;
+ pm->ps->clips = clips;
}
//FIXME: predicted angles miss a problem??
@@ -3291,7 +3294,8 @@ void PmoveSingle( pmove_t *pmove )
pm = pmove;
- BG_UnpackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, &ammo, &clips );
+ ammo = pm->ps->ammo;
+ clips = pm->ps->clips;
// this counter lets us debug movement problems with a journal
// by setting a conditional breakpoint fot the previous frame
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index e0e6233..817b7aa 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -1109,9 +1109,7 @@ typedef struct
//TA:
-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 5b167a5..147aabc 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -800,7 +800,7 @@ void ClientTimerActions( gentity_t *ent, int msec )
{
int ammo;
- BG_UnpackAmmoArray( WP_LUCIFER_CANNON, client->ps.ammo, client->ps.powerups, &ammo, NULL );
+ ammo = client->ps.ammo;
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;
@@ -1099,12 +1099,13 @@ void ClientTimerActions( gentity_t *ent, int msec )
int ammo, maxAmmo;
BG_FindAmmoForWeapon( WP_ALEVEL3_UPG, &maxAmmo, NULL );
- BG_UnpackAmmoArray( WP_ALEVEL3_UPG, client->ps.ammo, client->ps.powerups, &ammo, NULL );
+ ammo = client->ps.ammo;
if( ammo < maxAmmo )
{
ammo++;
- BG_PackAmmoArray( WP_ALEVEL3_UPG, client->ps.ammo, client->ps.powerups, ammo, 0 );
+ client->ps.ammo = ammo;
+ client->ps.clips = 0;
}
}
}
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index de59a47..5761586 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -4716,8 +4716,8 @@ qboolean G_admin_denyweapon( gentity_t *ent, int skiparg )
BG_AddWeaponToInventory( WP_MACHINEGUN, vic->client->ps.stats );
BG_FindAmmoForWeapon( WP_MACHINEGUN, &maxAmmo, &maxClips );
- BG_PackAmmoArray( WP_MACHINEGUN, vic->client->ps.ammo, vic->client->ps.powerups,
- maxAmmo, maxClips );
+ vic->client->ps.ammo = maxAmmo;
+ vic->client->ps.clips = maxClips;
G_ForceWeaponChange( vic, WP_MACHINEGUN );
vic->client->ps.stats[ STAT_MISC ] = 0;
ClientUserinfoChanged( pids[ 0 ], qfalse );
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 00ed443..ef35f16 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -1847,7 +1847,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 5c5101b..1233e31 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -445,7 +445,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;
}
}
@@ -3850,8 +3851,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 );
@@ -4073,7 +4074,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_trigger.c b/src/game/g_trigger.c
index 2b5b25a..0ac34bb 100644
--- a/src/game/g_trigger.c
+++ b/src/game/g_trigger.c
@@ -1099,8 +1099,8 @@ 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 );
+ ammo = other->client->ps.ammo;
+ clips = other->client->ps.clips;
if( ( ammo + self->damage ) > maxAmmo )
{
@@ -1115,8 +1115,8 @@ void trigger_ammo_touch( gentity_t *self, gentity_t *other, trace_t *trace )
else
ammo += self->damage;
- BG_PackAmmoArray( other->client->ps.weapon, other->client->ps.ammo, other->client->ps.powerups,
- ammo, clips );
+ other->client->ps.ammo = ammo;
+ other->client->ps.clips = clips;
}
/*
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index 4da6205..e2d0183 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -97,7 +97,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 );
@@ -109,8 +109,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;
}
diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h
index 14f68c4..3d6a498 100644
--- a/src/qcommon/q_shared.h
+++ b/src/qcommon/q_shared.h
@@ -1063,7 +1063,11 @@ typedef struct playerState_s {
int torsoTimer; // don't change low priority animations until this runs out
int torsoAnim; // mask off ANIM_TOGGLEBIT
- int movementDir; // a number 0 to 7 that represents the reletive angle
+ int tauntTimer; // don't allow another taunt until this runs out
+
+ int weaponAnim; // mask off ANIM_TOGGLEBIT
+
+ int movementDir; // a number 0 to 7 that represents the relative angle
// of movement to the view angle (axial and diagonals)
// when at rest, the value will remain unchanged
// used to twist the legs during strafing
@@ -1096,7 +1100,8 @@ 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 ammo; // ammo held
+ int clips; // clips held
int generic1;
int loopSound;
@@ -1104,7 +1109,7 @@ typedef struct playerState_s {
// not communicated over the net at all
int ping; // server to game info for scoreboard
- int pmove_framecount; // FIXME: don't transmit over the network
+ int pmove_framecount;
int jumppad_frame;
int entityEventSequence;
} playerState_t;
@@ -1218,6 +1223,7 @@ typedef struct entityState_s {
int weapon; // determines weapon and flash model, etc
int legsAnim; // mask off ANIM_TOGGLEBIT
int torsoAnim; // mask off ANIM_TOGGLEBIT
+ int weaponAnim; // mask off ANIM_TOGGLEBIT
int generic1;
} entityState_t;