From cbf48b43822a2ee453077e10e0d2ff69e20d27b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Mocquillon?= Date: Sun, 26 Jun 2022 21:39:05 +0200 Subject: [PATCH] Avoid double move when an area with same coordinates already exists --- apps/openmw/mwworld/store.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index ba33703668..9d6e11f141 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -404,12 +404,15 @@ namespace MWWorld land.load(esm, isDeleted); // Same area defined in multiple plugins? -> last plugin wins - auto [it, inserted] = mStatic.insert(std::move(land)); - if (!inserted) { + auto it = mStatic.lower_bound(land); + if (it != mStatic.end() && (std::tie(it->mX, it->mY) == std::tie(land.mX, land.mY))) + { auto nh = mStatic.extract(it); nh.value() = std::move(land); mStatic.insert(std::move(nh)); } + else + mStatic.insert(it, std::move(land)); return RecordId("", isDeleted); }