From a5d8286cf2c6186f236d59f011e87ddb63d19efd Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Thu, 16 Jun 2022 15:46:08 +0300 Subject: [PATCH] Reject models that don't have grass\ prefix from groundcover cache --- CHANGELOG.md | 1 + apps/openmw/mwworld/groundcoverstore.cpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index defd0e7542..7f1014a6a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -113,6 +113,7 @@ Bug #6631: Fix ffmpeg avio API usage causing hangs in ffmpeg version 5 Bug #6667: Pressing the Esc key while resting or waiting causes black screen. Bug #6670: Dialogue order is incorrect + Bug #6672: Garbage object refs in groundcover plugins like Vurt's grass plugins Bug #6680: object.cpp handles nodetree unsafely, memory access with dangling pointer Bug #6682: HitOnMe doesn't fire as intended Bug #6697: Shaders vertex lighting incorrectly clamped diff --git a/apps/openmw/mwworld/groundcoverstore.cpp b/apps/openmw/mwworld/groundcoverstore.cpp index 1c75ce19f2..4f3136d557 100644 --- a/apps/openmw/mwworld/groundcoverstore.cpp +++ b/apps/openmw/mwworld/groundcoverstore.cpp @@ -18,18 +18,25 @@ namespace MWWorld ESM::ReadersCache readers; const ::EsmLoader::EsmData content = ::EsmLoader::loadEsmData(query, groundcoverFiles, fileCollections, readers, encoder); + static constexpr std::string_view prefix = "grass\\"; for (const ESM::Static& stat : statics) { std::string id = Misc::StringUtils::lowerCase(stat.mId); - mMeshCache[id] = Misc::StringUtils::lowerCase( - MWBase::Environment::get().getWindowManager()->correctMeshPath(stat.mModel)); + std::string model = Misc::StringUtils::lowerCase(stat.mModel); + std::replace(model.begin(), model.end(), '/', '\\'); + if (model.compare(0, prefix.size(), prefix) != 0) + continue; + mMeshCache[id] = MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } for (const ESM::Static& stat : content.mStatics) { std::string id = Misc::StringUtils::lowerCase(stat.mId); - mMeshCache[id] = Misc::StringUtils::lowerCase( - MWBase::Environment::get().getWindowManager()->correctMeshPath(stat.mModel)); + std::string model = Misc::StringUtils::lowerCase(stat.mModel); + std::replace(model.begin(), model.end(), '/', '\\'); + if (model.compare(0, prefix.size(), prefix) != 0) + continue; + mMeshCache[id] = MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } for (const ESM::Cell& cell : content.mCells)