Browse Source

fix some AddressSanitizer issues

pull/71/head
nillerusr 2 years ago
parent
commit
29db778997
  1. 2
      engine/cmd.cpp
  2. 5
      game/client/hud_closecaption.cpp
  3. 2
      game/client/particlemgr.cpp
  4. 13
      game/server/ai_behavior_follow.cpp
  5. 2
      game/server/ai_behavior_follow.h
  6. 2
      game/server/hl2/npc_antlion.cpp
  7. 10
      game/shared/props_shared.cpp
  8. 10
      game/shared/props_shared.h

2
engine/cmd.cpp

@ -624,7 +624,7 @@ void Cmd_Exec_f( const CCommand &args )
} }
} }
char buf[16384] = { 0 }; static char buf[16384] = { 0 };
int len = 0; int len = 0;
char *f = (char *)COM_LoadStackFile( fileName, buf, sizeof( buf ), len ); char *f = (char *)COM_LoadStackFile( fileName, buf, sizeof( buf ), len );
if ( !f ) if ( !f )

5
game/client/hud_closecaption.cpp

@ -543,7 +543,7 @@ struct AsyncCaptionData_t
data->m_nBlockNum = params.blocktoload; data->m_nBlockNum = params.blocktoload;
data->m_nFileIndex = params.fileindex; data->m_nFileIndex = params.fileindex;
data->m_nBlockSize = params.blocksize; data->m_nBlockSize = params.blocksize;
data->m_pBlockData = new byte[ data->m_nBlockSize ]; data->m_pBlockData = new byte[ data->m_nBlockSize * sizeof(ucs2) ];
return data; return data;
} }
@ -2027,6 +2027,7 @@ public:
if ( entry.blockNum != nBlockNum ) if ( entry.blockNum != nBlockNum )
continue; continue;
#ifdef WIN32 #ifdef WIN32
const wchar_t *pIn = ( const wchar_t *)&pData->m_pBlockData[ entry.offset ]; const wchar_t *pIn = ( const wchar_t *)&pData->m_pBlockData[ entry.offset ];
caption->stream = new wchar_t[ entry.length >> 1 ]; caption->stream = new wchar_t[ entry.length >> 1 ];
@ -2034,7 +2035,7 @@ public:
#else #else
// we persist to disk as ucs2 so convert back to real unicode here // we persist to disk as ucs2 so convert back to real unicode here
caption->stream = new wchar_t[ entry.length ]; caption->stream = new wchar_t[ entry.length ];
V_UCS2ToUnicode( (ucs2 *)&pData->m_pBlockData[ entry.offset ], caption->stream, entry.length*sizeof(wchar_t) ); V_UCS2ToUnicode( (ucs2 *)&pData->m_pBlockData[ entry.offset ], caption->stream, entry.length << 1 );
#endif #endif
} }
} }

2
game/client/particlemgr.cpp

@ -1014,7 +1014,7 @@ bool CParticleEffectBinding::RecalculateBoundingBox()
CEffectMaterial* CParticleEffectBinding::GetEffectMaterial( CParticleSubTexture *pSubTexture ) CEffectMaterial* CParticleEffectBinding::GetEffectMaterial( CParticleSubTexture *pSubTexture )
{ {
// Hash the IMaterial pointer. // Hash the IMaterial pointer.
unsigned long index = (((unsigned long)pSubTexture->m_pGroup) >> 6) % EFFECT_MATERIAL_HASH_SIZE; unsigned int index = (((unsigned int)pSubTexture->m_pGroup) >> 6) % EFFECT_MATERIAL_HASH_SIZE;
for ( CEffectMaterial *pCur=m_EffectMaterialHash[index]; pCur; pCur = pCur->m_pHashedNext ) for ( CEffectMaterial *pCur=m_EffectMaterialHash[index]; pCur; pCur = pCur->m_pHashedNext )
{ {
if ( pCur->m_pGroup == pSubTexture->m_pGroup ) if ( pCur->m_pGroup == pSubTexture->m_pGroup )

13
game/server/ai_behavior_follow.cpp

@ -53,7 +53,7 @@ struct AI_Follower_t
} }
AIHANDLE hFollower; AIHANDLE hFollower;
int slot; intp slot;
AI_FollowNavInfo_t navInfo; AI_FollowNavInfo_t navInfo;
AI_FollowGroup_t * pGroup; // backpointer for efficiency AI_FollowGroup_t * pGroup; // backpointer for efficiency
}; };
@ -2561,7 +2561,7 @@ bool CAI_FollowManager::AddFollower( CBaseEntity *pTarget, CAI_BaseNPC *pFollowe
AI_FollowSlot_t *pSlot = &pGroup->pFormation->pSlots[slot]; AI_FollowSlot_t *pSlot = &pGroup->pFormation->pSlots[slot];
int i = pGroup->followers.AddToTail( ); intp i = pGroup->followers.AddToTail( );
AI_Follower_t *iterNode = &pGroup->followers[i]; AI_Follower_t *iterNode = &pGroup->followers[i];
iterNode->hFollower = pFollower; iterNode->hFollower = pFollower;
@ -2569,7 +2569,6 @@ bool CAI_FollowManager::AddFollower( CBaseEntity *pTarget, CAI_BaseNPC *pFollowe
iterNode->pGroup = pGroup; iterNode->pGroup = pGroup;
pGroup->slotUsage.Set( slot ); pGroup->slotUsage.Set( slot );
CalculateFieldsFromSlot( pSlot, &iterNode->navInfo ); CalculateFieldsFromSlot( pSlot, &iterNode->navInfo );
pHandle->m_hFollower = i; pHandle->m_hFollower = i;
@ -2641,8 +2640,8 @@ bool CAI_FollowManager::RedistributeSlots( AI_FollowGroup_t *pGroup )
{ {
AI_FollowSlot_t * pSlot = &pGroup->pFormation->pSlots[bestSlot]; AI_FollowSlot_t * pSlot = &pGroup->pFormation->pSlots[bestSlot];
Vector slotPos = originFollowed + pSlot->position; Vector slotPos = originFollowed + pSlot->position;
int h = pGroup->followers.Head(); intp h = pGroup->followers.Head();
int hBest = pGroup->followers.InvalidIndex(); intp hBest = pGroup->followers.InvalidIndex();
float distSqBest = FLT_MAX; float distSqBest = FLT_MAX;
while ( h != pGroup->followers.InvalidIndex() ) while ( h != pGroup->followers.InvalidIndex() )
@ -2691,7 +2690,7 @@ void CAI_FollowManager::ChangeFormation( AI_FollowManagerInfoHandle_t& hInfo, AI
if ( pNewFormation == pGroup->pFormation ) if ( pNewFormation == pGroup->pFormation )
return; return;
int h = pGroup->followers.Head(); intp h = pGroup->followers.Head();
while ( h != pGroup->followers.InvalidIndex() ) while ( h != pGroup->followers.InvalidIndex() )
{ {
@ -2738,7 +2737,7 @@ void CAI_FollowManager::RemoveFollower( AI_FollowManagerInfoHandle_t& hInfo )
AI_FollowGroup_t *pGroup = hInfo.m_pGroup; AI_FollowGroup_t *pGroup = hInfo.m_pGroup;
AI_Follower_t* iterNode = &pGroup->followers[hInfo.m_hFollower]; AI_Follower_t* iterNode = &pGroup->followers[hInfo.m_hFollower];
int slot = iterNode->slot; intp slot = iterNode->slot;
pGroup->slotUsage.Clear( slot ); pGroup->slotUsage.Clear( slot );
pGroup->followers.Remove( hInfo.m_hFollower ); pGroup->followers.Remove( hInfo.m_hFollower );
if ( pGroup->followers.Count() == 0 ) if ( pGroup->followers.Count() == 0 )

2
game/server/ai_behavior_follow.h

@ -100,7 +100,7 @@ struct AI_FollowGroup_t;
struct AI_FollowManagerInfoHandle_t struct AI_FollowManagerInfoHandle_t
{ {
AI_FollowGroup_t *m_pGroup; AI_FollowGroup_t *m_pGroup;
int m_hFollower; intp m_hFollower;
}; };
//------------------------------------- //-------------------------------------

2
game/server/hl2/npc_antlion.cpp

@ -4016,7 +4016,7 @@ bool CNPC_Antlion::CorpseGib( const CTakeDamageInfo &info )
Vector velocity = vec3_origin; Vector velocity = vec3_origin;
AngularImpulse angVelocity = RandomAngularImpulse( -150, 150 ); AngularImpulse angVelocity = RandomAngularImpulse( -150, 150 );
breakablepropparams_t params( EyePosition(), GetAbsAngles(), velocity, angVelocity ); static breakablepropparams_t params( EyePosition(), GetAbsAngles(), velocity, angVelocity );
params.impactEnergyScale = 1.0f; params.impactEnergyScale = 1.0f;
params.defBurstScale = 150.0f; params.defBurstScale = 150.0f;
params.defCollisionGroup = COLLISION_GROUP_DEBRIS; params.defCollisionGroup = COLLISION_GROUP_DEBRIS;

10
game/shared/props_shared.cpp

@ -951,7 +951,7 @@ void PropBreakableCreateAll( int modelindex, IPhysicsObject *pPhysics, const bre
nSkin = pOwnerAnim->m_nSkin; nSkin = pOwnerAnim->m_nSkin;
} }
} }
matrix3x4_t localToWorld; static matrix3x4_t localToWorld;
CStudioHdr studioHdr; CStudioHdr studioHdr;
const model_t *model = modelinfo->GetModel( modelindex ); const model_t *model = modelinfo->GetModel( modelindex );
@ -1009,7 +1009,7 @@ void PropBreakableCreateAll( int modelindex, IPhysicsObject *pPhysics, const bre
if ( ( iPrecomputedBreakableCount != -1 ) && ( i >= iPrecomputedBreakableCount ) ) if ( ( iPrecomputedBreakableCount != -1 ) && ( i >= iPrecomputedBreakableCount ) )
break; break;
matrix3x4_t matrix; static matrix3x4_t matrix;
AngleMatrix( params.angles, params.origin, matrix ); AngleMatrix( params.angles, params.origin, matrix );
CStudioHdr studioHdr; CStudioHdr studioHdr;
@ -1188,7 +1188,7 @@ void PropBreakableCreateAll( int modelindex, IPhysicsObject *pPhysics, const bre
Vector vecBreakableObbSize = pBreakable->CollisionProp()->OBBSize(); Vector vecBreakableObbSize = pBreakable->CollisionProp()->OBBSize();
// Try to align the gibs along the original axis // Try to align the gibs along the original axis
matrix3x4_t matrix; static matrix3x4_t matrix;
AngleMatrix( vecAngles, matrix ); AngleMatrix( vecAngles, matrix );
AlignBoxes( &matrix, vecObbSize, vecBreakableObbSize ); AlignBoxes( &matrix, vecObbSize, vecBreakableObbSize );
MatrixAngles( matrix, vecAngles ); MatrixAngles( matrix, vecAngles );
@ -1397,7 +1397,7 @@ CBaseEntity *CreateGibsFromList( CUtlVector<breakmodel_t> &list, int modelindex,
if ( ( iPrecomputedBreakableCount != -1 ) && ( i >= iPrecomputedBreakableCount ) ) if ( ( iPrecomputedBreakableCount != -1 ) && ( i >= iPrecomputedBreakableCount ) )
break; break;
matrix3x4_t matrix; static matrix3x4_t matrix;
AngleMatrix( params.angles, params.origin, matrix ); AngleMatrix( params.angles, params.origin, matrix );
CStudioHdr studioHdr; CStudioHdr studioHdr;
@ -1596,7 +1596,7 @@ CBaseEntity *CreateGibsFromList( CUtlVector<breakmodel_t> &list, int modelindex,
Vector vecBreakableObbSize = pBreakable->CollisionProp()->OBBSize(); Vector vecBreakableObbSize = pBreakable->CollisionProp()->OBBSize();
// Try to align the gibs along the original axis // Try to align the gibs along the original axis
matrix3x4_t matrix; static matrix3x4_t matrix;
AngleMatrix( vecAngles, matrix ); AngleMatrix( vecAngles, matrix );
AlignBoxes( &matrix, vecObbSize, vecBreakableObbSize ); AlignBoxes( &matrix, vecObbSize, vecBreakableObbSize );
MatrixAngles( matrix, vecAngles ); MatrixAngles( matrix, vecAngles );

10
game/shared/props_shared.h

@ -221,7 +221,7 @@ struct breakmodel_t
struct breakablepropparams_t struct breakablepropparams_t
{ {
breakablepropparams_t( const Vector &_origin, const QAngle &_angles, const Vector &_velocity, const AngularImpulse &_angularVelocity ) breakablepropparams_t( const Vector _origin, const QAngle _angles, const Vector _velocity, const AngularImpulse _angularVelocity )
: origin(_origin), angles(_angles), velocity(_velocity), angularVelocity(_angularVelocity) : origin(_origin), angles(_angles), velocity(_velocity), angularVelocity(_angularVelocity)
{ {
impactEnergyScale = 0; impactEnergyScale = 0;
@ -230,10 +230,10 @@ struct breakablepropparams_t
nDefaultSkin = 0; nDefaultSkin = 0;
} }
const Vector &origin; const Vector origin;
const QAngle &angles; const QAngle angles;
const Vector &velocity; const Vector velocity;
const AngularImpulse &angularVelocity; const AngularImpulse angularVelocity;
float impactEnergyScale; float impactEnergyScale;
float defBurstScale; float defBurstScale;
int defCollisionGroup; int defCollisionGroup;

Loading…
Cancel
Save