diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index c78ca5604..960cafaa9 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -59,7 +59,7 @@ DedicatedPlayer::DedicatedPlayer(RakNet::RakNetGUID guid) : BasePlayer(guid) MWBase::World *world = MWBase::Environment::get().getWorld(); npc = *world->getPlayerPtr().get()->mBase; - npc.mId = "Dedicated Player"; + npc.mId = ""; previousRace = npc.mRace; hasFinishedInitialTeleportation = false; @@ -162,7 +162,7 @@ void DedicatedPlayer::setBaseInfo() } else { - RecordHelper::updateNpcRecord(npc); + RecordHelper::overrideNpcRecord(npc); reloadPtr(); } @@ -202,14 +202,13 @@ void DedicatedPlayer::setShapeshift() // and reuse it if (creatureRecordId.empty()) { - creature.mId = "Dedicated Player"; creature.mId = creatureRecordId = RecordHelper::createCreatureRecord(creature); LOG_APPEND(Log::LOG_INFO, "- Creating new creature record %s", creatureRecordId.c_str()); } else { creature.mId = creatureRecordId; - RecordHelper::updateCreatureRecord(creature); + RecordHelper::overrideCreatureRecord(creature); } if (!reference) @@ -231,7 +230,7 @@ void DedicatedPlayer::setShapeshift() deleteReference(); } - RecordHelper::updateNpcRecord(npc); + RecordHelper::overrideNpcRecord(npc); createReference(npc.mId); reloadPtr(); } diff --git a/apps/openmw/mwmp/RecordHelper.cpp b/apps/openmw/mwmp/RecordHelper.cpp index 186558d18..d4d8aaec4 100644 --- a/apps/openmw/mwmp/RecordHelper.cpp +++ b/apps/openmw/mwmp/RecordHelper.cpp @@ -34,22 +34,37 @@ std::string RecordHelper::createNpcRecord(const ESM::NPC& npc) return world->createRecord(npc)->mId; } -void RecordHelper::updateCreatureRecord(const ESM::Creature& creature) +void RecordHelper::overrideCreatureRecord(const ESM::Creature& creature) { MWBase::World *world = MWBase::Environment::get().getWorld(); - MWWorld::ESMStore *esmStore = const_cast(&world->getStore()); - MWWorld::Store *creatureStore = const_cast *> (&esmStore->get()); + world->getModifiableStore().overrideRecord(creature); +} + +void RecordHelper::overrideNpcRecord(const ESM::NPC& npc) +{ + MWBase::World *world = MWBase::Environment::get().getWorld(); - creatureStore->insert(creature); + world->getModifiableStore().overrideRecord(npc); } -void RecordHelper::updateNpcRecord(const ESM::NPC& npc) +void RecordHelper::overrideEnchantmentRecord(const ESM::Enchantment& enchantment) { MWBase::World *world = MWBase::Environment::get().getWorld(); - MWWorld::ESMStore *esmStore = const_cast(&world->getStore()); - MWWorld::Store *npcStore = const_cast *> (&esmStore->get()); + world->getModifiableStore().overrideRecord(enchantment); +} + +void RecordHelper::overridePotionRecord(const ESM::Potion& potion) +{ + MWBase::World *world = MWBase::Environment::get().getWorld(); + + world->getModifiableStore().overrideRecord(potion); +} + +void RecordHelper::overrideSpellRecord(const ESM::Spell& spell) +{ + MWBase::World *world = MWBase::Environment::get().getWorld(); - npcStore->insert(npc); + world->getModifiableStore().overrideRecord(spell); } diff --git a/apps/openmw/mwmp/RecordHelper.hpp b/apps/openmw/mwmp/RecordHelper.hpp index 314438332..0a7811f2b 100644 --- a/apps/openmw/mwmp/RecordHelper.hpp +++ b/apps/openmw/mwmp/RecordHelper.hpp @@ -12,8 +12,12 @@ namespace RecordHelper std::string createCreatureRecord(const ESM::Creature& creature); std::string createNpcRecord(const ESM::NPC& npc); - void updateCreatureRecord(const ESM::Creature& creature); - void updateNpcRecord(const ESM::NPC& npc); + void overrideCreatureRecord(const ESM::Creature& creature); + void overrideNpcRecord(const ESM::NPC& npc); + + void overrideEnchantmentRecord(const ESM::Enchantment& enchantment); + void overridePotionRecord(const ESM::Potion& potion); + void overrideSpellRecord(const ESM::Spell& spell); }