From aec3ba2579b0ef50157b9f4a2bf6643b3f8a80b0 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Wed, 31 Jan 2024 18:33:34 +0700 Subject: [PATCH] Fixed m_looseBombArea assertion --- regamedll/dlls/bot/cs_bot_manager.cpp | 2 +- regamedll/game_shared/bot/nav_area.cpp | 5 +++++ regamedll/game_shared/bot/nav_area.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/bot/cs_bot_manager.cpp b/regamedll/dlls/bot/cs_bot_manager.cpp index 6324ceeb..345ae31f 100644 --- a/regamedll/dlls/bot/cs_bot_manager.cpp +++ b/regamedll/dlls/bot/cs_bot_manager.cpp @@ -1452,7 +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 + DbgAssert(!TheNavAreaGrid.IsValid() || 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/game_shared/bot/nav_area.cpp b/regamedll/game_shared/bot/nav_area.cpp index 4e4bb309..1ff3ef8c 100644 --- a/regamedll/game_shared/bot/nav_area.cpp +++ b/regamedll/game_shared/bot/nav_area.cpp @@ -4674,6 +4674,11 @@ void CNavAreaGrid::RemoveNavArea(CNavArea *area) m_areaCount--; } +bool CNavAreaGrid::IsValid() const +{ + return m_grid && m_areaCount > 0; +} + // Given a position, return the nav area that IsOverlapping and is *immediately* beneath it CNavArea *CNavAreaGrid::GetNavArea(const Vector *pos, float beneathLimit) const { diff --git a/regamedll/game_shared/bot/nav_area.h b/regamedll/game_shared/bot/nav_area.h index 434424a1..d1ed024e 100644 --- a/regamedll/game_shared/bot/nav_area.h +++ b/regamedll/game_shared/bot/nav_area.h @@ -503,6 +503,7 @@ public: CNavArea *GetNavAreaByID(unsigned int id) const; CNavArea *GetNearestNavArea(const Vector *pos, bool anyZ = false) const; + bool IsValid() const; Place GetPlace(const Vector *pos) const; // return radio chatter place for given coordinate private: