From 8d5570d85fc9e15d168739e3d45132ddca38ab1a Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Tue, 26 Sep 2023 21:04:28 -0500 Subject: [PATCH] Fix(client): Override dynamic cell records as well, minor refactor for clarity --- apps/openmw/mwworld/store.cpp | 41 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 66c6be35b..911100ba7 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -801,30 +801,37 @@ namespace MWWorld */ ESM::Cell *Store::override(const ESM::Cell &cell) { - if (search(cell) != 0) - { - for (auto it = mSharedInt.begin(); it != mSharedInt.end(); ++it) + if (search(cell) == 0) + return insert(cell); + + + for (auto it = mSharedInt.begin(); it != mSharedInt.end(); ++it) { if (Misc::StringUtils::ciEqual((*it)->mName, cell.mName)) - { - (*it) = &const_cast(cell); - break; - } + { + (*it) = &const_cast(cell); + break; + } } - for (auto it = mInt.begin(); it != mInt.end(); ++it) + for (auto it = mInt.begin(); it != mInt.end(); ++it) { if (Misc::StringUtils::ciEqual((*it).second.mName, cell.mName)) - { - (*it).second = cell; - return &(*it).second; - } + { + (*it).second = cell; + return &(*it).second; + } } - } - else - { - return insert(cell); - } + + for (auto it = mDynamicInt.begin(); it != mDynamicInt.end(); ++it) + { + if (Misc::StringUtils::ciEqual((*it).second.mName, cell.mName)) + { + (*it).second = cell; + return &(*it).second; + } + } + return nullptr; } /* End of tes3mp addition