From 6d261d38ddea150b7615bc87f7d557aed79c9347 Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 12 Feb 2023 19:36:56 +0100 Subject: [PATCH] Add functions to read and write ESM::RefId and use them To be later changed with another implementation. --- apps/essimporter/converter.hpp | 6 ++--- apps/openmw/mwgui/windowmanagerimp.cpp | 2 +- apps/openmw/mwmechanics/actors.cpp | 2 +- components/esm/luascripts.cpp | 7 ++---- components/esm3/activespells.cpp | 2 +- components/esm3/aisequence.cpp | 12 +++++----- components/esm3/cellref.cpp | 16 ++++++------- components/esm3/creaturestats.cpp | 10 ++++---- components/esm3/debugprofile.cpp | 2 +- components/esm3/dialoguestate.cpp | 6 ++--- components/esm3/esmreader.cpp | 20 ++++++++++++++-- components/esm3/esmreader.hpp | 13 +++++++++- components/esm3/esmwriter.cpp | 25 +++++++++++++++++++ components/esm3/esmwriter.hpp | 33 ++++++++++++++++++++++++++ components/esm3/filter.cpp | 2 +- components/esm3/globalscript.cpp | 8 +++---- components/esm3/inventorystate.cpp | 4 ++-- components/esm3/journalentry.cpp | 8 +++---- components/esm3/loadacti.cpp | 4 ++-- components/esm3/loadalch.cpp | 4 ++-- components/esm3/loadappa.cpp | 4 ++-- components/esm3/loadarmo.cpp | 14 +++++------ components/esm3/loadbody.cpp | 4 ++-- components/esm3/loadbook.cpp | 6 ++--- components/esm3/loadbsgn.cpp | 2 +- components/esm3/loadcell.cpp | 4 ++-- components/esm3/loadclas.cpp | 2 +- components/esm3/loadclot.cpp | 6 ++--- components/esm3/loadcont.cpp | 8 +++---- components/esm3/loadcrea.cpp | 6 ++--- components/esm3/loaddial.cpp | 4 ++-- components/esm3/loaddoor.cpp | 8 +++---- components/esm3/loadench.cpp | 2 +- components/esm3/loadfact.cpp | 4 ++-- components/esm3/loadglob.cpp | 4 ++-- components/esm3/loadgmst.cpp | 4 ++-- components/esm3/loadinfo.cpp | 26 ++++++++++---------- components/esm3/loadingr.cpp | 4 ++-- components/esm3/loadlevlist.cpp | 6 ++--- components/esm3/loadligh.cpp | 6 ++--- components/esm3/loadlock.cpp | 4 ++-- components/esm3/loadltex.cpp | 2 +- components/esm3/loadmgef.cpp | 16 ++++++------- components/esm3/loadmisc.cpp | 4 ++-- components/esm3/loadnpc.cpp | 14 +++++------ components/esm3/loadpgrd.cpp | 2 +- components/esm3/loadprob.cpp | 4 ++-- components/esm3/loadrace.cpp | 2 +- components/esm3/loadregn.cpp | 8 +++---- components/esm3/loadrepa.cpp | 4 ++-- components/esm3/loadscpt.cpp | 4 ++-- components/esm3/loadsndg.cpp | 6 ++--- components/esm3/loadsoun.cpp | 2 +- components/esm3/loadspel.cpp | 2 +- components/esm3/loadsscr.cpp | 2 +- components/esm3/loadstat.cpp | 2 +- components/esm3/loadtes3.cpp | 4 ++-- components/esm3/loadweap.cpp | 6 ++--- components/esm3/npcstats.cpp | 4 ++-- components/esm3/player.cpp | 12 +++++----- components/esm3/projectilestate.cpp | 12 +++++----- components/esm3/queststate.cpp | 4 ++-- components/esm3/quickkeys.cpp | 2 +- components/esm3/savedgame.cpp | 8 +++---- components/esm3/spelllist.cpp | 2 +- components/esm3/spellstate.cpp | 8 +++---- components/esm3/stolenitems.cpp | 6 ++--- components/esm3/weatherstate.cpp | 6 ++--- 68 files changed, 272 insertions(+), 190 deletions(-) diff --git a/apps/essimporter/converter.hpp b/apps/essimporter/converter.hpp index c8b4b7d779..1db278c750 100644 --- a/apps/essimporter/converter.hpp +++ b/apps/essimporter/converter.hpp @@ -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)); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index a95e534094..c2686ccc87 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -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); } diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index e41885c8d1..04a847240f 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -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); diff --git a/components/esm/luascripts.cpp b/components/esm/luascripts.cpp index 55a4b8c423..0a7a2ff281 100644 --- a/components/esm/luascripts.cpp +++ b/components/esm/luascripts.cpp @@ -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(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(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); } diff --git a/components/esm3/activespells.cpp b/components/esm3/activespells.cpp index dae16e3120..c03200d3ae 100644 --- a/components/esm3/activespells.cpp +++ b/components/esm3/activespells.cpp @@ -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); diff --git a/components/esm3/aisequence.cpp b/components/esm3/aisequence.cpp index d556d7ec6a..66bda9be62 100644 --- a/components/esm3/aisequence.cpp +++ b/components/esm3/aisequence.cpp @@ -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); } diff --git a/components/esm3/cellref.cpp b/components/esm3/cellref.cpp index 1e0dffb92b..a74c44270c 100644 --- a/components/esm3/cellref.cpp +++ b/components/esm3/cellref.cpp @@ -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) diff --git a/components/esm3/creaturestats.cpp b/components/esm3/creaturestats.cpp index 7343baf5d9..8a7625b9f0 100644 --- a/components/esm3/creaturestats.cpp +++ b/components/esm3/creaturestats.cpp @@ -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); diff --git a/components/esm3/debugprofile.cpp b/components/esm3/debugprofile.cpp index 241df1e743..fb4ff77206 100644 --- a/components/esm3/debugprofile.cpp +++ b/components/esm3/debugprofile.cpp @@ -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) { diff --git a/components/esm3/dialoguestate.cpp b/components/esm3/dialoguestate.cpp index 2423bbb6b1..88fbe9659a 100644 --- a/components/esm3/dialoguestate.cpp +++ b/components/esm3/dialoguestate.cpp @@ -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); } } diff --git a/components/esm3/esmreader.cpp b/components/esm3/esmreader.cpp index 453b96a286..62f78af80f 100644 --- a/components/esm3/esmreader.cpp +++ b/components/esm3/esmreader.cpp @@ -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; diff --git a/components/esm3/esmreader.hpp b/components/esm3/esmreader.hpp index ecd17777f5..c1dcf99297 100644 --- a/components/esm3/esmreader.hpp +++ b/components/esm3/esmreader.hpp @@ -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]; diff --git a/components/esm3/esmwriter.cpp b/components/esm3/esmwriter.cpp index 022b00f93f..3cd534e404 100644 --- a/components/esm3/esmwriter.cpp +++ b/components/esm3/esmwriter.cpp @@ -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); diff --git a/components/esm3/esmwriter.hpp b/components/esm3/esmwriter.hpp index 6d22b70879..d10ba26241 100644 --- a/components/esm3/esmwriter.hpp +++ b/components/esm3/esmwriter.hpp @@ -6,6 +6,8 @@ #include #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 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: diff --git a/components/esm3/filter.cpp b/components/esm3/filter.cpp index c7caf28260..31f00cb168 100644 --- a/components/esm3/filter.cpp +++ b/components/esm3/filter.cpp @@ -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) { diff --git a/components/esm3/globalscript.cpp b/components/esm3/globalscript.cpp index 707b5266a1..73ca10018c 100644 --- a/components/esm3/globalscript.cpp +++ b/components/esm3/globalscript.cpp @@ -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"); } diff --git a/components/esm3/inventorystate.cpp b/components/esm3/inventorystate.cpp index 6f1ceeac11..3c34e708e5 100644 --- a/components/esm3/inventorystate.cpp +++ b/components/esm3/inventorystate.cpp @@ -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>& params = it->second; for (std::vector>::const_iterator pIt = params.begin(); pIt != params.end(); ++pIt) diff --git a/components/esm3/journalentry.cpp b/components/esm3/journalentry.cpp index 159e2624c4..11bdf2bd46 100644 --- a/components/esm3/journalentry.cpp +++ b/components/esm3/journalentry.cpp @@ -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) diff --git a/components/esm3/loadacti.cpp b/components/esm3/loadacti.cpp index c233f50dcc..0b5cc9267c 100644 --- a/components/esm3/loadacti.cpp +++ b/components/esm3/loadacti.cpp @@ -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() diff --git a/components/esm3/loadalch.cpp b/components/esm3/loadalch.cpp index 76b153f05a..5ab6000414 100644 --- a/components/esm3/loadalch.cpp +++ b/components/esm3/loadalch.cpp @@ -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); diff --git a/components/esm3/loadappa.cpp b/components/esm3/loadappa.cpp index f80ae9781b..da50aae4ea 100644 --- a/components/esm3/loadappa.cpp +++ b/components/esm3/loadappa.cpp @@ -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); } diff --git a/components/esm3/loadarmo.cpp b/components/esm3/loadarmo.cpp index 16039f39dd..c6da2acfae 100644 --- a/components/esm3/loadarmo.cpp +++ b/components/esm3/loadarmo.cpp @@ -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::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() diff --git a/components/esm3/loadbody.cpp b/components/esm3/loadbody.cpp index 3165a76548..035edbb94c 100644 --- a/components/esm3/loadbody.cpp +++ b/components/esm3/loadbody.cpp @@ -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); } diff --git a/components/esm3/loadbook.cpp b/components/esm3/loadbook.cpp index 259b7e99a8..aa85b7d206 100644 --- a/components/esm3/loadbook.cpp +++ b/components/esm3/loadbook.cpp @@ -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() diff --git a/components/esm3/loadbsgn.cpp b/components/esm3/loadbsgn.cpp index 8d09ced793..93a4c5fcab 100644 --- a/components/esm3/loadbsgn.cpp +++ b/components/esm3/loadbsgn.cpp @@ -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) { diff --git a/components/esm3/loadcell.cpp b/components/esm3/loadcell.cpp index f69fd88c44..5e72646b56 100644 --- a/components/esm3/loadcell.cpp +++ b/components/esm3/loadcell.cpp @@ -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); } diff --git a/components/esm3/loadclas.cpp b/components/esm3/loadclas.cpp index 5863434564..8da92d95f6 100644 --- a/components/esm3/loadclas.cpp +++ b/components/esm3/loadclas.cpp @@ -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) { diff --git a/components/esm3/loadclot.cpp b/components/esm3/loadclot.cpp index 45b5405f5b..8f86f55a5c 100644 --- a/components/esm3/loadclot.cpp +++ b/components/esm3/loadclot.cpp @@ -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() diff --git a/components/esm3/loadcont.cpp b/components/esm3/loadcont.cpp index d247cba07b..2d4b134350 100644 --- a/components/esm3/loadcont.cpp +++ b/components/esm3/loadcont.cpp @@ -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); } diff --git a/components/esm3/loadcrea.cpp b/components/esm3/loadcrea.cpp index f4314254e0..29d9535e47 100644 --- a/components/esm3/loadcrea.cpp +++ b/components/esm3/loadcrea.cpp @@ -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) diff --git a/components/esm3/loaddial.cpp b/components/esm3/loaddial.cpp index 48ca6a659f..87bed4db81 100644 --- a/components/esm3/loaddial.cpp +++ b/components/esm3/loaddial.cpp @@ -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); diff --git a/components/esm3/loaddoor.cpp b/components/esm3/loaddoor.cpp index a3a02030e4..07dd4cd964 100644 --- a/components/esm3/loaddoor.cpp +++ b/components/esm3/loaddoor.cpp @@ -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() diff --git a/components/esm3/loadench.cpp b/components/esm3/loadench.cpp index fa839e8848..b72850daca 100644 --- a/components/esm3/loadench.cpp +++ b/components/esm3/loadench.cpp @@ -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) { diff --git a/components/esm3/loadfact.cpp b/components/esm3/loadfact.cpp index 08bbb8769a..bd1c998556 100644 --- a/components/esm3/loadfact.cpp +++ b/components/esm3/loadfact.cpp @@ -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); } } diff --git a/components/esm3/loadglob.cpp b/components/esm3/loadglob.cpp index 99278d2546..71760e64f4 100644 --- a/components/esm3/loadglob.cpp +++ b/components/esm3/loadglob.cpp @@ -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) { diff --git a/components/esm3/loadgmst.cpp b/components/esm3/loadgmst.cpp index 9ad9c2dda7..b6a40a2256 100644 --- a/components/esm3/loadgmst.cpp +++ b/components/esm3/loadgmst.cpp @@ -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); } diff --git a/components/esm3/loadinfo.cpp b/components/esm3/loadinfo.cpp index 5ab955230e..16270e57e2 100644 --- a/components/esm3/loadinfo.cpp +++ b/components/esm3/loadinfo.cpp @@ -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); diff --git a/components/esm3/loadingr.cpp b/components/esm3/loadingr.cpp index 09240218b8..b57abe0428 100644 --- a/components/esm3/loadingr.cpp +++ b/components/esm3/loadingr.cpp @@ -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); } diff --git a/components/esm3/loadlevlist.cpp b/components/esm3/loadlevlist.cpp index 56b1d32562..970174ada2 100644 --- a/components/esm3/loadlevlist.cpp +++ b/components/esm3/loadlevlist.cpp @@ -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::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); } } diff --git a/components/esm3/loadligh.cpp b/components/esm3/loadligh.cpp index 54b53ebc9a..5e84b321c6 100644 --- a/components/esm3/loadligh.cpp +++ b/components/esm3/loadligh.cpp @@ -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() diff --git a/components/esm3/loadlock.cpp b/components/esm3/loadlock.cpp index 1f2756bb8d..7058860532 100644 --- a/components/esm3/loadlock.cpp +++ b/components/esm3/loadlock.cpp @@ -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); } diff --git a/components/esm3/loadltex.cpp b/components/esm3/loadltex.cpp index 0234c6c257..f9ce3a72b2 100644 --- a/components/esm3/loadltex.cpp +++ b/components/esm3/loadltex.cpp @@ -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); diff --git a/components/esm3/loadmgef.cpp b/components/esm3/loadmgef.cpp index c9981bea33..019c7db616 100644 --- a/components/esm3/loadmgef.cpp +++ b/components/esm3/loadmgef.cpp @@ -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); } diff --git a/components/esm3/loadmisc.cpp b/components/esm3/loadmisc.cpp index 613eacbfa8..77863d90fa 100644 --- a/components/esm3/loadmisc.cpp +++ b/components/esm3/loadmisc.cpp @@ -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); } diff --git a/components/esm3/loadnpc.cpp b/components/esm3/loadnpc.cpp index bd8b58a93d..7f68ac1788 100644 --- a/components/esm3/loadnpc.cpp +++ b/components/esm3/loadnpc.cpp @@ -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) { diff --git a/components/esm3/loadpgrd.cpp b/components/esm3/loadpgrd.cpp index 8fd822036f..912d21f77e 100644 --- a/components/esm3/loadpgrd.cpp +++ b/components/esm3/loadpgrd.cpp @@ -154,7 +154,7 @@ namespace ESM } // Save - esm.writeHNCString("NAME", mCell.getRefIdString()); + esm.writeHNCRefId("NAME", mCell); esm.writeHNT("DATA", mData, 12); if (isDeleted) diff --git a/components/esm3/loadprob.cpp b/components/esm3/loadprob.cpp index 2b69657aef..a45c91cb35 100644 --- a/components/esm3/loadprob.cpp +++ b/components/esm3/loadprob.cpp @@ -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); } diff --git a/components/esm3/loadrace.cpp b/components/esm3/loadrace.cpp index f57ffc24ea..00eb5eda3a 100644 --- a/components/esm3/loadrace.cpp +++ b/components/esm3/loadrace.cpp @@ -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) { diff --git a/components/esm3/loadregn.cpp b/components/esm3/loadregn.cpp index 84b448dabc..b4a362dbef 100644 --- a/components/esm3/loadregn.cpp +++ b/components/esm3/loadregn.cpp @@ -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::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"); } diff --git a/components/esm3/loadrepa.cpp b/components/esm3/loadrepa.cpp index 41914311e3..7e48e9854c 100644 --- a/components/esm3/loadrepa.cpp +++ b/components/esm3/loadrepa.cpp @@ -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); } diff --git a/components/esm3/loadscpt.cpp b/components/esm3/loadscpt.cpp index df4459d85b..1724479f4c 100644 --- a/components/esm3/loadscpt.cpp +++ b/components/esm3/loadscpt.cpp @@ -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"); diff --git a/components/esm3/loadsndg.cpp b/components/esm3/loadsndg.cpp index 3e46832f1f..2763180ad0 100644 --- a/components/esm3/loadsndg.cpp +++ b/components/esm3/loadsndg.cpp @@ -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() diff --git a/components/esm3/loadsoun.cpp b/components/esm3/loadsoun.cpp index 99743a8f42..af7d7b3710 100644 --- a/components/esm3/loadsoun.cpp +++ b/components/esm3/loadsoun.cpp @@ -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) { diff --git a/components/esm3/loadspel.cpp b/components/esm3/loadspel.cpp index ede06c0591..d94073d33c 100644 --- a/components/esm3/loadspel.cpp +++ b/components/esm3/loadspel.cpp @@ -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) { diff --git a/components/esm3/loadsscr.cpp b/components/esm3/loadsscr.cpp index c911c71bee..b96e9cacd5 100644 --- a/components/esm3/loadsscr.cpp +++ b/components/esm3/loadsscr.cpp @@ -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); diff --git a/components/esm3/loadstat.cpp b/components/esm3/loadstat.cpp index cbac768267..7ebf036cd1 100644 --- a/components/esm3/loadstat.cpp +++ b/components/esm3/loadstat.cpp @@ -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); diff --git a/components/esm3/loadtes3.cpp b/components/esm3/loadtes3.cpp index b80f8af0cb..f64acc26f4 100644 --- a/components/esm3/loadtes3.cpp +++ b/components/esm3/loadtes3.cpp @@ -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); } diff --git a/components/esm3/loadweap.cpp b/components/esm3/loadweap.cpp index 782366816a..22fe3816fa 100644 --- a/components/esm3/loadweap.cpp +++ b/components/esm3/loadweap.cpp @@ -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() diff --git a/components/esm3/npcstats.cpp b/components/esm3/npcstats.cpp index 38b781fda6..7234afbed2 100644 --- a/components/esm3/npcstats.cpp +++ b/components/esm3/npcstats.cpp @@ -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); diff --git a/components/esm3/player.cpp b/components/esm3/player.cpp index 17a30ad085..0a25886ce0 100644 --- a/components/esm3/player.cpp +++ b/components/esm3/player.cpp @@ -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); diff --git a/components/esm3/projectilestate.cpp b/components/esm3/projectilestate.cpp index 933b2ab384..2b9eccc3e8 100644 --- a/components/esm3/projectilestate.cpp +++ b/components/esm3/projectilestate.cpp @@ -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; diff --git a/components/esm3/queststate.cpp b/components/esm3/queststate.cpp index 33f5bfb35e..609771f9be 100644 --- a/components/esm3/queststate.cpp +++ b/components/esm3/queststate.cpp @@ -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); } diff --git a/components/esm3/quickkeys.cpp b/components/esm3/quickkeys.cpp index f1003ccc56..ec9c1ed307 100644 --- a/components/esm3/quickkeys.cpp +++ b/components/esm3/quickkeys.cpp @@ -34,7 +34,7 @@ namespace ESM for (std::vector::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); } } diff --git a/components/esm3/savedgame.cpp b/components/esm3/savedgame.cpp index ad77709f8e..add3df02b3 100644 --- a/components/esm3/savedgame.cpp +++ b/components/esm3/savedgame.cpp @@ -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); diff --git a/components/esm3/spelllist.cpp b/components/esm3/spelllist.cpp index 21871d23b9..587246c9a3 100644 --- a/components/esm3/spelllist.cpp +++ b/components/esm3/spelllist.cpp @@ -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); } } diff --git a/components/esm3/spellstate.cpp b/components/esm3/spellstate.cpp index f8aac38500..449bf6b179 100644 --- a/components/esm3/spellstate.cpp +++ b/components/esm3/spellstate.cpp @@ -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); } } diff --git a/components/esm3/stolenitems.cpp b/components/esm3/stolenitems.cpp index da57dd8339..bf1d4569c0 100644 --- a/components/esm3/stolenitems.cpp +++ b/components/esm3/stolenitems.cpp @@ -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); } } diff --git a/components/esm3/weatherstate.cpp b/components/esm3/weatherstate.cpp index 3d4b13a66e..4c6896d37e 100644 --- a/components/esm3/weatherstate.cpp +++ b/components/esm3/weatherstate.cpp @@ -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) {