From 4707d7602d4d273395cb1a48770ad5c9d70b04d9 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Tue, 12 Aug 2025 11:02:10 +0200 Subject: [PATCH 1/2] Check for nullptr before dereferencing pathgrids --- apps/openmw/mwmechanics/aiwander.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index ad4fc730df..332f7e6545 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -636,6 +636,12 @@ namespace MWMechanics const MWWorld::Cell& cell = *actor.getCell()->getCell(); const ESM::Pathgrid* pathgrid = world.getStore().get().search(cell); + // Moved to a cell without a pathgrid + if (pathgrid == nullptr) + { + storage.mAllowedPositions.clear(); + return; + } const PathgridGraph& pathgridGraph = getPathGridGraph(pathgrid); const Misc::CoordinateConverter converter = Misc::makeCoordinateConverter(cell); From 8caf68ad30b93f8332faafc46ab30dacebd222c1 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Wed, 20 Aug 2025 21:47:57 +0200 Subject: [PATCH 2/2] Count pathgrids with 0-1 nodes as non-existent --- apps/openmw/mwmechanics/aiwander.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 332f7e6545..4499304303 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -637,7 +637,7 @@ namespace MWMechanics const MWWorld::Cell& cell = *actor.getCell()->getCell(); const ESM::Pathgrid* pathgrid = world.getStore().get().search(cell); // Moved to a cell without a pathgrid - if (pathgrid == nullptr) + if (pathgrid == nullptr || pathgrid->mPoints.size() < 2) { storage.mAllowedPositions.clear(); return;