Some improvements on possible buffer overflow ...
This commit is contained in:
parent
10cb9dbf07
commit
4f1c5397b6
2 changed files with 17 additions and 11 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include "cdll_client_int.h"
|
#include "cdll_client_int.h"
|
||||||
#include "convar.h"
|
#include "convar.h"
|
||||||
#include "datacache/imdlcache.h"
|
#include "datacache/imdlcache.h"
|
||||||
|
#include "dbg.h"
|
||||||
#include "dt_recv.h"
|
#include "dt_recv.h"
|
||||||
#include "iconvar.h"
|
#include "iconvar.h"
|
||||||
#include "interpolatedvar.h"
|
#include "interpolatedvar.h"
|
||||||
|
@ -2144,12 +2145,13 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
|
||||||
if ( player && !player->IsLocalPlayer() )
|
if ( player && !player->IsLocalPlayer() )
|
||||||
{
|
{
|
||||||
const auto nAttackerTickBase = event->GetInt( "tickbase" );
|
const auto nAttackerTickBase = event->GetInt( "tickbase" );
|
||||||
|
const auto pStudioHdr = player->GetModelPtr();
|
||||||
|
const auto numhitboxes = event->GetInt( "num_hitboxes" );
|
||||||
|
|
||||||
const auto numhitboxes = event->GetInt( "num_hitboxes" );
|
|
||||||
QAngle angles[MAXSTUDIOBONES];
|
QAngle angles[MAXSTUDIOBONES];
|
||||||
Vector positions[MAXSTUDIOBONES];
|
Vector positions[MAXSTUDIOBONES];
|
||||||
|
|
||||||
Assert( numhitboxes == player->GetModelPtr()->numbones() );
|
AssertFatal( numhitboxes == pStudioHdr->numbones() );
|
||||||
|
|
||||||
for ( int i = 0; i < numhitboxes; i++ )
|
for ( int i = 0; i < numhitboxes; i++ )
|
||||||
{
|
{
|
||||||
|
@ -2210,7 +2212,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
|
||||||
event->GetFloat( "angle_z" ) ) );
|
event->GetFloat( "angle_z" ) ) );
|
||||||
|
|
||||||
const auto numposeparams = event->GetInt( "num_poseparams" );
|
const auto numposeparams = event->GetInt( "num_poseparams" );
|
||||||
Assert( numposeparams == player->GetModelPtr()->GetNumPoseParameters() );
|
AssertFatal( numposeparams == pStudioHdr->GetNumPoseParameters() );
|
||||||
|
|
||||||
for ( int i = 0; i < numposeparams; i++ )
|
for ( int i = 0; i < numposeparams; i++ )
|
||||||
{
|
{
|
||||||
|
@ -2221,7 +2223,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto numbonecontrollers = event->GetInt( "num_bonecontrollers" );
|
const auto numbonecontrollers = event->GetInt( "num_bonecontrollers" );
|
||||||
Assert( numbonecontrollers == player->GetModelPtr()->GetNumBoneControllers() );
|
AssertFatal( numbonecontrollers == pStudioHdr->GetNumBoneControllers() );
|
||||||
|
|
||||||
for ( int i = 0; i < numbonecontrollers; i++ )
|
for ( int i = 0; i < numbonecontrollers; i++ )
|
||||||
{
|
{
|
||||||
|
@ -2232,7 +2234,7 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
|
||||||
}
|
}
|
||||||
|
|
||||||
auto numanimoverlays = event->GetInt( "num_anim_overlays" );
|
auto numanimoverlays = event->GetInt( "num_anim_overlays" );
|
||||||
Assert( numanimoverlays == player->GetNumAnimOverlays() );
|
AssertFatal( numanimoverlays == player->GetNumAnimOverlays() );
|
||||||
|
|
||||||
for ( int i = 0; i < numanimoverlays; i++ )
|
for ( int i = 0; i < numanimoverlays; i++ )
|
||||||
{
|
{
|
||||||
|
@ -2352,16 +2354,14 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mdl = player->GetModelPtr();
|
for ( int i = 0; i < pStudioHdr->GetNumPoseParameters(); i++ )
|
||||||
|
|
||||||
for ( int i = 0; i < mdl->GetNumPoseParameters(); i++ )
|
|
||||||
{
|
{
|
||||||
if ( pRecord->m_flPoseParameters[i] != player->m_flPoseParameter[i] )
|
if ( pRecord->m_flPoseParameters[i] != player->m_flPoseParameter[i] )
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
V_sprintf_safe( buffer,
|
V_sprintf_safe( buffer,
|
||||||
"pose parameter %s (%i): %f != %f",
|
"pose parameter %s (%i): %f != %f",
|
||||||
mdl->pPoseParameter( i ).pszName(),
|
pStudioHdr->pPoseParameter( i ).pszName(),
|
||||||
i,
|
i,
|
||||||
player->m_flPoseParameter[i],
|
player->m_flPoseParameter[i],
|
||||||
pRecord->m_flPoseParameters[i] );
|
pRecord->m_flPoseParameters[i] );
|
||||||
|
@ -2371,14 +2371,14 @@ void C_CSPlayer::FireGameEvent( IGameEvent* event )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int i = 0; i < mdl->GetNumBoneControllers(); i++ )
|
for ( int i = 0; i < pStudioHdr->GetNumBoneControllers(); i++ )
|
||||||
{
|
{
|
||||||
if ( pRecord->m_flEncodedControllers[i] != player->m_flEncodedController[i] )
|
if ( pRecord->m_flEncodedControllers[i] != player->m_flEncodedController[i] )
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
V_sprintf_safe( buffer,
|
V_sprintf_safe( buffer,
|
||||||
"bone controller %i (%i): %f != %f",
|
"bone controller %i (%i): %f != %f",
|
||||||
mdl->pBonecontroller( i )->bone,
|
pStudioHdr->pBonecontroller( i )->bone,
|
||||||
i,
|
i,
|
||||||
player->m_flEncodedController[i],
|
player->m_flEncodedController[i],
|
||||||
pRecord->m_flEncodedControllers[i] );
|
pRecord->m_flEncodedControllers[i] );
|
||||||
|
|
|
@ -897,6 +897,7 @@ void CPrediction::RunPostThink( C_BasePlayer *player )
|
||||||
|
|
||||||
void CPrediction::CheckMovingGround( CBasePlayer *player, double frametime )
|
void CPrediction::CheckMovingGround( CBasePlayer *player, double frametime )
|
||||||
{
|
{
|
||||||
|
#if !defined( NO_ENTITY_PREDICTION )
|
||||||
VPROF( "CPrediction::CheckMovingGround()" );
|
VPROF( "CPrediction::CheckMovingGround()" );
|
||||||
|
|
||||||
CBaseEntity *groundentity;
|
CBaseEntity *groundentity;
|
||||||
|
@ -926,6 +927,7 @@ void CPrediction::CheckMovingGround( CBasePlayer *player, double frametime )
|
||||||
}
|
}
|
||||||
|
|
||||||
player->RemoveFlag( FL_BASEVELOCITY );
|
player->RemoveFlag( FL_BASEVELOCITY );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1352,6 +1354,7 @@ void CPrediction::RunSimulation( int current_command, float curtime, CUserCmd *c
|
||||||
// TODO_ENHANCED: we should get rid of this to prefer SaveData/RestoreData.
|
// TODO_ENHANCED: we should get rid of this to prefer SaveData/RestoreData.
|
||||||
void CPrediction::RestorePredictedTouched( int current_command )
|
void CPrediction::RestorePredictedTouched( int current_command )
|
||||||
{
|
{
|
||||||
|
#if !defined( NO_ENTITY_PREDICTION )
|
||||||
VPROF( "CPrediction::RestorePredictedTouched" );
|
VPROF( "CPrediction::RestorePredictedTouched" );
|
||||||
|
|
||||||
if ( m_nCommandsPredicted == 0 )
|
if ( m_nCommandsPredicted == 0 )
|
||||||
|
@ -1419,10 +1422,12 @@ void CPrediction::RestorePredictedTouched( int current_command )
|
||||||
|
|
||||||
g_EventQueue.AddEvent( newEvent );
|
g_EventQueue.AddEvent( newEvent );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPrediction::StorePredictedTouched( int current_command )
|
void CPrediction::StorePredictedTouched( int current_command )
|
||||||
{
|
{
|
||||||
|
#if !defined( NO_ENTITY_PREDICTION )
|
||||||
VPROF( "CPrediction::StorePredictedTouched" );
|
VPROF( "CPrediction::StorePredictedTouched" );
|
||||||
|
|
||||||
int pc = predictables->GetPredictableCount();
|
int pc = predictables->GetPredictableCount();
|
||||||
|
@ -1480,6 +1485,7 @@ void CPrediction::StorePredictedTouched( int current_command )
|
||||||
|
|
||||||
// This will be reconstructed later.
|
// This will be reconstructed later.
|
||||||
g_EventQueue.Clear();
|
g_EventQueue.Clear();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue