From db03935f348950dbedf5f499d3808c13d19fb76b Mon Sep 17 00:00:00 2001 From: Kamay Xutax Date: Sat, 14 Sep 2024 22:06:11 +0200 Subject: [PATCH] Fixed possible crash --- game/server/cstrike/bot/cs_bot_manager.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/game/server/cstrike/bot/cs_bot_manager.cpp b/game/server/cstrike/bot/cs_bot_manager.cpp index 8962c62565..10e2354a40 100644 --- a/game/server/cstrike/bot/cs_bot_manager.cpp +++ b/game/server/cstrike/bot/cs_bot_manager.cpp @@ -1942,7 +1942,16 @@ class CheckAreasOverlappingBreakable //-------------------------------------------------------------------------------------------------------------- void CCSBotManager::OnBreakBreakable( IGameEvent *event ) { - CheckAreasOverlappingBreakable collector( UTIL_EntityByIndex( event->GetInt( "entindex" ) ) ); + auto ent = UTIL_EntityByIndex( event->GetInt( "entindex" ) ); + + if ( !ent ) + { + // TODO_ENHANCED. + DevMsg("CCSBotManager::OnBreakBreakable bug\n"); + return; + } + + CheckAreasOverlappingBreakable collector( ent ); TheNavMesh->ForAllAreas( collector ); CCSBOTMANAGER_ITERATE_BOTS( OnBreakBreakable, event ); @@ -1952,7 +1961,16 @@ void CCSBotManager::OnBreakBreakable( IGameEvent *event ) //-------------------------------------------------------------------------------------------------------------- void CCSBotManager::OnBreakProp( IGameEvent *event ) { - CheckAreasOverlappingBreakable collector( UTIL_EntityByIndex( event->GetInt( "entindex" ) ) ); + auto ent = UTIL_EntityByIndex( event->GetInt( "entindex" ) ); + + if ( !ent ) + { + // TODO_ENHANCED. + DevMsg("CCSBotManager::OnBreakProp bug\n"); + return; + } + + CheckAreasOverlappingBreakable collector( ent ); TheNavMesh->ForAllAreas( collector ); CCSBOTMANAGER_ITERATE_BOTS( OnBreakProp, event );