Prevent soundent loop

This commit is contained in:
mittorn 2018-08-04 20:59:46 +07:00
parent 29bd5d059f
commit 45e13383ff
2 changed files with 15 additions and 2 deletions

View File

@ -219,6 +219,8 @@ void CBaseMonster::Listen( void )
ClearConditions( bits_COND_HEAR_SOUND | bits_COND_SMELL_FOOD | bits_COND_SMELL );
hearingSensitivity = HearingSensitivity();
int i = 0;
while( iSound != SOUNDLIST_EMPTY )
{
pCurrentSound = CSoundEnt::SoundPointerForIndex( iSound );
@ -260,14 +262,16 @@ void CBaseMonster::Listen( void )
m_iAudibleList = iSound;
}
else if( iSound == pCurrentSound->m_iNext )
else if( i > 9999 || iSound == pCurrentSound->m_iNext )
{
void GGM_CleanSoundEnt( void );
m_iAudibleList = SOUNDLIST_EMPTY;
pCurrentSound->m_iNext = -1;
ALERT( at_error, "Sound list is broken, preventing infinite loop!\n" );
GGM_CleanSoundEnt();
return;
}
//iSound = g_pSoundEnt->m_SoundPool[iSound].m_iNext;
iSound = pCurrentSound->m_iNext;
}

View File

@ -376,3 +376,12 @@ int CSoundEnt::ClientSoundIndex( edict_t *pClient )
return iReturn;
}
void GGM_CleanSoundEnt( void )
{
if( !pSoundEnt )
return;
pSoundEnt->pev->flags |= FL_KILLME;
pSoundEnt = NULL;
}