From 2f89080b36e4b2ddbb33c15db7b670608d981a9a Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 7 May 2018 22:32:04 +0400 Subject: [PATCH] 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,