From 991573f165bd60bbdfddb4ad225dc6fc27292a4d Mon Sep 17 00:00:00 2001 From: s1lentq Date: Sun, 31 Dec 2023 07:56:45 +0700 Subject: [PATCH] Fixed bot navigation route when connected area somehow is null --- regamedll/game_shared/bot/nav_area.cpp | 2 ++ regamedll/game_shared/bot/nav_area.h | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/regamedll/game_shared/bot/nav_area.cpp b/regamedll/game_shared/bot/nav_area.cpp index f0c9de93..4e4bb309 100644 --- a/regamedll/game_shared/bot/nav_area.cpp +++ b/regamedll/game_shared/bot/nav_area.cpp @@ -294,6 +294,8 @@ void CNavArea::OnDestroyNotify(CNavArea *dead) // Connect this area to given area in given direction void CNavArea::ConnectTo(CNavArea *area, NavDirType dir) { + DbgAssert(area); + // check if already connected for (NavConnectList::iterator iter = m_connect[dir].begin(); iter != m_connect[dir].end(); iter++) { diff --git a/regamedll/game_shared/bot/nav_area.h b/regamedll/game_shared/bot/nav_area.h index 87fbb369..434424a1 100644 --- a/regamedll/game_shared/bot/nav_area.h +++ b/regamedll/game_shared/bot/nav_area.h @@ -683,7 +683,7 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa int ladderTopDir; while (true) { - CNavArea *newArea; + CNavArea *newArea = nullptr; NavTraverseType how; const CNavLadder *ladder = nullptr; @@ -716,6 +716,11 @@ bool NavAreaBuildPath(CNavArea *startArea, CNavArea *goalArea, const Vector *goa newArea = (*floorIter).area; how = (NavTraverseType)dir; floorIter++; + + DbgAssert(newArea); + + if (!newArea) + continue; } // search ladders else