diff --git a/components/esm3/aisequence.cpp b/components/esm3/aisequence.cpp index 668b36c871..21973acd1d 100644 --- a/components/esm3/aisequence.cpp +++ b/components/esm3/aisequence.cpp @@ -196,7 +196,7 @@ namespace ESM int count = 0; while (esm.isNextSub("AIPK")) { - int type; + int32_t type; esm.getHT(type); mPackages.emplace_back(); diff --git a/components/esm3/loadcell.cpp b/components/esm3/loadcell.cpp index b966338ae5..829cf9e916 100644 --- a/components/esm3/loadcell.cpp +++ b/components/esm3/loadcell.cpp @@ -17,7 +17,7 @@ namespace ESM ///< Translate 8bit/24bit code (stored in refNum.mIndex) into a proper refNum void adjustRefNum(RefNum& refNum, const ESMReader& reader) { - unsigned int local = (refNum.mIndex & 0xff000000) >> 24; + uint32_t local = (refNum.mIndex & 0xff000000) >> 24; // If we have an index value that does not make sense, assume that it was an addition // by the present plugin (but a faulty one) @@ -124,7 +124,7 @@ namespace ESM switch (esm.retSubName().toInt()) { case fourCC("INTV"): - int waterl; + int32_t waterl; esm.getHT(waterl); mWater = static_cast(waterl); mWaterInt = true; @@ -192,7 +192,7 @@ namespace ESM { if (mWaterInt) { - int water = (mWater >= 0) ? (int)(mWater + 0.5) : (int)(mWater - 0.5); + int32_t water = (mWater >= 0) ? static_cast(mWater + 0.5) : static_cast(mWater - 0.5); esm.writeHNT("INTV", water); } else @@ -218,13 +218,13 @@ namespace ESM } } - void Cell::saveTempMarker(ESMWriter& esm, int tempCount) const + void Cell::saveTempMarker(ESMWriter& esm, int32_t tempCount) const { if (tempCount != 0) esm.writeHNT("NAM0", tempCount); } - void Cell::restore(ESMReader& esm, int iCtx) const + void Cell::restore(ESMReader& esm, size_t iCtx) const { esm.restoreContext(mContextList.at(iCtx)); } @@ -321,7 +321,7 @@ namespace ESM void Cell::blank() { - mName = ""; + mName.clear(); mRegion = ESM::RefId(); mWater = 0; mWaterInt = false; diff --git a/components/esm3/loadcell.hpp b/components/esm3/loadcell.hpp index 0ba0777e7c..bfabdd58f9 100644 --- a/components/esm3/loadcell.hpp +++ b/components/esm3/loadcell.hpp @@ -34,7 +34,7 @@ namespace ESM RefNum mRefNum; // Coordinates of target exterior cell - int mTarget[2]; + int32_t mTarget[2]; // The content file format does not support moving objects to an interior cell. // The save game format does support moving to interior cells, but uses a different mechanism @@ -153,13 +153,13 @@ namespace ESM ESMReader& esm, bool saveContext = true); // Load everything, except NAME, DATAstruct and references void save(ESMWriter& esm, bool isDeleted = false) const; - void saveTempMarker(ESMWriter& esm, int tempCount) const; + void saveTempMarker(ESMWriter& esm, int32_t tempCount) const; bool isExterior() const { return !(mData.mFlags & Interior); } - int getGridX() const { return mData.mX; } + int32_t getGridX() const { return mData.mX; } - int getGridY() const { return mData.mY; } + int32_t getGridY() const { return mData.mY; } bool hasWater() const { return ((mData.mFlags & HasWater) != 0) || isExterior(); } @@ -172,7 +172,7 @@ namespace ESM // somewhere other than the file system, you need to pre-open the // ESMReader, and the filename must match the stored filename // exactly. - void restore(ESMReader& esm, int iCtx) const; + void restore(ESMReader& esm, size_t iCtx) const; std::string getDescription() const; ///< Return a short string describing the cell (mostly used for debugging/logging purpose) diff --git a/components/esm3/loadcont.hpp b/components/esm3/loadcont.hpp index 3921821da0..3c1fb6468e 100644 --- a/components/esm3/loadcont.hpp +++ b/components/esm3/loadcont.hpp @@ -19,7 +19,7 @@ namespace ESM struct ContItem { - int mCount{ 0 }; + int32_t mCount{ 0 }; ESM::RefId mItem; }; @@ -48,12 +48,12 @@ namespace ESM Unknown = 8 }; - unsigned int mRecordFlags; + uint32_t mRecordFlags; RefId mId, mScript; std::string mName, mModel; float mWeight; // Not sure, might be max total weight allowed? - int mFlags; + int32_t mFlags; InventoryList mInventory; void load(ESMReader& esm, bool& isDeleted); diff --git a/components/esm3/loadglob.hpp b/components/esm3/loadglob.hpp index eed53a5f7b..c78bc83917 100644 --- a/components/esm3/loadglob.hpp +++ b/components/esm3/loadglob.hpp @@ -25,7 +25,7 @@ namespace ESM /// Return a string descriptor for this record type. Currently used for debugging / error logs only. static std::string_view getRecordType() { return "Global"; } - unsigned int mRecordFlags; + uint32_t mRecordFlags; ESM::RefId mId; Variant mValue; diff --git a/components/esm3/loadgmst.hpp b/components/esm3/loadgmst.hpp index 72d30b9ea9..c827be5b6b 100644 --- a/components/esm3/loadgmst.hpp +++ b/components/esm3/loadgmst.hpp @@ -26,7 +26,7 @@ namespace ESM /// Return a string descriptor for this record type. Currently used for debugging / error logs only. static std::string_view getRecordType() { return "GameSetting"; } - unsigned int mRecordFlags; + uint32_t mRecordFlags; RefId mId; Variant mValue; diff --git a/components/esm3/loadlevlist.cpp b/components/esm3/loadlevlist.cpp index 970174ada2..627edbadce 100644 --- a/components/esm3/loadlevlist.cpp +++ b/components/esm3/loadlevlist.cpp @@ -30,7 +30,7 @@ namespace ESM break; case fourCC("INDX"): { - int length = 0; + uint32_t length = 0; esm.getHT(length); mList.resize(length); @@ -87,12 +87,12 @@ namespace ESM esm.writeHNT("DATA", mFlags); esm.writeHNT("NNAM", mChanceNone); - esm.writeHNT("INDX", mList.size()); + esm.writeHNT("INDX", mList.size()); - for (std::vector::const_iterator it = mList.begin(); it != mList.end(); ++it) + for (const auto& item : mList) { - esm.writeHNCRefId(recName, it->mId); - esm.writeHNT("INTV", it->mLevel); + esm.writeHNCRefId(recName, item.mId); + esm.writeHNT("INTV", item.mLevel); } } diff --git a/components/esm3/loadlevlist.hpp b/components/esm3/loadlevlist.hpp index 809c89102e..536b865d90 100644 --- a/components/esm3/loadlevlist.hpp +++ b/components/esm3/loadlevlist.hpp @@ -24,15 +24,15 @@ namespace ESM struct LevelledListBase { - int mFlags; + int32_t mFlags; unsigned char mChanceNone; // Chance that none are selected (0-100) - unsigned int mRecordFlags; + uint32_t mRecordFlags; RefId mId; struct LevelItem { RefId mId; - short mLevel; + uint16_t mLevel; }; std::vector mList; diff --git a/components/esm3/loadltex.hpp b/components/esm3/loadltex.hpp index e6dc2de73e..fb95e8b9ed 100644 --- a/components/esm3/loadltex.hpp +++ b/components/esm3/loadltex.hpp @@ -29,7 +29,7 @@ namespace ESM // mId is merely a user friendly name for the texture in the editor. std::string mTexture; RefId mId; - int mIndex; + int32_t mIndex; void load(ESMReader& esm, bool& isDeleted); void save(ESMWriter& esm, bool isDeleted = false) const; diff --git a/components/esm3/loadmgef.cpp b/components/esm3/loadmgef.cpp index 7d3879a341..686afbc34a 100644 --- a/components/esm3/loadmgef.cpp +++ b/components/esm3/loadmgef.cpp @@ -36,7 +36,7 @@ namespace ESM esm.getSubNameIs("MEDT"); esm.getSubHeader(); - int school; + int32_t school; esm.getT(school); mData.mSchool = MagicSchool::indexToSkillRefId(school); esm.getT(mData.mBaseCost); diff --git a/components/esm3/loadmgef.hpp b/components/esm3/loadmgef.hpp index 9d68bad609..25ec7d0655 100644 --- a/components/esm3/loadmgef.hpp +++ b/components/esm3/loadmgef.hpp @@ -25,7 +25,7 @@ namespace ESM /// Return a string descriptor for this record type. Currently used for debugging / error logs only. static std::string_view getRecordType() { return "MagicEffect"; } - unsigned int mRecordFlags; + uint32_t mRecordFlags; RefId mId; enum Flags @@ -74,9 +74,9 @@ namespace ESM { RefId mSchool; // Skill id float mBaseCost; - int mFlags; + int32_t mFlags; // Glow color for enchanted items with this effect - int mRed, mGreen, mBlue; + int32_t mRed, mGreen, mBlue; float mUnknown1; // Called "Size X" in CS float mSpeed; // Speed of fired projectile @@ -107,7 +107,7 @@ namespace ESM // there. They can be redefined in mods by setting the name in GMST // sEffectSummonCreature04/05 creature id in // sMagicCreature04ID/05ID. - int mIndex; + int32_t mIndex; void load(ESMReader& esm, bool& isDeleted); void save(ESMWriter& esm, bool isDeleted = false) const; diff --git a/components/esm3/loadnpc.cpp b/components/esm3/loadnpc.cpp index 24a79d2e4c..d844f7d2bc 100644 --- a/components/esm3/loadnpc.cpp +++ b/components/esm3/loadnpc.cpp @@ -82,7 +82,7 @@ namespace ESM break; case fourCC("FLAG"): hasFlags = true; - int flags; + int32_t flags; esm.getHT(flags); mFlags = flags & 0xFF; mBloodType = ((flags >> 8) & 0xFF) >> 2; diff --git a/components/esm3/loadnpc.hpp b/components/esm3/loadnpc.hpp index f0d726434b..af8c2a8574 100644 --- a/components/esm3/loadnpc.hpp +++ b/components/esm3/loadnpc.hpp @@ -79,28 +79,28 @@ namespace ESM struct NPDTstruct52 { - short mLevel; + int16_t mLevel; unsigned char mStrength, mIntelligence, mWillpower, mAgility, mSpeed, mEndurance, mPersonality, mLuck; // mSkill can grow up to 200, it must be unsigned std::array mSkills; char mUnknown1; - unsigned short mHealth, mMana, mFatigue; + uint16_t mHealth, mMana, mFatigue; unsigned char mDisposition, mReputation, mRank; char mUnknown2; - int mGold; + int32_t mGold; }; // 52 bytes // Structure for autocalculated characters. // This is only used for load and save operations. struct NPDTstruct12 { - short mLevel; + int16_t mLevel; // see above unsigned char mDisposition, mReputation, mRank; char mUnknown1, mUnknown2, mUnknown3; - int mGold; + int32_t mGold; }; // 12 bytes #pragma pack(pop) @@ -111,7 +111,7 @@ namespace ESM int getFactionRank() const; /// wrapper for mNpdt*, -1 = no rank - int mBloodType; + int32_t mBloodType; unsigned char mFlags; InventoryList mInventory; @@ -125,7 +125,7 @@ namespace ESM AIPackageList mAiPackage; - unsigned int mRecordFlags; + uint32_t mRecordFlags; RefId mId, mRace, mClass, mFaction, mScript; std::string mModel, mName; diff --git a/components/esm3/loadrace.hpp b/components/esm3/loadrace.hpp index 8dd60bdef1..8cb9d76118 100644 --- a/components/esm3/loadrace.hpp +++ b/components/esm3/loadrace.hpp @@ -27,13 +27,13 @@ namespace ESM struct SkillBonus { - int mSkill; // SkillEnum - int mBonus; + int32_t mSkill; // SkillEnum + int32_t mBonus; }; struct MaleFemale { - int mMale, mFemale; + int32_t mMale, mFemale; int getValue(bool male) const; }; @@ -63,13 +63,13 @@ namespace ESM // as 'height' times 128. This has not been tested yet. MaleFemaleF mHeight, mWeight; - int mFlags; // 0x1 - playable, 0x2 - beast race + int32_t mFlags; // 0x1 - playable, 0x2 - beast race }; // Size = 140 bytes RADTstruct mData; - unsigned int mRecordFlags; + uint32_t mRecordFlags; std::string mName, mDescription; RefId mId; SpellList mPowers; diff --git a/components/esm3/loadsndg.hpp b/components/esm3/loadsndg.hpp index fff4b98439..3337220d9d 100644 --- a/components/esm3/loadsndg.hpp +++ b/components/esm3/loadsndg.hpp @@ -36,9 +36,9 @@ namespace ESM }; // Type - int mType; + int32_t mType; - unsigned int mRecordFlags; + uint32_t mRecordFlags; RefId mId, mCreature, mSound; void load(ESMReader& esm, bool& isDeleted); diff --git a/components/esm3/loadsscr.hpp b/components/esm3/loadsscr.hpp index 6c9163e4e6..34349d8ea4 100644 --- a/components/esm3/loadsscr.hpp +++ b/components/esm3/loadsscr.hpp @@ -28,7 +28,7 @@ namespace ESM static std::string_view getRecordType() { return "StartScript"; } std::string mData; - unsigned int mRecordFlags; + uint32_t mRecordFlags; RefId mId; // Load a record and add it to the list diff --git a/components/esm3/loadstat.hpp b/components/esm3/loadstat.hpp index abe589563b..4c0341f4ea 100644 --- a/components/esm3/loadstat.hpp +++ b/components/esm3/loadstat.hpp @@ -31,7 +31,7 @@ namespace ESM /// Return a string descriptor for this record type. Currently used for debugging / error logs only. static std::string_view getRecordType() { return "Static"; } - unsigned int mRecordFlags; + uint32_t mRecordFlags; RefId mId; std::string mModel; diff --git a/components/esm3/loadtes3.hpp b/components/esm3/loadtes3.hpp index 7927b35cee..8b14d41645 100644 --- a/components/esm3/loadtes3.hpp +++ b/components/esm3/loadtes3.hpp @@ -20,11 +20,11 @@ namespace ESM versions are 1.2 and 1.3. These correspond to: 1.2 = 0x3f99999a and 1.3 = 0x3fa66666 */ - unsigned int version; - int type; // 0=esp, 1=esm, 32=ess (unused) + uint32_t version; + int32_t type; // 0=esp, 1=esm, 32=ess (unused) std::string author; // Author's name std::string desc; // File description - int records; // Number of records + int32_t records; // Number of records }; struct GMDT diff --git a/components/esm3/magiceffects.cpp b/components/esm3/magiceffects.cpp index 346cc2c568..a8a759949b 100644 --- a/components/esm3/magiceffects.cpp +++ b/components/esm3/magiceffects.cpp @@ -20,8 +20,8 @@ namespace ESM { while (esm.isNextSub("EFID")) { - int id; - std::pair params; + int32_t id; + std::pair params; esm.getHT(id); esm.getHNT(params.first, "BASE"); if (esm.getFormatVersion() <= MaxClearModifiersFormatVersion) diff --git a/components/esm3/magiceffects.hpp b/components/esm3/magiceffects.hpp index 3f141355c8..74a6e34743 100644 --- a/components/esm3/magiceffects.hpp +++ b/components/esm3/magiceffects.hpp @@ -16,7 +16,7 @@ namespace ESM struct MagicEffects { // - std::map> mEffects; + std::map> mEffects; void load(ESMReader& esm); void save(ESMWriter& esm) const; @@ -24,16 +24,16 @@ namespace ESM struct SummonKey { - SummonKey(int effectId, const ESM::RefId& sourceId, int index) + SummonKey(int32_t effectId, const ESM::RefId& sourceId, int32_t index) : mEffectId(effectId) , mSourceId(sourceId) , mEffectIndex(index) { } - int mEffectId; + int32_t mEffectId; ESM::RefId mSourceId; - int mEffectIndex; + int32_t mEffectIndex; }; inline auto makeTupleRef(const SummonKey& value) noexcept diff --git a/components/esm3/npcstats.cpp b/components/esm3/npcstats.cpp index c34205f6c2..a21ba807e4 100644 --- a/components/esm3/npcstats.cpp +++ b/components/esm3/npcstats.cpp @@ -21,7 +21,7 @@ namespace ESM Faction faction; - int expelled = 0; + int32_t expelled = 0; esm.getHNOT(expelled, "FAEX"); if (expelled) @@ -75,7 +75,7 @@ namespace ESM esm.getHNOT(hasWerewolfAttributes, "HWAT"); if (hasWerewolfAttributes) { - StatState dummy; + StatState dummy; for (int i = 0; i < ESM::Attribute::Length; ++i) dummy.load(esm, intFallback); mWerewolfDeprecatedData = true; @@ -130,21 +130,21 @@ namespace ESM void NpcStats::save(ESMWriter& esm) const { - for (auto iter(mFactions.begin()); iter != mFactions.end(); ++iter) + for (const auto& [id, faction] : mFactions) { - esm.writeHNRefId("FACT", iter->first); + esm.writeHNRefId("FACT", id); - if (iter->second.mExpelled) + if (faction.mExpelled) { - int expelled = 1; + int32_t expelled = 1; esm.writeHNT("FAEX", expelled); } - if (iter->second.mRank >= 0) - esm.writeHNT("FARA", iter->second.mRank); + if (faction.mRank >= 0) + esm.writeHNT("FARA", faction.mRank); - if (iter->second.mReputation) - esm.writeHNT("FARE", iter->second.mReputation); + if (faction.mReputation) + esm.writeHNT("FARE", faction.mReputation); } if (mDisposition) @@ -169,7 +169,7 @@ namespace ESM esm.writeHNT("LPRO", mLevelProgress); bool saveSkillIncreases = false; - for (int increase : mSkillIncrease) + for (int32_t increase : mSkillIncrease) { if (increase != 0) { @@ -183,8 +183,8 @@ namespace ESM if (mSpecIncreases[0] != 0 || mSpecIncreases[1] != 0 || mSpecIncreases[2] != 0) esm.writeHNT("SPEC", mSpecIncreases); - for (auto iter(mUsedIds.begin()); iter != mUsedIds.end(); ++iter) - esm.writeHNRefId("USED", *iter); + for (const RefId& id : mUsedIds) + esm.writeHNRefId("USED", id); if (mTimeToStartDrowning) esm.writeHNT("DRTI", mTimeToStartDrowning); diff --git a/components/esm3/npcstats.hpp b/components/esm3/npcstats.hpp index e80ec04c25..ccb58a12ad 100644 --- a/components/esm3/npcstats.hpp +++ b/components/esm3/npcstats.hpp @@ -23,8 +23,8 @@ namespace ESM struct Faction { bool mExpelled; - int mRank; - int mReputation; + int32_t mRank; + int32_t mReputation; Faction(); }; @@ -33,18 +33,18 @@ namespace ESM bool mWerewolfDeprecatedData; - std::map mFactions; // lower case IDs - int mDisposition; + std::map mFactions; + int32_t mDisposition; std::array, ESM::Skill::Length> mSkills; - int mBounty; - int mReputation; - int mWerewolfKills; - int mLevelProgress; - std::array mSkillIncrease; - std::array mSpecIncreases; - std::vector mUsedIds; // lower case IDs + int32_t mBounty; + int32_t mReputation; + int32_t mWerewolfKills; + int32_t mLevelProgress; + std::array mSkillIncrease; + std::array mSpecIncreases; + std::vector mUsedIds; float mTimeToStartDrowning; - int mCrimeId; + int32_t mCrimeId; /// Initialize to default state void blank(); diff --git a/components/esm3/objectstate.cpp b/components/esm3/objectstate.cpp index a56988843a..a7fe41d66c 100644 --- a/components/esm3/objectstate.cpp +++ b/components/esm3/objectstate.cpp @@ -49,7 +49,7 @@ namespace ESM esm.getHNOT(mFlags, "FLAG"); // obsolete - int unused; + int32_t unused; esm.getHNOT(unused, "LTIM"); mAnimationState.load(esm); @@ -179,6 +179,6 @@ namespace ESM throw std::logic_error(error.str()); } - ObjectState::~ObjectState() {} + ObjectState::~ObjectState() = default; } diff --git a/components/esm3/objectstate.hpp b/components/esm3/objectstate.hpp index 67f4d27706..4c09d16d18 100644 --- a/components/esm3/objectstate.hpp +++ b/components/esm3/objectstate.hpp @@ -32,9 +32,9 @@ namespace ESM Locals mLocals; LuaScripts mLuaScripts; unsigned char mEnabled; - int mCount; + int32_t mCount; Position mPosition; - unsigned int mFlags; + uint32_t mFlags; // Is there any class-specific state following the ObjectState bool mHasCustomState; diff --git a/components/esm3/player.hpp b/components/esm3/player.hpp index f691f22e86..7f9309765c 100644 --- a/components/esm3/player.hpp +++ b/components/esm3/player.hpp @@ -27,8 +27,8 @@ namespace ESM RefId mMarkedCell; ESM::RefId mBirthsign; - int mCurrentCrimeId; - int mPaidCrimeId; + int32_t mCurrentCrimeId; + int32_t mPaidCrimeId; float mSaveAttributes[Attribute::Length]; float mSaveSkills[Skill::Length]; diff --git a/components/esm3/projectilestate.hpp b/components/esm3/projectilestate.hpp index 7a7651f364..cab550b114 100644 --- a/components/esm3/projectilestate.hpp +++ b/components/esm3/projectilestate.hpp @@ -23,7 +23,7 @@ namespace ESM Vector3 mPosition; Quaternion mOrientation; - int mActorId; + int32_t mActorId; void load(ESMReader& esm); void save(ESMWriter& esm) const; diff --git a/components/esm3/queststate.hpp b/components/esm3/queststate.hpp index 5858714df0..6d9fd6c4fb 100644 --- a/components/esm3/queststate.hpp +++ b/components/esm3/queststate.hpp @@ -14,7 +14,7 @@ namespace ESM struct QuestState { ESM::RefId mTopic; // lower case id - int mState; + int32_t mState; unsigned char mFinished; void load(ESMReader& esm); diff --git a/components/esm3/savedgame.hpp b/components/esm3/savedgame.hpp index 2048244ac2..4632e98927 100644 --- a/components/esm3/savedgame.hpp +++ b/components/esm3/savedgame.hpp @@ -20,7 +20,7 @@ namespace ESM std::vector mContentFiles; std::string mPlayerName; - int mPlayerLevel; + int32_t mPlayerLevel; // ID of class ESM::RefId mPlayerClassId; @@ -34,7 +34,7 @@ namespace ESM std::string mDescription; std::vector mScreenshot; // raw jpg-encoded data - int mCurrentDay = 0; + int32_t mCurrentDay = 0; float mCurrentHealth = 0; float mMaximumHealth = 0; diff --git a/components/esm3/statstate.cpp b/components/esm3/statstate.cpp index b5ddc54985..7477d83e2d 100644 --- a/components/esm3/statstate.cpp +++ b/components/esm3/statstate.cpp @@ -21,19 +21,19 @@ namespace ESM // We changed stats values from integers to floats; ensure backwards compatibility if (intFallback) { - int base = 0; + int32_t base = 0; esm.getHNT(base, "STBA"); mBase = static_cast(base); - int mod = 0; + int32_t mod = 0; esm.getHNOT(mod, "STMO"); mMod = static_cast(mod); - int current = 0; + int32_t current = 0; esm.getHNOT(current, "STCU"); mCurrent = static_cast(current); - int oldDamage = 0; + int32_t oldDamage = 0; esm.getHNOT(oldDamage, "STDA"); mDamage = static_cast(oldDamage); } diff --git a/components/esm3/variant.cpp b/components/esm3/variant.cpp index 3d5daa2cb3..48621818eb 100644 --- a/components/esm3/variant.cpp +++ b/components/esm3/variant.cpp @@ -17,7 +17,7 @@ namespace ESM template struct GetValue { - constexpr T operator()(int value) const { return static_cast(value); } + constexpr T operator()(int32_t value) const { return static_cast(value); } constexpr T operator()(float value) const { return static_cast(value); } @@ -41,7 +41,7 @@ namespace ESM { } - void operator()(int& value) const { value = static_cast(mValue); } + void operator()(int32_t& value) const { value = static_cast(mValue); } void operator()(float& value) const { value = static_cast(mValue); } @@ -58,9 +58,9 @@ namespace ESM return std::get(mData); } - int Variant::getInteger() const + int32_t Variant::getInteger() const { - return std::visit(GetValue{}, mData); + return std::visit(GetValue{}, mData); } float Variant::getFloat() const @@ -194,17 +194,17 @@ namespace ESM case VT_Short: - stream << "variant short: " << std::get(mData); + stream << "variant short: " << std::get(mData); break; case VT_Int: - stream << "variant int: " << std::get(mData); + stream << "variant int: " << std::get(mData); break; case VT_Long: - stream << "variant long: " << std::get(mData); + stream << "variant long: " << std::get(mData); break; case VT_Float: @@ -259,7 +259,7 @@ namespace ESM std::get(mData) = std::move(value); } - void Variant::setInteger(int value) + void Variant::setInteger(int32_t value) { std::visit(SetValue(value), mData); } diff --git a/components/esm3/variant.hpp b/components/esm3/variant.hpp index d00ccb2746..ed72b1dc05 100644 --- a/components/esm3/variant.hpp +++ b/components/esm3/variant.hpp @@ -25,7 +25,7 @@ namespace ESM class Variant { VarType mType; - std::variant mData; + std::variant mData; public: enum Format @@ -54,7 +54,7 @@ namespace ESM { } - explicit Variant(int value) + explicit Variant(int32_t value) : mType(VT_Long) , mData(value) { @@ -71,7 +71,7 @@ namespace ESM const std::string& getString() const; ///< Will throw an exception, if value can not be represented as a string. - int getInteger() const; + int32_t getInteger() const; ///< Will throw an exception, if value can not be represented as an integer (implicit /// casting of float values is permitted). @@ -93,7 +93,7 @@ namespace ESM void setString(std::string&& value); ///< Will throw an exception, if type is not compatible with string. - void setInteger(int value); + void setInteger(int32_t value); ///< Will throw an exception, if type is not compatible with integer. void setFloat(float value); diff --git a/components/esm3/variantimp.cpp b/components/esm3/variantimp.cpp index 410f4ade8d..31248556ec 100644 --- a/components/esm3/variantimp.cpp +++ b/components/esm3/variantimp.cpp @@ -46,7 +46,7 @@ namespace ESM esm.writeHNString("STRV", in); } - void readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, int& out) + void readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, int32_t& out) { if (type != VT_Short && type != VT_Long && type != VT_Int) throw std::logic_error("not an integer type"); @@ -60,9 +60,9 @@ namespace ESM if (std::isnan(value)) out = 0; else - out = static_cast(value); + out = static_cast(value); else if (type == VT_Long) - out = static_cast(value); + out = static_cast(value); else esm.fail("unsupported global variable integer type"); } @@ -82,7 +82,7 @@ namespace ESM { if (type == VT_Short) { - short value; + int16_t value; esm.getHT(value); out = value; } @@ -95,7 +95,7 @@ namespace ESM } } - void writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, int in) + void writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, int32_t in) { if (type != VT_Short && type != VT_Long && type != VT_Int) throw std::logic_error("not an integer type"); @@ -126,7 +126,7 @@ namespace ESM else if (format == Variant::Format_Local) { if (type == VT_Short) - esm.writeHNT("STTV", static_cast(in)); + esm.writeHNT("STTV", static_cast(in)); else if (type == VT_Int) esm.writeHNT("INTV", in); else diff --git a/components/esm3/variantimp.hpp b/components/esm3/variantimp.hpp index 90f45a420f..365cff988a 100644 --- a/components/esm3/variantimp.hpp +++ b/components/esm3/variantimp.hpp @@ -12,13 +12,13 @@ namespace ESM void readESMVariantValue(ESMReader& reader, Variant::Format format, VarType type, float& value); - void readESMVariantValue(ESMReader& reader, Variant::Format format, VarType type, int& value); + void readESMVariantValue(ESMReader& reader, Variant::Format format, VarType type, int32_t& value); void writeESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type, const std::string& value); void writeESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type, float value); - void writeESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type, int value); + void writeESMVariantValue(ESMWriter& writer, Variant::Format format, VarType type, int32_t value); struct ReadESMVariantValue {