From 227a993b9453b7ff2473975047774b82f00b970a Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Thu, 20 Apr 2023 13:37:01 +0200 Subject: [PATCH 1/2] Remove `createRecord` functions from World because the only forward the argument to ESMStore that can be used directly. --- apps/openmw/mwbase/world.hpp | 63 +----------- apps/openmw/mwclass/armor.cpp | 10 +- apps/openmw/mwclass/book.cpp | 2 +- apps/openmw/mwclass/clothing.cpp | 2 +- apps/openmw/mwclass/creature.cpp | 4 +- apps/openmw/mwclass/npc.cpp | 12 +-- apps/openmw/mwclass/weapon.cpp | 2 +- apps/openmw/mwgui/spellcreationdialog.cpp | 2 +- apps/openmw/mwlua/luabindings.cpp | 2 +- apps/openmw/mwmechanics/alchemy.cpp | 2 +- apps/openmw/mwmechanics/enchanting.cpp | 2 +- apps/openmw/mwmechanics/inventory.hpp | 4 +- .../mwmechanics/mechanicsmanagerimp.cpp | 10 +- apps/openmw/mwmechanics/setbaseaisetting.hpp | 2 +- apps/openmw/mwmechanics/spelllist.cpp | 2 +- apps/openmw/mwscript/miscextensions.cpp | 8 +- apps/openmw/mwsound/regionsoundselector.cpp | 7 +- apps/openmw/mwsound/regionsoundselector.hpp | 3 +- apps/openmw/mwsound/sound_buffer.cpp | 6 +- apps/openmw/mwsound/soundmanagerimp.cpp | 2 +- apps/openmw/mwworld/esmstore.hpp | 1 + apps/openmw/mwworld/inventorystore.cpp | 4 +- apps/openmw/mwworld/worldimp.cpp | 96 +------------------ apps/openmw/mwworld/worldimp.hpp | 62 +----------- apps/openmw/mwworld/worldmodel.cpp | 2 +- 25 files changed, 52 insertions(+), 260 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 7d486b8b2f..d6933a5443 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -147,7 +147,8 @@ namespace MWBase virtual MWWorld::Ptr getPlayerPtr() = 0; virtual MWWorld::ConstPtr getPlayerConstPtr() const = 0; - virtual const MWWorld::ESMStore& getStore() const = 0; + virtual MWWorld::ESMStore& getStore() = 0; + const MWWorld::ESMStore& getStore() const { return const_cast(this)->getStore(); } virtual const std::vector& getESMVersions() const = 0; @@ -344,66 +345,6 @@ namespace MWBase ///< Toggle a render mode. ///< \return Resulting mode - virtual const ESM::Potion* createRecord(const ESM::Potion& record) = 0; - ///< Create a new record (of type potion) in the ESM store. - /// \return pointer to created record - - virtual const ESM::Spell* createRecord(const ESM::Spell& record) = 0; - ///< Create a new record (of type spell) in the ESM store. - /// \return pointer to created record - - virtual const ESM::Class* createRecord(const ESM::Class& record) = 0; - ///< Create a new record (of type class) in the ESM store. - /// \return pointer to created record - - virtual const ESM::Cell* createRecord(const ESM::Cell& record) = 0; - ///< Create a new record (of type cell) in the ESM store. - /// \return pointer to created record - - virtual const ESM::NPC* createRecord(const ESM::NPC& record) = 0; - ///< Create a new record (of type npc) in the ESM store. - /// \return pointer to created record - - virtual const ESM::Armor* createRecord(const ESM::Armor& record) = 0; - ///< Create a new record (of type armor) in the ESM store. - /// \return pointer to created record - - virtual const ESM::Weapon* createRecord(const ESM::Weapon& record) = 0; - ///< Create a new record (of type weapon) in the ESM store. - /// \return pointer to created record - - virtual const ESM::Clothing* createRecord(const ESM::Clothing& record) = 0; - ///< Create a new record (of type clothing) in the ESM store. - /// \return pointer to created record - - virtual const ESM::Enchantment* createRecord(const ESM::Enchantment& record) = 0; - ///< Create a new record (of type enchantment) in the ESM store. - /// \return pointer to created record - - virtual const ESM::Book* createRecord(const ESM::Book& record) = 0; - ///< Create a new record (of type book) in the ESM store. - /// \return pointer to created record - - virtual const ESM::CreatureLevList* createOverrideRecord(const ESM::CreatureLevList& record) = 0; - ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. - /// \return pointer to created record - - virtual const ESM::ItemLevList* createOverrideRecord(const ESM::ItemLevList& record) = 0; - ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. - /// \return pointer to created record - - virtual const ESM::Creature* createOverrideRecord(const ESM::Creature& record) = 0; - ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. - /// \return pointer to created record - - virtual const ESM::NPC* createOverrideRecord(const ESM::NPC& record) = 0; - ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. - /// \return pointer to created record - - virtual const ESM::Container* createOverrideRecord(const ESM::Container& record) = 0; - ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. - /// \return pointer to created record - virtual MWWorld::Ptr placeObject(const MWWorld::ConstPtr& object, float cursorX, float cursorY, int amount) = 0; ///< copy and place an object into the gameworld at the specified cursor position /// @param object diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index a7a19bcfb3..2b32d06bc7 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -289,7 +289,7 @@ namespace MWClass newItem.mName = newName; newItem.mData.mEnchant = enchCharge; newItem.mEnchant = enchId; - const ESM::Armor* record = MWBase::Environment::get().getWorld()->createRecord(newItem); + const ESM::Armor* record = MWBase::Environment::get().getWorld()->getStore().insert(newItem); return record->mId; } @@ -300,8 +300,12 @@ namespace MWClass int armorSkillType = getEquipmentSkill(ptr); float armorSkill = actor.getClass().getSkill(actor, armorSkillType); - const MWBase::World* world = MWBase::Environment::get().getWorld(); - int iBaseArmorSkill = world->getStore().get().find("iBaseArmorSkill")->mValue.getInteger(); + int iBaseArmorSkill = MWBase::Environment::get() + .getWorld() + ->getStore() + .get() + .find("iBaseArmorSkill") + ->mValue.getInteger(); if (ref->mBase->mData.mWeight == 0) return ref->mBase->mData.mArmor; diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 27b4a28a22..8b71463505 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -151,7 +151,7 @@ namespace MWClass newItem.mData.mIsScroll = 1; newItem.mData.mEnchant = enchCharge; newItem.mEnchant = enchId; - const ESM::Book* record = MWBase::Environment::get().getWorld()->createRecord(newItem); + const ESM::Book* record = MWBase::Environment::get().getWorld()->getStore().insert(newItem); return record->mId; } diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 4a1c3019d8..17d5c443df 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -196,7 +196,7 @@ namespace MWClass newItem.mName = newName; newItem.mData.mEnchant = enchCharge; newItem.mEnchant = enchId; - const ESM::Clothing* record = MWBase::Environment::get().getWorld()->createRecord(newItem); + const ESM::Clothing* record = MWBase::Environment::get().getWorld()->getStore().insert(newItem); return record->mId; } diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 120cd0c76e..7723cf36ae 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -91,8 +91,8 @@ namespace MWClass static const GMST staticGmst = [] { GMST gmst; - const MWBase::World* world = MWBase::Environment::get().getWorld(); - const MWWorld::Store& store = world->getStore().get(); + const MWWorld::Store& store + = MWBase::Environment::get().getWorld()->getStore().get(); gmst.fMinWalkSpeedCreature = store.find("fMinWalkSpeedCreature"); gmst.fMaxWalkSpeedCreature = store.find("fMaxWalkSpeedCreature"); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 27ca299ac1..ebc11c623a 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -276,8 +276,8 @@ namespace MWClass static const GMST staticGmst = [] { GMST gmst; - const MWBase::World* world = MWBase::Environment::get().getWorld(); - const MWWorld::Store& store = world->getStore().get(); + const MWWorld::Store& store + = MWBase::Environment::get().getWorld()->getStore().get(); gmst.fMinWalkSpeed = store.find("fMinWalkSpeed"); gmst.fMaxWalkSpeed = store.find("fMaxWalkSpeed"); @@ -536,8 +536,8 @@ namespace MWClass if (ptr.getRefData().getCustomData() && ptr.getRefData().getCustomData()->asNpcCustomData().mNpcStats.isWerewolf()) { - const MWBase::World* world = MWBase::Environment::get().getWorld(); - const MWWorld::Store& store = world->getStore().get(); + const MWWorld::Store& store + = MWBase::Environment::get().getWorld()->getStore().get(); return store.find("sWerewolfPopup")->mValue.getString(); } @@ -1195,8 +1195,8 @@ namespace MWClass float Npc::getArmorRating(const MWWorld::Ptr& ptr) const { - const MWBase::World* world = MWBase::Environment::get().getWorld(); - const MWWorld::Store& store = world->getStore().get(); + const MWWorld::Store& store + = MWBase::Environment::get().getWorld()->getStore().get(); MWMechanics::NpcStats& stats = getNpcStats(ptr); const MWWorld::InventoryStore& invStore = getInventoryStore(ptr); diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 3a02581f62..8dffba0fde 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -269,7 +269,7 @@ namespace MWClass newItem.mData.mEnchant = enchCharge; newItem.mEnchant = enchId; newItem.mData.mFlags |= ESM::Weapon::Magical; - const ESM::Weapon* record = MWBase::Environment::get().getWorld()->createRecord(newItem); + const ESM::Weapon* record = MWBase::Environment::get().getWorld()->getStore().insert(newItem); return record->mId; } diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index c1fccb8df0..149615ce62 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -416,7 +416,7 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Mysticism Hit")); - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->createRecord(mSpell); + const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().insert(mSpell); MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player); MWMechanics::Spells& spells = stats.getSpells(); diff --git a/apps/openmw/mwlua/luabindings.cpp b/apps/openmw/mwlua/luabindings.cpp index 45d9069d27..e11ba382a2 100644 --- a/apps/openmw/mwlua/luabindings.cpp +++ b/apps/openmw/mwlua/luabindings.cpp @@ -120,7 +120,7 @@ namespace MWLua // Creates a new record in the world database. api["createRecord"] = sol::overload([](const ESM::Potion& potion) -> const ESM::Potion* { - return MWBase::Environment::get().getWorld()->createRecord(potion); + return MWBase::Environment::get().getWorld()->getStore().insert(potion); } // TODO: add here overloads for other records ); diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index b045ef6f95..3030a0997a 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -315,7 +315,7 @@ void MWMechanics::Alchemy::addPotion(const std::string& name) const ESM::Potion* record = getRecord(newRecord); if (!record) - record = MWBase::Environment::get().getWorld()->createRecord(newRecord); + record = MWBase::Environment::get().getWorld()->getStore().insert(newRecord); mAlchemist.getClass().getContainerStore(mAlchemist).add(record->mId, 1); } diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index 7121682176..044807574f 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -98,7 +98,7 @@ namespace MWMechanics // Try to find a dynamic enchantment with the same stats, create a new one if not found. const ESM::Enchantment* enchantmentPtr = getRecord(enchantment); if (enchantmentPtr == nullptr) - enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord(enchantment); + enchantmentPtr = MWBase::Environment::get().getWorld()->getStore().insert(enchantment); // Apply the enchantment const ESM::RefId& newItemId diff --git a/apps/openmw/mwmechanics/inventory.hpp b/apps/openmw/mwmechanics/inventory.hpp index b26d40f301..a741e3c4ec 100644 --- a/apps/openmw/mwmechanics/inventory.hpp +++ b/apps/openmw/mwmechanics/inventory.hpp @@ -24,7 +24,7 @@ namespace MWMechanics { const int sign = it.mCount < 1 ? -1 : 1; it.mCount = sign * std::max(it.mCount * sign + amount, 0); - MWBase::Environment::get().getWorld()->createOverrideRecord(copy); + MWBase::Environment::get().getWorld()->getStore().overrideRecord(copy); return; } } @@ -34,7 +34,7 @@ namespace MWMechanics cont.mItem = itemId; cont.mCount = amount; copy.mInventory.mList.push_back(cont); - MWBase::Environment::get().getWorld()->createOverrideRecord(copy); + MWBase::Environment::get().getWorld()->getStore().overrideRecord(copy); } } } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 80f9460892..23bf892fc4 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -440,7 +440,7 @@ namespace MWMechanics ESM::NPC player = *world->getPlayerPtr().get()->mBase; player.mName = name; - world->createRecord(player); + world->getStore().insert(player); mUpdatePlayer = true; } @@ -457,7 +457,7 @@ namespace MWMechanics player.mHair = hair; player.setIsMale(male); - world->createRecord(player); + world->getStore().insert(player); mRaceSelected = true; buildPlayer(); @@ -478,7 +478,7 @@ namespace MWMechanics ESM::NPC player = *world->getPlayerPtr().get()->mBase; player.mClass = id; - world->createRecord(player); + world->getStore().insert(player); mClassSelected = true; buildPlayer(); @@ -489,12 +489,12 @@ namespace MWMechanics { MWBase::World* world = MWBase::Environment::get().getWorld(); - const ESM::Class* ptr = world->createRecord(cls); + const ESM::Class* ptr = world->getStore().insert(cls); ESM::NPC player = *world->getPlayerPtr().get()->mBase; player.mClass = ptr->mId; - world->createRecord(player); + world->getStore().insert(player); mClassSelected = true; buildPlayer(); diff --git a/apps/openmw/mwmechanics/setbaseaisetting.hpp b/apps/openmw/mwmechanics/setbaseaisetting.hpp index 6e2b34b71d..780ff2ca76 100644 --- a/apps/openmw/mwmechanics/setbaseaisetting.hpp +++ b/apps/openmw/mwmechanics/setbaseaisetting.hpp @@ -33,7 +33,7 @@ namespace MWMechanics default: assert(false); } - MWBase::Environment::get().getWorld()->createOverrideRecord(copy); + MWBase::Environment::get().getWorld()->getStore().overrideRecord(copy); } } diff --git a/apps/openmw/mwmechanics/spelllist.cpp b/apps/openmw/mwmechanics/spelllist.cpp index 08fad5129f..4a7a29bc07 100644 --- a/apps/openmw/mwmechanics/spelllist.cpp +++ b/apps/openmw/mwmechanics/spelllist.cpp @@ -27,7 +27,7 @@ namespace T copy = *MWBase::Environment::get().getWorld()->getStore().get().find(id); bool changed = function(copy.mSpells.mList); if (changed) - MWBase::Environment::get().getWorld()->createOverrideRecord(copy); + MWBase::Environment::get().getWorld()->getStore().overrideRecord(copy); return changed; } } diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 5b819a0f6a..7d436713e0 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -1506,7 +1506,7 @@ namespace MWScript ESM::CreatureLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get().find(levId); addToLevList(&listCopy, creatureId, level); - MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy); + MWBase::Environment::get().getWorld()->getStore().overrideRecord(listCopy); } }; @@ -1525,7 +1525,7 @@ namespace MWScript ESM::CreatureLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get().find(levId); removeFromLevList(&listCopy, creatureId, level); - MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy); + MWBase::Environment::get().getWorld()->getStore().overrideRecord(listCopy); } }; @@ -1544,7 +1544,7 @@ namespace MWScript ESM::ItemLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get().find(levId); addToLevList(&listCopy, itemId, level); - MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy); + MWBase::Environment::get().getWorld()->getStore().overrideRecord(listCopy); } }; @@ -1563,7 +1563,7 @@ namespace MWScript ESM::ItemLevList listCopy = *MWBase::Environment::get().getWorld()->getStore().get().find(levId); removeFromLevList(&listCopy, itemId, level); - MWBase::Environment::get().getWorld()->createOverrideRecord(listCopy); + MWBase::Environment::get().getWorld()->getStore().overrideRecord(listCopy); } }; diff --git a/apps/openmw/mwsound/regionsoundselector.cpp b/apps/openmw/mwsound/regionsoundselector.cpp index ba876c4fe7..65ac7d0c6f 100644 --- a/apps/openmw/mwsound/regionsoundselector.cpp +++ b/apps/openmw/mwsound/regionsoundselector.cpp @@ -7,6 +7,7 @@ #include #include +#include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwworld/esmstore.hpp" @@ -26,8 +27,7 @@ namespace MWSound { } - std::optional RegionSoundSelector::getNextRandom( - float duration, const ESM::RefId& regionName, const MWBase::World& world) + std::optional RegionSoundSelector::getNextRandom(float duration, const ESM::RefId& regionName) { mTimePassed += duration; @@ -44,7 +44,8 @@ namespace MWSound mSumChance = 0; } - const ESM::Region* const region = world.getStore().get().search(mLastRegionName); + const ESM::Region* const region + = MWBase::Environment::get().getWorld()->getStore().get().search(mLastRegionName); if (region == nullptr) return {}; diff --git a/apps/openmw/mwsound/regionsoundselector.hpp b/apps/openmw/mwsound/regionsoundselector.hpp index ee26bee97b..1a9e6e450b 100644 --- a/apps/openmw/mwsound/regionsoundselector.hpp +++ b/apps/openmw/mwsound/regionsoundselector.hpp @@ -15,8 +15,7 @@ namespace MWSound class RegionSoundSelector { public: - std::optional getNextRandom( - float duration, const ESM::RefId& regionName, const MWBase::World& world); + std::optional getNextRandom(float duration, const ESM::RefId& regionName); RegionSoundSelector(); diff --git a/apps/openmw/mwsound/sound_buffer.cpp b/apps/openmw/mwsound/sound_buffer.cpp index db24b3c45d..17ec516882 100644 --- a/apps/openmw/mwsound/sound_buffer.cpp +++ b/apps/openmw/mwsound/sound_buffer.cpp @@ -24,9 +24,8 @@ namespace MWSound float mAudioMaxDistanceMult; }; - AudioParams makeAudioParams(const MWBase::World& world) + AudioParams makeAudioParams(const MWWorld::Store& settings) { - const auto& settings = world.getStore().get(); AudioParams params; params.mAudioDefaultMinDistance = settings.find("fAudioDefaultMinDistance")->mValue.getFloat(); params.mAudioDefaultMaxDistance = settings.find("fAudioDefaultMaxDistance")->mValue.getFloat(); @@ -119,7 +118,8 @@ namespace MWSound Sound_Buffer* SoundBufferPool::insertSound(const ESM::RefId& soundId, const ESM::Sound& sound) { - static const AudioParams audioParams = makeAudioParams(*MWBase::Environment::get().getWorld()); + static const AudioParams audioParams + = makeAudioParams(MWBase::Environment::get().getWorld()->getStore().get()); float volume = static_cast(std::pow(10.0, (sound.mData.mVolume / 255.0 * 3348.0 - 3348.0) / 2000.0)); float min = sound.mData.mMinRange; diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 2f7b38aad9..bb9931db33 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -773,7 +773,7 @@ namespace MWSound if (mCurrentRegionSound && mOutput->isSoundPlaying(mCurrentRegionSound)) return; - if (const auto next = mRegionSoundSelector.getNextRandom(duration, cell->getRegion(), *world)) + if (const auto next = mRegionSoundSelector.getNextRandom(duration, cell->getRegion())) mCurrentRegionSound = playSound(*next, 1.0f, 1.0f); } diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 4ad9b6eab2..004c456ff1 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -197,6 +197,7 @@ namespace MWWorld } /// Insert a custom record (i.e. with a generated ID that will not clash will pre-existing records) + /// \return pointer to created record template const T* insert(const T& x) { diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index b497da690d..8c7070b588 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -389,8 +389,8 @@ void MWWorld::InventoryStore::autoEquipArmor(TSlots& slots_) return; } - const MWBase::World* world = MWBase::Environment::get().getWorld(); - const MWWorld::Store& store = world->getStore().get(); + const MWWorld::Store& store + = MWBase::Environment::get().getWorld()->getStore().get(); static float fUnarmoredBase1 = store.find("fUnarmoredBase1")->mValue.getFloat(); static float fUnarmoredBase2 = store.find("fUnarmoredBase2")->mValue.getFloat(); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 250dd97b97..82cdd095e2 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -599,11 +599,6 @@ namespace MWWorld return mESMVersions; } - const MWWorld::ESMStore& World::getStore() const - { - return mStore; - } - LocalScripts& World::getLocalScripts() { return mLocalScripts; @@ -1721,95 +1716,6 @@ namespace MWWorld } } - const ESM::Potion* World::createRecord(const ESM::Potion& record) - { - return mStore.insert(record); - } - - const ESM::Class* World::createRecord(const ESM::Class& record) - { - return mStore.insert(record); - } - - const ESM::Spell* World::createRecord(const ESM::Spell& record) - { - return mStore.insert(record); - } - - const ESM::Cell* World::createRecord(const ESM::Cell& record) - { - return mStore.insert(record); - } - - const ESM::CreatureLevList* World::createOverrideRecord(const ESM::CreatureLevList& record) - { - return mStore.overrideRecord(record); - } - - const ESM::ItemLevList* World::createOverrideRecord(const ESM::ItemLevList& record) - { - return mStore.overrideRecord(record); - } - - const ESM::Creature* World::createOverrideRecord(const ESM::Creature& record) - { - return mStore.overrideRecord(record); - } - - const ESM::NPC* World::createOverrideRecord(const ESM::NPC& record) - { - return mStore.overrideRecord(record); - } - - const ESM::Container* World::createOverrideRecord(const ESM::Container& record) - { - return mStore.overrideRecord(record); - } - - const ESM::NPC* World::createRecord(const ESM::NPC& record) - { - bool update = false; - - if (record.mId == "Player") - { - const ESM::NPC* player = mPlayer->getPlayer().get()->mBase; - - update = record.isMale() != player->isMale() || !(record.mRace == player->mRace) - || !(record.mHead == player->mHead) || !(record.mHair == player->mHair); - } - const ESM::NPC* ret = mStore.insert(record); - if (update) - { - renderPlayer(); - } - return ret; - } - - const ESM::Armor* World::createRecord(const ESM::Armor& record) - { - return mStore.insert(record); - } - - const ESM::Weapon* World::createRecord(const ESM::Weapon& record) - { - return mStore.insert(record); - } - - const ESM::Clothing* World::createRecord(const ESM::Clothing& record) - { - return mStore.insert(record); - } - - const ESM::Enchantment* World::createRecord(const ESM::Enchantment& record) - { - return mStore.insert(record); - } - - const ESM::Book* World::createRecord(const ESM::Book& record) - { - return mStore.insert(record); - } - void World::update(float duration, bool paused) { if (mGoToJail && !paused) @@ -3211,7 +3117,7 @@ namespace MWWorld { if (playing.insert(effect.mEffectId).second) { - const auto magicEffect = getStore().get().find(effect.mEffectId); + const auto magicEffect = mStore.get().find(effect.mEffectId); if (magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx) MWMechanics::playEffects(ptr, *magicEffect, false); } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 47ed94bdfa..a236a7ed45 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -235,7 +235,7 @@ namespace MWWorld MWWorld::Ptr getPlayerPtr() override; MWWorld::ConstPtr getPlayerConstPtr() const override; - const MWWorld::ESMStore& getStore() const override; + MWWorld::ESMStore& getStore() override { return mStore; } const std::vector& getESMVersions() const override; @@ -428,66 +428,6 @@ namespace MWWorld ///< Toggle a render mode. ///< \return Resulting mode - const ESM::Potion* createRecord(const ESM::Potion& record) override; - ///< Create a new record (of type potion) in the ESM store. - /// \return pointer to created record - - const ESM::Spell* createRecord(const ESM::Spell& record) override; - ///< Create a new record (of type spell) in the ESM store. - /// \return pointer to created record - - const ESM::Class* createRecord(const ESM::Class& record) override; - ///< Create a new record (of type class) in the ESM store. - /// \return pointer to created record - - const ESM::Cell* createRecord(const ESM::Cell& record) override; - ///< Create a new record (of type cell) in the ESM store. - /// \return pointer to created record - - const ESM::NPC* createRecord(const ESM::NPC& record) override; - ///< Create a new record (of type npc) in the ESM store. - /// \return pointer to created record - - const ESM::Armor* createRecord(const ESM::Armor& record) override; - ///< Create a new record (of type armor) in the ESM store. - /// \return pointer to created record - - const ESM::Weapon* createRecord(const ESM::Weapon& record) override; - ///< Create a new record (of type weapon) in the ESM store. - /// \return pointer to created record - - const ESM::Clothing* createRecord(const ESM::Clothing& record) override; - ///< Create a new record (of type clothing) in the ESM store. - /// \return pointer to created record - - const ESM::Enchantment* createRecord(const ESM::Enchantment& record) override; - ///< Create a new record (of type enchantment) in the ESM store. - /// \return pointer to created record - - const ESM::Book* createRecord(const ESM::Book& record) override; - ///< Create a new record (of type book) in the ESM store. - /// \return pointer to created record - - const ESM::CreatureLevList* createOverrideRecord(const ESM::CreatureLevList& record) override; - ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. - /// \return pointer to created record - - const ESM::ItemLevList* createOverrideRecord(const ESM::ItemLevList& record) override; - ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. - /// \return pointer to created record - - const ESM::Creature* createOverrideRecord(const ESM::Creature& record) override; - ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. - /// \return pointer to created record - - const ESM::NPC* createOverrideRecord(const ESM::NPC& record) override; - ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. - /// \return pointer to created record - - const ESM::Container* createOverrideRecord(const ESM::Container& record) override; - ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. - /// \return pointer to created record - void update(float duration, bool paused); void updatePhysics( float duration, bool paused, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats); diff --git a/apps/openmw/mwworld/worldmodel.cpp b/apps/openmw/mwworld/worldmodel.cpp index 84bee5bbde..87f112238a 100644 --- a/apps/openmw/mwworld/worldmodel.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -179,7 +179,7 @@ MWWorld::CellStore& MWWorld::WorldModel::getExterior(int x, int y) record.mMapColor = 0; record.updateId(); - cell = MWBase::Environment::get().getWorld()->createRecord(record); + cell = MWBase::Environment::get().getWorld()->getStore().insert(record); } CellStore* cellStore From f1beaa7b8cca6e55f050ca645b92861408b8b6dc Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Thu, 20 Apr 2023 21:07:53 +0200 Subject: [PATCH 2/2] Put ESMStore to Environment --- apps/openmw/engine.cpp | 1 + apps/openmw/mwbase/environment.hpp | 4 ++ apps/openmw/mwclass/activator.cpp | 4 +- apps/openmw/mwclass/armor.cpp | 11 ++-- apps/openmw/mwclass/book.cpp | 4 +- apps/openmw/mwclass/clothing.cpp | 4 +- apps/openmw/mwclass/container.cpp | 2 +- apps/openmw/mwclass/creature.cpp | 10 +-- apps/openmw/mwclass/creaturelevlist.cpp | 6 +- apps/openmw/mwclass/door.cpp | 2 +- apps/openmw/mwclass/ingredient.cpp | 5 +- apps/openmw/mwclass/misc.cpp | 4 +- apps/openmw/mwclass/npc.cpp | 66 ++++++++----------- apps/openmw/mwclass/weapon.cpp | 4 +- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 32 ++++----- apps/openmw/mwdialogue/filter.cpp | 9 +-- apps/openmw/mwdialogue/hypertextparser.cpp | 2 +- apps/openmw/mwdialogue/journalentry.cpp | 6 +- apps/openmw/mwdialogue/journalimp.cpp | 2 +- apps/openmw/mwdialogue/quest.cpp | 5 +- apps/openmw/mwdialogue/scripttest.cpp | 2 +- apps/openmw/mwdialogue/topic.cpp | 3 +- apps/openmw/mwgui/alchemywindow.cpp | 2 +- apps/openmw/mwgui/birth.cpp | 5 +- apps/openmw/mwgui/charactercreation.cpp | 5 +- apps/openmw/mwgui/class.cpp | 6 +- apps/openmw/mwgui/console.cpp | 2 +- apps/openmw/mwgui/dialogue.cpp | 14 ++-- apps/openmw/mwgui/enchantingdialog.cpp | 5 +- apps/openmw/mwgui/hud.cpp | 14 ++-- apps/openmw/mwgui/itemchargeview.cpp | 2 +- apps/openmw/mwgui/jailscreen.cpp | 2 +- apps/openmw/mwgui/mapwindow.cpp | 4 +- apps/openmw/mwgui/merchantrepair.cpp | 12 +--- apps/openmw/mwgui/quickkeysmenu.cpp | 4 +- apps/openmw/mwgui/race.cpp | 9 ++- apps/openmw/mwgui/recharge.cpp | 3 +- apps/openmw/mwgui/review.cpp | 14 ++-- apps/openmw/mwgui/savegamedialog.cpp | 3 +- apps/openmw/mwgui/sortfilteritemmodel.cpp | 9 ++- apps/openmw/mwgui/spellbuyingwindow.cpp | 4 +- apps/openmw/mwgui/spellcreationdialog.cpp | 29 ++++---- apps/openmw/mwgui/spellicons.cpp | 7 +- apps/openmw/mwgui/spellmodel.cpp | 4 +- apps/openmw/mwgui/spellwindow.cpp | 7 +- apps/openmw/mwgui/statswatcher.cpp | 9 ++- apps/openmw/mwgui/statswindow.cpp | 11 ++-- apps/openmw/mwgui/tooltips.cpp | 17 +++-- apps/openmw/mwgui/tradewindow.cpp | 2 +- apps/openmw/mwgui/trainingwindow.cpp | 6 +- apps/openmw/mwgui/travelwindow.cpp | 7 +- apps/openmw/mwgui/waitdialog.cpp | 2 +- apps/openmw/mwgui/widgets.cpp | 6 +- apps/openmw/mwlua/luabindings.cpp | 7 +- apps/openmw/mwlua/luamanagerimp.cpp | 2 +- apps/openmw/mwlua/stats.cpp | 2 +- apps/openmw/mwlua/types/misc.cpp | 2 +- apps/openmw/mwlua/types/types.hpp | 2 +- apps/openmw/mwmechanics/activespells.cpp | 5 +- apps/openmw/mwmechanics/actors.cpp | 30 ++++----- apps/openmw/mwmechanics/aibreathe.cpp | 8 +-- apps/openmw/mwmechanics/aicombat.cpp | 11 ++-- apps/openmw/mwmechanics/aicombataction.cpp | 46 ++++++------- apps/openmw/mwmechanics/aiwander.cpp | 7 +- apps/openmw/mwmechanics/alchemy.cpp | 42 +++++------- apps/openmw/mwmechanics/autocalcspell.cpp | 20 +++--- apps/openmw/mwmechanics/combat.cpp | 40 +++++------ apps/openmw/mwmechanics/creaturestats.cpp | 2 +- apps/openmw/mwmechanics/difficultyscaling.cpp | 8 +-- apps/openmw/mwmechanics/disease.hpp | 10 ++- apps/openmw/mwmechanics/enchanting.cpp | 22 +++---- apps/openmw/mwmechanics/inventory.hpp | 6 +- apps/openmw/mwmechanics/levelledlist.cpp | 4 +- apps/openmw/mwmechanics/magiceffects.cpp | 2 +- .../mwmechanics/mechanicsmanagerimp.cpp | 30 ++++----- apps/openmw/mwmechanics/npcstats.cpp | 32 ++++----- apps/openmw/mwmechanics/pickpocket.cpp | 15 ++--- apps/openmw/mwmechanics/recharge.cpp | 15 ++--- apps/openmw/mwmechanics/repair.cpp | 10 ++- apps/openmw/mwmechanics/security.cpp | 12 ++-- apps/openmw/mwmechanics/setbaseaisetting.hpp | 4 +- apps/openmw/mwmechanics/spellcasting.cpp | 16 ++--- apps/openmw/mwmechanics/spelleffects.cpp | 9 ++- apps/openmw/mwmechanics/spelllist.cpp | 8 +-- apps/openmw/mwmechanics/spellpriority.cpp | 20 +++--- apps/openmw/mwmechanics/spellresistance.cpp | 3 +- apps/openmw/mwmechanics/spells.cpp | 14 ++-- apps/openmw/mwmechanics/spellutil.cpp | 13 ++-- apps/openmw/mwmechanics/summoning.cpp | 8 +-- apps/openmw/mwmechanics/trading.cpp | 2 +- apps/openmw/mwmechanics/weaponpriority.cpp | 2 +- apps/openmw/mwphysics/movementsolver.cpp | 5 +- apps/openmw/mwphysics/physicssystem.cpp | 9 ++- apps/openmw/mwrender/actoranimation.cpp | 2 +- apps/openmw/mwrender/animation.cpp | 2 +- apps/openmw/mwrender/globalmap.cpp | 2 +- apps/openmw/mwrender/npcanimation.cpp | 8 +-- apps/openmw/mwrender/terrainstorage.cpp | 6 +- apps/openmw/mwrender/weaponanimation.cpp | 2 +- apps/openmw/mwscript/aiextensions.cpp | 2 +- apps/openmw/mwscript/compilercontext.cpp | 7 +- apps/openmw/mwscript/containerextensions.cpp | 14 ++-- apps/openmw/mwscript/guiextensions.cpp | 6 +- apps/openmw/mwscript/interpretercontext.cpp | 15 ++--- apps/openmw/mwscript/locals.cpp | 3 +- apps/openmw/mwscript/miscextensions.cpp | 28 ++++---- apps/openmw/mwscript/skyextensions.cpp | 3 +- apps/openmw/mwscript/statsextensions.cpp | 12 ++-- .../mwscript/transformationextensions.cpp | 6 +- apps/openmw/mwsound/regionsoundselector.cpp | 2 +- apps/openmw/mwsound/sound_buffer.cpp | 7 +- apps/openmw/mwworld/actionread.cpp | 2 +- apps/openmw/mwworld/actionsoulgem.cpp | 2 +- apps/openmw/mwworld/cellref.cpp | 3 +- apps/openmw/mwworld/cellstore.cpp | 18 +++-- apps/openmw/mwworld/class.cpp | 9 ++- apps/openmw/mwworld/containerstore.cpp | 17 +++-- apps/openmw/mwworld/inventorystore.cpp | 3 +- apps/openmw/mwworld/livecellref.cpp | 4 +- apps/openmw/mwworld/magiceffects.cpp | 4 +- apps/openmw/mwworld/player.cpp | 4 +- apps/openmw/mwworld/projectilemanager.cpp | 29 ++++---- apps/openmw/mwworld/worldmodel.cpp | 2 +- 123 files changed, 499 insertions(+), 644 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index adef6d62ea..3b90f60a0b 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -776,6 +776,7 @@ void OMW::Engine::prepareEngine() mEnvironment.setWorld(*mWorld); mEnvironment.setWorldModel(mWorld->getWorldModel()); mEnvironment.setWorldScene(mWorld->getWorldScene()); + mEnvironment.setESMStore(mWorld->getStore()); const MWWorld::Store* gmst = &mWorld->getStore().get(); mL10nManager->setGmstLoader( diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index bb0257bd97..aa8a41b7c1 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -17,6 +17,7 @@ namespace l10n namespace MWWorld { + class ESMStore; class WorldModel; class Scene; } @@ -45,6 +46,7 @@ namespace MWBase World* mWorld = nullptr; MWWorld::WorldModel* mWorldModel = nullptr; MWWorld::Scene* mWorldScene = nullptr; + MWWorld::ESMStore* mESMStore = nullptr; SoundManager* mSoundManager = nullptr; ScriptManager* mScriptManager = nullptr; WindowManager* mWindowManager = nullptr; @@ -71,6 +73,7 @@ namespace MWBase void setWorld(World& value) { mWorld = &value; } void setWorldModel(MWWorld::WorldModel& value) { mWorldModel = &value; } void setWorldScene(MWWorld::Scene& value) { mWorldScene = &value; } + void setESMStore(MWWorld::ESMStore& value) { mESMStore = &value; } void setSoundManager(SoundManager& value) { mSoundManager = &value; } @@ -97,6 +100,7 @@ namespace MWBase Misc::NotNullPtr getWorld() const { return mWorld; } Misc::NotNullPtr getWorldModel() const { return mWorldModel; } Misc::NotNullPtr getWorldScene() const { return mWorldScene; } + Misc::NotNullPtr getESMStore() const { return mESMStore; } Misc::NotNullPtr getSoundManager() const { return mSoundManager; } diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 4922bb21d1..09578b8345 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -120,7 +120,7 @@ namespace MWClass { if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound* sound = store.get().searchRandom("WolfActivator", prng); @@ -144,7 +144,7 @@ namespace MWClass { const std::string model = getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::RefId* creatureId = nullptr; const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 2b32d06bc7..12954e29d7 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -153,7 +153,7 @@ namespace MWClass return -1; const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); float iWeight = floor(gmst.find(typeGmst)->mValue.getFloat()); @@ -289,7 +289,7 @@ namespace MWClass newItem.mName = newName; newItem.mData.mEnchant = enchCharge; newItem.mEnchant = enchId; - const ESM::Armor* record = MWBase::Environment::get().getWorld()->getStore().insert(newItem); + const ESM::Armor* record = MWBase::Environment::get().getESMStore()->insert(newItem); return record->mId; } @@ -301,9 +301,8 @@ namespace MWClass float armorSkill = actor.getClass().getSkill(actor, armorSkillType); int iBaseArmorSkill = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iBaseArmorSkill") ->mValue.getInteger(); @@ -331,7 +330,7 @@ namespace MWClass const ESM::RefId& npcRace = npc.get()->mBase->mRace; // Beast races cannot equip shoes / boots, or full helms (head part vs hair part) - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(npcRace); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(npcRace); if (race->mData.mFlags & ESM::Race::Beast) { std::vector parts = ptr.get()->mBase->mParts.mParts; diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 8b71463505..0a32d3acbf 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -58,7 +58,7 @@ namespace MWClass { if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound* sound = store.get().searchRandom("WolfItem", prng); @@ -151,7 +151,7 @@ namespace MWClass newItem.mData.mIsScroll = 1; newItem.mData.mEnchant = enchCharge; newItem.mEnchant = enchId; - const ESM::Book* record = MWBase::Environment::get().getWorld()->getStore().insert(newItem); + const ESM::Book* record = MWBase::Environment::get().getESMStore()->insert(newItem); return record->mId; } diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 17d5c443df..b3c58443f0 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -196,7 +196,7 @@ namespace MWClass newItem.mName = newName; newItem.mData.mEnchant = enchCharge; newItem.mEnchant = enchId; - const ESM::Clothing* record = MWBase::Environment::get().getWorld()->getStore().insert(newItem); + const ESM::Clothing* record = MWBase::Environment::get().getESMStore()->insert(newItem); return record->mId; } @@ -214,7 +214,7 @@ namespace MWClass const ESM::RefId& npcRace = npc.get()->mBase->mRace; // Beast races cannot equip shoes / boots, or full helms (head part vs hair part) - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(npcRace); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(npcRace); if (race->mData.mFlags & ESM::Race::Beast) { std::vector parts = ptr.get()->mBase->mParts.mParts; diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 47260c3ba4..13a7406c21 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -141,7 +141,7 @@ namespace MWClass if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound* sound = store.get().searchRandom("WolfContainer", prng); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 7723cf36ae..e1cff1b201 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -92,7 +92,7 @@ namespace MWClass GMST gmst; const MWWorld::Store& store - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); gmst.fMinWalkSpeedCreature = store.find("fMinWalkSpeedCreature"); gmst.fMaxWalkSpeedCreature = store.find("fMaxWalkSpeedCreature"); @@ -469,7 +469,7 @@ namespace MWClass { if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound* sound = store.get().searchRandom("WolfCreature", prng); @@ -647,7 +647,7 @@ namespace MWClass const ESM::RefId& ourId = (ref->mBase->mOriginal.empty()) ? ptr.getCellRef().getRefId() : ref->mBase->mOriginal; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); auto sound = store.get().begin(); while (sound != store.get().end()) { @@ -766,7 +766,7 @@ namespace MWClass { MWWorld::LiveCellRef* ref = ptr.get(); - const ESM::Skill* skillRecord = MWBase::Environment::get().getWorld()->getStore().get().find(skill); + const ESM::Skill* skillRecord = MWBase::Environment::get().getESMStore()->get().find(skill); switch (skillRecord->mData.mSpecialization) { @@ -862,7 +862,7 @@ namespace MWClass return; const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fCorpseRespawnDelay = gmst.find("fCorpseRespawnDelay")->mValue.getFloat(); static const float fCorpseClearDelay = gmst.find("fCorpseClearDelay")->mValue.getFloat(); diff --git a/apps/openmw/mwclass/creaturelevlist.cpp b/apps/openmw/mwclass/creaturelevlist.cpp index 464a1acfa0..dd346306e9 100644 --- a/apps/openmw/mwclass/creaturelevlist.cpp +++ b/apps/openmw/mwclass/creaturelevlist.cpp @@ -86,7 +86,7 @@ namespace MWClass else if (creatureStats.isDead()) { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fCorpseRespawnDelay = gmst.find("fCorpseRespawnDelay")->mValue.getFloat(); static const float fCorpseClearDelay = gmst.find("fCorpseClearDelay")->mValue.getFloat(); @@ -111,7 +111,7 @@ namespace MWClass if (it->mLevel > player.getClass().getCreatureStats(player).getLevel()) continue; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); MWWorld::ManualRef ref(store, it->mId); ref.getPtr().getClass().getModelsToPreload(ref.getPtr(), models); } @@ -127,7 +127,7 @@ namespace MWClass if (!customData.mSpawn) return; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::RefId& id = MWMechanics::getLevelledItem( store.get().find(ptr.getCellRef().getRefId()), true, prng); diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 089d4b18f4..f848b2c311 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -133,7 +133,7 @@ namespace MWClass MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); if (animation) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::MagicEffect* effect = store.get().find(ESM::MagicEffect::Telekinesis); animation->addSpellCastGlow( diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 7fab60392a..81f26430ef 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -126,9 +126,8 @@ namespace MWClass float alchemySkill = player.getClass().getSkill(player, ESM::Skill::Alchemy); static const float fWortChanceValue = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fWortChanceValue") ->mValue.getFloat(); diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 51a4241cbf..83a903387e 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -86,7 +86,7 @@ namespace MWClass if (!ptr.getCellRef().getSoul().empty()) { const ESM::Creature* creature - = MWBase::Environment::get().getWorld()->getStore().get().search(ref->mRef.getSoul()); + = MWBase::Environment::get().getESMStore()->get().search(ref->mRef.getSoul()); if (creature) { int soul = creature->mData.mSoul; @@ -177,7 +177,7 @@ namespace MWClass { MWWorld::Ptr newPtr; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); if (isGold(ptr)) { diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index ebc11c623a..55739256dd 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -84,7 +84,7 @@ namespace void autoCalculateAttributes(const ESM::NPC* npc, MWMechanics::CreatureStats& creatureStats) { // race bonus - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(npc->mRace); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(npc->mRace); bool male = (npc->mFlags & ESM::NPC::Female) == 0; @@ -96,8 +96,7 @@ namespace } // class bonus - const ESM::Class* class_ - = MWBase::Environment::get().getWorld()->getStore().get().find(npc->mClass); + const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); for (int i = 0; i < 2; ++i) { @@ -115,7 +114,7 @@ namespace for (int j = 0; j < ESM::Skill::Length; ++j) { - const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get().find(j); + const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get().find(j); if (skill->mData.mAttribute != attribute) continue; @@ -174,12 +173,11 @@ namespace void autoCalculateSkills( const ESM::NPC* npc, MWMechanics::NpcStats& npcStats, const MWWorld::Ptr& ptr, bool spellsInitialised) { - const ESM::Class* class_ - = MWBase::Environment::get().getWorld()->getStore().get().find(npc->mClass); + const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); unsigned int level = npcStats.getLevel(); - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(npc->mRace); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(npc->mRace); for (int i = 0; i < 2; ++i) { @@ -223,8 +221,7 @@ namespace } // is this skill in the same Specialization as the class? - const ESM::Skill* skill - = MWBase::Environment::get().getWorld()->getStore().get().find(skillIndex); + const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get().find(skillIndex); if (skill->mData.mSpecialization == class_->mData.mSpecialization) { specMultiplier = 0.5f; @@ -277,7 +274,7 @@ namespace MWClass GMST gmst; const MWWorld::Store& store - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); gmst.fMinWalkSpeed = store.find("fMinWalkSpeed"); gmst.fMaxWalkSpeed = store.find("fMaxWalkSpeed"); @@ -367,22 +364,19 @@ namespace MWClass data->mNpcStats.setDeathAnimationFinished(isPersistent(ptr)); // race powers - const ESM::Race* race - = MWBase::Environment::get().getWorld()->getStore().get().find(ref->mBase->mRace); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(ref->mBase->mRace); data->mNpcStats.getSpells().addAllToInstance(race->mPowers.mList); if (!ref->mBase->mFaction.empty()) { static const int iAutoRepFacMod = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iAutoRepFacMod") ->mValue.getInteger(); static const int iAutoRepLevMod = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iAutoRepLevMod") ->mValue.getInteger(); int rank = ref->mBase->getFactionRank(); @@ -435,8 +429,7 @@ namespace MWClass const MWWorld::LiveCellRef* ref = ptr.get(); std::string model = Settings::Manager::getString("baseanim", "Models"); - const ESM::Race* race - = MWBase::Environment::get().getWorld()->getStore().get().find(ref->mBase->mRace); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(ref->mBase->mRace); if (race->mData.mFlags & ESM::Race::Beast) model = Settings::Manager::getString("baseanimkna", "Models"); @@ -446,8 +439,7 @@ namespace MWClass void Npc::getModelsToPreload(const MWWorld::Ptr& ptr, std::vector& models) const { const MWWorld::LiveCellRef* npc = ptr.get(); - const ESM::Race* race - = MWBase::Environment::get().getWorld()->getStore().get().search(npc->mBase->mRace); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().search(npc->mBase->mRace); if (race && race->mData.mFlags & ESM::Race::Beast) models.emplace_back(Settings::Manager::getString("baseanimkna", "Models")); @@ -464,14 +456,14 @@ namespace MWClass if (!npc->mBase->mHead.empty()) { const ESM::BodyPart* head - = MWBase::Environment::get().getWorld()->getStore().get().search(npc->mBase->mHead); + = MWBase::Environment::get().getESMStore()->get().search(npc->mBase->mHead); if (head) models.push_back(Misc::ResourceHelpers::correctMeshPath(head->mModel, vfs)); } if (!npc->mBase->mHair.empty()) { const ESM::BodyPart* hair - = MWBase::Environment::get().getWorld()->getStore().get().search(npc->mBase->mHair); + = MWBase::Environment::get().getESMStore()->get().search(npc->mBase->mHair); if (hair) models.push_back(Misc::ResourceHelpers::correctMeshPath(hair->mModel, vfs)); } @@ -510,7 +502,7 @@ namespace MWClass = (female && !it->mFemale.empty()) || (!female && it->mMale.empty()) ? it->mFemale : it->mMale; const ESM::BodyPart* part - = MWBase::Environment::get().getWorld()->getStore().get().search(partname); + = MWBase::Environment::get().getESMStore()->get().search(partname); if (part && !part->mModel.empty()) models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel, vfs)); } @@ -537,7 +529,7 @@ namespace MWClass && ptr.getRefData().getCustomData()->asNpcCustomData().mNpcStats.isWerewolf()) { const MWWorld::Store& store - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); return store.find("sWerewolfPopup")->mValue.getString(); } @@ -784,7 +776,7 @@ namespace MWClass // 'ptr' is losing health. Play a 'hit' voiced dialog entry if not already saying // something, alert the character controller, scripts, etc. - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const GMST& gmst = getGmst(); int chance = store.get().find("iVoiceHitOdds")->mValue.getInteger(); @@ -932,7 +924,7 @@ namespace MWClass // Werewolfs can't activate NPCs if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound* sound = store.get().searchRandom("WolfNPC", prng); @@ -1153,9 +1145,8 @@ namespace MWClass { const MWMechanics::CreatureStats& stats = getCreatureStats(ptr); static const float fEncumbranceStrMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fEncumbranceStrMult") ->mValue.getFloat(); return stats.getAttribute(ESM::Attribute::Strength).getModified() * fEncumbranceStrMult; @@ -1187,8 +1178,7 @@ namespace MWClass MWWorld::LiveCellRef* ref = ptr.get(); - const ESM::Class* class_ - = MWBase::Environment::get().getWorld()->getStore().get().find(ref->mBase->mClass); + const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get().find(ref->mBase->mClass); stats.useSkill(skill, *class_, usageType, extraFactor); } @@ -1196,7 +1186,7 @@ namespace MWClass float Npc::getArmorRating(const MWWorld::Ptr& ptr) const { const MWWorld::Store& store - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); MWMechanics::NpcStats& stats = getNpcStats(ptr); const MWWorld::InventoryStore& invStore = getInventoryStore(ptr); @@ -1249,8 +1239,7 @@ namespace MWClass const MWWorld::LiveCellRef* ref = ptr.get(); - const ESM::Race* race - = MWBase::Environment::get().getWorld()->getStore().get().find(ref->mBase->mRace); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(ref->mBase->mRace); // Race weight should not affect 1st-person meshes, otherwise it will change hand proportions and can break // aiming. @@ -1283,8 +1272,7 @@ namespace MWClass const ESM::NPC* npc = actor.get()->mBase; if (npc->mFlags & ESM::NPC::Autocalc) { - const ESM::Class* class_ - = MWBase::Environment::get().getWorld()->getStore().get().find(npc->mClass); + const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); return class_->mData.mServices; } return npc->mAiData.mServices; @@ -1470,7 +1458,7 @@ namespace MWClass return; const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fCorpseRespawnDelay = gmst.find("fCorpseRespawnDelay")->mValue.getFloat(); static const float fCorpseClearDelay = gmst.find("fCorpseClearDelay")->mValue.getFloat(); diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 8dffba0fde..320d979fc7 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -155,7 +155,7 @@ namespace MWClass = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count); info.icon = ref->mBase->mIcon; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); std::string text; @@ -269,7 +269,7 @@ namespace MWClass newItem.mData.mEnchant = enchCharge; newItem.mEnchant = enchId; newItem.mData.mFlags |= ESM::Weapon::Magical; - const ESM::Weapon* record = MWBase::Environment::get().getWorld()->getStore().insert(newItem); + const ESM::Weapon* record = MWBase::Environment::get().getESMStore()->insert(newItem); return record->mId; } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index c0e506ebf2..bb06a53b35 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -155,8 +155,7 @@ namespace MWDialogue mActorKnownTopics.clear(); // greeting - const MWWorld::Store& dialogs - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& dialogs = MWBase::Environment::get().getESMStore()->get(); Filter filter(actor, mChoice, mTalkedTo); @@ -288,8 +287,7 @@ namespace MWDialogue { Filter filter(mActor, mChoice, mTalkedTo); - const MWWorld::Store& dialogues - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& dialogues = MWBase::Environment::get().getESMStore()->get(); const ESM::Dialogue& dialogue = *dialogues.find(topic); @@ -308,7 +306,7 @@ namespace MWDialogue modifiedTopic.erase(std::remove(modifiedTopic.begin(), modifiedTopic.end(), ' '), modifiedTopic.end()); const MWWorld::Store& gmsts - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); title = gmsts.find(modifiedTopic)->mValue.getString(); } @@ -343,7 +341,7 @@ namespace MWDialogue const ESM::Dialogue* DialogueManager::searchDialogue(const ESM::RefId& id) { - return MWBase::Environment::get().getWorld()->getStore().get().search(id); + return MWBase::Environment::get().getESMStore()->get().search(id); } void DialogueManager::updateGlobals() @@ -357,7 +355,7 @@ namespace MWDialogue mActorKnownTopics.clear(); - const auto& dialogs = MWBase::Environment::get().getWorld()->getStore().get(); + const auto& dialogs = MWBase::Environment::get().getESMStore()->get(); Filter filter(mActor, -1, mTalkedTo); @@ -607,8 +605,7 @@ namespace MWDialogue { Filter filter(mActor, service, mTalkedTo); - const MWWorld::Store& dialogues - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& dialogues = MWBase::Environment::get().getESMStore()->get(); const ESM::Dialogue& dialogue = *dialogues.find(ESM::RefId::stringRefId("Service Refusal")); @@ -620,7 +617,7 @@ namespace MWDialogue addTopicsFromText(info->mResponse); const MWWorld::Store& gmsts - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor); @@ -654,7 +651,7 @@ namespace MWDialogue return; } - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::Dialogue* dial = store.get().find(topic); const MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor); @@ -695,7 +692,7 @@ namespace MWDialogue { if (type == ESM::REC_DIAS) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); ESM::DialogueState state; state.load(reader); @@ -712,8 +709,8 @@ namespace MWDialogue void DialogueManager::modFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int diff) { // Make sure the factions exist - MWBase::Environment::get().getWorld()->getStore().get().find(faction1); - MWBase::Environment::get().getWorld()->getStore().get().find(faction2); + MWBase::Environment::get().getESMStore()->get().find(faction1); + MWBase::Environment::get().getESMStore()->get().find(faction2); int newValue = getFactionReaction(faction1, faction2) + diff; @@ -724,8 +721,8 @@ namespace MWDialogue void DialogueManager::setFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int absolute) { // Make sure the factions exist - MWBase::Environment::get().getWorld()->getStore().get().find(faction1); - MWBase::Environment::get().getWorld()->getStore().get().find(faction2); + MWBase::Environment::get().getESMStore()->get().find(faction1); + MWBase::Environment::get().getESMStore()->get().find(faction2); auto& map = mChangedFactionReaction[faction1]; map[faction2] = absolute; @@ -737,8 +734,7 @@ namespace MWDialogue if (map != mChangedFactionReaction.end() && map->second.find(faction2) != map->second.end()) return map->second.at(faction2); - const ESM::Faction* faction - = MWBase::Environment::get().getWorld()->getStore().get().find(faction1); + const ESM::Faction* faction = MWBase::Environment::get().getESMStore()->get().find(faction1); auto it = faction->mReactions.begin(); for (; it != faction->mReactions.end(); ++it) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index c2107155ac..f9f7f37d28 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -650,8 +650,7 @@ bool MWDialogue::Filter::hasFactionRankSkillRequirements( if (!actor.getClass().getNpcStats(actor).hasSkillsForRank(factionId, rank)) return false; - const ESM::Faction& faction - = *MWBase::Environment::get().getWorld()->getStore().get().find(factionId); + const ESM::Faction& faction = *MWBase::Environment::get().getESMStore()->get().find(factionId); MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor); @@ -667,8 +666,7 @@ bool MWDialogue::Filter::hasFactionRankReputationRequirements( MWMechanics::NpcStats& stats = actor.getClass().getNpcStats(actor); - const ESM::Faction& faction - = *MWBase::Environment::get().getWorld()->getStore().get().find(factionId); + const ESM::Faction& faction = *MWBase::Environment::get().getESMStore()->get().find(factionId); return stats.getFactionReputation(factionId) >= faction.mData.mRankData[rank].mFactReaction; } @@ -724,8 +722,7 @@ std::vector MWDialogue::Filter::list( // No response is valid because of low NPC disposition, // search a response in the topic "Info Refusal" - const MWWorld::Store& dialogues - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& dialogues = MWBase::Environment::get().getESMStore()->get(); const ESM::Dialogue& infoRefusalDialogue = *dialogues.find(ESM::RefId::stringRefId("Info Refusal")); diff --git a/apps/openmw/mwdialogue/hypertextparser.cpp b/apps/openmw/mwdialogue/hypertextparser.cpp index bb05b5e798..54a0d99d03 100644 --- a/apps/openmw/mwdialogue/hypertextparser.cpp +++ b/apps/openmw/mwdialogue/hypertextparser.cpp @@ -48,7 +48,7 @@ namespace MWDialogue void tokenizeKeywords(const std::string& text, std::vector& tokens) { const auto& keywordSearch - = MWBase::Environment::get().getWorld()->getStore().get().getDialogIdKeywordSearch(); + = MWBase::Environment::get().getESMStore()->get().getDialogIdKeywordSearch(); std::vector::Match> matches; keywordSearch.highlightKeywords(text.begin(), text.end(), matches); diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index 74376ff5d9..c691e0d462 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -19,8 +19,7 @@ namespace MWDialogue Entry::Entry(const ESM::RefId& topic, const ESM::RefId& infoId, const MWWorld::Ptr& actor) : mInfoId(infoId) { - const ESM::Dialogue* dialogue - = MWBase::Environment::get().getWorld()->getStore().get().find(topic); + const ESM::Dialogue* dialogue = MWBase::Environment::get().getESMStore()->get().find(topic); for (ESM::Dialogue::InfoContainer::const_iterator iter(dialogue->mInfo.begin()); iter != dialogue->mInfo.end(); ++iter) @@ -87,8 +86,7 @@ namespace MWDialogue const ESM::RefId& JournalEntry::idFromIndex(const ESM::RefId& topic, int index) { - const ESM::Dialogue* dialogue - = MWBase::Environment::get().getWorld()->getStore().get().find(topic); + const ESM::Dialogue* dialogue = MWBase::Environment::get().getESMStore()->get().find(topic); for (ESM::Dialogue::InfoContainer::const_iterator iter(dialogue->mInfo.begin()); iter != dialogue->mInfo.end(); ++iter) diff --git a/apps/openmw/mwdialogue/journalimp.cpp b/apps/openmw/mwdialogue/journalimp.cpp index 31ecbe62dd..369e029e77 100644 --- a/apps/openmw/mwdialogue/journalimp.cpp +++ b/apps/openmw/mwdialogue/journalimp.cpp @@ -49,7 +49,7 @@ namespace MWDialogue bool Journal::isThere(const ESM::RefId& topicId, const ESM::RefId& infoId) const { if (const ESM::Dialogue* dialogue - = MWBase::Environment::get().getWorld()->getStore().get().search(topicId)) + = MWBase::Environment::get().getESMStore()->get().search(topicId)) { if (infoId.empty()) return true; diff --git a/apps/openmw/mwdialogue/quest.cpp b/apps/openmw/mwdialogue/quest.cpp index 205da7b8f3..0fdb918859 100644 --- a/apps/openmw/mwdialogue/quest.cpp +++ b/apps/openmw/mwdialogue/quest.cpp @@ -34,8 +34,7 @@ namespace MWDialogue std::string_view Quest::getName() const { - const ESM::Dialogue* dialogue - = MWBase::Environment::get().getWorld()->getStore().get().find(mTopic); + const ESM::Dialogue* dialogue = MWBase::Environment::get().getESMStore()->get().find(mTopic); for (ESM::Dialogue::InfoContainer::const_iterator iter(dialogue->mInfo.begin()); iter != dialogue->mInfo.end(); ++iter) @@ -69,7 +68,7 @@ namespace MWDialogue bool Quest::addEntry(const JournalEntry& entry) { const ESM::Dialogue* dialogue - = MWBase::Environment::get().getWorld()->getStore().get().find(entry.mTopic); + = MWBase::Environment::get().getESMStore()->get().find(entry.mTopic); auto info = std::find_if(dialogue->mInfo.begin(), dialogue->mInfo.end(), [&](const auto& info) { return info.mId == entry.mInfoId; }); diff --git a/apps/openmw/mwdialogue/scripttest.cpp b/apps/openmw/mwdialogue/scripttest.cpp index cf9f225db2..92746c8856 100644 --- a/apps/openmw/mwdialogue/scripttest.cpp +++ b/apps/openmw/mwdialogue/scripttest.cpp @@ -91,7 +91,7 @@ namespace MWDialogue std::pair compileAll(const Compiler::Extensions* extensions, int warningsMode) { int compiled = 0, total = 0; - const auto& store = MWBase::Environment::get().getWorld()->getStore(); + const auto& store = *MWBase::Environment::get().getESMStore(); MWScript::CompilerContext compilerContext(MWScript::CompilerContext::Type_Dialogue); compilerContext.setExtensions(extensions); diff --git a/apps/openmw/mwdialogue/topic.cpp b/apps/openmw/mwdialogue/topic.cpp index 5490441d18..9526c4f0eb 100644 --- a/apps/openmw/mwdialogue/topic.cpp +++ b/apps/openmw/mwdialogue/topic.cpp @@ -11,8 +11,7 @@ namespace MWDialogue Topic::Topic(const ESM::RefId& topic) : mTopic(topic) - , mName( - MWBase::Environment::get().getWorld()->getStore().get().find(topic)->mId.getRefIdString()) + , mName(MWBase::Environment::get().getESMStore()->get().find(topic)->mId.getRefIdString()) { } diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 54f4e3cc0d..7e8b80bc5e 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -356,7 +356,7 @@ namespace MWGui Widgets::SpellEffectParams params; params.mEffectID = effectKey.mId; const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(effectKey.mId); + = MWBase::Environment::get().getESMStore()->get().find(effectKey.mId); if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill) params.mSkill = effectKey.mArg; else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index c60a3e1ca5..5e505b6cd3 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -147,8 +147,7 @@ namespace MWGui { mBirthList->removeAllItems(); - const MWWorld::Store& signs - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& signs = MWBase::Environment::get().getESMStore()->get(); // sort by name std::vector> birthSigns; @@ -192,7 +191,7 @@ namespace MWGui const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), lineHeight); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::BirthSign* birth = store.get().find(mCurrentBirthId); diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index bc2d73dda7..7a54f23825 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -353,7 +353,7 @@ namespace MWGui if (!classId.empty()) MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId); - const ESM::Class* klass = MWBase::Environment::get().getWorld()->getStore().get().find(classId); + const ESM::Class* klass = MWBase::Environment::get().getESMStore()->get().find(classId); if (klass) { mPlayerClass = *klass; @@ -686,8 +686,7 @@ namespace MWGui MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); - const ESM::Class* klass - = MWBase::Environment::get().getWorld()->getStore().get().find(mGenerateClass); + const ESM::Class* klass = MWBase::Environment::get().getESMStore()->get().find(mGenerateClass); mPlayerClass = *klass; } diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 23b8f2241f..7385330333 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -65,7 +65,7 @@ namespace MWGui setClassImage(mClassImage, mCurrentClassId); mClassName->setCaption( - MWBase::Environment::get().getWorld()->getStore().get().find(mCurrentClassId)->mName); + MWBase::Environment::get().getESMStore()->get().find(mCurrentClassId)->mName); center(); } @@ -208,7 +208,7 @@ namespace MWGui { mClassList->removeAllItems(); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); std::vector> items; // class id, class name for (const ESM::Class& classInfo : store.get()) @@ -246,7 +246,7 @@ namespace MWGui { if (mCurrentClassId.empty()) return; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::Class* klass = store.get().search(mCurrentClassId); if (!klass) return; diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 6b3cdd7679..c376ab87f4 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -107,7 +107,7 @@ namespace MWGui scanner.listKeywords(mNames); // identifier - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); std::vector ids; for (const auto* store : esmStore) { diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index ff94af3cee..1b4b11f5b6 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -390,7 +390,7 @@ namespace MWGui return; const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); const std::string& sPersuasion = gmst.find("sPersuasion")->mValue.getString(); const std::string& sCompanionShare = gmst.find("sCompanionShare")->mValue.getString(); @@ -492,9 +492,8 @@ namespace MWGui { MWMechanics::CreatureStats& sellerStats = mPtr.getClass().getCreatureStats(mPtr); float delay = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fBarterGoldResetDelay") ->mValue.getFloat(); @@ -545,7 +544,7 @@ namespace MWGui && !mPtr.get()->mBase->getTransport().empty()); const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); if (mPtr.getType() == ESM::NPC::sRecordId) mTopicsList->addItem(gmst.find("sPersuasion")->mValue.getString()); @@ -639,9 +638,8 @@ namespace MWGui auto interactiveId = TypesetBook::InteractiveId(link.get()); mLinks.push_back(std::move(link)); const std::string& goodbye = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("sGoodbye") ->mValue.getString(); BookTypesetter::Style* questionStyle = typesetter->createHotStyle( diff --git a/apps/openmw/mwgui/enchantingdialog.cpp b/apps/openmw/mwgui/enchantingdialog.cpp index 0fb5e89882..ece29a220f 100644 --- a/apps/openmw/mwgui/enchantingdialog.cpp +++ b/apps/openmw/mwgui/enchantingdialog.cpp @@ -342,9 +342,8 @@ namespace MWGui item.getCellRef().getRefId(), mPtr)) { std::string msg = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("sNotifyMessage49") ->mValue.getString(); msg = Misc::StringUtils::format(msg, item.getClass().getName(item)); diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 94842e4bb9..4df0e1dba4 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -394,7 +394,7 @@ namespace MWGui void HUD::setSelectedSpell(const ESM::RefId& spellId, int successChancePercent) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(spellId); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().find(spellId); const std::string& spellName = spell->mName; if (spellName != mSpellName && mSpellVisible) @@ -412,7 +412,7 @@ namespace MWGui mSpellBox->setUserString("Spell", spellId.serialize()); // use the icon of the first effect - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().get().find( + const ESM::MagicEffect* effect = MWBase::Environment::get().getESMStore()->get().find( spell->mEffects.mList.front().mEffectID); std::string icon = effect->mIcon; @@ -617,9 +617,8 @@ namespace MWGui mEnemyHealth->setProgressPosition(static_cast(stats.getHealth().getRatio() * 100)); static const float fNPCHealthBarFade = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fNPCHealthBarFade") ->mValue.getFloat(); if (fNPCHealthBarFade > 0.f) @@ -630,9 +629,8 @@ namespace MWGui { mEnemyActorId = enemy.getClass().getCreatureStats(enemy).getActorId(); mEnemyHealthTimer = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fNPCHealthBarTime") ->mValue.getFloat(); if (!mEnemyHealth->getVisible()) diff --git a/apps/openmw/mwgui/itemchargeview.cpp b/apps/openmw/mwgui/itemchargeview.cpp index aab52173a7..48fb236fc6 100644 --- a/apps/openmw/mwgui/itemchargeview.cpp +++ b/apps/openmw/mwgui/itemchargeview.cpp @@ -194,7 +194,7 @@ namespace MWGui if (enchId.empty()) break; const ESM::Enchantment* ench - = MWBase::Environment::get().getWorld()->getStore().get().search(enchId); + = MWBase::Environment::get().getESMStore()->get().search(enchId); if (!ench) break; diff --git a/apps/openmw/mwgui/jailscreen.cpp b/apps/openmw/mwgui/jailscreen.cpp index 37102d6ae9..9dc45d0d05 100644 --- a/apps/openmw/mwgui/jailscreen.cpp +++ b/apps/openmw/mwgui/jailscreen.cpp @@ -103,7 +103,7 @@ namespace MWGui } const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); std::string message; if (mDays == 1) diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index e6216ca951..44306c30a5 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -1315,8 +1315,8 @@ namespace MWGui for (const ESM::GlobalMap::CellId& cellId : map.mMarkers) { - const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get().search( - cellId.first, cellId.second); + const ESM::Cell* cell + = MWBase::Environment::get().getESMStore()->get().search(cellId.first, cellId.second); if (cell && !cell->mName.empty()) addVisitedLocation(cell->mName, cellId.first, cellId.second); } diff --git a/apps/openmw/mwgui/merchantrepair.cpp b/apps/openmw/mwgui/merchantrepair.cpp index dcb44dadce..e520f9cb28 100644 --- a/apps/openmw/mwgui/merchantrepair.cpp +++ b/apps/openmw/mwgui/merchantrepair.cpp @@ -56,9 +56,8 @@ namespace MWGui int basePrice = iter->getClass().getValue(*iter); float fRepairMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fRepairMult") ->mValue.getFloat(); @@ -73,12 +72,7 @@ namespace MWGui std::string name{ iter->getClass().getName(*iter) }; name += " - " + MyGUI::utility::toString(price) - + MWBase::Environment::get() - .getWorld() - ->getStore() - .get() - .find("sgp") - ->mValue.getString(); + + MWBase::Environment::get().getESMStore()->get().find("sgp")->mValue.getString(); MyGUI::Button* button = mList->createWidget(price <= playerGold ? "SandTextButton" diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index a820eeaf5c..fb03ab99c9 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -287,7 +287,7 @@ namespace MWGui while (mSelected->button->getChildCount()) // Destroy number label MyGUI::Gui::getInstance().destroyWidget(mSelected->button->getChildAt(0)); - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); const ESM::Spell* spell = esmStore.get().find(spellId); mSelected->type = ESM::QuickKeys::Type::Magic; @@ -552,7 +552,7 @@ namespace MWGui switch (quickKey.mType) { case ESM::QuickKeys::Type::Magic: - if (MWBase::Environment::get().getWorld()->getStore().get().search(quickKey.mId)) + if (MWBase::Environment::get().getESMStore()->get().search(quickKey.mId)) onAssignMagic(quickKey.mId); break; case ESM::QuickKeys::Type::Item: diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 3f8b8f5d9d..795c58723f 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -316,8 +316,7 @@ namespace MWGui void RaceDialog::getBodyParts(int part, std::vector& out) { out.clear(); - const MWWorld::Store& store - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& store = MWBase::Environment::get().getESMStore()->get(); for (const ESM::BodyPart& bodypart : store) { @@ -373,7 +372,7 @@ namespace MWGui { mRaceList->removeAllItems(); - const MWWorld::Store& races = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& races = MWBase::Environment::get().getESMStore()->get(); std::vector> items; // ID, name for (const ESM::Race& race : races) @@ -411,7 +410,7 @@ namespace MWGui const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::Race* race = store.get().find(mCurrentRaceId); int count = sizeof(race->mData.mBonus) / sizeof(race->mData.mBonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? @@ -448,7 +447,7 @@ namespace MWGui const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), lineHeight); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::Race* race = store.get().find(mCurrentRaceId); int i = 0; diff --git a/apps/openmw/mwgui/recharge.cpp b/apps/openmw/mwgui/recharge.cpp index d00ad79455..96ca425c6c 100644 --- a/apps/openmw/mwgui/recharge.cpp +++ b/apps/openmw/mwgui/recharge.cpp @@ -69,8 +69,7 @@ namespace MWGui MWWorld::Ptr gem = *mGemIcon->getUserData(); const ESM::RefId& soul = gem.getCellRef().getSoul(); - const ESM::Creature* creature - = MWBase::Environment::get().getWorld()->getStore().get().find(soul); + const ESM::Creature* creature = MWBase::Environment::get().getESMStore()->get().find(soul); mChargeLabel->setCaptionWithReplacing("#{sCharges} " + MyGUI::utility::toString(creature->mData.mSoul)); diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 7219fa2273..7fe59d7a32 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -128,7 +128,7 @@ namespace MWGui { mRaceId = raceId; - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().search(mRaceId); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().search(mRaceId); if (race) { ToolTips::createRaceToolTip(mRaceWidget, race); @@ -150,7 +150,7 @@ namespace MWGui mBirthSignId = signId; const ESM::BirthSign* sign - = MWBase::Environment::get().getWorld()->getStore().get().search(mBirthSignId); + = MWBase::Environment::get().getESMStore()->get().search(mBirthSignId); if (sign) { mBirthSignWidget->setCaption(sign->mName); @@ -391,7 +391,7 @@ namespace MWGui const ESM::Race* race = nullptr; if (!mRaceId.empty()) - race = MWBase::Environment::get().getWorld()->getStore().get().find(mRaceId); + race = MWBase::Environment::get().getESMStore()->get().find(mRaceId); int skills[ESM::Skill::Length]; for (int i = 0; i < ESM::Skill::Length; ++i) @@ -420,7 +420,7 @@ namespace MWGui if (!mBirthSignId.empty()) { const ESM::BirthSign* sign - = MWBase::Environment::get().getWorld()->getStore().get().find(mBirthSignId); + = MWBase::Environment::get().getESMStore()->get().find(mBirthSignId); for (const auto& spellId : sign->mPowers.mList) { if (std::find(spells.begin(), spells.end(), spellId) == spells.end()) @@ -434,7 +434,7 @@ namespace MWGui coord1, coord2); for (auto& spellId : spells) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(spellId); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().find(spellId); if (spell->mData.mType == ESM::Spell::ST_Ability) addItem(spell, coord1, coord2); } @@ -444,7 +444,7 @@ namespace MWGui coord2); for (auto& spellId : spells) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(spellId); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().find(spellId); if (spell->mData.mType == ESM::Spell::ST_Power) addItem(spell, coord1, coord2); } @@ -454,7 +454,7 @@ namespace MWGui coord2); for (auto& spellId : spells) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(spellId); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().find(spellId); if (spell->mData.mType == ESM::Spell::ST_Spell) addItem(spell, coord1, coord2); } diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index db1acf40d2..80029aa837 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -189,8 +189,7 @@ namespace MWGui { // Find the localised name for this class from the store const ESM::Class* class_ - = MWBase::Environment::get().getWorld()->getStore().get().search( - signature.mPlayerClassId); + = MWBase::Environment::get().getESMStore()->get().search(signature.mPlayerClassId); if (class_) className = class_->mName; else diff --git a/apps/openmw/mwgui/sortfilteritemmodel.cpp b/apps/openmw/mwgui/sortfilteritemmodel.cpp index 33833f3daa..d56bd11973 100644 --- a/apps/openmw/mwgui/sortfilteritemmodel.cpp +++ b/apps/openmw/mwgui/sortfilteritemmodel.cpp @@ -106,7 +106,7 @@ namespace if (!leftNameEnch.empty()) { const ESM::Enchantment* ench - = MWBase::Environment::get().getWorld()->getStore().get().search(leftNameEnch); + = MWBase::Environment::get().getESMStore()->get().search(leftNameEnch); if (ench) { if (ench->mData.mType == ESM::Enchantment::ConstantEffect) @@ -120,7 +120,7 @@ namespace if (!rightNameEnch.empty()) { const ESM::Enchantment* ench - = MWBase::Environment::get().getWorld()->getStore().get().search(rightNameEnch); + = MWBase::Environment::get().getESMStore()->get().search(rightNameEnch); if (ench) { if (ench->mData.mType == ESM::Enchantment::ConstantEffect) @@ -263,8 +263,7 @@ namespace MWGui return false; if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getType() != ESM::Miscellaneous::sRecordId || base.getCellRef().getSoul().empty() - || !MWBase::Environment::get().getWorld()->getStore().get().search( - base.getCellRef().getSoul()))) + || !MWBase::Environment::get().getESMStore()->get().search(base.getCellRef().getSoul()))) return false; if ((mFilter & Filter_OnlyRepairTools) && (base.getType() != ESM::Repair::sRecordId)) return false; @@ -297,7 +296,7 @@ namespace MWGui const ESM::RefId& enchId = base.getClass().getEnchantment(base); const ESM::Enchantment* ench - = MWBase::Environment::get().getWorld()->getStore().get().search(enchId); + = MWBase::Environment::get().getESMStore()->get().search(enchId); if (!ench) { Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchId << "' on item " diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 8190a81f97..66ef981dd0 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -40,7 +40,7 @@ namespace MWGui void SpellBuyingWindow::addSpell(const ESM::Spell& spell) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); int price = std::max(1, static_cast( @@ -103,7 +103,7 @@ namespace MWGui if (actor.getClass().isNpc()) { - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find( + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find( actor.get()->mBase->mRace); if (race->mPowers.exists(spell->mId)) continue; diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 149615ce62..034ac25227 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -35,7 +35,7 @@ namespace bool sortMagicEffects(short id1, short id2) { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); return gmst.find(ESM::MagicEffect::effectIdToString(id1))->mValue.getString() < gmst.find(ESM::MagicEffect::effectIdToString(id2))->mValue.getString(); @@ -161,7 +161,7 @@ namespace MWGui void EditEffectDialog::editEffect(ESM::ENAMstruct effect) { const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); + = MWBase::Environment::get().getESMStore()->get().find(effect.mEffectID); setMagicEffect(magicEffect); mOldEffect = effect; @@ -416,7 +416,7 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Mysticism Hit")); - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().insert(mSpell); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->insert(mSpell); MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player); MWMechanics::Spells& spells = stats.getSpells(); @@ -457,7 +457,7 @@ namespace MWGui float y = 0; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); for (const ESM::ENAMstruct& effect : mEffects) { @@ -529,8 +529,7 @@ namespace MWGui for (const ESM::ENAMstruct& effectInfo : spell->mEffects.mList) { const ESM::MagicEffect* effect - = MWBase::Environment::get().getWorld()->getStore().get().find( - effectInfo.mEffectID); + = MWBase::Environment::get().getESMStore()->get().find(effectInfo.mEffectID); // skip effects that do not allow spellmaking/enchanting int requiredFlags @@ -551,9 +550,8 @@ namespace MWGui for (const short effectId : knownEffects) { mAvailableEffectsList->addItem(MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find(ESM::MagicEffect::effectIdToString(effectId)) ->mValue.getString()); mButtonMapping[i] = effectId; @@ -565,9 +563,8 @@ namespace MWGui for (const short effectId : knownEffects) { const std::string& name = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find(ESM::MagicEffect::effectIdToString(effectId)) ->mValue.getString(); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); @@ -591,7 +588,7 @@ namespace MWGui void EffectEditorBase::onSelectAttribute() { const ESM::MagicEffect* effect - = MWBase::Environment::get().getWorld()->getStore().get().find(mSelectedKnownEffectId); + = MWBase::Environment::get().getESMStore()->get().find(mSelectedKnownEffectId); mAddEffectDialog.newEffect(effect); mAddEffectDialog.setAttribute(mSelectAttributeDialog->getAttributeId()); @@ -601,7 +598,7 @@ namespace MWGui void EffectEditorBase::onSelectSkill() { const ESM::MagicEffect* effect - = MWBase::Environment::get().getWorld()->getStore().get().find(mSelectedKnownEffectId); + = MWBase::Environment::get().getESMStore()->get().find(mSelectedKnownEffectId); mAddEffectDialog.newEffect(effect); mAddEffectDialog.setSkill(mSelectSkillDialog->getSkillId()); @@ -628,7 +625,7 @@ namespace MWGui mSelectedKnownEffectId = mButtonMapping[buttonId]; const ESM::MagicEffect* effect - = MWBase::Environment::get().getWorld()->getStore().get().find(mSelectedKnownEffectId); + = MWBase::Environment::get().getESMStore()->get().find(mSelectedKnownEffectId); bool allowSelf = (effect->mData.mFlags & ESM::MagicEffect::CastSelf) != 0; bool allowTouch = (effect->mData.mFlags & ESM::MagicEffect::CastTouch) && !mConstantEffect; @@ -761,7 +758,7 @@ namespace MWGui { if (it->mRange != ESM::RT_Self) { - auto& store = MWBase::Environment::get().getWorld()->getStore(); + auto& store = *MWBase::Environment::get().getESMStore(); auto magicEffect = store.get().find(it->mEffectID); if ((magicEffect->mData.mFlags & ESM::MagicEffect::CastSelf) == 0) { diff --git a/apps/openmw/mwgui/spellicons.cpp b/apps/openmw/mwgui/spellicons.cpp index 058c89da6a..dcd65c48b4 100644 --- a/apps/openmw/mwgui/spellicons.cpp +++ b/apps/openmw/mwgui/spellicons.cpp @@ -52,7 +52,7 @@ namespace MWGui for (const auto& [effectId, effectInfos] : effects) { const ESM::MagicEffect* effect - = MWBase::Environment::get().getWorld()->getStore().get().find(effectId); + = MWBase::Environment::get().getESMStore()->get().find(effectId); float remainingDuration = 0; float totalDuration = 0; @@ -60,9 +60,8 @@ namespace MWGui std::string sourcesDescription; static const float fadeTime = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fMagicStartIconBlink") ->mValue.getFloat(); diff --git a/apps/openmw/mwgui/spellmodel.cpp b/apps/openmw/mwgui/spellmodel.cpp index 5e29c1d952..691f48b53a 100644 --- a/apps/openmw/mwgui/spellmodel.cpp +++ b/apps/openmw/mwgui/spellmodel.cpp @@ -45,7 +45,7 @@ namespace MWGui bool SpellModel::matchingEffectExists(std::string filter, const ESM::EffectList& effects) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); for (const auto& effect : effects.mList) { @@ -75,7 +75,7 @@ namespace MWGui MWMechanics::CreatureStats& stats = mActor.getClass().getCreatureStats(mActor); const MWMechanics::Spells& spells = stats.getSpells(); - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); std::string filter = Utf8Stream::lowerCaseUtf8(mFilter); diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index 847085d4ef..50a97c7d91 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -139,18 +139,17 @@ namespace MWGui void SpellWindow::askDeleteSpell(const ESM::RefId& spellId) { // delete spell, if allowed - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(spellId); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().find(spellId); MWWorld::Ptr player = MWMechanics::getPlayer(); const ESM::RefId& raceId = player.get()->mBase->mRace; - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(raceId); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(raceId); // can't delete racial spells, birthsign spells or powers bool isInherent = race->mPowers.exists(spell->mId) || spell->mData.mType == ESM::Spell::ST_Power; const ESM::RefId& signId = MWBase::Environment::get().getWorld()->getPlayer().getBirthSign(); if (!isInherent && !signId.empty()) { - const ESM::BirthSign* sign - = MWBase::Environment::get().getWorld()->getStore().get().find(signId); + const ESM::BirthSign* sign = MWBase::Environment::get().getESMStore()->get().find(signId); isInherent = sign->mPowers.exists(spell->mId); } diff --git a/apps/openmw/mwgui/statswatcher.cpp b/apps/openmw/mwgui/statswatcher.cpp index 5df0079a44..b03eab6869 100644 --- a/apps/openmw/mwgui/statswatcher.cpp +++ b/apps/openmw/mwgui/statswatcher.cpp @@ -67,9 +67,8 @@ namespace MWGui if (timeToDrown != mWatchedTimeToStartDrowning) { static const float fHoldBreathTime = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fHoldBreathTime") ->mValue.getFloat(); @@ -114,7 +113,7 @@ namespace MWGui { mWatchedRace = watchedRecord->mRace; const ESM::Race* race - = MWBase::Environment::get().getWorld()->getStore().get().find(watchedRecord->mRace); + = MWBase::Environment::get().getESMStore()->get().find(watchedRecord->mRace); setValue("race", race->mName); } @@ -122,7 +121,7 @@ namespace MWGui { mWatchedClass = watchedRecord->mClass; const ESM::Class* cls - = MWBase::Environment::get().getWorld()->getStore().get().find(watchedRecord->mClass); + = MWBase::Environment::get().getESMStore()->get().find(watchedRecord->mClass); setValue("class", cls->mName); MWBase::WindowManager::SkillList majorSkills(5); diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index d02667940a..b016bceaf5 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -57,7 +57,7 @@ namespace MWGui { "Attrib6", "sAttributeEndurance" }, { "Attrib7", "sAttributePersonality" }, { "Attrib8", "sAttributeLuck" }, { 0, 0 } }; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); for (int i = 0; names[i][0]; ++i) { setText(names[i][0], store.get().find(names[i][1])->mValue.getString()); @@ -240,7 +240,7 @@ namespace MWGui void setSkillProgress(MyGUI::Widget* w, float progress, int skillId) { MWWorld::Ptr player = MWMechanics::getPlayer(); - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); float progressRequirement = player.getClass().getNpcStats(player).getSkillProgressRequirement( skillId, *esmStore.get().find(player.get()->mBase->mClass)); @@ -358,9 +358,8 @@ namespace MWGui for (int i = 0; i < 2; ++i) { int max = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iLevelUpTotal") ->mValue.getInteger(); getWidget(levelWidget, i == 0 ? "Level_str" : "LevelText"); @@ -510,7 +509,7 @@ namespace MWGui continue; const std::string& skillNameId = ESM::Skill::sSkillNameIds[skillId]; - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); const ESM::Skill* skill = esmStore.get().find(skillId); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index c829fdb2c4..a0ae5942d7 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -226,7 +226,7 @@ namespace MWGui { ToolTipInfo info; - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find( + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().find( ESM::RefId::deserialize(focus->getUserString("Spell"))); info.caption = spell->mName; Widgets::SpellEffectList effects; @@ -420,7 +420,7 @@ namespace MWGui text.erase(0, 1); const ESM::Enchantment* enchant = nullptr; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); if (!info.enchant.empty()) { enchant = store.get().search(info.enchant); @@ -681,7 +681,7 @@ namespace MWGui const ESM::RefId& soul = cellref.getSoul(); if (soul.empty()) return {}; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::Creature* creature = store.get().search(soul); if (!creature) return {}; @@ -697,7 +697,7 @@ namespace MWGui const ESM::RefId& factionId = cellref.getFaction(); if (!factionId.empty()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::Faction* fact = store.get().search(factionId); if (fact != nullptr) { @@ -809,7 +809,7 @@ namespace MWGui if (skillId == -1) return; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const std::string& skillNameId = ESM::Skill::sSkillNameIds[skillId]; const ESM::Skill* skill = store.get().find(skillId); @@ -848,7 +848,7 @@ namespace MWGui widget->setUserString("Caption_Caption", name); std::string specText; // get all skills of this specialisation - const MWWorld::Store& skills = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& skills = MWBase::Environment::get().getESMStore()->get(); bool isFirst = true; for (auto& skillPair : skills) @@ -870,7 +870,7 @@ namespace MWGui void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const ESM::RefId& birthsignId) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::BirthSign* sign = store.get().find(birthsignId); const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); @@ -953,8 +953,7 @@ namespace MWGui void ToolTips::createMagicEffectToolTip(MyGUI::Widget* widget, short id) { - const ESM::MagicEffect* effect - = MWBase::Environment::get().getWorld()->getStore().get().find(id); + const ESM::MagicEffect* effect = MWBase::Environment::get().getESMStore()->get().find(id); const std::string& name = ESM::MagicEffect::effectIdToString(id); std::string icon = effect->mIcon; diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 9143efe57b..a42ca35843 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -273,7 +273,7 @@ namespace MWGui = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel(); const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); if (mTotalBalance->getValue() == 0) mCurrentBalance = 0; diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index bf8362a6be..94647c839b 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -98,7 +98,7 @@ namespace MWGui MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats(player); const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; @@ -146,7 +146,7 @@ namespace MWGui MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats(player); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); int price = pcStats.getSkill(skillId).getBase() * store.get().find("iTrainingMod")->mValue.getInteger(); @@ -162,7 +162,7 @@ namespace MWGui } // You can not train a skill above its governing attribute - const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get().find(skillId); + const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get().find(skillId); if (pcStats.getSkill(skillId).getBase() >= pcStats.getAttribute(skill->mData.mAttribute).getBase()) { MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage17}"); diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 5430de11e2..55ff9fa601 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -49,7 +49,7 @@ namespace MWGui int price; const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId); @@ -182,9 +182,8 @@ namespace MWGui = (osg::Vec3f(pos.pos[0], pos.pos[1], 0) - osg::Vec3f(playerPos.pos[0], playerPos.pos[1], 0)).length(); int hours = static_cast(d / MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fTravelTimeMult") ->mValue.getFloat()); MWBase::Environment::get().getMechanicsManager()->rest(hours, true); diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 6159ef0263..0c93773278 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -279,7 +279,7 @@ namespace MWGui // trigger levelup if possible const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); if (mSleeping && pcstats.getLevelProgress() >= gmst.find("iLevelUpTotal")->mValue.getInteger()) { MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Levelup); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 987c8e598a..c13dbd4da1 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -214,7 +214,7 @@ namespace MWGui::Widgets void MWSpell::createEffectWidgets( std::vector& effects, MyGUI::Widget* creator, MyGUI::IntCoord& coord, int flags) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::Spell* spell = store.get().search(mId); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); @@ -245,7 +245,7 @@ namespace MWGui::Widgets { if (mSpellNameWidget && MWBase::Environment::get().getWindowManager()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::Spell* spell = store.get().search(mId); if (spell) @@ -375,7 +375,7 @@ namespace MWGui::Widgets return; } - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::MagicEffect* magicEffect = store.get().search(mEffectParams.mEffectID); diff --git a/apps/openmw/mwlua/luabindings.cpp b/apps/openmw/mwlua/luabindings.cpp index e11ba382a2..d62b1c10ba 100644 --- a/apps/openmw/mwlua/luabindings.cpp +++ b/apps/openmw/mwlua/luabindings.cpp @@ -71,7 +71,7 @@ namespace MWLua api["magic"] = initCoreMagicBindings(context); api["l10n"] = LuaUtil::initL10nLoader(lua->sol(), MWBase::Environment::get().getL10nManager()); const MWWorld::Store* gmst - = &MWBase::Environment::get().getWorld()->getStore().get(); + = &MWBase::Environment::get().getESMStore()->get(); api["getGMST"] = [lua = context.mLua, gmst](const std::string& setting) -> sol::object { const ESM::Variant& value = gmst->find(setting)->mValue; if (value.getType() == ESM::VT_String) @@ -110,8 +110,7 @@ namespace MWLua // Doesn't matter which cell to use because the new object will be in disabled state. MWWorld::CellStore* cell = MWBase::Environment::get().getWorldScene()->getCurrentCell(); - MWWorld::ManualRef mref( - MWBase::Environment::get().getWorld()->getStore(), ESM::RefId::deserializeText(recordId)); + MWWorld::ManualRef mref(*MWBase::Environment::get().getESMStore(), ESM::RefId::deserializeText(recordId)); const MWWorld::Ptr& ptr = mref.getPtr(); ptr.getRefData().disable(); MWWorld::Ptr newPtr = ptr.getClass().copyToCell(ptr, *cell, count.value_or(1)); @@ -120,7 +119,7 @@ namespace MWLua // Creates a new record in the world database. api["createRecord"] = sol::overload([](const ESM::Potion& potion) -> const ESM::Potion* { - return MWBase::Environment::get().getWorld()->getStore().insert(potion); + return MWBase::Environment::get().getESMStore()->insert(potion); } // TODO: add here overloads for other records ); diff --git a/apps/openmw/mwlua/luamanagerimp.cpp b/apps/openmw/mwlua/luamanagerimp.cpp index bcf5221643..35d1d0be4d 100644 --- a/apps/openmw/mwlua/luamanagerimp.cpp +++ b/apps/openmw/mwlua/luamanagerimp.cpp @@ -67,7 +67,7 @@ namespace MWLua void LuaManager::initConfiguration() { - mConfiguration.init(MWBase::Environment::get().getWorld()->getStore().getLuaScriptsCfg()); + mConfiguration.init(MWBase::Environment::get().getESMStore()->getLuaScriptsCfg()); Log(Debug::Verbose) << "Lua scripts configuration (" << mConfiguration.size() << " scripts):"; for (size_t i = 0; i < mConfiguration.size(); ++i) Log(Debug::Verbose) << "#" << i << " " << LuaUtil::scriptCfgToString(mConfiguration[i]); diff --git a/apps/openmw/mwlua/stats.cpp b/apps/openmw/mwlua/stats.cpp index 2def0c6ac6..eeeb11cb91 100644 --- a/apps/openmw/mwlua/stats.cpp +++ b/apps/openmw/mwlua/stats.cpp @@ -261,7 +261,7 @@ namespace MWLua static float getMaxProgress(const MWWorld::Ptr& ptr, int index, const MWMechanics::SkillValue& stat) { - const auto& store = MWBase::Environment::get().getWorld()->getStore(); + const auto& store = *MWBase::Environment::get().getESMStore(); const auto cl = store.get().find(ptr.get()->mBase->mClass); return ptr.getClass().getNpcStats(ptr).getSkillProgressRequirement(index, *cl); } diff --git a/apps/openmw/mwlua/types/misc.cpp b/apps/openmw/mwlua/types/misc.cpp index c451ee4f98..17b51898de 100644 --- a/apps/openmw/mwlua/types/misc.cpp +++ b/apps/openmw/mwlua/types/misc.cpp @@ -28,7 +28,7 @@ namespace MWLua miscellaneous["setSoul"] = [](const GObject& object, std::string_view soulId) { ESM::RefId creature = ESM::RefId::deserializeText(soulId); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); if (!store.get().search(creature)) { diff --git a/apps/openmw/mwlua/types/types.hpp b/apps/openmw/mwlua/types/types.hpp index fd36db8c74..cc0a8f3b82 100644 --- a/apps/openmw/mwlua/types/types.hpp +++ b/apps/openmw/mwlua/types/types.hpp @@ -69,7 +69,7 @@ namespace MWLua void addRecordFunctionBinding( sol::table table, const Context& context, const std::string& recordName = std::string(T::getRecordType())) { - const MWWorld::Store& store = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& store = MWBase::Environment::get().getESMStore()->get(); table["record"] = sol::overload([](const Object& obj) -> const T* { return obj.ptr().get()->mBase; }, [&store](std::string_view id) -> const T* { return store.find(ESM::RefId::deserializeText(id)); }); diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 8a9139a84b..69c73c2130 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -323,9 +323,8 @@ namespace MWMechanics } if (reflected) { - const ESM::Static* reflectStatic - = MWBase::Environment::get().getWorld()->getStore().get().find( - ESM::RefId::stringRefId("VFX_Reflect")); + const ESM::Static* reflectStatic = MWBase::Environment::get().getESMStore()->get().find( + ESM::RefId::stringRefId("VFX_Reflect")); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); if (animation && !reflectStatic->mModel.empty()) { diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 04a847240f..0e9a38ea44 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -102,7 +102,7 @@ namespace { const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); const MWWorld::Store& settings - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); const float endurance = stats.getAttribute(ESM::Attribute::Endurance).getModified(); const float health = 0.1f * endurance; @@ -262,15 +262,13 @@ namespace MWMechanics return; static const float fMaxHeadTrackDistance = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fMaxHeadTrackDistance") ->mValue.getFloat(); static const float fInteriorHeadTrackMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fInteriorHeadTrackMult") ->mValue.getFloat(); float maxDistance = fMaxHeadTrackDistance; @@ -493,9 +491,8 @@ namespace MWMechanics // Play a random voice greeting if the player gets too close static const int iGreetDistanceMultiplier = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iGreetDistanceMultiplier") ->mValue.getInteger(); @@ -820,7 +817,7 @@ namespace MWMechanics return; const MWWorld::Store& settings - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); if (sleep) { @@ -898,7 +895,7 @@ namespace MWMechanics // Restore fatigue const float endurance = stats.getAttribute(ESM::Attribute::Endurance).getModified(); const MWWorld::Store& settings - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fFatigueReturnBase = settings.find("fFatigueReturnBase")->mValue.getFloat(); static const float fFatigueReturnMult = settings.find("fFatigueReturnMult")->mValue.getFloat(); @@ -939,9 +936,8 @@ namespace MWMechanics // When npc stats are just initialized, mTimeToStartDrowning == -1 and we should get value from GMST static const float fHoldBreathTime = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fHoldBreathTime") ->mValue.getFloat(); if (stats.getTimeToStartDrowning() == -1.f) @@ -1848,7 +1844,7 @@ namespace MWMechanics { MWBase::Environment::get().getWorld()->deleteObject(ptr); - const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get().search( + const ESM::Static* fx = MWBase::Environment::get().getESMStore()->get().search( ESM::RefId::stringRefId("VFX_Summon_End")); if (fx) { @@ -2301,7 +2297,7 @@ namespace MWMechanics ESM::RefId id = reader.getRefId(); int count; reader.getHNT(count, "COUN"); - if (MWBase::Environment::get().getWorld()->getStore().find(id)) + if (MWBase::Environment::get().getESMStore()->find(id)) mDeathCount[id] = count; } } diff --git a/apps/openmw/mwmechanics/aibreathe.cpp b/apps/openmw/mwmechanics/aibreathe.cpp index e437547a7a..ab0344d86a 100644 --- a/apps/openmw/mwmechanics/aibreathe.cpp +++ b/apps/openmw/mwmechanics/aibreathe.cpp @@ -14,12 +14,8 @@ bool MWMechanics::AiBreathe::execute( const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) { - static const float fHoldBreathTime = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() - .find("fHoldBreathTime") - ->mValue.getFloat(); + static const float fHoldBreathTime + = MWBase::Environment::get().getESMStore()->get().find("fHoldBreathTime")->mValue.getFloat(); const MWWorld::Class& actorClass = actor.getClass(); if (actorClass.isNpc()) diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index b28d00fdd0..1e32b420ac 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -362,7 +362,7 @@ namespace MWMechanics if (storage.mLOS && (triggerDist >= 1000 || getDistanceMinusHalfExtents(actor, target) <= triggerDist)) { const ESM::Pathgrid* pathgrid - = MWBase::Environment::get().getWorld()->getStore().get().search(*cellVariant); + = MWBase::Environment::get().getESMStore()->get().search(*cellVariant); bool runFallback = true; @@ -429,9 +429,8 @@ namespace MWMechanics case AiCombatStorage::FleeState_RunToDestination: { static const float fFleeDistance = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fFleeDistance") ->mValue.getFloat(); @@ -649,7 +648,7 @@ namespace MWMechanics auto& prng = MWBase::Environment::get().getWorld()->getPrng(); mStrength = Misc::Rng::rollClosedProbability(prng); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); float baseDelay = store.get().find("fCombatDelayCreature")->mValue.getFloat(); if (actor.getClass().isNpc()) @@ -741,7 +740,7 @@ namespace { float projSpeed; const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); // get projectile speed (depending on weapon type) if (MWMechanics::getWeaponType(weapType)->mWeaponClass == ESM::WeaponType::Thrown) diff --git a/apps/openmw/mwmechanics/aicombataction.cpp b/apps/openmw/mwmechanics/aicombataction.cpp index f41640323a..7981ed123a 100644 --- a/apps/openmw/mwmechanics/aicombataction.cpp +++ b/apps/openmw/mwmechanics/aicombataction.cpp @@ -25,15 +25,13 @@ namespace MWMechanics float suggestCombatRange(int rangeTypes) { static const float fCombatDistance = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fCombatDistance") ->mValue.getFloat(); static float fHandToHandReach = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fHandToHandReach") ->mValue.getFloat(); @@ -58,13 +56,13 @@ namespace MWMechanics inv.setSelectedEnchantItem(inv.end()); } - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(mSpellId); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().find(mSpellId); MWBase::Environment::get().getWorld()->preloadEffects(&spell->mEffects); } float ActionSpell::getCombatRange(bool& isRanged) const { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(mSpellId); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().find(mSpellId); int types = getRangeTypes(spell->mEffects); isRanged = (types & RangeTypes::Target) | (types & RangeTypes::Self); @@ -80,9 +78,8 @@ namespace MWMechanics float ActionEnchantedItem::getCombatRange(bool& isRanged) const { - const ESM::Enchantment* enchantment - = MWBase::Environment::get().getWorld()->getStore().get().find( - mItem->getClass().getEnchantment(*mItem)); + const ESM::Enchantment* enchantment = MWBase::Environment::get().getESMStore()->get().find( + mItem->getClass().getEnchantment(*mItem)); int types = getRangeTypes(enchantment->mEffects); isRanged = (types & RangeTypes::Target) | (types & RangeTypes::Self); @@ -127,24 +124,21 @@ namespace MWMechanics isRanged = false; static const float fCombatDistance = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fCombatDistance") ->mValue.getFloat(); static const float fProjectileMaxSpeed = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fProjectileMaxSpeed") ->mValue.getFloat(); if (mWeapon.isEmpty()) { static float fHandToHandReach = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fHandToHandReach") ->mValue.getFloat(); return fHandToHandReach * fCombatDistance; @@ -322,7 +316,7 @@ namespace MWMechanics { const CreatureStats& stats = actor.getClass().getCreatureStats(actor); const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); const ESM::RefId& selectedSpellId = stats.getSpells().getSelectedSpell(); MWWorld::Ptr selectedEnchItem; @@ -356,14 +350,14 @@ namespace MWMechanics if (!selectedSpellId.empty()) { const ESM::Spell* spell - = MWBase::Environment::get().getWorld()->getStore().get().find(selectedSpellId); + = MWBase::Environment::get().getESMStore()->get().find(selectedSpellId); for (std::vector::const_iterator effectIt = spell->mEffects.mList.begin(); effectIt != spell->mEffects.mList.end(); ++effectIt) { if (effectIt->mRange == ESM::RT_Target) { const ESM::MagicEffect* effect - = MWBase::Environment::get().getWorld()->getStore().get().find( + = MWBase::Environment::get().getESMStore()->get().find( effectIt->mEffectID); dist = effect->mData.mSpeed; break; @@ -376,14 +370,14 @@ namespace MWMechanics if (!enchId.empty()) { const ESM::Enchantment* ench - = MWBase::Environment::get().getWorld()->getStore().get().find(enchId); + = MWBase::Environment::get().getESMStore()->get().find(enchId); for (std::vector::const_iterator effectIt = ench->mEffects.mList.begin(); effectIt != ench->mEffects.mList.end(); ++effectIt) { if (effectIt->mRange == ESM::RT_Target) { const ESM::MagicEffect* effect - = MWBase::Environment::get().getWorld()->getStore().get().find( + = MWBase::Environment::get().getESMStore()->get().find( effectIt->mEffectID); dist = effect->mData.mSpeed; break; @@ -507,7 +501,7 @@ namespace MWMechanics { const CreatureStats& stats = actor.getClass().getCreatureStats(actor); const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); const int flee = stats.getAiSetting(AiSetting::Flee).getModified(); if (flee >= 100) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 9d8d23a08d..69f78616e7 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -211,8 +211,7 @@ namespace MWMechanics if (!mPathFinder.isPathConstructed() && mHasDestination) { const ESM::Pathgrid* pathgrid - = MWBase::Environment::get().getWorld()->getStore().get().search( - *actor.getCell()->getCell()); + = MWBase::Environment::get().getESMStore()->get().search(*actor.getCell()->getCell()); if (mUsePathgrid) { mPathFinder.buildPathByPathgrid( @@ -805,7 +804,7 @@ namespace MWMechanics ESM::Pathgrid::Point dest, const MWWorld::CellStore* currentCell, ESM::Pathgrid::PointList& points) { const ESM::Pathgrid* pathgrid - = MWBase::Environment::get().getWorld()->getStore().get().search(*currentCell->getCell()); + = MWBase::Environment::get().getESMStore()->get().search(*currentCell->getCell()); if (pathgrid == nullptr || pathgrid->mPoints.empty()) return; @@ -820,7 +819,7 @@ namespace MWMechanics // infrequently used, therefore no benefit in caching it as a member const MWWorld::CellStore* cellStore = actor.getCell(); const ESM::Pathgrid* pathgrid - = MWBase::Environment::get().getWorld()->getStore().get().search(*cellStore->getCell()); + = MWBase::Environment::get().getESMStore()->get().search(*cellStore->getCell()); storage.mAllowedNodes.clear(); diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 3030a0997a..7dee12b6be 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -139,26 +139,20 @@ void MWMechanics::Alchemy::updateEffects() x *= mTools[ESM::Apparatus::MortarPestle].get()->mBase->mData.mQuality; x *= MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fPotionStrengthMult") ->mValue.getFloat(); // value - mValue = static_cast(x - * MWBase::Environment::get() - .getWorld() - ->getStore() - .get() - .find("iAlchemyMod") - ->mValue.getFloat()); + mValue = static_cast( + x * MWBase::Environment::get().getESMStore()->get().find("iAlchemyMod")->mValue.getFloat()); // build quantified effect list for (std::set::const_iterator iter(effects.begin()); iter != effects.end(); ++iter) { const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(iter->mId); + = MWBase::Environment::get().getESMStore()->get().find(iter->mId); if (magicEffect->mData.mBaseCost <= 0) { @@ -167,9 +161,8 @@ void MWMechanics::Alchemy::updateEffects() } float fPotionT1MagMul = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fPotionT1MagMult") ->mValue.getFloat(); @@ -177,9 +170,8 @@ void MWMechanics::Alchemy::updateEffects() throw std::runtime_error("invalid gmst: fPotionT1MagMul"); float fPotionT1DurMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fPotionT1DurMult") ->mValue.getFloat(); @@ -228,7 +220,7 @@ void MWMechanics::Alchemy::updateEffects() const ESM::Potion* MWMechanics::Alchemy::getRecord(const ESM::Potion& toFind) const { - const MWWorld::Store& potions = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& potions = MWBase::Environment::get().getESMStore()->get(); MWWorld::Store::iterator iter = potions.begin(); for (; iter != potions.end(); ++iter) @@ -315,7 +307,7 @@ void MWMechanics::Alchemy::addPotion(const std::string& name) const ESM::Potion* record = getRecord(newRecord); if (!record) - record = MWBase::Environment::get().getWorld()->getStore().insert(newRecord); + record = MWBase::Environment::get().getESMStore()->insert(newRecord); mAlchemist.getClass().getContainerStore(mAlchemist).add(record->mId, 1); } @@ -480,12 +472,8 @@ MWMechanics::Alchemy::TEffectsIterator MWMechanics::Alchemy::endEffects() const bool MWMechanics::Alchemy::knownEffect(unsigned int potionEffectIndex, const MWWorld::Ptr& npc) { float alchemySkill = npc.getClass().getSkill(npc, ESM::Skill::Alchemy); - static const float fWortChanceValue = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() - .find("fWortChanceValue") - ->mValue.getFloat(); + static const float fWortChanceValue + = MWBase::Environment::get().getESMStore()->get().find("fWortChanceValue")->mValue.getFloat(); return (potionEffectIndex <= 1 && alchemySkill >= fWortChanceValue) || (potionEffectIndex <= 3 && alchemySkill >= fWortChanceValue * 2) || (potionEffectIndex <= 5 && alchemySkill >= fWortChanceValue * 3) @@ -573,8 +561,8 @@ std::vector MWMechanics::Alchemy::effectsDescription(const MWWorld: std::vector effects; const auto& item = ptr.get()->mBase; - const auto& gmst = MWBase::Environment::get().getWorld()->getStore().get(); - const auto& mgef = MWBase::Environment::get().getWorld()->getStore().get(); + const auto& gmst = MWBase::Environment::get().getESMStore()->get(); + const auto& mgef = MWBase::Environment::get().getESMStore()->get(); const static auto fWortChanceValue = gmst.find("fWortChanceValue")->mValue.getFloat(); const auto& data = item->mData; diff --git a/apps/openmw/mwmechanics/autocalcspell.cpp b/apps/openmw/mwmechanics/autocalcspell.cpp index 3e88c3370d..e2ad06854d 100644 --- a/apps/openmw/mwmechanics/autocalcspell.cpp +++ b/apps/openmw/mwmechanics/autocalcspell.cpp @@ -30,7 +30,7 @@ namespace MWMechanics std::vector autoCalcNpcSpells(const int* actorSkills, const int* actorAttributes, const ESM::Race* race) { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fNPCbaseMagickaMult = gmst.find("fNPCbaseMagickaMult")->mValue.getFloat(); float baseMagicka = fNPCbaseMagickaMult * actorAttributes[ESM::Attribute::Intelligence]; @@ -62,7 +62,7 @@ namespace MWMechanics std::vector selectedSpells; - const MWWorld::Store& spells = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& spells = MWBase::Environment::get().getESMStore()->get(); // Note: the algorithm heavily depends on the traversal order of the spells. For vanilla-compatible results the // Store must preserve the record ordering as it was in the content files. @@ -150,7 +150,7 @@ namespace MWMechanics std::vector autoCalcPlayerSpells( const int* actorSkills, const int* actorAttributes, const ESM::Race* race) { - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); static const float fPCbaseMagickaMult = esmStore.get().find("fPCbaseMagickaMult")->mValue.getFloat(); @@ -231,11 +231,10 @@ namespace MWMechanics for (const auto& spellEffect : spell->mEffects.mList) { const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(spellEffect.mEffectID); + = MWBase::Environment::get().getESMStore()->get().find(spellEffect.mEffectID); static const int iAutoSpellAttSkillMin = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iAutoSpellAttSkillMin") ->mValue.getInteger(); @@ -264,7 +263,7 @@ namespace MWMechanics for (const ESM::ENAMstruct& effect : spell->mEffects.mList) { const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); + = MWBase::Environment::get().getESMStore()->get().find(effect.mEffectID); int minMagn = 1; int maxMagn = 1; @@ -281,9 +280,8 @@ namespace MWMechanics duration = std::max(1, duration); static const float fEffectCostMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fEffectCostMult") ->mValue.getFloat(); diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index 0aee50de90..bc7ada178d 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -50,7 +50,7 @@ namespace MWMechanics if (!enchantmentName.empty()) { const ESM::Enchantment* enchantment - = MWBase::Environment::get().getWorld()->getStore().get().find(enchantmentName); + = MWBase::Environment::get().getESMStore()->get().find(enchantmentName); if (enchantment->mData.mType == ESM::Enchantment::WhenStrikes) { MWMechanics::CastSpell cast(attacker, victim, fromProjectile); @@ -93,7 +93,7 @@ namespace MWMechanics blocker.getRefData().getBaseNode()->getAttitude() * osg::Vec3f(0, 1, 0), osg::Vec3f(0, 0, 1))); const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fCombatBlockLeftAngle = gmst.find("fCombatBlockLeftAngle")->mValue.getFloat(); if (angleDegrees < fCombatBlockLeftAngle) return false; @@ -205,7 +205,7 @@ namespace MWMechanics if (isSilver && actor.getClass().getNpcStats(actor).isWerewolf()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); damage *= store.get().find("fWereWolfSilverWeaponDamageMult")->mValue.getFloat(); } } @@ -371,9 +371,8 @@ namespace MWMechanics x = std::min(100.f, x + elementResistance); static const float fElementalShieldMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fElementalShieldMult") ->mValue.getFloat(); x = fElementalShieldMult * magnitude * (1.f - 0.01f * x); @@ -410,9 +409,8 @@ namespace MWMechanics if (!godmode) { const float fWeaponDamageMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fWeaponDamageMult") ->mValue.getFloat(); float x = std::max(1.f, fWeaponDamageMult * damage); @@ -439,15 +437,13 @@ namespace MWMechanics } static const float fDamageStrengthBase = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fDamageStrengthBase") ->mValue.getFloat(); static const float fDamageStrengthMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fDamageStrengthMult") ->mValue.getFloat(); damage *= fDamageStrengthBase @@ -458,7 +454,7 @@ namespace MWMechanics void getHandToHandDamage( const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, float& damage, bool& healthdmg, float attackStrength) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); static const float minstrike = store.get().find("fMinHandToHandMult")->mValue.getFloat(); static const float maxstrike = store.get().find("fMaxHandToHandMult")->mValue.getFloat(); damage = static_cast(attacker.getClass().getSkill(attacker, ESM::Skill::HandToHand)); @@ -509,7 +505,7 @@ namespace MWMechanics { // somewhat of a guess, but using the weapon weight makes sense const MWWorld::Store& store - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fFatigueAttackBase = store.find("fFatigueAttackBase")->mValue.getFloat(); static const float fFatigueAttackMult = store.find("fFatigueAttackMult")->mValue.getFloat(); static const float fWeaponFatigueMult = store.find("fWeaponFatigueMult")->mValue.getFloat(); @@ -537,15 +533,13 @@ namespace MWMechanics float d = getAggroDistance(actor1, pos1, pos2); static const int iFightDistanceBase = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iFightDistanceBase") ->mValue.getInteger(); static const float fFightDistanceMultiplier = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fFightDistanceMultiplier") ->mValue.getFloat(); diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index f742e3737a..0ef77f9f5c 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -66,7 +66,7 @@ namespace MWMechanics float normalised = std::floor(max) == 0 ? 1 : std::max(0.0f, current / max); const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fFatigueBase = gmst.find("fFatigueBase")->mValue.getFloat(); static const float fFatigueMult = gmst.find("fFatigueMult")->mValue.getFloat(); diff --git a/apps/openmw/mwmechanics/difficultyscaling.cpp b/apps/openmw/mwmechanics/difficultyscaling.cpp index fc027a03c9..a20bb1eac7 100644 --- a/apps/openmw/mwmechanics/difficultyscaling.cpp +++ b/apps/openmw/mwmechanics/difficultyscaling.cpp @@ -15,12 +15,8 @@ float scaleDamage(float damage, const MWWorld::Ptr& attacker, const MWWorld::Ptr // [-500, 500] const int difficultySetting = std::clamp(Settings::Manager::getInt("difficulty", "Game"), -500, 500); - static const float fDifficultyMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() - .find("fDifficultyMult") - ->mValue.getFloat(); + static const float fDifficultyMult + = MWBase::Environment::get().getESMStore()->get().find("fDifficultyMult")->mValue.getFloat(); float difficultyTerm = 0.01f * difficultySetting; diff --git a/apps/openmw/mwmechanics/disease.hpp b/apps/openmw/mwmechanics/disease.hpp index 6b2b185b44..f4d2cc9067 100644 --- a/apps/openmw/mwmechanics/disease.hpp +++ b/apps/openmw/mwmechanics/disease.hpp @@ -29,9 +29,8 @@ namespace MWMechanics return; float fDiseaseXferChance = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fDiseaseXferChance") ->mValue.getFloat(); @@ -71,9 +70,8 @@ namespace MWMechanics MWBase::Environment::get().getWorld()->applyLoopingParticles(actor); std::string msg = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("sMagicContractDisease") ->mValue.getString(); msg = Misc::StringUtils::format(msg, spell->mName); diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index 044807574f..d44c798666 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -98,7 +98,7 @@ namespace MWMechanics // Try to find a dynamic enchantment with the same stats, create a new one if not found. const ESM::Enchantment* enchantmentPtr = getRecord(enchantment); if (enchantmentPtr == nullptr) - enchantmentPtr = MWBase::Environment::get().getWorld()->getStore().insert(enchantment); + enchantmentPtr = MWBase::Environment::get().getESMStore()->insert(enchantment); // Apply the enchantment const ESM::RefId& newItemId @@ -120,9 +120,8 @@ namespace MWMechanics return; const bool powerfulSoul = getGemCharge() >= MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iSoulAmountForConstantEffect") ->mValue.getInteger(); if ((mObjectType == ESM::Armor::sRecordId) || (mObjectType == ESM::Clothing::sRecordId)) @@ -190,7 +189,7 @@ namespace MWMechanics // No effects added, cost = 0 return 0; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const float fEffectCostMult = store.get().find("fEffectCostMult")->mValue.getFloat(); const float fEnchantmentConstantDurationMult = store.get().find("fEnchantmentConstantDurationMult")->mValue.getFloat(); @@ -223,7 +222,7 @@ namespace MWMechanics const ESM::Enchantment* Enchanting::getRecord(const ESM::Enchantment& toFind) const { const MWWorld::Store& enchantments - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); MWWorld::Store::iterator iter(enchantments.begin()); iter += (enchantments.getSize() - enchantments.getDynamicSize()); for (; iter != enchantments.end(); ++iter) @@ -284,9 +283,8 @@ namespace MWMechanics return 0; float priceMultipler = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fEnchantmentValueMult") ->mValue.getFloat(); int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer( @@ -297,7 +295,7 @@ namespace MWMechanics int Enchanting::getGemCharge() const { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); if (soulEmpty()) return 0; if (mSoulGemPtr.getCellRef().getSoul().empty()) @@ -314,7 +312,7 @@ namespace MWMechanics if (itemEmpty()) return 0; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); return static_cast(mOldItemPtr.getClass().getEnchantmentPoints(mOldItemPtr) * store.get().find("fEnchantmentMult")->mValue.getFloat()); @@ -345,7 +343,7 @@ namespace MWMechanics { const CreatureStats& stats = mEnchanter.getClass().getCreatureStats(mEnchanter); const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); const float a = static_cast(mEnchanter.getClass().getSkill(mEnchanter, ESM::Skill::Enchant)); const float b = static_cast(stats.getAttribute(ESM::Attribute::Intelligence).getModified()); const float c = static_cast(stats.getAttribute(ESM::Attribute::Luck).getModified()); diff --git a/apps/openmw/mwmechanics/inventory.hpp b/apps/openmw/mwmechanics/inventory.hpp index a741e3c4ec..5185d540c6 100644 --- a/apps/openmw/mwmechanics/inventory.hpp +++ b/apps/openmw/mwmechanics/inventory.hpp @@ -17,14 +17,14 @@ namespace MWMechanics template void modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) { - T copy = *MWBase::Environment::get().getWorld()->getStore().get().find(actorId); + T copy = *MWBase::Environment::get().getESMStore()->get().find(actorId); for (auto& it : copy.mInventory.mList) { if (it.mItem == itemId) { const int sign = it.mCount < 1 ? -1 : 1; it.mCount = sign * std::max(it.mCount * sign + amount, 0); - MWBase::Environment::get().getWorld()->getStore().overrideRecord(copy); + MWBase::Environment::get().getESMStore()->overrideRecord(copy); return; } } @@ -34,7 +34,7 @@ namespace MWMechanics cont.mItem = itemId; cont.mCount = amount; copy.mInventory.mList.push_back(cont); - MWBase::Environment::get().getWorld()->getStore().overrideRecord(copy); + MWBase::Environment::get().getESMStore()->overrideRecord(copy); } } } diff --git a/apps/openmw/mwmechanics/levelledlist.cpp b/apps/openmw/mwmechanics/levelledlist.cpp index 4dcafff49f..83e964f2d0 100644 --- a/apps/openmw/mwmechanics/levelledlist.cpp +++ b/apps/openmw/mwmechanics/levelledlist.cpp @@ -49,7 +49,7 @@ namespace MWMechanics const ESM::RefId& item = *candidates[Misc::Rng::rollDice(candidates.size(), prng)]; // Vanilla doesn't fail on nonexistent items in levelled lists - if (!MWBase::Environment::get().getWorld()->getStore().find(item)) + if (!MWBase::Environment::get().getESMStore()->find(item)) { Log(Debug::Warning) << "Warning: ignoring nonexistent item " << item << " in levelled list " << levItem->mId; @@ -57,7 +57,7 @@ namespace MWMechanics } // Is this another levelled item or a real item? - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), item, 1); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), item, 1); if (ref.getPtr().getType() != ESM::ItemLevList::sRecordId && ref.getPtr().getType() != ESM::CreatureLevList::sRecordId) { diff --git a/apps/openmw/mwmechanics/magiceffects.cpp b/apps/openmw/mwmechanics/magiceffects.cpp index 0feac9e6b1..d44d43947a 100644 --- a/apps/openmw/mwmechanics/magiceffects.cpp +++ b/apps/openmw/mwmechanics/magiceffects.cpp @@ -52,7 +52,7 @@ namespace MWMechanics std::string EffectKey::toString() const { const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().search(mId); + = MWBase::Environment::get().getESMStore()->get().search(mId); return getMagicEffectString(*magicEffect, mArg, mArg); } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 23bf892fc4..03fbbdebc3 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -41,9 +41,8 @@ namespace float getFightDispositionBias(float disposition) { static const float fFightDispMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fFightDispMult") ->mValue.getFloat(); return ((50.f - disposition) * fFightDispMult); @@ -53,7 +52,7 @@ namespace const MWMechanics::NpcStats& stats, float& rating1, float& rating2, float& rating3, bool player) { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); float persTerm = stats.getAttribute(ESM::Attribute::Personality).getModified() / gmst.find("fPersonalityMod")->mValue.getFloat(); @@ -140,7 +139,7 @@ namespace MWMechanics creatureStats.setAttribute(ESM::Attribute::Endurance, player->mNpdt.mEndurance); creatureStats.setAttribute(ESM::Attribute::Personality, player->mNpdt.mPersonality); creatureStats.setAttribute(ESM::Attribute::Luck, player->mNpdt.mLuck); - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); // race if (mRaceSelected) @@ -512,7 +511,7 @@ namespace MWMechanics const MWMechanics::NpcStats& playerStats = playerPtr.getClass().getNpcStats(playerPtr); const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fDispRaceMod = gmst.find("fDispRaceMod")->mValue.getFloat(); if (npc->mBase->mRace == player->mBase->mRace) x += fDispRaceMod; @@ -623,7 +622,7 @@ namespace MWMechanics const MWWorld::Ptr& npc, PersuasionType type, bool& success, int& tempChange, int& permChange) { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); MWMechanics::NpcStats& npcStats = npc.getClass().getNpcStats(npc); @@ -851,7 +850,7 @@ namespace MWMechanics { // Build a list of known bound item ID's const MWWorld::Store& gameSettings - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); for (const ESM::GameSetting& currentSetting : gameSettings) { @@ -1145,7 +1144,7 @@ namespace MWMechanics std::vector neighbors; osg::Vec3f from(player.getRefData().getPosition().asVec3()); - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); float radius = esmStore.get().find("fAlarmRadius")->mValue.getFloat(); mActors.getObjectsInRange(from, radius, neighbors); @@ -1223,7 +1222,7 @@ namespace MWMechanics const MWWorld::Ptr& player, const MWWorld::Ptr& victim, OffenseType type, const ESM::RefId& factionId, int arg) { const MWWorld::Store& store - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); if (type == OT_Murder && !victim.isEmpty()) victim.getClass().getCreatureStats(victim).notifyMurder(); @@ -1261,7 +1260,7 @@ namespace MWMechanics // Make surrounding actors within alarm distance respond to the crime std::vector neighbors; - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); osg::Vec3f from(player.getRefData().getPosition().asVec3()); float radius = esmStore.get().find("fAlarmRadius")->mValue.getFloat(); @@ -1534,7 +1533,7 @@ namespace MWMechanics return false; const MWWorld::Store& store - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); @@ -1788,8 +1787,7 @@ namespace MWMechanics && MWBase::Environment::get().getWorld()->getGlobalInt(MWWorld::Globals::sPCKnownWerewolf))) { const ESM::GameSetting* iWerewolfFightMod - = MWBase::Environment::get().getWorld()->getStore().get().find( - "iWerewolfFightMod"); + = MWBase::Environment::get().getESMStore()->get().find("iWerewolfFightMod"); fight += iWerewolfFightMod->mValue.getInteger(); } } @@ -1887,7 +1885,7 @@ namespace MWMechanics // Witnesses of the player's transformation will make them a globally known werewolf std::vector neighbors; const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); getActorsInRange( actor.getRefData().getPosition().asVec3(), gmst.find("fAlarmRadius")->mValue.getFloat(), neighbors); @@ -1928,7 +1926,7 @@ namespace MWMechanics void MechanicsManager::applyWerewolfAcrobatics(const MWWorld::Ptr& actor) { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); MWMechanics::NpcStats& stats = actor.getClass().getNpcStats(actor); auto& skill = stats.getSkill(ESM::Skill::Acrobatics); skill.setModifier(gmst.find("fWerewolfAcrobatics")->mValue.getFloat() - skill.getModified()); diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 60278c0678..6f56af46ad 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -84,8 +84,7 @@ void MWMechanics::NpcStats::raiseRank(const ESM::RefId& faction) if (it != mFactionRank.end()) { // Does the next rank exist? - const ESM::Faction* factionPtr - = MWBase::Environment::get().getWorld()->getStore().get().find(faction); + const ESM::Faction* factionPtr = MWBase::Environment::get().getESMStore()->get().find(faction); if (it->second + 1 < 10 && !factionPtr->mRanks[it->second + 1].empty()) it->second += 1; } @@ -122,7 +121,7 @@ void MWMechanics::NpcStats::expell(const ESM::RefId& factionID) if (mExpelled.find(factionID) == mExpelled.end()) { std::string message = "#{sExpelledMessage}"; - message += MWBase::Environment::get().getWorld()->getStore().get().find(factionID)->mName; + message += MWBase::Environment::get().getESMStore()->get().find(factionID)->mName; MWBase::Environment::get().getWindowManager()->messageBox(message); mExpelled.insert(factionID); } @@ -157,8 +156,7 @@ float MWMechanics::NpcStats::getSkillProgressRequirement(int skillIndex, const E { float progressRequirement = static_cast(1 + getSkill(skillIndex).getBase()); - const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& gmst = MWBase::Environment::get().getESMStore()->get(); float typeFactor = gmst.find("fMiscSkillBonus")->mValue.getFloat(); @@ -183,7 +181,7 @@ float MWMechanics::NpcStats::getSkillProgressRequirement(int skillIndex, const E float specialisationFactor = 1; - const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get().find(skillIndex); + const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get().find(skillIndex); if (skill->mData.mSpecialization == class_.mData.mSpecialization) { specialisationFactor = gmst.find("fSpecialSkillBonus")->mValue.getFloat(); @@ -198,7 +196,7 @@ float MWMechanics::NpcStats::getSkillProgressRequirement(int skillIndex, const E void MWMechanics::NpcStats::useSkill(int skillIndex, const ESM::Class& class_, int usageType, float extraFactor) { - const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get().find(skillIndex); + const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get().find(skillIndex); float skillGain = 1; if (usageType >= 4) throw std::runtime_error("skill usage type out of range"); @@ -231,8 +229,7 @@ void MWMechanics::NpcStats::increaseSkill( base += 1; - const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& gmst = MWBase::Environment::get().getESMStore()->get(); // is this a minor or major skill? int increase = gmst.find("iLevelupMiscMultAttriubte")->mValue.getInteger(); // Note: GMST has a typo @@ -252,7 +249,7 @@ void MWMechanics::NpcStats::increaseSkill( } } - const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get().find(skillIndex); + const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get().find(skillIndex); mSkillIncreases[skill->mData.mAttribute] += increase; mSpecIncreases[skill->mData.mSpecialization] += gmst.find("iLevelupSpecialization")->mValue.getInteger(); @@ -288,8 +285,7 @@ int MWMechanics::NpcStats::getLevelProgress() const void MWMechanics::NpcStats::levelUp() { - const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& gmst = MWBase::Environment::get().getESMStore()->get(); mLevelProgress -= gmst.find("iLevelUpTotal")->mValue.getInteger(); mLevelProgress = std::max(0, mLevelProgress); // might be necessary when levelup was invoked via console @@ -333,12 +329,7 @@ int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const std::stringstream gmst; gmst << "iLevelUp" << std::setfill('0') << std::setw(2) << num << "Mult"; - return MWBase::Environment::get() - .getWorld() - ->getStore() - .get() - .find(gmst.str()) - ->mValue.getInteger(); + return MWBase::Environment::get().getESMStore()->get().find(gmst.str())->mValue.getInteger(); } int MWMechanics::NpcStats::getSkillIncreasesForSpecialization(int spec) const @@ -392,8 +383,7 @@ bool MWMechanics::NpcStats::hasSkillsForRank(const ESM::RefId& factionId, int ra if (rank < 0 || rank >= 10) throw std::runtime_error("rank index out of range"); - const ESM::Faction& faction - = *MWBase::Environment::get().getWorld()->getStore().get().find(factionId); + const ESM::Faction& faction = *MWBase::Environment::get().getESMStore()->get().find(factionId); std::vector skills; @@ -517,7 +507,7 @@ void MWMechanics::NpcStats::readState(const ESM::CreatureStats& state) void MWMechanics::NpcStats::readState(const ESM::NpcStats& state) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); for (auto iter(state.mFactions.begin()); iter != state.mFactions.end(); ++iter) if (store.get().search(iter->first)) diff --git a/apps/openmw/mwmechanics/pickpocket.cpp b/apps/openmw/mwmechanics/pickpocket.cpp index 58c871880f..5e153191cf 100644 --- a/apps/openmw/mwmechanics/pickpocket.cpp +++ b/apps/openmw/mwmechanics/pickpocket.cpp @@ -37,15 +37,13 @@ namespace MWMechanics float pcSneak = static_cast(mThief.getClass().getSkill(mThief, ESM::Skill::Sneak)); int iPickMinChance = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iPickMinChance") ->mValue.getInteger(); int iPickMaxChance = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iPickMaxChance") ->mValue.getInteger(); @@ -66,9 +64,8 @@ namespace MWMechanics { float stackValue = static_cast(item.getClass().getValue(item) * count); float fPickPocketMod = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fPickPocketMod") ->mValue.getFloat(); float valueTerm = 10 * fPickPocketMod * stackValue; diff --git a/apps/openmw/mwmechanics/recharge.cpp b/apps/openmw/mwmechanics/recharge.cpp index 2f96ae0133..b9a6a3ca76 100644 --- a/apps/openmw/mwmechanics/recharge.cpp +++ b/apps/openmw/mwmechanics/recharge.cpp @@ -26,9 +26,8 @@ namespace MWMechanics return false; static const float fMagicItemRechargePerSecond = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fMagicItemRechargePerSecond") ->mValue.getFloat(); @@ -62,13 +61,12 @@ namespace MWMechanics if (roll < x) { const ESM::RefId& soul = gem.getCellRef().getSoul(); - const ESM::Creature* creature - = MWBase::Environment::get().getWorld()->getStore().get().find(soul); + const ESM::Creature* creature = MWBase::Environment::get().getESMStore()->get().find(soul); float restored = creature->mData.mSoul * (roll / x); const ESM::Enchantment* enchantment - = MWBase::Environment::get().getWorld()->getStore().get().find( + = MWBase::Environment::get().getESMStore()->get().find( item.getClass().getEnchantment(item)); item.getCellRef().setEnchantmentCharge(std::min( item.getCellRef().getEnchantmentCharge() + restored, static_cast(enchantment->mData.mCharge))); @@ -88,9 +86,8 @@ namespace MWMechanics if (gem.getRefData().getCount() == 0) { std::string message = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("sNotifyMessage51") ->mValue.getString(); message = Misc::StringUtils::format(message, gem.getClass().getName(gem)); diff --git a/apps/openmw/mwmechanics/repair.cpp b/apps/openmw/mwmechanics/repair.cpp index 39f9ee224e..4894b93e7f 100644 --- a/apps/openmw/mwmechanics/repair.cpp +++ b/apps/openmw/mwmechanics/repair.cpp @@ -38,9 +38,8 @@ namespace MWMechanics float armorerSkill = player.getClass().getSkill(player, ESM::Skill::Armorer); float fRepairAmountMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fRepairAmountMult") ->mValue.getFloat(); @@ -88,9 +87,8 @@ namespace MWMechanics store.remove(mTool, 1); std::string message = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("sNotifyMessage51") ->mValue.getString(); message = Misc::StringUtils::format(message, mTool.getClass().getName(mTool)); diff --git a/apps/openmw/mwmechanics/security.cpp b/apps/openmw/mwmechanics/security.cpp index 6b0f7fc110..8c72fbd38f 100644 --- a/apps/openmw/mwmechanics/security.cpp +++ b/apps/openmw/mwmechanics/security.cpp @@ -41,9 +41,8 @@ namespace MWMechanics float pickQuality = lockpick.get()->mBase->mData.mQuality; float fPickLockMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fPickLockMult") ->mValue.getFloat(); @@ -88,13 +87,12 @@ namespace MWMechanics float probeQuality = probe.get()->mBase->mData.mQuality; const ESM::Spell* trapSpell - = MWBase::Environment::get().getWorld()->getStore().get().find(trap.getCellRef().getTrap()); + = MWBase::Environment::get().getESMStore()->get().find(trap.getCellRef().getTrap()); int trapSpellPoints = trapSpell->mData.mCost; float fTrapCostMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fTrapCostMult") ->mValue.getFloat(); diff --git a/apps/openmw/mwmechanics/setbaseaisetting.hpp b/apps/openmw/mwmechanics/setbaseaisetting.hpp index 780ff2ca76..07e69dddd2 100644 --- a/apps/openmw/mwmechanics/setbaseaisetting.hpp +++ b/apps/openmw/mwmechanics/setbaseaisetting.hpp @@ -15,7 +15,7 @@ namespace MWMechanics template void setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) { - T copy = *MWBase::Environment::get().getWorld()->getStore().get().find(id); + T copy = *MWBase::Environment::get().getESMStore()->get().find(id); switch (setting) { case MWMechanics::AiSetting::Hello: @@ -33,7 +33,7 @@ namespace MWMechanics default: assert(false); } - MWBase::Environment::get().getWorld()->getStore().overrideRecord(copy); + MWBase::Environment::get().getESMStore()->overrideRecord(copy); } } diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index d6ecc34117..195bda5ddf 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -167,7 +167,7 @@ namespace MWMechanics bool containsRecastable = false; std::vector magicEffects; magicEffects.reserve(effects.mList.size()); - const auto& store = MWBase::Environment::get().getWorld()->getStore().get(); + const auto& store = MWBase::Environment::get().getESMStore()->get(); for (const ESM::ENAMstruct& effect : effects.mList) { if (effect.mRange == range) @@ -278,7 +278,7 @@ namespace MWMechanics bool CastSpell::cast(const ESM::RefId& id) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); if (const auto spell = store.get().search(id)) return cast(spell); @@ -301,7 +301,7 @@ namespace MWMechanics mId = item.getCellRef().getRefId(); const ESM::Enchantment* enchantment - = MWBase::Environment::get().getWorld()->getStore().get().find(enchantmentName); + = MWBase::Environment::get().getESMStore()->get().find(enchantmentName); mSlot = slot; @@ -336,7 +336,7 @@ namespace MWMechanics { short effectId = enchantment->mEffects.mList.front().mEffectID; const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(effectId); + = MWBase::Environment::get().getESMStore()->get().find(effectId); school = magicEffect->mData.mSchool; } @@ -472,7 +472,7 @@ namespace MWMechanics effect.mRange = ESM::RT_Self; effect.mArea = 0; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const auto magicEffect = store.get().find(effect.mEffectID); const MWMechanics::CreatureStats& creatureStats = mCaster.getClass().getCreatureStats(mCaster); @@ -533,7 +533,7 @@ namespace MWMechanics void CastSpell::playSpellCastingEffects(const std::vector& effects) const { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); std::vector addedEffects; const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); @@ -626,9 +626,9 @@ namespace MWMechanics // Add VFX const ESM::Static* castStatic; if (!magicEffect.mHit.empty()) - castStatic = MWBase::Environment::get().getWorld()->getStore().get().find(magicEffect.mHit); + castStatic = MWBase::Environment::get().getESMStore()->get().find(magicEffect.mHit); else - castStatic = MWBase::Environment::get().getWorld()->getStore().get().find( + castStatic = MWBase::Environment::get().getESMStore()->get().find( ESM::RefId::stringRefId("VFX_DefaultHit")); bool loop = (magicEffect.mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0; diff --git a/apps/openmw/mwmechanics/spelleffects.cpp b/apps/openmw/mwmechanics/spelleffects.cpp index 133ddf0151..1ccb8f3396 100644 --- a/apps/openmw/mwmechanics/spelleffects.cpp +++ b/apps/openmw/mwmechanics/spelleffects.cpp @@ -267,7 +267,7 @@ namespace if (effect.mFlags & ESM::ActiveEffect::Flag_Applied && effect.mEffectId != ESM::MagicEffect::Corprus) { const auto* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectId); + = MWBase::Environment::get().getESMStore()->get().find(effect.mEffectId); if (magicEffect->mData.mFlags & ESM::MagicEffect::Flags::AppliedOnce && (!harmfulOnly || magicEffect->mData.mFlags & ESM::MagicEffect::Flags::Harmful)) return true; @@ -277,7 +277,7 @@ namespace void absorbSpell(const ESM::RefId& spellId, const MWWorld::Ptr& caster, const MWWorld::Ptr& target) { - const auto& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const auto& esmStore = *MWBase::Environment::get().getESMStore(); const ESM::Static* absorbStatic = esmStore.get().find(ESM::RefId::stringRefId("VFX_Absorb")); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target); if (animation && !absorbStatic->mModel.empty()) @@ -359,7 +359,7 @@ namespace { const ESM::Spell* spell = nullptr; if (spellParams.getType() == ESM::ActiveSpells::Type_Temporary) - spell = MWBase::Environment::get().getWorld()->getStore().get().search(spellParams.getId()); + spell = MWBase::Environment::get().getESMStore()->get().search(spellParams.getId()); float magnitudeMult = MWMechanics::getEffectMultiplier(effect.mEffectId, target, caster, spell, &magnitudes); if (magnitudeMult == 0) @@ -431,8 +431,7 @@ namespace MWMechanics if (params.getType() == ESM::ActiveSpells::Type_Temporary) { const ESM::Spell* spell - = MWBase::Environment::get().getWorld()->getStore().get().search( - params.getId()); + = MWBase::Environment::get().getESMStore()->get().search(params.getId()); if (spell && spell->mData.mType == ESM::Spell::ST_Spell) { auto& prng = MWBase::Environment::get().getWorld()->getPrng(); diff --git a/apps/openmw/mwmechanics/spelllist.cpp b/apps/openmw/mwmechanics/spelllist.cpp index 4a7a29bc07..1e27ca5763 100644 --- a/apps/openmw/mwmechanics/spelllist.cpp +++ b/apps/openmw/mwmechanics/spelllist.cpp @@ -18,16 +18,16 @@ namespace template const std::vector getSpellList(const ESM::RefId& id) { - return MWBase::Environment::get().getWorld()->getStore().get().find(id)->mSpells.mList; + return MWBase::Environment::get().getESMStore()->get().find(id)->mSpells.mList; } template bool withBaseRecord(const ESM::RefId& id, const std::function&)>& function) { - T copy = *MWBase::Environment::get().getWorld()->getStore().get().find(id); + T copy = *MWBase::Environment::get().getESMStore()->get().find(id); bool changed = function(copy.mSpells.mList); if (changed) - MWBase::Environment::get().getWorld()->getStore().overrideRecord(copy); + MWBase::Environment::get().getESMStore()->overrideRecord(copy); return changed; } } @@ -68,7 +68,7 @@ namespace MWMechanics const ESM::Spell* SpellList::getSpell(const ESM::RefId& id) { - return MWBase::Environment::get().getWorld()->getStore().get().find(id); + return MWBase::Environment::get().getESMStore()->get().find(id); } void SpellList::add(const ESM::Spell* spell) diff --git a/apps/openmw/mwmechanics/spellpriority.cpp b/apps/openmw/mwmechanics/spellpriority.cpp index af946f43fc..839e6700ec 100644 --- a/apps/openmw/mwmechanics/spellpriority.cpp +++ b/apps/openmw/mwmechanics/spellpriority.cpp @@ -32,7 +32,7 @@ namespace if (effectFilter == -1) { const ESM::Spell* spell - = MWBase::Environment::get().getWorld()->getStore().get().search(it->getId()); + = MWBase::Environment::get().getESMStore()->get().search(it->getId()); if (!spell || spell->mData.mType != ESM::Spell::ST_Spell) continue; } @@ -44,7 +44,7 @@ namespace if (effectFilter != -1 && effectId != effectFilter) continue; const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(effectId); + = MWBase::Environment::get().getESMStore()->get().find(effectId); if (effect.mDuration <= 3) // Don't attempt to dispel if effect runs out shortly anyway continue; @@ -127,7 +127,7 @@ namespace MWMechanics if (actor.getClass().isNpc()) { const ESM::RefId& raceid = actor.get()->mBase->mRace; - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(raceid); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(raceid); if (race->mPowers.exists(spell->mId)) return 0.f; } @@ -147,9 +147,8 @@ namespace MWMechanics if (ptr.getClass().getEnchantment(ptr).empty()) return 0.f; - const ESM::Enchantment* enchantment - = MWBase::Environment::get().getWorld()->getStore().get().find( - ptr.getClass().getEnchantment(ptr)); + const ESM::Enchantment* enchantment = MWBase::Environment::get().getESMStore()->get().find( + ptr.getClass().getEnchantment(ptr)); // Spells don't stack, so early out if the spell is still active on the target int types = getRangeTypes(enchantment->mEffects); @@ -372,8 +371,7 @@ namespace MWMechanics { // Beast races can't wear helmets or boots const ESM::RefId& raceid = actor.get()->mBase->mRace; - const ESM::Race* race - = MWBase::Environment::get().getWorld()->getStore().get().find(raceid); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(raceid); if (race->mData.mFlags & ESM::Race::Beast) return 0.f; } @@ -640,7 +638,7 @@ namespace MWMechanics } const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); + = MWBase::Environment::get().getESMStore()->get().find(effect.mEffectID); if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful) { rating *= -1.f; @@ -694,7 +692,7 @@ namespace MWMechanics float rating = 0.f; const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fAIMagicSpellMult = gmst.find("fAIMagicSpellMult")->mValue.getFloat(); static const float fAIRangeMagicSpellMult = gmst.find("fAIRangeMagicSpellMult")->mValue.getFloat(); @@ -716,7 +714,7 @@ namespace MWMechanics float vanillaRateSpell(const ESM::Spell* spell, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fAIMagicSpellMult = gmst.find("fAIMagicSpellMult")->mValue.getFloat(); static const float fAIRangeMagicSpellMult = gmst.find("fAIRangeMagicSpellMult")->mValue.getFloat(); diff --git a/apps/openmw/mwmechanics/spellresistance.cpp b/apps/openmw/mwmechanics/spellresistance.cpp index 0c27f9c197..0fb864aa8a 100644 --- a/apps/openmw/mwmechanics/spellresistance.cpp +++ b/apps/openmw/mwmechanics/spellresistance.cpp @@ -33,8 +33,7 @@ namespace MWMechanics if (ESM::MagicEffect::getResistanceEffect(effectId) == -1) return 0.f; - const auto magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(effectId); + const auto magicEffect = MWBase::Environment::get().getESMStore()->get().find(effectId); const MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor); const MWMechanics::MagicEffects* magicEffects = &stats.getMagicEffects(); diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index f1b2cbed5e..f9c2a2472b 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -208,7 +208,7 @@ namespace MWMechanics for (const ESM::RefId& id : state.mSpells) { // Discard spells that are no longer available due to changed content files - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().search(id); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().search(id); if (spell) { addSpell(spell); @@ -220,15 +220,14 @@ namespace MWMechanics // Add spells from the base record for (const ESM::RefId& id : baseSpells) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().search(id); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().search(id); if (spell) addSpell(spell); } for (auto it = state.mUsedPowers.begin(); it != state.mUsedPowers.end(); ++it) { - const ESM::Spell* spell - = MWBase::Environment::get().getWorld()->getStore().get().search(it->first); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().search(it->first); if (!spell) continue; mUsedPowers.emplace_back(spell, MWWorld::TimeStamp(it->second)); @@ -238,8 +237,7 @@ namespace MWMechanics // only in old saves. Convert data to the new approach. for (auto it = state.mPermanentSpellEffects.begin(); it != state.mPermanentSpellEffects.end(); ++it) { - const ESM::Spell* spell - = MWBase::Environment::get().getWorld()->getStore().get().search(it->first); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().search(it->first); if (!spell) continue; @@ -293,7 +291,7 @@ namespace MWMechanics bool Spells::setSpells(const ESM::RefId& actorId) { bool result; - std::tie(mSpellList, result) = MWBase::Environment::get().getWorld()->getStore().getSpellList(actorId); + std::tie(mSpellList, result) = MWBase::Environment::get().getESMStore()->getSpellList(actorId); mSpellList->addListener(this); addAllToInstance(mSpellList->getSpells()); return result; @@ -303,7 +301,7 @@ namespace MWMechanics { for (const ESM::RefId& id : spells) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().search(id); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().search(id); if (spell) addSpell(spell); else diff --git a/apps/openmw/mwmechanics/spellutil.cpp b/apps/openmw/mwmechanics/spellutil.cpp index a15aa9790c..344597bca0 100644 --- a/apps/openmw/mwmechanics/spellutil.cpp +++ b/apps/openmw/mwmechanics/spellutil.cpp @@ -31,7 +31,7 @@ namespace MWMechanics float calcEffectCost( const ESM::ENAMstruct& effect, const ESM::MagicEffect* magicEffect, const EffectCostMethod method) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); if (!magicEffect) magicEffect = store.get().find(effect.mEffectID); bool hasMagnitude = !(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude); @@ -104,7 +104,7 @@ namespace MWMechanics { float x = static_cast(effect.mDuration); const auto magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); + = MWBase::Environment::get().getESMStore()->get().find(effect.mEffectID); if (!(magicEffect->mData.mFlags & ESM::MagicEffect::AppliedOnce)) x = std::max(1.f, x); @@ -115,9 +115,8 @@ namespace MWMechanics if (effect.mRange == ESM::RT_Target) x *= 1.5f; static const float fEffectCostMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fEffectCostMult") ->mValue.getFloat(); x *= fEffectCostMult; @@ -183,7 +182,7 @@ namespace MWMechanics float getSpellSuccessChance( const ESM::RefId& spellId, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap, bool checkMagicka) { - if (const auto spell = MWBase::Environment::get().getWorld()->getStore().get().search(spellId)) + if (const auto spell = MWBase::Environment::get().getESMStore()->get().search(spellId)) return getSpellSuccessChance(spell, actor, effectiveSchool, cap, checkMagicka); return 0.f; } @@ -209,7 +208,7 @@ namespace MWMechanics bool spellIncreasesSkill(const ESM::RefId& spellId) { - const auto spell = MWBase::Environment::get().getWorld()->getStore().get().search(spellId); + const auto spell = MWBase::Environment::get().getESMStore()->get().search(spellId); return spell && spellIncreasesSkill(spell); } } diff --git a/apps/openmw/mwmechanics/summoning.cpp b/apps/openmw/mwmechanics/summoning.cpp index a651d18c1f..16316989f7 100644 --- a/apps/openmw/mwmechanics/summoning.cpp +++ b/apps/openmw/mwmechanics/summoning.cpp @@ -63,12 +63,8 @@ namespace MWMechanics for (const auto& it : summonMapToGameSetting) { - summonMap[it.first] = ESM::RefId::stringRefId(MWBase::Environment::get() - .getWorld() - ->getStore() - .get() - .find(it.second) - ->mValue.getString()); + summonMap[it.first] = ESM::RefId::stringRefId( + MWBase::Environment::get().getESMStore()->get().find(it.second)->mValue.getString()); } return summonMap; } diff --git a/apps/openmw/mwmechanics/trading.cpp b/apps/openmw/mwmechanics/trading.cpp index 0fceda46a4..9500897f25 100644 --- a/apps/openmw/mwmechanics/trading.cpp +++ b/apps/openmw/mwmechanics/trading.cpp @@ -30,7 +30,7 @@ namespace MWMechanics } const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); // Is the player buying? bool buying = (merchantOffer < 0); diff --git a/apps/openmw/mwmechanics/weaponpriority.cpp b/apps/openmw/mwmechanics/weaponpriority.cpp index d5f7ccf517..14ee1d7c02 100644 --- a/apps/openmw/mwmechanics/weaponpriority.cpp +++ b/apps/openmw/mwmechanics/weaponpriority.cpp @@ -170,7 +170,7 @@ namespace MWMechanics const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); static const float fAIMeleeWeaponMult = gmst.find("fAIMeleeWeaponMult")->mValue.getFloat(); static const float fAIMeleeArmorMult = gmst.find("fAIMeleeArmorMult")->mValue.getFloat(); diff --git a/apps/openmw/mwphysics/movementsolver.cpp b/apps/openmw/mwphysics/movementsolver.cpp index 846be640e2..8ba9f44c73 100644 --- a/apps/openmw/mwphysics/movementsolver.cpp +++ b/apps/openmw/mwphysics/movementsolver.cpp @@ -177,9 +177,8 @@ namespace MWPhysics float angleDegrees = osg::RadiansToDegrees( std::acos(stormDirection * velocity / (stormDirection.length() * velocity.length()))); static const float fStromWalkMult = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fStromWalkMult") ->mValue.getFloat(); velocity *= 1.f - (fStromWalkMult * (angleDegrees / 180.f)); diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 26fecd93b9..d2076a6280 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -77,7 +77,7 @@ namespace if (!isPlayer || !MWBase::Environment::get().getWorld()->getGodModeState()) { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); const float fFatigueJumpBase = gmst.find("fFatigueJumpBase")->mValue.getFloat(); const float fFatigueJumpMult = gmst.find("fFatigueJumpMult")->mValue.getFloat(); const float normalizedEncumbrance = std::min(1.f, ptr.getClass().getNormalizedEncumbrance(ptr)); @@ -209,7 +209,7 @@ namespace MWPhysics // Use cone shape as fallback const MWWorld::Store& store - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); btConeShape shape(osg::DegreesToRadians(store.find("fCombatAngleXY")->mValue.getFloat() / 2.0f), queryDistance); shape.setLocalScaling(btVector3( @@ -988,9 +988,8 @@ namespace MWPhysics , mSwimLevel(waterlevel - (actor.getRenderingHalfExtents().z() * 2 * MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fSwimHeightScale") ->mValue.getFloat())) , mSlowFall(slowFall) diff --git a/apps/openmw/mwrender/actoranimation.cpp b/apps/openmw/mwrender/actoranimation.cpp index c71e4f0afd..fa5b2c9532 100644 --- a/apps/openmw/mwrender/actoranimation.cpp +++ b/apps/openmw/mwrender/actoranimation.cpp @@ -112,7 +112,7 @@ namespace MWRender // Try to recover the body part model, use ground model as a fallback otherwise. if (!bodyparts.empty()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const MWWorld::Store& partStore = store.get(); for (const auto& part : bodyparts) { diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 9813c68a06..034e6c1bc3 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1413,7 +1413,7 @@ namespace MWRender // given race and gender as well Since it is a quite rare case, there should not be a noticable // performance loss Note: consider that player and werewolves have no custom animation files // attached for now - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::Race* race = store.get().find(ref->mBase->mRace); bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0; diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index d2e79d8af1..d8b0889aa3 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -290,7 +290,7 @@ namespace MWRender void GlobalMap::render() { - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); // get the size of the world MWWorld::Store::iterator it = esmStore.get().extBegin(); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 9e98b2e6ff..14558e8047 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -56,7 +56,7 @@ namespace if (sVampireMapping.find(thisCombination) == sVampireMapping.end()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); for (const ESM::BodyPart& bodypart : store.get()) { if (!bodypart.mData.mVampire) @@ -463,7 +463,7 @@ namespace MWRender for (size_t i = 0; i < ESM::PRT_Count; i++) removeIndividualPart((ESM::PartReferenceType)i); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const ESM::Race* race = store.get().find(mNpc->mRace); NpcType curType = getNpcType(); bool isWerewolf = (curType == Type_Werewolf); @@ -873,7 +873,7 @@ namespace MWRender void NpcAnimation::addPartGroup(int group, int priority, const std::vector& parts, bool enchantedGlow, osg::Vec4f* glowColor) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const MWWorld::Store& partStore = store.get(); const char* ext = (mViewMode == VM_FirstPerson) ? ".1st" : ""; @@ -1201,7 +1201,7 @@ namespace MWRender if (werewolf) return parts; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); for (const ESM::BodyPart& bodypart : store.get()) { diff --git a/apps/openmw/mwrender/terrainstorage.cpp b/apps/openmw/mwrender/terrainstorage.cpp index fc3b77a4e6..c85ee62f88 100644 --- a/apps/openmw/mwrender/terrainstorage.cpp +++ b/apps/openmw/mwrender/terrainstorage.cpp @@ -28,7 +28,7 @@ namespace MWRender bool TerrainStorage::hasData(int cellX, int cellY) { - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); const ESM::Land* land = esmStore.get().search(cellX, cellY); return land != nullptr; @@ -41,7 +41,7 @@ namespace MWRender maxX = 0; maxY = 0; - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); MWWorld::Store::iterator it = esmStore.get().begin(); for (; it != esmStore.get().end(); ++it) @@ -73,7 +73,7 @@ namespace MWRender const ESM::LandTexture* TerrainStorage::getLandTexture(int index, short plugin) { - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); return esmStore.get().search(index, plugin); } diff --git a/apps/openmw/mwrender/weaponanimation.cpp b/apps/openmw/mwrender/weaponanimation.cpp index 42f47b21fc..c19062168e 100644 --- a/apps/openmw/mwrender/weaponanimation.cpp +++ b/apps/openmw/mwrender/weaponanimation.cpp @@ -114,7 +114,7 @@ namespace MWRender * osg::Quat(actor.getRefData().getPosition().rot[2], osg::Vec3f(0, 0, -1)); const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); MWMechanics::applyFatigueLoss(actor, *weapon, attackStrength); diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index 3feabf43cc..b6acbd246b 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -167,7 +167,7 @@ namespace MWScript if (cellID.empty()) return; - if (!MWBase::Environment::get().getWorld()->getStore().get().search(cellID)) + if (!MWBase::Environment::get().getESMStore()->get().search(cellID)) return; MWMechanics::AiEscort escortPackage(actorID, cellID, static_cast(duration), x, y, z, repeat); diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index cba07419de..b1ec747f3d 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -55,14 +55,13 @@ namespace MWScript const ESM::RefId* script = nullptr; bool reference = false; - if (const ESM::Script* scriptRecord - = MWBase::Environment::get().getWorld()->getStore().get().search(id)) + if (const ESM::Script* scriptRecord = MWBase::Environment::get().getESMStore()->get().search(id)) { script = &scriptRecord->mId; } else { - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), id); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), id); script = &ref.getPtr().getClass().getScript(ref.getPtr()); reference = true; @@ -79,7 +78,7 @@ namespace MWScript bool CompilerContext::isId(const ESM::RefId& name) const { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); return store.get().search(name) || store.get().search(name) || store.get().search(name) || store.get().search(name) diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 243934abfe..e664dfbd45 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -67,7 +67,7 @@ namespace = MWMechanics::getLevelledItem(itemPtr.get()->mBase, false, prng); if (itemId.empty()) return; - MWWorld::ManualRef manualRef(MWBase::Environment::get().getWorld()->getStore(), itemId, 1); + MWWorld::ManualRef manualRef(*MWBase::Environment::get().getESMStore(), itemId, 1); addRandomToStore(manualRef.getPtr(), count, store, false); } } @@ -105,7 +105,7 @@ namespace MWScript item = ESM::RefId::stringRefId("gold_001"); // Check if "item" can be placed in a container - MWWorld::ManualRef manualRef(MWBase::Environment::get().getWorld()->getStore(), item, 1); + MWWorld::ManualRef manualRef(*MWBase::Environment::get().getESMStore(), item, 1); MWWorld::Ptr itemPtr = manualRef.getPtr(); bool isLevelledList = itemPtr.getClass().getType() == ESM::ItemLevList::sRecordId; if (!isLevelledList) @@ -113,7 +113,7 @@ namespace MWScript // Explicit calls to non-unique actors affect the base record if (!R::implicit && ptr.getClass().isActor() - && MWBase::Environment::get().getWorld()->getStore().getRefCount(ptr.getCellRef().getRefId()) > 1) + && MWBase::Environment::get().getESMStore()->getRefCount(ptr.getCellRef().getRefId()) > 1) { ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, count); return; @@ -125,7 +125,7 @@ namespace MWScript { ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, count); const ESM::Container* baseRecord - = MWBase::Environment::get().getWorld()->getStore().get().find( + = MWBase::Environment::get().getESMStore()->get().find( ptr.getCellRef().getRefId()); const auto& ptrs = MWBase::Environment::get().getWorld()->getAll(ptr.getCellRef().getRefId()); for (const auto& container : ptrs) @@ -222,7 +222,7 @@ namespace MWScript // Explicit calls to non-unique actors affect the base record if (!R::implicit && ptr.getClass().isActor() - && MWBase::Environment::get().getWorld()->getStore().getRefCount(ptr.getCellRef().getRefId()) > 1) + && MWBase::Environment::get().getESMStore()->getRefCount(ptr.getCellRef().getRefId()) > 1) { ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, -count); return; @@ -233,7 +233,7 @@ namespace MWScript { ptr.getClass().modifyBaseInventory(ptr.getCellRef().getRefId(), item, -count); const ESM::Container* baseRecord - = MWBase::Environment::get().getWorld()->getStore().get().find( + = MWBase::Environment::get().getESMStore()->get().find( ptr.getCellRef().getRefId()); const auto& ptrs = MWBase::Environment::get().getWorld()->getAll(ptr.getCellRef().getRefId()); for (const auto& container : ptrs) @@ -298,7 +298,7 @@ namespace MWScript MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr); auto found = invStore.end(); - const auto& store = MWBase::Environment::get().getWorld()->getStore(); + const auto& store = *MWBase::Environment::get().getESMStore(); // With soul gems we prefer filled ones. for (auto it = invStore.begin(); it != invStore.end(); ++it) diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 8f09500bde..b2667e6320 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -119,8 +119,7 @@ namespace MWScript // "Will match complete or partial cells, so ShowMap, "Vivec" will show cells Vivec and Vivec, Fred's // House as well." http://www.uesp.net/wiki/Tes3Mod:ShowMap - const MWWorld::Store& cells - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& cells = MWBase::Environment::get().getESMStore()->get(); MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager(); @@ -138,8 +137,7 @@ namespace MWScript public: void execute(Interpreter::Runtime& runtime) override { - const MWWorld::Store& cells - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& cells = MWBase::Environment::get().getESMStore()->get(); for (auto it = cells.extBegin(); it != cells.extEnd(); ++it) { diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index a2b818115d..0f296b2ca9 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -56,7 +56,7 @@ namespace MWScript id = std::ref(ptr.getClass().getScript(ptr)); - ptr.getRefData().setLocals(*MWBase::Environment::get().getWorld()->getStore().get().find(id)); + ptr.getRefData().setLocals(*MWBase::Environment::get().getESMStore()->get().find(id)); return ptr.getRefData().getLocals(); } @@ -74,7 +74,7 @@ namespace MWScript id = std::ref(ptr.getClass().getScript(ptr)); - ptr.getRefData().setLocals(*MWBase::Environment::get().getWorld()->getStore().get().find(id)); + ptr.getRefData().setLocals(*MWBase::Environment::get().getESMStore()->get().find(id)); return ptr.getRefData().getLocals(); } @@ -233,8 +233,7 @@ namespace MWScript std::vector InterpreterContext::getGlobals() const { - const MWWorld::Store& globals - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& globals = MWBase::Environment::get().getESMStore()->get(); std::vector ids; for (const auto& globalVariable : globals) @@ -289,23 +288,21 @@ namespace MWScript std::string_view InterpreterContext::getNPCRace() const { const ESM::NPC* npc = getReferenceImp().get()->mBase; - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(npc->mRace); + const ESM::Race* race = MWBase::Environment::get().getESMStore()->get().find(npc->mRace); return race->mName; } std::string_view InterpreterContext::getNPCClass() const { const ESM::NPC* npc = getReferenceImp().get()->mBase; - const ESM::Class* class_ - = MWBase::Environment::get().getWorld()->getStore().get().find(npc->mClass); + const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); return class_->mName; } std::string_view InterpreterContext::getNPCFaction() const { const ESM::NPC* npc = getReferenceImp().get()->mBase; - const ESM::Faction* faction - = MWBase::Environment::get().getWorld()->getStore().get().find(npc->mFaction); + const ESM::Faction* faction = MWBase::Environment::get().getESMStore()->get().find(npc->mFaction); return faction->mName; } diff --git a/apps/openmw/mwscript/locals.cpp b/apps/openmw/mwscript/locals.cpp index 8da736efb7..b84cb7e8e8 100644 --- a/apps/openmw/mwscript/locals.cpp +++ b/apps/openmw/mwscript/locals.cpp @@ -19,8 +19,7 @@ namespace MWScript { if (!mInitialised) { - const ESM::Script* script - = MWBase::Environment::get().getWorld()->getStore().get().find(scriptName); + const ESM::Script* script = MWBase::Environment::get().getESMStore()->get().find(scriptName); configure(*script); } diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 7d436713e0..080b6094d7 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -617,7 +617,7 @@ namespace MWScript if (!ptr.getClass().hasInventoryStore(ptr)) return; - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); store.get().find( creature); // This line throws an exception if it can't find the creature @@ -730,7 +730,7 @@ namespace MWScript } } - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), item, 1); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), item, 1); MWWorld::Ptr itemPtr(ref.getPtr()); if (amount > 0) { @@ -1234,8 +1234,7 @@ namespace MWScript ESM::RefId targetId = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); runtime.pop(); - const ESM::Spell* spell - = MWBase::Environment::get().getWorld()->getStore().get().search(spellId); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().search(spellId); if (!spell) { runtime.getContext().report( @@ -1282,8 +1281,7 @@ namespace MWScript ESM::RefId spellId = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); runtime.pop(); - const ESM::Spell* spell - = MWBase::Environment::get().getWorld()->getStore().get().search(spellId); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().search(spellId); if (!spell) { runtime.getContext().report( @@ -1504,9 +1502,9 @@ namespace MWScript runtime.pop(); ESM::CreatureLevList listCopy - = *MWBase::Environment::get().getWorld()->getStore().get().find(levId); + = *MWBase::Environment::get().getESMStore()->get().find(levId); addToLevList(&listCopy, creatureId, level); - MWBase::Environment::get().getWorld()->getStore().overrideRecord(listCopy); + MWBase::Environment::get().getESMStore()->overrideRecord(listCopy); } }; @@ -1523,9 +1521,9 @@ namespace MWScript runtime.pop(); ESM::CreatureLevList listCopy - = *MWBase::Environment::get().getWorld()->getStore().get().find(levId); + = *MWBase::Environment::get().getESMStore()->get().find(levId); removeFromLevList(&listCopy, creatureId, level); - MWBase::Environment::get().getWorld()->getStore().overrideRecord(listCopy); + MWBase::Environment::get().getESMStore()->overrideRecord(listCopy); } }; @@ -1542,9 +1540,9 @@ namespace MWScript runtime.pop(); ESM::ItemLevList listCopy - = *MWBase::Environment::get().getWorld()->getStore().get().find(levId); + = *MWBase::Environment::get().getESMStore()->get().find(levId); addToLevList(&listCopy, itemId, level); - MWBase::Environment::get().getWorld()->getStore().overrideRecord(listCopy); + MWBase::Environment::get().getESMStore()->overrideRecord(listCopy); } }; @@ -1561,9 +1559,9 @@ namespace MWScript runtime.pop(); ESM::ItemLevList listCopy - = *MWBase::Environment::get().getWorld()->getStore().get().find(levId); + = *MWBase::Environment::get().getESMStore()->get().find(levId); removeFromLevList(&listCopy, itemId, level); - MWBase::Environment::get().getWorld()->getStore().overrideRecord(listCopy); + MWBase::Environment::get().getESMStore()->overrideRecord(listCopy); } }; @@ -1690,7 +1688,7 @@ namespace MWScript { Resource::SceneManager* sceneManager = MWBase::Environment::get().getResourceSystem()->getSceneManager(); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); for (const T& record : store.get()) { MWWorld::ManualRef ref(store, record.mId); diff --git a/apps/openmw/mwscript/skyextensions.cpp b/apps/openmw/mwscript/skyextensions.cpp index 88c1af561a..2284e2a3ae 100644 --- a/apps/openmw/mwscript/skyextensions.cpp +++ b/apps/openmw/mwscript/skyextensions.cpp @@ -87,8 +87,7 @@ namespace MWScript Interpreter::Type_Integer id = runtime[0].mInteger; runtime.pop(); - const ESM::Region* reg - = MWBase::Environment::get().getWorld()->getStore().get().search(region); + const ESM::Region* reg = MWBase::Environment::get().getESMStore()->get().search(region); if (reg) MWBase::Environment::get().getWorld()->changeWeather(region, id); else diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 6214a3b4fe..d88b277af6 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -67,7 +67,7 @@ namespace template void updateBaseRecord(MWWorld::Ptr& ptr) { - const auto& store = MWBase::Environment::get().getWorld()->getStore(); + const auto& store = *MWBase::Environment::get().getESMStore(); const T* base = store.get().find(ptr.getCellRef().getRefId()); ptr.get()->mBase = base; } @@ -463,7 +463,7 @@ namespace MWScript ESM::RefId id = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); runtime.pop(); - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(id); + const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get().find(id); MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr); creatureStats.getSpells().add(spell); @@ -572,7 +572,7 @@ namespace MWScript runtime.pop(); } // Make sure this faction exists - MWBase::Environment::get().getWorld()->getStore().get().find(factionID); + MWBase::Environment::get().getESMStore()->get().find(factionID); if (!factionID.empty()) { @@ -602,7 +602,7 @@ namespace MWScript runtime.pop(); } // Make sure this faction exists - MWBase::Environment::get().getWorld()->getStore().get().find(factionID); + MWBase::Environment::get().getESMStore()->get().find(factionID); if (!factionID.empty()) { @@ -639,7 +639,7 @@ namespace MWScript runtime.pop(); } // Make sure this faction exists - MWBase::Environment::get().getWorld()->getStore().get().find(factionID); + MWBase::Environment::get().getESMStore()->get().find(factionID); if (!factionID.empty()) { @@ -668,7 +668,7 @@ namespace MWScript factionID = ptr.getClass().getPrimaryFaction(ptr); } // Make sure this faction exists - MWBase::Environment::get().getWorld()->getStore().get().find(factionID); + MWBase::Environment::get().getESMStore()->get().find(factionID); if (!factionID.empty()) { diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index f27721c2ef..110309ae1a 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -533,7 +533,7 @@ namespace MWScript pos.pos[2] = z; pos.rot[0] = pos.rot[1] = 0; pos.rot[2] = osg::DegreesToRadians(zRotDegrees); - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), itemID); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), itemID); ref.getPtr().mRef->mData.mPhysicsPostponed = !ref.getPtr().getClass().isActor(); ref.getPtr().getCellRef().setPosition(pos); MWWorld::Ptr placed = MWBase::Environment::get().getWorld()->placeObject(ref.getPtr(), store, pos); @@ -579,7 +579,7 @@ namespace MWScript pos.pos[2] = z; pos.rot[0] = pos.rot[1] = 0; pos.rot[2] = osg::DegreesToRadians(zRotDegrees); - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), itemID); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), itemID); ref.getPtr().mRef->mData.mPhysicsPostponed = !ref.getPtr().getClass().isActor(); ref.getPtr().getCellRef().setPosition(pos); MWWorld::Ptr placed = MWBase::Environment::get().getWorld()->placeObject(ref.getPtr(), store, pos); @@ -617,7 +617,7 @@ namespace MWScript for (int i = 0; i < count; ++i) { // create item - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), itemID, 1); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), itemID, 1); ref.getPtr().mRef->mData.mPhysicsPostponed = !ref.getPtr().getClass().isActor(); MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->safePlaceObject( diff --git a/apps/openmw/mwsound/regionsoundselector.cpp b/apps/openmw/mwsound/regionsoundselector.cpp index 65ac7d0c6f..388fe3bf91 100644 --- a/apps/openmw/mwsound/regionsoundselector.cpp +++ b/apps/openmw/mwsound/regionsoundselector.cpp @@ -45,7 +45,7 @@ namespace MWSound } const ESM::Region* const region - = MWBase::Environment::get().getWorld()->getStore().get().search(mLastRegionName); + = MWBase::Environment::get().getESMStore()->get().search(mLastRegionName); if (region == nullptr) return {}; diff --git a/apps/openmw/mwsound/sound_buffer.cpp b/apps/openmw/mwsound/sound_buffer.cpp index 17ec516882..ce95e26bca 100644 --- a/apps/openmw/mwsound/sound_buffer.cpp +++ b/apps/openmw/mwsound/sound_buffer.cpp @@ -67,7 +67,7 @@ namespace MWSound { if (mBufferNameMap.empty()) { - for (const ESM::Sound& sound : MWBase::Environment::get().getWorld()->getStore().get()) + for (const ESM::Sound& sound : MWBase::Environment::get().getESMStore()->get()) insertSound(sound.mId, sound); } @@ -77,8 +77,7 @@ namespace MWSound sfx = it->second; else { - const ESM::Sound* sound - = MWBase::Environment::get().getWorld()->getStore().get().search(soundId); + const ESM::Sound* sound = MWBase::Environment::get().getESMStore()->get().search(soundId); if (sound == nullptr) return {}; sfx = insertSound(soundId, *sound); @@ -119,7 +118,7 @@ namespace MWSound Sound_Buffer* SoundBufferPool::insertSound(const ESM::RefId& soundId, const ESM::Sound& sound) { static const AudioParams audioParams - = makeAudioParams(MWBase::Environment::get().getWorld()->getStore().get()); + = makeAudioParams(MWBase::Environment::get().getESMStore()->get()); float volume = static_cast(std::pow(10.0, (sound.mData.mVolume / 255.0 * 3348.0 - 3348.0) / 2000.0)); float min = sound.mData.mMinRange; diff --git a/apps/openmw/mwworld/actionread.cpp b/apps/openmw/mwworld/actionread.cpp index 518ec9219b..10614f48da 100644 --- a/apps/openmw/mwworld/actionread.cpp +++ b/apps/openmw/mwworld/actionread.cpp @@ -52,7 +52,7 @@ namespace MWWorld MWWorld::LiveCellRef* playerRef = actor.get(); const ESM::Class* class_ - = MWBase::Environment::get().getWorld()->getStore().get().find(playerRef->mBase->mClass); + = MWBase::Environment::get().getESMStore()->get().find(playerRef->mBase->mClass); npcStats.increaseSkill(ref->mBase->mData.mSkillId, *class_, true, true); diff --git a/apps/openmw/mwworld/actionsoulgem.cpp b/apps/openmw/mwworld/actionsoulgem.cpp index e0daf00f1a..74eda6bba5 100644 --- a/apps/openmw/mwworld/actionsoulgem.cpp +++ b/apps/openmw/mwworld/actionsoulgem.cpp @@ -39,7 +39,7 @@ namespace MWWorld return; } - if (!MWBase::Environment::get().getWorld()->getStore().get().search(targetSoul)) + if (!MWBase::Environment::get().getESMStore()->get().search(targetSoul)) { Log(Debug::Warning) << "Soul '" << targetSoul << "' not found (item: '" << target.getCellRef().getRefId() << "')"; diff --git a/apps/openmw/mwworld/cellref.cpp b/apps/openmw/mwworld/cellref.cpp index 2e7ab7b748..e5ed333098 100644 --- a/apps/openmw/mwworld/cellref.cpp +++ b/apps/openmw/mwworld/cellref.cpp @@ -99,8 +99,7 @@ namespace MWWorld if (ref.mDoor.destDoor.isZeroOrUnset()) return ESM::RefId::sEmpty; const ESM4::Reference* refDest - = MWBase::Environment::get().getWorld()->getStore().get().searchStatic( - ref.mDoor.destDoor); + = MWBase::Environment::get().getESMStore()->get().searchStatic(ref.mDoor.destDoor); if (refDest) return refDest->mParent; return ESM::RefId::sEmpty; diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 9c48cd2c9e..cb2063a45e 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -212,7 +212,7 @@ namespace void readReferenceCollection(ESM::ESMReader& reader, MWWorld::CellRefList& collection, const ESM::CellRef& cref, const std::map& contentFileMap, MWWorld::CellStore* cellstore) { - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); using StateType = typename RecordToState::StateType; StateType state; @@ -763,7 +763,7 @@ namespace MWWorld template static void visitCell4References(const ESM4::Cell& cell, ESM::ReadersCache& readers, ReferenceInvocable&& invocable) { - for (const ESM4::Reference& ref : MWBase::Environment::get().getWorld()->getStore().get()) + for (const ESM4::Reference& ref : MWBase::Environment::get().getESMStore()->get()) { if (ref.mParent == cell.mId) { @@ -1003,7 +1003,7 @@ namespace MWWorld ESM::CellRef cref; cref.loadId(reader, true); - int type = MWBase::Environment::get().getWorld()->getStore().find(cref.mRefID); + int type = MWBase::Environment::get().getESMStore()->find(cref.mRefID); if (type == 0) { Log(Debug::Warning) << "Dropping reference to '" << cref.mRefID << "' (object no longer exists)"; @@ -1101,9 +1101,8 @@ namespace MWWorld { const MWMechanics::CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr); static const float fCorpseClearDelay = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("fCorpseClearDelay") ->mValue.getFloat(); if (creatureStats.isDead() && creatureStats.isDeathAnimationFinished() && !ptr.getClass().isPersistent(ptr) @@ -1184,9 +1183,8 @@ namespace MWWorld if (mState == State_Loaded) { static const int iMonthsToRespawn = MWBase::Environment::get() - .getWorld() - ->getStore() - .get() + .getESMStore() + ->get() .find("iMonthsToRespawn") ->mValue.getInteger(); if (MWBase::Environment::get().getWorld()->getTimeStamp() - mLastRespawn > 24 * 30 * iMonthsToRespawn) @@ -1265,7 +1263,7 @@ namespace MWWorld return; const ESM::Enchantment* enchantment - = MWBase::Environment::get().getWorld()->getStore().get().search(enchantmentId); + = MWBase::Environment::get().getESMStore()->get().search(enchantmentId); if (!enchantment) { Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchantmentId << "' on item " diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index f71198cf12..92439c1550 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -347,7 +347,7 @@ namespace MWWorld if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); auto& prng = MWBase::Environment::get().getWorld()->getPrng(); const ESM::Sound* sound = store.get().searchRandom("WolfItem", prng); @@ -508,15 +508,14 @@ namespace MWWorld return result; const ESM::Enchantment* enchantment - = MWBase::Environment::get().getWorld()->getStore().get().search(enchantmentName); + = MWBase::Environment::get().getESMStore()->get().search(enchantmentName); if (!enchantment) return result; assert(enchantment->mEffects.mList.size()); - const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().search( - enchantment->mEffects.mList.front().mEffectID); + const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getESMStore()->get().search( + enchantment->mEffects.mList.front().mEffectID); if (!magicEffect) return result; diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index f40f0474cd..adcc340f68 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -93,7 +93,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::getState( if (!LiveCellRef::checkState(state)) return ContainerStoreIterator(this); // not valid anymore with current content files -> skip - const T* record = MWBase::Environment::get().getWorld()->getStore().get().search(state.mRef.mRefID); + const T* record = MWBase::Environment::get().getESMStore()->get().search(state.mRef.mRefID); if (!record) return ContainerStoreIterator(this); @@ -265,9 +265,8 @@ bool MWWorld::ContainerStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2) // If it has an enchantment, don't stack when some of the charge is already used if (!ptr1.getClass().getEnchantment(ptr1).empty()) { - const ESM::Enchantment* enchantment - = MWBase::Environment::get().getWorld()->getStore().get().find( - ptr1.getClass().getEnchantment(ptr1)); + const ESM::Enchantment* enchantment = MWBase::Environment::get().getESMStore()->get().find( + ptr1.getClass().getEnchantment(ptr1)); float maxCharge = static_cast(enchantment->mData.mCharge); float enchantCharge1 = ptr1.getCellRef().getEnchantmentCharge() == -1 ? maxCharge : ptr1.getCellRef().getEnchantmentCharge(); @@ -294,7 +293,7 @@ bool MWWorld::ContainerStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2) MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add(const ESM::RefId& id, int count) { - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), id, count); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), id, count); return add(ref.getPtr(), count); } @@ -371,7 +370,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImp(const Ptr& ptr, resolve(); int type = getType(ptr); - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); // gold needs special handling: when it is inserted into a container, the base object automatically becomes Gold_001 // this ensures that gold piles of different sizes stack with each other (also, several scripts rely on Gold_001 for @@ -499,7 +498,7 @@ void MWWorld::ContainerStore::updateRechargingItems() if (!enchantmentId.empty()) { const ESM::Enchantment* enchantment - = MWBase::Environment::get().getWorld()->getStore().get().search(enchantmentId); + = MWBase::Environment::get().getESMStore()->get().search(enchantmentId); if (!enchantment) { Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchantmentId << "' on item " @@ -601,7 +600,7 @@ void MWWorld::ContainerStore::addInitialItem( return; // Don't restock with nothing. try { - ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), id, count); + ManualRef ref(*MWBase::Environment::get().getESMStore(), id, count); if (ref.getPtr().getClass().getScript(ref.getPtr()).empty()) { addInitialItemImp(ref.getPtr(), owner, count, prng, topLevel); @@ -932,7 +931,7 @@ void MWWorld::ContainerStore::readState(const ESM::InventoryState& inventory) int index = 0; for (const ESM::ObjectState& state : inventory.mItems) { - int type = MWBase::Environment::get().getWorld()->getStore().find(state.mRef.mRefID); + int type = MWBase::Environment::get().getESMStore()->find(state.mRef.mRefID); int thisIndex = index++; diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 8c7070b588..34a298ae0d 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -389,8 +389,7 @@ void MWWorld::InventoryStore::autoEquipArmor(TSlots& slots_) return; } - const MWWorld::Store& store - = MWBase::Environment::get().getWorld()->getStore().get(); + const MWWorld::Store& store = MWBase::Environment::get().getESMStore()->get(); static float fUnarmoredBase1 = store.find("fUnarmoredBase1")->mValue.getFloat(); static float fUnarmoredBase2 = store.find("fUnarmoredBase2")->mValue.getFloat(); diff --git a/apps/openmw/mwworld/livecellref.cpp b/apps/openmw/mwworld/livecellref.cpp index 73678cf21d..30b413daae 100644 --- a/apps/openmw/mwworld/livecellref.cpp +++ b/apps/openmw/mwworld/livecellref.cpp @@ -43,7 +43,7 @@ void MWWorld::LiveCellRefBase::loadImp(const ESM::ObjectState& state) if (!scriptId.empty()) { if (const ESM::Script* script - = MWBase::Environment::get().getWorld()->getStore().get().search(scriptId)) + = MWBase::Environment::get().getESMStore()->get().search(scriptId)) { try { @@ -62,7 +62,7 @@ void MWWorld::LiveCellRefBase::loadImp(const ESM::ObjectState& state) mClass->readAdditionalState(ptr, state); if (!mRef.getSoul().empty() - && !MWBase::Environment::get().getWorld()->getStore().get().search(mRef.getSoul())) + && !MWBase::Environment::get().getESMStore()->get().search(mRef.getSoul())) { Log(Debug::Warning) << "Soul '" << mRef.getSoul() << "' not found, removing the soul from soul gem"; mRef.setSoul(ESM::RefId()); diff --git a/apps/openmw/mwworld/magiceffects.cpp b/apps/openmw/mwworld/magiceffects.cpp index b59e180dbe..77525ad3df 100644 --- a/apps/openmw/mwworld/magiceffects.cpp +++ b/apps/openmw/mwworld/magiceffects.cpp @@ -20,7 +20,7 @@ namespace template void getEnchantedItem(const ESM::RefId& id, ESM::RefId& enchantment, std::string& itemName) { - const T* item = MWBase::Environment::get().getWorld()->getStore().get().search(id); + const T* item = MWBase::Environment::get().getESMStore()->get().search(id); if (item) { enchantment = item->mEnchant; @@ -33,7 +33,7 @@ namespace MWWorld { void convertMagicEffects(ESM::CreatureStats& creatureStats, ESM::InventoryState& inventory, ESM::NpcStats* npcStats) { - const auto& store = MWBase::Environment::get().getWorld()->getStore(); + const auto& store = *MWBase::Environment::get().getESMStore(); // Convert corprus to format 10 for (const auto& [id, oldStats] : creatureStats.mSpells.mCorprusSpells) { diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index f280f02318..00a0ee7aa6 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -68,7 +68,7 @@ namespace MWWorld void Player::restoreStats() { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); MWMechanics::CreatureStats& creatureStats = getPlayer().getClass().getCreatureStats(getPlayer()); MWMechanics::NpcStats& npcStats = getPlayer().getClass().getNpcStats(getPlayer()); MWMechanics::DynamicStat health = creatureStats.getDynamic(0); @@ -91,7 +91,7 @@ namespace MWWorld void Player::setWerewolfStats() { const MWWorld::Store& gmst - = MWBase::Environment::get().getWorld()->getStore().get(); + = MWBase::Environment::get().getESMStore()->get(); MWMechanics::CreatureStats& creatureStats = getPlayer().getClass().getCreatureStats(getPlayer()); MWMechanics::NpcStats& npcStats = getPlayer().getClass().getNpcStats(getPlayer()); MWMechanics::DynamicStat health = creatureStats.getDynamic(0); diff --git a/apps/openmw/mwworld/projectilemanager.cpp b/apps/openmw/mwworld/projectilemanager.cpp index b0c5853388..0785241927 100644 --- a/apps/openmw/mwworld/projectilemanager.cpp +++ b/apps/openmw/mwworld/projectilemanager.cpp @@ -60,7 +60,7 @@ namespace ESM::EffectList getMagicBoltData(std::vector& projectileIDs, std::set& sounds, float& speed, std::string& texture, std::string& sourceName, const ESM::RefId& id) { - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); const ESM::EffectList* effects; if (const ESM::Spell* spell = esmStore.get().search(id)) // check if it's a spell { @@ -83,7 +83,7 @@ namespace ++iter) { const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(iter->mEffectID); + = MWBase::Environment::get().getESMStore()->get().find(iter->mEffectID); // Speed of multi-effect projectiles should be the average of the constituent effects, // based on observation of the original engine. @@ -114,7 +114,7 @@ namespace if (projectileEffects.mList.size() == 1) { const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find( + = MWBase::Environment::get().getESMStore()->get().find( effects->mList.begin()->mEffectID); texture = magicEffect->mParticle; } @@ -141,7 +141,7 @@ namespace ++iter) { const ESM::MagicEffect* magicEffect - = MWBase::Environment::get().getWorld()->getStore().get().find(iter->mEffectID); + = MWBase::Environment::get().getESMStore()->get().find(iter->mEffectID); lightDiffuseRed += (static_cast(magicEffect->mData.mRed) / 255.f); lightDiffuseGreen += (static_cast(magicEffect->mData.mGreen) / 255.f); lightDiffuseBlue += (static_cast(magicEffect->mData.mBlue) / 255.f); @@ -220,8 +220,8 @@ namespace MWWorld { std::ostringstream nodeName; nodeName << "Dummy" << std::setw(2) << std::setfill('0') << iter; - const ESM::Weapon* weapon = MWBase::Environment::get().getWorld()->getStore().get().find( - state.mIdMagic.at(iter)); + const ESM::Weapon* weapon + = MWBase::Environment::get().getESMStore()->get().find(state.mIdMagic.at(iter)); std::string nameToFind = nodeName.str(); SceneUtil::FindByNameVisitor findVisitor(nameToFind); attachTo->accept(findVisitor); @@ -313,7 +313,7 @@ namespace MWWorld return; } - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), state.mIdMagic.at(0)); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), state.mIdMagic.at(0)); MWWorld::Ptr ptr = ref.getPtr(); osg::Vec4 lightDiffuseColor = getMagicBoltLightDiffuseColor(state.mEffects); @@ -335,7 +335,7 @@ namespace MWWorld if (state.mIdMagic.size() > 1) { model = Misc::ResourceHelpers::correctMeshPath( - MWBase::Environment::get().getWorld()->getStore().get().find(state.mIdMagic[1])->mModel, + MWBase::Environment::get().getESMStore()->get().find(state.mIdMagic[1])->mModel, MWBase::Environment::get().getResourceSystem()->getVFS()); } state.mProjectileId = mPhysics->addProjectile(caster, pos, model, true); @@ -356,7 +356,7 @@ namespace MWWorld int type = projectile.get()->mBase->mData.mType; state.mThrown = MWMechanics::getWeaponType(type)->mWeaponClass == ESM::WeaponType::Thrown; - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), projectile.getCellRef().getRefId()); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), projectile.getCellRef().getRefId()); MWWorld::Ptr ptr = ref.getPtr(); const auto model = ptr.getClass().getModel(ptr); @@ -449,7 +449,7 @@ namespace MWWorld } } - const auto& store = MWBase::Environment::get().getWorld()->getStore(); + const auto& store = *MWBase::Environment::get().getESMStore(); osg::Quat orient = magicBoltState.mNode->getAttitude(); static float fTargetSpellMaxSpeed = store.get().find("fTargetSpellMaxSpeed")->mValue.getFloat(); @@ -537,8 +537,7 @@ namespace MWWorld caster = target; // Try to get a Ptr to the bow that was used. It might no longer exist. - MWWorld::ManualRef projectileRef( - MWBase::Environment::get().getWorld()->getStore(), projectileState.mIdArrow); + MWWorld::ManualRef projectileRef(*MWBase::Environment::get().getESMStore(), projectileState.mIdArrow); MWWorld::Ptr bow = projectileRef.getPtr(); if (!caster.isEmpty() && projectileState.mIdArrow != projectileState.mBowId) { @@ -557,7 +556,7 @@ namespace MWWorld caster, target, bow, projectileRef.getPtr(), hitPosition, projectileState.mAttackStrength); projectileState.mToDelete = true; } - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore(); for (auto& magicBoltState : mMagicBolts) { if (magicBoltState.mToDelete) @@ -703,7 +702,7 @@ namespace MWWorld std::string model; try { - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), esm.mId); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), esm.mId); MWWorld::Ptr ptr = ref.getPtr(); model = ptr.getClass().getModel(ptr); int weaponType = ptr.get()->mBase->mData.mType; @@ -756,7 +755,7 @@ namespace MWWorld std::string model; try { - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), state.mIdMagic.at(0)); + MWWorld::ManualRef ref(*MWBase::Environment::get().getESMStore(), state.mIdMagic.at(0)); MWWorld::Ptr ptr = ref.getPtr(); model = ptr.getClass().getModel(ptr); } diff --git a/apps/openmw/mwworld/worldmodel.cpp b/apps/openmw/mwworld/worldmodel.cpp index 87f112238a..9b644de987 100644 --- a/apps/openmw/mwworld/worldmodel.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -179,7 +179,7 @@ MWWorld::CellStore& MWWorld::WorldModel::getExterior(int x, int y) record.mMapColor = 0; record.updateId(); - cell = MWBase::Environment::get().getWorld()->getStore().insert(record); + cell = MWBase::Environment::get().getESMStore()->insert(record); } CellStore* cellStore