mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 19:49:54 +00:00
60bc7447d9
The usage of const_cast has been replaced with usage of MWWorld::getModifiableStore() and ESMStore::overrideRecord() Methods whose names started with "update" now start with "override", for consistency with ESMStore's overrideRecord() New methods have been added for "overriding" enchantment, potion and spell records, which actually leads to them being created with their already set refIds if they haven't been created yet, as per the description of ESMStore::overrideRecord(): "Insert a record with set ID, and allow it to override a pre-existing static record." Usage of RecordHelper methods has been updated in DedicatedPlayer.
70 lines
1.9 KiB
C++
70 lines
1.9 KiB
C++
#include <components/openmw-mp/Log.hpp>
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwworld/worldimp.hpp"
|
|
|
|
#include "RecordHelper.hpp"
|
|
|
|
bool RecordHelper::doesCreatureExist(const std::string& refId)
|
|
{
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
return world->getStore().get<ESM::Creature>().search(refId);
|
|
}
|
|
|
|
bool RecordHelper::doesRaceExist(const std::string& raceId)
|
|
{
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
return world->getStore().get<ESM::Race>().search(raceId);
|
|
}
|
|
|
|
std::string RecordHelper::createCreatureRecord(const ESM::Creature& creature)
|
|
{
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
return world->createRecord(creature)->mId;
|
|
}
|
|
|
|
std::string RecordHelper::createNpcRecord(const ESM::NPC& npc)
|
|
{
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
return world->createRecord(npc)->mId;
|
|
}
|
|
|
|
void RecordHelper::overrideCreatureRecord(const ESM::Creature& creature)
|
|
{
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
world->getModifiableStore().overrideRecord(creature);
|
|
}
|
|
|
|
void RecordHelper::overrideNpcRecord(const ESM::NPC& npc)
|
|
{
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
world->getModifiableStore().overrideRecord(npc);
|
|
}
|
|
|
|
void RecordHelper::overrideEnchantmentRecord(const ESM::Enchantment& enchantment)
|
|
{
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
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();
|
|
|
|
world->getModifiableStore().overrideRecord(spell);
|
|
}
|