1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-29 17:15:34 +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:
void read(ESM::ESMReader& esm) override
{
auto id = ESM::RefId::stringRefId(esm.getHNString("NAME"));
auto id = esm.getHNRefId("NAME");
NPCC npcc;
npcc.load(esm);
if (id == "PlayerSaveGame")
@ -308,7 +308,7 @@ namespace ESSImport
{
void read(ESM::ESMReader& esm) override
{
auto id = ESM::RefId::stringRefId(esm.getHNString("NAME"));
auto id = esm.getHNRefId("NAME");
CNTC cntc;
cntc.load(esm);
mContext->mContainerChanges.insert(std::make_pair(std::make_pair(cntc.mIndex, id), cntc));
@ -320,7 +320,7 @@ namespace ESSImport
public:
void read(ESM::ESMReader& esm) override
{
auto id = ESM::RefId::stringRefId(esm.getHNString("NAME"));
auto id = esm.getHNRefId("NAME");
CREC crec;
crec.load(esm);
mContext->mCreatureChanges.insert(std::make_pair(std::make_pair(crec.mIndex, id), crec));

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -37,16 +37,16 @@ namespace ESM
{
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)
{
esm.writeHNString("FACT", iter->first.getRefIdString());
esm.writeHNRefId("FACT", iter->first);
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);
}
}

View file

@ -131,10 +131,10 @@ namespace ESM
return ESM::RefId::sEmpty;
}
void ESMReader::skipHNOString(NAME name)
void ESMReader::skipHNORefId(NAME name)
{
if (isNextSub(name))
skipHString();
skipHRefId();
}
std::string ESMReader::getHNString(NAME name)
@ -143,6 +143,12 @@ namespace ESM
return getHString();
}
RefId ESMReader::getHNRefId(NAME name)
{
getSubNameIs(name);
return getRefId();
}
std::string ESMReader::getHString()
{
return std::string(getHStringView());
@ -194,6 +200,11 @@ namespace ESM
skip(mCtx.leftSub);
}
void ESMReader::skipHRefId()
{
skipHString();
}
void ESMReader::getHExact(void* p, int size)
{
getSubHeader();
@ -390,6 +401,11 @@ namespace ESM
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)
{
std::stringstream ss;

View file

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

View file

@ -167,6 +167,16 @@ namespace ESM
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)
{
std::string string;
@ -210,6 +220,21 @@ namespace ESM
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)
{
write(name.mData, NAME::sCapacity);

View file

@ -6,6 +6,8 @@
#include <type_traits>
#include "components/esm/esmcommon.hpp"
#include "components/esm/refid.hpp"
#include "loadtes3.hpp"
namespace ToUTF8
@ -76,6 +78,29 @@ namespace ESM
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>
void writeHNT(NAME name, const T& data)
{
@ -139,7 +164,15 @@ namespace ESM
void writeMaybeFixedSizeString(const std::string& data, std::size_t size);
void writeHString(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 write(const char* data, size_t size);
private:

View file

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

View file

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

View file

@ -140,7 +140,7 @@ namespace ESM
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.writeHNString("LGRP", it->first.second);
}
@ -148,7 +148,7 @@ namespace ESM
for (TEffectMagnitudes::const_iterator it = mPermanentMagicEffectMagnitudes.begin();
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;
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)
{
esm.getHNOT(mType, "JETY");
mTopic = ESM::RefId::stringRefId(esm.getHNString("YETO"));
mInfo = ESM::RefId::stringRefId(esm.getHNString("YEIN"));
mTopic = esm.getHNRefId("YETO");
mInfo = esm.getHNRefId("YEIN");
mText = esm.getHNString("TEXT");
if (mType == Type_Journal)
@ -26,8 +26,8 @@ namespace ESM
void JournalEntry::save(ESMWriter& esm) const
{
esm.writeHNT("JETY", mType);
esm.writeHNString("YETO", mTopic.getRefIdString());
esm.writeHNString("YEIN", mInfo.getRefIdString());
esm.writeHNRefId("YETO", mTopic);
esm.writeHNRefId("YEIN", mInfo);
esm.writeHNString("TEXT", mText);
if (mType == Type_Journal)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -84,7 +84,7 @@ namespace ESM
void Faction::save(ESMWriter& esm, bool isDeleted) const
{
esm.writeHNCString("NAME", mId.getRefIdString());
esm.writeHNCRefId("NAME", mId);
if (isDeleted)
{
@ -106,7 +106,7 @@ namespace ESM
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);
}
}

View file

@ -10,7 +10,7 @@ namespace ESM
isDeleted = false;
mRecordFlags = esm.getRecordFlags();
mId = ESM::RefId::stringRefId(esm.getHNString("NAME"));
mId = esm.getHNRefId("NAME");
if (esm.isNextSub("DELE"))
{
@ -25,7 +25,7 @@ namespace ESM
void Global::save(ESMWriter& esm, bool isDeleted) const
{
esm.writeHNCString("NAME", mId.getRefIdString());
esm.writeHNCRefId("NAME", mId);
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)
mRecordFlags = esm.getRecordFlags();
mId = ESM::RefId::stringRefId(esm.getHNString("NAME"));
mId = esm.getHNRefId("NAME");
mValue.read(esm, Variant::Format_Gmst);
}
void GameSetting::save(ESMWriter& esm, bool /*isDeleted*/) const
{
esm.writeHNCString("NAME", mId.getRefIdString());
esm.writeHNCRefId("NAME", mId);
mValue.write(esm, Variant::Format_Gmst);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -8,14 +8,14 @@ namespace ESM
void QuestState::load(ESMReader& esm)
{
mTopic = ESM::RefId::stringRefId(esm.getHNString("YETO"));
mTopic = esm.getHNRefId("YETO");
esm.getHNOT(mState, "QSTA");
esm.getHNOT(mFinished, "QFIN");
}
void QuestState::save(ESMWriter& esm) const
{
esm.writeHNString("YETO", mTopic.getRefIdString());
esm.writeHNRefId("YETO", mTopic);
esm.writeHNT("QSTA", mState);
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)
{
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");
esm.getHNOT(mPlayerLevel, "PLLE");
mPlayerClassId = ESM::RefId::stringRefId(esm.getHNOString("PLCL"));
mPlayerClassId = esm.getHNORefId("PLCL");
mPlayerClassName = esm.getHNOString("PLCN");
mPlayerCell = ESM::RefId::stringRefId(esm.getHNString("PLCE"));
mPlayerCell = esm.getHNRefId("PLCE");
esm.getHNTSized<16>(mInGameTime, "TSTM");
esm.getHNT(mTimePlayed, "TIME");
mDescription = esm.getHNString("DESC");
@ -33,11 +33,11 @@ namespace ESM
esm.writeHNT("PLLE", mPlayerLevel);
if (!mPlayerClassId.empty())
esm.writeHNString("PLCL", mPlayerClassId.getRefIdString());
esm.writeHNRefId("PLCL", mPlayerClassId);
else
esm.writeHNString("PLCN", mPlayerClassName);
esm.writeHNString("PLCE", mPlayerCell.getRefIdString());
esm.writeHNRefId("PLCE", mPlayerCell);
esm.writeHNT("TSTM", mInGameTime, 16);
esm.writeHNT("TIME", mTimePlayed);
esm.writeHNString("DESC", mDescription);

View file

@ -17,7 +17,7 @@ namespace ESM
{
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;
}
mSelectedSpell = ESM::RefId::stringRefId(esm.getHNOString("SLCT"));
mSelectedSpell = esm.getHNORefId("SLCT");
}
void SpellState::save(ESMWriter& esm) const
{
for (const ESM::RefId& spell : mSpells)
esm.writeHNString("SPEL", spell.getRefIdString());
esm.writeHNRefId("SPEL", spell);
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);
}
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)
{
esm.writeHNString("NAME", it->first.getRefIdString());
esm.writeHNRefId("NAME", it->first);
for (auto ownerIt = it->second.begin(); ownerIt != it->second.end(); ++ownerIt)
{
if (ownerIt->first.second)
esm.writeHNString("FNAM", ownerIt->first.first.getRefIdString());
esm.writeHNRefId("FNAM", ownerIt->first.first);
else
esm.writeHNString("ONAM", ownerIt->first.first.getRefIdString());
esm.writeHNRefId("ONAM", ownerIt->first.first);
esm.writeHNT("COUN", ownerIt->second);
}
}

View file

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