From d3c0ec8aeb6708a4982a067221351c15ea8b2442 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Sun, 31 Dec 2023 17:30:29 +0700 Subject: [PATCH] Fixed crash bot when can see a loose bomb but didn't get closest area for bomb --- regamedll/dlls/bot/cs_bot_manager.cpp | 1 + regamedll/dlls/bot/states/cs_bot_hunt.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/regamedll/dlls/bot/cs_bot_manager.cpp b/regamedll/dlls/bot/cs_bot_manager.cpp index 7793e815..6324ceeb 100644 --- a/regamedll/dlls/bot/cs_bot_manager.cpp +++ b/regamedll/dlls/bot/cs_bot_manager.cpp @@ -1452,6 +1452,7 @@ void CCSBotManager::SetLooseBomb(CBaseEntity *bomb) if (bomb) { m_looseBombArea = TheNavAreaGrid.GetNearestNavArea(&bomb->pev->origin); + DbgAssert(m_looseBombArea); // TODO: Need investigation and find out why it cannot find nearest area for a lost bomb, just catch it } else { diff --git a/regamedll/dlls/bot/states/cs_bot_hunt.cpp b/regamedll/dlls/bot/states/cs_bot_hunt.cpp index d1082675..aa701db9 100644 --- a/regamedll/dlls/bot/states/cs_bot_hunt.cpp +++ b/regamedll/dlls/bot/states/cs_bot_hunt.cpp @@ -95,10 +95,15 @@ void HuntState::OnUpdate(CCSBot *me) { if (!me->IsRogue() && me->CanSeeLooseBomb()) { + CNavArea *looseBombArea = TheCSBots()->GetLooseBombArea(); + // if we are near the loose bomb and can see it, hide nearby and guard it me->SetTask(CCSBot::GUARD_LOOSE_BOMB); - me->Hide(TheCSBots()->GetLooseBombArea()); - me->GetChatter()->AnnouncePlan("GoingToGuardLooseBomb", TheCSBots()->GetLooseBombArea()->GetPlace()); + me->Hide(looseBombArea); + + if (looseBombArea) + me->GetChatter()->AnnouncePlan("GoingToGuardLooseBomb", looseBombArea->GetPlace()); + return; } else if (TheCSBots()->IsBombPlanted())