forked from teamnwah/openmw-tes3coop
Merge pull request #406 from TES3MP/0.6.3 while resolving conflicts
Conflicts: apps/openmw-mp/Script/Functions/Mechanics.cpp apps/openmw-mp/Script/Functions/Mechanics.hpp components/openmw-mp/Base/BasePlayer.hppsol2-server-rewrite
commit
ed15d9ebf5
@ -0,0 +1,55 @@
|
||||
#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);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef OPENMW_RECORDHELPER_HPP
|
||||
#define OPENMW_RECORDHELPER_HPP
|
||||
|
||||
#include <components/esm/loadcrea.hpp>
|
||||
#include <components/esm/loadnpc.hpp>
|
||||
|
||||
namespace RecordHelper
|
||||
{
|
||||
bool doesCreatureExist(const std::string& refId);
|
||||
bool doesRaceExist(const std::string& raceId);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
#endif //OPENMW_RECORDHELPER_HPP
|
Loading…
Reference in New Issue