1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 22:19:54 +00:00
openmw-tes3mp/apps/openmw/mwmp/RecordHelper.cpp

55 lines
1.6 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::updateCreatureRecord(const ESM::Creature& creature)
{
MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::ESMStore *esmStore = const_cast<MWWorld::ESMStore *>(&world->getStore());
MWWorld::Store<ESM::Creature> *creatureStore = const_cast<MWWorld::Store<ESM::Creature> *> (&esmStore->get<ESM::Creature>());
creatureStore->insert(creature);
}
void RecordHelper::updateNpcRecord(const ESM::NPC& npc)
{
MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::ESMStore *esmStore = const_cast<MWWorld::ESMStore *>(&world->getStore());
MWWorld::Store<ESM::NPC> *npcStore = const_cast<MWWorld::Store<ESM::NPC> *> (&esmStore->get<ESM::NPC>());
npcStore->insert(npc);
}