From 4e0eb750942a48ce2ff18732f44eb8d1a06d47a0 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Wed, 12 Apr 2023 12:22:48 +0200 Subject: [PATCH 1/3] Fix exterior check when finding markers --- apps/openmw/mwworld/worldimp.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 0ff113826e..3df0141cf4 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -3338,8 +3338,8 @@ namespace MWWorld nextCells.insert(ptr.getCell()->getCell()->getId()); while (!nextCells.empty()) { - currentCells = nextCells; - nextCells.clear(); + currentCells.clear(); + std::swap(currentCells, nextCells); for (const auto& cell : currentCells) { MWWorld::CellStore* next = mWorldModel.getCell(cell); @@ -3359,7 +3359,13 @@ namespace MWWorld if (!ref.mRef.getTeleport()) continue; - if (ref.mRef.getDestCell().empty()) + bool isExterior = visit( + [](auto&& variant) { + using T = std::decay_t; + return std::is_same_v; + }, + ref.mRef.getDestCell()); + if (isExterior) { osg::Vec3f worldPos = ref.mRef.getDoorDest().asVec3(); return getClosestMarkerFromExteriorPosition(worldPos, id); @@ -3367,7 +3373,7 @@ namespace MWWorld else { const auto& dest = ref.mRef.getDestCell(); - if (!checkedCells.count(dest) && !currentCells.count(dest)) + if (!checkedCells.contains(dest) && !currentCells.contains(dest)) nextCells.insert(dest); } } From 97fb06d8c9cb339249427848f19e82ce6c1e7c65 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Thu, 13 Apr 2023 17:43:13 +0200 Subject: [PATCH 2/3] Add RefId::is --- apps/openmw/mwgui/console.cpp | 9 ++------- apps/openmw/mwworld/worldimp.cpp | 8 +------- components/esm/refid.hpp | 6 ++++++ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index b743fd91ef..6b3cdd7679 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -114,13 +114,8 @@ namespace MWGui store->listIdentifier(ids); for (auto id : ids) { - visit( - [&](auto&& variant) { - using T = std::decay_t; - if constexpr (std::is_same_v) - mNames.push_back(id.getRefIdString()); - }, - id); + if (id.is()) + mNames.push_back(id.getRefIdString()); } ids.clear(); } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 3df0141cf4..d8ae8fe9b6 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -3359,13 +3359,7 @@ namespace MWWorld if (!ref.mRef.getTeleport()) continue; - bool isExterior = visit( - [](auto&& variant) { - using T = std::decay_t; - return std::is_same_v; - }, - ref.mRef.getDestCell()); - if (isExterior) + if (ref.mRef.getDestCell().is()) { osg::Vec3f worldPos = ref.mRef.getDoorDest().asVec3(); return getClosestMarkerFromExteriorPosition(worldPos, id); diff --git a/components/esm/refid.hpp b/components/esm/refid.hpp index bfed568b79..170db6791d 100644 --- a/components/esm/refid.hpp +++ b/components/esm/refid.hpp @@ -142,6 +142,12 @@ namespace ESM return std::get_if(&mValue); } + template + bool is() const + { + return std::holds_alternative(mValue); + } + friend constexpr bool operator==(const RefId& l, const RefId& r) { return l.mValue == r.mValue; } bool operator==(std::string_view rhs) const; From 2deff337d8efc63ab656d821b3503b5a2fc751cf Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Thu, 13 Apr 2023 17:44:23 +0200 Subject: [PATCH 3/3] Fix global map position --- apps/openmw/mwworld/worldimp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index d8ae8fe9b6..f1e2a762f7 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -3298,7 +3298,7 @@ namespace MWWorld if (!ref.mRef.getTeleport()) continue; - if (ref.mRef.getDestCell().empty()) + if (ref.mRef.getDestCell().is()) { ESM::Position pos = ref.mRef.getDoorDest(); result = pos.asVec3();