diff --git a/apps/openmw_test_suite/esm/variant.cpp b/apps/openmw_test_suite/esm/variant.cpp index 6991a8b4a8..287540c1e0 100644 --- a/apps/openmw_test_suite/esm/variant.cpp +++ b/apps/openmw_test_suite/esm/variant.cpp @@ -425,7 +425,7 @@ namespace std::string write(const Variant& variant, const Variant::Format format) { std::ostringstream out; - ESM::ESMWriter writer; + ESMWriter writer; writer.save(out); variant.write(writer, format); writer.close(); @@ -435,7 +435,7 @@ namespace Variant read(const Variant::Format format, const std::string& data) { Variant result; - ESM::ESMReader reader; + ESMReader reader; reader.open(std::make_shared(data), ""); result.read(reader, format); return result; @@ -490,7 +490,7 @@ namespace { const auto param = GetParam(); std::ostringstream out; - ESM::ESMWriter writer; + ESMWriter writer; writer.save(out); ASSERT_THROW(param.mVariant.write(writer, param.mFormat), std::runtime_error); } diff --git a/components/esm3/activespells.cpp b/components/esm3/activespells.cpp index 61be6a7838..014c5c2e77 100644 --- a/components/esm3/activespells.cpp +++ b/components/esm3/activespells.cpp @@ -3,9 +3,11 @@ #include "esmreader.hpp" #include "esmwriter.hpp" +namespace ESM +{ namespace { - void save(ESM::ESMWriter& esm, const std::vector& spells, ESM::NAME tag) + void saveImpl(ESMWriter& esm, const std::vector& spells, NAME tag) { for (const auto& params : spells) { @@ -38,19 +40,19 @@ namespace } } - void load(ESM::ESMReader& esm, std::vector& spells, ESM::NAME tag) + void loadImpl(ESMReader& esm, std::vector& spells, NAME tag) { int format = esm.getFormat(); while (esm.isNextSub(tag)) { - ESM::ActiveSpells::ActiveSpellParams params; + ActiveSpells::ActiveSpellParams params; params.mId = esm.getHString(); esm.getHNT (params.mCasterActorId, "CAST"); params.mDisplayName = esm.getHNString ("DISP"); params.mItem.unset(); if (format < 17) - params.mType = ESM::ActiveSpells::Type_Temporary; + params.mType = ActiveSpells::Type_Temporary; else { esm.getHNT (params.mType, "TYPE"); @@ -71,7 +73,7 @@ namespace while (esm.isNextSub("MGEF")) { - ESM::ActiveEffect effect; + ActiveEffect effect; esm.getHT(effect.mEffectId); effect.mArg = -1; esm.getHNOT(effect.mArg, "ARG_"); @@ -94,7 +96,7 @@ namespace else esm.getHNT (effect.mTimeLeft, "LEFT"); if (format < 17) - effect.mFlags = ESM::ActiveEffect::Flag_None; + effect.mFlags = ActiveEffect::Flag_None; else esm.getHNT (effect.mFlags, "FLAG"); @@ -104,19 +106,19 @@ namespace } } } +} namespace ESM { - void ActiveSpells::save(ESMWriter &esm) const { - ::save(esm, mSpells, "ID__"); - ::save(esm, mQueue, "QID_"); + saveImpl(esm, mSpells, "ID__"); + saveImpl(esm, mQueue, "QID_"); } void ActiveSpells::load(ESMReader &esm) { - ::load(esm, mSpells, "ID__"); - ::load(esm, mQueue, "QID_"); + loadImpl(esm, mSpells, "ID__"); + loadImpl(esm, mQueue, "QID_"); } } diff --git a/components/esm3/aipackage.cpp b/components/esm3/aipackage.cpp index 5a95e58ca8..55ee64db9c 100644 --- a/components/esm3/aipackage.cpp +++ b/components/esm3/aipackage.cpp @@ -65,7 +65,7 @@ namespace ESM case AI_Escort: case AI_Follow: { - const ESM::NAME name = (it->mType == AI_Escort) ? ESM::NAME("AI_E") : ESM::NAME("AI_F"); + const NAME name = (it->mType == AI_Escort) ? NAME("AI_E") : NAME("AI_F"); esm.writeHNT(name, it->mTarget, sizeof(it->mTarget)); esm.writeHNOCString("CNDT", it->mCellName); break; diff --git a/components/esm3/aisequence.hpp b/components/esm3/aisequence.hpp index 412c7401bf..f71771a4d5 100644 --- a/components/esm3/aisequence.hpp +++ b/components/esm3/aisequence.hpp @@ -22,13 +22,13 @@ namespace ESM enum AiPackages { - Ai_Wander = ESM::fourCC("WAND"), - Ai_Travel = ESM::fourCC("TRAV"), - Ai_Escort = ESM::fourCC("ESCO"), - Ai_Follow = ESM::fourCC("FOLL"), - Ai_Activate = ESM::fourCC("ACTI"), - Ai_Combat = ESM::fourCC("COMB"), - Ai_Pursue = ESM::fourCC("PURS") + Ai_Wander = fourCC("WAND"), + Ai_Travel = fourCC("TRAV"), + Ai_Escort = fourCC("ESCO"), + Ai_Follow = fourCC("FOLL"), + Ai_Activate = fourCC("ACTI"), + Ai_Combat = fourCC("COMB"), + Ai_Pursue = fourCC("PURS") }; @@ -67,10 +67,10 @@ namespace ESM struct AiWander : AiPackage { AiWanderData mData; - AiWanderDuration mDurationData; // was ESM::TimeStamp mStartTime + AiWanderDuration mDurationData; // was TimeStamp mStartTime bool mStoredInitialActorPosition; - ESM::Vector3 mInitialActorPosition; + Vector3 mInitialActorPosition; /// \todo add more AiWander state diff --git a/components/esm3/cellid.cpp b/components/esm3/cellid.cpp index 87ad0cc21c..154ef53056 100644 --- a/components/esm3/cellid.cpp +++ b/components/esm3/cellid.cpp @@ -3,9 +3,12 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -const std::string ESM::CellId::sDefaultWorldspace = "sys::default"; +namespace ESM +{ + +const std::string CellId::sDefaultWorldspace = "sys::default"; -void ESM::CellId::load (ESMReader &esm) +void CellId::load (ESMReader &esm) { mWorldspace = esm.getHNString ("SPAC"); @@ -18,7 +21,7 @@ void ESM::CellId::load (ESMReader &esm) mPaged = false; } -void ESM::CellId::save (ESMWriter &esm) const +void CellId::save (ESMWriter &esm) const { esm.writeHNString ("SPAC", mWorldspace); @@ -26,18 +29,18 @@ void ESM::CellId::save (ESMWriter &esm) const esm.writeHNT ("CIDX", mIndex, 8); } -bool ESM::operator== (const CellId& left, const CellId& right) +bool operator== (const CellId& left, const CellId& right) { return left.mWorldspace==right.mWorldspace && left.mPaged==right.mPaged && (!left.mPaged || (left.mIndex.mX==right.mIndex.mX && left.mIndex.mY==right.mIndex.mY)); } -bool ESM::operator!= (const CellId& left, const CellId& right) +bool operator!= (const CellId& left, const CellId& right) { return !(left==right); } -bool ESM::operator < (const CellId& left, const CellId& right) +bool operator < (const CellId& left, const CellId& right) { if (left.mPaged < right.mPaged) return true; @@ -59,3 +62,5 @@ bool ESM::operator < (const CellId& left, const CellId& right) return left.mWorldspace < right.mWorldspace; } + +} diff --git a/components/esm3/cellref.cpp b/components/esm3/cellref.cpp index d5ed0b4003..770680b8e2 100644 --- a/components/esm3/cellref.cpp +++ b/components/esm3/cellref.cpp @@ -63,67 +63,67 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::fourCC("UNAM"): + case fourCC("UNAM"): getHTOrSkip(cellRef.mReferenceBlocked); break; - case ESM::fourCC("XSCL"): + case fourCC("XSCL"): getHTOrSkip(cellRef.mScale); if constexpr (load) cellRef.mScale = std::clamp(cellRef.mScale, 0.5f, 2.0f); break; - case ESM::fourCC("ANAM"): + case fourCC("ANAM"): getHStringOrSkip(cellRef.mOwner); break; - case ESM::fourCC("BNAM"): + case fourCC("BNAM"): getHStringOrSkip(cellRef.mGlobalVariable); break; - case ESM::fourCC("XSOL"): + case fourCC("XSOL"): getHStringOrSkip(cellRef.mSoul); break; - case ESM::fourCC("CNAM"): + case fourCC("CNAM"): getHStringOrSkip(cellRef.mFaction); break; - case ESM::fourCC("INDX"): + case fourCC("INDX"): getHTOrSkip(cellRef.mFactionRank); break; - case ESM::fourCC("XCHG"): + case fourCC("XCHG"): getHTOrSkip(cellRef.mEnchantmentCharge); break; - case ESM::fourCC("INTV"): + case fourCC("INTV"): getHTOrSkip(cellRef.mChargeInt); break; - case ESM::fourCC("NAM9"): + case fourCC("NAM9"): getHTOrSkip(cellRef.mGoldValue); break; - case ESM::fourCC("DODT"): + case fourCC("DODT"): getHTOrSkip(cellRef.mDoorDest); if constexpr (load) cellRef.mTeleport = true; break; - case ESM::fourCC("DNAM"): + case fourCC("DNAM"): getHStringOrSkip(cellRef.mDestCell); break; - case ESM::fourCC("FLTV"): + case fourCC("FLTV"): getHTOrSkip(cellRef.mLockLevel); break; - case ESM::fourCC("KNAM"): + case fourCC("KNAM"): getHStringOrSkip(cellRef.mKey); break; - case ESM::fourCC("TNAM"): + case fourCC("TNAM"): getHStringOrSkip(cellRef.mTrap); break; - case ESM::fourCC("DATA"): + case fourCC("DATA"): if constexpr (load) esm.getHTSized<24>(cellRef.mPos); else esm.skipHTSized<24, decltype(cellRef.mPos)>(); break; - case ESM::fourCC("NAM0"): + case fourCC("NAM0"): { esm.skipHSub(); break; } - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); if constexpr (load) isDeleted = true; @@ -145,9 +145,8 @@ namespace ESM } } } -} -void ESM::RefNum::load(ESMReader& esm, bool wide, ESM::NAME tag) +void RefNum::load(ESMReader& esm, bool wide, NAME tag) { if (wide) esm.getHNTSized<8>(*this, tag); @@ -155,7 +154,7 @@ void ESM::RefNum::load(ESMReader& esm, bool wide, ESM::NAME tag) esm.getHNT(mIndex, tag); } -void ESM::RefNum::save(ESMWriter &esm, bool wide, ESM::NAME tag) const +void RefNum::save(ESMWriter &esm, bool wide, NAME tag) const { if (wide) esm.writeHNT (tag, *this, 8); @@ -168,23 +167,23 @@ void ESM::RefNum::save(ESMWriter &esm, bool wide, ESM::NAME tag) const } } -void ESM::CellRef::load (ESMReader& esm, bool &isDeleted, bool wideRefNum) +void CellRef::load (ESMReader& esm, bool &isDeleted, bool wideRefNum) { loadId(esm, wideRefNum); loadData(esm, isDeleted); } -void ESM::CellRef::loadId (ESMReader& esm, bool wideRefNum) +void CellRef::loadId (ESMReader& esm, bool wideRefNum) { loadIdImpl(esm, wideRefNum, *this); } -void ESM::CellRef::loadData(ESMReader &esm, bool &isDeleted) +void CellRef::loadData(ESMReader &esm, bool &isDeleted) { loadDataImpl(esm, isDeleted, *this); } -void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool isDeleted) const +void CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool isDeleted) const { mRefNum.save (esm, wideRefNum); @@ -246,7 +245,7 @@ void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool esm.writeHNT("DATA", mPos, 24); } -void ESM::CellRef::blank() +void CellRef::blank() { mRefNum.unset(); mRefID.clear(); @@ -276,10 +275,12 @@ void ESM::CellRef::blank() } } -void ESM::skipLoadCellRef(ESMReader& esm, bool wideRefNum) +void skipLoadCellRef(ESMReader& esm, bool wideRefNum) { CellRef cellRef; loadIdImpl(esm, wideRefNum, cellRef); bool isDeleted; loadDataImpl(esm, isDeleted, cellRef); } + +} diff --git a/components/esm3/cellref.hpp b/components/esm3/cellref.hpp index 07d4e0c80a..f710167afc 100644 --- a/components/esm3/cellref.hpp +++ b/components/esm3/cellref.hpp @@ -19,9 +19,9 @@ namespace ESM unsigned int mIndex; int mContentFile; - void load(ESMReader& esm, bool wide = false, ESM::NAME tag = "FRMR"); + void load(ESMReader& esm, bool wide = false, NAME tag = "FRMR"); - void save(ESMWriter &esm, bool wide = false, ESM::NAME tag = "FRMR") const; + void save(ESMWriter &esm, bool wide = false, NAME tag = "FRMR") const; inline bool hasContentFile() const { return mContentFile >= 0; } diff --git a/components/esm3/cellstate.cpp b/components/esm3/cellstate.cpp index 83b130dcd9..d5773d5f26 100644 --- a/components/esm3/cellstate.cpp +++ b/components/esm3/cellstate.cpp @@ -3,7 +3,10 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -void ESM::CellState::load (ESMReader &esm) +namespace ESM +{ + +void CellState::load (ESMReader &esm) { mWaterLevel = 0; esm.getHNOT (mWaterLevel, "WLVL"); @@ -16,7 +19,7 @@ void ESM::CellState::load (ESMReader &esm) esm.getHNOT (mLastRespawn, "RESP"); } -void ESM::CellState::save (ESMWriter &esm) const +void CellState::save (ESMWriter &esm) const { if (!mId.mPaged) esm.writeHNT ("WLVL", mWaterLevel); @@ -25,3 +28,5 @@ void ESM::CellState::save (ESMWriter &esm) const esm.writeHNT ("RESP", mLastRespawn); } + +} diff --git a/components/esm3/cellstate.hpp b/components/esm3/cellstate.hpp index 9c0427f76b..bf332ae5e8 100644 --- a/components/esm3/cellstate.hpp +++ b/components/esm3/cellstate.hpp @@ -21,7 +21,7 @@ namespace ESM int mHasFogOfWar; // Do we have fog of war state (0 or 1)? (see fogstate.hpp) - ESM::TimeStamp mLastRespawn; + TimeStamp mLastRespawn; void load (ESMReader &esm); void save (ESMWriter &esm) const; diff --git a/components/esm3/containerstate.cpp b/components/esm3/containerstate.cpp index 301549d597..b54736cb8b 100644 --- a/components/esm3/containerstate.cpp +++ b/components/esm3/containerstate.cpp @@ -1,15 +1,20 @@ #include "containerstate.hpp" -void ESM::ContainerState::load (ESMReader &esm) +namespace ESM +{ + +void ContainerState::load (ESMReader &esm) { ObjectState::load (esm); mInventory.load (esm); } -void ESM::ContainerState::save (ESMWriter &esm, bool inInventory) const +void ContainerState::save (ESMWriter &esm, bool inInventory) const { ObjectState::save (esm, inInventory); mInventory.save (esm); } + +} diff --git a/components/esm3/controlsstate.cpp b/components/esm3/controlsstate.cpp index ae4e1dff16..c985c23f15 100644 --- a/components/esm3/controlsstate.cpp +++ b/components/esm3/controlsstate.cpp @@ -3,7 +3,10 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -ESM::ControlsState::ControlsState() +namespace ESM +{ + +ControlsState::ControlsState() : mViewSwitchDisabled(false), mControlsDisabled(false), mJumpingDisabled(false), @@ -14,7 +17,7 @@ ESM::ControlsState::ControlsState() { } -void ESM::ControlsState::load(ESM::ESMReader& esm) +void ControlsState::load(ESMReader& esm) { int flags; esm.getHNT(flags, "CFLG"); @@ -28,7 +31,7 @@ void ESM::ControlsState::load(ESM::ESMReader& esm) mSpellDrawingDisabled = flags & SpellDrawingDisabled; } -void ESM::ControlsState::save(ESM::ESMWriter& esm) const +void ControlsState::save(ESMWriter& esm) const { int flags = 0; if (mViewSwitchDisabled) flags |= ViewSwitchDisabled; @@ -41,3 +44,5 @@ void ESM::ControlsState::save(ESM::ESMWriter& esm) const esm.writeHNT("CFLG", flags); } + +} diff --git a/components/esm3/creaturestate.cpp b/components/esm3/creaturestate.cpp index bffa4e5e45..e9a9f52cf1 100644 --- a/components/esm3/creaturestate.cpp +++ b/components/esm3/creaturestate.cpp @@ -1,6 +1,9 @@ #include "creaturestate.hpp" -void ESM::CreatureState::load (ESMReader &esm) +namespace ESM +{ + +void CreatureState::load (ESMReader &esm) { ObjectState::load (esm); @@ -12,7 +15,7 @@ void ESM::CreatureState::load (ESMReader &esm) } } -void ESM::CreatureState::save (ESMWriter &esm, bool inInventory) const +void CreatureState::save (ESMWriter &esm, bool inInventory) const { ObjectState::save (esm, inInventory); @@ -24,8 +27,10 @@ void ESM::CreatureState::save (ESMWriter &esm, bool inInventory) const } } -void ESM::CreatureState::blank() +void CreatureState::blank() { ObjectState::blank(); mCreatureStats.blank(); } + +} diff --git a/components/esm3/creaturestats.cpp b/components/esm3/creaturestats.cpp index 0f404ba58b..1a1eabd2ab 100644 --- a/components/esm3/creaturestats.cpp +++ b/components/esm3/creaturestats.cpp @@ -4,7 +4,10 @@ #include -void ESM::CreatureStats::load (ESMReader &esm) +namespace ESM +{ + +void CreatureStats::load (ESMReader &esm) { bool intFallback = esm.getFormat() < 11; for (int i=0; i<8; ++i) @@ -174,7 +177,7 @@ void ESM::CreatureStats::load (ESMReader &esm) } } -void ESM::CreatureStats::save (ESMWriter &esm) const +void CreatureStats::save (ESMWriter &esm) const { for (int i=0; i<8; ++i) mAttributes[i].save (esm); @@ -259,7 +262,7 @@ void ESM::CreatureStats::save (ESMWriter &esm) const esm.writeHNT("NOAC", mMissingACDT); } -void ESM::CreatureStats::blank() +void CreatureStats::blank() { mTradeTime.mHour = 0; mTradeTime.mDay = 0; @@ -287,3 +290,5 @@ void ESM::CreatureStats::blank() mCorprusSpells.clear(); mMissingACDT = false; } + +} diff --git a/components/esm3/creaturestats.hpp b/components/esm3/creaturestats.hpp index d47a283630..7ad168b12f 100644 --- a/components/esm3/creaturestats.hpp +++ b/components/esm3/creaturestats.hpp @@ -43,7 +43,7 @@ namespace ESM std::multimap mSummonedCreatures; std::vector mSummonGraveyard; - ESM::TimeStamp mTradeTime; + TimeStamp mTradeTime; int mGoldPool; int mActorId; //int mHitAttemptActorId; @@ -83,7 +83,7 @@ namespace ESM bool mRecalcDynamicStats; int mDrawState; signed char mDeathAnimation; - ESM::TimeStamp mTimeOfDeath; + TimeStamp mTimeOfDeath; int mLevel; bool mMissingACDT; diff --git a/components/esm3/custommarkerstate.cpp b/components/esm3/custommarkerstate.cpp index dc81c123d4..7752cc146f 100644 --- a/components/esm3/custommarkerstate.cpp +++ b/components/esm3/custommarkerstate.cpp @@ -6,7 +6,7 @@ namespace ESM { -void CustomMarker::save(ESM::ESMWriter &esm) const +void CustomMarker::save(ESMWriter &esm) const { esm.writeHNT("POSX", mWorldX); esm.writeHNT("POSY", mWorldY); @@ -15,7 +15,7 @@ void CustomMarker::save(ESM::ESMWriter &esm) const esm.writeHNString("NOTE", mNote); } -void CustomMarker::load(ESM::ESMReader &esm) +void CustomMarker::load(ESMReader &esm) { esm.getHNT(mWorldX, "POSX"); esm.getHNT(mWorldY, "POSY"); diff --git a/components/esm3/custommarkerstate.hpp b/components/esm3/custommarkerstate.hpp index 2be43c53bf..0b527c0a92 100644 --- a/components/esm3/custommarkerstate.hpp +++ b/components/esm3/custommarkerstate.hpp @@ -12,7 +12,7 @@ struct CustomMarker float mWorldX; float mWorldY; - ESM::CellId mCell; + CellId mCell; std::string mNote; @@ -21,8 +21,8 @@ struct CustomMarker return mNote == other.mNote && mCell == other.mCell && mWorldX == other.mWorldX && mWorldY == other.mWorldY; } - void load (ESM::ESMReader& reader); - void save (ESM::ESMWriter& writer) const; + void load (ESMReader& reader); + void save (ESMWriter& writer) const; }; } diff --git a/components/esm3/debugprofile.cpp b/components/esm3/debugprofile.cpp index 87c3bd13ba..cdbd47bce4 100644 --- a/components/esm3/debugprofile.cpp +++ b/components/esm3/debugprofile.cpp @@ -4,9 +4,12 @@ #include "esmwriter.hpp" #include "components/esm/defs.hpp" -unsigned int ESM::DebugProfile::sRecordId = REC_DBGP; +namespace ESM +{ + +unsigned int DebugProfile::sRecordId = REC_DBGP; -void ESM::DebugProfile::load (ESMReader& esm, bool &isDeleted) +void DebugProfile::load (ESMReader& esm, bool &isDeleted) { isDeleted = false; mRecordFlags = esm.getRecordFlags(); @@ -16,19 +19,19 @@ void ESM::DebugProfile::load (ESMReader& esm, bool &isDeleted) esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); break; - case ESM::fourCC("DESC"): + case fourCC("DESC"): mDescription = esm.getHString(); break; - case ESM::fourCC("SCRP"): + case fourCC("SCRP"): mScriptText = esm.getHString(); break; - case ESM::fourCC("FLAG"): + case fourCC("FLAG"): esm.getHT(mFlags); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; @@ -39,7 +42,7 @@ void ESM::DebugProfile::load (ESMReader& esm, bool &isDeleted) } } -void ESM::DebugProfile::save (ESMWriter& esm, bool isDeleted) const +void DebugProfile::save (ESMWriter& esm, bool isDeleted) const { esm.writeHNCString ("NAME", mId); @@ -54,9 +57,11 @@ void ESM::DebugProfile::save (ESMWriter& esm, bool isDeleted) const esm.writeHNT ("FLAG", mFlags); } -void ESM::DebugProfile::blank() +void DebugProfile::blank() { mDescription.clear(); mScriptText.clear(); mFlags = 0; } + +} diff --git a/components/esm3/dialoguestate.cpp b/components/esm3/dialoguestate.cpp index 2b1887e4eb..bdae1dbf4c 100644 --- a/components/esm3/dialoguestate.cpp +++ b/components/esm3/dialoguestate.cpp @@ -3,7 +3,10 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -void ESM::DialogueState::load (ESMReader &esm) +namespace ESM +{ + +void DialogueState::load (ESMReader &esm) { while (esm.isNextSub ("TOPI")) mKnownTopics.push_back (esm.getHString()); @@ -30,7 +33,7 @@ void ESM::DialogueState::load (ESMReader &esm) } } -void ESM::DialogueState::save (ESMWriter &esm) const +void DialogueState::save (ESMWriter &esm) const { for (std::vector::const_iterator iter (mKnownTopics.begin()); iter!=mKnownTopics.end(); ++iter) @@ -51,3 +54,5 @@ void ESM::DialogueState::save (ESMWriter &esm) const } } } + +} diff --git a/components/esm3/effectlist.cpp b/components/esm3/effectlist.cpp index 1cfb25618d..c578e4095a 100644 --- a/components/esm3/effectlist.cpp +++ b/components/esm3/effectlist.cpp @@ -3,7 +3,8 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -namespace ESM { +namespace ESM +{ void EffectList::load(ESMReader &esm) { diff --git a/components/esm3/esmreader.hpp b/components/esm3/esmreader.hpp index a91a1f1978..7994899db9 100644 --- a/components/esm3/esmreader.hpp +++ b/components/esm3/esmreader.hpp @@ -13,7 +13,8 @@ #include "components/esm/esmcommon.hpp" #include "loadtes3.hpp" -namespace ESM { +namespace ESM +{ class ESMReader { diff --git a/components/esm3/esmwriter.cpp b/components/esm3/esmwriter.cpp index 77ba5fc6aa..351de8612a 100644 --- a/components/esm3/esmwriter.cpp +++ b/components/esm3/esmwriter.cpp @@ -86,7 +86,7 @@ namespace ESM throw std::runtime_error ("Unclosed record remaining"); } - void ESMWriter::startRecord(ESM::NAME name, uint32_t flags) + void ESMWriter::startRecord(NAME name, uint32_t flags) { mRecordCount++; @@ -105,10 +105,10 @@ namespace ESM void ESMWriter::startRecord (uint32_t name, uint32_t flags) { - startRecord(ESM::NAME(name), flags); + startRecord(NAME(name), flags); } - void ESMWriter::startSubRecord(ESM::NAME name) + void ESMWriter::startSubRecord(NAME name) { // Sub-record hierarchies are not properly supported in ESMReader. This should be fixed later. assert (mRecords.size() <= 1); @@ -124,7 +124,7 @@ namespace ESM assert(mRecords.back().size == 0); } - void ESMWriter::endRecord(ESM::NAME name) + void ESMWriter::endRecord(NAME name) { RecordData rec = mRecords.back(); assert(rec.name == name); @@ -142,17 +142,17 @@ namespace ESM void ESMWriter::endRecord (uint32_t name) { - endRecord(ESM::NAME(name)); + endRecord(NAME(name)); } - void ESMWriter::writeHNString(ESM::NAME name, const std::string& data) + void ESMWriter::writeHNString(NAME name, const std::string& data) { startSubRecord(name); writeHString(data); endRecord(name); } - void ESMWriter::writeHNString(ESM::NAME name, const std::string& data, size_t size) + void ESMWriter::writeHNString(NAME name, const std::string& data, size_t size) { assert(data.size() <= size); startSubRecord(name); @@ -196,9 +196,9 @@ namespace ESM write("\0", 1); } - void ESMWriter::writeName(ESM::NAME name) + void ESMWriter::writeName(NAME name) { - write(name.mData, ESM::NAME::sCapacity); + write(name.mData, NAME::sCapacity); } void ESMWriter::write(const char* data, size_t size) diff --git a/components/esm3/esmwriter.hpp b/components/esm3/esmwriter.hpp index 8ee507f39d..264dc1c877 100644 --- a/components/esm3/esmwriter.hpp +++ b/components/esm3/esmwriter.hpp @@ -13,13 +13,14 @@ namespace ToUTF8 class Utf8Encoder; } -namespace ESM { +namespace ESM +{ class ESMWriter { struct RecordData { - ESM::NAME name; + NAME name; std::streampos position; uint32_t size; }; @@ -30,7 +31,7 @@ class ESMWriter unsigned int getVersion() const; - // Set various header data (ESM::Header::Data). All of the below functions must be called before writing, + // Set various header data (Header::Data). All of the below functions must be called before writing, // otherwise this data will be left uninitialized. void setVersion(unsigned int ver = 0x3fa66666); void setType(int type); @@ -56,27 +57,27 @@ class ESMWriter void close(); ///< \note Does not close the stream. - void writeHNString(ESM::NAME name, const std::string& data); - void writeHNString(ESM::NAME name, const std::string& data, size_t size); - void writeHNCString(ESM::NAME name, const std::string& data) + void writeHNString(NAME name, const std::string& data); + void writeHNString(NAME name, const std::string& data, size_t size); + void writeHNCString(NAME name, const std::string& data) { startSubRecord(name); writeHCString(data); endRecord(name); } - void writeHNOString(ESM::NAME name, const std::string& data) + void writeHNOString(NAME name, const std::string& data) { if (!data.empty()) writeHNString(name, data); } - void writeHNOCString(ESM::NAME name, const std::string& data) + void writeHNOCString(NAME name, const std::string& data) { if (!data.empty()) writeHNCString(name, data); } template - void writeHNT(ESM::NAME name, const T& data) + void writeHNT(NAME name, const T& data) { startSubRecord(name); writeT(data); @@ -84,7 +85,7 @@ class ESMWriter } template - void writeHNT(ESM::NAME name, const T (&data)[size]) + void writeHNT(NAME name, const T (&data)[size]) { startSubRecord(name); writeT(data); @@ -94,15 +95,15 @@ class ESMWriter // Prevent using writeHNT with strings. This already happened by accident and results in // state being discarded without any error on writing or reading it. :( // writeHNString and friends must be used instead. - void writeHNT(ESM::NAME name, const std::string& data) = delete; + void writeHNT(NAME name, const std::string& data) = delete; - void writeT(ESM::NAME data) = delete; + void writeT(NAME data) = delete; template - void writeHNT(ESM::NAME name, const T (&data)[size], int) = delete; + void writeHNT(NAME name, const T (&data)[size], int) = delete; template - void writeHNT(ESM::NAME name, const T& data, int size) + void writeHNT(NAME name, const T& data, int size) { startSubRecord(name); writeT(data, size); @@ -129,16 +130,16 @@ class ESMWriter write((char*)&data, size); } - void startRecord(ESM::NAME name, uint32_t flags = 0); + void startRecord(NAME name, uint32_t flags = 0); void startRecord(uint32_t name, uint32_t flags = 0); /// @note Sub-record hierarchies are not properly supported in ESMReader. This should be fixed later. - void startSubRecord(ESM::NAME name); - void endRecord(ESM::NAME name); + void startSubRecord(NAME name); + void endRecord(NAME name); void endRecord(uint32_t name); void writeFixedSizeString(const std::string& data, int size); void writeHString(const std::string& data); void writeHCString(const std::string& data); - void writeName(ESM::NAME data); + 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 a031e0f608..d432f789d3 100644 --- a/components/esm3/filter.cpp +++ b/components/esm3/filter.cpp @@ -4,9 +4,12 @@ #include "esmwriter.hpp" #include "components/esm/defs.hpp" -unsigned int ESM::Filter::sRecordId = REC_FILT; +namespace ESM +{ + +unsigned int Filter::sRecordId = REC_FILT; -void ESM::Filter::load (ESMReader& esm, bool &isDeleted) +void Filter::load (ESMReader& esm, bool &isDeleted) { isDeleted = false; mRecordFlags = esm.getRecordFlags(); @@ -17,16 +20,16 @@ void ESM::Filter::load (ESMReader& esm, bool &isDeleted) uint32_t name = esm.retSubName().toInt(); switch (name) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); break; - case ESM::fourCC("FILT"): + case fourCC("FILT"): mFilter = esm.getHString(); break; - case ESM::fourCC("DESC"): + case fourCC("DESC"): mDescription = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; @@ -37,7 +40,7 @@ void ESM::Filter::load (ESMReader& esm, bool &isDeleted) } } -void ESM::Filter::save (ESMWriter& esm, bool isDeleted) const +void Filter::save (ESMWriter& esm, bool isDeleted) const { esm.writeHNCString ("NAME", mId); @@ -51,8 +54,10 @@ void ESM::Filter::save (ESMWriter& esm, bool isDeleted) const esm.writeHNCString ("DESC", mDescription); } -void ESM::Filter::blank() +void Filter::blank() { mFilter.clear(); mDescription.clear(); } + +} diff --git a/components/esm3/fogstate.cpp b/components/esm3/fogstate.cpp index ff20f339f9..8b072d1ce9 100644 --- a/components/esm3/fogstate.cpp +++ b/components/esm3/fogstate.cpp @@ -10,6 +10,10 @@ #include "savedgame.hpp" +namespace ESM +{ +namespace +{ void convertFogOfWar(std::vector& imageData) { if (imageData.empty()) @@ -52,7 +56,9 @@ void convertFogOfWar(std::vector& imageData) imageData = std::vector(str.begin(), str.end()); } -void ESM::FogState::load (ESMReader &esm) +} + +void FogState::load (ESMReader &esm) { esm.getHNOT(mBounds, "BOUN"); esm.getHNOT(mNorthMarkerAngle, "ANGL"); @@ -76,7 +82,7 @@ void ESM::FogState::load (ESMReader &esm) } } -void ESM::FogState::save (ESMWriter &esm, bool interiorCell) const +void FogState::save (ESMWriter &esm, bool interiorCell) const { if (interiorCell) { @@ -92,3 +98,5 @@ void ESM::FogState::save (ESMWriter &esm, bool interiorCell) const esm.endRecord("FTEX"); } } + +} diff --git a/components/esm3/globalmap.cpp b/components/esm3/globalmap.cpp index 3005349d26..8eb4aebd8b 100644 --- a/components/esm3/globalmap.cpp +++ b/components/esm3/globalmap.cpp @@ -4,9 +4,12 @@ #include "esmwriter.hpp" #include "components/esm/defs.hpp" -unsigned int ESM::GlobalMap::sRecordId = ESM::REC_GMAP; +namespace ESM +{ + +unsigned int GlobalMap::sRecordId = REC_GMAP; -void ESM::GlobalMap::load (ESMReader &esm) +void GlobalMap::load (ESMReader &esm) { esm.getHNT(mBounds, "BNDS"); @@ -25,7 +28,7 @@ void ESM::GlobalMap::load (ESMReader &esm) } } -void ESM::GlobalMap::save (ESMWriter &esm) const +void GlobalMap::save (ESMWriter &esm) const { esm.writeHNT("BNDS", mBounds); @@ -41,3 +44,5 @@ void ESM::GlobalMap::save (ESMWriter &esm) const esm.endRecord("MRK_"); } } + +} diff --git a/components/esm3/globalscript.cpp b/components/esm3/globalscript.cpp index a8a8e79cf5..0eb1e31e9c 100644 --- a/components/esm3/globalscript.cpp +++ b/components/esm3/globalscript.cpp @@ -3,7 +3,10 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -void ESM::GlobalScript::load (ESMReader &esm) +namespace ESM +{ + +void GlobalScript::load (ESMReader &esm) { mId = esm.getHNString ("NAME"); @@ -18,7 +21,7 @@ void ESM::GlobalScript::load (ESMReader &esm) mTargetRef.load(esm, true, "FRMR"); } -void ESM::GlobalScript::save (ESMWriter &esm) const +void GlobalScript::save (ESMWriter &esm) const { esm.writeHNString ("NAME", mId); @@ -34,3 +37,5 @@ void ESM::GlobalScript::save (ESMWriter &esm) const mTargetRef.save (esm, true, "FRMR"); } } + +} diff --git a/components/esm3/inventorystate.cpp b/components/esm3/inventorystate.cpp index 980d67f7ef..b43a7b7233 100644 --- a/components/esm3/inventorystate.cpp +++ b/components/esm3/inventorystate.cpp @@ -5,7 +5,10 @@ #include -void ESM::InventoryState::load (ESMReader &esm) +namespace ESM +{ + +void InventoryState::load (ESMReader &esm) { // obsolete int index = 0; @@ -123,7 +126,7 @@ void ESM::InventoryState::load (ESMReader &esm) } } -void ESM::InventoryState::save (ESMWriter &esm) const +void InventoryState::save (ESMWriter &esm) const { int itemsCount = static_cast(mItems.size()); if (itemsCount > 0) @@ -170,3 +173,5 @@ void ESM::InventoryState::save (ESMWriter &esm) const if (mSelectedEnchantItem != -1) esm.writeHNT ("SELE", mSelectedEnchantItem); } + +} diff --git a/components/esm3/journalentry.cpp b/components/esm3/journalentry.cpp index 93011e581b..869a5df29e 100644 --- a/components/esm3/journalentry.cpp +++ b/components/esm3/journalentry.cpp @@ -3,7 +3,10 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -void ESM::JournalEntry::load (ESMReader &esm) +namespace ESM +{ + +void JournalEntry::load (ESMReader &esm) { esm.getHNOT (mType, "JETY"); mTopic = esm.getHNString ("YETO"); @@ -20,7 +23,7 @@ void ESM::JournalEntry::load (ESMReader &esm) mActorName = esm.getHNOString("ACT_"); } -void ESM::JournalEntry::save (ESMWriter &esm) const +void JournalEntry::save (ESMWriter &esm) const { esm.writeHNT ("JETY", mType); esm.writeHNString ("YETO", mTopic); @@ -36,3 +39,5 @@ void ESM::JournalEntry::save (ESMWriter &esm) const else if (mType==Type_Topic) esm.writeHNString ("ACT_", mActorName); } + +} diff --git a/components/esm3/loadacti.cpp b/components/esm3/loadacti.cpp index d57ef44be2..a8689bf78c 100644 --- a/components/esm3/loadacti.cpp +++ b/components/esm3/loadacti.cpp @@ -19,20 +19,20 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadalch.cpp b/components/esm3/loadalch.cpp index 7173090e4b..888e049079 100644 --- a/components/esm3/loadalch.cpp +++ b/components/esm3/loadalch.cpp @@ -22,30 +22,30 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("TEXT"): // not ITEX here for some reason + case fourCC("TEXT"): // not ITEX here for some reason mIcon = esm.getHString(); break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("ALDT"): + case fourCC("ALDT"): esm.getHTSized<12>(mData); hasData = true; break; - case ESM::fourCC("ENAM"): + case fourCC("ENAM"): mEffects.add(esm); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadappa.cpp b/components/esm3/loadappa.cpp index f29e5bf4f9..8bf87f1e69 100644 --- a/components/esm3/loadappa.cpp +++ b/components/esm3/loadappa.cpp @@ -20,27 +20,27 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("AADT"): + case fourCC("AADT"): esm.getHT(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadarmo.cpp b/components/esm3/loadarmo.cpp index 7176f82f1e..77cfd2ff39 100644 --- a/components/esm3/loadarmo.cpp +++ b/components/esm3/loadarmo.cpp @@ -52,33 +52,33 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("AODT"): + case fourCC("AODT"): esm.getHTSized<24>(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::fourCC("ENAM"): + case fourCC("ENAM"): mEnchant = esm.getHString(); break; - case ESM::fourCC("INDX"): + case fourCC("INDX"): mParts.add(esm); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadbody.cpp b/components/esm3/loadbody.cpp index 55aa5b7bf5..0275f3a63e 100644 --- a/components/esm3/loadbody.cpp +++ b/components/esm3/loadbody.cpp @@ -20,21 +20,21 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mRace = esm.getHString(); break; - case ESM::fourCC("BYDT"): + case fourCC("BYDT"): esm.getHTSized<4>(mData); hasData = true; break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadbook.cpp b/components/esm3/loadbook.cpp index 7e5f75e055..2845e67622 100644 --- a/components/esm3/loadbook.cpp +++ b/components/esm3/loadbook.cpp @@ -20,33 +20,33 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("BKDT"): + case fourCC("BKDT"): esm.getHTSized<20>(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::fourCC("ENAM"): + case fourCC("ENAM"): mEnchant = esm.getHString(); break; - case ESM::fourCC("TEXT"): + case fourCC("TEXT"): mText = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadbsgn.cpp b/components/esm3/loadbsgn.cpp index c894918bb2..5be175e72e 100644 --- a/components/esm3/loadbsgn.cpp +++ b/components/esm3/loadbsgn.cpp @@ -21,23 +21,23 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("TNAM"): + case fourCC("TNAM"): mTexture = esm.getHString(); break; - case ESM::fourCC("DESC"): + case fourCC("DESC"): mDescription = esm.getHString(); break; - case ESM::fourCC("NPCS"): + case fourCC("NPCS"): mPowers.add(esm); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadcell.cpp b/components/esm3/loadcell.cpp index b36f066501..9ab9eacba1 100644 --- a/components/esm3/loadcell.cpp +++ b/components/esm3/loadcell.cpp @@ -14,10 +14,12 @@ #include "components/esm/defs.hpp" #include "cellid.hpp" +namespace ESM +{ namespace { ///< Translate 8bit/24bit code (stored in refNum.mIndex) into a proper refNum - void adjustRefNum (ESM::RefNum& refNum, const ESM::ESMReader& reader) + void adjustRefNum (RefNum& refNum, const ESMReader& reader) { unsigned int local = (refNum.mIndex & 0xff000000) >> 24; @@ -37,6 +39,7 @@ namespace } } } +} namespace ESM { @@ -72,14 +75,14 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mName = esm.getHString(); break; - case ESM::fourCC("DATA"): + case fourCC("DATA"): esm.getHTSized<12>(mData); hasData = true; break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; @@ -97,7 +100,7 @@ namespace ESM if (mCellId.mPaged) { - mCellId.mWorldspace = ESM::CellId::sDefaultWorldspace; + mCellId.mWorldspace = CellId::sDefaultWorldspace; mCellId.mIndex.mX = mData.mX; mCellId.mIndex.mY = mData.mY; } @@ -119,13 +122,13 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::fourCC("INTV"): + case fourCC("INTV"): int waterl; esm.getHT(waterl); mWater = static_cast(waterl); mWaterInt = true; break; - case ESM::fourCC("WHGT"): + case fourCC("WHGT"): float waterLevel; esm.getHT(waterLevel); mWaterInt = false; @@ -138,17 +141,17 @@ namespace ESM else mWater = waterLevel; break; - case ESM::fourCC("AMBI"): + case fourCC("AMBI"): esm.getHT(mAmbi); mHasAmbi = true; break; - case ESM::fourCC("RGNN"): + case fourCC("RGNN"): mRegion = esm.getHString(); break; - case ESM::fourCC("NAM5"): + case fourCC("NAM5"): esm.getHT(mMapColor); break; - case ESM::fourCC("NAM0"): + case fourCC("NAM0"): esm.getHT(mRefNumCounter); break; default: diff --git a/components/esm3/loadclas.cpp b/components/esm3/loadclas.cpp index 718ba6c3ac..9b34fbd541 100644 --- a/components/esm3/loadclas.cpp +++ b/components/esm3/loadclas.cpp @@ -50,23 +50,23 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("CLDT"): + case fourCC("CLDT"): esm.getHTSized<60>(mData); if (mData.mIsPlayable > 1) esm.fail("Unknown bool value"); hasData = true; break; - case ESM::fourCC("DESC"): + case fourCC("DESC"): mDescription = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadclot.cpp b/components/esm3/loadclot.cpp index 5b6fa4210b..ea87d1566b 100644 --- a/components/esm3/loadclot.cpp +++ b/components/esm3/loadclot.cpp @@ -22,33 +22,33 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("CTDT"): + case fourCC("CTDT"): esm.getHTSized<12>(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::fourCC("ENAM"): + case fourCC("ENAM"): mEnchant = esm.getHString(); break; - case ESM::fourCC("INDX"): + case fourCC("INDX"): mParts.add(esm); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadcont.cpp b/components/esm3/loadcont.cpp index 6477bb9301..b74f9f2ba2 100644 --- a/components/esm3/loadcont.cpp +++ b/components/esm3/loadcont.cpp @@ -44,21 +44,21 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("CNDT"): + case fourCC("CNDT"): esm.getHTSized<4>(mWeight); hasWeight = true; break; - case ESM::fourCC("FLAG"): + case fourCC("FLAG"): esm.getHTSized<4>(mFlags); if (mFlags & 0xf4) esm.fail("Unknown flags"); @@ -66,13 +66,13 @@ namespace ESM esm.fail("Flag 8 not set"); hasFlags = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("NPCO"): + case fourCC("NPCO"): mInventory.add(esm); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadcrea.cpp b/components/esm3/loadcrea.cpp index f82c488c63..c9d4e6ad14 100644 --- a/components/esm3/loadcrea.cpp +++ b/components/esm3/loadcrea.cpp @@ -6,7 +6,8 @@ #include "esmwriter.hpp" #include "components/esm/defs.hpp" -namespace ESM { +namespace ESM +{ unsigned int Creature::sRecordId = REC_CREA; @@ -33,47 +34,47 @@ namespace ESM { esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("CNAM"): + case fourCC("CNAM"): mOriginal = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("NPDT"): + case fourCC("NPDT"): esm.getHTSized<96>(mData); hasNpdt = true; break; - case ESM::fourCC("FLAG"): + case fourCC("FLAG"): int flags; esm.getHT(flags); mFlags = flags & 0xFF; mBloodType = ((flags >> 8) & 0xFF) >> 2; hasFlags = true; break; - case ESM::fourCC("XSCL"): + case fourCC("XSCL"): esm.getHT(mScale); break; - case ESM::fourCC("NPCO"): + case fourCC("NPCO"): mInventory.add(esm); break; - case ESM::fourCC("NPCS"): + case fourCC("NPCS"): mSpells.add(esm); break; - case ESM::fourCC("AIDT"): + case fourCC("AIDT"): esm.getHExact(&mAiData, sizeof(mAiData)); break; - case ESM::fourCC("DODT"): - case ESM::fourCC("DNAM"): + case fourCC("DODT"): + case fourCC("DNAM"): mTransport.add(esm); break; case AI_Wander: @@ -84,11 +85,11 @@ namespace ESM { case AI_CNDT: mAiPackage.add(esm); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; - case ESM::fourCC("INDX"): + case fourCC("INDX"): // seems to occur only in .ESS files, unsure of purpose int index; esm.getHT(index); diff --git a/components/esm3/loaddial.cpp b/components/esm3/loaddial.cpp index a4b21cd1b3..b3b42b9989 100644 --- a/components/esm3/loaddial.cpp +++ b/components/esm3/loaddial.cpp @@ -30,7 +30,7 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::fourCC("DATA"): + case fourCC("DATA"): { esm.getSubHeader(); int size = esm.getSubSize(); @@ -44,7 +44,7 @@ namespace ESM } break; } - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); mType = Unknown; isDeleted = true; @@ -76,7 +76,7 @@ namespace ESM void Dialogue::readInfo(ESMReader &esm, bool merge) { - ESM::DialInfo info; + DialInfo info; bool isDeleted = false; info.load(esm, isDeleted); diff --git a/components/esm3/loaddial.hpp b/components/esm3/loaddial.hpp index 7adc8b1cf8..7998623998 100644 --- a/components/esm3/loaddial.hpp +++ b/components/esm3/loaddial.hpp @@ -61,7 +61,7 @@ struct Dialogue /// Read the next info record /// @param merge Merge with existing list, or just push each record to the end of the list? - void readInfo (ESM::ESMReader& esm, bool merge); + void readInfo (ESMReader& esm, bool merge); void blank(); ///< Set record to default state (does not touch the ID and does not change the type). diff --git a/components/esm3/loaddoor.cpp b/components/esm3/loaddoor.cpp index e059a1dc05..c866fc96c0 100644 --- a/components/esm3/loaddoor.cpp +++ b/components/esm3/loaddoor.cpp @@ -19,26 +19,26 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("SNAM"): + case fourCC("SNAM"): mOpenSound = esm.getHString(); break; - case ESM::fourCC("ANAM"): + case fourCC("ANAM"): mCloseSound = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadench.cpp b/components/esm3/loadench.cpp index 4280b3a8af..533ba154b7 100644 --- a/components/esm3/loadench.cpp +++ b/components/esm3/loadench.cpp @@ -21,18 +21,18 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("ENDT"): + case fourCC("ENDT"): esm.getHTSized<16>(mData); hasData = true; break; - case ESM::fourCC("ENAM"): + case fourCC("ENAM"): mEffects.add(esm); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadfact.cpp b/components/esm3/loadfact.cpp index 9fc5410164..513f8c3199 100644 --- a/components/esm3/loadfact.cpp +++ b/components/esm3/loadfact.cpp @@ -43,25 +43,25 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("RNAM"): + case fourCC("RNAM"): if (rankCounter >= 10) esm.fail("Rank out of range"); mRanks[rankCounter++] = esm.getHString(); break; - case ESM::fourCC("FADT"): + case fourCC("FADT"): esm.getHTSized<240>(mData); if (mData.mIsHidden > 1) esm.fail("Unknown flag!"); hasData = true; break; - case ESM::fourCC("ANAM"): + case fourCC("ANAM"): { std::string faction = esm.getHString(); int reaction; @@ -69,7 +69,7 @@ namespace ESM mReactions[faction] = reaction; break; } - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadfact.hpp b/components/esm3/loadfact.hpp index da01c004e9..d47ff5a43e 100644 --- a/components/esm3/loadfact.hpp +++ b/components/esm3/loadfact.hpp @@ -45,7 +45,7 @@ struct Faction RankData mRankData[10]; int mSkills[7]; // IDs of skills this faction require - // Each element will either contain an ESM::Skill index, or -1. + // Each element will either contain an Skill index, or -1. int mIsHidden; // 1 - hidden from player diff --git a/components/esm3/loadglob.cpp b/components/esm3/loadglob.cpp index fd4ee05665..cc2188a5b5 100644 --- a/components/esm3/loadglob.cpp +++ b/components/esm3/loadglob.cpp @@ -22,7 +22,7 @@ namespace ESM } else { - mValue.read (esm, ESM::Variant::Format_Global); + mValue.read (esm, Variant::Format_Global); } } @@ -36,13 +36,13 @@ namespace ESM } else { - mValue.write (esm, ESM::Variant::Format_Global); + mValue.write (esm, Variant::Format_Global); } } void Global::blank() { - mValue.setType (ESM::VT_None); + mValue.setType (VT_None); } bool operator== (const Global& left, const Global& right) diff --git a/components/esm3/loadgmst.cpp b/components/esm3/loadgmst.cpp index 1bcf6a1fa4..31439dc268 100644 --- a/components/esm3/loadgmst.cpp +++ b/components/esm3/loadgmst.cpp @@ -14,18 +14,18 @@ namespace ESM mRecordFlags = esm.getRecordFlags(); mId = esm.getHNString("NAME"); - mValue.read (esm, ESM::Variant::Format_Gmst); + mValue.read (esm, Variant::Format_Gmst); } void GameSetting::save (ESMWriter &esm, bool /*isDeleted*/) const { esm.writeHNCString("NAME", mId); - mValue.write (esm, ESM::Variant::Format_Gmst); + mValue.write (esm, Variant::Format_Gmst); } void GameSetting::blank() { - mValue.setType (ESM::VT_None); + mValue.setType (VT_None); } bool operator== (const GameSetting& left, const GameSetting& right) diff --git a/components/esm3/loadinfo.cpp b/components/esm3/loadinfo.cpp index fb32f80188..0c7c4db61a 100644 --- a/components/esm3/loadinfo.cpp +++ b/components/esm3/loadinfo.cpp @@ -25,19 +25,19 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::fourCC("DATA"): + case fourCC("DATA"): esm.getHTSized<12>(mData); break; - case ESM::fourCC("ONAM"): + case fourCC("ONAM"): mActor = esm.getHString(); break; - case ESM::fourCC("RNAM"): + case fourCC("RNAM"): mRace = esm.getHString(); break; - case ESM::fourCC("CNAM"): + case fourCC("CNAM"): mClass = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): { mFaction = esm.getHString(); if (mFaction == "FFFF") @@ -46,19 +46,19 @@ namespace ESM } break; } - case ESM::fourCC("ANAM"): + case fourCC("ANAM"): mCell = esm.getHString(); break; - case ESM::fourCC("DNAM"): + case fourCC("DNAM"): mPcFaction = esm.getHString(); break; - case ESM::fourCC("SNAM"): + case fourCC("SNAM"): mSound = esm.getHString(); break; - case ESM::SREC_NAME: + case SREC_NAME: mResponse = esm.getHString(); break; - case ESM::fourCC("SCVR"): + case fourCC("SCVR"): { SelectStruct ss; ss.mSelectRule = esm.getHString(); @@ -66,22 +66,22 @@ namespace ESM mSelects.push_back(ss); break; } - case ESM::fourCC("BNAM"): + case fourCC("BNAM"): mResultScript = esm.getHString(); break; - case ESM::fourCC("QSTN"): + case fourCC("QSTN"): mQuestStatus = QS_Name; esm.skipRecord(); break; - case ESM::fourCC("QSTF"): + case fourCC("QSTF"): mQuestStatus = QS_Finished; esm.skipRecord(); break; - case ESM::fourCC("QSTR"): + case fourCC("QSTR"): mQuestStatus = QS_Restart; esm.skipRecord(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadingr.cpp b/components/esm3/loadingr.cpp index d7317a8dc4..ea10da42b9 100644 --- a/components/esm3/loadingr.cpp +++ b/components/esm3/loadingr.cpp @@ -20,27 +20,27 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("IRDT"): + case fourCC("IRDT"): esm.getHTSized<56>(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadland.cpp b/components/esm3/loadland.cpp index f9563411a3..71b020f767 100644 --- a/components/esm3/loadland.cpp +++ b/components/esm3/loadland.cpp @@ -46,7 +46,7 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::fourCC("INTV"): + case fourCC("INTV"): esm.getSubHeader(); if (esm.getSubSize() != 8) esm.fail("Subrecord size is not equal to 8"); @@ -54,10 +54,10 @@ namespace ESM esm.getT(mY); hasLocation = true; break; - case ESM::fourCC("DATA"): + case fourCC("DATA"): esm.getHT(mFlags); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; @@ -82,23 +82,23 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::fourCC("VNML"): + case fourCC("VNML"): esm.skipHSub(); mDataTypes |= DATA_VNML; break; - case ESM::fourCC("VHGT"): + case fourCC("VHGT"): esm.skipHSub(); mDataTypes |= DATA_VHGT; break; - case ESM::fourCC("WNAM"): + case fourCC("WNAM"): esm.getHExact(mWnam, sizeof(mWnam)); mDataTypes |= DATA_WNAM; break; - case ESM::fourCC("VCLR"): + case fourCC("VCLR"): esm.skipHSub(); mDataTypes |= DATA_VCLR; break; - case ESM::fourCC("VTEX"): + case fourCC("VTEX"): esm.skipHSub(); mDataTypes |= DATA_VTEX; break; @@ -162,12 +162,12 @@ namespace ESM signed char wnam[LAND_GLOBAL_MAP_LOD_SIZE]; constexpr float max = std::numeric_limits::max(); constexpr float min = std::numeric_limits::min(); - constexpr float vertMult = static_cast(ESM::Land::LAND_SIZE - 1) / LAND_GLOBAL_MAP_LOD_SIZE_SQRT; + constexpr float vertMult = static_cast(Land::LAND_SIZE - 1) / LAND_GLOBAL_MAP_LOD_SIZE_SQRT; for (int row = 0; row < LAND_GLOBAL_MAP_LOD_SIZE_SQRT; ++row) { for (int col = 0; col < LAND_GLOBAL_MAP_LOD_SIZE_SQRT; ++col) { - float height = mLandData->mHeights[int(row * vertMult) * ESM::Land::LAND_SIZE + int(col * vertMult)]; + float height = mLandData->mHeights[int(row * vertMult) * Land::LAND_SIZE + int(col * vertMult)]; height /= height > 0 ? 128.f : 16.f; height = std::clamp(height, min, max); wnam[row * LAND_GLOBAL_MAP_LOD_SIZE_SQRT + col] = static_cast(height); @@ -246,7 +246,7 @@ namespace ESM return; } - ESM::ESMReader reader; + ESMReader reader; reader.restoreContext(mContext); if (reader.isNextSub("VNML")) { @@ -306,7 +306,7 @@ namespace ESM } } - bool Land::condLoad(ESM::ESMReader& reader, int flags, int& targetFlags, int dataFlag, void *ptr, unsigned int size) const + bool Land::condLoad(ESMReader& reader, int flags, int& targetFlags, int dataFlag, void *ptr, unsigned int size) const { if ((targetFlags & dataFlag) == 0 && (flags & dataFlag) != 0) { reader.getHExact(ptr, size); diff --git a/components/esm3/loadland.hpp b/components/esm3/loadland.hpp index 1244a955cf..28bd36b8c7 100644 --- a/components/esm3/loadland.hpp +++ b/components/esm3/loadland.hpp @@ -109,7 +109,7 @@ struct Land // 24-bit normals, these aren't always correct though. Edge and corner normals may be garbage. VNML mNormals[LAND_NUM_VERTS * 3]; - // 2D array of texture indices. An index can be used to look up an ESM::LandTexture, + // 2D array of texture indices. An index can be used to look up an LandTexture, // but to do so you must subtract 1 from the index first! // An index of 0 indicates the default texture. uint16_t mTextures[LAND_NUM_TEXTURES]; @@ -179,7 +179,7 @@ struct Land /// Loads data and marks it as loaded /// \return true if data is actually loaded from file, false otherwise /// including the case when data is already loaded - bool condLoad(ESM::ESMReader& reader, int flags, int& targetFlags, int dataFlag, void *ptr, unsigned int size) const; + bool condLoad(ESMReader& reader, int flags, int& targetFlags, int dataFlag, void *ptr, unsigned int size) const; mutable LandData *mLandData; }; diff --git a/components/esm3/loadlevlist.cpp b/components/esm3/loadlevlist.cpp index ace5304152..51055103bf 100644 --- a/components/esm3/loadlevlist.cpp +++ b/components/esm3/loadlevlist.cpp @@ -6,7 +6,7 @@ namespace ESM { - void LevelledListBase::load(ESMReader& esm, ESM::NAME recName, bool& isDeleted) + void LevelledListBase::load(ESMReader& esm, NAME recName, bool& isDeleted) { isDeleted = false; mRecordFlags = esm.getRecordFlags(); @@ -18,17 +18,17 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("DATA"): + case fourCC("DATA"): esm.getHT(mFlags); break; - case ESM::fourCC("NNAM"): + case fourCC("NNAM"): esm.getHT(mChanceNone); break; - case ESM::fourCC("INDX"): + case fourCC("INDX"): { int length = 0; esm.getHT(length); @@ -50,7 +50,7 @@ namespace ESM hasList = true; break; } - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; @@ -75,7 +75,7 @@ namespace ESM esm.fail("Missing NAME subrecord"); } - void LevelledListBase::save(ESMWriter& esm, ESM::NAME recName, bool isDeleted) const + void LevelledListBase::save(ESMWriter& esm, NAME recName, bool isDeleted) const { esm.writeHNCString("NAME", mId); diff --git a/components/esm3/loadlevlist.hpp b/components/esm3/loadlevlist.hpp index 3e75ad7c70..d73003fdda 100644 --- a/components/esm3/loadlevlist.hpp +++ b/components/esm3/loadlevlist.hpp @@ -36,8 +36,8 @@ struct LevelledListBase std::vector mList; - void load(ESMReader& esm, ESM::NAME recName, bool& isDeleted); - void save(ESMWriter& esm, ESM::NAME recName, bool isDeleted) const; + void load(ESMReader& esm, NAME recName, bool& isDeleted); + void save(ESMWriter& esm, NAME recName, bool isDeleted) const; void blank(); ///< Set record to default state (does not touch the ID). @@ -53,7 +53,7 @@ struct CustomLevelledListBase : LevelledListBase struct CreatureLevList : CustomLevelledListBase { /// Record name used to read references. - static constexpr ESM::NAME sRecName {"CNAM"}; + static constexpr NAME sRecName {"CNAM"}; static constexpr RecNameInts sRecordId = RecNameInts::REC_LEVC; /// Return a string descriptor for this record type. Currently used for debugging / error logs only. static std::string_view getRecordType() { return "CreatureLevList"; } @@ -70,7 +70,7 @@ struct CreatureLevList : CustomLevelledListBase struct ItemLevList : CustomLevelledListBase { /// Record name used to read references. - static constexpr ESM::NAME sRecName {"INAM"}; + static constexpr NAME sRecName {"INAM"}; static constexpr RecNameInts sRecordId = RecNameInts::REC_LEVI; /// Return a string descriptor for this record type. Currently used for debugging / error logs only. static std::string_view getRecordType() { return "ItemLevList"; } diff --git a/components/esm3/loadligh.cpp b/components/esm3/loadligh.cpp index 7b3c6e8787..da45674e85 100644 --- a/components/esm3/loadligh.cpp +++ b/components/esm3/loadligh.cpp @@ -20,30 +20,30 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::fourCC("LHDT"): + case fourCC("LHDT"): esm.getHTSized<24>(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("SNAM"): + case fourCC("SNAM"): mSound = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadlock.cpp b/components/esm3/loadlock.cpp index 0bdcbba635..e298001cb6 100644 --- a/components/esm3/loadlock.cpp +++ b/components/esm3/loadlock.cpp @@ -20,27 +20,27 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("LKDT"): + case fourCC("LKDT"): esm.getHTSized<16>(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadltex.cpp b/components/esm3/loadltex.cpp index de5eb53e56..26ce41c5b3 100644 --- a/components/esm3/loadltex.cpp +++ b/components/esm3/loadltex.cpp @@ -19,18 +19,18 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("INTV"): + case fourCC("INTV"): esm.getHT(mIndex); hasIndex = true; break; - case ESM::fourCC("DATA"): + case fourCC("DATA"): mTexture = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadmgef.cpp b/components/esm3/loadmgef.cpp index b528e8bf9a..9707f2f255 100644 --- a/components/esm3/loadmgef.cpp +++ b/components/esm3/loadmgef.cpp @@ -6,9 +6,11 @@ #include "esmwriter.hpp" #include "components/esm/defs.hpp" +namespace ESM +{ namespace { - static const char *sIds[ESM::MagicEffect::Length] = + static const char *sIds[MagicEffect::Length] = { "WaterBreathing", "SwiftSwim", @@ -181,6 +183,7 @@ namespace 0x11c8, 0x1048, 0x1048, 0x1048, 0x1048, 0x1048, 0x1048 }; } +} namespace ESM { @@ -211,37 +214,37 @@ void MagicEffect::load(ESMReader &esm, bool &isDeleted) esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::fourCC("PTEX"): + case fourCC("PTEX"): mParticle = esm.getHString(); break; - case ESM::fourCC("BSND"): + case fourCC("BSND"): mBoltSound = esm.getHString(); break; - case ESM::fourCC("CSND"): + case fourCC("CSND"): mCastSound = esm.getHString(); break; - case ESM::fourCC("HSND"): + case fourCC("HSND"): mHitSound = esm.getHString(); break; - case ESM::fourCC("ASND"): + case fourCC("ASND"): mAreaSound = esm.getHString(); break; - case ESM::fourCC("CVFX"): + case fourCC("CVFX"): mCasting = esm.getHString(); break; - case ESM::fourCC("BVFX"): + case fourCC("BVFX"): mBolt = esm.getHString(); break; - case ESM::fourCC("HVFX"): + case fourCC("HVFX"): mHit = esm.getHString(); break; - case ESM::fourCC("AVFX"): + case fourCC("AVFX"): mArea = esm.getHString(); break; - case ESM::fourCC("DESC"): + case fourCC("DESC"): mDescription = esm.getHString(); break; default: diff --git a/components/esm3/loadmgef.hpp b/components/esm3/loadmgef.hpp index 00cadf99c0..64d89dab39 100644 --- a/components/esm3/loadmgef.hpp +++ b/components/esm3/loadmgef.hpp @@ -83,8 +83,8 @@ struct MagicEffect MEDTstruct mData; std::string mIcon, mParticle; // Textures - std::string mCasting, mHit, mArea; // ESM::Static - std::string mBolt; // ESM::Weapon + std::string mCasting, mHit, mArea; // Static + std::string mBolt; // Weapon std::string mCastSound, mBoltSound, mHitSound, mAreaSound; // Sounds std::string mDescription; diff --git a/components/esm3/loadmisc.cpp b/components/esm3/loadmisc.cpp index bbf1ac0635..db6a050a24 100644 --- a/components/esm3/loadmisc.cpp +++ b/components/esm3/loadmisc.cpp @@ -20,27 +20,27 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("MCDT"): + case fourCC("MCDT"): esm.getHTSized<12>(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadnpc.cpp b/components/esm3/loadnpc.cpp index 338b453a5a..6c0b8d0a68 100644 --- a/components/esm3/loadnpc.cpp +++ b/components/esm3/loadnpc.cpp @@ -28,35 +28,35 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("RNAM"): + case fourCC("RNAM"): mRace = esm.getHString(); break; - case ESM::fourCC("CNAM"): + case fourCC("CNAM"): mClass = esm.getHString(); break; - case ESM::fourCC("ANAM"): + case fourCC("ANAM"): mFaction = esm.getHString(); break; - case ESM::fourCC("BNAM"): + case fourCC("BNAM"): mHead = esm.getHString(); break; - case ESM::fourCC("KNAM"): + case fourCC("KNAM"): mHair = esm.getHString(); break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("NPDT"): + case fourCC("NPDT"): hasNpdt = true; esm.getSubHeader(); if (esm.getSubSize() == 52) @@ -83,24 +83,24 @@ namespace ESM else esm.fail("NPC_NPDT must be 12 or 52 bytes long"); break; - case ESM::fourCC("FLAG"): + case fourCC("FLAG"): hasFlags = true; int flags; esm.getHT(flags); mFlags = flags & 0xFF; mBloodType = ((flags >> 8) & 0xFF) >> 2; break; - case ESM::fourCC("NPCS"): + case fourCC("NPCS"): mSpells.add(esm); break; - case ESM::fourCC("NPCO"): + case fourCC("NPCO"): mInventory.add(esm); break; - case ESM::fourCC("AIDT"): + case fourCC("AIDT"): esm.getHExact(&mAiData, sizeof(mAiData)); break; - case ESM::fourCC("DODT"): - case ESM::fourCC("DNAM"): + case fourCC("DODT"): + case fourCC("DNAM"): mTransport.add(esm); break; case AI_Wander: @@ -111,7 +111,7 @@ namespace ESM case AI_CNDT: mAiPackage.add(esm); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadnpc.hpp b/components/esm3/loadnpc.hpp index 24752beb11..b215a346bc 100644 --- a/components/esm3/loadnpc.hpp +++ b/components/esm3/loadnpc.hpp @@ -11,7 +11,8 @@ #include "loadskil.hpp" #include "transport.hpp" -namespace ESM { +namespace ESM +{ class ESMReader; class ESMWriter; diff --git a/components/esm3/loadpgrd.cpp b/components/esm3/loadpgrd.cpp index ed2ab2c5d3..f9204175fb 100644 --- a/components/esm3/loadpgrd.cpp +++ b/components/esm3/loadpgrd.cpp @@ -48,14 +48,14 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mCell = esm.getHString(); break; - case ESM::fourCC("DATA"): + case fourCC("DATA"): esm.getHTSized<12>(mData); hasData = true; break; - case ESM::fourCC("PGRP"): + case fourCC("PGRP"): { esm.getSubHeader(); int size = esm.getSubSize(); @@ -76,7 +76,7 @@ namespace ESM } break; } - case ESM::fourCC("PGRC"): + case fourCC("PGRC"): { esm.getSubHeader(); int size = esm.getSubSize(); @@ -113,7 +113,7 @@ namespace ESM } break; } - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadprob.cpp b/components/esm3/loadprob.cpp index f084732775..6299286ea8 100644 --- a/components/esm3/loadprob.cpp +++ b/components/esm3/loadprob.cpp @@ -20,27 +20,27 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("PBDT"): + case fourCC("PBDT"): esm.getHTSized<16>(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadrace.cpp b/components/esm3/loadrace.cpp index 9520b792ed..e2b5a1fcf8 100644 --- a/components/esm3/loadrace.cpp +++ b/components/esm3/loadrace.cpp @@ -32,24 +32,24 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("RADT"): + case fourCC("RADT"): esm.getHTSized<140>(mData); hasData = true; break; - case ESM::fourCC("DESC"): + case fourCC("DESC"): mDescription = esm.getHString(); break; - case ESM::fourCC("NPCS"): + case fourCC("NPCS"): mPowers.add(esm); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadregn.cpp b/components/esm3/loadregn.cpp index e2682e644e..99f09b7fad 100644 --- a/components/esm3/loadregn.cpp +++ b/components/esm3/loadregn.cpp @@ -19,14 +19,14 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("WEAT"): + case fourCC("WEAT"): { esm.getSubHeader(); if (esm.getVer() == VER_12) @@ -55,13 +55,13 @@ namespace ESM } break; } - case ESM::fourCC("BNAM"): + case fourCC("BNAM"): mSleepList = esm.getHString(); break; - case ESM::fourCC("CNAM"): + case fourCC("CNAM"): esm.getHT(mMapColor); break; - case ESM::fourCC("SNAM"): + case fourCC("SNAM"): { esm.getSubHeader(); SoundRef sr; @@ -70,7 +70,7 @@ namespace ESM mSoundList.push_back(sr); break; } - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadrepa.cpp b/components/esm3/loadrepa.cpp index 16dd296a25..8d09083cad 100644 --- a/components/esm3/loadrepa.cpp +++ b/components/esm3/loadrepa.cpp @@ -20,27 +20,27 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("RIDT"): + case fourCC("RIDT"): esm.getHTSized<16>(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadscpt.cpp b/components/esm3/loadscpt.cpp index b97a148963..1e5d342fa3 100644 --- a/components/esm3/loadscpt.cpp +++ b/components/esm3/loadscpt.cpp @@ -95,7 +95,7 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::fourCC("SCHD"): + case fourCC("SCHD"): { esm.getSubHeader(); mId = esm.getString(32); @@ -104,11 +104,11 @@ namespace ESM hasHeader = true; break; } - case ESM::fourCC("SCVR"): + case fourCC("SCVR"): // list of local variables loadSCVR(esm); break; - case ESM::fourCC("SCDT"): + case fourCC("SCDT"): { // compiled script esm.getSubHeader(); @@ -127,10 +127,10 @@ namespace ESM esm.getExact(mScriptData.data(), mScriptData.size()); break; } - case ESM::fourCC("SCTX"): + case fourCC("SCTX"): mScriptText = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadskil.cpp b/components/esm3/loadskil.cpp index f7bb0c49d6..86ffda4fd9 100644 --- a/components/esm3/loadskil.cpp +++ b/components/esm3/loadskil.cpp @@ -139,15 +139,15 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::fourCC("INDX"): + case fourCC("INDX"): esm.getHT(mIndex); hasIndex = true; break; - case ESM::fourCC("SKDT"): + case fourCC("SKDT"): esm.getHTSized<24>(mData); hasData = true; break; - case ESM::fourCC("DESC"): + case fourCC("DESC"): mDescription = esm.getHString(); break; default: diff --git a/components/esm3/loadskil.hpp b/components/esm3/loadskil.hpp index cd4cad6a71..58e1fa6deb 100644 --- a/components/esm3/loadskil.hpp +++ b/components/esm3/loadskil.hpp @@ -6,7 +6,8 @@ #include "components/esm/defs.hpp" -namespace ESM { +namespace ESM +{ class ESMReader; class ESMWriter; diff --git a/components/esm3/loadsndg.cpp b/components/esm3/loadsndg.cpp index 5519d835b4..9113d1ac3d 100644 --- a/components/esm3/loadsndg.cpp +++ b/components/esm3/loadsndg.cpp @@ -20,21 +20,21 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("DATA"): + case fourCC("DATA"): esm.getHTSized<4>(mType); hasData = true; break; - case ESM::fourCC("CNAM"): + case fourCC("CNAM"): mCreature = esm.getHString(); break; - case ESM::fourCC("SNAM"): + case fourCC("SNAM"): mSound = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadsoun.cpp b/components/esm3/loadsoun.cpp index 0ddda2d6b2..9904d5d0fb 100644 --- a/components/esm3/loadsoun.cpp +++ b/components/esm3/loadsoun.cpp @@ -20,18 +20,18 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mSound = esm.getHString(); break; - case ESM::fourCC("DATA"): + case fourCC("DATA"): esm.getHTSized<3>(mData); hasData = true; break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadspel.cpp b/components/esm3/loadspel.cpp index f2891c2b6c..bb0c866c5e 100644 --- a/components/esm3/loadspel.cpp +++ b/components/esm3/loadspel.cpp @@ -22,23 +22,23 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("SPDT"): + case fourCC("SPDT"): esm.getHTSized<12>(mData); hasData = true; break; - case ESM::fourCC("ENAM"): + case fourCC("ENAM"): ENAMstruct s; esm.getHTSized<24>(s); mEffects.mList.push_back(s); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadsscr.cpp b/components/esm3/loadsscr.cpp index 03c5b49380..3f7a4fe19d 100644 --- a/components/esm3/loadsscr.cpp +++ b/components/esm3/loadsscr.cpp @@ -20,15 +20,15 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("DATA"): + case fourCC("DATA"): mData = esm.getHString(); hasData = true; break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadstat.cpp b/components/esm3/loadstat.cpp index fd557d37d5..cb7c9fa2df 100644 --- a/components/esm3/loadstat.cpp +++ b/components/esm3/loadstat.cpp @@ -12,8 +12,8 @@ namespace ESM { isDeleted = false; mRecordFlags = esm.getRecordFlags(); - //bool isBlocked = (mRecordFlags & ESM::FLAG_Blocked) != 0; - //bool isPersistent = (mRecordFlags & ESM::FLAG_Persistent) != 0; + //bool isBlocked = (mRecordFlags & FLAG_Blocked) != 0; + //bool isPersistent = (mRecordFlags & FLAG_Persistent) != 0; bool hasName = false; while (esm.hasMoreSubs()) @@ -21,14 +21,14 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadstat.hpp b/components/esm3/loadstat.hpp index 26d8fda3a8..71f927d21c 100644 --- a/components/esm3/loadstat.hpp +++ b/components/esm3/loadstat.hpp @@ -3,7 +3,8 @@ #include -namespace ESM { +namespace ESM +{ class ESMReader; class ESMWriter; diff --git a/components/esm3/loadtes3.cpp b/components/esm3/loadtes3.cpp index e39d65298c..0c3ccf232e 100644 --- a/components/esm3/loadtes3.cpp +++ b/components/esm3/loadtes3.cpp @@ -5,9 +5,12 @@ #include "esmwriter.hpp" #include "components/esm/defs.hpp" -void ESM::Header::blank() +namespace ESM { - mData.version = ESM::VER_13; + +void Header::blank() +{ + mData.version = VER_13; mData.type = 0; mData.author.clear(); mData.desc.clear(); @@ -16,7 +19,7 @@ void ESM::Header::blank() mMaster.clear(); } -void ESM::Header::load (ESMReader &esm) +void Header::load (ESMReader &esm) { if (esm.isNextSub ("FORM")) { @@ -65,7 +68,7 @@ void ESM::Header::load (ESMReader &esm) } } -void ESM::Header::save (ESMWriter &esm) +void Header::save (ESMWriter &esm) { if (mFormat>0) esm.writeHNT ("FORM", mFormat); @@ -84,3 +87,5 @@ void ESM::Header::save (ESMWriter &esm) esm.writeHNT ("DATA", data.size); } } + +} diff --git a/components/esm3/loadweap.cpp b/components/esm3/loadweap.cpp index 452036cb95..696194f969 100644 --- a/components/esm3/loadweap.cpp +++ b/components/esm3/loadweap.cpp @@ -20,30 +20,30 @@ namespace ESM esm.getSubName(); switch (esm.retSubName().toInt()) { - case ESM::SREC_NAME: + case SREC_NAME: mId = esm.getHString(); hasName = true; break; - case ESM::fourCC("MODL"): + case fourCC("MODL"): mModel = esm.getHString(); break; - case ESM::fourCC("FNAM"): + case fourCC("FNAM"): mName = esm.getHString(); break; - case ESM::fourCC("WPDT"): + case fourCC("WPDT"): esm.getHTSized<32>(mData); hasData = true; break; - case ESM::fourCC("SCRI"): + case fourCC("SCRI"): mScript = esm.getHString(); break; - case ESM::fourCC("ITEX"): + case fourCC("ITEX"): mIcon = esm.getHString(); break; - case ESM::fourCC("ENAM"): + case fourCC("ENAM"): mEnchant = esm.getHString(); break; - case ESM::SREC_DELE: + case SREC_DELE: esm.skipHSub(); isDeleted = true; break; diff --git a/components/esm3/loadweap.hpp b/components/esm3/loadweap.hpp index 98ba57b8b8..e75e12d685 100644 --- a/components/esm3/loadweap.hpp +++ b/components/esm3/loadweap.hpp @@ -105,7 +105,7 @@ struct WeaponType std::string mSoundId; std::string mAttachBone; std::string mSheathingBone; - ESM::Skill::SkillEnum mSkill; + Skill::SkillEnum mSkill; Class mWeaponClass; int mAmmoType; int mFlags; diff --git a/components/esm3/locals.cpp b/components/esm3/locals.cpp index 4149695fe9..7db0e544ec 100644 --- a/components/esm3/locals.cpp +++ b/components/esm3/locals.cpp @@ -3,7 +3,10 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -void ESM::Locals::load (ESMReader &esm) +namespace ESM +{ + +void Locals::load (ESMReader &esm) { while (esm.isNextSub ("LOCA")) { @@ -16,7 +19,7 @@ void ESM::Locals::load (ESMReader &esm) } } -void ESM::Locals::save (ESMWriter &esm) const +void Locals::save (ESMWriter &esm) const { for (std::vector >::const_iterator iter (mVariables.begin()); iter!=mVariables.end(); ++iter) @@ -25,3 +28,5 @@ void ESM::Locals::save (ESMWriter &esm) const iter->second.write (esm, Variant::Format_Local); } } + +} diff --git a/components/esm3/mappings.cpp b/components/esm3/mappings.cpp index 440e735739..4553c1396f 100644 --- a/components/esm3/mappings.cpp +++ b/components/esm3/mappings.cpp @@ -4,128 +4,128 @@ namespace ESM { - ESM::BodyPart::MeshPart getMeshPart(ESM::PartReferenceType type) + BodyPart::MeshPart getMeshPart(PartReferenceType type) { switch(type) { - case ESM::PRT_Head: - return ESM::BodyPart::MP_Head; - case ESM::PRT_Hair: - return ESM::BodyPart::MP_Hair; - case ESM::PRT_Neck: - return ESM::BodyPart::MP_Neck; - case ESM::PRT_Cuirass: - return ESM::BodyPart::MP_Chest; - case ESM::PRT_Groin: - return ESM::BodyPart::MP_Groin; - case ESM::PRT_RHand: - return ESM::BodyPart::MP_Hand; - case ESM::PRT_LHand: - return ESM::BodyPart::MP_Hand; - case ESM::PRT_RWrist: - return ESM::BodyPart::MP_Wrist; - case ESM::PRT_LWrist: - return ESM::BodyPart::MP_Wrist; - case ESM::PRT_RForearm: - return ESM::BodyPart::MP_Forearm; - case ESM::PRT_LForearm: - return ESM::BodyPart::MP_Forearm; - case ESM::PRT_RUpperarm: - return ESM::BodyPart::MP_Upperarm; - case ESM::PRT_LUpperarm: - return ESM::BodyPart::MP_Upperarm; - case ESM::PRT_RFoot: - return ESM::BodyPart::MP_Foot; - case ESM::PRT_LFoot: - return ESM::BodyPart::MP_Foot; - case ESM::PRT_RAnkle: - return ESM::BodyPart::MP_Ankle; - case ESM::PRT_LAnkle: - return ESM::BodyPart::MP_Ankle; - case ESM::PRT_RKnee: - return ESM::BodyPart::MP_Knee; - case ESM::PRT_LKnee: - return ESM::BodyPart::MP_Knee; - case ESM::PRT_RLeg: - return ESM::BodyPart::MP_Upperleg; - case ESM::PRT_LLeg: - return ESM::BodyPart::MP_Upperleg; - case ESM::PRT_Tail: - return ESM::BodyPart::MP_Tail; + case PRT_Head: + return BodyPart::MP_Head; + case PRT_Hair: + return BodyPart::MP_Hair; + case PRT_Neck: + return BodyPart::MP_Neck; + case PRT_Cuirass: + return BodyPart::MP_Chest; + case PRT_Groin: + return BodyPart::MP_Groin; + case PRT_RHand: + return BodyPart::MP_Hand; + case PRT_LHand: + return BodyPart::MP_Hand; + case PRT_RWrist: + return BodyPart::MP_Wrist; + case PRT_LWrist: + return BodyPart::MP_Wrist; + case PRT_RForearm: + return BodyPart::MP_Forearm; + case PRT_LForearm: + return BodyPart::MP_Forearm; + case PRT_RUpperarm: + return BodyPart::MP_Upperarm; + case PRT_LUpperarm: + return BodyPart::MP_Upperarm; + case PRT_RFoot: + return BodyPart::MP_Foot; + case PRT_LFoot: + return BodyPart::MP_Foot; + case PRT_RAnkle: + return BodyPart::MP_Ankle; + case PRT_LAnkle: + return BodyPart::MP_Ankle; + case PRT_RKnee: + return BodyPart::MP_Knee; + case PRT_LKnee: + return BodyPart::MP_Knee; + case PRT_RLeg: + return BodyPart::MP_Upperleg; + case PRT_LLeg: + return BodyPart::MP_Upperleg; + case PRT_Tail: + return BodyPart::MP_Tail; default: throw std::runtime_error("PartReferenceType " + std::to_string(type) + " not associated with a mesh part"); } } - std::string getBoneName(ESM::PartReferenceType type) + std::string getBoneName(PartReferenceType type) { switch(type) { - case ESM::PRT_Head: + case PRT_Head: return "head"; - case ESM::PRT_Hair: + case PRT_Hair: return "head"; // This is purposeful. - case ESM::PRT_Neck: + case PRT_Neck: return "neck"; - case ESM::PRT_Cuirass: + case PRT_Cuirass: return "chest"; - case ESM::PRT_Groin: + case PRT_Groin: return "groin"; - case ESM::PRT_Skirt: + case PRT_Skirt: return "groin"; - case ESM::PRT_RHand: + case PRT_RHand: return "right hand"; - case ESM::PRT_LHand: + case PRT_LHand: return "left hand"; - case ESM::PRT_RWrist: + case PRT_RWrist: return "right wrist"; - case ESM::PRT_LWrist: + case PRT_LWrist: return "left wrist"; - case ESM::PRT_Shield: + case PRT_Shield: return "shield bone"; - case ESM::PRT_RForearm: + case PRT_RForearm: return "right forearm"; - case ESM::PRT_LForearm: + case PRT_LForearm: return "left forearm"; - case ESM::PRT_RUpperarm: + case PRT_RUpperarm: return "right upper arm"; - case ESM::PRT_LUpperarm: + case PRT_LUpperarm: return "left upper arm"; - case ESM::PRT_RFoot: + case PRT_RFoot: return "right foot"; - case ESM::PRT_LFoot: + case PRT_LFoot: return "left foot"; - case ESM::PRT_RAnkle: + case PRT_RAnkle: return "right ankle"; - case ESM::PRT_LAnkle: + case PRT_LAnkle: return "left ankle"; - case ESM::PRT_RKnee: + case PRT_RKnee: return "right knee"; - case ESM::PRT_LKnee: + case PRT_LKnee: return "left knee"; - case ESM::PRT_RLeg: + case PRT_RLeg: return "right upper leg"; - case ESM::PRT_LLeg: + case PRT_LLeg: return "left upper leg"; - case ESM::PRT_RPauldron: + case PRT_RPauldron: return "right clavicle"; - case ESM::PRT_LPauldron: + case PRT_LPauldron: return "left clavicle"; - case ESM::PRT_Weapon: + case PRT_Weapon: return "weapon bone"; - case ESM::PRT_Tail: + case PRT_Tail: return "tail"; default: throw std::runtime_error("unknown PartReferenceType"); } } - std::string getMeshFilter(ESM::PartReferenceType type) + std::string getMeshFilter(PartReferenceType type) { switch(type) { - case ESM::PRT_Hair: + case PRT_Hair: return "hair"; default: return getBoneName(type); diff --git a/components/esm3/mappings.hpp b/components/esm3/mappings.hpp index e2fa1b62c3..a6f0ec3048 100644 --- a/components/esm3/mappings.hpp +++ b/components/esm3/mappings.hpp @@ -8,9 +8,9 @@ namespace ESM { - ESM::BodyPart::MeshPart getMeshPart(ESM::PartReferenceType type); - std::string getBoneName(ESM::PartReferenceType type); - std::string getMeshFilter(ESM::PartReferenceType type); + BodyPart::MeshPart getMeshPart(PartReferenceType type); + std::string getBoneName(PartReferenceType type); + std::string getMeshFilter(PartReferenceType type); } #endif diff --git a/components/esm3/npcstate.cpp b/components/esm3/npcstate.cpp index 6c9988d50d..91c6ebbf09 100644 --- a/components/esm3/npcstate.cpp +++ b/components/esm3/npcstate.cpp @@ -1,6 +1,9 @@ #include "npcstate.hpp" -void ESM::NpcState::load (ESMReader &esm) +namespace ESM +{ + +void NpcState::load (ESMReader &esm) { ObjectState::load (esm); @@ -14,7 +17,7 @@ void ESM::NpcState::load (ESMReader &esm) } } -void ESM::NpcState::save (ESMWriter &esm, bool inInventory) const +void NpcState::save (ESMWriter &esm, bool inInventory) const { ObjectState::save (esm, inInventory); @@ -28,10 +31,12 @@ void ESM::NpcState::save (ESMWriter &esm, bool inInventory) const } } -void ESM::NpcState::blank() +void NpcState::blank() { ObjectState::blank(); mNpcStats.blank(); mCreatureStats.blank(); mHasCustomState = true; } + +} diff --git a/components/esm3/npcstats.cpp b/components/esm3/npcstats.cpp index 277335e8ca..2896f6a922 100644 --- a/components/esm3/npcstats.cpp +++ b/components/esm3/npcstats.cpp @@ -5,9 +5,12 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -ESM::NpcStats::Faction::Faction() : mExpelled (false), mRank (-1), mReputation (0) {} +namespace ESM +{ + +NpcStats::Faction::Faction() : mExpelled (false), mRank (-1), mReputation (0) {} -void ESM::NpcStats::load (ESMReader &esm) +void NpcStats::load (ESMReader &esm) { while (esm.isNextSub ("FACT")) { @@ -41,17 +44,17 @@ void ESM::NpcStats::load (ESMReader &esm) // we have deprecated werewolf skills, stored interleaved // Load into one big vector, then remove every 2nd value mWerewolfDeprecatedData = true; - std::vector > skills(mSkills, mSkills + sizeof(mSkills)/sizeof(mSkills[0])); + std::vector > skills(mSkills, mSkills + sizeof(mSkills)/sizeof(mSkills[0])); for (int i=0; i<27; ++i) { - ESM::StatState skill; + StatState skill; skill.load(esm, intFallback); skills.push_back(skill); } int i=0; - for (std::vector >::iterator it = skills.begin(); it != skills.end(); ++i) + for (std::vector >::iterator it = skills.begin(); it != skills.end(); ++i) { if (i%2 == 1) it = skills.erase(it); @@ -67,7 +70,7 @@ void ESM::NpcStats::load (ESMReader &esm) esm.getHNOT (hasWerewolfAttributes, "HWAT"); if (hasWerewolfAttributes) { - ESM::StatState dummy; + StatState dummy; for (int i=0; i<8; ++i) dummy.load(esm, intFallback); mWerewolfDeprecatedData = true; @@ -122,7 +125,7 @@ void ESM::NpcStats::load (ESMReader &esm) esm.getHNOT (mCrimeId, "CRID"); } -void ESM::NpcStats::save (ESMWriter &esm) const +void NpcStats::save (ESMWriter &esm) const { for (std::map::const_iterator iter (mFactions.begin()); iter!=mFactions.end(); ++iter) @@ -191,7 +194,7 @@ void ESM::NpcStats::save (ESMWriter &esm) const esm.writeHNT ("CRID", mCrimeId); } -void ESM::NpcStats::blank() +void NpcStats::blank() { mWerewolfDeprecatedData = false; mIsWerewolf = false; @@ -207,3 +210,5 @@ void ESM::NpcStats::blank() mTimeToStartDrowning = 20; mCrimeId = -1; } + +} diff --git a/components/esm3/objectstate.cpp b/components/esm3/objectstate.cpp index 5204af7daf..30f6c98f38 100644 --- a/components/esm3/objectstate.cpp +++ b/components/esm3/objectstate.cpp @@ -8,7 +8,10 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -void ESM::ObjectState::load (ESMReader &esm) +namespace ESM +{ + +void ObjectState::load (ESMReader &esm) { mVersion = esm.getFormat(); @@ -56,7 +59,7 @@ void ESM::ObjectState::load (ESMReader &esm) esm.getHNOT (mHasCustomState, "HCUS"); } -void ESM::ObjectState::save (ESMWriter &esm, bool inInventory) const +void ObjectState::save (ESMWriter &esm, bool inInventory) const { mRef.save (esm, true, inInventory); @@ -91,7 +94,7 @@ void ESM::ObjectState::save (ESMWriter &esm, bool inInventory) const esm.writeHNT ("HCUS", false); } -void ESM::ObjectState::blank() +void ObjectState::blank() { mRef.blank(); mHasLocals = 0; @@ -106,74 +109,76 @@ void ESM::ObjectState::blank() mHasCustomState = true; } -const ESM::NpcState& ESM::ObjectState::asNpcState() const +const NpcState& ObjectState::asNpcState() const { std::stringstream error; error << "bad cast " << typeid(this).name() << " to NpcState"; throw std::logic_error(error.str()); } -ESM::NpcState& ESM::ObjectState::asNpcState() +NpcState& ObjectState::asNpcState() { std::stringstream error; error << "bad cast " << typeid(this).name() << " to NpcState"; throw std::logic_error(error.str()); } -const ESM::CreatureState& ESM::ObjectState::asCreatureState() const +const CreatureState& ObjectState::asCreatureState() const { std::stringstream error; error << "bad cast " << typeid(this).name() << " to CreatureState"; throw std::logic_error(error.str()); } -ESM::CreatureState& ESM::ObjectState::asCreatureState() +CreatureState& ObjectState::asCreatureState() { std::stringstream error; error << "bad cast " << typeid(this).name() << " to CreatureState"; throw std::logic_error(error.str()); } -const ESM::ContainerState& ESM::ObjectState::asContainerState() const +const ContainerState& ObjectState::asContainerState() const { std::stringstream error; error << "bad cast " << typeid(this).name() << " to ContainerState"; throw std::logic_error(error.str()); } -ESM::ContainerState& ESM::ObjectState::asContainerState() +ContainerState& ObjectState::asContainerState() { std::stringstream error; error << "bad cast " << typeid(this).name() << " to ContainerState"; throw std::logic_error(error.str()); } -const ESM::DoorState& ESM::ObjectState::asDoorState() const +const DoorState& ObjectState::asDoorState() const { std::stringstream error; error << "bad cast " << typeid(this).name() << " to DoorState"; throw std::logic_error(error.str()); } -ESM::DoorState& ESM::ObjectState::asDoorState() +DoorState& ObjectState::asDoorState() { std::stringstream error; error << "bad cast " << typeid(this).name() << " to DoorState"; throw std::logic_error(error.str()); } -const ESM::CreatureLevListState& ESM::ObjectState::asCreatureLevListState() const +const CreatureLevListState& ObjectState::asCreatureLevListState() const { std::stringstream error; error << "bad cast " << typeid(this).name() << " to CreatureLevListState"; throw std::logic_error(error.str()); } -ESM::CreatureLevListState& ESM::ObjectState::asCreatureLevListState() +CreatureLevListState& ObjectState::asCreatureLevListState() { std::stringstream error; error << "bad cast " << typeid(this).name() << " to CreatureLevListState"; throw std::logic_error(error.str()); } -ESM::ObjectState::~ObjectState() {} +ObjectState::~ObjectState() {} + +} diff --git a/components/esm3/objectstate.hpp b/components/esm3/objectstate.hpp index eb09e2e854..5a9e85b71d 100644 --- a/components/esm3/objectstate.hpp +++ b/components/esm3/objectstate.hpp @@ -31,7 +31,7 @@ namespace ESM LuaScripts mLuaScripts; unsigned char mEnabled; int mCount; - ESM::Position mPosition; + Position mPosition; unsigned int mFlags; // Is there any class-specific state following the ObjectState @@ -39,7 +39,7 @@ namespace ESM unsigned int mVersion; - ESM::AnimationState mAnimationState; + AnimationState mAnimationState; ObjectState() : mHasLocals(0), mEnabled(0), mCount(0) diff --git a/components/esm3/player.cpp b/components/esm3/player.cpp index 1839a45749..fbf6afec93 100644 --- a/components/esm3/player.cpp +++ b/components/esm3/player.cpp @@ -3,7 +3,10 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -void ESM::Player::load (ESMReader &esm) +namespace ESM +{ + +void Player::load (ESMReader &esm) { mObject.mRef.loadId(esm, true); mObject.load (esm); @@ -50,7 +53,7 @@ void ESM::Player::load (ESMReader &esm) bool clearModified = esm.getFormat() < 17 && !mObject.mNpcStats.mIsWerewolf; if (esm.hasMoreSubs()) { - for (int i=0; i attribute; attribute.load(esm, intFallback); @@ -60,7 +63,7 @@ void ESM::Player::load (ESMReader &esm) if (mObject.mNpcStats.mIsWerewolf) mObject.mCreatureStats.mAttributes[i] = attribute; } - for (int i=0; i skill; skill.load(esm, intFallback); @@ -69,7 +72,7 @@ void ESM::Player::load (ESMReader &esm) mSaveSkills[i] = skill.mBase + skill.mMod - skill.mDamage; if (mObject.mNpcStats.mIsWerewolf) { - if(i == ESM::Skill::Acrobatics) + if(i == Skill::Acrobatics) mSetWerewolfAcrobatics = mObject.mNpcStats.mSkills[i].mBase != skill.mBase; mObject.mNpcStats.mSkills[i] = skill; } @@ -84,7 +87,7 @@ void ESM::Player::load (ESMReader &esm) } } -void ESM::Player::save (ESMWriter &esm) const +void Player::save (ESMWriter &esm) const { mObject.save (esm); @@ -112,3 +115,5 @@ void ESM::Player::save (ESMWriter &esm) const esm.writeHNT("WWAT", mSaveAttributes); esm.writeHNT("WWSK", mSaveSkills); } + +} diff --git a/components/esm3/player.hpp b/components/esm3/player.hpp index d69571705d..6e914b0e9a 100644 --- a/components/esm3/player.hpp +++ b/components/esm3/player.hpp @@ -24,15 +24,15 @@ namespace ESM float mLastKnownExteriorPosition[3]; unsigned char mHasMark; bool mSetWerewolfAcrobatics; - ESM::Position mMarkedPosition; + Position mMarkedPosition; CellId mMarkedCell; std::string mBirthsign; int mCurrentCrimeId; int mPaidCrimeId; - float mSaveAttributes[ESM::Attribute::Length]; - float mSaveSkills[ESM::Skill::Length]; + float mSaveAttributes[Attribute::Length]; + float mSaveSkills[Skill::Length]; typedef std::map PreviousItems; // previous equipped items, needed for bound spells PreviousItems mPreviousItems; diff --git a/components/esm3/projectilestate.cpp b/components/esm3/projectilestate.cpp index 3421c19526..6a2fcc6675 100644 --- a/components/esm3/projectilestate.cpp +++ b/components/esm3/projectilestate.cpp @@ -38,7 +38,7 @@ namespace ESM mSpellId = esm.getHNString("SPEL"); if (esm.isNextSub("SRCN")) // for backwards compatibility esm.skipHSub(); - ESM::EffectList().load(esm); // for backwards compatibility + EffectList().load(esm); // for backwards compatibility esm.getHNT (mSpeed, "SPED"); if(esm.getFormat() < 17) mSlot = 0; diff --git a/components/esm3/queststate.cpp b/components/esm3/queststate.cpp index 5408cd2ffd..af7ed81f9e 100644 --- a/components/esm3/queststate.cpp +++ b/components/esm3/queststate.cpp @@ -3,16 +3,21 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -void ESM::QuestState::load (ESMReader &esm) +namespace ESM +{ + +void QuestState::load (ESMReader &esm) { mTopic = esm.getHNString ("YETO"); esm.getHNOT (mState, "QSTA"); esm.getHNOT (mFinished, "QFIN"); } -void ESM::QuestState::save (ESMWriter &esm) const +void QuestState::save (ESMWriter &esm) const { esm.writeHNString ("YETO", mTopic); esm.writeHNT ("QSTA", mState); esm.writeHNT ("QFIN", mFinished); } + +} diff --git a/components/esm3/savedgame.cpp b/components/esm3/savedgame.cpp index 94ea075759..9a4997842c 100644 --- a/components/esm3/savedgame.cpp +++ b/components/esm3/savedgame.cpp @@ -3,10 +3,13 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -unsigned int ESM::SavedGame::sRecordId = ESM::REC_SAVE; -int ESM::SavedGame::sCurrentFormat = 21; +namespace ESM +{ + +unsigned int SavedGame::sRecordId = REC_SAVE; +int SavedGame::sCurrentFormat = 21; -void ESM::SavedGame::load (ESMReader &esm) +void SavedGame::load (ESMReader &esm) { mPlayerName = esm.getHNString("PLNA"); esm.getHNOT (mPlayerLevel, "PLLE"); @@ -28,7 +31,7 @@ void ESM::SavedGame::load (ESMReader &esm) esm.getExact(mScreenshot.data(), mScreenshot.size()); } -void ESM::SavedGame::save (ESMWriter &esm) const +void SavedGame::save (ESMWriter &esm) const { esm.writeHNString ("PLNA", mPlayerName); esm.writeHNT ("PLLE", mPlayerLevel); @@ -51,3 +54,5 @@ void ESM::SavedGame::save (ESMWriter &esm) const esm.write(&mScreenshot[0], mScreenshot.size()); esm.endRecord("SCRN"); } + +} diff --git a/components/esm3/spelllist.cpp b/components/esm3/spelllist.cpp index 71c7b340d2..168a8c7448 100644 --- a/components/esm3/spelllist.cpp +++ b/components/esm3/spelllist.cpp @@ -3,7 +3,8 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -namespace ESM { +namespace ESM +{ void SpellList::add(ESMReader &esm) { diff --git a/components/esm3/statstate.cpp b/components/esm3/statstate.cpp index 30d39e3c67..4e37df7d79 100644 --- a/components/esm3/statstate.cpp +++ b/components/esm3/statstate.cpp @@ -70,7 +70,7 @@ namespace ESM if (mProgress) esm.writeHNT("STPR", mProgress); } -} -template struct ESM::StatState; -template struct ESM::StatState; + template struct StatState; + template struct StatState; +} diff --git a/components/esm3/stolenitems.hpp b/components/esm3/stolenitems.hpp index 928fbbf757..cd7fe5a6c8 100644 --- a/components/esm3/stolenitems.hpp +++ b/components/esm3/stolenitems.hpp @@ -15,8 +15,8 @@ namespace ESM typedef std::map, int> > StolenItemsMap; StolenItemsMap mStolenItems; - void load(ESM::ESMReader& esm); - void write(ESM::ESMWriter& esm) const; + void load(ESMReader& esm); + void write(ESMWriter& esm) const; }; } diff --git a/components/esm3/transport.cpp b/components/esm3/transport.cpp index 40f831e748..b79818a228 100644 --- a/components/esm3/transport.cpp +++ b/components/esm3/transport.cpp @@ -10,13 +10,13 @@ namespace ESM void Transport::add(ESMReader &esm) { - if (esm.retSubName().toInt() == ESM::fourCC("DODT")) + if (esm.retSubName().toInt() == fourCC("DODT")) { Dest dodt; esm.getHExact(&dodt.mPos, 24); mList.push_back(dodt); } - else if (esm.retSubName().toInt() == ESM::fourCC("DNAM")) + else if (esm.retSubName().toInt() == fourCC("DNAM")) { const std::string name = esm.getHString(); if (mList.empty()) diff --git a/components/esm3/variant.cpp b/components/esm3/variant.cpp index c50581327d..b7dc293f53 100644 --- a/components/esm3/variant.cpp +++ b/components/esm3/variant.cpp @@ -8,12 +8,14 @@ #include "components/esm/defs.hpp" +namespace ESM +{ namespace { - constexpr uint32_t STRV = ESM::fourCC("STRV"); - constexpr uint32_t INTV = ESM::fourCC("INTV"); - constexpr uint32_t FLTV = ESM::fourCC("FLTV"); - constexpr uint32_t STTV = ESM::fourCC("STTV"); + constexpr uint32_t STRV = fourCC("STRV"); + constexpr uint32_t INTV = fourCC("INTV"); + constexpr uint32_t FLTV = fourCC("FLTV"); + constexpr uint32_t STTV = fourCC("STTV"); template struct GetValue @@ -48,22 +50,22 @@ namespace }; } -const std::string& ESM::Variant::getString() const +const std::string& Variant::getString() const { return std::get(mData); } -int ESM::Variant::getInteger() const +int Variant::getInteger() const { return std::visit(GetValue{}, mData); } -float ESM::Variant::getFloat() const +float Variant::getFloat() const { return std::visit(GetValue{}, mData); } -void ESM::Variant::read (ESMReader& esm, Format format) +void Variant::read (ESMReader& esm, Format format) { // type VarType type = VT_Unknown; @@ -152,7 +154,7 @@ void ESM::Variant::read (ESMReader& esm, Format format) std::visit(ReadESMVariantValue {esm, format, mType}, mData); } -void ESM::Variant::write (ESMWriter& esm, Format format) const +void Variant::write (ESMWriter& esm, Format format) const { if (mType==VT_Unknown) { @@ -175,7 +177,7 @@ void ESM::Variant::write (ESMWriter& esm, Format format) const std::visit(WriteESMVariantValue {esm, format, mType}, mData); } -void ESM::Variant::write (std::ostream& stream) const +void Variant::write (std::ostream& stream) const { switch (mType) { @@ -216,7 +218,7 @@ void ESM::Variant::write (std::ostream& stream) const } } -void ESM::Variant::setType (VarType type) +void Variant::setType (VarType type) { if (type!=mType) { @@ -246,28 +248,30 @@ void ESM::Variant::setType (VarType type) } } -void ESM::Variant::setString (const std::string& value) +void Variant::setString (const std::string& value) { std::get(mData) = value; } -void ESM::Variant::setString (std::string&& value) +void Variant::setString (std::string&& value) { std::get(mData) = std::move(value); } -void ESM::Variant::setInteger (int value) +void Variant::setInteger (int value) { std::visit(SetValue(value), mData); } -void ESM::Variant::setFloat (float value) +void Variant::setFloat (float value) { std::visit(SetValue(value), mData); } -std::ostream& ESM::operator<< (std::ostream& stream, const Variant& value) +std::ostream& operator<< (std::ostream& stream, const Variant& value) { value.write (stream); return stream; } + +} diff --git a/components/esm3/variantimp.cpp b/components/esm3/variantimp.cpp index df491e7cec..7116ce7a74 100644 --- a/components/esm3/variantimp.cpp +++ b/components/esm3/variantimp.cpp @@ -7,7 +7,10 @@ #include "esmreader.hpp" #include "esmwriter.hpp" -void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, std::string& out) +namespace ESM +{ + +void readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, std::string& out) { if (type!=VT_String) throw std::logic_error ("not a string type"); @@ -25,7 +28,7 @@ void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType ty out = esm.getHString(); } -void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, const std::string& in) +void writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, const std::string& in) { if (type!=VT_String) throw std::logic_error ("not a string type"); @@ -43,7 +46,7 @@ void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType t esm.writeHNString("STRV", in); } -void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, int& out) +void readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, int& out) { if (type!=VT_Short && type!=VT_Long && type!=VT_Int) throw std::logic_error ("not an integer type"); @@ -93,7 +96,7 @@ void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType ty } } -void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, int in) +void writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, int in) { if (type!=VT_Short && type!=VT_Long && type!=VT_Int) throw std::logic_error ("not an integer type"); @@ -133,7 +136,7 @@ void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType t } } -void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, float& out) +void readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, float& out) { if (type!=VT_Float) throw std::logic_error ("not a float type"); @@ -148,7 +151,7 @@ void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType ty } } -void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, float in) +void writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, float in) { if (type!=VT_Float) throw std::logic_error ("not a float type"); @@ -163,3 +166,5 @@ void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType t esm.writeHNT("FLTV", in); } } + +} diff --git a/components/esm3/weatherstate.cpp b/components/esm3/weatherstate.cpp index c791aac145..b149c2bfe0 100644 --- a/components/esm3/weatherstate.cpp +++ b/components/esm3/weatherstate.cpp @@ -3,19 +3,22 @@ #include "esmreader.hpp" #include "esmwriter.hpp" +namespace ESM +{ namespace { - constexpr ESM::NAME currentRegionRecord = "CREG"; - constexpr ESM::NAME timePassedRecord = "TMPS"; - constexpr ESM::NAME fastForwardRecord = "FAST"; - constexpr ESM::NAME weatherUpdateTimeRecord = "WUPD"; - constexpr ESM::NAME transitionFactorRecord = "TRFC"; - constexpr ESM::NAME currentWeatherRecord = "CWTH"; - constexpr ESM::NAME nextWeatherRecord = "NWTH"; - constexpr ESM::NAME queuedWeatherRecord = "QWTH"; - constexpr ESM::NAME regionNameRecord = "RGNN"; - constexpr ESM::NAME regionWeatherRecord = "RGNW"; - constexpr ESM::NAME regionChanceRecord = "RGNC"; + constexpr NAME currentRegionRecord = "CREG"; + constexpr NAME timePassedRecord = "TMPS"; + constexpr NAME fastForwardRecord = "FAST"; + constexpr NAME weatherUpdateTimeRecord = "WUPD"; + constexpr NAME transitionFactorRecord = "TRFC"; + constexpr NAME currentWeatherRecord = "CWTH"; + constexpr NAME nextWeatherRecord = "NWTH"; + constexpr NAME queuedWeatherRecord = "QWTH"; + constexpr NAME regionNameRecord = "RGNN"; + constexpr NAME regionWeatherRecord = "RGNW"; + constexpr NAME regionChanceRecord = "RGNC"; +} } namespace ESM