1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-28 20:15:32 +00:00

[Client] Add createRecord() function to RecordHelper

This commit is contained in:
David Cernat 2019-10-16 13:14:32 +03:00
parent 13deaa88f2
commit aa06056d00
3 changed files with 18 additions and 27 deletions

View file

@ -160,7 +160,7 @@ void DedicatedPlayer::setBaseInfo()
if (!reference)
{
npc.mId = RecordHelper::createNpcRecord(npc);
npc.mId = RecordHelper::createRecord(npc)->mId;
createReference(npc.mId);
}
else
@ -202,7 +202,7 @@ void DedicatedPlayer::setShapeshift()
// and reuse it
if (creatureRecordId.empty())
{
creature.mId = creatureRecordId = RecordHelper::createCreatureRecord(creature);
creature.mId = creatureRecordId = RecordHelper::createRecord(creature)->mId;
LOG_APPEND(TimedLog::LOG_INFO, "- Creating new creature record %s", creatureRecordId.c_str());
}
else

View file

@ -7,20 +7,6 @@
#include "RecordHelper.hpp"
std::string RecordHelper::createCreatureRecord(const ESM::Creature& record)
{
MWBase::World *world = MWBase::Environment::get().getWorld();
return world->createRecord(record)->mId;
}
std::string RecordHelper::createNpcRecord(const ESM::NPC& record)
{
MWBase::World *world = MWBase::Environment::get().getWorld();
return world->createRecord(record)->mId;
}
void RecordHelper::overrideCreatureRecord(const mwmp::CreatureRecord& record)
{
const ESM::Creature &recordData = record.data;

View file

@ -8,9 +8,6 @@
namespace RecordHelper
{
std::string createCreatureRecord(const ESM::Creature& record);
std::string createNpcRecord(const ESM::NPC& record);
void overrideCreatureRecord(const mwmp::CreatureRecord& record);
void overrideNpcRecord(const mwmp::NpcRecord& record);
@ -38,14 +35,6 @@ namespace RecordHelper
void overrideLightRecord(const mwmp::LightRecord& record);
void overrideCellRecord(const mwmp::CellRecord& record);
template<class RecordType>
bool doesRecordIdExist(const std::string& id)
{
MWBase::World *world = MWBase::Environment::get().getWorld();
return world->getStore().get<RecordType>().search(id);
}
template<class RecordType>
void overrideRecord(const RecordType &record)
{
@ -53,6 +42,22 @@ namespace RecordHelper
world->getModifiableStore().overrideRecord(record);
}
template<class RecordType>
const RecordType *createRecord(const RecordType &record)
{
MWBase::World *world = MWBase::Environment::get().getWorld();
return world->createRecord(record);
}
template<class RecordType>
bool doesRecordIdExist(const std::string& id)
{
MWBase::World *world = MWBase::Environment::get().getWorld();
return world->getStore().get<RecordType>().search(id);
}
}