From 27eb64c7f005c826af3635ce4fa8dea94f21d5f3 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Wed, 2 Jan 2019 13:49:04 +0300 Subject: [PATCH] Clean up fallback record creation again --- apps/openmw/mwworld/esmstore.cpp | 2 -- apps/openmw/mwworld/store.cpp | 52 ----------------------------- apps/openmw/mwworld/worldimp.cpp | 57 +++++++++++++++++++++++++------- 3 files changed, 45 insertions(+), 66 deletions(-) diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index c85e3d30e..fe92f570d 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -140,8 +140,6 @@ void ESMStore::setUp(bool validateRecords) mMagicEffects.setUp(); mAttributes.setUp(); mDialogs.setUp(); - mStatics.setUp(); - mDoors.setUp(); if (validateRecords) validate(); diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 7df61bec3..67df33bf0 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -1053,58 +1053,6 @@ 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; - newMarker.mId = marker.first; - newMarker.mModel = marker.second; - std::pair ret = mStatic.insert(std::make_pair(marker.first, newMarker)); - if (ret.first != mStatic.end()) - { - mShared.push_back(&ret.first->second); - } - } - } - } - - template<> - void Store::setUp() - { - // Load default Door type marker definitions - std::pair markers[] = { - std::make_pair("prisonmarker", "marker_prison.nif") - }; - - for (const std::pair &marker : markers) - { - if (search(marker.first) == 0) - { - ESM::Door newMarker; - newMarker.mId = marker.first; - newMarker.mModel = marker.second; - std::pair ret = mStatic.insert(std::make_pair(marker.first, newMarker)); - if (ret.first != mStatic.end()) - { - mShared.push_back(&ret.first->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/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index cb5ded593..181fa0742 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -494,6 +494,17 @@ namespace MWWorld gmst["iWereWolfBounty"] = ESM::Variant(1000); gmst["fCombatDistanceWerewolfMod"] = ESM::Variant(0.3f); + for (const std::pair ¶ms : gmst) + { + if (!mStore.get().search(params.first)) + { + ESM::GameSetting record; + record.mId = params.first; + record.mValue = params.second; + mStore.insertStatic(record); + } + } + std::map globals; // vanilla Morrowind does not define dayspassed. globals["dayspassed"] = ESM::Variant(1); // but the addons start counting at 1 :( @@ -513,25 +524,47 @@ namespace MWWorld globals["crimegoldturnin"] = ESM::Variant(0); globals["pchasturnin"] = ESM::Variant(0); - for (std::map::iterator it = gmst.begin(); it != gmst.end(); ++it) + for (const std::pair ¶ms : globals) + { + if (!mStore.get().search(params.first)) + { + ESM::Global record; + record.mId = params.first; + record.mValue = params.second; + mStore.insertStatic(record); + } + } + + std::map statics; + // Total conversions from SureAI lack marker records + statics["divinemarker"] = "marker_divine.nif"; + statics["doormarker"] = "marker_arrow.nif"; + statics["northmarker"] = "marker_north.nif"; + statics["templemarker"] = "marker_temple.nif"; + statics["travelmarker"] = "marker_travel.nif"; + + for (const std::pair ¶ms : statics) { - if (!mStore.get().search(it->first)) + if (!mStore.get().search(params.first)) { - ESM::GameSetting setting; - setting.mId = it->first; - setting.mValue = it->second; - mStore.insertStatic(setting); + ESM::Static record; + record.mId = params.first; + record.mModel = params.second; + mStore.insertStatic(record); } } - for (std::map::iterator it = globals.begin(); it != globals.end(); ++it) + std::map doors; + doors["prisonmarker"] = "marker_prison.nif"; + + for (const std::pair ¶ms : doors) { - if (!mStore.get().search(it->first)) + if (!mStore.get().search(params.first)) { - ESM::Global setting; - setting.mId = it->first; - setting.mValue = it->second; - mStore.insertStatic(setting); + ESM::Door record; + record.mId = params.first; + record.mModel = params.second; + mStore.insertStatic(record); } } }