game/server: fix some Asan issues
This commit is contained in:
parent
5eaa214d7c
commit
2dd0fb3af0
4 changed files with 34 additions and 3 deletions
|
@ -111,7 +111,7 @@ public:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for ( int i = pGroup->followers.Head(); i != pGroup->followers.InvalidIndex(); i = pGroup->followers.Next( i ) )
|
for ( intp i = pGroup->followers.Head(); i != pGroup->followers.InvalidIndex(); i = pGroup->followers.Next( i ) )
|
||||||
{
|
{
|
||||||
if ( pGroup->followers[i].hFollower && pGroup->followers[i].hFollower->ClassMatches( iszClassname ) )
|
if ( pGroup->followers[i].hFollower && pGroup->followers[i].hFollower->ClassMatches( iszClassname ) )
|
||||||
{
|
{
|
||||||
|
@ -131,7 +131,7 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int h = pGroup->followers.Head();
|
intp h = pGroup->followers.Head();
|
||||||
|
|
||||||
while( h != pGroup->followers.InvalidIndex() )
|
while( h != pGroup->followers.InvalidIndex() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,6 +120,8 @@ CAI_Network::CAI_Network()
|
||||||
#ifdef AI_NODE_TREE
|
#ifdef AI_NODE_TREE
|
||||||
m_pNodeTree = NULL;
|
m_pNodeTree = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gEntList.AddListenerEntity( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -133,6 +135,9 @@ CAI_Network::~CAI_Network()
|
||||||
m_pNodeTree = NULL;
|
m_pNodeTree = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gEntList.RemoveListenerEntity( this );
|
||||||
|
|
||||||
if ( m_pAInode )
|
if ( m_pAInode )
|
||||||
{
|
{
|
||||||
for ( int node = 0; node < m_iNumNodes; node++ )
|
for ( int node = 0; node < m_iNumNodes; node++ )
|
||||||
|
@ -642,3 +647,22 @@ IterationRetval_t CAI_Network::EnumElement( IHandleEntity *pHandleEntity )
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
void CAI_Network::OnEntityDeleted( CBaseEntity *pEntity )
|
||||||
|
{
|
||||||
|
if( pEntity->IsNPC() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
const char *classname = pEntity->GetClassname();
|
||||||
|
if( !classname || strcmp(classname, "ai_hint") != 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
for( int i = 0; i < m_iNumNodes; i++)
|
||||||
|
{
|
||||||
|
if( m_pAInode[i]->GetHint() == (CAI_Hint*)pEntity )
|
||||||
|
{
|
||||||
|
m_pAInode[i]->SetHint( NULL );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -84,12 +84,14 @@ public:
|
||||||
// Purpose: Stores a node graph through which an AI may pathfind
|
// Purpose: Stores a node graph through which an AI may pathfind
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
class CAI_Network : public IPartitionEnumerator
|
class CAI_Network : public IPartitionEnumerator, public IEntityListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAI_Network();
|
CAI_Network();
|
||||||
~CAI_Network();
|
~CAI_Network();
|
||||||
|
|
||||||
|
void OnEntityDeleted( CBaseEntity *pEntity );
|
||||||
|
|
||||||
CAI_Node * AddNode( const Vector &origin, float yaw ); // Returns a new node in the network
|
CAI_Node * AddNode( const Vector &origin, float yaw ); // Returns a new node in the network
|
||||||
CAI_Link * CreateLink( int srcID, int destID, CAI_DynamicLink *pDynamicLink = NULL );
|
CAI_Link * CreateLink( int srcID, int destID, CAI_DynamicLink *pDynamicLink = NULL );
|
||||||
|
|
||||||
|
@ -128,6 +130,8 @@ public:
|
||||||
|
|
||||||
CAI_Node** AccessNodes() const { return m_pAInode; }
|
CAI_Node** AccessNodes() const { return m_pAInode; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class CAI_NetworkManager;
|
friend class CAI_NetworkManager;
|
||||||
|
|
||||||
|
|
|
@ -2019,6 +2019,9 @@ bool V_StripLastDir( char *dirName, int maxlen )
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
const char * V_UnqualifiedFileName( const char * in )
|
const char * V_UnqualifiedFileName( const char * in )
|
||||||
{
|
{
|
||||||
|
if( !in || !in[0] )
|
||||||
|
return in;
|
||||||
|
|
||||||
// back up until the character after the first path separator we find,
|
// back up until the character after the first path separator we find,
|
||||||
// or the beginning of the string
|
// or the beginning of the string
|
||||||
const char * out = in + strlen( in ) - 1;
|
const char * out = in + strlen( in ) - 1;
|
||||||
|
|
Loading…
Reference in a new issue