From ea72dde27d909e80088375b2d21b2338cbface29 Mon Sep 17 00:00:00 2001 From: Kamay Xutax Date: Fri, 19 Jul 2024 05:09:43 +0200 Subject: [PATCH] Corrected again a bit more cl_showimpacts --- engine/host.cpp | 2 +- game/client/c_baseanimating.cpp | 23 +++---- game/client/c_baseanimating.h | 2 + game/client/c_baseplayer.cpp | 88 ++++++++++++++++++++---- game/client/c_baseplayer.h | 10 +-- game/client/cstrike/c_cs_player.cpp | 40 ++--------- game/client/cstrike/c_cs_player.h | 2 +- game/client/in_main.cpp | 18 ++--- game/server/baseanimating.cpp | 29 +++++++- game/server/baseanimating.h | 2 + game/server/player.cpp | 11 +-- game/server/player.h | 8 ++- game/server/player_command.cpp | 2 +- game/shared/cstrike/cs_player_shared.cpp | 55 +++++++-------- game/shared/cstrike/fx_cs_shared.cpp | 10 ++- game/shared/usercmd.cpp | 4 +- game/shared/usercmd.h | 8 +-- 17 files changed, 186 insertions(+), 128 deletions(-) diff --git a/engine/host.cpp b/engine/host.cpp index 97391845b1..4187a17b9a 100644 --- a/engine/host.cpp +++ b/engine/host.cpp @@ -3189,7 +3189,7 @@ void _Host_RunFrame (float time) g_ClientGlobalVariables.interpolation_amount = flInterpAmount - flLastInterpolationAmountOnTick; ErrorIfNot(g_ClientGlobalVariables.interpolation_amount >= 0.0f, - ("Interpolation amount was bigger than 1 (%f)\n", g_ClientGlobalVariables.interpolation_amount)); + ("Interpolation amount was lower than 0 (%f)\n", g_ClientGlobalVariables.interpolation_amount)); #ifdef false printf("current interp: %f, old amount: %f, time: %f, frametime: %f, last remainder not interpolated: %f\n", g_ClientGlobalVariables.interpolation_amount, diff --git a/game/client/c_baseanimating.cpp b/game/client/c_baseanimating.cpp index 08dab27762..d6b2d64932 100644 --- a/game/client/c_baseanimating.cpp +++ b/game/client/c_baseanimating.cpp @@ -22,6 +22,8 @@ #include "c_te_legacytempents.h" #include "activitylist.h" #include "animation.h" +#include "recvproxy.h" +#include "studio.h" #include "tier0/vprof.h" #include "clienteffectprecachesystem.h" #include "IEffects.h" @@ -200,8 +202,7 @@ IMPLEMENT_CLIENTCLASS_DT(C_BaseAnimating, DT_BaseAnimating, CBaseAnimating) RecvPropFloat( RECVINFO( m_fadeMaxDist ) ), RecvPropFloat( RECVINFO( m_flFadeScale ) ), RecvPropArray3( RECVINFO_ARRAY(m_vecHitboxServerPositions), RecvPropVector(RECVINFO(m_vecHitboxServerPositions[0]))), - RecvPropArray3( RECVINFO_ARRAY(m_angHitboxServerAngles), RecvPropQAngles(RECVINFO(m_angHitboxServerAngles[0]))), - + RecvPropArray3( RECVINFO_ARRAY(m_angHitboxServerAngles), RecvPropQAngles(RECVINFO(m_angHitboxServerAngles[0]))) END_RECV_TABLE() @@ -4538,7 +4539,7 @@ void C_BaseAnimating::PreDataUpdate( DataUpdateType_t updateType ) for ( i=0;iframetime, true); - DrawServerHitboxes(gpGlobals->frametime, true); - } } diff --git a/game/client/c_baseanimating.h b/game/client/c_baseanimating.h index e0a4c8f30f..34f4c594ac 100644 --- a/game/client/c_baseanimating.h +++ b/game/client/c_baseanimating.h @@ -640,6 +640,8 @@ private: mutable CStudioHdr *m_pStudioHdr; mutable MDLHandle_t m_hStudioHdr; CThreadFastMutex m_StudioHdrInitLock; + + public: Vector m_vecHitboxServerPositions[MAXSTUDIOBONES]; QAngle m_angHitboxServerAngles[MAXSTUDIOBONES]; }; diff --git a/game/client/c_baseplayer.cpp b/game/client/c_baseplayer.cpp index 73d7b03621..c43d61efef 100644 --- a/game/client/c_baseplayer.cpp +++ b/game/client/c_baseplayer.cpp @@ -7,9 +7,13 @@ //===========================================================================// #include "cbase.h" #include "c_baseplayer.h" +#include "cdll_client_int.h" #include "convar.h" #include "dt_recv.h" #include "flashlighteffect.h" +#include "recvproxy.h" +#include "shareddefs.h" +#include "util_shared.h" #include "weapon_selection.h" #include "history_resource.h" #include "iinput.h" @@ -60,6 +64,8 @@ // NVNT haptics system interface #include "haptics/ihaptics.h" +#include "debugoverlay_shared.h" + // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -247,9 +253,10 @@ END_RECV_TABLE() RecvPropInt ( RECVINFO( m_nWaterLevel ) ), RecvPropFloat ( RECVINFO( m_flLaggedMovementValue )), - RecvPropArray3 ( RECVINFO_ARRAY(m_vecBulletServerPositions), RecvPropVector( RECVINFO(m_vecBulletServerPositions[0])) ), - RecvPropInt(RECVINFO(m_iBulletServerPositionCount)), - RecvPropArray3 ( RECVINFO_ARRAY(m_vecServerShootPosition), RecvPropVector( RECVINFO(m_vecServerShootPosition[0])) ), + RecvPropUtlVector ( RECVINFO_UTLVECTOR(m_vecBulletServerPositions), MAX_PLAYER_BULLET_SERVER_POSITIONS,RecvPropVector(NULL, 0) ), + RecvPropUtlVector ( RECVINFO_UTLVECTOR(m_vecServerShootPositions) ,MAX_PLAYER_BULLET_SERVER_POSITIONS, RecvPropVector(NULL, 0) ), + RecvPropBool (RECVINFO(m_bDebugServerBullets)), + RecvPropUtlVector ( RECVINFO_UTLVECTOR(m_touchedEntitiesWithBullet) ,MAX_PLAYER_BULLET_SERVER_POSITIONS, RecvPropVector(NULL, 0) ), END_RECV_TABLE() @@ -445,8 +452,8 @@ C_BasePlayer::C_BasePlayer() : m_iv_vecViewOffset( "C_BasePlayer::m_iv_vecViewOf ListenForGameEvent( "base_player_teleported" ); - m_nTickBaseFireBullet = -1; - m_iBulletServerPositionCount = 0; + m_lastBulletDiameter = 1.0f; + m_bDebugServerBullets = false; } //----------------------------------------------------------------------------- @@ -488,7 +495,7 @@ void C_BasePlayer::Spawn( void ) m_bWasFreezeFraming = false; - m_bFiredWeapon = false; + m_bFiredWeapon = false; } //----------------------------------------------------------------------------- @@ -913,7 +920,7 @@ void C_BasePlayer::PostDataUpdate( DataUpdateType_t updateType ) if ( engine->IsPaused() || bForceEFNoInterp ) { ResetLatched(); - } + } } //----------------------------------------------------------------------------- @@ -2135,15 +2142,70 @@ void C_BasePlayer::Simulate() ResetLatched(); } + static ConVarRef cl_showfirebullethitboxes("cl_showfirebullethitboxes"); static ConVarRef cl_showimpacts("cl_showimpacts"); - static ConVarRef cl_showfirebullethitboxes("cl_showfirebullethitboxes"); - bool shouldShowFireBulletHitbox = m_nTickBaseFireBullet <= m_nTickBase && m_nTickBaseFireBullet != -1; - - if (shouldShowFireBulletHitbox && (cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3 || cl_showfirebullethitboxes.GetBool())) + static ConVarRef cl_showhitboxes("cl_showhitboxes"); + + if (m_bDebugServerBullets) { - DrawServerHitboxes(60.0f, true); - m_nTickBaseFireBullet = -1; + if (cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3) + { + for (int i = 0; i < m_vecServerShootPositions.Count(); i++) + { + NDebugOverlay::SweptBox(m_vecServerShootPositions[i], + m_vecBulletServerPositions[i], + Vector(-m_lastBulletDiameter, -m_lastBulletDiameter, -m_lastBulletDiameter) / 2, + Vector(m_lastBulletDiameter, m_lastBulletDiameter, m_lastBulletDiameter) / 2, + QAngle(0, 0, 0), + 0, + 0, + 255, + 127, + 60.f); + NDebugOverlay::Box(m_vecBulletServerPositions[i], + Vector(-m_lastBulletDiameter, -m_lastBulletDiameter, -m_lastBulletDiameter) / 2, + Vector(m_lastBulletDiameter, m_lastBulletDiameter, m_lastBulletDiameter) / 2, + 0, + 0, + 255, + 127, + 60.f); + } + } + + if (cl_showfirebullethitboxes.GetBool()) + { + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + auto player = UTIL_PlayerByIndex(i); + + if (player && player != GetLocalPlayer()) + { + player->DrawServerHitboxes(60.0f, true); + } + } + } + else + { + for (auto&& entityIndex : m_touchedEntitiesWithBullet) + { + auto player = UTIL_PlayerByIndex(entityIndex); + + if (player && player != GetLocalPlayer()) + { + player->DrawServerHitboxes(60.0f, true); + } + } + } + + m_bDebugServerBullets = false; } + + if (cl_showhitboxes.GetBool() && IsPlayer() && this != GetLocalPlayer()) + { + DrawClientHitboxes(gpGlobals->frametime, true); + DrawServerHitboxes(gpGlobals->frametime, true); + } } //----------------------------------------------------------------------------- diff --git a/game/client/c_baseplayer.h b/game/client/c_baseplayer.h index 7a6a61338a..9798f29853 100644 --- a/game/client/c_baseplayer.h +++ b/game/client/c_baseplayer.h @@ -13,6 +13,7 @@ #pragma once #endif +#include "utlvector.h" #include "c_playerlocaldata.h" #include "c_basecombatcharacter.h" #include "PlayerState.h" @@ -639,10 +640,11 @@ public: void SetOldPlayerZ( float flOld ) { m_flOldPlayerZ = flOld; } - int m_nTickBaseFireBullet; - Vector m_vecBulletServerPositions[MAX_PLAYER_BULLET_SERVER_POSITIONS]; - int m_iBulletServerPositionCount; - Vector m_vecServerShootPosition[MAX_PLAYER_BULLET_SERVER_POSITIONS]; + float m_lastBulletDiameter; + bool m_bDebugServerBullets; + CUtlVector m_vecBulletServerPositions; + CUtlVector m_vecServerShootPositions; + CUtlVector m_touchedEntitiesWithBullet; }; EXTERN_RECV_TABLE(DT_BasePlayer); diff --git a/game/client/cstrike/c_cs_player.cpp b/game/client/cstrike/c_cs_player.cpp index 4970d92ab7..e10916273f 100644 --- a/game/client/cstrike/c_cs_player.cpp +++ b/game/client/cstrike/c_cs_player.cpp @@ -1349,6 +1349,10 @@ void C_CSPlayer::ValidateModelIndex( void ) UpdateMinModels(); } +void C_CSPlayer::PreDataUpdate(DataUpdateType_t updateType) +{ + BaseClass::PreDataUpdate( updateType ); +} void C_CSPlayer::PostDataUpdate( DataUpdateType_t updateType ) { @@ -2227,42 +2231,6 @@ void C_CSPlayer::Simulate( void ) } BaseClass::Simulate(); - - static ConVarRef cl_showimpacts("cl_showimpacts"); - - if ((cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3) && m_lastBulletDiameter != -1.0f) - { - auto weaponInfo = GetActiveWeapon(); - - if (!weaponInfo) - { - return; - } - - for (int i = 0; i < m_iBulletServerPositionCount; i++) - { - NDebugOverlay::SweptBox(m_vecServerShootPosition[i], - m_vecBulletServerPositions[i], - Vector(-m_lastBulletDiameter, -m_lastBulletDiameter, -m_lastBulletDiameter) / 2, - Vector(m_lastBulletDiameter, m_lastBulletDiameter, m_lastBulletDiameter) / 2, - QAngle(0, 0, 0), - 0, - 0, - 255, - 127, - 60.f); - NDebugOverlay::Box(m_vecBulletServerPositions[i], - Vector(-m_lastBulletDiameter, -m_lastBulletDiameter, -m_lastBulletDiameter) / 2, - Vector(m_lastBulletDiameter, m_lastBulletDiameter, m_lastBulletDiameter) / 2, - 0, - 0, - 255, - 127, - 60.f); - } - - m_lastBulletDiameter = -1.0f; - } } void C_CSPlayer::PostThink() diff --git a/game/client/cstrike/c_cs_player.h b/game/client/cstrike/c_cs_player.h index a966e672d5..e1ca29c5c5 100644 --- a/game/client/cstrike/c_cs_player.h +++ b/game/client/cstrike/c_cs_player.h @@ -91,6 +91,7 @@ public: virtual void ClientThink(); virtual void OnDataChanged( DataUpdateType_t type ); + virtual void PreDataUpdate( DataUpdateType_t updateType ); virtual void PostDataUpdate( DataUpdateType_t updateType ); virtual bool Interpolate( float currentTime ); virtual void UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity ); @@ -168,7 +169,6 @@ public: public: virtual float GetPlayerMaxSpeed(); - float m_lastBulletDiameter; float GetBulletDiameter(int iBulletType); void GetBulletTypeParameters( int iBulletType, diff --git a/game/client/in_main.cpp b/game/client/in_main.cpp index a3b2bf495d..47d2294834 100644 --- a/game/client/in_main.cpp +++ b/game/client/in_main.cpp @@ -1316,22 +1316,22 @@ void CInput::CreateMove ( int sequence_number, float input_sample_frametime, boo static ConVarRef cl_showhitboxes("cl_showhitboxes"); + cmd->debug_hitboxes = CUserCmd::DEBUG_HITBOXES_OFF; + if (cl_showhitboxes.GetBool()) { - cmd->debug_hitboxes = CUserCmd::DEBUG_HITBOXES_ALWAYS_ON; + cmd->debug_hitboxes |= CUserCmd::DEBUG_HITBOXES_ALWAYS_ON; } - else if (cl_showfirebullethitboxes.GetBool()) + + if (cl_showfirebullethitboxes.GetBool()) { - cmd->debug_hitboxes = CUserCmd::DEBUG_HITBOXES_ON_BULLET; + cmd->debug_hitboxes |= CUserCmd::DEBUG_HITBOXES_ON_FIRE; } - else if (cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3) + + if (cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 3) { - cmd->debug_hitboxes = CUserCmd::DEBUG_HITBOXES_ON_HIT; + cmd->debug_hitboxes |= CUserCmd::DEBUG_HITBOXES_ON_HIT; } - else - { - cmd->debug_hitboxes = CUserCmd::DEBUG_HITBOXES_OFF; - } pVerified->m_cmd = *cmd; diff --git a/game/server/baseanimating.cpp b/game/server/baseanimating.cpp index 533dd19629..dd84b2fa63 100644 --- a/game/server/baseanimating.cpp +++ b/game/server/baseanimating.cpp @@ -203,6 +203,32 @@ void* SendTableProxy_HitboxServerAngles(const SendProp* pProp, return ((QAngle*)pData + entity->entindex() * MAXSTUDIOBONES); } +void SendProxy_ShouldShowServerHitboxesOnFire(const SendProp* pProp, + const void* pStructBase, + const void* pData, + DVariant* pOut, + int iElement, + int objectID) +{ + auto index = engine->GetSendTableCurrentEntityIndex(); + + if (index == -1) + { + pOut->m_Int = false; + return; + } + + CBaseEntity* entity = UTIL_EntityByIndex(index); + + if (!entity) + { + pOut->m_Int = false; + return; + } + + pOut->m_Int = *((bool*)pData + entity->entindex()); +} + static CIKSaveRestoreOps s_IKSaveRestoreOp; @@ -311,7 +337,6 @@ IMPLEMENT_SERVERCLASS_ST(CBaseAnimating, DT_BaseAnimating) SendPropFloat( SENDINFO( m_flFadeScale ), 0, SPROP_NOSCALE ), SendPropArray3 (SENDINFO_NAME(m_vecHitboxServerPositions[0][0], m_vecHitboxServerPositions), MAXSTUDIOBONES, SendPropVector(SENDINFO_NAME(m_vecHitboxServerPositions[0][0], m_vecHitboxServerPositions[0]) ), SendTableProxy_HitboxServerPositions), SendPropArray3 (SENDINFO_NAME(m_angHitboxServerAngles[0][0], m_angHitboxServerAngles), MAXSTUDIOBONES, SendPropQAngles(SENDINFO_NAME(m_angHitboxServerAngles[0][0], m_angHitboxServerAngles[0]) ), SendTableProxy_HitboxServerAngles), - END_SEND_TABLE() @@ -346,7 +371,7 @@ CBaseAnimating::CBaseAnimating() { m_vecHitboxServerPositions[i][j] = vec3_origin; m_angHitboxServerAngles[i][j] = vec3_angle; - } + } } } diff --git a/game/server/baseanimating.h b/game/server/baseanimating.h index a8757a3d0b..0e9f1ad474 100644 --- a/game/server/baseanimating.h +++ b/game/server/baseanimating.h @@ -6,6 +6,8 @@ #ifndef BASEANIMATING_H #define BASEANIMATING_H +#include "networkvar.h" +#include "shareddefs.h" #ifdef _WIN32 #pragma once #endif diff --git a/game/server/player.cpp b/game/server/player.cpp index 521694b880..49a6425fc3 100644 --- a/game/server/player.cpp +++ b/game/server/player.cpp @@ -9,6 +9,8 @@ #include "baseplayer_shared.h" #include "dt_common.h" #include "dt_send.h" +#include "sendproxy.h" +#include "shareddefs.h" #include "trains.h" #include "soundent.h" #include "gib.h" @@ -636,7 +638,6 @@ CBasePlayer::CBasePlayer( ) m_flLastUserCommandTime = 0.f; m_flMovementTimeForUserCmdProcessingRemaining = 0.0f; - m_iBulletServerPositionCount.Set(0); } CBasePlayer::~CBasePlayer( ) @@ -4521,6 +4522,7 @@ void CBasePlayer::ForceOrigin( const Vector &vecOrigin ) //----------------------------------------------------------------------------- void CBasePlayer::PostThink() { + m_bDebugServerBullets = false; m_vecSmoothedVelocity = m_vecSmoothedVelocity * SMOOTHING_FACTOR + GetAbsVelocity() * ( 1 - SMOOTHING_FACTOR ); if ( !g_fGameOver && !m_iPlayerLocked ) @@ -7972,9 +7974,10 @@ void CMovementSpeedMod::InputSpeedMod(inputdata_t &data) SendPropInt ( SENDINFO( m_nWaterLevel ), 2, SPROP_UNSIGNED ), SendPropFloat ( SENDINFO( m_flLaggedMovementValue ), 0, SPROP_NOSCALE ), - SendPropArray3( SENDINFO_ARRAY3(m_vecBulletServerPositions), SendPropVector(SENDINFO_ARRAY(m_vecBulletServerPositions))), - SendPropInt(SENDINFO(m_iBulletServerPositionCount)), - SendPropArray3( SENDINFO_ARRAY3(m_vecServerShootPosition), SendPropVector(SENDINFO_ARRAY(m_vecServerShootPosition))), + SendPropUtlVector( SENDINFO_UTLVECTOR(m_vecBulletServerPositions), MAX_PLAYER_BULLET_SERVER_POSITIONS, SendPropVector(NULL, 0)), + SendPropUtlVector( SENDINFO_UTLVECTOR(m_vecServerShootPositions), MAX_PLAYER_BULLET_SERVER_POSITIONS, SendPropVector(NULL, 0)), + SendPropBool(SENDINFO(m_bDebugServerBullets)), + SendPropUtlVector( SENDINFO_UTLVECTOR(m_touchedEntitiesWithBullet), MAX_PLAYER_BULLET_SERVER_POSITIONS, SendPropVector(NULL, 0)), END_SEND_TABLE() diff --git a/game/server/player.h b/game/server/player.h index b62f228d46..3c51a6869d 100644 --- a/game/server/player.h +++ b/game/server/player.h @@ -10,6 +10,7 @@ #pragma once #endif +#include "utlvector.h" #include "basecombatcharacter.h" #include "usercmd.h" #include "playerlocaldata.h" @@ -1210,9 +1211,10 @@ private: public: virtual unsigned int PlayerSolidMask( bool brushOnly = false ) const; // returns the solid mask for the given player, so bots can have a more-restrictive set - CNetworkArray(Vector, m_vecBulletServerPositions, MAX_PLAYER_BULLET_SERVER_POSITIONS); - CNetworkVar(int, m_iBulletServerPositionCount); - CNetworkArray(Vector, m_vecServerShootPosition, MAX_PLAYER_BULLET_SERVER_POSITIONS); + CNetworkVar(bool, m_bDebugServerBullets); + CUtlVector m_vecBulletServerPositions; + CUtlVector m_vecServerShootPositions; + CUtlVector m_touchedEntitiesWithBullet; }; typedef CHandle CBasePlayerHandle; diff --git a/game/server/player_command.cpp b/game/server/player_command.cpp index 7fa3213cea..a7961e0c8c 100644 --- a/game/server/player_command.cpp +++ b/game/server/player_command.cpp @@ -346,7 +346,7 @@ void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper g_pGameMovement->StartTrackPredictionErrors( player ); - if (ucmd->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ALWAYS_ON) + if (ucmd->debug_hitboxes & CUserCmd::DEBUG_HITBOXES_ALWAYS_ON) { lagcompensation->StartLagCompensation( player, player->GetCurrentCommand() ); diff --git a/game/shared/cstrike/cs_player_shared.cpp b/game/shared/cstrike/cs_player_shared.cpp index cb5fe78bad..cef2f491d2 100644 --- a/game/shared/cstrike/cs_player_shared.cpp +++ b/game/shared/cstrike/cs_player_shared.cpp @@ -491,6 +491,7 @@ void CCSPlayer::FireBullet( #ifdef CLIENT_DLL static ConVarRef cl_showfirebullethitboxes("cl_showfirebullethitboxes"); + if (cl_showfirebullethitboxes.GetBool()) { for (int i = 1; i <= gpGlobals->maxClients; i++) @@ -500,12 +501,11 @@ void CCSPlayer::FireBullet( if ( lagPlayer && !lagPlayer->IsLocalPlayer() && IsLocalPlayer()) { lagPlayer->DrawClientHitboxes(60, true); - lagPlayer->m_nTickBaseFireBullet = int(lagPlayer->GetTimeBase() / TICK_INTERVAL); } } } #else - if ( m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ON_BULLET || m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ALWAYS_ON ) + if ( m_pCurrentCommand->debug_hitboxes & CUserCmd::DEBUG_HITBOXES_ON_FIRE ) { for (int i = 1; i <= gpGlobals->maxClients; i++) { @@ -563,12 +563,11 @@ void CCSPlayer::FireBullet( flDamageModifier = 0.99f; } -#ifdef CLIENT_DLL - m_lastBulletDiameter = flBulletDiameter; -#endif #ifdef CLIENT_DLL - static ConVarRef cl_showimpacts("cl_showimpacts"); + m_lastBulletDiameter = flBulletDiameter; + + static ConVarRef cl_showimpacts("cl_showimpacts"); if (cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 2) { @@ -582,38 +581,30 @@ void CCSPlayer::FireBullet( 0, 127, 60.0f); - } + NDebugOverlay::Box(tr.endpos, vecBulletRadiusMins, vecBulletRadiusMaxs, 255, 0, 0, 127, 60.f); + } - if (tr.m_pEnt && tr.m_pEnt->IsPlayer()) - { - C_BasePlayer* player = ToBasePlayer(tr.m_pEnt); + if (tr.m_pEnt && tr.m_pEnt->IsPlayer()) + { + C_BasePlayer* player = ToBasePlayer(tr.m_pEnt); - if (cl_showimpacts.GetInt() == 1 - || cl_showimpacts.GetInt() == 2) + if (cl_showimpacts.GetInt() == 1 || cl_showimpacts.GetInt() == 2) { - NDebugOverlay::Box(tr.endpos, - vecBulletRadiusMins, - vecBulletRadiusMaxs, - 255, - 0, - 0, - 127, - 60.f); player->DrawClientHitboxes(60.0f, true); } - - player->m_nTickBaseFireBullet = int(player->GetTimeBase() - / TICK_INTERVAL); - } + } #else - if ( m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ON_HIT || m_pCurrentCommand->debug_hitboxes == CUserCmd::DEBUG_HITBOXES_ALWAYS_ON ) - { - if (m_iBulletServerPositionCount.Get() < MAX_PLAYER_BULLET_SERVER_POSITIONS) + bool shouldShowServerHitRegistration = m_pCurrentCommand->debug_hitboxes & CUserCmd::DEBUG_HITBOXES_ON_HIT; + + if (shouldShowServerHitRegistration) + { + m_vecBulletServerPositions.AddToTail(tr.endpos); + m_vecServerShootPositions.AddToTail(vecSrc); + + if (tr.m_pEnt) { - m_vecBulletServerPositions.Set(m_iBulletServerPositionCount.Get(), tr.endpos); - m_vecServerShootPosition.Set(m_iBulletServerPositionCount.Get(), vecSrc); - m_iBulletServerPositionCount.Set(m_iBulletServerPositionCount.Get() + 1); - } + m_touchedEntitiesWithBullet.AddToTail(tr.m_pEnt->entindex()); + } if (tr.m_pEnt && tr.m_pEnt->IsPlayer()) { @@ -623,7 +614,7 @@ void CCSPlayer::FireBullet( } #endif - //calculate the damage based on the distance the bullet travelled. + //calculate the damage based on the distance the bullet travelled. flCurrentDistance += tr.fraction * flDistance; fCurrentDamage *= pow (flRangeModifier, (flCurrentDistance / 500)); diff --git a/game/shared/cstrike/fx_cs_shared.cpp b/game/shared/cstrike/fx_cs_shared.cpp index 777dcfc8a5..e15caedaa8 100644 --- a/game/shared/cstrike/fx_cs_shared.cpp +++ b/game/shared/cstrike/fx_cs_shared.cpp @@ -10,7 +10,7 @@ #include "weapon_csbase.h" #ifndef CLIENT_DLL - #include "ilagcompensationmanager.h" + #include "ilagcompensationmanager.h" #endif ConVar weapon_accuracy_logging( "weapon_accuracy_logging", "0", FCVAR_REPLICATED | FCVAR_DEVELOPMENTONLY | FCVAR_ARCHIVE ); @@ -292,8 +292,12 @@ void FX_FireBullets( } #ifndef CLIENT_DLL - pPlayer->m_iBulletServerPositionCount.Set(0); + pPlayer->m_vecBulletServerPositions.RemoveAll(); + pPlayer->m_vecServerShootPositions.RemoveAll(); + pPlayer->m_touchedEntitiesWithBullet.RemoveAll(); + pPlayer->m_bDebugServerBullets = true; #endif + for ( int iBullet=0; iBullet < pWeaponInfo->m_iBullets; iBullet++ ) { #ifdef CLIENT_DLL @@ -314,7 +318,7 @@ void FX_FireBullets( pPlayer, bDoEffects, x0 + x1[iBullet], y0 + y1[iBullet] ); - } + } #if !defined (CLIENT_DLL) lagcompensation->FinishLagCompensation( pPlayer ); diff --git a/game/shared/usercmd.cpp b/game/shared/usercmd.cpp index 83911890b1..49e159b1e8 100644 --- a/game/shared/usercmd.cpp +++ b/game/shared/usercmd.cpp @@ -219,7 +219,7 @@ void WriteUsercmd( bf_write *buf, const CUserCmd *to, const CUserCmd *from ) if (to->debug_hitboxes != from->debug_hitboxes) { buf->WriteOneBit(1); - buf->WriteUBitLong(to->debug_hitboxes, 2); + buf->WriteUBitLong(to->debug_hitboxes, 3); } else { @@ -362,7 +362,7 @@ void ReadUsercmd( bf_read *buf, CUserCmd *move, CUserCmd *from ) if ( buf->ReadOneBit() ) { - move->debug_hitboxes = (CUserCmd::debug_hitboxes_t)buf->ReadUBitLong(2); + move->debug_hitboxes = (CUserCmd::debug_hitboxes_t)buf->ReadUBitLong(3); } #if defined( HL2_DLL ) diff --git a/game/shared/usercmd.h b/game/shared/usercmd.h index 25efcf56e7..29fd67570e 100644 --- a/game/shared/usercmd.h +++ b/game/shared/usercmd.h @@ -220,12 +220,12 @@ public: enum debug_hitboxes_t : uint8 { DEBUG_HITBOXES_OFF, - DEBUG_HITBOXES_ALWAYS_ON, - DEBUG_HITBOXES_ON_BULLET, - DEBUG_HITBOXES_ON_HIT + DEBUG_HITBOXES_ALWAYS_ON = 1 << 0, + DEBUG_HITBOXES_ON_FIRE = 1 << 1, + DEBUG_HITBOXES_ON_HIT = 1 << 2 }; - debug_hitboxes_t debug_hitboxes; + uint8 debug_hitboxes; // Back channel to communicate IK state #if defined( HL2_DLL ) || defined( HL2_CLIENT_DLL )