Add fallbacks to Store<ESM::GameSetting>

revert-6246b479
Petr Mikheev 2 years ago
parent be45b8199e
commit 96399b3d23

@ -10,6 +10,7 @@
#include <components/esm3/esmwriter.hpp>
#include <components/esm4/loadland.hpp>
#include <components/esm4/loadwrld.hpp>
#include <components/fallback/fallback.hpp>
#include <components/loadinglistener/loadinglistener.hpp>
#include <components/misc/rng.hpp>
@ -980,6 +981,24 @@ namespace MWWorld
return TypedDynamicStore::search(ESM::RefId::stringRefId(id));
}
void Store<ESM::GameSetting>::setUp()
{
auto addSetting = [&](const std::string& key, ESM::Variant value) {
ESM::GameSetting setting;
setting.blank();
setting.mId = ESM::RefId::stringRefId(key);
setting.mValue = std::move(value);
mStatic.emplace(setting.mId, std::move(setting));
};
for (auto& [key, value] : Fallback::Map::getIntFallbackMap())
addSetting(key, ESM::Variant(value));
for (auto& [key, value] : Fallback::Map::getFloatFallbackMap())
addSetting(key, ESM::Variant(value));
for (auto& [key, value] : Fallback::Map::getNonNumericFallbackMap())
addSetting(key, ESM::Variant(value));
TypedDynamicStore<ESM::GameSetting>::setUp();
}
// Magic effect
//=========================================================================
Store<ESM::MagicEffect>::Store() {}

@ -292,6 +292,8 @@ namespace MWWorld
const ESM::GameSetting* find(const std::string_view id) const;
const ESM::GameSetting* search(const std::string_view id) const;
void setUp() override;
};
template <>

@ -19,6 +19,13 @@ namespace Fallback
public:
static void init(const std::map<std::string, std::string>& fallback);
static const std::map<std::string, int, std::less<>>& getIntFallbackMap() { return mIntFallbackMap; }
static const std::map<std::string, float, std::less<>>& getFloatFallbackMap() { return mFloatFallbackMap; }
static const std::map<std::string, std::string, std::less<>>& getNonNumericFallbackMap()
{
return mNonNumericFallbackMap;
}
static std::string_view getString(std::string_view fall);
static float getFloat(std::string_view fall);
static int getInt(std::string_view fall);

Loading…
Cancel
Save