Merge branch 'simplify_world' into 'master'

Refactoring. Put ESMStore to Environment; remove `createRecord` from World.

See merge request OpenMW/openmw!2947
7344-support-launching-the-example-suite
psi29a 2 years ago
commit 675dfb9725

@ -776,6 +776,7 @@ void OMW::Engine::prepareEngine()
mEnvironment.setWorld(*mWorld); mEnvironment.setWorld(*mWorld);
mEnvironment.setWorldModel(mWorld->getWorldModel()); mEnvironment.setWorldModel(mWorld->getWorldModel());
mEnvironment.setWorldScene(mWorld->getWorldScene()); mEnvironment.setWorldScene(mWorld->getWorldScene());
mEnvironment.setESMStore(mWorld->getStore());
const MWWorld::Store<ESM::GameSetting>* gmst = &mWorld->getStore().get<ESM::GameSetting>(); const MWWorld::Store<ESM::GameSetting>* gmst = &mWorld->getStore().get<ESM::GameSetting>();
mL10nManager->setGmstLoader( mL10nManager->setGmstLoader(

@ -17,6 +17,7 @@ namespace l10n
namespace MWWorld namespace MWWorld
{ {
class ESMStore;
class WorldModel; class WorldModel;
class Scene; class Scene;
} }
@ -45,6 +46,7 @@ namespace MWBase
World* mWorld = nullptr; World* mWorld = nullptr;
MWWorld::WorldModel* mWorldModel = nullptr; MWWorld::WorldModel* mWorldModel = nullptr;
MWWorld::Scene* mWorldScene = nullptr; MWWorld::Scene* mWorldScene = nullptr;
MWWorld::ESMStore* mESMStore = nullptr;
SoundManager* mSoundManager = nullptr; SoundManager* mSoundManager = nullptr;
ScriptManager* mScriptManager = nullptr; ScriptManager* mScriptManager = nullptr;
WindowManager* mWindowManager = nullptr; WindowManager* mWindowManager = nullptr;
@ -71,6 +73,7 @@ namespace MWBase
void setWorld(World& value) { mWorld = &value; } void setWorld(World& value) { mWorld = &value; }
void setWorldModel(MWWorld::WorldModel& value) { mWorldModel = &value; } void setWorldModel(MWWorld::WorldModel& value) { mWorldModel = &value; }
void setWorldScene(MWWorld::Scene& value) { mWorldScene = &value; } void setWorldScene(MWWorld::Scene& value) { mWorldScene = &value; }
void setESMStore(MWWorld::ESMStore& value) { mESMStore = &value; }
void setSoundManager(SoundManager& value) { mSoundManager = &value; } void setSoundManager(SoundManager& value) { mSoundManager = &value; }
@ -97,6 +100,7 @@ namespace MWBase
Misc::NotNullPtr<World> getWorld() const { return mWorld; } Misc::NotNullPtr<World> getWorld() const { return mWorld; }
Misc::NotNullPtr<MWWorld::WorldModel> getWorldModel() const { return mWorldModel; } Misc::NotNullPtr<MWWorld::WorldModel> getWorldModel() const { return mWorldModel; }
Misc::NotNullPtr<MWWorld::Scene> getWorldScene() const { return mWorldScene; } Misc::NotNullPtr<MWWorld::Scene> getWorldScene() const { return mWorldScene; }
Misc::NotNullPtr<MWWorld::ESMStore> getESMStore() const { return mESMStore; }
Misc::NotNullPtr<SoundManager> getSoundManager() const { return mSoundManager; } Misc::NotNullPtr<SoundManager> getSoundManager() const { return mSoundManager; }

@ -147,7 +147,8 @@ namespace MWBase
virtual MWWorld::Ptr getPlayerPtr() = 0; virtual MWWorld::Ptr getPlayerPtr() = 0;
virtual MWWorld::ConstPtr getPlayerConstPtr() const = 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<MWBase::World*>(this)->getStore(); }
virtual const std::vector<int>& getESMVersions() const = 0; virtual const std::vector<int>& getESMVersions() const = 0;
@ -344,66 +345,6 @@ namespace MWBase
///< Toggle a render mode. ///< Toggle a render mode.
///< \return Resulting 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; 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 ///< copy and place an object into the gameworld at the specified cursor position
/// @param object /// @param object

@ -120,7 +120,7 @@ namespace MWClass
{ {
if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) 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(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfActivator", prng); const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfActivator", prng);
@ -144,7 +144,7 @@ namespace MWClass
{ {
const std::string model const std::string model
= getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise = 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 ESM::RefId* creatureId = nullptr;
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();

@ -153,7 +153,7 @@ namespace MWClass
return -1; return -1;
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
float iWeight = floor(gmst.find(typeGmst)->mValue.getFloat()); float iWeight = floor(gmst.find(typeGmst)->mValue.getFloat());
@ -289,7 +289,7 @@ namespace MWClass
newItem.mName = newName; newItem.mName = newName;
newItem.mData.mEnchant = enchCharge; newItem.mData.mEnchant = enchCharge;
newItem.mEnchant = enchId; newItem.mEnchant = enchId;
const ESM::Armor* record = MWBase::Environment::get().getWorld()->createRecord(newItem); const ESM::Armor* record = MWBase::Environment::get().getESMStore()->insert(newItem);
return record->mId; return record->mId;
} }
@ -300,8 +300,11 @@ namespace MWClass
int armorSkillType = getEquipmentSkill(ptr); int armorSkillType = getEquipmentSkill(ptr);
float armorSkill = actor.getClass().getSkill(actor, armorSkillType); float armorSkill = actor.getClass().getSkill(actor, armorSkillType);
const MWBase::World* world = MWBase::Environment::get().getWorld(); int iBaseArmorSkill = MWBase::Environment::get()
int iBaseArmorSkill = world->getStore().get<ESM::GameSetting>().find("iBaseArmorSkill")->mValue.getInteger(); .getESMStore()
->get<ESM::GameSetting>()
.find("iBaseArmorSkill")
->mValue.getInteger();
if (ref->mBase->mData.mWeight == 0) if (ref->mBase->mData.mWeight == 0)
return ref->mBase->mData.mArmor; return ref->mBase->mData.mArmor;
@ -327,7 +330,7 @@ namespace MWClass
const ESM::RefId& npcRace = npc.get<ESM::NPC>()->mBase->mRace; const ESM::RefId& npcRace = npc.get<ESM::NPC>()->mBase->mRace;
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part) // Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace); const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(npcRace);
if (race->mData.mFlags & ESM::Race::Beast) if (race->mData.mFlags & ESM::Race::Beast)
{ {
std::vector<ESM::PartReference> parts = ptr.get<ESM::Armor>()->mBase->mParts.mParts; std::vector<ESM::PartReference> parts = ptr.get<ESM::Armor>()->mBase->mParts.mParts;

@ -58,7 +58,7 @@ namespace MWClass
{ {
if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) 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(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfItem", prng); const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfItem", prng);
@ -151,7 +151,7 @@ namespace MWClass
newItem.mData.mIsScroll = 1; newItem.mData.mIsScroll = 1;
newItem.mData.mEnchant = enchCharge; newItem.mData.mEnchant = enchCharge;
newItem.mEnchant = enchId; newItem.mEnchant = enchId;
const ESM::Book* record = MWBase::Environment::get().getWorld()->createRecord(newItem); const ESM::Book* record = MWBase::Environment::get().getESMStore()->insert(newItem);
return record->mId; return record->mId;
} }

@ -196,7 +196,7 @@ namespace MWClass
newItem.mName = newName; newItem.mName = newName;
newItem.mData.mEnchant = enchCharge; newItem.mData.mEnchant = enchCharge;
newItem.mEnchant = enchId; newItem.mEnchant = enchId;
const ESM::Clothing* record = MWBase::Environment::get().getWorld()->createRecord(newItem); const ESM::Clothing* record = MWBase::Environment::get().getESMStore()->insert(newItem);
return record->mId; return record->mId;
} }
@ -214,7 +214,7 @@ namespace MWClass
const ESM::RefId& npcRace = npc.get<ESM::NPC>()->mBase->mRace; const ESM::RefId& npcRace = npc.get<ESM::NPC>()->mBase->mRace;
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part) // Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace); const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(npcRace);
if (race->mData.mFlags & ESM::Race::Beast) if (race->mData.mFlags & ESM::Race::Beast)
{ {
std::vector<ESM::PartReference> parts = ptr.get<ESM::Clothing>()->mBase->mParts.mParts; std::vector<ESM::PartReference> parts = ptr.get<ESM::Clothing>()->mBase->mParts.mParts;

@ -141,7 +141,7 @@ namespace MWClass
if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) 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(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfContainer", prng); const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfContainer", prng);

@ -91,8 +91,8 @@ namespace MWClass
static const GMST staticGmst = [] { static const GMST staticGmst = [] {
GMST gmst; GMST gmst;
const MWBase::World* world = MWBase::Environment::get().getWorld(); const MWWorld::Store<ESM::GameSetting>& store
const MWWorld::Store<ESM::GameSetting>& store = world->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
gmst.fMinWalkSpeedCreature = store.find("fMinWalkSpeedCreature"); gmst.fMinWalkSpeedCreature = store.find("fMinWalkSpeedCreature");
gmst.fMaxWalkSpeedCreature = store.find("fMaxWalkSpeedCreature"); gmst.fMaxWalkSpeedCreature = store.find("fMaxWalkSpeedCreature");
@ -469,7 +469,7 @@ namespace MWClass
{ {
if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) 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(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfCreature", prng); const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfCreature", prng);
@ -647,7 +647,7 @@ namespace MWClass
const ESM::RefId& ourId = (ref->mBase->mOriginal.empty()) ? ptr.getCellRef().getRefId() : ref->mBase->mOriginal; 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<ESM::SoundGenerator>().begin(); auto sound = store.get<ESM::SoundGenerator>().begin();
while (sound != store.get<ESM::SoundGenerator>().end()) while (sound != store.get<ESM::SoundGenerator>().end())
{ {
@ -766,7 +766,7 @@ namespace MWClass
{ {
MWWorld::LiveCellRef<ESM::Creature>* ref = ptr.get<ESM::Creature>(); MWWorld::LiveCellRef<ESM::Creature>* ref = ptr.get<ESM::Creature>();
const ESM::Skill* skillRecord = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find(skill); const ESM::Skill* skillRecord = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().find(skill);
switch (skillRecord->mData.mSpecialization) switch (skillRecord->mData.mSpecialization)
{ {
@ -862,7 +862,7 @@ namespace MWClass
return; return;
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fCorpseRespawnDelay = gmst.find("fCorpseRespawnDelay")->mValue.getFloat(); static const float fCorpseRespawnDelay = gmst.find("fCorpseRespawnDelay")->mValue.getFloat();
static const float fCorpseClearDelay = gmst.find("fCorpseClearDelay")->mValue.getFloat(); static const float fCorpseClearDelay = gmst.find("fCorpseClearDelay")->mValue.getFloat();

@ -86,7 +86,7 @@ namespace MWClass
else if (creatureStats.isDead()) else if (creatureStats.isDead())
{ {
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fCorpseRespawnDelay = gmst.find("fCorpseRespawnDelay")->mValue.getFloat(); static const float fCorpseRespawnDelay = gmst.find("fCorpseRespawnDelay")->mValue.getFloat();
static const float fCorpseClearDelay = gmst.find("fCorpseClearDelay")->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()) if (it->mLevel > player.getClass().getCreatureStats(player).getLevel())
continue; continue;
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
MWWorld::ManualRef ref(store, it->mId); MWWorld::ManualRef ref(store, it->mId);
ref.getPtr().getClass().getModelsToPreload(ref.getPtr(), models); ref.getPtr().getClass().getModelsToPreload(ref.getPtr(), models);
} }
@ -127,7 +127,7 @@ namespace MWClass
if (!customData.mSpawn) if (!customData.mSpawn)
return; 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(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::RefId& id = MWMechanics::getLevelledItem( const ESM::RefId& id = MWMechanics::getLevelledItem(
store.get<ESM::CreatureLevList>().find(ptr.getCellRef().getRefId()), true, prng); store.get<ESM::CreatureLevList>().find(ptr.getCellRef().getRefId()), true, prng);

@ -133,7 +133,7 @@ namespace MWClass
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr);
if (animation) 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<ESM::MagicEffect>().find(ESM::MagicEffect::Telekinesis); const ESM::MagicEffect* effect = store.get<ESM::MagicEffect>().find(ESM::MagicEffect::Telekinesis);
animation->addSpellCastGlow( animation->addSpellCastGlow(

@ -126,9 +126,8 @@ namespace MWClass
float alchemySkill = player.getClass().getSkill(player, ESM::Skill::Alchemy); float alchemySkill = player.getClass().getSkill(player, ESM::Skill::Alchemy);
static const float fWortChanceValue = MWBase::Environment::get() static const float fWortChanceValue = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fWortChanceValue") .find("fWortChanceValue")
->mValue.getFloat(); ->mValue.getFloat();

@ -86,7 +86,7 @@ namespace MWClass
if (!ptr.getCellRef().getSoul().empty()) if (!ptr.getCellRef().getSoul().empty())
{ {
const ESM::Creature* creature const ESM::Creature* creature
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(ref->mRef.getSoul()); = MWBase::Environment::get().getESMStore()->get<ESM::Creature>().search(ref->mRef.getSoul());
if (creature) if (creature)
{ {
int soul = creature->mData.mSoul; int soul = creature->mData.mSoul;
@ -177,7 +177,7 @@ namespace MWClass
{ {
MWWorld::Ptr newPtr; MWWorld::Ptr newPtr;
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
if (isGold(ptr)) if (isGold(ptr))
{ {

@ -84,7 +84,7 @@ namespace
void autoCalculateAttributes(const ESM::NPC* npc, MWMechanics::CreatureStats& creatureStats) void autoCalculateAttributes(const ESM::NPC* npc, MWMechanics::CreatureStats& creatureStats)
{ {
// race bonus // race bonus
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npc->mRace); const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(npc->mRace);
bool male = (npc->mFlags & ESM::NPC::Female) == 0; bool male = (npc->mFlags & ESM::NPC::Female) == 0;
@ -96,8 +96,7 @@ namespace
} }
// class bonus // class bonus
const ESM::Class* class_ const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(npc->mClass);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(npc->mClass);
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
@ -115,7 +114,7 @@ namespace
for (int j = 0; j < ESM::Skill::Length; ++j) for (int j = 0; j < ESM::Skill::Length; ++j)
{ {
const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find(j); const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().find(j);
if (skill->mData.mAttribute != attribute) if (skill->mData.mAttribute != attribute)
continue; continue;
@ -174,12 +173,11 @@ namespace
void autoCalculateSkills( void autoCalculateSkills(
const ESM::NPC* npc, MWMechanics::NpcStats& npcStats, const MWWorld::Ptr& ptr, bool spellsInitialised) const ESM::NPC* npc, MWMechanics::NpcStats& npcStats, const MWWorld::Ptr& ptr, bool spellsInitialised)
{ {
const ESM::Class* class_ const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(npc->mClass);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(npc->mClass);
unsigned int level = npcStats.getLevel(); unsigned int level = npcStats.getLevel();
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npc->mRace); const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(npc->mRace);
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
@ -223,8 +221,7 @@ namespace
} }
// is this skill in the same Specialization as the class? // is this skill in the same Specialization as the class?
const ESM::Skill* skill const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().find(skillIndex);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find(skillIndex);
if (skill->mData.mSpecialization == class_->mData.mSpecialization) if (skill->mData.mSpecialization == class_->mData.mSpecialization)
{ {
specMultiplier = 0.5f; specMultiplier = 0.5f;
@ -276,8 +273,8 @@ namespace MWClass
static const GMST staticGmst = [] { static const GMST staticGmst = [] {
GMST gmst; GMST gmst;
const MWBase::World* world = MWBase::Environment::get().getWorld(); const MWWorld::Store<ESM::GameSetting>& store
const MWWorld::Store<ESM::GameSetting>& store = world->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
gmst.fMinWalkSpeed = store.find("fMinWalkSpeed"); gmst.fMinWalkSpeed = store.find("fMinWalkSpeed");
gmst.fMaxWalkSpeed = store.find("fMaxWalkSpeed"); gmst.fMaxWalkSpeed = store.find("fMaxWalkSpeed");
@ -367,22 +364,19 @@ namespace MWClass
data->mNpcStats.setDeathAnimationFinished(isPersistent(ptr)); data->mNpcStats.setDeathAnimationFinished(isPersistent(ptr));
// race powers // race powers
const ESM::Race* race const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(ref->mBase->mRace);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(ref->mBase->mRace);
data->mNpcStats.getSpells().addAllToInstance(race->mPowers.mList); data->mNpcStats.getSpells().addAllToInstance(race->mPowers.mList);
if (!ref->mBase->mFaction.empty()) if (!ref->mBase->mFaction.empty())
{ {
static const int iAutoRepFacMod = MWBase::Environment::get() static const int iAutoRepFacMod = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("iAutoRepFacMod") .find("iAutoRepFacMod")
->mValue.getInteger(); ->mValue.getInteger();
static const int iAutoRepLevMod = MWBase::Environment::get() static const int iAutoRepLevMod = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("iAutoRepLevMod") .find("iAutoRepLevMod")
->mValue.getInteger(); ->mValue.getInteger();
int rank = ref->mBase->getFactionRank(); int rank = ref->mBase->getFactionRank();
@ -435,8 +429,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>(); const MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>();
std::string model = Settings::Manager::getString("baseanim", "Models"); std::string model = Settings::Manager::getString("baseanim", "Models");
const ESM::Race* race const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(ref->mBase->mRace);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(ref->mBase->mRace);
if (race->mData.mFlags & ESM::Race::Beast) if (race->mData.mFlags & ESM::Race::Beast)
model = Settings::Manager::getString("baseanimkna", "Models"); model = Settings::Manager::getString("baseanimkna", "Models");
@ -446,8 +439,7 @@ namespace MWClass
void Npc::getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const void Npc::getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const
{ {
const MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>(); const MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>();
const ESM::Race* race const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().search(npc->mBase->mRace);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().search(npc->mBase->mRace);
if (race && race->mData.mFlags & ESM::Race::Beast) if (race && race->mData.mFlags & ESM::Race::Beast)
models.emplace_back(Settings::Manager::getString("baseanimkna", "Models")); models.emplace_back(Settings::Manager::getString("baseanimkna", "Models"));
@ -464,14 +456,14 @@ namespace MWClass
if (!npc->mBase->mHead.empty()) if (!npc->mBase->mHead.empty())
{ {
const ESM::BodyPart* head const ESM::BodyPart* head
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(npc->mBase->mHead); = MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>().search(npc->mBase->mHead);
if (head) if (head)
models.push_back(Misc::ResourceHelpers::correctMeshPath(head->mModel, vfs)); models.push_back(Misc::ResourceHelpers::correctMeshPath(head->mModel, vfs));
} }
if (!npc->mBase->mHair.empty()) if (!npc->mBase->mHair.empty())
{ {
const ESM::BodyPart* hair const ESM::BodyPart* hair
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(npc->mBase->mHair); = MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>().search(npc->mBase->mHair);
if (hair) if (hair)
models.push_back(Misc::ResourceHelpers::correctMeshPath(hair->mModel, vfs)); 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; = (female && !it->mFemale.empty()) || (!female && it->mMale.empty()) ? it->mFemale : it->mMale;
const ESM::BodyPart* part const ESM::BodyPart* part
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(partname); = MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>().search(partname);
if (part && !part->mModel.empty()) if (part && !part->mModel.empty())
models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel, vfs)); models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel, vfs));
} }
@ -536,8 +528,8 @@ namespace MWClass
if (ptr.getRefData().getCustomData() if (ptr.getRefData().getCustomData()
&& ptr.getRefData().getCustomData()->asNpcCustomData().mNpcStats.isWerewolf()) && ptr.getRefData().getCustomData()->asNpcCustomData().mNpcStats.isWerewolf())
{ {
const MWBase::World* world = MWBase::Environment::get().getWorld(); const MWWorld::Store<ESM::GameSetting>& store
const MWWorld::Store<ESM::GameSetting>& store = world->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
return store.find("sWerewolfPopup")->mValue.getString(); 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 // 'ptr' is losing health. Play a 'hit' voiced dialog entry if not already saying
// something, alert the character controller, scripts, etc. // 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(); const GMST& gmst = getGmst();
int chance = store.get<ESM::GameSetting>().find("iVoiceHitOdds")->mValue.getInteger(); int chance = store.get<ESM::GameSetting>().find("iVoiceHitOdds")->mValue.getInteger();
@ -932,7 +924,7 @@ namespace MWClass
// Werewolfs can't activate NPCs // Werewolfs can't activate NPCs
if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) 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(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfNPC", prng); const ESM::Sound* sound = store.get<ESM::Sound>().searchRandom("WolfNPC", prng);
@ -1153,9 +1145,8 @@ namespace MWClass
{ {
const MWMechanics::CreatureStats& stats = getCreatureStats(ptr); const MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
static const float fEncumbranceStrMult = MWBase::Environment::get() static const float fEncumbranceStrMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fEncumbranceStrMult") .find("fEncumbranceStrMult")
->mValue.getFloat(); ->mValue.getFloat();
return stats.getAttribute(ESM::Attribute::Strength).getModified() * fEncumbranceStrMult; return stats.getAttribute(ESM::Attribute::Strength).getModified() * fEncumbranceStrMult;
@ -1187,16 +1178,15 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>(); MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>();
const ESM::Class* class_ const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(ref->mBase->mClass);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(ref->mBase->mClass);
stats.useSkill(skill, *class_, usageType, extraFactor); stats.useSkill(skill, *class_, usageType, extraFactor);
} }
float Npc::getArmorRating(const MWWorld::Ptr& ptr) const float Npc::getArmorRating(const MWWorld::Ptr& ptr) const
{ {
const MWBase::World* world = MWBase::Environment::get().getWorld(); const MWWorld::Store<ESM::GameSetting>& store
const MWWorld::Store<ESM::GameSetting>& store = world->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
MWMechanics::NpcStats& stats = getNpcStats(ptr); MWMechanics::NpcStats& stats = getNpcStats(ptr);
const MWWorld::InventoryStore& invStore = getInventoryStore(ptr); const MWWorld::InventoryStore& invStore = getInventoryStore(ptr);
@ -1249,8 +1239,7 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>(); const MWWorld::LiveCellRef<ESM::NPC>* ref = ptr.get<ESM::NPC>();
const ESM::Race* race const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(ref->mBase->mRace);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(ref->mBase->mRace);
// Race weight should not affect 1st-person meshes, otherwise it will change hand proportions and can break // Race weight should not affect 1st-person meshes, otherwise it will change hand proportions and can break
// aiming. // aiming.
@ -1283,8 +1272,7 @@ namespace MWClass
const ESM::NPC* npc = actor.get<ESM::NPC>()->mBase; const ESM::NPC* npc = actor.get<ESM::NPC>()->mBase;
if (npc->mFlags & ESM::NPC::Autocalc) if (npc->mFlags & ESM::NPC::Autocalc)
{ {
const ESM::Class* class_ const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(npc->mClass);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(npc->mClass);
return class_->mData.mServices; return class_->mData.mServices;
} }
return npc->mAiData.mServices; return npc->mAiData.mServices;
@ -1470,7 +1458,7 @@ namespace MWClass
return; return;
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fCorpseRespawnDelay = gmst.find("fCorpseRespawnDelay")->mValue.getFloat(); static const float fCorpseRespawnDelay = gmst.find("fCorpseRespawnDelay")->mValue.getFloat();
static const float fCorpseClearDelay = gmst.find("fCorpseClearDelay")->mValue.getFloat(); static const float fCorpseClearDelay = gmst.find("fCorpseClearDelay")->mValue.getFloat();

@ -155,7 +155,7 @@ namespace MWClass
= MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count); = MyGUI::TextIterator::toTagsString(MWGui::toUString(name)) + MWGui::ToolTips::getCountString(count);
info.icon = ref->mBase->mIcon; 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; std::string text;
@ -269,7 +269,7 @@ namespace MWClass
newItem.mData.mEnchant = enchCharge; newItem.mData.mEnchant = enchCharge;
newItem.mEnchant = enchId; newItem.mEnchant = enchId;
newItem.mData.mFlags |= ESM::Weapon::Magical; newItem.mData.mFlags |= ESM::Weapon::Magical;
const ESM::Weapon* record = MWBase::Environment::get().getWorld()->createRecord(newItem); const ESM::Weapon* record = MWBase::Environment::get().getESMStore()->insert(newItem);
return record->mId; return record->mId;
} }

@ -155,8 +155,7 @@ namespace MWDialogue
mActorKnownTopics.clear(); mActorKnownTopics.clear();
// greeting // greeting
const MWWorld::Store<ESM::Dialogue>& dialogs const MWWorld::Store<ESM::Dialogue>& dialogs = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>();
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
Filter filter(actor, mChoice, mTalkedTo); Filter filter(actor, mChoice, mTalkedTo);
@ -288,8 +287,7 @@ namespace MWDialogue
{ {
Filter filter(mActor, mChoice, mTalkedTo); Filter filter(mActor, mChoice, mTalkedTo);
const MWWorld::Store<ESM::Dialogue>& dialogues const MWWorld::Store<ESM::Dialogue>& dialogues = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>();
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
const ESM::Dialogue& dialogue = *dialogues.find(topic); const ESM::Dialogue& dialogue = *dialogues.find(topic);
@ -308,7 +306,7 @@ namespace MWDialogue
modifiedTopic.erase(std::remove(modifiedTopic.begin(), modifiedTopic.end(), ' '), modifiedTopic.end()); modifiedTopic.erase(std::remove(modifiedTopic.begin(), modifiedTopic.end(), ' '), modifiedTopic.end());
const MWWorld::Store<ESM::GameSetting>& gmsts const MWWorld::Store<ESM::GameSetting>& gmsts
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
title = gmsts.find(modifiedTopic)->mValue.getString(); title = gmsts.find(modifiedTopic)->mValue.getString();
} }
@ -343,7 +341,7 @@ namespace MWDialogue
const ESM::Dialogue* DialogueManager::searchDialogue(const ESM::RefId& id) const ESM::Dialogue* DialogueManager::searchDialogue(const ESM::RefId& id)
{ {
return MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().search(id); return MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().search(id);
} }
void DialogueManager::updateGlobals() void DialogueManager::updateGlobals()
@ -357,7 +355,7 @@ namespace MWDialogue
mActorKnownTopics.clear(); mActorKnownTopics.clear();
const auto& dialogs = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); const auto& dialogs = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>();
Filter filter(mActor, -1, mTalkedTo); Filter filter(mActor, -1, mTalkedTo);
@ -607,8 +605,7 @@ namespace MWDialogue
{ {
Filter filter(mActor, service, mTalkedTo); Filter filter(mActor, service, mTalkedTo);
const MWWorld::Store<ESM::Dialogue>& dialogues const MWWorld::Store<ESM::Dialogue>& dialogues = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>();
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
const ESM::Dialogue& dialogue = *dialogues.find(ESM::RefId::stringRefId("Service Refusal")); const ESM::Dialogue& dialogue = *dialogues.find(ESM::RefId::stringRefId("Service Refusal"));
@ -620,7 +617,7 @@ namespace MWDialogue
addTopicsFromText(info->mResponse); addTopicsFromText(info->mResponse);
const MWWorld::Store<ESM::GameSetting>& gmsts const MWWorld::Store<ESM::GameSetting>& gmsts
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor); MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(), mActor);
@ -654,7 +651,7 @@ namespace MWDialogue
return; return;
} }
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
const ESM::Dialogue* dial = store.get<ESM::Dialogue>().find(topic); const ESM::Dialogue* dial = store.get<ESM::Dialogue>().find(topic);
const MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor); const MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
@ -695,7 +692,7 @@ namespace MWDialogue
{ {
if (type == ESM::REC_DIAS) 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; ESM::DialogueState state;
state.load(reader); state.load(reader);
@ -712,8 +709,8 @@ namespace MWDialogue
void DialogueManager::modFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int diff) void DialogueManager::modFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int diff)
{ {
// Make sure the factions exist // Make sure the factions exist
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction1); MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction1);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction2); MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction2);
int newValue = getFactionReaction(faction1, faction2) + diff; 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) void DialogueManager::setFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int absolute)
{ {
// Make sure the factions exist // Make sure the factions exist
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction1); MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction1);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction2); MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction2);
auto& map = mChangedFactionReaction[faction1]; auto& map = mChangedFactionReaction[faction1];
map[faction2] = absolute; map[faction2] = absolute;
@ -737,8 +734,7 @@ namespace MWDialogue
if (map != mChangedFactionReaction.end() && map->second.find(faction2) != map->second.end()) if (map != mChangedFactionReaction.end() && map->second.find(faction2) != map->second.end())
return map->second.at(faction2); return map->second.at(faction2);
const ESM::Faction* faction const ESM::Faction* faction = MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction1);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction1);
auto it = faction->mReactions.begin(); auto it = faction->mReactions.begin();
for (; it != faction->mReactions.end(); ++it) for (; it != faction->mReactions.end(); ++it)

@ -650,8 +650,7 @@ bool MWDialogue::Filter::hasFactionRankSkillRequirements(
if (!actor.getClass().getNpcStats(actor).hasSkillsForRank(factionId, rank)) if (!actor.getClass().getNpcStats(actor).hasSkillsForRank(factionId, rank))
return false; return false;
const ESM::Faction& faction const ESM::Faction& faction = *MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(factionId);
= *MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(factionId);
MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor); MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor);
@ -667,8 +666,7 @@ bool MWDialogue::Filter::hasFactionRankReputationRequirements(
MWMechanics::NpcStats& stats = actor.getClass().getNpcStats(actor); MWMechanics::NpcStats& stats = actor.getClass().getNpcStats(actor);
const ESM::Faction& faction const ESM::Faction& faction = *MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(factionId);
= *MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(factionId);
return stats.getFactionReputation(factionId) >= faction.mData.mRankData[rank].mFactReaction; return stats.getFactionReputation(factionId) >= faction.mData.mRankData[rank].mFactReaction;
} }
@ -724,8 +722,7 @@ std::vector<const ESM::DialInfo*> MWDialogue::Filter::list(
// No response is valid because of low NPC disposition, // No response is valid because of low NPC disposition,
// search a response in the topic "Info Refusal" // search a response in the topic "Info Refusal"
const MWWorld::Store<ESM::Dialogue>& dialogues const MWWorld::Store<ESM::Dialogue>& dialogues = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>();
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>();
const ESM::Dialogue& infoRefusalDialogue = *dialogues.find(ESM::RefId::stringRefId("Info Refusal")); const ESM::Dialogue& infoRefusalDialogue = *dialogues.find(ESM::RefId::stringRefId("Info Refusal"));

@ -48,7 +48,7 @@ namespace MWDialogue
void tokenizeKeywords(const std::string& text, std::vector<Token>& tokens) void tokenizeKeywords(const std::string& text, std::vector<Token>& tokens)
{ {
const auto& keywordSearch const auto& keywordSearch
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().getDialogIdKeywordSearch(); = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().getDialogIdKeywordSearch();
std::vector<KeywordSearch<std::string, int /*unused*/>::Match> matches; std::vector<KeywordSearch<std::string, int /*unused*/>::Match> matches;
keywordSearch.highlightKeywords(text.begin(), text.end(), matches); keywordSearch.highlightKeywords(text.begin(), text.end(), matches);

@ -19,8 +19,7 @@ namespace MWDialogue
Entry::Entry(const ESM::RefId& topic, const ESM::RefId& infoId, const MWWorld::Ptr& actor) Entry::Entry(const ESM::RefId& topic, const ESM::RefId& infoId, const MWWorld::Ptr& actor)
: mInfoId(infoId) : mInfoId(infoId)
{ {
const ESM::Dialogue* dialogue const ESM::Dialogue* dialogue = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().find(topic);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(topic);
for (ESM::Dialogue::InfoContainer::const_iterator iter(dialogue->mInfo.begin()); iter != dialogue->mInfo.end(); for (ESM::Dialogue::InfoContainer::const_iterator iter(dialogue->mInfo.begin()); iter != dialogue->mInfo.end();
++iter) ++iter)
@ -87,8 +86,7 @@ namespace MWDialogue
const ESM::RefId& JournalEntry::idFromIndex(const ESM::RefId& topic, int index) const ESM::RefId& JournalEntry::idFromIndex(const ESM::RefId& topic, int index)
{ {
const ESM::Dialogue* dialogue const ESM::Dialogue* dialogue = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().find(topic);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(topic);
for (ESM::Dialogue::InfoContainer::const_iterator iter(dialogue->mInfo.begin()); iter != dialogue->mInfo.end(); for (ESM::Dialogue::InfoContainer::const_iterator iter(dialogue->mInfo.begin()); iter != dialogue->mInfo.end();
++iter) ++iter)

@ -49,7 +49,7 @@ namespace MWDialogue
bool Journal::isThere(const ESM::RefId& topicId, const ESM::RefId& infoId) const bool Journal::isThere(const ESM::RefId& topicId, const ESM::RefId& infoId) const
{ {
if (const ESM::Dialogue* dialogue if (const ESM::Dialogue* dialogue
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().search(topicId)) = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().search(topicId))
{ {
if (infoId.empty()) if (infoId.empty())
return true; return true;

@ -34,8 +34,7 @@ namespace MWDialogue
std::string_view Quest::getName() const std::string_view Quest::getName() const
{ {
const ESM::Dialogue* dialogue const ESM::Dialogue* dialogue = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().find(mTopic);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(mTopic);
for (ESM::Dialogue::InfoContainer::const_iterator iter(dialogue->mInfo.begin()); iter != dialogue->mInfo.end(); for (ESM::Dialogue::InfoContainer::const_iterator iter(dialogue->mInfo.begin()); iter != dialogue->mInfo.end();
++iter) ++iter)
@ -69,7 +68,7 @@ namespace MWDialogue
bool Quest::addEntry(const JournalEntry& entry) bool Quest::addEntry(const JournalEntry& entry)
{ {
const ESM::Dialogue* dialogue const ESM::Dialogue* dialogue
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(entry.mTopic); = MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().find(entry.mTopic);
auto info = std::find_if(dialogue->mInfo.begin(), dialogue->mInfo.end(), auto info = std::find_if(dialogue->mInfo.begin(), dialogue->mInfo.end(),
[&](const auto& info) { return info.mId == entry.mInfoId; }); [&](const auto& info) { return info.mId == entry.mInfoId; });

@ -91,7 +91,7 @@ namespace MWDialogue
std::pair<int, int> compileAll(const Compiler::Extensions* extensions, int warningsMode) std::pair<int, int> compileAll(const Compiler::Extensions* extensions, int warningsMode)
{ {
int compiled = 0, total = 0; 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); MWScript::CompilerContext compilerContext(MWScript::CompilerContext::Type_Dialogue);
compilerContext.setExtensions(extensions); compilerContext.setExtensions(extensions);

@ -11,8 +11,7 @@ namespace MWDialogue
Topic::Topic(const ESM::RefId& topic) Topic::Topic(const ESM::RefId& topic)
: mTopic(topic) : mTopic(topic)
, mName( , mName(MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().find(topic)->mId.getRefIdString())
MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find(topic)->mId.getRefIdString())
{ {
} }

@ -356,7 +356,7 @@ namespace MWGui
Widgets::SpellEffectParams params; Widgets::SpellEffectParams params;
params.mEffectID = effectKey.mId; params.mEffectID = effectKey.mId;
const ESM::MagicEffect* magicEffect const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectKey.mId); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effectKey.mId);
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill) if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill)
params.mSkill = effectKey.mArg; params.mSkill = effectKey.mArg;
else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute) else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute)

@ -147,8 +147,7 @@ namespace MWGui
{ {
mBirthList->removeAllItems(); mBirthList->removeAllItems();
const MWWorld::Store<ESM::BirthSign>& signs const MWWorld::Store<ESM::BirthSign>& signs = MWBase::Environment::get().getESMStore()->get<ESM::BirthSign>();
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>();
// sort by name // sort by name
std::vector<std::pair<ESM::RefId, const ESM::BirthSign*>> birthSigns; std::vector<std::pair<ESM::RefId, const ESM::BirthSign*>> birthSigns;
@ -192,7 +191,7 @@ namespace MWGui
const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), lineHeight); 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<ESM::BirthSign>().find(mCurrentBirthId); const ESM::BirthSign* birth = store.get<ESM::BirthSign>().find(mCurrentBirthId);

@ -353,7 +353,7 @@ namespace MWGui
if (!classId.empty()) if (!classId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId);
const ESM::Class* klass = MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(classId); const ESM::Class* klass = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(classId);
if (klass) if (klass)
{ {
mPlayerClass = *klass; mPlayerClass = *klass;
@ -686,8 +686,7 @@ namespace MWGui
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
const ESM::Class* klass const ESM::Class* klass = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(mGenerateClass);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(mGenerateClass);
mPlayerClass = *klass; mPlayerClass = *klass;
} }

@ -65,7 +65,7 @@ namespace MWGui
setClassImage(mClassImage, mCurrentClassId); setClassImage(mClassImage, mCurrentClassId);
mClassName->setCaption( mClassName->setCaption(
MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(mCurrentClassId)->mName); MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(mCurrentClassId)->mName);
center(); center();
} }
@ -208,7 +208,7 @@ namespace MWGui
{ {
mClassList->removeAllItems(); mClassList->removeAllItems();
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
std::vector<std::pair<ESM::RefId, std::string>> items; // class id, class name std::vector<std::pair<ESM::RefId, std::string>> items; // class id, class name
for (const ESM::Class& classInfo : store.get<ESM::Class>()) for (const ESM::Class& classInfo : store.get<ESM::Class>())
@ -246,7 +246,7 @@ namespace MWGui
{ {
if (mCurrentClassId.empty()) if (mCurrentClassId.empty())
return; return;
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
const ESM::Class* klass = store.get<ESM::Class>().search(mCurrentClassId); const ESM::Class* klass = store.get<ESM::Class>().search(mCurrentClassId);
if (!klass) if (!klass)
return; return;

@ -107,7 +107,7 @@ namespace MWGui
scanner.listKeywords(mNames); scanner.listKeywords(mNames);
// identifier // identifier
const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
std::vector<ESM::RefId> ids; std::vector<ESM::RefId> ids;
for (const auto* store : esmStore) for (const auto* store : esmStore)
{ {

@ -390,7 +390,7 @@ namespace MWGui
return; return;
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
const std::string& sPersuasion = gmst.find("sPersuasion")->mValue.getString(); const std::string& sPersuasion = gmst.find("sPersuasion")->mValue.getString();
const std::string& sCompanionShare = gmst.find("sCompanionShare")->mValue.getString(); const std::string& sCompanionShare = gmst.find("sCompanionShare")->mValue.getString();
@ -492,9 +492,8 @@ namespace MWGui
{ {
MWMechanics::CreatureStats& sellerStats = mPtr.getClass().getCreatureStats(mPtr); MWMechanics::CreatureStats& sellerStats = mPtr.getClass().getCreatureStats(mPtr);
float delay = MWBase::Environment::get() float delay = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fBarterGoldResetDelay") .find("fBarterGoldResetDelay")
->mValue.getFloat(); ->mValue.getFloat();
@ -545,7 +544,7 @@ namespace MWGui
&& !mPtr.get<ESM::Creature>()->mBase->getTransport().empty()); && !mPtr.get<ESM::Creature>()->mBase->getTransport().empty());
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
if (mPtr.getType() == ESM::NPC::sRecordId) if (mPtr.getType() == ESM::NPC::sRecordId)
mTopicsList->addItem(gmst.find("sPersuasion")->mValue.getString()); mTopicsList->addItem(gmst.find("sPersuasion")->mValue.getString());
@ -639,9 +638,8 @@ namespace MWGui
auto interactiveId = TypesetBook::InteractiveId(link.get()); auto interactiveId = TypesetBook::InteractiveId(link.get());
mLinks.push_back(std::move(link)); mLinks.push_back(std::move(link));
const std::string& goodbye = MWBase::Environment::get() const std::string& goodbye = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("sGoodbye") .find("sGoodbye")
->mValue.getString(); ->mValue.getString();
BookTypesetter::Style* questionStyle = typesetter->createHotStyle( BookTypesetter::Style* questionStyle = typesetter->createHotStyle(

@ -342,9 +342,8 @@ namespace MWGui
item.getCellRef().getRefId(), mPtr)) item.getCellRef().getRefId(), mPtr))
{ {
std::string msg = MWBase::Environment::get() std::string msg = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("sNotifyMessage49") .find("sNotifyMessage49")
->mValue.getString(); ->mValue.getString();
msg = Misc::StringUtils::format(msg, item.getClass().getName(item)); msg = Misc::StringUtils::format(msg, item.getClass().getName(item));

@ -394,7 +394,7 @@ namespace MWGui
void HUD::setSelectedSpell(const ESM::RefId& spellId, int successChancePercent) void HUD::setSelectedSpell(const ESM::RefId& spellId, int successChancePercent)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(spellId);
const std::string& spellName = spell->mName; const std::string& spellName = spell->mName;
if (spellName != mSpellName && mSpellVisible) if (spellName != mSpellName && mSpellVisible)
@ -412,7 +412,7 @@ namespace MWGui
mSpellBox->setUserString("Spell", spellId.serialize()); mSpellBox->setUserString("Spell", spellId.serialize());
// use the icon of the first effect // use the icon of the first effect
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find( const ESM::MagicEffect* effect = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(
spell->mEffects.mList.front().mEffectID); spell->mEffects.mList.front().mEffectID);
std::string icon = effect->mIcon; std::string icon = effect->mIcon;
@ -617,9 +617,8 @@ namespace MWGui
mEnemyHealth->setProgressPosition(static_cast<size_t>(stats.getHealth().getRatio() * 100)); mEnemyHealth->setProgressPosition(static_cast<size_t>(stats.getHealth().getRatio() * 100));
static const float fNPCHealthBarFade = MWBase::Environment::get() static const float fNPCHealthBarFade = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fNPCHealthBarFade") .find("fNPCHealthBarFade")
->mValue.getFloat(); ->mValue.getFloat();
if (fNPCHealthBarFade > 0.f) if (fNPCHealthBarFade > 0.f)
@ -630,9 +629,8 @@ namespace MWGui
{ {
mEnemyActorId = enemy.getClass().getCreatureStats(enemy).getActorId(); mEnemyActorId = enemy.getClass().getCreatureStats(enemy).getActorId();
mEnemyHealthTimer = MWBase::Environment::get() mEnemyHealthTimer = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fNPCHealthBarTime") .find("fNPCHealthBarTime")
->mValue.getFloat(); ->mValue.getFloat();
if (!mEnemyHealth->getVisible()) if (!mEnemyHealth->getVisible())

@ -194,7 +194,7 @@ namespace MWGui
if (enchId.empty()) if (enchId.empty())
break; break;
const ESM::Enchantment* ench const ESM::Enchantment* ench
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(enchId); = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().search(enchId);
if (!ench) if (!ench)
break; break;

@ -103,7 +103,7 @@ namespace MWGui
} }
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
std::string message; std::string message;
if (mDays == 1) if (mDays == 1)

@ -1315,8 +1315,8 @@ namespace MWGui
for (const ESM::GlobalMap::CellId& cellId : map.mMarkers) for (const ESM::GlobalMap::CellId& cellId : map.mMarkers)
{ {
const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>().search( const ESM::Cell* cell
cellId.first, cellId.second); = MWBase::Environment::get().getESMStore()->get<ESM::Cell>().search(cellId.first, cellId.second);
if (cell && !cell->mName.empty()) if (cell && !cell->mName.empty())
addVisitedLocation(cell->mName, cellId.first, cellId.second); addVisitedLocation(cell->mName, cellId.first, cellId.second);
} }

@ -56,9 +56,8 @@ namespace MWGui
int basePrice = iter->getClass().getValue(*iter); int basePrice = iter->getClass().getValue(*iter);
float fRepairMult = MWBase::Environment::get() float fRepairMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fRepairMult") .find("fRepairMult")
->mValue.getFloat(); ->mValue.getFloat();
@ -73,12 +72,7 @@ namespace MWGui
std::string name{ iter->getClass().getName(*iter) }; std::string name{ iter->getClass().getName(*iter) };
name += " - " + MyGUI::utility::toString(price) name += " - " + MyGUI::utility::toString(price)
+ MWBase::Environment::get() + MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find("sgp")->mValue.getString();
.getWorld()
->getStore()
.get<ESM::GameSetting>()
.find("sgp")
->mValue.getString();
MyGUI::Button* button = mList->createWidget<MyGUI::Button>(price <= playerGold MyGUI::Button* button = mList->createWidget<MyGUI::Button>(price <= playerGold
? "SandTextButton" ? "SandTextButton"

@ -287,7 +287,7 @@ namespace MWGui
while (mSelected->button->getChildCount()) // Destroy number label while (mSelected->button->getChildCount()) // Destroy number label
MyGUI::Gui::getInstance().destroyWidget(mSelected->button->getChildAt(0)); 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<ESM::Spell>().find(spellId); const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(spellId);
mSelected->type = ESM::QuickKeys::Type::Magic; mSelected->type = ESM::QuickKeys::Type::Magic;
@ -552,7 +552,7 @@ namespace MWGui
switch (quickKey.mType) switch (quickKey.mType)
{ {
case ESM::QuickKeys::Type::Magic: case ESM::QuickKeys::Type::Magic:
if (MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(quickKey.mId)) if (MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(quickKey.mId))
onAssignMagic(quickKey.mId); onAssignMagic(quickKey.mId);
break; break;
case ESM::QuickKeys::Type::Item: case ESM::QuickKeys::Type::Item:

@ -316,8 +316,7 @@ namespace MWGui
void RaceDialog::getBodyParts(int part, std::vector<ESM::RefId>& out) void RaceDialog::getBodyParts(int part, std::vector<ESM::RefId>& out)
{ {
out.clear(); out.clear();
const MWWorld::Store<ESM::BodyPart>& store const MWWorld::Store<ESM::BodyPart>& store = MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>();
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>();
for (const ESM::BodyPart& bodypart : store) for (const ESM::BodyPart& bodypart : store)
{ {
@ -373,7 +372,7 @@ namespace MWGui
{ {
mRaceList->removeAllItems(); mRaceList->removeAllItems();
const MWWorld::Store<ESM::Race>& races = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>(); const MWWorld::Store<ESM::Race>& races = MWBase::Environment::get().getESMStore()->get<ESM::Race>();
std::vector<std::pair<ESM::RefId, std::string>> items; // ID, name std::vector<std::pair<ESM::RefId, std::string>> items; // ID, name
for (const ESM::Race& race : races) for (const ESM::Race& race : races)
@ -411,7 +410,7 @@ namespace MWGui
const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18); 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<ESM::Race>().find(mCurrentRaceId); const ESM::Race* race = store.get<ESM::Race>().find(mCurrentRaceId);
int count = sizeof(race->mData.mBonus) int count = sizeof(race->mData.mBonus)
/ sizeof(race->mData.mBonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? / 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; const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), lineHeight); 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<ESM::Race>().find(mCurrentRaceId); const ESM::Race* race = store.get<ESM::Race>().find(mCurrentRaceId);
int i = 0; int i = 0;

@ -69,8 +69,7 @@ namespace MWGui
MWWorld::Ptr gem = *mGemIcon->getUserData<MWWorld::Ptr>(); MWWorld::Ptr gem = *mGemIcon->getUserData<MWWorld::Ptr>();
const ESM::RefId& soul = gem.getCellRef().getSoul(); const ESM::RefId& soul = gem.getCellRef().getSoul();
const ESM::Creature* creature const ESM::Creature* creature = MWBase::Environment::get().getESMStore()->get<ESM::Creature>().find(soul);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(soul);
mChargeLabel->setCaptionWithReplacing("#{sCharges} " + MyGUI::utility::toString(creature->mData.mSoul)); mChargeLabel->setCaptionWithReplacing("#{sCharges} " + MyGUI::utility::toString(creature->mData.mSoul));

@ -128,7 +128,7 @@ namespace MWGui
{ {
mRaceId = raceId; mRaceId = raceId;
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().search(mRaceId); const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().search(mRaceId);
if (race) if (race)
{ {
ToolTips::createRaceToolTip(mRaceWidget, race); ToolTips::createRaceToolTip(mRaceWidget, race);
@ -150,7 +150,7 @@ namespace MWGui
mBirthSignId = signId; mBirthSignId = signId;
const ESM::BirthSign* sign const ESM::BirthSign* sign
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().search(mBirthSignId); = MWBase::Environment::get().getESMStore()->get<ESM::BirthSign>().search(mBirthSignId);
if (sign) if (sign)
{ {
mBirthSignWidget->setCaption(sign->mName); mBirthSignWidget->setCaption(sign->mName);
@ -391,7 +391,7 @@ namespace MWGui
const ESM::Race* race = nullptr; const ESM::Race* race = nullptr;
if (!mRaceId.empty()) if (!mRaceId.empty())
race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(mRaceId); race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(mRaceId);
int skills[ESM::Skill::Length]; int skills[ESM::Skill::Length];
for (int i = 0; i < ESM::Skill::Length; ++i) for (int i = 0; i < ESM::Skill::Length; ++i)
@ -420,7 +420,7 @@ namespace MWGui
if (!mBirthSignId.empty()) if (!mBirthSignId.empty())
{ {
const ESM::BirthSign* sign const ESM::BirthSign* sign
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().find(mBirthSignId); = MWBase::Environment::get().getESMStore()->get<ESM::BirthSign>().find(mBirthSignId);
for (const auto& spellId : sign->mPowers.mList) for (const auto& spellId : sign->mPowers.mList)
{ {
if (std::find(spells.begin(), spells.end(), spellId) == spells.end()) if (std::find(spells.begin(), spells.end(), spellId) == spells.end())
@ -434,7 +434,7 @@ namespace MWGui
coord1, coord2); coord1, coord2);
for (auto& spellId : spells) for (auto& spellId : spells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Ability) if (spell->mData.mType == ESM::Spell::ST_Ability)
addItem(spell, coord1, coord2); addItem(spell, coord1, coord2);
} }
@ -444,7 +444,7 @@ namespace MWGui
coord2); coord2);
for (auto& spellId : spells) for (auto& spellId : spells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Power) if (spell->mData.mType == ESM::Spell::ST_Power)
addItem(spell, coord1, coord2); addItem(spell, coord1, coord2);
} }
@ -454,7 +454,7 @@ namespace MWGui
coord2); coord2);
for (auto& spellId : spells) for (auto& spellId : spells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(spellId);
if (spell->mData.mType == ESM::Spell::ST_Spell) if (spell->mData.mType == ESM::Spell::ST_Spell)
addItem(spell, coord1, coord2); addItem(spell, coord1, coord2);
} }

@ -189,8 +189,7 @@ namespace MWGui
{ {
// Find the localised name for this class from the store // Find the localised name for this class from the store
const ESM::Class* class_ const ESM::Class* class_
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().search( = MWBase::Environment::get().getESMStore()->get<ESM::Class>().search(signature.mPlayerClassId);
signature.mPlayerClassId);
if (class_) if (class_)
className = class_->mName; className = class_->mName;
else else

@ -106,7 +106,7 @@ namespace
if (!leftNameEnch.empty()) if (!leftNameEnch.empty())
{ {
const ESM::Enchantment* ench const ESM::Enchantment* ench
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(leftNameEnch); = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().search(leftNameEnch);
if (ench) if (ench)
{ {
if (ench->mData.mType == ESM::Enchantment::ConstantEffect) if (ench->mData.mType == ESM::Enchantment::ConstantEffect)
@ -120,7 +120,7 @@ namespace
if (!rightNameEnch.empty()) if (!rightNameEnch.empty())
{ {
const ESM::Enchantment* ench const ESM::Enchantment* ench
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(rightNameEnch); = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().search(rightNameEnch);
if (ench) if (ench)
{ {
if (ench->mData.mType == ESM::Enchantment::ConstantEffect) if (ench->mData.mType == ESM::Enchantment::ConstantEffect)
@ -263,8 +263,7 @@ namespace MWGui
return false; return false;
if ((mFilter & Filter_OnlyChargedSoulstones) if ((mFilter & Filter_OnlyChargedSoulstones)
&& (base.getType() != ESM::Miscellaneous::sRecordId || base.getCellRef().getSoul().empty() && (base.getType() != ESM::Miscellaneous::sRecordId || base.getCellRef().getSoul().empty()
|| !MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search( || !MWBase::Environment::get().getESMStore()->get<ESM::Creature>().search(base.getCellRef().getSoul())))
base.getCellRef().getSoul())))
return false; return false;
if ((mFilter & Filter_OnlyRepairTools) && (base.getType() != ESM::Repair::sRecordId)) if ((mFilter & Filter_OnlyRepairTools) && (base.getType() != ESM::Repair::sRecordId))
return false; return false;
@ -297,7 +296,7 @@ namespace MWGui
const ESM::RefId& enchId = base.getClass().getEnchantment(base); const ESM::RefId& enchId = base.getClass().getEnchantment(base);
const ESM::Enchantment* ench const ESM::Enchantment* ench
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(enchId); = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().search(enchId);
if (!ench) if (!ench)
{ {
Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchId << "' on item " Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchId << "' on item "

@ -40,7 +40,7 @@ namespace MWGui
void SpellBuyingWindow::addSpell(const ESM::Spell& spell) 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, int price = std::max(1,
static_cast<int>( static_cast<int>(
@ -103,7 +103,7 @@ namespace MWGui
if (actor.getClass().isNpc()) if (actor.getClass().isNpc())
{ {
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find( const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(
actor.get<ESM::NPC>()->mBase->mRace); actor.get<ESM::NPC>()->mBase->mRace);
if (race->mPowers.exists(spell->mId)) if (race->mPowers.exists(spell->mId))
continue; continue;

@ -35,7 +35,7 @@ namespace
bool sortMagicEffects(short id1, short id2) bool sortMagicEffects(short id1, short id2)
{ {
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
return gmst.find(ESM::MagicEffect::effectIdToString(id1))->mValue.getString() return gmst.find(ESM::MagicEffect::effectIdToString(id1))->mValue.getString()
< gmst.find(ESM::MagicEffect::effectIdToString(id2))->mValue.getString(); < gmst.find(ESM::MagicEffect::effectIdToString(id2))->mValue.getString();
@ -161,7 +161,7 @@ namespace MWGui
void EditEffectDialog::editEffect(ESM::ENAMstruct effect) void EditEffectDialog::editEffect(ESM::ENAMstruct effect)
{ {
const ESM::MagicEffect* magicEffect const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effect.mEffectID); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effect.mEffectID);
setMagicEffect(magicEffect); setMagicEffect(magicEffect);
mOldEffect = effect; mOldEffect = effect;
@ -416,7 +416,7 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Mysticism Hit")); 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().getESMStore()->insert(mSpell);
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player); MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
MWMechanics::Spells& spells = stats.getSpells(); MWMechanics::Spells& spells = stats.getSpells();
@ -457,7 +457,7 @@ namespace MWGui
float y = 0; 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) for (const ESM::ENAMstruct& effect : mEffects)
{ {
@ -529,8 +529,7 @@ namespace MWGui
for (const ESM::ENAMstruct& effectInfo : spell->mEffects.mList) for (const ESM::ENAMstruct& effectInfo : spell->mEffects.mList)
{ {
const ESM::MagicEffect* effect const ESM::MagicEffect* effect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find( = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effectInfo.mEffectID);
effectInfo.mEffectID);
// skip effects that do not allow spellmaking/enchanting // skip effects that do not allow spellmaking/enchanting
int requiredFlags int requiredFlags
@ -551,9 +550,8 @@ namespace MWGui
for (const short effectId : knownEffects) for (const short effectId : knownEffects)
{ {
mAvailableEffectsList->addItem(MWBase::Environment::get() mAvailableEffectsList->addItem(MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find(ESM::MagicEffect::effectIdToString(effectId)) .find(ESM::MagicEffect::effectIdToString(effectId))
->mValue.getString()); ->mValue.getString());
mButtonMapping[i] = effectId; mButtonMapping[i] = effectId;
@ -565,9 +563,8 @@ namespace MWGui
for (const short effectId : knownEffects) for (const short effectId : knownEffects)
{ {
const std::string& name = MWBase::Environment::get() const std::string& name = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find(ESM::MagicEffect::effectIdToString(effectId)) .find(ESM::MagicEffect::effectIdToString(effectId))
->mValue.getString(); ->mValue.getString();
MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name);
@ -591,7 +588,7 @@ namespace MWGui
void EffectEditorBase::onSelectAttribute() void EffectEditorBase::onSelectAttribute()
{ {
const ESM::MagicEffect* effect const ESM::MagicEffect* effect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(mSelectedKnownEffectId); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(mSelectedKnownEffectId);
mAddEffectDialog.newEffect(effect); mAddEffectDialog.newEffect(effect);
mAddEffectDialog.setAttribute(mSelectAttributeDialog->getAttributeId()); mAddEffectDialog.setAttribute(mSelectAttributeDialog->getAttributeId());
@ -601,7 +598,7 @@ namespace MWGui
void EffectEditorBase::onSelectSkill() void EffectEditorBase::onSelectSkill()
{ {
const ESM::MagicEffect* effect const ESM::MagicEffect* effect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(mSelectedKnownEffectId); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(mSelectedKnownEffectId);
mAddEffectDialog.newEffect(effect); mAddEffectDialog.newEffect(effect);
mAddEffectDialog.setSkill(mSelectSkillDialog->getSkillId()); mAddEffectDialog.setSkill(mSelectSkillDialog->getSkillId());
@ -628,7 +625,7 @@ namespace MWGui
mSelectedKnownEffectId = mButtonMapping[buttonId]; mSelectedKnownEffectId = mButtonMapping[buttonId];
const ESM::MagicEffect* effect const ESM::MagicEffect* effect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(mSelectedKnownEffectId); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(mSelectedKnownEffectId);
bool allowSelf = (effect->mData.mFlags & ESM::MagicEffect::CastSelf) != 0; bool allowSelf = (effect->mData.mFlags & ESM::MagicEffect::CastSelf) != 0;
bool allowTouch = (effect->mData.mFlags & ESM::MagicEffect::CastTouch) && !mConstantEffect; bool allowTouch = (effect->mData.mFlags & ESM::MagicEffect::CastTouch) && !mConstantEffect;
@ -761,7 +758,7 @@ namespace MWGui
{ {
if (it->mRange != ESM::RT_Self) if (it->mRange != ESM::RT_Self)
{ {
auto& store = MWBase::Environment::get().getWorld()->getStore(); auto& store = *MWBase::Environment::get().getESMStore();
auto magicEffect = store.get<ESM::MagicEffect>().find(it->mEffectID); auto magicEffect = store.get<ESM::MagicEffect>().find(it->mEffectID);
if ((magicEffect->mData.mFlags & ESM::MagicEffect::CastSelf) == 0) if ((magicEffect->mData.mFlags & ESM::MagicEffect::CastSelf) == 0)
{ {

@ -52,7 +52,7 @@ namespace MWGui
for (const auto& [effectId, effectInfos] : effects) for (const auto& [effectId, effectInfos] : effects)
{ {
const ESM::MagicEffect* effect const ESM::MagicEffect* effect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectId); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effectId);
float remainingDuration = 0; float remainingDuration = 0;
float totalDuration = 0; float totalDuration = 0;
@ -60,9 +60,8 @@ namespace MWGui
std::string sourcesDescription; std::string sourcesDescription;
static const float fadeTime = MWBase::Environment::get() static const float fadeTime = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fMagicStartIconBlink") .find("fMagicStartIconBlink")
->mValue.getFloat(); ->mValue.getFloat();

@ -45,7 +45,7 @@ namespace MWGui
bool SpellModel::matchingEffectExists(std::string filter, const ESM::EffectList& effects) 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) for (const auto& effect : effects.mList)
{ {
@ -75,7 +75,7 @@ namespace MWGui
MWMechanics::CreatureStats& stats = mActor.getClass().getCreatureStats(mActor); MWMechanics::CreatureStats& stats = mActor.getClass().getCreatureStats(mActor);
const MWMechanics::Spells& spells = stats.getSpells(); 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); std::string filter = Utf8Stream::lowerCaseUtf8(mFilter);

@ -139,18 +139,17 @@ namespace MWGui
void SpellWindow::askDeleteSpell(const ESM::RefId& spellId) void SpellWindow::askDeleteSpell(const ESM::RefId& spellId)
{ {
// delete spell, if allowed // delete spell, if allowed
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(spellId);
MWWorld::Ptr player = MWMechanics::getPlayer(); MWWorld::Ptr player = MWMechanics::getPlayer();
const ESM::RefId& raceId = player.get<ESM::NPC>()->mBase->mRace; const ESM::RefId& raceId = player.get<ESM::NPC>()->mBase->mRace;
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(raceId); const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(raceId);
// can't delete racial spells, birthsign spells or powers // can't delete racial spells, birthsign spells or powers
bool isInherent = race->mPowers.exists(spell->mId) || spell->mData.mType == ESM::Spell::ST_Power; bool isInherent = race->mPowers.exists(spell->mId) || spell->mData.mType == ESM::Spell::ST_Power;
const ESM::RefId& signId = MWBase::Environment::get().getWorld()->getPlayer().getBirthSign(); const ESM::RefId& signId = MWBase::Environment::get().getWorld()->getPlayer().getBirthSign();
if (!isInherent && !signId.empty()) if (!isInherent && !signId.empty())
{ {
const ESM::BirthSign* sign const ESM::BirthSign* sign = MWBase::Environment::get().getESMStore()->get<ESM::BirthSign>().find(signId);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().find(signId);
isInherent = sign->mPowers.exists(spell->mId); isInherent = sign->mPowers.exists(spell->mId);
} }

@ -67,9 +67,8 @@ namespace MWGui
if (timeToDrown != mWatchedTimeToStartDrowning) if (timeToDrown != mWatchedTimeToStartDrowning)
{ {
static const float fHoldBreathTime = MWBase::Environment::get() static const float fHoldBreathTime = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fHoldBreathTime") .find("fHoldBreathTime")
->mValue.getFloat(); ->mValue.getFloat();
@ -114,7 +113,7 @@ namespace MWGui
{ {
mWatchedRace = watchedRecord->mRace; mWatchedRace = watchedRecord->mRace;
const ESM::Race* race const ESM::Race* race
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(watchedRecord->mRace); = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(watchedRecord->mRace);
setValue("race", race->mName); setValue("race", race->mName);
} }
@ -122,7 +121,7 @@ namespace MWGui
{ {
mWatchedClass = watchedRecord->mClass; mWatchedClass = watchedRecord->mClass;
const ESM::Class* cls const ESM::Class* cls
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(watchedRecord->mClass); = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(watchedRecord->mClass);
setValue("class", cls->mName); setValue("class", cls->mName);
MWBase::WindowManager::SkillList majorSkills(5); MWBase::WindowManager::SkillList majorSkills(5);

@ -57,7 +57,7 @@ namespace MWGui
{ "Attrib6", "sAttributeEndurance" }, { "Attrib7", "sAttributePersonality" }, { "Attrib6", "sAttributeEndurance" }, { "Attrib7", "sAttributePersonality" },
{ "Attrib8", "sAttributeLuck" }, { 0, 0 } }; { "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) for (int i = 0; names[i][0]; ++i)
{ {
setText(names[i][0], store.get<ESM::GameSetting>().find(names[i][1])->mValue.getString()); setText(names[i][0], store.get<ESM::GameSetting>().find(names[i][1])->mValue.getString());
@ -240,7 +240,7 @@ namespace MWGui
void setSkillProgress(MyGUI::Widget* w, float progress, int skillId) void setSkillProgress(MyGUI::Widget* w, float progress, int skillId)
{ {
MWWorld::Ptr player = MWMechanics::getPlayer(); 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( float progressRequirement = player.getClass().getNpcStats(player).getSkillProgressRequirement(
skillId, *esmStore.get<ESM::Class>().find(player.get<ESM::NPC>()->mBase->mClass)); skillId, *esmStore.get<ESM::Class>().find(player.get<ESM::NPC>()->mBase->mClass));
@ -358,9 +358,8 @@ namespace MWGui
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
int max = MWBase::Environment::get() int max = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("iLevelUpTotal") .find("iLevelUpTotal")
->mValue.getInteger(); ->mValue.getInteger();
getWidget(levelWidget, i == 0 ? "Level_str" : "LevelText"); getWidget(levelWidget, i == 0 ? "Level_str" : "LevelText");
@ -510,7 +509,7 @@ namespace MWGui
continue; continue;
const std::string& skillNameId = ESM::Skill::sSkillNameIds[skillId]; 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<ESM::Skill>().find(skillId); const ESM::Skill* skill = esmStore.get<ESM::Skill>().find(skillId);

@ -226,7 +226,7 @@ namespace MWGui
{ {
ToolTipInfo info; ToolTipInfo info;
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find( const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(
ESM::RefId::deserialize(focus->getUserString("Spell"))); ESM::RefId::deserialize(focus->getUserString("Spell")));
info.caption = spell->mName; info.caption = spell->mName;
Widgets::SpellEffectList effects; Widgets::SpellEffectList effects;
@ -420,7 +420,7 @@ namespace MWGui
text.erase(0, 1); text.erase(0, 1);
const ESM::Enchantment* enchant = nullptr; 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()) if (!info.enchant.empty())
{ {
enchant = store.get<ESM::Enchantment>().search(info.enchant); enchant = store.get<ESM::Enchantment>().search(info.enchant);
@ -681,7 +681,7 @@ namespace MWGui
const ESM::RefId& soul = cellref.getSoul(); const ESM::RefId& soul = cellref.getSoul();
if (soul.empty()) if (soul.empty())
return {}; return {};
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
const ESM::Creature* creature = store.get<ESM::Creature>().search(soul); const ESM::Creature* creature = store.get<ESM::Creature>().search(soul);
if (!creature) if (!creature)
return {}; return {};
@ -697,7 +697,7 @@ namespace MWGui
const ESM::RefId& factionId = cellref.getFaction(); const ESM::RefId& factionId = cellref.getFaction();
if (!factionId.empty()) 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<ESM::Faction>().search(factionId); const ESM::Faction* fact = store.get<ESM::Faction>().search(factionId);
if (fact != nullptr) if (fact != nullptr)
{ {
@ -809,7 +809,7 @@ namespace MWGui
if (skillId == -1) if (skillId == -1)
return; 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 std::string& skillNameId = ESM::Skill::sSkillNameIds[skillId];
const ESM::Skill* skill = store.get<ESM::Skill>().find(skillId); const ESM::Skill* skill = store.get<ESM::Skill>().find(skillId);
@ -848,7 +848,7 @@ namespace MWGui
widget->setUserString("Caption_Caption", name); widget->setUserString("Caption_Caption", name);
std::string specText; std::string specText;
// get all skills of this specialisation // get all skills of this specialisation
const MWWorld::Store<ESM::Skill>& skills = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>(); const MWWorld::Store<ESM::Skill>& skills = MWBase::Environment::get().getESMStore()->get<ESM::Skill>();
bool isFirst = true; bool isFirst = true;
for (auto& skillPair : skills) for (auto& skillPair : skills)
@ -870,7 +870,7 @@ namespace MWGui
void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const ESM::RefId& birthsignId) 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<ESM::BirthSign>().find(birthsignId); const ESM::BirthSign* sign = store.get<ESM::BirthSign>().find(birthsignId);
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
@ -953,8 +953,7 @@ namespace MWGui
void ToolTips::createMagicEffectToolTip(MyGUI::Widget* widget, short id) void ToolTips::createMagicEffectToolTip(MyGUI::Widget* widget, short id)
{ {
const ESM::MagicEffect* effect const ESM::MagicEffect* effect = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(id);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(id);
const std::string& name = ESM::MagicEffect::effectIdToString(id); const std::string& name = ESM::MagicEffect::effectIdToString(id);
std::string icon = effect->mIcon; std::string icon = effect->mIcon;

@ -273,7 +273,7 @@ namespace MWGui
= MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel(); = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel();
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
if (mTotalBalance->getValue() == 0) if (mTotalBalance->getValue() == 0)
mCurrentBalance = 0; mCurrentBalance = 0;

@ -98,7 +98,7 @@ namespace MWGui
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats(player); MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats(player);
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
@ -146,7 +146,7 @@ namespace MWGui
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats(player); 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() int price = pcStats.getSkill(skillId).getBase()
* store.get<ESM::GameSetting>().find("iTrainingMod")->mValue.getInteger(); * store.get<ESM::GameSetting>().find("iTrainingMod")->mValue.getInteger();
@ -162,7 +162,7 @@ namespace MWGui
} }
// You can not train a skill above its governing attribute // You can not train a skill above its governing attribute
const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find(skillId); const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().find(skillId);
if (pcStats.getSkill(skillId).getBase() >= pcStats.getAttribute(skill->mData.mAttribute).getBase()) if (pcStats.getSkill(skillId).getBase() >= pcStats.getAttribute(skill->mData.mAttribute).getBase())
{ {
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage17}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage17}");

@ -49,7 +49,7 @@ namespace MWGui
int price; int price;
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId); 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(); = (osg::Vec3f(pos.pos[0], pos.pos[1], 0) - osg::Vec3f(playerPos.pos[0], playerPos.pos[1], 0)).length();
int hours = static_cast<int>(d int hours = static_cast<int>(d
/ MWBase::Environment::get() / MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fTravelTimeMult") .find("fTravelTimeMult")
->mValue.getFloat()); ->mValue.getFloat());
MWBase::Environment::get().getMechanicsManager()->rest(hours, true); MWBase::Environment::get().getMechanicsManager()->rest(hours, true);

@ -279,7 +279,7 @@ namespace MWGui
// trigger levelup if possible // trigger levelup if possible
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
if (mSleeping && pcstats.getLevelProgress() >= gmst.find("iLevelUpTotal")->mValue.getInteger()) if (mSleeping && pcstats.getLevelProgress() >= gmst.find("iLevelUpTotal")->mValue.getInteger())
{ {
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Levelup); MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Levelup);

@ -214,7 +214,7 @@ namespace MWGui::Widgets
void MWSpell::createEffectWidgets( void MWSpell::createEffectWidgets(
std::vector<MyGUI::Widget*>& effects, MyGUI::Widget* creator, MyGUI::IntCoord& coord, int flags) std::vector<MyGUI::Widget*>& 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<ESM::Spell>().search(mId); const ESM::Spell* spell = store.get<ESM::Spell>().search(mId);
MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found");
@ -245,7 +245,7 @@ namespace MWGui::Widgets
{ {
if (mSpellNameWidget && MWBase::Environment::get().getWindowManager()) 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<ESM::Spell>().search(mId); const ESM::Spell* spell = store.get<ESM::Spell>().search(mId);
if (spell) if (spell)
@ -375,7 +375,7 @@ namespace MWGui::Widgets
return; return;
} }
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
const ESM::MagicEffect* magicEffect = store.get<ESM::MagicEffect>().search(mEffectParams.mEffectID); const ESM::MagicEffect* magicEffect = store.get<ESM::MagicEffect>().search(mEffectParams.mEffectID);

@ -71,7 +71,7 @@ namespace MWLua
api["magic"] = initCoreMagicBindings(context); api["magic"] = initCoreMagicBindings(context);
api["l10n"] = LuaUtil::initL10nLoader(lua->sol(), MWBase::Environment::get().getL10nManager()); api["l10n"] = LuaUtil::initL10nLoader(lua->sol(), MWBase::Environment::get().getL10nManager());
const MWWorld::Store<ESM::GameSetting>* gmst const MWWorld::Store<ESM::GameSetting>* gmst
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = &MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
api["getGMST"] = [lua = context.mLua, gmst](const std::string& setting) -> sol::object { api["getGMST"] = [lua = context.mLua, gmst](const std::string& setting) -> sol::object {
const ESM::Variant& value = gmst->find(setting)->mValue; const ESM::Variant& value = gmst->find(setting)->mValue;
if (value.getType() == ESM::VT_String) 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. // 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::CellStore* cell = MWBase::Environment::get().getWorldScene()->getCurrentCell();
MWWorld::ManualRef mref( MWWorld::ManualRef mref(*MWBase::Environment::get().getESMStore(), ESM::RefId::deserializeText(recordId));
MWBase::Environment::get().getWorld()->getStore(), ESM::RefId::deserializeText(recordId));
const MWWorld::Ptr& ptr = mref.getPtr(); const MWWorld::Ptr& ptr = mref.getPtr();
ptr.getRefData().disable(); ptr.getRefData().disable();
MWWorld::Ptr newPtr = ptr.getClass().copyToCell(ptr, *cell, count.value_or(1)); 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. // Creates a new record in the world database.
api["createRecord"] = sol::overload([](const ESM::Potion& potion) -> const ESM::Potion* { api["createRecord"] = sol::overload([](const ESM::Potion& potion) -> const ESM::Potion* {
return MWBase::Environment::get().getWorld()->createRecord(potion); return MWBase::Environment::get().getESMStore()->insert(potion);
} }
// TODO: add here overloads for other records // TODO: add here overloads for other records
); );

@ -67,7 +67,7 @@ namespace MWLua
void LuaManager::initConfiguration() 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):"; Log(Debug::Verbose) << "Lua scripts configuration (" << mConfiguration.size() << " scripts):";
for (size_t i = 0; i < mConfiguration.size(); ++i) for (size_t i = 0; i < mConfiguration.size(); ++i)
Log(Debug::Verbose) << "#" << i << " " << LuaUtil::scriptCfgToString(mConfiguration[i]); Log(Debug::Verbose) << "#" << i << " " << LuaUtil::scriptCfgToString(mConfiguration[i]);

@ -261,7 +261,7 @@ namespace MWLua
static float getMaxProgress(const MWWorld::Ptr& ptr, int index, const MWMechanics::SkillValue& stat) 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<ESM::Class>().find(ptr.get<ESM::NPC>()->mBase->mClass); const auto cl = store.get<ESM::Class>().find(ptr.get<ESM::NPC>()->mBase->mClass);
return ptr.getClass().getNpcStats(ptr).getSkillProgressRequirement(index, *cl); return ptr.getClass().getNpcStats(ptr).getSkillProgressRequirement(index, *cl);
} }

@ -28,7 +28,7 @@ namespace MWLua
miscellaneous["setSoul"] = [](const GObject& object, std::string_view soulId) { miscellaneous["setSoul"] = [](const GObject& object, std::string_view soulId) {
ESM::RefId creature = ESM::RefId::deserializeText(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<ESM::Creature>().search(creature)) if (!store.get<ESM::Creature>().search(creature))
{ {

@ -69,7 +69,7 @@ namespace MWLua
void addRecordFunctionBinding( void addRecordFunctionBinding(
sol::table table, const Context& context, const std::string& recordName = std::string(T::getRecordType())) sol::table table, const Context& context, const std::string& recordName = std::string(T::getRecordType()))
{ {
const MWWorld::Store<T>& store = MWBase::Environment::get().getWorld()->getStore().get<T>(); const MWWorld::Store<T>& store = MWBase::Environment::get().getESMStore()->get<T>();
table["record"] = sol::overload([](const Object& obj) -> const T* { return obj.ptr().get<T>()->mBase; }, table["record"] = sol::overload([](const Object& obj) -> const T* { return obj.ptr().get<T>()->mBase; },
[&store](std::string_view id) -> const T* { return store.find(ESM::RefId::deserializeText(id)); }); [&store](std::string_view id) -> const T* { return store.find(ESM::RefId::deserializeText(id)); });

@ -323,8 +323,7 @@ namespace MWMechanics
} }
if (reflected) if (reflected)
{ {
const ESM::Static* reflectStatic const ESM::Static* reflectStatic = MWBase::Environment::get().getESMStore()->get<ESM::Static>().find(
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find(
ESM::RefId::stringRefId("VFX_Reflect")); ESM::RefId::stringRefId("VFX_Reflect"));
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr);
if (animation && !reflectStatic->mModel.empty()) if (animation && !reflectStatic->mModel.empty())

@ -102,7 +102,7 @@ namespace
{ {
const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
const MWWorld::Store<ESM::GameSetting>& settings const MWWorld::Store<ESM::GameSetting>& settings
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
const float endurance = stats.getAttribute(ESM::Attribute::Endurance).getModified(); const float endurance = stats.getAttribute(ESM::Attribute::Endurance).getModified();
const float health = 0.1f * endurance; const float health = 0.1f * endurance;
@ -262,15 +262,13 @@ namespace MWMechanics
return; return;
static const float fMaxHeadTrackDistance = MWBase::Environment::get() static const float fMaxHeadTrackDistance = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fMaxHeadTrackDistance") .find("fMaxHeadTrackDistance")
->mValue.getFloat(); ->mValue.getFloat();
static const float fInteriorHeadTrackMult = MWBase::Environment::get() static const float fInteriorHeadTrackMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fInteriorHeadTrackMult") .find("fInteriorHeadTrackMult")
->mValue.getFloat(); ->mValue.getFloat();
float maxDistance = fMaxHeadTrackDistance; float maxDistance = fMaxHeadTrackDistance;
@ -493,9 +491,8 @@ namespace MWMechanics
// Play a random voice greeting if the player gets too close // Play a random voice greeting if the player gets too close
static const int iGreetDistanceMultiplier = MWBase::Environment::get() static const int iGreetDistanceMultiplier = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("iGreetDistanceMultiplier") .find("iGreetDistanceMultiplier")
->mValue.getInteger(); ->mValue.getInteger();
@ -820,7 +817,7 @@ namespace MWMechanics
return; return;
const MWWorld::Store<ESM::GameSetting>& settings const MWWorld::Store<ESM::GameSetting>& settings
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
if (sleep) if (sleep)
{ {
@ -898,7 +895,7 @@ namespace MWMechanics
// Restore fatigue // Restore fatigue
const float endurance = stats.getAttribute(ESM::Attribute::Endurance).getModified(); const float endurance = stats.getAttribute(ESM::Attribute::Endurance).getModified();
const MWWorld::Store<ESM::GameSetting>& settings const MWWorld::Store<ESM::GameSetting>& settings
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fFatigueReturnBase = settings.find("fFatigueReturnBase")->mValue.getFloat(); static const float fFatigueReturnBase = settings.find("fFatigueReturnBase")->mValue.getFloat();
static const float fFatigueReturnMult = settings.find("fFatigueReturnMult")->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 // When npc stats are just initialized, mTimeToStartDrowning == -1 and we should get value from GMST
static const float fHoldBreathTime = MWBase::Environment::get() static const float fHoldBreathTime = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fHoldBreathTime") .find("fHoldBreathTime")
->mValue.getFloat(); ->mValue.getFloat();
if (stats.getTimeToStartDrowning() == -1.f) if (stats.getTimeToStartDrowning() == -1.f)
@ -1848,7 +1844,7 @@ namespace MWMechanics
{ {
MWBase::Environment::get().getWorld()->deleteObject(ptr); MWBase::Environment::get().getWorld()->deleteObject(ptr);
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().search( const ESM::Static* fx = MWBase::Environment::get().getESMStore()->get<ESM::Static>().search(
ESM::RefId::stringRefId("VFX_Summon_End")); ESM::RefId::stringRefId("VFX_Summon_End"));
if (fx) if (fx)
{ {
@ -2301,7 +2297,7 @@ namespace MWMechanics
ESM::RefId id = reader.getRefId(); ESM::RefId id = reader.getRefId();
int count; int count;
reader.getHNT(count, "COUN"); reader.getHNT(count, "COUN");
if (MWBase::Environment::get().getWorld()->getStore().find(id)) if (MWBase::Environment::get().getESMStore()->find(id))
mDeathCount[id] = count; mDeathCount[id] = count;
} }
} }

@ -14,12 +14,8 @@
bool MWMechanics::AiBreathe::execute( bool MWMechanics::AiBreathe::execute(
const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{ {
static const float fHoldBreathTime = MWBase::Environment::get() static const float fHoldBreathTime
.getWorld() = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find("fHoldBreathTime")->mValue.getFloat();
->getStore()
.get<ESM::GameSetting>()
.find("fHoldBreathTime")
->mValue.getFloat();
const MWWorld::Class& actorClass = actor.getClass(); const MWWorld::Class& actorClass = actor.getClass();
if (actorClass.isNpc()) if (actorClass.isNpc())

@ -362,7 +362,7 @@ namespace MWMechanics
if (storage.mLOS && (triggerDist >= 1000 || getDistanceMinusHalfExtents(actor, target) <= triggerDist)) if (storage.mLOS && (triggerDist >= 1000 || getDistanceMinusHalfExtents(actor, target) <= triggerDist))
{ {
const ESM::Pathgrid* pathgrid const ESM::Pathgrid* pathgrid
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*cellVariant); = MWBase::Environment::get().getESMStore()->get<ESM::Pathgrid>().search(*cellVariant);
bool runFallback = true; bool runFallback = true;
@ -429,9 +429,8 @@ namespace MWMechanics
case AiCombatStorage::FleeState_RunToDestination: case AiCombatStorage::FleeState_RunToDestination:
{ {
static const float fFleeDistance = MWBase::Environment::get() static const float fFleeDistance = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fFleeDistance") .find("fFleeDistance")
->mValue.getFloat(); ->mValue.getFloat();
@ -649,7 +648,7 @@ namespace MWMechanics
auto& prng = MWBase::Environment::get().getWorld()->getPrng(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();
mStrength = Misc::Rng::rollClosedProbability(prng); 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<ESM::GameSetting>().find("fCombatDelayCreature")->mValue.getFloat(); float baseDelay = store.get<ESM::GameSetting>().find("fCombatDelayCreature")->mValue.getFloat();
if (actor.getClass().isNpc()) if (actor.getClass().isNpc())
@ -741,7 +740,7 @@ namespace
{ {
float projSpeed; float projSpeed;
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
// get projectile speed (depending on weapon type) // get projectile speed (depending on weapon type)
if (MWMechanics::getWeaponType(weapType)->mWeaponClass == ESM::WeaponType::Thrown) if (MWMechanics::getWeaponType(weapType)->mWeaponClass == ESM::WeaponType::Thrown)

@ -25,15 +25,13 @@ namespace MWMechanics
float suggestCombatRange(int rangeTypes) float suggestCombatRange(int rangeTypes)
{ {
static const float fCombatDistance = MWBase::Environment::get() static const float fCombatDistance = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fCombatDistance") .find("fCombatDistance")
->mValue.getFloat(); ->mValue.getFloat();
static float fHandToHandReach = MWBase::Environment::get() static float fHandToHandReach = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fHandToHandReach") .find("fHandToHandReach")
->mValue.getFloat(); ->mValue.getFloat();
@ -58,13 +56,13 @@ namespace MWMechanics
inv.setSelectedEnchantItem(inv.end()); inv.setSelectedEnchantItem(inv.end());
} }
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(mSpellId); const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(mSpellId);
MWBase::Environment::get().getWorld()->preloadEffects(&spell->mEffects); MWBase::Environment::get().getWorld()->preloadEffects(&spell->mEffects);
} }
float ActionSpell::getCombatRange(bool& isRanged) const float ActionSpell::getCombatRange(bool& isRanged) const
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(mSpellId); const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(mSpellId);
int types = getRangeTypes(spell->mEffects); int types = getRangeTypes(spell->mEffects);
isRanged = (types & RangeTypes::Target) | (types & RangeTypes::Self); isRanged = (types & RangeTypes::Target) | (types & RangeTypes::Self);
@ -80,8 +78,7 @@ namespace MWMechanics
float ActionEnchantedItem::getCombatRange(bool& isRanged) const float ActionEnchantedItem::getCombatRange(bool& isRanged) const
{ {
const ESM::Enchantment* enchantment const ESM::Enchantment* enchantment = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().find(
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(
mItem->getClass().getEnchantment(*mItem)); mItem->getClass().getEnchantment(*mItem));
int types = getRangeTypes(enchantment->mEffects); int types = getRangeTypes(enchantment->mEffects);
@ -127,24 +124,21 @@ namespace MWMechanics
isRanged = false; isRanged = false;
static const float fCombatDistance = MWBase::Environment::get() static const float fCombatDistance = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fCombatDistance") .find("fCombatDistance")
->mValue.getFloat(); ->mValue.getFloat();
static const float fProjectileMaxSpeed = MWBase::Environment::get() static const float fProjectileMaxSpeed = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fProjectileMaxSpeed") .find("fProjectileMaxSpeed")
->mValue.getFloat(); ->mValue.getFloat();
if (mWeapon.isEmpty()) if (mWeapon.isEmpty())
{ {
static float fHandToHandReach = MWBase::Environment::get() static float fHandToHandReach = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fHandToHandReach") .find("fHandToHandReach")
->mValue.getFloat(); ->mValue.getFloat();
return fHandToHandReach * fCombatDistance; return fHandToHandReach * fCombatDistance;
@ -322,7 +316,7 @@ namespace MWMechanics
{ {
const CreatureStats& stats = actor.getClass().getCreatureStats(actor); const CreatureStats& stats = actor.getClass().getCreatureStats(actor);
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
const ESM::RefId& selectedSpellId = stats.getSpells().getSelectedSpell(); const ESM::RefId& selectedSpellId = stats.getSpells().getSelectedSpell();
MWWorld::Ptr selectedEnchItem; MWWorld::Ptr selectedEnchItem;
@ -356,14 +350,14 @@ namespace MWMechanics
if (!selectedSpellId.empty()) if (!selectedSpellId.empty())
{ {
const ESM::Spell* spell const ESM::Spell* spell
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(selectedSpellId); = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(selectedSpellId);
for (std::vector<ESM::ENAMstruct>::const_iterator effectIt = spell->mEffects.mList.begin(); for (std::vector<ESM::ENAMstruct>::const_iterator effectIt = spell->mEffects.mList.begin();
effectIt != spell->mEffects.mList.end(); ++effectIt) effectIt != spell->mEffects.mList.end(); ++effectIt)
{ {
if (effectIt->mRange == ESM::RT_Target) if (effectIt->mRange == ESM::RT_Target)
{ {
const ESM::MagicEffect* effect const ESM::MagicEffect* effect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find( = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(
effectIt->mEffectID); effectIt->mEffectID);
dist = effect->mData.mSpeed; dist = effect->mData.mSpeed;
break; break;
@ -376,14 +370,14 @@ namespace MWMechanics
if (!enchId.empty()) if (!enchId.empty())
{ {
const ESM::Enchantment* ench const ESM::Enchantment* ench
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchId); = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().find(enchId);
for (std::vector<ESM::ENAMstruct>::const_iterator effectIt = ench->mEffects.mList.begin(); for (std::vector<ESM::ENAMstruct>::const_iterator effectIt = ench->mEffects.mList.begin();
effectIt != ench->mEffects.mList.end(); ++effectIt) effectIt != ench->mEffects.mList.end(); ++effectIt)
{ {
if (effectIt->mRange == ESM::RT_Target) if (effectIt->mRange == ESM::RT_Target)
{ {
const ESM::MagicEffect* effect const ESM::MagicEffect* effect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find( = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(
effectIt->mEffectID); effectIt->mEffectID);
dist = effect->mData.mSpeed; dist = effect->mData.mSpeed;
break; break;
@ -507,7 +501,7 @@ namespace MWMechanics
{ {
const CreatureStats& stats = actor.getClass().getCreatureStats(actor); const CreatureStats& stats = actor.getClass().getCreatureStats(actor);
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
const int flee = stats.getAiSetting(AiSetting::Flee).getModified(); const int flee = stats.getAiSetting(AiSetting::Flee).getModified();
if (flee >= 100) if (flee >= 100)

@ -211,8 +211,7 @@ namespace MWMechanics
if (!mPathFinder.isPathConstructed() && mHasDestination) if (!mPathFinder.isPathConstructed() && mHasDestination)
{ {
const ESM::Pathgrid* pathgrid const ESM::Pathgrid* pathgrid
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search( = MWBase::Environment::get().getESMStore()->get<ESM::Pathgrid>().search(*actor.getCell()->getCell());
*actor.getCell()->getCell());
if (mUsePathgrid) if (mUsePathgrid)
{ {
mPathFinder.buildPathByPathgrid( mPathFinder.buildPathByPathgrid(
@ -805,7 +804,7 @@ namespace MWMechanics
ESM::Pathgrid::Point dest, const MWWorld::CellStore* currentCell, ESM::Pathgrid::PointList& points) ESM::Pathgrid::Point dest, const MWWorld::CellStore* currentCell, ESM::Pathgrid::PointList& points)
{ {
const ESM::Pathgrid* pathgrid const ESM::Pathgrid* pathgrid
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*currentCell->getCell()); = MWBase::Environment::get().getESMStore()->get<ESM::Pathgrid>().search(*currentCell->getCell());
if (pathgrid == nullptr || pathgrid->mPoints.empty()) if (pathgrid == nullptr || pathgrid->mPoints.empty())
return; return;
@ -820,7 +819,7 @@ namespace MWMechanics
// infrequently used, therefore no benefit in caching it as a member // infrequently used, therefore no benefit in caching it as a member
const MWWorld::CellStore* cellStore = actor.getCell(); const MWWorld::CellStore* cellStore = actor.getCell();
const ESM::Pathgrid* pathgrid const ESM::Pathgrid* pathgrid
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*cellStore->getCell()); = MWBase::Environment::get().getESMStore()->get<ESM::Pathgrid>().search(*cellStore->getCell());
storage.mAllowedNodes.clear(); storage.mAllowedNodes.clear();

@ -139,26 +139,20 @@ void MWMechanics::Alchemy::updateEffects()
x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->mBase->mData.mQuality; x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->mBase->mData.mQuality;
x *= MWBase::Environment::get() x *= MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fPotionStrengthMult") .find("fPotionStrengthMult")
->mValue.getFloat(); ->mValue.getFloat();
// value // value
mValue = static_cast<int>(x mValue = static_cast<int>(
* MWBase::Environment::get() x * MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find("iAlchemyMod")->mValue.getFloat());
.getWorld()
->getStore()
.get<ESM::GameSetting>()
.find("iAlchemyMod")
->mValue.getFloat());
// build quantified effect list // build quantified effect list
for (std::set<EffectKey>::const_iterator iter(effects.begin()); iter != effects.end(); ++iter) for (std::set<EffectKey>::const_iterator iter(effects.begin()); iter != effects.end(); ++iter)
{ {
const ESM::MagicEffect* magicEffect const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(iter->mId); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(iter->mId);
if (magicEffect->mData.mBaseCost <= 0) if (magicEffect->mData.mBaseCost <= 0)
{ {
@ -167,9 +161,8 @@ void MWMechanics::Alchemy::updateEffects()
} }
float fPotionT1MagMul = MWBase::Environment::get() float fPotionT1MagMul = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fPotionT1MagMult") .find("fPotionT1MagMult")
->mValue.getFloat(); ->mValue.getFloat();
@ -177,9 +170,8 @@ void MWMechanics::Alchemy::updateEffects()
throw std::runtime_error("invalid gmst: fPotionT1MagMul"); throw std::runtime_error("invalid gmst: fPotionT1MagMul");
float fPotionT1DurMult = MWBase::Environment::get() float fPotionT1DurMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fPotionT1DurMult") .find("fPotionT1DurMult")
->mValue.getFloat(); ->mValue.getFloat();
@ -228,7 +220,7 @@ void MWMechanics::Alchemy::updateEffects()
const ESM::Potion* MWMechanics::Alchemy::getRecord(const ESM::Potion& toFind) const const ESM::Potion* MWMechanics::Alchemy::getRecord(const ESM::Potion& toFind) const
{ {
const MWWorld::Store<ESM::Potion>& potions = MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>(); const MWWorld::Store<ESM::Potion>& potions = MWBase::Environment::get().getESMStore()->get<ESM::Potion>();
MWWorld::Store<ESM::Potion>::iterator iter = potions.begin(); MWWorld::Store<ESM::Potion>::iterator iter = potions.begin();
for (; iter != potions.end(); ++iter) for (; iter != potions.end(); ++iter)
@ -315,7 +307,7 @@ void MWMechanics::Alchemy::addPotion(const std::string& name)
const ESM::Potion* record = getRecord(newRecord); const ESM::Potion* record = getRecord(newRecord);
if (!record) if (!record)
record = MWBase::Environment::get().getWorld()->createRecord(newRecord); record = MWBase::Environment::get().getESMStore()->insert(newRecord);
mAlchemist.getClass().getContainerStore(mAlchemist).add(record->mId, 1); 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) bool MWMechanics::Alchemy::knownEffect(unsigned int potionEffectIndex, const MWWorld::Ptr& npc)
{ {
float alchemySkill = npc.getClass().getSkill(npc, ESM::Skill::Alchemy); float alchemySkill = npc.getClass().getSkill(npc, ESM::Skill::Alchemy);
static const float fWortChanceValue = MWBase::Environment::get() static const float fWortChanceValue
.getWorld() = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find("fWortChanceValue")->mValue.getFloat();
->getStore()
.get<ESM::GameSetting>()
.find("fWortChanceValue")
->mValue.getFloat();
return (potionEffectIndex <= 1 && alchemySkill >= fWortChanceValue) return (potionEffectIndex <= 1 && alchemySkill >= fWortChanceValue)
|| (potionEffectIndex <= 3 && alchemySkill >= fWortChanceValue * 2) || (potionEffectIndex <= 3 && alchemySkill >= fWortChanceValue * 2)
|| (potionEffectIndex <= 5 && alchemySkill >= fWortChanceValue * 3) || (potionEffectIndex <= 5 && alchemySkill >= fWortChanceValue * 3)
@ -573,8 +561,8 @@ std::vector<std::string> MWMechanics::Alchemy::effectsDescription(const MWWorld:
std::vector<std::string> effects; std::vector<std::string> effects;
const auto& item = ptr.get<ESM::Ingredient>()->mBase; const auto& item = ptr.get<ESM::Ingredient>()->mBase;
const auto& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); const auto& gmst = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
const auto& mgef = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>(); const auto& mgef = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>();
const static auto fWortChanceValue = gmst.find("fWortChanceValue")->mValue.getFloat(); const static auto fWortChanceValue = gmst.find("fWortChanceValue")->mValue.getFloat();
const auto& data = item->mData; const auto& data = item->mData;

@ -30,7 +30,7 @@ namespace MWMechanics
std::vector<ESM::RefId> autoCalcNpcSpells(const int* actorSkills, const int* actorAttributes, const ESM::Race* race) std::vector<ESM::RefId> autoCalcNpcSpells(const int* actorSkills, const int* actorAttributes, const ESM::Race* race)
{ {
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fNPCbaseMagickaMult = gmst.find("fNPCbaseMagickaMult")->mValue.getFloat(); static const float fNPCbaseMagickaMult = gmst.find("fNPCbaseMagickaMult")->mValue.getFloat();
float baseMagicka = fNPCbaseMagickaMult * actorAttributes[ESM::Attribute::Intelligence]; float baseMagicka = fNPCbaseMagickaMult * actorAttributes[ESM::Attribute::Intelligence];
@ -62,7 +62,7 @@ namespace MWMechanics
std::vector<ESM::RefId> selectedSpells; std::vector<ESM::RefId> selectedSpells;
const MWWorld::Store<ESM::Spell>& spells = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>(); const MWWorld::Store<ESM::Spell>& spells = MWBase::Environment::get().getESMStore()->get<ESM::Spell>();
// Note: the algorithm heavily depends on the traversal order of the spells. For vanilla-compatible results the // 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. // Store must preserve the record ordering as it was in the content files.
@ -150,7 +150,7 @@ namespace MWMechanics
std::vector<ESM::RefId> autoCalcPlayerSpells( std::vector<ESM::RefId> autoCalcPlayerSpells(
const int* actorSkills, const int* actorAttributes, const ESM::Race* race) 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 static const float fPCbaseMagickaMult
= esmStore.get<ESM::GameSetting>().find("fPCbaseMagickaMult")->mValue.getFloat(); = esmStore.get<ESM::GameSetting>().find("fPCbaseMagickaMult")->mValue.getFloat();
@ -231,11 +231,10 @@ namespace MWMechanics
for (const auto& spellEffect : spell->mEffects.mList) for (const auto& spellEffect : spell->mEffects.mList)
{ {
const ESM::MagicEffect* magicEffect const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(spellEffect.mEffectID); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(spellEffect.mEffectID);
static const int iAutoSpellAttSkillMin = MWBase::Environment::get() static const int iAutoSpellAttSkillMin = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("iAutoSpellAttSkillMin") .find("iAutoSpellAttSkillMin")
->mValue.getInteger(); ->mValue.getInteger();
@ -264,7 +263,7 @@ namespace MWMechanics
for (const ESM::ENAMstruct& effect : spell->mEffects.mList) for (const ESM::ENAMstruct& effect : spell->mEffects.mList)
{ {
const ESM::MagicEffect* magicEffect const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effect.mEffectID); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effect.mEffectID);
int minMagn = 1; int minMagn = 1;
int maxMagn = 1; int maxMagn = 1;
@ -281,9 +280,8 @@ namespace MWMechanics
duration = std::max(1, duration); duration = std::max(1, duration);
static const float fEffectCostMult = MWBase::Environment::get() static const float fEffectCostMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fEffectCostMult") .find("fEffectCostMult")
->mValue.getFloat(); ->mValue.getFloat();

@ -50,7 +50,7 @@ namespace MWMechanics
if (!enchantmentName.empty()) if (!enchantmentName.empty())
{ {
const ESM::Enchantment* enchantment const ESM::Enchantment* enchantment
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantmentName); = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().find(enchantmentName);
if (enchantment->mData.mType == ESM::Enchantment::WhenStrikes) if (enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
{ {
MWMechanics::CastSpell cast(attacker, victim, fromProjectile); 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))); blocker.getRefData().getBaseNode()->getAttitude() * osg::Vec3f(0, 1, 0), osg::Vec3f(0, 0, 1)));
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fCombatBlockLeftAngle = gmst.find("fCombatBlockLeftAngle")->mValue.getFloat(); static const float fCombatBlockLeftAngle = gmst.find("fCombatBlockLeftAngle")->mValue.getFloat();
if (angleDegrees < fCombatBlockLeftAngle) if (angleDegrees < fCombatBlockLeftAngle)
return false; return false;
@ -205,7 +205,7 @@ namespace MWMechanics
if (isSilver && actor.getClass().getNpcStats(actor).isWerewolf()) 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<ESM::GameSetting>().find("fWereWolfSilverWeaponDamageMult")->mValue.getFloat(); damage *= store.get<ESM::GameSetting>().find("fWereWolfSilverWeaponDamageMult")->mValue.getFloat();
} }
} }
@ -371,9 +371,8 @@ namespace MWMechanics
x = std::min(100.f, x + elementResistance); x = std::min(100.f, x + elementResistance);
static const float fElementalShieldMult = MWBase::Environment::get() static const float fElementalShieldMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fElementalShieldMult") .find("fElementalShieldMult")
->mValue.getFloat(); ->mValue.getFloat();
x = fElementalShieldMult * magnitude * (1.f - 0.01f * x); x = fElementalShieldMult * magnitude * (1.f - 0.01f * x);
@ -410,9 +409,8 @@ namespace MWMechanics
if (!godmode) if (!godmode)
{ {
const float fWeaponDamageMult = MWBase::Environment::get() const float fWeaponDamageMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fWeaponDamageMult") .find("fWeaponDamageMult")
->mValue.getFloat(); ->mValue.getFloat();
float x = std::max(1.f, fWeaponDamageMult * damage); float x = std::max(1.f, fWeaponDamageMult * damage);
@ -439,15 +437,13 @@ namespace MWMechanics
} }
static const float fDamageStrengthBase = MWBase::Environment::get() static const float fDamageStrengthBase = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fDamageStrengthBase") .find("fDamageStrengthBase")
->mValue.getFloat(); ->mValue.getFloat();
static const float fDamageStrengthMult = MWBase::Environment::get() static const float fDamageStrengthMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fDamageStrengthMult") .find("fDamageStrengthMult")
->mValue.getFloat(); ->mValue.getFloat();
damage *= fDamageStrengthBase damage *= fDamageStrengthBase
@ -458,7 +454,7 @@ namespace MWMechanics
void getHandToHandDamage( void getHandToHandDamage(
const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, float& damage, bool& healthdmg, float attackStrength) 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<ESM::GameSetting>().find("fMinHandToHandMult")->mValue.getFloat(); static const float minstrike = store.get<ESM::GameSetting>().find("fMinHandToHandMult")->mValue.getFloat();
static const float maxstrike = store.get<ESM::GameSetting>().find("fMaxHandToHandMult")->mValue.getFloat(); static const float maxstrike = store.get<ESM::GameSetting>().find("fMaxHandToHandMult")->mValue.getFloat();
damage = static_cast<float>(attacker.getClass().getSkill(attacker, ESM::Skill::HandToHand)); damage = static_cast<float>(attacker.getClass().getSkill(attacker, ESM::Skill::HandToHand));
@ -509,7 +505,7 @@ namespace MWMechanics
{ {
// somewhat of a guess, but using the weapon weight makes sense // somewhat of a guess, but using the weapon weight makes sense
const MWWorld::Store<ESM::GameSetting>& store const MWWorld::Store<ESM::GameSetting>& store
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fFatigueAttackBase = store.find("fFatigueAttackBase")->mValue.getFloat(); static const float fFatigueAttackBase = store.find("fFatigueAttackBase")->mValue.getFloat();
static const float fFatigueAttackMult = store.find("fFatigueAttackMult")->mValue.getFloat(); static const float fFatigueAttackMult = store.find("fFatigueAttackMult")->mValue.getFloat();
static const float fWeaponFatigueMult = store.find("fWeaponFatigueMult")->mValue.getFloat(); static const float fWeaponFatigueMult = store.find("fWeaponFatigueMult")->mValue.getFloat();
@ -537,15 +533,13 @@ namespace MWMechanics
float d = getAggroDistance(actor1, pos1, pos2); float d = getAggroDistance(actor1, pos1, pos2);
static const int iFightDistanceBase = MWBase::Environment::get() static const int iFightDistanceBase = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("iFightDistanceBase") .find("iFightDistanceBase")
->mValue.getInteger(); ->mValue.getInteger();
static const float fFightDistanceMultiplier = MWBase::Environment::get() static const float fFightDistanceMultiplier = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fFightDistanceMultiplier") .find("fFightDistanceMultiplier")
->mValue.getFloat(); ->mValue.getFloat();

@ -66,7 +66,7 @@ namespace MWMechanics
float normalised = std::floor(max) == 0 ? 1 : std::max(0.0f, current / max); float normalised = std::floor(max) == 0 ? 1 : std::max(0.0f, current / max);
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fFatigueBase = gmst.find("fFatigueBase")->mValue.getFloat(); static const float fFatigueBase = gmst.find("fFatigueBase")->mValue.getFloat();
static const float fFatigueMult = gmst.find("fFatigueMult")->mValue.getFloat(); static const float fFatigueMult = gmst.find("fFatigueMult")->mValue.getFloat();

@ -15,12 +15,8 @@ float scaleDamage(float damage, const MWWorld::Ptr& attacker, const MWWorld::Ptr
// [-500, 500] // [-500, 500]
const int difficultySetting = std::clamp(Settings::Manager::getInt("difficulty", "Game"), -500, 500); const int difficultySetting = std::clamp(Settings::Manager::getInt("difficulty", "Game"), -500, 500);
static const float fDifficultyMult = MWBase::Environment::get() static const float fDifficultyMult
.getWorld() = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find("fDifficultyMult")->mValue.getFloat();
->getStore()
.get<ESM::GameSetting>()
.find("fDifficultyMult")
->mValue.getFloat();
float difficultyTerm = 0.01f * difficultySetting; float difficultyTerm = 0.01f * difficultySetting;

@ -29,9 +29,8 @@ namespace MWMechanics
return; return;
float fDiseaseXferChance = MWBase::Environment::get() float fDiseaseXferChance = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fDiseaseXferChance") .find("fDiseaseXferChance")
->mValue.getFloat(); ->mValue.getFloat();
@ -71,9 +70,8 @@ namespace MWMechanics
MWBase::Environment::get().getWorld()->applyLoopingParticles(actor); MWBase::Environment::get().getWorld()->applyLoopingParticles(actor);
std::string msg = MWBase::Environment::get() std::string msg = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("sMagicContractDisease") .find("sMagicContractDisease")
->mValue.getString(); ->mValue.getString();
msg = Misc::StringUtils::format(msg, spell->mName); msg = Misc::StringUtils::format(msg, spell->mName);

@ -98,7 +98,7 @@ namespace MWMechanics
// Try to find a dynamic enchantment with the same stats, create a new one if not found. // Try to find a dynamic enchantment with the same stats, create a new one if not found.
const ESM::Enchantment* enchantmentPtr = getRecord(enchantment); const ESM::Enchantment* enchantmentPtr = getRecord(enchantment);
if (enchantmentPtr == nullptr) if (enchantmentPtr == nullptr)
enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord(enchantment); enchantmentPtr = MWBase::Environment::get().getESMStore()->insert(enchantment);
// Apply the enchantment // Apply the enchantment
const ESM::RefId& newItemId const ESM::RefId& newItemId
@ -120,9 +120,8 @@ namespace MWMechanics
return; return;
const bool powerfulSoul = getGemCharge() >= MWBase::Environment::get() const bool powerfulSoul = getGemCharge() >= MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("iSoulAmountForConstantEffect") .find("iSoulAmountForConstantEffect")
->mValue.getInteger(); ->mValue.getInteger();
if ((mObjectType == ESM::Armor::sRecordId) || (mObjectType == ESM::Clothing::sRecordId)) if ((mObjectType == ESM::Armor::sRecordId) || (mObjectType == ESM::Clothing::sRecordId))
@ -190,7 +189,7 @@ namespace MWMechanics
// No effects added, cost = 0 // No effects added, cost = 0
return 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<ESM::GameSetting>().find("fEffectCostMult")->mValue.getFloat(); const float fEffectCostMult = store.get<ESM::GameSetting>().find("fEffectCostMult")->mValue.getFloat();
const float fEnchantmentConstantDurationMult const float fEnchantmentConstantDurationMult
= store.get<ESM::GameSetting>().find("fEnchantmentConstantDurationMult")->mValue.getFloat(); = store.get<ESM::GameSetting>().find("fEnchantmentConstantDurationMult")->mValue.getFloat();
@ -223,7 +222,7 @@ namespace MWMechanics
const ESM::Enchantment* Enchanting::getRecord(const ESM::Enchantment& toFind) const const ESM::Enchantment* Enchanting::getRecord(const ESM::Enchantment& toFind) const
{ {
const MWWorld::Store<ESM::Enchantment>& enchantments const MWWorld::Store<ESM::Enchantment>& enchantments
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>(); = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>();
MWWorld::Store<ESM::Enchantment>::iterator iter(enchantments.begin()); MWWorld::Store<ESM::Enchantment>::iterator iter(enchantments.begin());
iter += (enchantments.getSize() - enchantments.getDynamicSize()); iter += (enchantments.getSize() - enchantments.getDynamicSize());
for (; iter != enchantments.end(); ++iter) for (; iter != enchantments.end(); ++iter)
@ -284,9 +283,8 @@ namespace MWMechanics
return 0; return 0;
float priceMultipler = MWBase::Environment::get() float priceMultipler = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fEnchantmentValueMult") .find("fEnchantmentValueMult")
->mValue.getFloat(); ->mValue.getFloat();
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer( int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(
@ -297,7 +295,7 @@ namespace MWMechanics
int Enchanting::getGemCharge() const int Enchanting::getGemCharge() const
{ {
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
if (soulEmpty()) if (soulEmpty())
return 0; return 0;
if (mSoulGemPtr.getCellRef().getSoul().empty()) if (mSoulGemPtr.getCellRef().getSoul().empty())
@ -314,7 +312,7 @@ namespace MWMechanics
if (itemEmpty()) if (itemEmpty())
return 0; return 0;
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
return static_cast<int>(mOldItemPtr.getClass().getEnchantmentPoints(mOldItemPtr) return static_cast<int>(mOldItemPtr.getClass().getEnchantmentPoints(mOldItemPtr)
* store.get<ESM::GameSetting>().find("fEnchantmentMult")->mValue.getFloat()); * store.get<ESM::GameSetting>().find("fEnchantmentMult")->mValue.getFloat());
@ -345,7 +343,7 @@ namespace MWMechanics
{ {
const CreatureStats& stats = mEnchanter.getClass().getCreatureStats(mEnchanter); const CreatureStats& stats = mEnchanter.getClass().getCreatureStats(mEnchanter);
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
const float a = static_cast<float>(mEnchanter.getClass().getSkill(mEnchanter, ESM::Skill::Enchant)); const float a = static_cast<float>(mEnchanter.getClass().getSkill(mEnchanter, ESM::Skill::Enchant));
const float b = static_cast<float>(stats.getAttribute(ESM::Attribute::Intelligence).getModified()); const float b = static_cast<float>(stats.getAttribute(ESM::Attribute::Intelligence).getModified());
const float c = static_cast<float>(stats.getAttribute(ESM::Attribute::Luck).getModified()); const float c = static_cast<float>(stats.getAttribute(ESM::Attribute::Luck).getModified());

@ -17,14 +17,14 @@ namespace MWMechanics
template <class T> template <class T>
void modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount) void modifyBaseInventory(const ESM::RefId& actorId, const ESM::RefId& itemId, int amount)
{ {
T copy = *MWBase::Environment::get().getWorld()->getStore().get<T>().find(actorId); T copy = *MWBase::Environment::get().getESMStore()->get<T>().find(actorId);
for (auto& it : copy.mInventory.mList) for (auto& it : copy.mInventory.mList)
{ {
if (it.mItem == itemId) if (it.mItem == itemId)
{ {
const int sign = it.mCount < 1 ? -1 : 1; const int sign = it.mCount < 1 ? -1 : 1;
it.mCount = sign * std::max(it.mCount * sign + amount, 0); it.mCount = sign * std::max(it.mCount * sign + amount, 0);
MWBase::Environment::get().getWorld()->createOverrideRecord(copy); MWBase::Environment::get().getESMStore()->overrideRecord(copy);
return; return;
} }
} }
@ -34,7 +34,7 @@ namespace MWMechanics
cont.mItem = itemId; cont.mItem = itemId;
cont.mCount = amount; cont.mCount = amount;
copy.mInventory.mList.push_back(cont); copy.mInventory.mList.push_back(cont);
MWBase::Environment::get().getWorld()->createOverrideRecord(copy); MWBase::Environment::get().getESMStore()->overrideRecord(copy);
} }
} }
} }

@ -49,7 +49,7 @@ namespace MWMechanics
const ESM::RefId& item = *candidates[Misc::Rng::rollDice(candidates.size(), prng)]; const ESM::RefId& item = *candidates[Misc::Rng::rollDice(candidates.size(), prng)];
// Vanilla doesn't fail on nonexistent items in levelled lists // 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 " Log(Debug::Warning) << "Warning: ignoring nonexistent item " << item << " in levelled list "
<< levItem->mId; << levItem->mId;
@ -57,7 +57,7 @@ namespace MWMechanics
} }
// Is this another levelled item or a real item? // 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 if (ref.getPtr().getType() != ESM::ItemLevList::sRecordId
&& ref.getPtr().getType() != ESM::CreatureLevList::sRecordId) && ref.getPtr().getType() != ESM::CreatureLevList::sRecordId)
{ {

@ -52,7 +52,7 @@ namespace MWMechanics
std::string EffectKey::toString() const std::string EffectKey::toString() const
{ {
const ESM::MagicEffect* magicEffect const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().search(mId); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().search(mId);
return getMagicEffectString(*magicEffect, mArg, mArg); return getMagicEffectString(*magicEffect, mArg, mArg);
} }

@ -41,9 +41,8 @@ namespace
float getFightDispositionBias(float disposition) float getFightDispositionBias(float disposition)
{ {
static const float fFightDispMult = MWBase::Environment::get() static const float fFightDispMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fFightDispMult") .find("fFightDispMult")
->mValue.getFloat(); ->mValue.getFloat();
return ((50.f - disposition) * fFightDispMult); return ((50.f - disposition) * fFightDispMult);
@ -53,7 +52,7 @@ namespace
const MWMechanics::NpcStats& stats, float& rating1, float& rating2, float& rating3, bool player) const MWMechanics::NpcStats& stats, float& rating1, float& rating2, float& rating3, bool player)
{ {
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
float persTerm = stats.getAttribute(ESM::Attribute::Personality).getModified() float persTerm = stats.getAttribute(ESM::Attribute::Personality).getModified()
/ gmst.find("fPersonalityMod")->mValue.getFloat(); / gmst.find("fPersonalityMod")->mValue.getFloat();
@ -140,7 +139,7 @@ namespace MWMechanics
creatureStats.setAttribute(ESM::Attribute::Endurance, player->mNpdt.mEndurance); creatureStats.setAttribute(ESM::Attribute::Endurance, player->mNpdt.mEndurance);
creatureStats.setAttribute(ESM::Attribute::Personality, player->mNpdt.mPersonality); creatureStats.setAttribute(ESM::Attribute::Personality, player->mNpdt.mPersonality);
creatureStats.setAttribute(ESM::Attribute::Luck, player->mNpdt.mLuck); 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 // race
if (mRaceSelected) if (mRaceSelected)
@ -440,7 +439,7 @@ namespace MWMechanics
ESM::NPC player = *world->getPlayerPtr().get<ESM::NPC>()->mBase; ESM::NPC player = *world->getPlayerPtr().get<ESM::NPC>()->mBase;
player.mName = name; player.mName = name;
world->createRecord(player); world->getStore().insert(player);
mUpdatePlayer = true; mUpdatePlayer = true;
} }
@ -457,7 +456,7 @@ namespace MWMechanics
player.mHair = hair; player.mHair = hair;
player.setIsMale(male); player.setIsMale(male);
world->createRecord(player); world->getStore().insert(player);
mRaceSelected = true; mRaceSelected = true;
buildPlayer(); buildPlayer();
@ -478,7 +477,7 @@ namespace MWMechanics
ESM::NPC player = *world->getPlayerPtr().get<ESM::NPC>()->mBase; ESM::NPC player = *world->getPlayerPtr().get<ESM::NPC>()->mBase;
player.mClass = id; player.mClass = id;
world->createRecord(player); world->getStore().insert(player);
mClassSelected = true; mClassSelected = true;
buildPlayer(); buildPlayer();
@ -489,12 +488,12 @@ namespace MWMechanics
{ {
MWBase::World* world = MWBase::Environment::get().getWorld(); 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<ESM::NPC>()->mBase; ESM::NPC player = *world->getPlayerPtr().get<ESM::NPC>()->mBase;
player.mClass = ptr->mId; player.mClass = ptr->mId;
world->createRecord(player); world->getStore().insert(player);
mClassSelected = true; mClassSelected = true;
buildPlayer(); buildPlayer();
@ -512,7 +511,7 @@ namespace MWMechanics
const MWMechanics::NpcStats& playerStats = playerPtr.getClass().getNpcStats(playerPtr); const MWMechanics::NpcStats& playerStats = playerPtr.getClass().getNpcStats(playerPtr);
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fDispRaceMod = gmst.find("fDispRaceMod")->mValue.getFloat(); static const float fDispRaceMod = gmst.find("fDispRaceMod")->mValue.getFloat();
if (npc->mBase->mRace == player->mBase->mRace) if (npc->mBase->mRace == player->mBase->mRace)
x += fDispRaceMod; x += fDispRaceMod;
@ -623,7 +622,7 @@ namespace MWMechanics
const MWWorld::Ptr& npc, PersuasionType type, bool& success, int& tempChange, int& permChange) const MWWorld::Ptr& npc, PersuasionType type, bool& success, int& tempChange, int& permChange)
{ {
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
MWMechanics::NpcStats& npcStats = npc.getClass().getNpcStats(npc); MWMechanics::NpcStats& npcStats = npc.getClass().getNpcStats(npc);
@ -851,7 +850,7 @@ namespace MWMechanics
{ {
// Build a list of known bound item ID's // Build a list of known bound item ID's
const MWWorld::Store<ESM::GameSetting>& gameSettings const MWWorld::Store<ESM::GameSetting>& gameSettings
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
for (const ESM::GameSetting& currentSetting : gameSettings) for (const ESM::GameSetting& currentSetting : gameSettings)
{ {
@ -1145,7 +1144,7 @@ namespace MWMechanics
std::vector<MWWorld::Ptr> neighbors; std::vector<MWWorld::Ptr> neighbors;
osg::Vec3f from(player.getRefData().getPosition().asVec3()); 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<ESM::GameSetting>().find("fAlarmRadius")->mValue.getFloat(); float radius = esmStore.get<ESM::GameSetting>().find("fAlarmRadius")->mValue.getFloat();
mActors.getObjectsInRange(from, radius, neighbors); 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::Ptr& player, const MWWorld::Ptr& victim, OffenseType type, const ESM::RefId& factionId, int arg)
{ {
const MWWorld::Store<ESM::GameSetting>& store const MWWorld::Store<ESM::GameSetting>& store
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
if (type == OT_Murder && !victim.isEmpty()) if (type == OT_Murder && !victim.isEmpty())
victim.getClass().getCreatureStats(victim).notifyMurder(); victim.getClass().getCreatureStats(victim).notifyMurder();
@ -1261,7 +1260,7 @@ namespace MWMechanics
// Make surrounding actors within alarm distance respond to the crime // Make surrounding actors within alarm distance respond to the crime
std::vector<MWWorld::Ptr> neighbors; std::vector<MWWorld::Ptr> 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()); osg::Vec3f from(player.getRefData().getPosition().asVec3());
float radius = esmStore.get<ESM::GameSetting>().find("fAlarmRadius")->mValue.getFloat(); float radius = esmStore.get<ESM::GameSetting>().find("fAlarmRadius")->mValue.getFloat();
@ -1534,7 +1533,7 @@ namespace MWMechanics
return false; return false;
const MWWorld::Store<ESM::GameSetting>& store const MWWorld::Store<ESM::GameSetting>& store
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
@ -1788,8 +1787,7 @@ namespace MWMechanics
&& MWBase::Environment::get().getWorld()->getGlobalInt(MWWorld::Globals::sPCKnownWerewolf))) && MWBase::Environment::get().getWorld()->getGlobalInt(MWWorld::Globals::sPCKnownWerewolf)))
{ {
const ESM::GameSetting* iWerewolfFightMod const ESM::GameSetting* iWerewolfFightMod
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find( = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find("iWerewolfFightMod");
"iWerewolfFightMod");
fight += iWerewolfFightMod->mValue.getInteger(); fight += iWerewolfFightMod->mValue.getInteger();
} }
} }
@ -1887,7 +1885,7 @@ namespace MWMechanics
// Witnesses of the player's transformation will make them a globally known werewolf // Witnesses of the player's transformation will make them a globally known werewolf
std::vector<MWWorld::Ptr> neighbors; std::vector<MWWorld::Ptr> neighbors;
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
getActorsInRange( getActorsInRange(
actor.getRefData().getPosition().asVec3(), gmst.find("fAlarmRadius")->mValue.getFloat(), neighbors); actor.getRefData().getPosition().asVec3(), gmst.find("fAlarmRadius")->mValue.getFloat(), neighbors);
@ -1928,7 +1926,7 @@ namespace MWMechanics
void MechanicsManager::applyWerewolfAcrobatics(const MWWorld::Ptr& actor) void MechanicsManager::applyWerewolfAcrobatics(const MWWorld::Ptr& actor)
{ {
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
MWMechanics::NpcStats& stats = actor.getClass().getNpcStats(actor); MWMechanics::NpcStats& stats = actor.getClass().getNpcStats(actor);
auto& skill = stats.getSkill(ESM::Skill::Acrobatics); auto& skill = stats.getSkill(ESM::Skill::Acrobatics);
skill.setModifier(gmst.find("fWerewolfAcrobatics")->mValue.getFloat() - skill.getModified()); skill.setModifier(gmst.find("fWerewolfAcrobatics")->mValue.getFloat() - skill.getModified());

@ -84,8 +84,7 @@ void MWMechanics::NpcStats::raiseRank(const ESM::RefId& faction)
if (it != mFactionRank.end()) if (it != mFactionRank.end())
{ {
// Does the next rank exist? // Does the next rank exist?
const ESM::Faction* factionPtr const ESM::Faction* factionPtr = MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(faction);
if (it->second + 1 < 10 && !factionPtr->mRanks[it->second + 1].empty()) if (it->second + 1 < 10 && !factionPtr->mRanks[it->second + 1].empty())
it->second += 1; it->second += 1;
} }
@ -122,7 +121,7 @@ void MWMechanics::NpcStats::expell(const ESM::RefId& factionID)
if (mExpelled.find(factionID) == mExpelled.end()) if (mExpelled.find(factionID) == mExpelled.end())
{ {
std::string message = "#{sExpelledMessage}"; std::string message = "#{sExpelledMessage}";
message += MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(factionID)->mName; message += MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(factionID)->mName;
MWBase::Environment::get().getWindowManager()->messageBox(message); MWBase::Environment::get().getWindowManager()->messageBox(message);
mExpelled.insert(factionID); mExpelled.insert(factionID);
} }
@ -157,8 +156,7 @@ float MWMechanics::NpcStats::getSkillProgressRequirement(int skillIndex, const E
{ {
float progressRequirement = static_cast<float>(1 + getSkill(skillIndex).getBase()); float progressRequirement = static_cast<float>(1 + getSkill(skillIndex).getBase());
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
float typeFactor = gmst.find("fMiscSkillBonus")->mValue.getFloat(); float typeFactor = gmst.find("fMiscSkillBonus")->mValue.getFloat();
@ -183,7 +181,7 @@ float MWMechanics::NpcStats::getSkillProgressRequirement(int skillIndex, const E
float specialisationFactor = 1; float specialisationFactor = 1;
const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find(skillIndex); const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().find(skillIndex);
if (skill->mData.mSpecialization == class_.mData.mSpecialization) if (skill->mData.mSpecialization == class_.mData.mSpecialization)
{ {
specialisationFactor = gmst.find("fSpecialSkillBonus")->mValue.getFloat(); 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) void MWMechanics::NpcStats::useSkill(int skillIndex, const ESM::Class& class_, int usageType, float extraFactor)
{ {
const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find(skillIndex); const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().find(skillIndex);
float skillGain = 1; float skillGain = 1;
if (usageType >= 4) if (usageType >= 4)
throw std::runtime_error("skill usage type out of range"); throw std::runtime_error("skill usage type out of range");
@ -231,8 +229,7 @@ void MWMechanics::NpcStats::increaseSkill(
base += 1; base += 1;
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
// is this a minor or major skill? // is this a minor or major skill?
int increase = gmst.find("iLevelupMiscMultAttriubte")->mValue.getInteger(); // Note: GMST has a typo 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<ESM::Skill>().find(skillIndex); const ESM::Skill* skill = MWBase::Environment::get().getESMStore()->get<ESM::Skill>().find(skillIndex);
mSkillIncreases[skill->mData.mAttribute] += increase; mSkillIncreases[skill->mData.mAttribute] += increase;
mSpecIncreases[skill->mData.mSpecialization] += gmst.find("iLevelupSpecialization")->mValue.getInteger(); mSpecIncreases[skill->mData.mSpecialization] += gmst.find("iLevelupSpecialization")->mValue.getInteger();
@ -288,8 +285,7 @@ int MWMechanics::NpcStats::getLevelProgress() const
void MWMechanics::NpcStats::levelUp() void MWMechanics::NpcStats::levelUp()
{ {
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
mLevelProgress -= gmst.find("iLevelUpTotal")->mValue.getInteger(); mLevelProgress -= gmst.find("iLevelUpTotal")->mValue.getInteger();
mLevelProgress = std::max(0, mLevelProgress); // might be necessary when levelup was invoked via console 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; std::stringstream gmst;
gmst << "iLevelUp" << std::setfill('0') << std::setw(2) << num << "Mult"; gmst << "iLevelUp" << std::setfill('0') << std::setw(2) << num << "Mult";
return MWBase::Environment::get() return MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find(gmst.str())->mValue.getInteger();
.getWorld()
->getStore()
.get<ESM::GameSetting>()
.find(gmst.str())
->mValue.getInteger();
} }
int MWMechanics::NpcStats::getSkillIncreasesForSpecialization(int spec) const 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) if (rank < 0 || rank >= 10)
throw std::runtime_error("rank index out of range"); throw std::runtime_error("rank index out of range");
const ESM::Faction& faction const ESM::Faction& faction = *MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(factionId);
= *MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(factionId);
std::vector<int> skills; std::vector<int> skills;
@ -517,7 +507,7 @@ void MWMechanics::NpcStats::readState(const ESM::CreatureStats& state)
void MWMechanics::NpcStats::readState(const ESM::NpcStats& 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) for (auto iter(state.mFactions.begin()); iter != state.mFactions.end(); ++iter)
if (store.get<ESM::Faction>().search(iter->first)) if (store.get<ESM::Faction>().search(iter->first))

@ -37,15 +37,13 @@ namespace MWMechanics
float pcSneak = static_cast<float>(mThief.getClass().getSkill(mThief, ESM::Skill::Sneak)); float pcSneak = static_cast<float>(mThief.getClass().getSkill(mThief, ESM::Skill::Sneak));
int iPickMinChance = MWBase::Environment::get() int iPickMinChance = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("iPickMinChance") .find("iPickMinChance")
->mValue.getInteger(); ->mValue.getInteger();
int iPickMaxChance = MWBase::Environment::get() int iPickMaxChance = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("iPickMaxChance") .find("iPickMaxChance")
->mValue.getInteger(); ->mValue.getInteger();
@ -66,9 +64,8 @@ namespace MWMechanics
{ {
float stackValue = static_cast<float>(item.getClass().getValue(item) * count); float stackValue = static_cast<float>(item.getClass().getValue(item) * count);
float fPickPocketMod = MWBase::Environment::get() float fPickPocketMod = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fPickPocketMod") .find("fPickPocketMod")
->mValue.getFloat(); ->mValue.getFloat();
float valueTerm = 10 * fPickPocketMod * stackValue; float valueTerm = 10 * fPickPocketMod * stackValue;

@ -26,9 +26,8 @@ namespace MWMechanics
return false; return false;
static const float fMagicItemRechargePerSecond = MWBase::Environment::get() static const float fMagicItemRechargePerSecond = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fMagicItemRechargePerSecond") .find("fMagicItemRechargePerSecond")
->mValue.getFloat(); ->mValue.getFloat();
@ -62,13 +61,12 @@ namespace MWMechanics
if (roll < x) if (roll < x)
{ {
const ESM::RefId& soul = gem.getCellRef().getSoul(); const ESM::RefId& soul = gem.getCellRef().getSoul();
const ESM::Creature* creature const ESM::Creature* creature = MWBase::Environment::get().getESMStore()->get<ESM::Creature>().find(soul);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(soul);
float restored = creature->mData.mSoul * (roll / x); float restored = creature->mData.mSoul * (roll / x);
const ESM::Enchantment* enchantment const ESM::Enchantment* enchantment
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find( = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().find(
item.getClass().getEnchantment(item)); item.getClass().getEnchantment(item));
item.getCellRef().setEnchantmentCharge(std::min( item.getCellRef().setEnchantmentCharge(std::min(
item.getCellRef().getEnchantmentCharge() + restored, static_cast<float>(enchantment->mData.mCharge))); item.getCellRef().getEnchantmentCharge() + restored, static_cast<float>(enchantment->mData.mCharge)));
@ -88,9 +86,8 @@ namespace MWMechanics
if (gem.getRefData().getCount() == 0) if (gem.getRefData().getCount() == 0)
{ {
std::string message = MWBase::Environment::get() std::string message = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("sNotifyMessage51") .find("sNotifyMessage51")
->mValue.getString(); ->mValue.getString();
message = Misc::StringUtils::format(message, gem.getClass().getName(gem)); message = Misc::StringUtils::format(message, gem.getClass().getName(gem));

@ -38,9 +38,8 @@ namespace MWMechanics
float armorerSkill = player.getClass().getSkill(player, ESM::Skill::Armorer); float armorerSkill = player.getClass().getSkill(player, ESM::Skill::Armorer);
float fRepairAmountMult = MWBase::Environment::get() float fRepairAmountMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fRepairAmountMult") .find("fRepairAmountMult")
->mValue.getFloat(); ->mValue.getFloat();
@ -88,9 +87,8 @@ namespace MWMechanics
store.remove(mTool, 1); store.remove(mTool, 1);
std::string message = MWBase::Environment::get() std::string message = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("sNotifyMessage51") .find("sNotifyMessage51")
->mValue.getString(); ->mValue.getString();
message = Misc::StringUtils::format(message, mTool.getClass().getName(mTool)); message = Misc::StringUtils::format(message, mTool.getClass().getName(mTool));

@ -41,9 +41,8 @@ namespace MWMechanics
float pickQuality = lockpick.get<ESM::Lockpick>()->mBase->mData.mQuality; float pickQuality = lockpick.get<ESM::Lockpick>()->mBase->mData.mQuality;
float fPickLockMult = MWBase::Environment::get() float fPickLockMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fPickLockMult") .find("fPickLockMult")
->mValue.getFloat(); ->mValue.getFloat();
@ -88,13 +87,12 @@ namespace MWMechanics
float probeQuality = probe.get<ESM::Probe>()->mBase->mData.mQuality; float probeQuality = probe.get<ESM::Probe>()->mBase->mData.mQuality;
const ESM::Spell* trapSpell const ESM::Spell* trapSpell
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(trap.getCellRef().getTrap()); = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(trap.getCellRef().getTrap());
int trapSpellPoints = trapSpell->mData.mCost; int trapSpellPoints = trapSpell->mData.mCost;
float fTrapCostMult = MWBase::Environment::get() float fTrapCostMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fTrapCostMult") .find("fTrapCostMult")
->mValue.getFloat(); ->mValue.getFloat();

@ -15,7 +15,7 @@ namespace MWMechanics
template <class T> template <class T>
void setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value) void setBaseAISetting(const ESM::RefId& id, MWMechanics::AiSetting setting, int value)
{ {
T copy = *MWBase::Environment::get().getWorld()->getStore().get<T>().find(id); T copy = *MWBase::Environment::get().getESMStore()->get<T>().find(id);
switch (setting) switch (setting)
{ {
case MWMechanics::AiSetting::Hello: case MWMechanics::AiSetting::Hello:
@ -33,7 +33,7 @@ namespace MWMechanics
default: default:
assert(false); assert(false);
} }
MWBase::Environment::get().getWorld()->createOverrideRecord(copy); MWBase::Environment::get().getESMStore()->overrideRecord(copy);
} }
} }

@ -167,7 +167,7 @@ namespace MWMechanics
bool containsRecastable = false; bool containsRecastable = false;
std::vector<const ESM::MagicEffect*> magicEffects; std::vector<const ESM::MagicEffect*> magicEffects;
magicEffects.reserve(effects.mList.size()); magicEffects.reserve(effects.mList.size());
const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>(); const auto& store = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>();
for (const ESM::ENAMstruct& effect : effects.mList) for (const ESM::ENAMstruct& effect : effects.mList)
{ {
if (effect.mRange == range) if (effect.mRange == range)
@ -278,7 +278,7 @@ namespace MWMechanics
bool CastSpell::cast(const ESM::RefId& id) 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<ESM::Spell>().search(id)) if (const auto spell = store.get<ESM::Spell>().search(id))
return cast(spell); return cast(spell);
@ -301,7 +301,7 @@ namespace MWMechanics
mId = item.getCellRef().getRefId(); mId = item.getCellRef().getRefId();
const ESM::Enchantment* enchantment const ESM::Enchantment* enchantment
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantmentName); = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().find(enchantmentName);
mSlot = slot; mSlot = slot;
@ -336,7 +336,7 @@ namespace MWMechanics
{ {
short effectId = enchantment->mEffects.mList.front().mEffectID; short effectId = enchantment->mEffects.mList.front().mEffectID;
const ESM::MagicEffect* magicEffect const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectId); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effectId);
school = magicEffect->mData.mSchool; school = magicEffect->mData.mSchool;
} }
@ -472,7 +472,7 @@ namespace MWMechanics
effect.mRange = ESM::RT_Self; effect.mRange = ESM::RT_Self;
effect.mArea = 0; 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<ESM::MagicEffect>().find(effect.mEffectID); const auto magicEffect = store.get<ESM::MagicEffect>().find(effect.mEffectID);
const MWMechanics::CreatureStats& creatureStats = mCaster.getClass().getCreatureStats(mCaster); const MWMechanics::CreatureStats& creatureStats = mCaster.getClass().getCreatureStats(mCaster);
@ -533,7 +533,7 @@ namespace MWMechanics
void CastSpell::playSpellCastingEffects(const std::vector<ESM::ENAMstruct>& effects) const void CastSpell::playSpellCastingEffects(const std::vector<ESM::ENAMstruct>& effects) const
{ {
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
std::vector<std::string> addedEffects; std::vector<std::string> addedEffects;
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
@ -626,9 +626,9 @@ namespace MWMechanics
// Add VFX // Add VFX
const ESM::Static* castStatic; const ESM::Static* castStatic;
if (!magicEffect.mHit.empty()) if (!magicEffect.mHit.empty())
castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find(magicEffect.mHit); castStatic = MWBase::Environment::get().getESMStore()->get<ESM::Static>().find(magicEffect.mHit);
else else
castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find( castStatic = MWBase::Environment::get().getESMStore()->get<ESM::Static>().find(
ESM::RefId::stringRefId("VFX_DefaultHit")); ESM::RefId::stringRefId("VFX_DefaultHit"));
bool loop = (magicEffect.mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0; bool loop = (magicEffect.mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;

@ -267,7 +267,7 @@ namespace
if (effect.mFlags & ESM::ActiveEffect::Flag_Applied && effect.mEffectId != ESM::MagicEffect::Corprus) if (effect.mFlags & ESM::ActiveEffect::Flag_Applied && effect.mEffectId != ESM::MagicEffect::Corprus)
{ {
const auto* magicEffect const auto* magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effect.mEffectId); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effect.mEffectId);
if (magicEffect->mData.mFlags & ESM::MagicEffect::Flags::AppliedOnce if (magicEffect->mData.mFlags & ESM::MagicEffect::Flags::AppliedOnce
&& (!harmfulOnly || magicEffect->mData.mFlags & ESM::MagicEffect::Flags::Harmful)) && (!harmfulOnly || magicEffect->mData.mFlags & ESM::MagicEffect::Flags::Harmful))
return true; return true;
@ -277,7 +277,7 @@ namespace
void absorbSpell(const ESM::RefId& spellId, const MWWorld::Ptr& caster, const MWWorld::Ptr& target) 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<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Absorb")); const ESM::Static* absorbStatic = esmStore.get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Absorb"));
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target);
if (animation && !absorbStatic->mModel.empty()) if (animation && !absorbStatic->mModel.empty())
@ -359,7 +359,7 @@ namespace
{ {
const ESM::Spell* spell = nullptr; const ESM::Spell* spell = nullptr;
if (spellParams.getType() == ESM::ActiveSpells::Type_Temporary) if (spellParams.getType() == ESM::ActiveSpells::Type_Temporary)
spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spellParams.getId()); spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(spellParams.getId());
float magnitudeMult float magnitudeMult
= MWMechanics::getEffectMultiplier(effect.mEffectId, target, caster, spell, &magnitudes); = MWMechanics::getEffectMultiplier(effect.mEffectId, target, caster, spell, &magnitudes);
if (magnitudeMult == 0) if (magnitudeMult == 0)
@ -431,8 +431,7 @@ namespace MWMechanics
if (params.getType() == ESM::ActiveSpells::Type_Temporary) if (params.getType() == ESM::ActiveSpells::Type_Temporary)
{ {
const ESM::Spell* spell const ESM::Spell* spell
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search( = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(params.getId());
params.getId());
if (spell && spell->mData.mType == ESM::Spell::ST_Spell) if (spell && spell->mData.mType == ESM::Spell::ST_Spell)
{ {
auto& prng = MWBase::Environment::get().getWorld()->getPrng(); auto& prng = MWBase::Environment::get().getWorld()->getPrng();

@ -18,16 +18,16 @@ namespace
template <class T> template <class T>
const std::vector<ESM::RefId> getSpellList(const ESM::RefId& id) const std::vector<ESM::RefId> getSpellList(const ESM::RefId& id)
{ {
return MWBase::Environment::get().getWorld()->getStore().get<T>().find(id)->mSpells.mList; return MWBase::Environment::get().getESMStore()->get<T>().find(id)->mSpells.mList;
} }
template <class T> template <class T>
bool withBaseRecord(const ESM::RefId& id, const std::function<bool(std::vector<ESM::RefId>&)>& function) bool withBaseRecord(const ESM::RefId& id, const std::function<bool(std::vector<ESM::RefId>&)>& function)
{ {
T copy = *MWBase::Environment::get().getWorld()->getStore().get<T>().find(id); T copy = *MWBase::Environment::get().getESMStore()->get<T>().find(id);
bool changed = function(copy.mSpells.mList); bool changed = function(copy.mSpells.mList);
if (changed) if (changed)
MWBase::Environment::get().getWorld()->createOverrideRecord(copy); MWBase::Environment::get().getESMStore()->overrideRecord(copy);
return changed; return changed;
} }
} }
@ -68,7 +68,7 @@ namespace MWMechanics
const ESM::Spell* SpellList::getSpell(const ESM::RefId& id) const ESM::Spell* SpellList::getSpell(const ESM::RefId& id)
{ {
return MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(id); return MWBase::Environment::get().getESMStore()->get<ESM::Spell>().find(id);
} }
void SpellList::add(const ESM::Spell* spell) void SpellList::add(const ESM::Spell* spell)

@ -32,7 +32,7 @@ namespace
if (effectFilter == -1) if (effectFilter == -1)
{ {
const ESM::Spell* spell const ESM::Spell* spell
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(it->getId()); = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(it->getId());
if (!spell || spell->mData.mType != ESM::Spell::ST_Spell) if (!spell || spell->mData.mType != ESM::Spell::ST_Spell)
continue; continue;
} }
@ -44,7 +44,7 @@ namespace
if (effectFilter != -1 && effectId != effectFilter) if (effectFilter != -1 && effectId != effectFilter)
continue; continue;
const ESM::MagicEffect* magicEffect const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectId); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effectId);
if (effect.mDuration <= 3) // Don't attempt to dispel if effect runs out shortly anyway if (effect.mDuration <= 3) // Don't attempt to dispel if effect runs out shortly anyway
continue; continue;
@ -127,7 +127,7 @@ namespace MWMechanics
if (actor.getClass().isNpc()) if (actor.getClass().isNpc())
{ {
const ESM::RefId& raceid = actor.get<ESM::NPC>()->mBase->mRace; const ESM::RefId& raceid = actor.get<ESM::NPC>()->mBase->mRace;
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(raceid); const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(raceid);
if (race->mPowers.exists(spell->mId)) if (race->mPowers.exists(spell->mId))
return 0.f; return 0.f;
} }
@ -147,8 +147,7 @@ namespace MWMechanics
if (ptr.getClass().getEnchantment(ptr).empty()) if (ptr.getClass().getEnchantment(ptr).empty())
return 0.f; return 0.f;
const ESM::Enchantment* enchantment const ESM::Enchantment* enchantment = MWBase::Environment::get().getESMStore()->get<ESM::Enchantment>().find(
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(
ptr.getClass().getEnchantment(ptr)); ptr.getClass().getEnchantment(ptr));
// Spells don't stack, so early out if the spell is still active on the target // Spells don't stack, so early out if the spell is still active on the target
@ -372,8 +371,7 @@ namespace MWMechanics
{ {
// Beast races can't wear helmets or boots // Beast races can't wear helmets or boots
const ESM::RefId& raceid = actor.get<ESM::NPC>()->mBase->mRace; const ESM::RefId& raceid = actor.get<ESM::NPC>()->mBase->mRace;
const ESM::Race* race const ESM::Race* race = MWBase::Environment::get().getESMStore()->get<ESM::Race>().find(raceid);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(raceid);
if (race->mData.mFlags & ESM::Race::Beast) if (race->mData.mFlags & ESM::Race::Beast)
return 0.f; return 0.f;
} }
@ -640,7 +638,7 @@ namespace MWMechanics
} }
const ESM::MagicEffect* magicEffect const ESM::MagicEffect* magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effect.mEffectID); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effect.mEffectID);
if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful) if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful)
{ {
rating *= -1.f; rating *= -1.f;
@ -694,7 +692,7 @@ namespace MWMechanics
float rating = 0.f; float rating = 0.f;
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fAIMagicSpellMult = gmst.find("fAIMagicSpellMult")->mValue.getFloat(); static const float fAIMagicSpellMult = gmst.find("fAIMagicSpellMult")->mValue.getFloat();
static const float fAIRangeMagicSpellMult = gmst.find("fAIRangeMagicSpellMult")->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) float vanillaRateSpell(const ESM::Spell* spell, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy)
{ {
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fAIMagicSpellMult = gmst.find("fAIMagicSpellMult")->mValue.getFloat(); static const float fAIMagicSpellMult = gmst.find("fAIMagicSpellMult")->mValue.getFloat();
static const float fAIRangeMagicSpellMult = gmst.find("fAIRangeMagicSpellMult")->mValue.getFloat(); static const float fAIRangeMagicSpellMult = gmst.find("fAIRangeMagicSpellMult")->mValue.getFloat();

@ -33,8 +33,7 @@ namespace MWMechanics
if (ESM::MagicEffect::getResistanceEffect(effectId) == -1) if (ESM::MagicEffect::getResistanceEffect(effectId) == -1)
return 0.f; return 0.f;
const auto magicEffect const auto magicEffect = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effectId);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectId);
const MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor); const MWMechanics::CreatureStats& stats = actor.getClass().getCreatureStats(actor);
const MWMechanics::MagicEffects* magicEffects = &stats.getMagicEffects(); const MWMechanics::MagicEffects* magicEffects = &stats.getMagicEffects();

@ -208,7 +208,7 @@ namespace MWMechanics
for (const ESM::RefId& id : state.mSpells) for (const ESM::RefId& id : state.mSpells)
{ {
// Discard spells that are no longer available due to changed content files // Discard spells that are no longer available due to changed content files
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(id); const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(id);
if (spell) if (spell)
{ {
addSpell(spell); addSpell(spell);
@ -220,15 +220,14 @@ namespace MWMechanics
// Add spells from the base record // Add spells from the base record
for (const ESM::RefId& id : baseSpells) for (const ESM::RefId& id : baseSpells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(id); const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(id);
if (spell) if (spell)
addSpell(spell); addSpell(spell);
} }
for (auto it = state.mUsedPowers.begin(); it != state.mUsedPowers.end(); ++it) for (auto it = state.mUsedPowers.begin(); it != state.mUsedPowers.end(); ++it)
{ {
const ESM::Spell* spell const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(it->first);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(it->first);
if (!spell) if (!spell)
continue; continue;
mUsedPowers.emplace_back(spell, MWWorld::TimeStamp(it->second)); mUsedPowers.emplace_back(spell, MWWorld::TimeStamp(it->second));
@ -238,8 +237,7 @@ namespace MWMechanics
// only in old saves. Convert data to the new approach. // only in old saves. Convert data to the new approach.
for (auto it = state.mPermanentSpellEffects.begin(); it != state.mPermanentSpellEffects.end(); ++it) for (auto it = state.mPermanentSpellEffects.begin(); it != state.mPermanentSpellEffects.end(); ++it)
{ {
const ESM::Spell* spell const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(it->first);
= MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(it->first);
if (!spell) if (!spell)
continue; continue;
@ -293,7 +291,7 @@ namespace MWMechanics
bool Spells::setSpells(const ESM::RefId& actorId) bool Spells::setSpells(const ESM::RefId& actorId)
{ {
bool result; 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); mSpellList->addListener(this);
addAllToInstance(mSpellList->getSpells()); addAllToInstance(mSpellList->getSpells());
return result; return result;
@ -303,7 +301,7 @@ namespace MWMechanics
{ {
for (const ESM::RefId& id : spells) for (const ESM::RefId& id : spells)
{ {
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(id); const ESM::Spell* spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(id);
if (spell) if (spell)
addSpell(spell); addSpell(spell);
else else

@ -31,7 +31,7 @@ namespace MWMechanics
float calcEffectCost( float calcEffectCost(
const ESM::ENAMstruct& effect, const ESM::MagicEffect* magicEffect, const EffectCostMethod method) 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) if (!magicEffect)
magicEffect = store.get<ESM::MagicEffect>().find(effect.mEffectID); magicEffect = store.get<ESM::MagicEffect>().find(effect.mEffectID);
bool hasMagnitude = !(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude); bool hasMagnitude = !(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude);
@ -104,7 +104,7 @@ namespace MWMechanics
{ {
float x = static_cast<float>(effect.mDuration); float x = static_cast<float>(effect.mDuration);
const auto magicEffect const auto magicEffect
= MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effect.mEffectID); = MWBase::Environment::get().getESMStore()->get<ESM::MagicEffect>().find(effect.mEffectID);
if (!(magicEffect->mData.mFlags & ESM::MagicEffect::AppliedOnce)) if (!(magicEffect->mData.mFlags & ESM::MagicEffect::AppliedOnce))
x = std::max(1.f, x); x = std::max(1.f, x);
@ -115,9 +115,8 @@ namespace MWMechanics
if (effect.mRange == ESM::RT_Target) if (effect.mRange == ESM::RT_Target)
x *= 1.5f; x *= 1.5f;
static const float fEffectCostMult = MWBase::Environment::get() static const float fEffectCostMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fEffectCostMult") .find("fEffectCostMult")
->mValue.getFloat(); ->mValue.getFloat();
x *= fEffectCostMult; x *= fEffectCostMult;
@ -183,7 +182,7 @@ namespace MWMechanics
float getSpellSuccessChance( float getSpellSuccessChance(
const ESM::RefId& spellId, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap, bool checkMagicka) const ESM::RefId& spellId, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap, bool checkMagicka)
{ {
if (const auto spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spellId)) if (const auto spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(spellId))
return getSpellSuccessChance(spell, actor, effectiveSchool, cap, checkMagicka); return getSpellSuccessChance(spell, actor, effectiveSchool, cap, checkMagicka);
return 0.f; return 0.f;
} }
@ -209,7 +208,7 @@ namespace MWMechanics
bool spellIncreasesSkill(const ESM::RefId& spellId) bool spellIncreasesSkill(const ESM::RefId& spellId)
{ {
const auto spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(spellId); const auto spell = MWBase::Environment::get().getESMStore()->get<ESM::Spell>().search(spellId);
return spell && spellIncreasesSkill(spell); return spell && spellIncreasesSkill(spell);
} }
} }

@ -63,12 +63,8 @@ namespace MWMechanics
for (const auto& it : summonMapToGameSetting) for (const auto& it : summonMapToGameSetting)
{ {
summonMap[it.first] = ESM::RefId::stringRefId(MWBase::Environment::get() summonMap[it.first] = ESM::RefId::stringRefId(
.getWorld() MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>().find(it.second)->mValue.getString());
->getStore()
.get<ESM::GameSetting>()
.find(it.second)
->mValue.getString());
} }
return summonMap; return summonMap;
} }

@ -30,7 +30,7 @@ namespace MWMechanics
} }
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
// Is the player buying? // Is the player buying?
bool buying = (merchantOffer < 0); bool buying = (merchantOffer < 0);

@ -170,7 +170,7 @@ namespace MWMechanics
const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy)
{ {
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fAIMeleeWeaponMult = gmst.find("fAIMeleeWeaponMult")->mValue.getFloat(); static const float fAIMeleeWeaponMult = gmst.find("fAIMeleeWeaponMult")->mValue.getFloat();
static const float fAIMeleeArmorMult = gmst.find("fAIMeleeArmorMult")->mValue.getFloat(); static const float fAIMeleeArmorMult = gmst.find("fAIMeleeArmorMult")->mValue.getFloat();

@ -177,9 +177,8 @@ namespace MWPhysics
float angleDegrees = osg::RadiansToDegrees( float angleDegrees = osg::RadiansToDegrees(
std::acos(stormDirection * velocity / (stormDirection.length() * velocity.length()))); std::acos(stormDirection * velocity / (stormDirection.length() * velocity.length())));
static const float fStromWalkMult = MWBase::Environment::get() static const float fStromWalkMult = MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fStromWalkMult") .find("fStromWalkMult")
->mValue.getFloat(); ->mValue.getFloat();
velocity *= 1.f - (fStromWalkMult * (angleDegrees / 180.f)); velocity *= 1.f - (fStromWalkMult * (angleDegrees / 180.f));

@ -77,7 +77,7 @@ namespace
if (!isPlayer || !MWBase::Environment::get().getWorld()->getGodModeState()) if (!isPlayer || !MWBase::Environment::get().getWorld()->getGodModeState())
{ {
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
const float fFatigueJumpBase = gmst.find("fFatigueJumpBase")->mValue.getFloat(); const float fFatigueJumpBase = gmst.find("fFatigueJumpBase")->mValue.getFloat();
const float fFatigueJumpMult = gmst.find("fFatigueJumpMult")->mValue.getFloat(); const float fFatigueJumpMult = gmst.find("fFatigueJumpMult")->mValue.getFloat();
const float normalizedEncumbrance = std::min(1.f, ptr.getClass().getNormalizedEncumbrance(ptr)); const float normalizedEncumbrance = std::min(1.f, ptr.getClass().getNormalizedEncumbrance(ptr));
@ -209,7 +209,7 @@ namespace MWPhysics
// Use cone shape as fallback // Use cone shape as fallback
const MWWorld::Store<ESM::GameSetting>& store const MWWorld::Store<ESM::GameSetting>& store
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
btConeShape shape(osg::DegreesToRadians(store.find("fCombatAngleXY")->mValue.getFloat() / 2.0f), queryDistance); btConeShape shape(osg::DegreesToRadians(store.find("fCombatAngleXY")->mValue.getFloat() / 2.0f), queryDistance);
shape.setLocalScaling(btVector3( shape.setLocalScaling(btVector3(
@ -988,9 +988,8 @@ namespace MWPhysics
, mSwimLevel(waterlevel , mSwimLevel(waterlevel
- (actor.getRenderingHalfExtents().z() * 2 - (actor.getRenderingHalfExtents().z() * 2
* MWBase::Environment::get() * MWBase::Environment::get()
.getWorld() .getESMStore()
->getStore() ->get<ESM::GameSetting>()
.get<ESM::GameSetting>()
.find("fSwimHeightScale") .find("fSwimHeightScale")
->mValue.getFloat())) ->mValue.getFloat()))
, mSlowFall(slowFall) , mSlowFall(slowFall)

@ -112,7 +112,7 @@ namespace MWRender
// Try to recover the body part model, use ground model as a fallback otherwise. // Try to recover the body part model, use ground model as a fallback otherwise.
if (!bodyparts.empty()) if (!bodyparts.empty())
{ {
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
const MWWorld::Store<ESM::BodyPart>& partStore = store.get<ESM::BodyPart>(); const MWWorld::Store<ESM::BodyPart>& partStore = store.get<ESM::BodyPart>();
for (const auto& part : bodyparts) for (const auto& part : bodyparts)
{ {

@ -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 // 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 // performance loss Note: consider that player and werewolves have no custom animation files
// attached for now // 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<ESM::Race>().find(ref->mBase->mRace); const ESM::Race* race = store.get<ESM::Race>().find(ref->mBase->mRace);
bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0; bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0;

@ -290,7 +290,7 @@ namespace MWRender
void GlobalMap::render() 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 // get the size of the world
MWWorld::Store<ESM::Cell>::iterator it = esmStore.get<ESM::Cell>().extBegin(); MWWorld::Store<ESM::Cell>::iterator it = esmStore.get<ESM::Cell>().extBegin();

@ -56,7 +56,7 @@ namespace
if (sVampireMapping.find(thisCombination) == sVampireMapping.end()) 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<ESM::BodyPart>()) for (const ESM::BodyPart& bodypart : store.get<ESM::BodyPart>())
{ {
if (!bodypart.mData.mVampire) if (!bodypart.mData.mVampire)
@ -463,7 +463,7 @@ namespace MWRender
for (size_t i = 0; i < ESM::PRT_Count; i++) for (size_t i = 0; i < ESM::PRT_Count; i++)
removeIndividualPart((ESM::PartReferenceType)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<ESM::Race>().find(mNpc->mRace); const ESM::Race* race = store.get<ESM::Race>().find(mNpc->mRace);
NpcType curType = getNpcType(); NpcType curType = getNpcType();
bool isWerewolf = (curType == Type_Werewolf); bool isWerewolf = (curType == Type_Werewolf);
@ -873,7 +873,7 @@ namespace MWRender
void NpcAnimation::addPartGroup(int group, int priority, const std::vector<ESM::PartReference>& parts, void NpcAnimation::addPartGroup(int group, int priority, const std::vector<ESM::PartReference>& parts,
bool enchantedGlow, osg::Vec4f* glowColor) 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<ESM::BodyPart>& partStore = store.get<ESM::BodyPart>(); const MWWorld::Store<ESM::BodyPart>& partStore = store.get<ESM::BodyPart>();
const char* ext = (mViewMode == VM_FirstPerson) ? ".1st" : ""; const char* ext = (mViewMode == VM_FirstPerson) ? ".1st" : "";
@ -1201,7 +1201,7 @@ namespace MWRender
if (werewolf) if (werewolf)
return parts; 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<ESM::BodyPart>()) for (const ESM::BodyPart& bodypart : store.get<ESM::BodyPart>())
{ {

@ -28,7 +28,7 @@ namespace MWRender
bool TerrainStorage::hasData(int cellX, int cellY) 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<ESM::Land>().search(cellX, cellY); const ESM::Land* land = esmStore.get<ESM::Land>().search(cellX, cellY);
return land != nullptr; return land != nullptr;
@ -41,7 +41,7 @@ namespace MWRender
maxX = 0; maxX = 0;
maxY = 0; maxY = 0;
const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
MWWorld::Store<ESM::Land>::iterator it = esmStore.get<ESM::Land>().begin(); MWWorld::Store<ESM::Land>::iterator it = esmStore.get<ESM::Land>().begin();
for (; it != esmStore.get<ESM::Land>().end(); ++it) for (; it != esmStore.get<ESM::Land>().end(); ++it)
@ -73,7 +73,7 @@ namespace MWRender
const ESM::LandTexture* TerrainStorage::getLandTexture(int index, short plugin) 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<ESM::LandTexture>().search(index, plugin); return esmStore.get<ESM::LandTexture>().search(index, plugin);
} }

@ -114,7 +114,7 @@ namespace MWRender
* osg::Quat(actor.getRefData().getPosition().rot[2], osg::Vec3f(0, 0, -1)); * osg::Quat(actor.getRefData().getPosition().rot[2], osg::Vec3f(0, 0, -1));
const MWWorld::Store<ESM::GameSetting>& gmst const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); = MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
MWMechanics::applyFatigueLoss(actor, *weapon, attackStrength); MWMechanics::applyFatigueLoss(actor, *weapon, attackStrength);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save