Compare commits

..

1 Commits

Author SHA1 Message Date
ad3bb04b64 LightState_t fix 2024-10-19 22:23:33 +03:00
12 changed files with 155 additions and 186 deletions

View File

@@ -552,9 +552,9 @@ void CWeaponShotgun::SecondaryAttack( void )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Override so shotgun can do mulitple reloads in a row // Purpose: Override so shotgun can do mulitple reloads in a row
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CWeaponShotgun::ItemPostFrame(void) void CWeaponShotgun::ItemPostFrame( void )
{ {
CBasePlayer* pOwner = ToBasePlayer(GetOwner()); CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if (!pOwner) if (!pOwner)
{ {
return; return;
@@ -563,14 +563,14 @@ void CWeaponShotgun::ItemPostFrame(void)
if (m_bInReload) if (m_bInReload)
{ {
// If I'm primary firing and have one round stop reloading and fire // If I'm primary firing and have one round stop reloading and fire
if ((pOwner->m_nButtons & IN_ATTACK) && (m_iClip1 >= 1)) if ((pOwner->m_nButtons & IN_ATTACK ) && (m_iClip1 >=1))
{ {
m_bInReload = false; m_bInReload = false;
m_bNeedPump = false; m_bNeedPump = false;
m_bDelayedFire1 = true; m_bDelayedFire1 = true;
} }
// If I'm secondary firing and have one round stop reloading and fire // If I'm secondary firing and have one round stop reloading and fire
else if ((pOwner->m_nButtons & IN_ATTACK2) && (m_iClip1 >= 2)) else if ((pOwner->m_nButtons & IN_ATTACK2 ) && (m_iClip1 >=2))
{ {
m_bInReload = false; m_bInReload = false;
m_bNeedPump = false; m_bNeedPump = false;
@@ -579,7 +579,7 @@ void CWeaponShotgun::ItemPostFrame(void)
else if (m_flNextPrimaryAttack <= gpGlobals->curtime) else if (m_flNextPrimaryAttack <= gpGlobals->curtime)
{ {
// If out of ammo end reload // If out of ammo end reload
if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0) if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <=0)
{ {
FinishReload(); FinishReload();
return; return;
@@ -601,7 +601,7 @@ void CWeaponShotgun::ItemPostFrame(void)
else else
{ {
// Make shotgun shell invisible // Make shotgun shell invisible
SetBodygroup(1, 1); SetBodygroup(1,1);
} }
if ((m_bNeedPump) && (m_flNextPrimaryAttack <= gpGlobals->curtime)) if ((m_bNeedPump) && (m_flNextPrimaryAttack <= gpGlobals->curtime))
@@ -610,21 +610,15 @@ void CWeaponShotgun::ItemPostFrame(void)
return; return;
} }
#ifdef GAME_DLL
if (!m_bLowered)
{
#endif // GAME_DLL
// Shotgun uses same timing and ammo for secondary attack // Shotgun uses same timing and ammo for secondary attack
if ((m_bDelayedFire2 || pOwner->m_nButtons & IN_ATTACK2) && (m_flNextPrimaryAttack <= gpGlobals->curtime)) if ((m_bDelayedFire2 || pOwner->m_nButtons & IN_ATTACK2)&&(m_flNextPrimaryAttack <= gpGlobals->curtime))
{ {
m_bDelayedFire2 = false; m_bDelayedFire2 = false;
if ((m_iClip1 <= 1 && UsesClipsForAmmo1())) if ( (m_iClip1 <= 1 && UsesClipsForAmmo1()))
{ {
// If only one shell is left, do a single shot instead // If only one shell is left, do a single shot instead
if (m_iClip1 == 1) if ( m_iClip1 == 1 )
{ {
PrimaryAttack(); PrimaryAttack();
} }
@@ -648,17 +642,17 @@ void CWeaponShotgun::ItemPostFrame(void)
else else
{ {
// If the firing button was just pressed, reset the firing time // If the firing button was just pressed, reset the firing time
if (pOwner->m_afButtonPressed & IN_ATTACK) if ( pOwner->m_afButtonPressed & IN_ATTACK )
{ {
m_flNextPrimaryAttack = gpGlobals->curtime; m_flNextPrimaryAttack = gpGlobals->curtime;
} }
SecondaryAttack(); SecondaryAttack();
} }
} }
else if ((m_bDelayedFire1 || pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime) else if ( (m_bDelayedFire1 || pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime)
{ {
m_bDelayedFire1 = false; m_bDelayedFire1 = false;
if ((m_iClip1 <= 0 && UsesClipsForAmmo1()) || (!UsesClipsForAmmo1() && !pOwner->GetAmmoCount(m_iPrimaryAmmoType))) if ( (m_iClip1 <= 0 && UsesClipsForAmmo1()) || ( !UsesClipsForAmmo1() && !pOwner->GetAmmoCount(m_iPrimaryAmmoType) ) )
{ {
if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType)) if (!pOwner->GetAmmoCount(m_iPrimaryAmmoType))
{ {
@@ -679,17 +673,14 @@ void CWeaponShotgun::ItemPostFrame(void)
else else
{ {
// If the firing button was just pressed, reset the firing time // If the firing button was just pressed, reset the firing time
CBasePlayer* pPlayer = ToBasePlayer(GetOwner()); CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (pPlayer && pPlayer->m_afButtonPressed & IN_ATTACK) if ( pPlayer && pPlayer->m_afButtonPressed & IN_ATTACK )
{ {
m_flNextPrimaryAttack = gpGlobals->curtime; m_flNextPrimaryAttack = gpGlobals->curtime;
} }
PrimaryAttack(); PrimaryAttack();
} }
} }
#ifdef GAME_DLL
}
#endif // GAME_DLL
if ( pOwner->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload ) if ( pOwner->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload )
{ {

View File

@@ -94,11 +94,6 @@ CBaseCombatWeapon::CBaseCombatWeapon() : BASECOMBATWEAPON_DERIVED_FROM()
m_hWeaponFileInfo = GetInvalidWeaponInfoHandle(); m_hWeaponFileInfo = GetInvalidWeaponInfoHandle();
#ifdef GAME_DLL
m_bLowered = false;
m_flRaiseTime = gpGlobals->curtime;
#endif
#if defined( TF_DLL ) #if defined( TF_DLL )
UseClientSideAnimation(); UseClientSideAnimation();
#endif #endif
@@ -1652,34 +1647,30 @@ void CBaseCombatWeapon::ItemPreFrame( void )
//==================================================================================== //====================================================================================
// WEAPON BEHAVIOUR // WEAPON BEHAVIOUR
//==================================================================================== //====================================================================================
void CBaseCombatWeapon::ItemPostFrame(void) void CBaseCombatWeapon::ItemPostFrame( void )
{ {
CBasePlayer* pOwner = ToBasePlayer(GetOwner()); CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if (!pOwner) if (!pOwner)
return; return;
UpdateAutoFire(); UpdateAutoFire();
//Track the duration of the fire //Track the duration of the fire
//FIXME: Check for IN_ATTACK2 as well? //FIXME: Check for IN_ATTACK2 as well?
//FIXME: What if we're calling ItemBusyFrame? //FIXME: What if we're calling ItemBusyFrame?
m_fFireDuration = (pOwner->m_nButtons & IN_ATTACK) ? (m_fFireDuration + gpGlobals->frametime) : 0.0f; m_fFireDuration = ( pOwner->m_nButtons & IN_ATTACK ) ? ( m_fFireDuration + gpGlobals->frametime ) : 0.0f;
if (UsesClipsForAmmo1()) if ( UsesClipsForAmmo1() )
{ {
CheckReload(); CheckReload();
} }
bool bFired = false; bool bFired = false;
#ifdef GAME_DLL
if (!m_bLowered)
{
#endif
// Secondary attack has priority // Secondary attack has priority
if ((pOwner->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime)) if ((pOwner->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= gpGlobals->curtime))
{ {
if (UsesSecondaryAmmo() && pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0) if (UsesSecondaryAmmo() && pOwner->GetAmmoCount(m_iSecondaryAmmoType)<=0 )
{ {
if (m_flNextEmptySoundTime < gpGlobals->curtime) if (m_flNextEmptySoundTime < gpGlobals->curtime)
{ {
@@ -1701,7 +1692,7 @@ void CBaseCombatWeapon::ItemPostFrame(void)
// stops the crossbow from firing on the 360 if the player chooses to hold down their // stops the crossbow from firing on the 360 if the player chooses to hold down their
// zoom button. (sjb) Orange Box 7/25/2007 // zoom button. (sjb) Orange Box 7/25/2007
#if !defined(CLIENT_DLL) #if !defined(CLIENT_DLL)
if (!IsX360() || !ClassMatches("weapon_crossbow")) if( !IsX360() || !ClassMatches("weapon_crossbow") )
#endif #endif
{ {
bFired = ShouldBlockPrimaryFire(); bFired = ShouldBlockPrimaryFire();
@@ -1710,23 +1701,23 @@ void CBaseCombatWeapon::ItemPostFrame(void)
SecondaryAttack(); SecondaryAttack();
// Secondary ammo doesn't have a reload animation // Secondary ammo doesn't have a reload animation
if (UsesClipsForAmmo2()) if ( UsesClipsForAmmo2() )
{ {
// reload clip2 if empty // reload clip2 if empty
if (m_iClip2 < 1) if (m_iClip2 < 1)
{ {
pOwner->RemoveAmmo(1, m_iSecondaryAmmoType); pOwner->RemoveAmmo( 1, m_iSecondaryAmmoType );
m_iClip2 = m_iClip2 + 1; m_iClip2 = m_iClip2 + 1;
} }
} }
} }
} }
if (!bFired && (pOwner->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime)) if ( !bFired && (pOwner->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= gpGlobals->curtime))
{ {
// Clip empty? Or out of ammo on a no-clip weapon? // Clip empty? Or out of ammo on a no-clip weapon?
if (!IsMeleeWeapon() && if ( !IsMeleeWeapon() &&
((UsesClipsForAmmo1() && m_iClip1 <= 0) || (!UsesClipsForAmmo1() && pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0))) (( UsesClipsForAmmo1() && m_iClip1 <= 0) || ( !UsesClipsForAmmo1() && pOwner->GetAmmoCount(m_iPrimaryAmmoType)<=0 )) )
{ {
HandleFireOnEmpty(); HandleFireOnEmpty();
} }
@@ -1739,7 +1730,6 @@ void CBaseCombatWeapon::ItemPostFrame(void)
} }
else else
{ {
//NOTENOTE: There is a bug with this code with regards to the way machine guns catch the leading edge trigger //NOTENOTE: There is a bug with this code with regards to the way machine guns catch the leading edge trigger
// on the player hitting the attack key. It relies on the gun catching that case in the same frame. // on the player hitting the attack key. It relies on the gun catching that case in the same frame.
// However, because the player can also be doing a secondary attack, the edge trigger may be missed. // However, because the player can also be doing a secondary attack, the edge trigger may be missed.
@@ -1747,32 +1737,28 @@ void CBaseCombatWeapon::ItemPostFrame(void)
// first shot. Right now that's too much of an architecture change -- jdw // first shot. Right now that's too much of an architecture change -- jdw
// If the firing button was just pressed, or the alt-fire just released, reset the firing time // If the firing button was just pressed, or the alt-fire just released, reset the firing time
if ((pOwner->m_afButtonPressed & IN_ATTACK) || (pOwner->m_afButtonReleased & IN_ATTACK2)) if ( ( pOwner->m_afButtonPressed & IN_ATTACK ) || ( pOwner->m_afButtonReleased & IN_ATTACK2 ) )
{ {
m_flNextPrimaryAttack = gpGlobals->curtime; m_flNextPrimaryAttack = gpGlobals->curtime;
} }
PrimaryAttack(); PrimaryAttack();
if (AutoFiresFullClip()) if ( AutoFiresFullClip() )
{ {
m_bFiringWholeClip = true; m_bFiringWholeClip = true;
} }
#ifdef CLIENT_DLL #ifdef CLIENT_DLL
pOwner->SetFiredWeapon(true); pOwner->SetFiredWeapon( true );
#endif #endif
} }
} }
#ifdef GAME_DLL
}
#endif
// ----------------------- // -----------------------
// Reload pressed / Clip Empty // Reload pressed / Clip Empty
// ----------------------- // -----------------------
if ((pOwner->m_nButtons & IN_RELOAD) && UsesClipsForAmmo1() && !m_bInReload) if ( ( pOwner->m_nButtons & IN_RELOAD ) && UsesClipsForAmmo1() && !m_bInReload )
{ {
// reload when reload is pressed, or if no buttons are down and weapon is empty. // reload when reload is pressed, or if no buttons are down and weapon is empty.
Reload(); Reload();
@@ -1785,7 +1771,7 @@ void CBaseCombatWeapon::ItemPostFrame(void)
if (!((pOwner->m_nButtons & IN_ATTACK) || (pOwner->m_nButtons & IN_ATTACK2) || (CanReload() && pOwner->m_nButtons & IN_RELOAD))) if (!((pOwner->m_nButtons & IN_ATTACK) || (pOwner->m_nButtons & IN_ATTACK2) || (CanReload() && pOwner->m_nButtons & IN_RELOAD)))
{ {
// no fire buttons down or reloading // no fire buttons down or reloading
if (!ReloadOrSwitchWeapons() && (m_bInReload == false)) if ( !ReloadOrSwitchWeapons() && ( m_bInReload == false ) )
{ {
WeaponIdle(); WeaponIdle();
} }
@@ -2593,9 +2579,6 @@ IMPLEMENT_NETWORKCLASS_ALIASED( BaseCombatWeapon, DT_BaseCombatWeapon )
//-----------------------------------------------------------------------------// //-----------------------------------------------------------------------------//
BEGIN_DATADESC( CBaseCombatWeapon ) BEGIN_DATADESC( CBaseCombatWeapon )
DEFINE_FIELD(m_bLowered, FIELD_BOOLEAN),
DEFINE_FIELD(m_flRaiseTime, FIELD_TIME),
DEFINE_FIELD( m_flNextPrimaryAttack, FIELD_TIME ), DEFINE_FIELD( m_flNextPrimaryAttack, FIELD_TIME ),
DEFINE_FIELD( m_flNextSecondaryAttack, FIELD_TIME ), DEFINE_FIELD( m_flNextSecondaryAttack, FIELD_TIME ),
DEFINE_FIELD( m_flTimeWeaponIdle, FIELD_TIME ), DEFINE_FIELD( m_flTimeWeaponIdle, FIELD_TIME ),

View File

@@ -526,11 +526,6 @@ private:
CNetworkVar( CBaseCombatCharacterHandle, m_hOwner ); // Player carrying this weapon CNetworkVar( CBaseCombatCharacterHandle, m_hOwner ); // Player carrying this weapon
protected: protected:
#ifdef GAME_DLL
bool m_bLowered; // Whether the viewmodel is raised or lowered
float m_flRaiseTime; // If lowered, the time we should raise the viewmodel
#endif
#if defined ( TF_CLIENT_DLL ) || defined ( TF_DLL ) #if defined ( TF_CLIENT_DLL ) || defined ( TF_DLL )
// Regulate crit frequency to reduce client-side seed hacking // Regulate crit frequency to reduce client-side seed hacking
void AddToCritBucket( float flAmount ); void AddToCritBucket( float flAmount );

View File

@@ -34,6 +34,8 @@ END_NETWORK_TABLE()
//--------------------------------------------------------- //---------------------------------------------------------
BEGIN_DATADESC( CBaseHLCombatWeapon ) BEGIN_DATADESC( CBaseHLCombatWeapon )
DEFINE_FIELD( m_bLowered, FIELD_BOOLEAN ),
DEFINE_FIELD( m_flRaiseTime, FIELD_TIME ),
DEFINE_FIELD( m_flHolsterTime, FIELD_TIME ), DEFINE_FIELD( m_flHolsterTime, FIELD_TIME ),
DEFINE_FIELD( m_iPrimaryAttacks, FIELD_INTEGER ), DEFINE_FIELD( m_iPrimaryAttacks, FIELD_INTEGER ),
DEFINE_FIELD( m_iSecondaryAttacks, FIELD_INTEGER ), DEFINE_FIELD( m_iSecondaryAttacks, FIELD_INTEGER ),

View File

@@ -58,10 +58,8 @@ public:
protected: protected:
#ifndef GAME_DLL
bool m_bLowered; // Whether the viewmodel is raised or lowered bool m_bLowered; // Whether the viewmodel is raised or lowered
float m_flRaiseTime; // If lowered, the time we should raise the viewmodel float m_flRaiseTime; // If lowered, the time we should raise the viewmodel
#endif
float m_flHolsterTime; // When the weapon was holstered float m_flHolsterTime; // When the weapon was holstered
}; };

View File

@@ -222,7 +222,7 @@ void DrawFleshInteriorBlendedPass( CBaseVSShader *pShader, IMaterialVar** params
bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow(); bool bUseStaticControlFlow = g_pHardwareConfig->SupportsStaticControlFlow();
// Set Vertex Shader Combos // Set Vertex Shader Combos
LightState_t lightState = { 0, false, false }; LightState_t lightState = { 0, false, false, false };
pShaderAPI->GetDX9LightState( &lightState ); pShaderAPI->GetDX9LightState( &lightState );
DECLARE_DYNAMIC_VERTEX_SHADER( flesh_interior_blended_pass_vs20 ); DECLARE_DYNAMIC_VERTEX_SHADER( flesh_interior_blended_pass_vs20 );
SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z );

View File

@@ -234,7 +234,7 @@ void DrawParticleLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params,
pShader->BindTexture( SHADER_SAMPLER7, info.m_nFlashlightTexture, info.m_nFlashlightTextureFrame ); pShader->BindTexture( SHADER_SAMPLER7, info.m_nFlashlightTexture, info.m_nFlashlightTextureFrame );
} }
LightState_t lightState = { 0, false, false }; LightState_t lightState = { 0, false, false, false };
if( !hasFlashlight ) if( !hasFlashlight )
pShaderAPI->GetDX9LightState( &lightState ); pShaderAPI->GetDX9LightState( &lightState );

View File

@@ -638,7 +638,7 @@ BEGIN_VS_SHADER( pyro_vision, "Help for pyro vision" )
DynamicCmdsOut.SetPixelShaderConstant( 12, vParms.Base() ); DynamicCmdsOut.SetPixelShaderConstant( 12, vParms.Base() );
int numBones = pShaderAPI->GetCurrentNumBones(); int numBones = pShaderAPI->GetCurrentNumBones();
LightState_t lightState = { 0, false, false }; LightState_t lightState = { 0, false, false, false };
if ( bVertexLit && !bFullBright ) if ( bVertexLit && !bFullBright )
{ {
pShaderAPI->GetDX9LightState( &lightState ); pShaderAPI->GetDX9LightState( &lightState );

View File

@@ -611,7 +611,7 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad
} }
} }
LightState_t lightState = { 0, false, false }; LightState_t lightState = { 0, false, false, false };
bool bFlashlightShadows = false; bool bFlashlightShadows = false;
if( bHasFlashlight ) if( bHasFlashlight )
{ {

View File

@@ -1188,7 +1188,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial
// Set up light combo state // Set up light combo state
LightState_t lightState = {0, false, false}; LightState_t lightState = {0, false, false, false};
if ( bVertexLitGeneric && (!bHasFlashlight || IsX360() ) ) if ( bVertexLitGeneric && (!bHasFlashlight || IsX360() ) )
{ {
pShaderAPI->GetDX9LightState( &lightState ); pShaderAPI->GetDX9LightState( &lightState );

View File

@@ -310,7 +310,7 @@ void DrawVortWarp_DX9( CBaseVSShader *pShader, IMaterialVar** params, IShaderDyn
} }
// Set up light combo state // Set up light combo state
LightState_t lightState = {0, false, false}; LightState_t lightState = {0, false, false, false};
if ( bVertexLitGeneric && !hasFlashlight ) if ( bVertexLitGeneric && !hasFlashlight )
{ {
pShaderAPI->GetDX9LightState( &lightState ); pShaderAPI->GetDX9LightState( &lightState );