1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-30 20:45:35 +00:00

Add functions to read and write ESM::RefId and use them

To be later changed with another implementation.
This commit is contained in:
elsid 2023-02-12 19:36:56 +01:00
parent bf0da418f9
commit 6d261d38dd
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
68 changed files with 272 additions and 190 deletions

View file

@ -213,7 +213,7 @@ namespace ESSImport
public: public:
void read(ESM::ESMReader& esm) override void read(ESM::ESMReader& esm) override
{ {
auto id = ESM::RefId::stringRefId(esm.getHNString("NAME")); auto id = esm.getHNRefId("NAME");
NPCC npcc; NPCC npcc;
npcc.load(esm); npcc.load(esm);
if (id == "PlayerSaveGame") if (id == "PlayerSaveGame")
@ -308,7 +308,7 @@ namespace ESSImport
{ {
void read(ESM::ESMReader& esm) override void read(ESM::ESMReader& esm) override
{ {
auto id = ESM::RefId::stringRefId(esm.getHNString("NAME")); auto id = esm.getHNRefId("NAME");
CNTC cntc; CNTC cntc;
cntc.load(esm); cntc.load(esm);
mContext->mContainerChanges.insert(std::make_pair(std::make_pair(cntc.mIndex, id), cntc)); mContext->mContainerChanges.insert(std::make_pair(std::make_pair(cntc.mIndex, id), cntc));
@ -320,7 +320,7 @@ namespace ESSImport
public: public:
void read(ESM::ESMReader& esm) override void read(ESM::ESMReader& esm) override
{ {
auto id = ESM::RefId::stringRefId(esm.getHNString("NAME")); auto id = esm.getHNRefId("NAME");
CREC crec; CREC crec;
crec.load(esm); crec.load(esm);
mContext->mCreatureChanges.insert(std::make_pair(std::make_pair(crec.mIndex, id), crec)); mContext->mCreatureChanges.insert(std::make_pair(std::make_pair(crec.mIndex, id), crec));

View file

@ -1815,7 +1815,7 @@ namespace MWGui
if (!mSelectedSpell.empty()) if (!mSelectedSpell.empty())
{ {
writer.startRecord(ESM::REC_ASPL); writer.startRecord(ESM::REC_ASPL);
writer.writeHNString("ID__", mSelectedSpell.getRefIdString()); writer.writeHNRefId("ID__", mSelectedSpell);
writer.endRecord(ESM::REC_ASPL); writer.endRecord(ESM::REC_ASPL);
} }

View file

@ -2286,7 +2286,7 @@ namespace MWMechanics
writer.startRecord(ESM::REC_DCOU); writer.startRecord(ESM::REC_DCOU);
for (const auto& [id, count] : mDeathCount) for (const auto& [id, count] : mDeathCount)
{ {
writer.writeHNString("ID__", id.getRefIdString()); writer.writeHNRefId("ID__", id);
writer.writeHNT("COUN", count); writer.writeHNT("COUN", count);
} }
writer.endRecord(ESM::REC_DCOU); writer.endRecord(ESM::REC_DCOU);

View file

@ -74,11 +74,8 @@ void ESM::LuaScriptsCfg::load(ESMReader& esm)
esm.getSubHeader(); esm.getSubHeader();
script.mRecords.emplace_back(); script.mRecords.emplace_back();
ESM::LuaScriptCfg::PerRecordCfg& recordCfg = script.mRecords.back(); ESM::LuaScriptCfg::PerRecordCfg& recordCfg = script.mRecords.back();
std::string recordIdString;
recordIdString.resize(esm.getSubSize() - 1);
recordCfg.mAttach = readBool(esm); recordCfg.mAttach = readBool(esm);
esm.getExact(recordIdString.data(), static_cast<int>(recordIdString.size())); recordCfg.mRecordId = esm.getRefId(esm.getSubSize() - 1);
recordCfg.mRecordId = ESM::RefId::stringRefId(recordIdString);
recordCfg.mInitializationData = loadLuaBinaryData(esm); recordCfg.mInitializationData = loadLuaBinaryData(esm);
} }
while (esm.isNextSub("LUAI")) while (esm.isNextSub("LUAI"))
@ -144,7 +141,7 @@ void ESM::LuaScriptsCfg::save(ESMWriter& esm) const
{ {
esm.startSubRecord("LUAR"); esm.startSubRecord("LUAR");
esm.writeT<char>(recordCfg.mAttach ? 1 : 0); esm.writeT<char>(recordCfg.mAttach ? 1 : 0);
esm.write(recordCfg.mRecordId.getRefIdString().data(), recordCfg.mRecordId.getRefIdString().size()); esm.writeHRefId(recordCfg.mRecordId);
esm.endRecord("LUAR"); esm.endRecord("LUAR");
saveLuaBinaryData(esm, recordCfg.mInitializationData); saveLuaBinaryData(esm, recordCfg.mInitializationData);
} }

View file

@ -11,7 +11,7 @@ namespace ESM
{ {
for (const auto& params : spells) for (const auto& params : spells)
{ {
esm.writeHNString(tag, params.mId.getRefIdString()); esm.writeHNRefId(tag, params.mId);
esm.writeHNT("CAST", params.mCasterActorId); esm.writeHNT("CAST", params.mCasterActorId);
esm.writeHNString("DISP", params.mDisplayName); esm.writeHNString("DISP", params.mDisplayName);

View file

@ -50,7 +50,7 @@ namespace ESM
void AiEscort::load(ESMReader& esm) void AiEscort::load(ESMReader& esm)
{ {
esm.getHNT(mData, "DATA"); esm.getHNT(mData, "DATA");
mTargetId = ESM::RefId::stringRefId(esm.getHNString("TARG")); mTargetId = esm.getHNRefId("TARG");
mTargetActorId = -1; mTargetActorId = -1;
esm.getHNOT(mTargetActorId, "TAID"); esm.getHNOT(mTargetActorId, "TAID");
esm.getHNT(mRemainingDuration, "DURA"); esm.getHNT(mRemainingDuration, "DURA");
@ -70,7 +70,7 @@ namespace ESM
void AiEscort::save(ESMWriter& esm) const void AiEscort::save(ESMWriter& esm) const
{ {
esm.writeHNT("DATA", mData); esm.writeHNT("DATA", mData);
esm.writeHNString("TARG", mTargetId.getRefIdString()); esm.writeHNRefId("TARG", mTargetId);
esm.writeHNT("TAID", mTargetActorId); esm.writeHNT("TAID", mTargetActorId);
esm.writeHNT("DURA", mRemainingDuration); esm.writeHNT("DURA", mRemainingDuration);
if (!mCellId.empty()) if (!mCellId.empty())
@ -82,7 +82,7 @@ namespace ESM
void AiFollow::load(ESMReader& esm) void AiFollow::load(ESMReader& esm)
{ {
esm.getHNT(mData, "DATA"); esm.getHNT(mData, "DATA");
mTargetId = ESM::RefId::stringRefId(esm.getHNString("TARG")); mTargetId = esm.getHNRefId("TARG");
mTargetActorId = -1; mTargetActorId = -1;
esm.getHNOT(mTargetActorId, "TAID"); esm.getHNOT(mTargetActorId, "TAID");
esm.getHNT(mRemainingDuration, "DURA"); esm.getHNT(mRemainingDuration, "DURA");
@ -107,7 +107,7 @@ namespace ESM
void AiFollow::save(ESMWriter& esm) const void AiFollow::save(ESMWriter& esm) const
{ {
esm.writeHNT("DATA", mData); esm.writeHNT("DATA", mData);
esm.writeHNString("TARG", mTargetId.getRefIdString()); esm.writeHNRefId("TARG", mTargetId);
esm.writeHNT("TAID", mTargetActorId); esm.writeHNT("TAID", mTargetActorId);
esm.writeHNT("DURA", mRemainingDuration); esm.writeHNT("DURA", mRemainingDuration);
if (!mCellId.empty()) if (!mCellId.empty())
@ -122,14 +122,14 @@ namespace ESM
void AiActivate::load(ESMReader& esm) void AiActivate::load(ESMReader& esm)
{ {
mTargetId = ESM::RefId::stringRefId(esm.getHNString("TARG")); mTargetId = esm.getHNRefId("TARG");
mRepeat = false; mRepeat = false;
esm.getHNOT(mRepeat, "REPT"); esm.getHNOT(mRepeat, "REPT");
} }
void AiActivate::save(ESMWriter& esm) const void AiActivate::save(ESMWriter& esm) const
{ {
esm.writeHNString("TARG", mTargetId.getRefIdString()); esm.writeHNRefId("TARG", mTargetId);
if (mRepeat) if (mRepeat)
esm.writeHNT("REPT", mRepeat); esm.writeHNT("REPT", mRepeat);
} }

View file

@ -34,7 +34,7 @@ namespace ESM
else else
{ {
RefNum{}.load(esm, wideRefNum); RefNum{}.load(esm, wideRefNum);
esm.skipHNOString("NAME"); esm.skipHNORefId("NAME");
} }
} }
@ -45,7 +45,7 @@ namespace ESM
if constexpr (load) if constexpr (load)
refId = esm.getRefId(); refId = esm.getRefId();
else else
esm.skipHString(); esm.skipHRefId();
}; };
const auto getHStringOrSkip = [&](std::string& value) { const auto getHStringOrSkip = [&](std::string& value) {
@ -195,7 +195,7 @@ namespace ESM
{ {
mRefNum.save(esm, wideRefNum); mRefNum.save(esm, wideRefNum);
esm.writeHNCString("NAME", mRefID.getRefIdString()); esm.writeHNCRefId("NAME", mRefID);
if (isDeleted) if (isDeleted)
{ {
@ -209,14 +209,14 @@ namespace ESM
} }
if (!inInventory) if (!inInventory)
esm.writeHNOCString("ANAM", mOwner.getRefIdString()); esm.writeHNOCRefId("ANAM", mOwner);
esm.writeHNOCString("BNAM", mGlobalVariable); esm.writeHNOCString("BNAM", mGlobalVariable);
esm.writeHNOCString("XSOL", mSoul.getRefIdString()); esm.writeHNOCRefId("XSOL", mSoul);
if (!inInventory) if (!inInventory)
{ {
esm.writeHNOCString("CNAM", mFaction.getRefIdString()); esm.writeHNOCRefId("CNAM", mFaction);
if (mFactionRank != -2) if (mFactionRank != -2)
{ {
esm.writeHNT("INDX", mFactionRank); esm.writeHNT("INDX", mFactionRank);
@ -245,8 +245,8 @@ namespace ESM
if (!inInventory) if (!inInventory)
{ {
esm.writeHNOCString("KNAM", mKey.getRefIdString()); esm.writeHNOCRefId("KNAM", mKey);
esm.writeHNOCString("TNAM", mTrap.getRefIdString()); esm.writeHNOCRefId("TNAM", mTrap);
} }
if (mReferenceBlocked != -1) if (mReferenceBlocked != -1)

View file

@ -87,9 +87,9 @@ namespace ESM
mFallHeight = 0; mFallHeight = 0;
esm.getHNOT(mFallHeight, "FALL"); esm.getHNOT(mFallHeight, "FALL");
mLastHitObject = ESM::RefId::stringRefId(esm.getHNOString("LHIT")); mLastHitObject = esm.getHNORefId("LHIT");
mLastHitAttemptObject = ESM::RefId::stringRefId(esm.getHNOString("LHAT")); mLastHitAttemptObject = esm.getHNORefId("LHAT");
if (esm.getFormatVersion() <= MaxWerewolfDeprecatedDataFormatVersion) if (esm.getFormatVersion() <= MaxWerewolfDeprecatedDataFormatVersion)
esm.getHNOT(mRecalcDynamicStats, "CALC"); esm.getHNOT(mRecalcDynamicStats, "CALC");
@ -121,7 +121,7 @@ namespace ESM
{ {
int magicEffect; int magicEffect;
esm.getHT(magicEffect); esm.getHT(magicEffect);
ESM::RefId source = ESM::RefId::stringRefId(esm.getHNOString("SOUR")); ESM::RefId source = esm.getHNORefId("SOUR");
int effectIndex = -1; int effectIndex = -1;
esm.getHNOT(effectIndex, "EIND"); esm.getHNOT(effectIndex, "EIND");
int actorId; int actorId;
@ -229,10 +229,10 @@ namespace ESM
esm.writeHNT("FALL", mFallHeight); esm.writeHNT("FALL", mFallHeight);
if (!mLastHitObject.empty()) if (!mLastHitObject.empty())
esm.writeHNString("LHIT", mLastHitObject.getRefIdString()); esm.writeHNRefId("LHIT", mLastHitObject);
if (!mLastHitAttemptObject.empty()) if (!mLastHitAttemptObject.empty())
esm.writeHNString("LHAT", mLastHitAttemptObject.getRefIdString()); esm.writeHNRefId("LHAT", mLastHitAttemptObject);
if (mDrawState) if (mDrawState)
esm.writeHNT("DRAW", mDrawState); esm.writeHNT("DRAW", mDrawState);

View file

@ -41,7 +41,7 @@ namespace ESM
void DebugProfile::save(ESMWriter& esm, bool isDeleted) const void DebugProfile::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {

View file

@ -37,16 +37,16 @@ namespace ESM
{ {
for (auto iter(mKnownTopics.begin()); iter != mKnownTopics.end(); ++iter) for (auto iter(mKnownTopics.begin()); iter != mKnownTopics.end(); ++iter)
{ {
esm.writeHNString("TOPI", iter->getRefIdString()); esm.writeHNRefId("TOPI", *iter);
} }
for (auto iter = mChangedFactionReaction.begin(); iter != mChangedFactionReaction.end(); ++iter) for (auto iter = mChangedFactionReaction.begin(); iter != mChangedFactionReaction.end(); ++iter)
{ {
esm.writeHNString("FACT", iter->first.getRefIdString()); esm.writeHNRefId("FACT", iter->first);
for (auto reactIter = iter->second.begin(); reactIter != iter->second.end(); ++reactIter) for (auto reactIter = iter->second.begin(); reactIter != iter->second.end(); ++reactIter)
{ {
esm.writeHNString("REA2", reactIter->first.getRefIdString()); esm.writeHNRefId("REA2", reactIter->first);
esm.writeHNT("INTV", reactIter->second); esm.writeHNT("INTV", reactIter->second);
} }
} }

View file

@ -131,10 +131,10 @@ namespace ESM
return ESM::RefId::sEmpty; return ESM::RefId::sEmpty;
} }
void ESMReader::skipHNOString(NAME name) void ESMReader::skipHNORefId(NAME name)
{ {
if (isNextSub(name)) if (isNextSub(name))
skipHString(); skipHRefId();
} }
std::string ESMReader::getHNString(NAME name) std::string ESMReader::getHNString(NAME name)
@ -143,6 +143,12 @@ namespace ESM
return getHString(); return getHString();
} }
RefId ESMReader::getHNRefId(NAME name)
{
getSubNameIs(name);
return getRefId();
}
std::string ESMReader::getHString() std::string ESMReader::getHString()
{ {
return std::string(getHStringView()); return std::string(getHStringView());
@ -194,6 +200,11 @@ namespace ESM
skip(mCtx.leftSub); skip(mCtx.leftSub);
} }
void ESMReader::skipHRefId()
{
skipHString();
}
void ESMReader::getHExact(void* p, int size) void ESMReader::getHExact(void* p, int size)
{ {
getSubHeader(); getSubHeader();
@ -390,6 +401,11 @@ namespace ESM
return std::string_view(ptr, size); return std::string_view(ptr, size);
} }
RefId ESMReader::getRefId(std::size_t size)
{
return RefId::stringRefId(getStringView(size));
}
[[noreturn]] void ESMReader::fail(const std::string& msg) [[noreturn]] void ESMReader::fail(const std::string& msg)
{ {
std::stringstream ss; std::stringstream ss;

View file

@ -165,20 +165,27 @@ namespace ESM
// Read a string by the given name if it is the next record. // Read a string by the given name if it is the next record.
std::string getHNOString(NAME name); std::string getHNOString(NAME name);
ESM::RefId getHNORefId(NAME name); ESM::RefId getHNORefId(NAME name);
void skipHNOString(NAME name); void skipHNORefId(NAME name);
// Read a string with the given sub-record name // Read a string with the given sub-record name
std::string getHNString(NAME name); std::string getHNString(NAME name);
RefId getHNRefId(NAME name);
// Read a string, including the sub-record header (but not the name) // Read a string, including the sub-record header (but not the name)
std::string getHString(); std::string getHString();
std::string_view getHStringView(); std::string_view getHStringView();
RefId getRefId(); RefId getRefId();
void skipHString(); void skipHString();
void skipHRefId();
// Read the given number of bytes from a subrecord // Read the given number of bytes from a subrecord
void getHExact(void* p, int size); void getHExact(void* p, int size);
@ -272,10 +279,14 @@ namespace ESM
std::string getMaybeFixedStringSize(std::size_t size); std::string getMaybeFixedStringSize(std::size_t size);
RefId getMaybeFixedRefIdSize(std::size_t size) { return RefId::stringRefId(getMaybeFixedStringSize(size)); }
// Read the next 'size' bytes and return them as a string. Converts // Read the next 'size' bytes and return them as a string. Converts
// them from native encoding to UTF8 in the process. // them from native encoding to UTF8 in the process.
std::string_view getStringView(std::size_t size); std::string_view getStringView(std::size_t size);
RefId getRefId(std::size_t size);
void skip(std::size_t bytes) void skip(std::size_t bytes)
{ {
char buffer[4096]; char buffer[4096];

View file

@ -167,6 +167,16 @@ namespace ESM
endRecord(name); endRecord(name);
} }
void ESMWriter::writeHNRefId(NAME name, const RefId& value)
{
writeHNString(name, value.getRefIdString());
}
void ESMWriter::writeHNRefId(NAME name, const RefId& value, std::size_t size)
{
writeHNString(name, value.getRefIdString(), size);
}
void ESMWriter::writeMaybeFixedSizeString(const std::string& data, std::size_t size) void ESMWriter::writeMaybeFixedSizeString(const std::string& data, std::size_t size)
{ {
std::string string; std::string string;
@ -210,6 +220,21 @@ namespace ESM
write("\0", 1); write("\0", 1);
} }
void ESMWriter::writeMaybeFixedSizeRefId(const RefId& value, std::size_t size)
{
writeMaybeFixedSizeString(value.getRefIdString(), size);
}
void ESMWriter::writeHRefId(const RefId& value)
{
writeHString(value.getRefIdString());
}
void ESMWriter::writeHCRefId(const RefId& value)
{
writeHCString(value.getRefIdString());
}
void ESMWriter::writeName(NAME name) void ESMWriter::writeName(NAME name)
{ {
write(name.mData, NAME::sCapacity); write(name.mData, NAME::sCapacity);

View file

@ -6,6 +6,8 @@
#include <type_traits> #include <type_traits>
#include "components/esm/esmcommon.hpp" #include "components/esm/esmcommon.hpp"
#include "components/esm/refid.hpp"
#include "loadtes3.hpp" #include "loadtes3.hpp"
namespace ToUTF8 namespace ToUTF8
@ -76,6 +78,29 @@ namespace ESM
writeHNCString(name, data); writeHNCString(name, data);
} }
void writeHNRefId(NAME name, const RefId& value);
void writeHNRefId(NAME name, const RefId& value, std::size_t size);
void writeHNCRefId(NAME name, const RefId& value)
{
startSubRecord(name);
writeHCRefId(value);
endRecord(name);
}
void writeHNORefId(NAME name, const RefId& value)
{
if (!value.empty())
writeHNRefId(name, value);
}
void writeHNOCRefId(NAME name, const RefId& value)
{
if (!value.empty())
writeHNCRefId(name, value);
}
template <typename T> template <typename T>
void writeHNT(NAME name, const T& data) void writeHNT(NAME name, const T& data)
{ {
@ -139,7 +164,15 @@ namespace ESM
void writeMaybeFixedSizeString(const std::string& data, std::size_t size); void writeMaybeFixedSizeString(const std::string& data, std::size_t size);
void writeHString(const std::string& data); void writeHString(const std::string& data);
void writeHCString(const std::string& data); void writeHCString(const std::string& data);
void writeMaybeFixedSizeRefId(const RefId& value, std::size_t size);
void writeHRefId(const RefId& value);
void writeHCRefId(const RefId& value);
void writeName(NAME data); void writeName(NAME data);
void write(const char* data, size_t size); void write(const char* data, size_t size);
private: private:

View file

@ -39,7 +39,7 @@ namespace ESM
void Filter::save(ESMWriter& esm, bool isDeleted) const void Filter::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {

View file

@ -8,7 +8,7 @@ namespace ESM
void GlobalScript::load(ESMReader& esm) void GlobalScript::load(ESMReader& esm)
{ {
mId = ESM::RefId::stringRefId(esm.getHNString("NAME")); mId = esm.getHNRefId("NAME");
mLocals.load(esm); mLocals.load(esm);
@ -16,14 +16,14 @@ namespace ESM
esm.getHNOT(mRunning, "RUN_"); esm.getHNOT(mRunning, "RUN_");
mTargetRef = RefNum{}; mTargetRef = RefNum{};
mTargetId = ESM::RefId::stringRefId(esm.getHNOString("TARG")); mTargetId = esm.getHNORefId("TARG");
if (esm.peekNextSub("FRMR")) if (esm.peekNextSub("FRMR"))
mTargetRef.load(esm, true, "FRMR"); mTargetRef.load(esm, true, "FRMR");
} }
void GlobalScript::save(ESMWriter& esm) const void GlobalScript::save(ESMWriter& esm) const
{ {
esm.writeHNString("NAME", mId.getRefIdString()); esm.writeHNRefId("NAME", mId);
mLocals.save(esm); mLocals.save(esm);
@ -32,7 +32,7 @@ namespace ESM
if (!mTargetId.empty()) if (!mTargetId.empty())
{ {
esm.writeHNOString("TARG", mTargetId.getRefIdString()); esm.writeHNORefId("TARG", mTargetId);
if (mTargetRef.isSet()) if (mTargetRef.isSet())
mTargetRef.save(esm, true, "FRMR"); mTargetRef.save(esm, true, "FRMR");
} }

View file

@ -140,7 +140,7 @@ namespace ESM
for (auto it = mLevelledItemMap.begin(); it != mLevelledItemMap.end(); ++it) for (auto it = mLevelledItemMap.begin(); it != mLevelledItemMap.end(); ++it)
{ {
esm.writeHNString("LEVM", it->first.first.getRefIdString()); esm.writeHNRefId("LEVM", it->first.first);
esm.writeHNT("COUN", it->second); esm.writeHNT("COUN", it->second);
esm.writeHNString("LGRP", it->first.second); esm.writeHNString("LGRP", it->first.second);
} }
@ -148,7 +148,7 @@ namespace ESM
for (TEffectMagnitudes::const_iterator it = mPermanentMagicEffectMagnitudes.begin(); for (TEffectMagnitudes::const_iterator it = mPermanentMagicEffectMagnitudes.begin();
it != mPermanentMagicEffectMagnitudes.end(); ++it) it != mPermanentMagicEffectMagnitudes.end(); ++it)
{ {
esm.writeHNString("MAGI", it->first.getRefIdString()); esm.writeHNRefId("MAGI", it->first);
const std::vector<std::pair<float, float>>& params = it->second; const std::vector<std::pair<float, float>>& params = it->second;
for (std::vector<std::pair<float, float>>::const_iterator pIt = params.begin(); pIt != params.end(); ++pIt) for (std::vector<std::pair<float, float>>::const_iterator pIt = params.begin(); pIt != params.end(); ++pIt)

View file

@ -9,8 +9,8 @@ namespace ESM
void JournalEntry::load(ESMReader& esm) void JournalEntry::load(ESMReader& esm)
{ {
esm.getHNOT(mType, "JETY"); esm.getHNOT(mType, "JETY");
mTopic = ESM::RefId::stringRefId(esm.getHNString("YETO")); mTopic = esm.getHNRefId("YETO");
mInfo = ESM::RefId::stringRefId(esm.getHNString("YEIN")); mInfo = esm.getHNRefId("YEIN");
mText = esm.getHNString("TEXT"); mText = esm.getHNString("TEXT");
if (mType == Type_Journal) if (mType == Type_Journal)
@ -26,8 +26,8 @@ namespace ESM
void JournalEntry::save(ESMWriter& esm) const void JournalEntry::save(ESMWriter& esm) const
{ {
esm.writeHNT("JETY", mType); esm.writeHNT("JETY", mType);
esm.writeHNString("YETO", mTopic.getRefIdString()); esm.writeHNRefId("YETO", mTopic);
esm.writeHNString("YEIN", mInfo.getRefIdString()); esm.writeHNRefId("YEIN", mInfo);
esm.writeHNString("TEXT", mText); esm.writeHNString("TEXT", mText);
if (mType == Type_Journal) if (mType == Type_Journal)

View file

@ -44,7 +44,7 @@ namespace ESM
} }
void Activator::save(ESMWriter& esm, bool isDeleted) const void Activator::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -54,7 +54,7 @@ namespace ESM
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
} }
void Activator::blank() void Activator::blank()

View file

@ -59,7 +59,7 @@ namespace ESM
} }
void Potion::save(ESMWriter& esm, bool isDeleted) const void Potion::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -69,7 +69,7 @@ namespace ESM
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("TEXT", mIcon); esm.writeHNOCString("TEXT", mIcon);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNT("ALDT", mData, 12); esm.writeHNT("ALDT", mData, 12);
mEffects.save(esm); mEffects.save(esm);

View file

@ -55,7 +55,7 @@ namespace ESM
void Apparatus::save(ESMWriter& esm, bool isDeleted) const void Apparatus::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -66,7 +66,7 @@ namespace ESM
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNCString("FNAM", mName); esm.writeHNCString("FNAM", mName);
esm.writeHNT("AADT", mData, 16); esm.writeHNT("AADT", mData, 16);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNCString("ITEX", mIcon); esm.writeHNCString("ITEX", mIcon);
} }

View file

@ -10,8 +10,8 @@ namespace ESM
{ {
PartReference pr; PartReference pr;
esm.getHT(pr.mPart); // The INDX byte esm.getHT(pr.mPart); // The INDX byte
pr.mMale = ESM::RefId::stringRefId(esm.getHNOString("BNAM")); pr.mMale = esm.getHNORefId("BNAM");
pr.mFemale = ESM::RefId::stringRefId(esm.getHNOString("CNAM")); pr.mFemale = esm.getHNORefId("CNAM");
mParts.push_back(pr); mParts.push_back(pr);
} }
@ -29,8 +29,8 @@ namespace ESM
for (std::vector<PartReference>::const_iterator it = mParts.begin(); it != mParts.end(); ++it) for (std::vector<PartReference>::const_iterator it = mParts.begin(); it != mParts.end(); ++it)
{ {
esm.writeHNT("INDX", it->mPart); esm.writeHNT("INDX", it->mPart);
esm.writeHNOString("BNAM", it->mMale.getRefIdString()); esm.writeHNORefId("BNAM", it->mMale);
esm.writeHNOString("CNAM", it->mFemale.getRefIdString()); esm.writeHNORefId("CNAM", it->mFemale);
} }
} }
@ -92,7 +92,7 @@ namespace ESM
void Armor::save(ESMWriter& esm, bool isDeleted) const void Armor::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -102,11 +102,11 @@ namespace ESM
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNT("AODT", mData, 24); esm.writeHNT("AODT", mData, 24);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
mParts.save(esm); mParts.save(esm);
esm.writeHNOCString("ENAM", mEnchant.getRefIdString()); esm.writeHNOCRefId("ENAM", mEnchant);
} }
void Armor::blank() void Armor::blank()

View file

@ -49,7 +49,7 @@ namespace ESM
void BodyPart::save(ESMWriter& esm, bool isDeleted) const void BodyPart::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -58,7 +58,7 @@ namespace ESM
} }
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mRace.getRefIdString()); esm.writeHNOCRefId("FNAM", mRace);
esm.writeHNT("BYDT", mData, 4); esm.writeHNT("BYDT", mData, 4);
} }

View file

@ -60,7 +60,7 @@ namespace ESM
} }
void Book::save(ESMWriter& esm, bool isDeleted) const void Book::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -71,10 +71,10 @@ namespace ESM
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNT("BKDT", mData, 20); esm.writeHNT("BKDT", mData, 20);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
esm.writeHNOString("TEXT", mText); esm.writeHNOString("TEXT", mText);
esm.writeHNOCString("ENAM", mEnchant.getRefIdString()); esm.writeHNOCRefId("ENAM", mEnchant);
} }
void Book::blank() void Book::blank()

View file

@ -50,7 +50,7 @@ namespace ESM
void BirthSign::save(ESMWriter& esm, bool isDeleted) const void BirthSign::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {

View file

@ -195,7 +195,7 @@ namespace ESM
} }
if (mData.mFlags & QuasiEx) if (mData.mFlags & QuasiEx)
esm.writeHNOCString("RGNN", mRegion.getRefIdString()); esm.writeHNOCRefId("RGNN", mRegion);
else else
{ {
// Try to avoid saving ambient lighting information when it's unnecessary. // Try to avoid saving ambient lighting information when it's unnecessary.
@ -206,7 +206,7 @@ namespace ESM
} }
else else
{ {
esm.writeHNOCString("RGNN", mRegion.getRefIdString()); esm.writeHNOCRefId("RGNN", mRegion);
if (mMapColor != 0) if (mMapColor != 0)
esm.writeHNT("NAM5", mMapColor); esm.writeHNT("NAM5", mMapColor);
} }

View file

@ -74,7 +74,7 @@ namespace ESM
} }
void Class::save(ESMWriter& esm, bool isDeleted) const void Class::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {

View file

@ -63,7 +63,7 @@ namespace ESM
void Clothing::save(ESMWriter& esm, bool isDeleted) const void Clothing::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -75,12 +75,12 @@ namespace ESM
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNT("CTDT", mData, 12); esm.writeHNT("CTDT", mData, 12);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
mParts.save(esm); mParts.save(esm);
esm.writeHNOCString("ENAM", mEnchant.getRefIdString()); esm.writeHNOCRefId("ENAM", mEnchant);
} }
void Clothing::blank() void Clothing::blank()

View file

@ -12,7 +12,7 @@ namespace ESM
esm.getSubHeader(); esm.getSubHeader();
ContItem ci; ContItem ci;
esm.getT(ci.mCount); esm.getT(ci.mCount);
ci.mItem = ESM::RefId::stringRefId(esm.getMaybeFixedStringSize(32)); ci.mItem = esm.getMaybeFixedRefIdSize(32);
mList.push_back(ci); mList.push_back(ci);
} }
@ -22,7 +22,7 @@ namespace ESM
{ {
esm.startSubRecord("NPCO"); esm.startSubRecord("NPCO");
esm.writeT(it->mCount); esm.writeT(it->mCount);
esm.writeMaybeFixedSizeString(it->mItem.getRefIdString(), 32); esm.writeMaybeFixedSizeRefId(it->mItem, 32);
esm.endRecord("NPCO"); esm.endRecord("NPCO");
} }
} }
@ -90,7 +90,7 @@ namespace ESM
void Container::save(ESMWriter& esm, bool isDeleted) const void Container::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -103,7 +103,7 @@ namespace ESM
esm.writeHNT("CNDT", mWeight, 4); esm.writeHNT("CNDT", mWeight, 4);
esm.writeHNT("FLAG", mFlags, 4); esm.writeHNT("FLAG", mFlags, 4);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
mInventory.save(esm); mInventory.save(esm);
} }

View file

@ -108,7 +108,7 @@ namespace ESM
void Creature::save(ESMWriter& esm, bool isDeleted) const void Creature::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -117,9 +117,9 @@ namespace ESM
} }
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("CNAM", mOriginal.getRefIdString()); esm.writeHNOCRefId("CNAM", mOriginal);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNT("NPDT", mData, 96); esm.writeHNT("NPDT", mData, 96);
esm.writeHNT("FLAG", ((mBloodType << 10) + mFlags)); esm.writeHNT("FLAG", ((mBloodType << 10) + mFlags));
if (mScale != 1.0) if (mScale != 1.0)

View file

@ -14,7 +14,7 @@ namespace ESM
void Dialogue::loadId(ESMReader& esm) void Dialogue::loadId(ESMReader& esm)
{ {
mId = ESM::RefId::stringRefId(esm.getHNString("NAME")); mId = esm.getHNRefId("NAME");
} }
void Dialogue::loadData(ESMReader& esm, bool& isDeleted) void Dialogue::loadData(ESMReader& esm, bool& isDeleted)
@ -54,7 +54,7 @@ namespace ESM
void Dialogue::save(ESMWriter& esm, bool isDeleted) const void Dialogue::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
esm.writeHNString("DELE", "", 3); esm.writeHNString("DELE", "", 3);

View file

@ -51,7 +51,7 @@ namespace ESM
void Door::save(ESMWriter& esm, bool isDeleted) const void Door::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -61,9 +61,9 @@ namespace ESM
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNOCString("SNAM", mOpenSound.getRefIdString()); esm.writeHNOCRefId("SNAM", mOpenSound);
esm.writeHNOCString("ANAM", mCloseSound.getRefIdString()); esm.writeHNOCRefId("ANAM", mCloseSound);
} }
void Door::blank() void Door::blank()

View file

@ -47,7 +47,7 @@ namespace ESM
void Enchantment::save(ESMWriter& esm, bool isDeleted) const void Enchantment::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {

View file

@ -84,7 +84,7 @@ namespace ESM
void Faction::save(ESMWriter& esm, bool isDeleted) const void Faction::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -106,7 +106,7 @@ namespace ESM
for (auto it = mReactions.begin(); it != mReactions.end(); ++it) for (auto it = mReactions.begin(); it != mReactions.end(); ++it)
{ {
esm.writeHNString("ANAM", it->first.getRefIdString()); esm.writeHNRefId("ANAM", it->first);
esm.writeHNT("INTV", it->second); esm.writeHNT("INTV", it->second);
} }
} }

View file

@ -10,7 +10,7 @@ namespace ESM
isDeleted = false; isDeleted = false;
mRecordFlags = esm.getRecordFlags(); mRecordFlags = esm.getRecordFlags();
mId = ESM::RefId::stringRefId(esm.getHNString("NAME")); mId = esm.getHNRefId("NAME");
if (esm.isNextSub("DELE")) if (esm.isNextSub("DELE"))
{ {
@ -25,7 +25,7 @@ namespace ESM
void Global::save(ESMWriter& esm, bool isDeleted) const void Global::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {

View file

@ -10,13 +10,13 @@ namespace ESM
isDeleted = false; // GameSetting record can't be deleted now (may be changed in the future) isDeleted = false; // GameSetting record can't be deleted now (may be changed in the future)
mRecordFlags = esm.getRecordFlags(); mRecordFlags = esm.getRecordFlags();
mId = ESM::RefId::stringRefId(esm.getHNString("NAME")); mId = esm.getHNRefId("NAME");
mValue.read(esm, Variant::Format_Gmst); mValue.read(esm, Variant::Format_Gmst);
} }
void GameSetting::save(ESMWriter& esm, bool /*isDeleted*/) const void GameSetting::save(ESMWriter& esm, bool /*isDeleted*/) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
mValue.write(esm, Variant::Format_Gmst); mValue.write(esm, Variant::Format_Gmst);
} }

View file

@ -7,15 +7,15 @@ namespace ESM
{ {
void DialInfo::load(ESMReader& esm, bool& isDeleted) void DialInfo::load(ESMReader& esm, bool& isDeleted)
{ {
mId = ESM::RefId::stringRefId(esm.getHNString("INAM")); mId = esm.getHNRefId("INAM");
isDeleted = false; isDeleted = false;
mQuestStatus = QS_None; mQuestStatus = QS_None;
mFactionLess = false; mFactionLess = false;
mPrev = ESM::RefId::stringRefId(esm.getHNString("PNAM")); mPrev = esm.getHNRefId("PNAM");
mNext = ESM::RefId::stringRefId(esm.getHNString("NNAM")); mNext = esm.getHNRefId("NNAM");
while (esm.hasMoreSubs()) while (esm.hasMoreSubs())
{ {
@ -37,7 +37,7 @@ namespace ESM
case fourCC("FNAM"): case fourCC("FNAM"):
{ {
mFaction = esm.getRefId(); mFaction = esm.getRefId();
if (mFaction.getRefIdString() == "FFFF") if (mFaction == "FFFF")
{ {
mFactionLess = true; mFactionLess = true;
} }
@ -91,9 +91,9 @@ namespace ESM
void DialInfo::save(ESMWriter& esm, bool isDeleted) const void DialInfo::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("INAM", mId.getRefIdString()); esm.writeHNCRefId("INAM", mId);
esm.writeHNCString("PNAM", mPrev.getRefIdString()); esm.writeHNCRefId("PNAM", mPrev);
esm.writeHNCString("NNAM", mNext.getRefIdString()); esm.writeHNCRefId("NNAM", mNext);
if (isDeleted) if (isDeleted)
{ {
@ -102,12 +102,12 @@ namespace ESM
} }
esm.writeHNT("DATA", mData, 12); esm.writeHNT("DATA", mData, 12);
esm.writeHNOCString("ONAM", mActor.getRefIdString()); esm.writeHNOCRefId("ONAM", mActor);
esm.writeHNOCString("RNAM", mRace.getRefIdString()); esm.writeHNOCRefId("RNAM", mRace);
esm.writeHNOCString("CNAM", mClass.getRefIdString()); esm.writeHNOCRefId("CNAM", mClass);
esm.writeHNOCString("FNAM", mFaction.getRefIdString()); esm.writeHNOCRefId("FNAM", mFaction);
esm.writeHNOCString("ANAM", mCell.getRefIdString()); esm.writeHNOCRefId("ANAM", mCell);
esm.writeHNOCString("DNAM", mPcFaction.getRefIdString()); esm.writeHNOCRefId("DNAM", mPcFaction);
esm.writeHNOCString("SNAM", mSound); esm.writeHNOCString("SNAM", mSound);
esm.writeHNOString("NAME", mResponse); esm.writeHNOString("NAME", mResponse);

View file

@ -72,7 +72,7 @@ namespace ESM
void Ingredient::save(ESMWriter& esm, bool isDeleted) const void Ingredient::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -83,7 +83,7 @@ namespace ESM
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNT("IRDT", mData, 56); esm.writeHNT("IRDT", mData, 56);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
} }

View file

@ -43,7 +43,7 @@ namespace ESM
for (size_t i = 0; i < mList.size(); i++) for (size_t i = 0; i < mList.size(); i++)
{ {
LevelItem& li = mList[i]; LevelItem& li = mList[i];
li.mId = ESM::RefId::stringRefId(esm.getHNString(recName)); li.mId = esm.getHNRefId(recName);
esm.getHNT(li.mLevel, "INTV"); esm.getHNT(li.mLevel, "INTV");
} }
@ -77,7 +77,7 @@ namespace ESM
void LevelledListBase::save(ESMWriter& esm, NAME recName, bool isDeleted) const void LevelledListBase::save(ESMWriter& esm, NAME recName, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -91,7 +91,7 @@ namespace ESM
for (std::vector<LevelItem>::const_iterator it = mList.begin(); it != mList.end(); ++it) for (std::vector<LevelItem>::const_iterator it = mList.begin(); it != mList.end(); ++it)
{ {
esm.writeHNCString(recName, it->mId.getRefIdString()); esm.writeHNCRefId(recName, it->mId);
esm.writeHNT("INTV", it->mLevel); esm.writeHNT("INTV", it->mLevel);
} }
} }

View file

@ -57,7 +57,7 @@ namespace ESM
} }
void Light::save(ESMWriter& esm, bool isDeleted) const void Light::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -69,8 +69,8 @@ namespace ESM
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
esm.writeHNT("LHDT", mData, 24); esm.writeHNT("LHDT", mData, 24);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNOCString("SNAM", mSound.getRefIdString()); esm.writeHNOCRefId("SNAM", mSound);
} }
void Light::blank() void Light::blank()

View file

@ -55,7 +55,7 @@ namespace ESM
void Lockpick::save(ESMWriter& esm, bool isDeleted) const void Lockpick::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -67,7 +67,7 @@ namespace ESM
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNT("LKDT", mData, 16); esm.writeHNT("LKDT", mData, 16);
esm.writeHNOString("SCRI", mScript.getRefIdString()); esm.writeHNORefId("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
} }

View file

@ -45,7 +45,7 @@ namespace ESM
} }
void LandTexture::save(ESMWriter& esm, bool isDeleted) const void LandTexture::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
esm.writeHNT("INTV", mIndex); esm.writeHNT("INTV", mIndex);
esm.writeHNCString("DATA", mTexture); esm.writeHNCString("DATA", mTexture);

View file

@ -250,15 +250,15 @@ namespace ESM
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
esm.writeHNOCString("PTEX", mParticle); esm.writeHNOCString("PTEX", mParticle);
esm.writeHNOCString("BSND", mBoltSound.getRefIdString()); esm.writeHNOCRefId("BSND", mBoltSound);
esm.writeHNOCString("CSND", mCastSound.getRefIdString()); esm.writeHNOCRefId("CSND", mCastSound);
esm.writeHNOCString("HSND", mHitSound.getRefIdString()); esm.writeHNOCRefId("HSND", mHitSound);
esm.writeHNOCString("ASND", mAreaSound.getRefIdString()); esm.writeHNOCRefId("ASND", mAreaSound);
esm.writeHNOCString("CVFX", mCasting.getRefIdString()); esm.writeHNOCRefId("CVFX", mCasting);
esm.writeHNOCString("BVFX", mBolt.getRefIdString()); esm.writeHNOCRefId("BVFX", mBolt);
esm.writeHNOCString("HVFX", mHit.getRefIdString()); esm.writeHNOCRefId("HVFX", mHit);
esm.writeHNOCString("AVFX", mArea.getRefIdString()); esm.writeHNOCRefId("AVFX", mArea);
esm.writeHNOString("DESC", mDescription); esm.writeHNOString("DESC", mDescription);
} }

View file

@ -55,7 +55,7 @@ namespace ESM
void Miscellaneous::save(ESMWriter& esm, bool isDeleted) const void Miscellaneous::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -66,7 +66,7 @@ namespace ESM
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNT("MCDT", mData, 12); esm.writeHNT("MCDT", mData, 12);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
} }

View file

@ -127,7 +127,7 @@ namespace ESM
} }
void NPC::save(ESMWriter& esm, bool isDeleted) const void NPC::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -137,12 +137,12 @@ namespace ESM
esm.writeHNOCString("MODL", mModel); esm.writeHNOCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNCString("RNAM", mRace.getRefIdString()); esm.writeHNCRefId("RNAM", mRace);
esm.writeHNCString("CNAM", mClass.getRefIdString()); esm.writeHNCRefId("CNAM", mClass);
esm.writeHNCString("ANAM", mFaction.getRefIdString()); esm.writeHNCRefId("ANAM", mFaction);
esm.writeHNCString("BNAM", mHead.getRefIdString()); esm.writeHNCRefId("BNAM", mHead);
esm.writeHNCString("KNAM", mHair.getRefIdString()); esm.writeHNCRefId("KNAM", mHair);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
if (mNpdtType == NPC_DEFAULT) if (mNpdtType == NPC_DEFAULT)
{ {

View file

@ -154,7 +154,7 @@ namespace ESM
} }
// Save // Save
esm.writeHNCString("NAME", mCell.getRefIdString()); esm.writeHNCRefId("NAME", mCell);
esm.writeHNT("DATA", mData, 12); esm.writeHNT("DATA", mData, 12);
if (isDeleted) if (isDeleted)

View file

@ -55,7 +55,7 @@ namespace ESM
void Probe::save(ESMWriter& esm, bool isDeleted) const void Probe::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -67,7 +67,7 @@ namespace ESM
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNT("PBDT", mData, 16); esm.writeHNT("PBDT", mData, 16);
esm.writeHNOString("SCRI", mScript.getRefIdString()); esm.writeHNORefId("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
} }

View file

@ -62,7 +62,7 @@ namespace ESM
} }
void Race::save(ESMWriter& esm, bool isDeleted) const void Race::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {

View file

@ -53,7 +53,7 @@ namespace ESM
{ {
esm.getSubHeader(); esm.getSubHeader();
SoundRef sr; SoundRef sr;
sr.mSound = ESM::RefId::stringRefId(esm.getMaybeFixedStringSize(32)); sr.mSound = esm.getMaybeFixedRefIdSize(32);
esm.getT(sr.mChance); esm.getT(sr.mChance);
mSoundList.push_back(sr); mSoundList.push_back(sr);
break; break;
@ -74,7 +74,7 @@ namespace ESM
void Region::save(ESMWriter& esm, bool isDeleted) const void Region::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -89,13 +89,13 @@ namespace ESM
else else
esm.writeHNT("WEAT", mData); esm.writeHNT("WEAT", mData);
esm.writeHNOCString("BNAM", mSleepList.getRefIdString()); esm.writeHNOCRefId("BNAM", mSleepList);
esm.writeHNT("CNAM", mMapColor); esm.writeHNT("CNAM", mMapColor);
for (std::vector<SoundRef>::const_iterator it = mSoundList.begin(); it != mSoundList.end(); ++it) for (std::vector<SoundRef>::const_iterator it = mSoundList.begin(); it != mSoundList.end(); ++it)
{ {
esm.startSubRecord("SNAM"); esm.startSubRecord("SNAM");
esm.writeMaybeFixedSizeString(it->mSound.getRefIdString(), 32); esm.writeMaybeFixedSizeRefId(it->mSound, 32);
esm.writeT(it->mChance); esm.writeT(it->mChance);
esm.endRecord("SNAM"); esm.endRecord("SNAM");
} }

View file

@ -55,7 +55,7 @@ namespace ESM
void Repair::save(ESMWriter& esm, bool isDeleted) const void Repair::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -67,7 +67,7 @@ namespace ESM
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNT("RIDT", mData, 16); esm.writeHNT("RIDT", mData, 16);
esm.writeHNOString("SCRI", mScript.getRefIdString()); esm.writeHNORefId("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
} }

View file

@ -98,7 +98,7 @@ namespace ESM
case fourCC("SCHD"): case fourCC("SCHD"):
{ {
esm.getSubHeader(); esm.getSubHeader();
mId = ESM::RefId::stringRefId(esm.getMaybeFixedStringSize(32)); mId = esm.getMaybeFixedRefIdSize(32);
esm.getT(mData); esm.getT(mData);
hasHeader = true; hasHeader = true;
@ -152,7 +152,7 @@ namespace ESM
varNameString.append(*it); varNameString.append(*it);
esm.startSubRecord("SCHD"); esm.startSubRecord("SCHD");
esm.writeMaybeFixedSizeString(mId.getRefIdString(), 32); esm.writeMaybeFixedSizeRefId(mId, 32);
esm.writeT(mData, 20); esm.writeT(mData, 20);
esm.endRecord("SCHD"); esm.endRecord("SCHD");

View file

@ -49,7 +49,7 @@ namespace ESM
} }
void SoundGenerator::save(ESMWriter& esm, bool isDeleted) const void SoundGenerator::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -58,8 +58,8 @@ namespace ESM
} }
esm.writeHNT("DATA", mType, 4); esm.writeHNT("DATA", mType, 4);
esm.writeHNOCString("CNAM", mCreature.getRefIdString()); esm.writeHNOCRefId("CNAM", mCreature);
esm.writeHNOCString("SNAM", mSound.getRefIdString()); esm.writeHNOCRefId("SNAM", mSound);
} }
void SoundGenerator::blank() void SoundGenerator::blank()

View file

@ -46,7 +46,7 @@ namespace ESM
void Sound::save(ESMWriter& esm, bool isDeleted) const void Sound::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {

View file

@ -53,7 +53,7 @@ namespace ESM
void Spell::save(ESMWriter& esm, bool isDeleted) const void Spell::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {

View file

@ -42,7 +42,7 @@ namespace ESM
} }
void StartScript::save(ESMWriter& esm, bool isDeleted) const void StartScript::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
esm.writeHNString("DELE", "", 3); esm.writeHNString("DELE", "", 3);

View file

@ -40,7 +40,7 @@ namespace ESM
} }
void Static::save(ESMWriter& esm, bool isDeleted) const void Static::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
esm.writeHNString("DELE", "", 3); esm.writeHNString("DELE", "", 3);

View file

@ -30,8 +30,8 @@ namespace ESM
esm.getSubHeader(); esm.getSubHeader();
esm.getT(mData.version); esm.getT(mData.version);
esm.getT(mData.type); esm.getT(mData.type);
mData.author.assign(esm.getMaybeFixedStringSize(32)); mData.author = esm.getMaybeFixedStringSize(32);
mData.desc.assign(esm.getMaybeFixedStringSize(256)); mData.desc = esm.getMaybeFixedStringSize(256);
esm.getT(mData.records); esm.getT(mData.records);
} }

View file

@ -57,7 +57,7 @@ namespace ESM
} }
void Weapon::save(ESMWriter& esm, bool isDeleted) const void Weapon::save(ESMWriter& esm, bool isDeleted) const
{ {
esm.writeHNCString("NAME", mId.getRefIdString()); esm.writeHNCRefId("NAME", mId);
if (isDeleted) if (isDeleted)
{ {
@ -68,9 +68,9 @@ namespace ESM
esm.writeHNCString("MODL", mModel); esm.writeHNCString("MODL", mModel);
esm.writeHNOCString("FNAM", mName); esm.writeHNOCString("FNAM", mName);
esm.writeHNT("WPDT", mData, 32); esm.writeHNT("WPDT", mData, 32);
esm.writeHNOCString("SCRI", mScript.getRefIdString()); esm.writeHNOCRefId("SCRI", mScript);
esm.writeHNOCString("ITEX", mIcon); esm.writeHNOCString("ITEX", mIcon);
esm.writeHNOCString("ENAM", mEnchant.getRefIdString()); esm.writeHNOCRefId("ENAM", mEnchant);
} }
void Weapon::blank() void Weapon::blank()

View file

@ -136,7 +136,7 @@ namespace ESM
{ {
for (auto iter(mFactions.begin()); iter != mFactions.end(); ++iter) for (auto iter(mFactions.begin()); iter != mFactions.end(); ++iter)
{ {
esm.writeHNString("FACT", iter->first.getRefIdString()); esm.writeHNRefId("FACT", iter->first);
if (iter->second.mExpelled) if (iter->second.mExpelled)
{ {
@ -188,7 +188,7 @@ namespace ESM
esm.writeHNT("SPEC", mSpecIncreases); esm.writeHNT("SPEC", mSpecIncreases);
for (auto iter(mUsedIds.begin()); iter != mUsedIds.end(); ++iter) for (auto iter(mUsedIds.begin()); iter != mUsedIds.end(); ++iter)
esm.writeHNString("USED", iter->getRefIdString()); esm.writeHNRefId("USED", *iter);
if (mTimeToStartDrowning) if (mTimeToStartDrowning)
esm.writeHNT("DRTI", mTimeToStartDrowning); esm.writeHNT("DRTI", mTimeToStartDrowning);

View file

@ -28,7 +28,7 @@ namespace ESM
if (esm.isNextSub("AMOV")) if (esm.isNextSub("AMOV"))
esm.skipHSub(); esm.skipHSub();
mBirthsign = ESM::RefId::stringRefId(esm.getHNString("SIGN")); mBirthsign = esm.getHNRefId("SIGN");
mCurrentCrimeId = -1; mCurrentCrimeId = -1;
esm.getHNOT(mCurrentCrimeId, "CURD"); esm.getHNOT(mCurrentCrimeId, "CURD");
@ -38,8 +38,8 @@ namespace ESM
bool checkPrevItems = true; bool checkPrevItems = true;
while (checkPrevItems) while (checkPrevItems)
{ {
ESM::RefId boundItemId = ESM::RefId::stringRefId(esm.getHNOString("BOUN")); ESM::RefId boundItemId = esm.getHNORefId("BOUN");
ESM::RefId prevItemId = ESM::RefId::stringRefId(esm.getHNOString("PREV")); ESM::RefId prevItemId = esm.getHNORefId("PREV");
if (!boundItemId.empty()) if (!boundItemId.empty())
mPreviousItems[boundItemId] = prevItemId; mPreviousItems[boundItemId] = prevItemId;
@ -102,15 +102,15 @@ namespace ESM
mMarkedCell.save(esm); mMarkedCell.save(esm);
} }
esm.writeHNString("SIGN", mBirthsign.getRefIdString()); esm.writeHNRefId("SIGN", mBirthsign);
esm.writeHNT("CURD", mCurrentCrimeId); esm.writeHNT("CURD", mCurrentCrimeId);
esm.writeHNT("PAYD", mPaidCrimeId); esm.writeHNT("PAYD", mPaidCrimeId);
for (PreviousItems::const_iterator it = mPreviousItems.begin(); it != mPreviousItems.end(); ++it) for (PreviousItems::const_iterator it = mPreviousItems.begin(); it != mPreviousItems.end(); ++it)
{ {
esm.writeHNString("BOUN", it->first.getRefIdString()); esm.writeHNRefId("BOUN", it->first);
esm.writeHNString("PREV", it->second.getRefIdString()); esm.writeHNRefId("PREV", it->second);
} }
esm.writeHNT("WWAT", mSaveAttributes); esm.writeHNT("WWAT", mSaveAttributes);

View file

@ -8,7 +8,7 @@ namespace ESM
void BaseProjectileState::save(ESMWriter& esm) const void BaseProjectileState::save(ESMWriter& esm) const
{ {
esm.writeHNString("ID__", mId.getRefIdString()); esm.writeHNRefId("ID__", mId);
esm.writeHNT("VEC3", mPosition); esm.writeHNT("VEC3", mPosition);
esm.writeHNT("QUAT", mOrientation); esm.writeHNT("QUAT", mOrientation);
esm.writeHNT("ACTO", mActorId); esm.writeHNT("ACTO", mActorId);
@ -16,7 +16,7 @@ namespace ESM
void BaseProjectileState::load(ESMReader& esm) void BaseProjectileState::load(ESMReader& esm)
{ {
mId = ESM::RefId::stringRefId(esm.getHNString("ID__")); mId = esm.getHNRefId("ID__");
esm.getHNT(mPosition, "VEC3"); esm.getHNT(mPosition, "VEC3");
esm.getHNT(mOrientation, "QUAT"); esm.getHNT(mOrientation, "QUAT");
esm.getHNT(mActorId, "ACTO"); esm.getHNT(mActorId, "ACTO");
@ -26,7 +26,7 @@ namespace ESM
{ {
BaseProjectileState::save(esm); BaseProjectileState::save(esm);
esm.writeHNString("SPEL", mSpellId.getRefIdString()); esm.writeHNRefId("SPEL", mSpellId);
esm.writeHNT("SPED", mSpeed); esm.writeHNT("SPED", mSpeed);
esm.writeHNT("SLOT", mSlot); esm.writeHNT("SLOT", mSlot);
} }
@ -35,7 +35,7 @@ namespace ESM
{ {
BaseProjectileState::load(esm); BaseProjectileState::load(esm);
mSpellId = ESM::RefId::stringRefId(esm.getHNString("SPEL")); mSpellId = esm.getHNRefId("SPEL");
if (esm.isNextSub("SRCN")) // for backwards compatibility if (esm.isNextSub("SRCN")) // for backwards compatibility
esm.skipHSub(); esm.skipHSub();
EffectList().load(esm); // for backwards compatibility EffectList().load(esm); // for backwards compatibility
@ -54,7 +54,7 @@ namespace ESM
{ {
BaseProjectileState::save(esm); BaseProjectileState::save(esm);
esm.writeHNString("BOW_", mBowId.getRefIdString()); esm.writeHNRefId("BOW_", mBowId);
esm.writeHNT("VEL_", mVelocity); esm.writeHNT("VEL_", mVelocity);
esm.writeHNT("STR_", mAttackStrength); esm.writeHNT("STR_", mAttackStrength);
} }
@ -63,7 +63,7 @@ namespace ESM
{ {
BaseProjectileState::load(esm); BaseProjectileState::load(esm);
mBowId = ESM::RefId::stringRefId(esm.getHNString("BOW_")); mBowId = esm.getHNRefId("BOW_");
esm.getHNT(mVelocity, "VEL_"); esm.getHNT(mVelocity, "VEL_");
mAttackStrength = 1.f; mAttackStrength = 1.f;

View file

@ -8,14 +8,14 @@ namespace ESM
void QuestState::load(ESMReader& esm) void QuestState::load(ESMReader& esm)
{ {
mTopic = ESM::RefId::stringRefId(esm.getHNString("YETO")); mTopic = esm.getHNRefId("YETO");
esm.getHNOT(mState, "QSTA"); esm.getHNOT(mState, "QSTA");
esm.getHNOT(mFinished, "QFIN"); esm.getHNOT(mFinished, "QFIN");
} }
void QuestState::save(ESMWriter& esm) const void QuestState::save(ESMWriter& esm) const
{ {
esm.writeHNString("YETO", mTopic.getRefIdString()); esm.writeHNRefId("YETO", mTopic);
esm.writeHNT("QSTA", mState); esm.writeHNT("QSTA", mState);
esm.writeHNT("QFIN", mFinished); esm.writeHNT("QFIN", mFinished);
} }

View file

@ -34,7 +34,7 @@ namespace ESM
for (std::vector<QuickKey>::const_iterator it = mKeys.begin(); it != mKeys.end(); ++it) for (std::vector<QuickKey>::const_iterator it = mKeys.begin(); it != mKeys.end(); ++it)
{ {
esm.writeHNT("TYPE", it->mType); esm.writeHNT("TYPE", it->mType);
esm.writeHNString("ID__", it->mId.getRefIdString()); esm.writeHNRefId("ID__", it->mId);
} }
} }

View file

@ -10,10 +10,10 @@ namespace ESM
mPlayerName = esm.getHNString("PLNA"); mPlayerName = esm.getHNString("PLNA");
esm.getHNOT(mPlayerLevel, "PLLE"); esm.getHNOT(mPlayerLevel, "PLLE");
mPlayerClassId = ESM::RefId::stringRefId(esm.getHNOString("PLCL")); mPlayerClassId = esm.getHNORefId("PLCL");
mPlayerClassName = esm.getHNOString("PLCN"); mPlayerClassName = esm.getHNOString("PLCN");
mPlayerCell = ESM::RefId::stringRefId(esm.getHNString("PLCE")); mPlayerCell = esm.getHNRefId("PLCE");
esm.getHNTSized<16>(mInGameTime, "TSTM"); esm.getHNTSized<16>(mInGameTime, "TSTM");
esm.getHNT(mTimePlayed, "TIME"); esm.getHNT(mTimePlayed, "TIME");
mDescription = esm.getHNString("DESC"); mDescription = esm.getHNString("DESC");
@ -33,11 +33,11 @@ namespace ESM
esm.writeHNT("PLLE", mPlayerLevel); esm.writeHNT("PLLE", mPlayerLevel);
if (!mPlayerClassId.empty()) if (!mPlayerClassId.empty())
esm.writeHNString("PLCL", mPlayerClassId.getRefIdString()); esm.writeHNRefId("PLCL", mPlayerClassId);
else else
esm.writeHNString("PLCN", mPlayerClassName); esm.writeHNString("PLCN", mPlayerClassName);
esm.writeHNString("PLCE", mPlayerCell.getRefIdString()); esm.writeHNRefId("PLCE", mPlayerCell);
esm.writeHNT("TSTM", mInGameTime, 16); esm.writeHNT("TSTM", mInGameTime, 16);
esm.writeHNT("TIME", mTimePlayed); esm.writeHNT("TIME", mTimePlayed);
esm.writeHNString("DESC", mDescription); esm.writeHNString("DESC", mDescription);

View file

@ -17,7 +17,7 @@ namespace ESM
{ {
for (auto it = mList.begin(); it != mList.end(); ++it) for (auto it = mList.begin(); it != mList.end(); ++it)
{ {
esm.writeHNString("NPCS", it->getRefIdString(), 32); esm.writeHNRefId("NPCS", *it, 32);
} }
} }

View file

@ -93,22 +93,22 @@ namespace ESM
mUsedPowers[id] = time; mUsedPowers[id] = time;
} }
mSelectedSpell = ESM::RefId::stringRefId(esm.getHNOString("SLCT")); mSelectedSpell = esm.getHNORefId("SLCT");
} }
void SpellState::save(ESMWriter& esm) const void SpellState::save(ESMWriter& esm) const
{ {
for (const ESM::RefId& spell : mSpells) for (const ESM::RefId& spell : mSpells)
esm.writeHNString("SPEL", spell.getRefIdString()); esm.writeHNRefId("SPEL", spell);
for (auto it = mUsedPowers.begin(); it != mUsedPowers.end(); ++it) for (auto it = mUsedPowers.begin(); it != mUsedPowers.end(); ++it)
{ {
esm.writeHNString("USED", it->first.getRefIdString()); esm.writeHNRefId("USED", it->first);
esm.writeHNT("TIME", it->second); esm.writeHNT("TIME", it->second);
} }
if (!mSelectedSpell.empty()) if (!mSelectedSpell.empty())
esm.writeHNString("SLCT", mSelectedSpell.getRefIdString()); esm.writeHNRefId("SLCT", mSelectedSpell);
} }
} }

View file

@ -10,13 +10,13 @@ namespace ESM
{ {
for (StolenItemsMap::const_iterator it = mStolenItems.begin(); it != mStolenItems.end(); ++it) for (StolenItemsMap::const_iterator it = mStolenItems.begin(); it != mStolenItems.end(); ++it)
{ {
esm.writeHNString("NAME", it->first.getRefIdString()); esm.writeHNRefId("NAME", it->first);
for (auto ownerIt = it->second.begin(); ownerIt != it->second.end(); ++ownerIt) for (auto ownerIt = it->second.begin(); ownerIt != it->second.end(); ++ownerIt)
{ {
if (ownerIt->first.second) if (ownerIt->first.second)
esm.writeHNString("FNAM", ownerIt->first.first.getRefIdString()); esm.writeHNRefId("FNAM", ownerIt->first.first);
else else
esm.writeHNString("ONAM", ownerIt->first.first.getRefIdString()); esm.writeHNRefId("ONAM", ownerIt->first.first);
esm.writeHNT("COUN", ownerIt->second); esm.writeHNT("COUN", ownerIt->second);
} }
} }

View file

@ -25,7 +25,7 @@ namespace ESM
{ {
void WeatherState::load(ESMReader& esm) void WeatherState::load(ESMReader& esm)
{ {
mCurrentRegion = ESM::RefId::stringRefId(esm.getHNString(currentRegionRecord)); mCurrentRegion = esm.getHNRefId(currentRegionRecord);
esm.getHNT(mTimePassed, timePassedRecord); esm.getHNT(mTimePassed, timePassedRecord);
esm.getHNT(mFastForward, fastForwardRecord); esm.getHNT(mFastForward, fastForwardRecord);
esm.getHNT(mWeatherUpdateTime, weatherUpdateTimeRecord); esm.getHNT(mWeatherUpdateTime, weatherUpdateTimeRecord);
@ -52,7 +52,7 @@ namespace ESM
void WeatherState::save(ESMWriter& esm) const void WeatherState::save(ESMWriter& esm) const
{ {
esm.writeHNCString(currentRegionRecord, mCurrentRegion.getRefIdString()); esm.writeHNCRefId(currentRegionRecord, mCurrentRegion);
esm.writeHNT(timePassedRecord, mTimePassed); esm.writeHNT(timePassedRecord, mTimePassed);
esm.writeHNT(fastForwardRecord, mFastForward); esm.writeHNT(fastForwardRecord, mFastForward);
esm.writeHNT(weatherUpdateTimeRecord, mWeatherUpdateTime); esm.writeHNT(weatherUpdateTimeRecord, mWeatherUpdateTime);
@ -64,7 +64,7 @@ namespace ESM
auto it = mRegions.begin(); auto it = mRegions.begin();
for (; it != mRegions.end(); ++it) for (; it != mRegions.end(); ++it)
{ {
esm.writeHNCString(regionNameRecord, it->first.getRefIdString().c_str()); esm.writeHNCRefId(regionNameRecord, it->first);
esm.writeHNT(regionWeatherRecord, it->second.mWeather); esm.writeHNT(regionWeatherRecord, it->second.mWeather);
for (size_t i = 0; i < it->second.mChances.size(); ++i) for (size_t i = 0; i < it->second.mChances.size(); ++i)
{ {