From f54e7b037b54e636eaa4c7e33774cb54316d9672 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 25 Oct 2018 23:33:52 +0500 Subject: [PATCH] Remove TabulateAmmo calls. Fix weapon ids. --- cl_dll/hl/hl_weapons.cpp | 40 ---------------------------------------- dlls/cbase.h | 22 ---------------------- dlls/client.cpp | 18 ------------------ dlls/combat.cpp | 31 ++----------------------------- dlls/player.cpp | 22 ---------------------- dlls/player.h | 2 -- dlls/util.cpp | 16 ++++++++++++++++ dlls/util.h | 1 + dlls/weapons.cpp | 5 ----- dlls/weapons.h | 15 +++++++++------ 10 files changed, 28 insertions(+), 144 deletions(-) diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index fb0a50cd..ea4f32c6 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -726,11 +726,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack; pCurrent->m_flTimeWeaponIdle = pfrom->m_flTimeWeaponIdle; pCurrent->pev->fuser1 = pfrom->fuser1; - pCurrent->m_flStartThrow = pfrom->fuser2; - pCurrent->m_flReleaseThrow = pfrom->fuser3; - pCurrent->m_chargeReady = pfrom->iuser1; - pCurrent->m_fInAttack = pfrom->iuser2; - pCurrent->m_fireState = pfrom->iuser3; pCurrent->m_iSecondaryAmmoType = (int)from->client.vuser3[2]; pCurrent->m_iPrimaryAmmoType = (int)from->client.vuser4[0]; @@ -769,15 +764,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm player.m_flNextAmmoBurn = from->client.fuser2; player.m_flAmmoStartCharge = from->client.fuser3; - //Stores all our ammo info, so the client side weapons can use them. - player.ammo_9mm = (int)from->client.vuser1[0]; - player.ammo_357 = (int)from->client.vuser1[1]; - player.ammo_argrens = (int)from->client.vuser1[2]; - player.ammo_bolts = (int)from->client.ammo_nails; //is an int anyways... - player.ammo_buckshot = (int)from->client.ammo_shells; - player.ammo_uranium = (int)from->client.ammo_cells; - player.ammo_hornets = (int)from->client.vuser2[0]; - player.ammo_rockets = (int)from->client.ammo_rockets; // Point to current weapon object if( from->client.m_iId ) @@ -785,11 +771,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm player.m_pActiveItem = g_pWpns[from->client.m_iId]; } - if( player.m_pActiveItem->m_iId == WEAPON_MP5 ) - { - player.ammo_ak47 = (int)from->client.vuser2[1]; - } - // Don't go firing anything if we have died. // Or if we don't have a weapon model deployed if( ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) && @@ -841,22 +822,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm to->client.fuser3 = player.m_flAmmoStartCharge; to->client.maxspeed = player.pev->maxspeed; - //HL Weapons - to->client.vuser1[0] = player.ammo_9mm; - to->client.vuser1[1] = player.ammo_357; - to->client.vuser1[2] = player.ammo_argrens; - - to->client.ammo_nails = player.ammo_bolts; - to->client.ammo_shells = player.ammo_buckshot; - to->client.ammo_cells = player.ammo_uranium; - to->client.vuser2[0] = player.ammo_hornets; - to->client.ammo_rockets = player.ammo_rockets; - - if( player.m_pActiveItem->m_iId == WEAPON_MP5 ) - { - from->client.vuser2[1] = player.ammo_ak47; - } - // Make sure that weapon animation matches what the game .dll is telling us // over the wire ( fixes some animation glitches ) if( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) ) @@ -887,11 +852,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm pto->m_flNextSecondaryAttack = pCurrent->m_flNextSecondaryAttack; pto->m_flTimeWeaponIdle = pCurrent->m_flTimeWeaponIdle; pto->fuser1 = pCurrent->pev->fuser1; - pto->fuser2 = pCurrent->m_flStartThrow; - pto->fuser3 = pCurrent->m_flReleaseThrow; - pto->iuser1 = pCurrent->m_chargeReady; - pto->iuser2 = pCurrent->m_fInAttack; - pto->iuser3 = pCurrent->m_fireState; // Decrement weapon counters, server does this at same time ( during post think, after doing everything else ) pto->m_flNextReload -= cmd->msec / 1000.0; diff --git a/dlls/cbase.h b/dlls/cbase.h index ac61a077..779e30e0 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -333,28 +333,6 @@ public: virtual BOOL FVisible( CBaseEntity *pEntity ); virtual BOOL FVisible( const Vector &vecOrigin ); - - //We use this variables to store each ammo count. - int ammo_9mm; - int ammo_357; - int ammo_bolts; - int ammo_buckshot; - int ammo_rockets; - int ammo_uranium; - int ammo_hornets; - int ammo_argrens; - int ammo_ak47; - - //Special stuff for grenades and satchels. - float m_flStartThrow; - float m_flReleaseThrow; - int m_chargeReady; - int m_fInAttack; - - enum EGON_FIRESTATE { FIRE_OFF, FIRE_CHARGE }; - int m_fireState; - - void MuzzleLight( Vector vecSrc, float flRadius, byte r, byte g, byte b, float flTime, float flDecay ); }; // Ugly technique to override base member functions diff --git a/dlls/client.cpp b/dlls/client.cpp index 69a9d46e..2711e6b7 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -1666,11 +1666,6 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) item->m_fInReload = gun->m_fInReload; item->m_fInSpecialReload = gun->m_fInSpecialReload; item->fuser1 = Q_max( gun->pev->fuser1, -0.001 ); - item->fuser2 = gun->m_flStartThrow; - item->fuser3 = gun->m_flReleaseThrow; - item->iuser1 = gun->m_chargeReady; - item->iuser2 = gun->m_fInAttack; - item->iuser3 = gun->m_fireState; //item->m_flPumpTime = max( gun->m_flPumpTime, -0.001 ); } @@ -1761,14 +1756,6 @@ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct client cd->m_flNextAttack = pl->m_flNextAttack; cd->fuser2 = pl->m_flNextAmmoBurn; cd->fuser3 = pl->m_flAmmoStartCharge; - cd->vuser1.x = pl->ammo_9mm; - cd->vuser1.y = pl->ammo_357; - cd->vuser1.z = pl->ammo_argrens; - cd->ammo_nails = pl->ammo_bolts; - cd->ammo_shells = pl->ammo_buckshot; - cd->ammo_rockets = pl->ammo_rockets; - cd->ammo_cells = pl->ammo_uranium; - cd->vuser2.x = pl->ammo_hornets; if( pl->m_pActiveItem ) { @@ -1785,11 +1772,6 @@ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct client cd->vuser4.x = gun->m_iPrimaryAmmoType; cd->vuser4.y = pl->m_rgAmmo[gun->m_iPrimaryAmmoType]; cd->vuser4.z = pl->m_rgAmmo[gun->m_iSecondaryAmmoType]; - - if( pl->m_pActiveItem->m_iId == WEAPON_MP5 ) - { - cd->vuser2.y = pl->ammo_ak47; - } } } } diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 692f9622..47c0b43d 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -1467,7 +1467,7 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin } ApplyMultiDamage( pev, pevAttacker ); - MuzzleLight( vecSrc, 200, 255, 255, 255, 0.1f, 0 ); + UTIL_MuzzleLight( vecSrc, 200, 255, 255, 255, 0.1f, 0 ); } /* @@ -1555,7 +1555,7 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi } ApplyMultiDamage( pev, pevAttacker ); - MuzzleLight( vecSrc, 200, 255, 255, 255, 0.1f, 0 ); + UTIL_MuzzleLight( vecSrc, 200, 255, 255, 255, 0.1f, 0 ); return Vector( x * vecSpread.x, y * vecSpread.y, 0.0 ); } @@ -1678,30 +1678,3 @@ void CBaseMonster::MakeDamageBloodDecal( int cCount, float flNoise, TraceResult } } } - -// ========================================== -// Code changes for- Night at the Office: -// ========================================== -// -// -Muzzle light. Light emitted onto maps when guns are fired. -// (both player and enemy) - -void CBaseEntity::MuzzleLight( Vector vecSrc, float flRadius, byte r, byte g, byte b, float flTime, float flDecay ) -{ - int iRadius = (int)( flRadius * 0.1f ); - int iTime = (int)( flTime * 10 ); - int iDecay = (int)( flDecay * 0.1f ); - - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_DLIGHT ); - WRITE_COORD( vecSrc.x ); // X - WRITE_COORD( vecSrc.y ); // Y - WRITE_COORD( vecSrc.z ); // Z - WRITE_BYTE( iRadius ); // radius * 0.1 - WRITE_BYTE( r ); // r - WRITE_BYTE( g ); // g - WRITE_BYTE( b ); // b - WRITE_BYTE( iTime ); // time * 10 - WRITE_BYTE( iDecay ); // decay * 0.1 - MESSAGE_END(); -} diff --git a/dlls/player.cpp b/dlls/player.cpp index 6cdb685a..9aa8f48c 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -1116,26 +1116,6 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) ResetSequenceInfo(); } -/* -=========== -TabulateAmmo -This function is used to find and store -all the ammo we have into the ammo vars. -============ -*/ -void CBasePlayer::TabulateAmmo() -{ - ammo_9mm = AmmoInventory( GetAmmoIndex( "9mm" ) ); - ammo_357 = AmmoInventory( GetAmmoIndex( "357" ) ); - ammo_argrens = AmmoInventory( GetAmmoIndex( "ARgrenades" ) ); - ammo_bolts = AmmoInventory( GetAmmoIndex( "bolts" ) ); - ammo_buckshot = AmmoInventory( GetAmmoIndex( "buckshot" ) ); - ammo_rockets = AmmoInventory( GetAmmoIndex( "rockets" ) ); - ammo_uranium = AmmoInventory( GetAmmoIndex( "uranium" ) ); - ammo_hornets = AmmoInventory( GetAmmoIndex( "Hornets" ) ); - ammo_ak47 = AmmoInventory( GetAmmoIndex( "ak47" ) ); -} - /* =========== WaterMove @@ -3654,8 +3634,6 @@ int CBasePlayer::GiveAmmo( int iCount, const char *szName, int iMax ) MESSAGE_END(); } - TabulateAmmo(); - return i; } diff --git a/dlls/player.h b/dlls/player.h index f029e316..6b3ac30b 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -305,8 +305,6 @@ public: void SetCustomDecalFrames( int nFrames ); int GetCustomDecalFrames( void ); - void TabulateAmmo( void ); - Vector m_vecLastViewAngles; float m_flStartCharge; diff --git a/dlls/util.cpp b/dlls/util.cpp index c7feab31..b9388f41 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -31,6 +31,22 @@ #include "weapons.h" #include "gamerules.h" +void UTIL_MuzzleLight( const Vector &vecSrc, float flRadius, byte r, byte g, byte b, float flTime, float flDecay ) +{ + MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); + WRITE_BYTE( TE_DLIGHT ); + WRITE_COORD( vecSrc.x ); // X + WRITE_COORD( vecSrc.y ); // Y + WRITE_COORD( vecSrc.z ); // Z + WRITE_BYTE( flRadius * 0.1f ); // radius * 0.1 + WRITE_BYTE( r ); // r + WRITE_BYTE( g ); // g + WRITE_BYTE( b ); // b + WRITE_BYTE( flTime * 10.0f ); // time * 10 + WRITE_BYTE( flDecay * 0.1f ); // decay * 0.1 + MESSAGE_END(); +} + float UTIL_WeaponTimeBase( void ) { #if defined( CLIENT_WEAPONS ) diff --git a/dlls/util.h b/dlls/util.h index 41e86a84..4b9d1da0 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -577,5 +577,6 @@ void UTIL_UnsetGroupTrace( void ); int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); +void UTIL_MuzzleLight( const Vector &vecSrc, float flRadius, byte r, byte g, byte b, float flTime, float flDecay ); float UTIL_WeaponTimeBase( void ); #endif // UTIL_H diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 99f28af0..140a9ecd 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -606,8 +606,6 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= m_iClip; // Remove an entire clip. } - m_pPlayer->TabulateAmmo(); - m_fInReload = FALSE; } @@ -623,7 +621,6 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fFireOnEmpty = TRUE; } - m_pPlayer->TabulateAmmo(); SecondaryAttack(); m_pPlayer->pev->button &= ~IN_ATTACK2; } @@ -634,7 +631,6 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fFireOnEmpty = TRUE; } - m_pPlayer->TabulateAmmo(); PrimaryAttack(); } else if( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) @@ -939,7 +935,6 @@ BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWe if( !CanDeploy() ) return FALSE; - m_pPlayer->TabulateAmmo(); m_pPlayer->pev->viewmodel = MAKE_STRING( szViewModel ); m_pPlayer->pev->weaponmodel = MAKE_STRING( szWeaponModel ); strcpy( m_pPlayer->m_szAnimExtention, szAnimExt ); diff --git a/dlls/weapons.h b/dlls/weapons.h index a5bc7be6..366b5ab3 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -63,12 +63,12 @@ public: #define ITEM_BATTERY 4 #define WEAPON_NONE 0 -#define WEAPON_HOLSTER 1 -#define WEAPON_TORCH 2 -#define WEAPON_CROWBAR 3 -#define WEAPON_GLOCK 4 -#define WEAPON_MP5 5 -#define WEAPON_SHOTGUN 6 +#define WEAPON_CROWBAR 1 +#define WEAPON_GLOCK 2 +#define WEAPON_TORCH 3 +#define WEAPON_MP5 4 +#define WEAPON_SHOTGUN 7 +#define WEAPON_HOLSTER 17 #define WEAPON_ALLWEAPONS (~(1<