From a401c517bfa000347443c2837a0b55718000a53a Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sat, 23 Jan 2021 00:56:46 +0100 Subject: [PATCH] Always unload height fields loadCell always adds a height field, but unloadCell only removed it for cells with height data. Reloading a cell overwrote the height field added earlier (leading to its destruction) while the navigator retained a reference to the now deleted collision shape, leading to a crash. --- apps/openmw/mwworld/scene.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 47b62862f7..427ee3aa8b 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -340,17 +340,9 @@ namespace MWWorld if ((*iter)->getCell()->isExterior()) { - const ESM::Land* land = - MWBase::Environment::get().getWorld()->getStore().get().search( - (*iter)->getCell()->getGridX(), - (*iter)->getCell()->getGridY() - ); - if (land && land->mDataTypes&ESM::Land::DATA_VHGT) - { - if (const auto heightField = mPhysics->getHeightField(cellX, cellY)) - navigator->removeObject(DetourNavigator::ObjectId(heightField)); - mPhysics->removeHeightField(cellX, cellY); - } + if (const auto heightField = mPhysics->getHeightField(cellX, cellY)) + navigator->removeObject(DetourNavigator::ObjectId(heightField)); + mPhysics->removeHeightField(cellX, cellY); } if ((*iter)->getCell()->hasWater())