From 1dd36329a34e1cf2d5b7412472d5a83f6907d98d Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 3 May 2018 10:37:55 +0400 Subject: [PATCH 1/3] Load default markers definitions (bug #4410) --- apps/openmw/mwworld/esmstore.cpp | 1 + apps/openmw/mwworld/store.cpp | 28 ++++++++++++++++++++++++++++ components/esm/loadstat.hpp | 16 +++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index 4a1763d0a..2fe9ebcad 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -141,6 +141,7 @@ void ESMStore::setUp() mMagicEffects.setUp(); mAttributes.setUp(); mDialogs.setUp(); + mStatics.setUp(); } int ESMStore::countSavedGameRecords() const diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 158d3f771..e9968c38f 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -1053,6 +1053,34 @@ namespace MWWorld } } + template<> + void Store::setUp() + { + // Load default marker definitions, if game files do not have them for some reason + std::pair markers[] = { + std::make_pair("divinemarker", "marker_divine.nif"), + std::make_pair("doormarker", "marker_arrow.nif"), + std::make_pair("northmarker", "marker_north.nif"), + std::make_pair("templemarker", "marker_temple.nif"), + std::make_pair("travelmarker", "marker_travel.nif") + }; + + for (const std::pair marker : markers) + { + if (search(marker.first) == 0) + { + ESM::Static newMarker = ESM::Static(marker.first, marker.second); + mStatic.insert(std::make_pair(marker.first, newMarker)); + + std::map::iterator found = mStatic.find(marker.first); + if (found != mStatic.end()) + { + mShared.push_back(&found->second); + } + } + } + } + template <> inline RecordId Store::load(ESM::ESMReader &esm) { // The original letter case of a dialogue ID is saved, because it's printed diff --git a/components/esm/loadstat.hpp b/components/esm/loadstat.hpp index 930cdb849..f80875b65 100644 --- a/components/esm/loadstat.hpp +++ b/components/esm/loadstat.hpp @@ -26,13 +26,23 @@ struct Static /// Return a string descriptor for this record type. Currently used for debugging / error logs only. static std::string getRecordType() { return "Static"; } - std::string mId, mModel; + std::string mId, mModel; - void load(ESMReader &esm, bool &isDeleted); - void save(ESMWriter &esm, bool isDeleted = false) const; + void load(ESMReader &esm, bool &isDeleted); + void save(ESMWriter &esm, bool isDeleted = false) const; void blank(); ///< Set record to default state (does not touch the ID). + + Static(const std::string id, const std::string &model) + : mId(id) + , mModel(model) + { + } + + Static() + { + } }; } #endif From 17222eb8219b546db7ec948e6a16616d2cb5ac76 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 6 May 2018 16:42:05 +0400 Subject: [PATCH 2/3] Get rid of unnecessary find --- apps/openmw/mwworld/store.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index e9968c38f..6f0a1b49f 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -1070,12 +1070,10 @@ namespace MWWorld if (search(marker.first) == 0) { ESM::Static newMarker = ESM::Static(marker.first, marker.second); - mStatic.insert(std::make_pair(marker.first, newMarker)); - - std::map::iterator found = mStatic.find(marker.first); - if (found != mStatic.end()) + std::pair ret = mStatic.insert(std::make_pair(marker.first, newMarker)); + if (ret.first != mStatic.end()) { - mShared.push_back(&found->second); + mShared.push_back(&ret.first->second); } } } From 2f89080b36e4b2ddbb33c15db7b670608d981a9a Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 7 May 2018 22:32:04 +0400 Subject: [PATCH 3/3] Load default markers definitions in editor --- apps/opencs/model/world/data.cpp | 26 ++++++++++++++++++++++++++ apps/opencs/model/world/data.hpp | 2 ++ 2 files changed, 28 insertions(+) diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 2216d5ca6..053754943 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -962,6 +962,29 @@ int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base return mReader->getRecordCount(); } +void CSMWorld::Data::loadFallbackEntries() +{ + // Load default marker definitions, if game files do not have them for some reason + std::pair markers[] = { + std::make_pair("divinemarker", "marker_divine.nif"), + std::make_pair("doormarker", "marker_arrow.nif"), + std::make_pair("northmarker", "marker_north.nif"), + std::make_pair("templemarker", "marker_temple.nif"), + std::make_pair("travelmarker", "marker_travel.nif") + }; + + for (const std::pair marker : markers) + { + if (mReferenceables.searchId (marker.first)==-1) + { + CSMWorld::Record record; + record.mBase = ESM::Static(marker.first, marker.second); + record.mState = CSMWorld::RecordBase::State_BaseOnly; + mReferenceables.appendRecord (record, CSMWorld::UniversalId::Type_Static); + } + } +} + bool CSMWorld::Data::continueLoading (CSMDoc::Messages& messages) { if (!mReader) @@ -983,6 +1006,9 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Messages& messages) mReader = 0; mDialogue = 0; + + loadFallbackEntries(); + return true; } diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index 8a3667ea1..1b975f430 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -144,6 +144,8 @@ namespace CSMWorld static int count (RecordBase::State state, const CollectionBase& collection); + void loadFallbackEntries(); + public: Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,