mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-25 03:40:40 +00:00
Merge branch 'sizeable' into 'master'
Replace more explicitly sized reads and variable width integers See merge request OpenMW/openmw!3364
This commit is contained in:
commit
cf950c2e4a
@ -232,7 +232,7 @@ namespace MWScript
|
||||
|
||||
desc->mLocals.write(script.mLocals, id);
|
||||
|
||||
script.mRunning = desc->mRunning ? 1 : 0;
|
||||
script.mRunning = desc->mRunning;
|
||||
|
||||
writer.startRecord(ESM::REC_GSCR);
|
||||
script.save(writer);
|
||||
@ -276,7 +276,7 @@ namespace MWScript
|
||||
return true;
|
||||
}
|
||||
|
||||
iter->second->mRunning = script.mRunning != 0;
|
||||
iter->second->mRunning = script.mRunning;
|
||||
iter->second->mLocals.read(script.mLocals, script.mId);
|
||||
|
||||
return true;
|
||||
|
@ -18,7 +18,7 @@ namespace ESM
|
||||
void EffectList::add(ESMReader& esm)
|
||||
{
|
||||
ENAMstruct s;
|
||||
esm.getHTSized<24>(s);
|
||||
esm.getHT(s.mEffectID, s.mSkill, s.mAttribute, s.mRange, s.mArea, s.mDuration, s.mMagnMin, s.mMagnMax);
|
||||
mList.push_back(s);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OPENMW_ESM_EFFECTLIST_H
|
||||
#define OPENMW_ESM_EFFECTLIST_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace ESM
|
||||
@ -17,15 +18,15 @@ namespace ESM
|
||||
struct ENAMstruct
|
||||
{
|
||||
// Magical effect, hard-coded ID
|
||||
short mEffectID;
|
||||
int16_t mEffectID;
|
||||
|
||||
// Which skills/attributes are affected (for restore/drain spells
|
||||
// etc.)
|
||||
signed char mSkill, mAttribute; // -1 if N/A
|
||||
|
||||
// Other spell parameters
|
||||
int mRange; // 0 - self, 1 - touch, 2 - target (RangeType enum)
|
||||
int mArea, mDuration, mMagnMin, mMagnMax;
|
||||
int32_t mRange; // 0 - self, 1 - touch, 2 - target (RangeType enum)
|
||||
int32_t mArea, mDuration, mMagnMin, mMagnMax;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
@ -362,7 +362,7 @@ namespace ESM
|
||||
void setEncoder(ToUTF8::Utf8Encoder* encoder) { mEncoder = encoder; }
|
||||
|
||||
/// Get record flags of last record
|
||||
unsigned int getRecordFlags() { return mRecordFlags; }
|
||||
uint32_t getRecordFlags() { return mRecordFlags; }
|
||||
|
||||
size_t getFileSize() const { return mFileSize; }
|
||||
|
||||
@ -380,7 +380,7 @@ namespace ESM
|
||||
|
||||
ESM_Context mCtx;
|
||||
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
|
||||
// Special file signifier (see SpecialFile enum above)
|
||||
|
||||
|
@ -58,7 +58,8 @@ namespace ESM
|
||||
|
||||
void FogState::load(ESMReader& esm)
|
||||
{
|
||||
esm.getHNOTSized<16>(mBounds, "BOUN");
|
||||
if (esm.isNextSub("BOUN"))
|
||||
esm.getHT(mBounds.mMinX, mBounds.mMinY, mBounds.mMaxX, mBounds.mMaxY);
|
||||
esm.getHNOT(mNorthMarkerAngle, "ANGL");
|
||||
const FormatVersion dataFormat = esm.getFormatVersion();
|
||||
while (esm.isNextSub("FTEX"))
|
||||
@ -69,7 +70,7 @@ namespace ESM
|
||||
esm.getT(tex.mX);
|
||||
esm.getT(tex.mY);
|
||||
|
||||
const std::size_t imageSize = esm.getSubSize() - sizeof(int) * 2;
|
||||
const std::size_t imageSize = esm.getSubSize() - sizeof(int32_t) * 2;
|
||||
tex.mImageData.resize(imageSize);
|
||||
esm.getExact(tex.mImageData.data(), imageSize);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OPENMW_ESM_FOGSTATE_H
|
||||
#define OPENMW_ESM_FOGSTATE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace ESM
|
||||
@ -10,7 +11,7 @@ namespace ESM
|
||||
|
||||
struct FogTexture
|
||||
{
|
||||
int mX, mY; // Only used for interior cells
|
||||
int32_t mX, mY; // Only used for interior cells
|
||||
std::vector<char> mImageData;
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,7 @@ namespace ESM
|
||||
|
||||
void GlobalMap::load(ESMReader& esm)
|
||||
{
|
||||
esm.getHNTSized<16>(mBounds, "BNDS");
|
||||
esm.getHNT("BNDS", mBounds.mMinX, mBounds.mMaxX, mBounds.mMinY, mBounds.mMaxY);
|
||||
|
||||
esm.getSubNameIs("DATA");
|
||||
esm.getSubHeader();
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OPENMW_COMPONENTS_ESM_GLOBALMAP_H
|
||||
#define OPENMW_COMPONENTS_ESM_GLOBALMAP_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
@ -21,7 +22,7 @@ namespace ESM
|
||||
// The minimum and maximum cell coordinates
|
||||
struct Bounds
|
||||
{
|
||||
int mMinX, mMaxX, mMinY, mMaxY;
|
||||
int32_t mMinX, mMaxX, mMinY, mMaxY;
|
||||
};
|
||||
|
||||
Bounds mBounds;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
||||
@ -12,8 +14,9 @@ namespace ESM
|
||||
|
||||
mLocals.load(esm);
|
||||
|
||||
mRunning = 0;
|
||||
esm.getHNOT(mRunning, "RUN_");
|
||||
int32_t running = 0;
|
||||
esm.getHNOT(running, "RUN_");
|
||||
mRunning = running != 0;
|
||||
|
||||
mTargetRef = RefNum{};
|
||||
mTargetId = esm.getHNORefId("TARG");
|
||||
@ -33,7 +36,7 @@ namespace ESM
|
||||
mLocals.save(esm);
|
||||
|
||||
if (mRunning)
|
||||
esm.writeHNT("RUN_", mRunning);
|
||||
esm.writeHNT("RUN_", int32_t{ 1 });
|
||||
|
||||
if (!mTargetId.empty())
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ namespace ESM
|
||||
{
|
||||
RefId mId; /// \note must be lowercase
|
||||
Locals mLocals;
|
||||
int mRunning;
|
||||
bool mRunning;
|
||||
RefId mTargetId; // for targeted scripts
|
||||
RefNum mTargetRef;
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
#define OPENMW_ESM_JOURNALENTRY_H
|
||||
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace ESM
|
||||
@ -20,15 +22,15 @@ namespace ESM
|
||||
Type_Quest = 2
|
||||
};
|
||||
|
||||
int mType;
|
||||
int32_t mType;
|
||||
ESM::RefId mTopic;
|
||||
ESM::RefId mInfo;
|
||||
std::string mText;
|
||||
std::string mActorName; // Could also be Actor ID to allow switching of localisation, but since mText is
|
||||
// plaintext anyway...
|
||||
int mDay; // time stamp
|
||||
int mMonth;
|
||||
int mDayOfMonth;
|
||||
int32_t mDay; // time stamp
|
||||
int32_t mMonth;
|
||||
int32_t mDayOfMonth;
|
||||
|
||||
void load(ESMReader& esm);
|
||||
void save(ESMWriter& esm) const;
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include "components/esm/defs.hpp"
|
||||
#include "components/esm/refid.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace ESM
|
||||
@ -18,7 +20,7 @@ namespace ESM
|
||||
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
||||
static std::string_view getRecordType() { return "Activator"; }
|
||||
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
RefId mId, mScript;
|
||||
std::string mName, mModel;
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace ESM
|
||||
mName = esm.getHString();
|
||||
break;
|
||||
case fourCC("ALDT"):
|
||||
esm.getHTSized<12>(mData);
|
||||
esm.getHT(mData.mWeight, mData.mValue, mData.mAutoCalc);
|
||||
hasData = true;
|
||||
break;
|
||||
case fourCC("ENAM"):
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OPENMW_ESM_ALCH_H
|
||||
#define OPENMW_ESM_ALCH_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "components/esm/defs.hpp"
|
||||
@ -27,12 +28,12 @@ namespace ESM
|
||||
struct ALDTstruct
|
||||
{
|
||||
float mWeight;
|
||||
int mValue;
|
||||
int mAutoCalc;
|
||||
int32_t mValue;
|
||||
int32_t mAutoCalc;
|
||||
};
|
||||
ALDTstruct mData;
|
||||
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
RefId mId, mScript;
|
||||
std::string mName, mModel, mIcon;
|
||||
EffectList mEffects;
|
||||
|
@ -28,7 +28,7 @@ namespace ESM
|
||||
mName = esm.getHString();
|
||||
break;
|
||||
case fourCC("AADT"):
|
||||
esm.getHTSized<16>(mData);
|
||||
esm.getHT(mData.mType, mData.mQuality, mData.mWeight, mData.mValue);
|
||||
hasData = true;
|
||||
break;
|
||||
case fourCC("SCRI"):
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OPENMW_ESM_APPA_H
|
||||
#define OPENMW_ESM_APPA_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "components/esm/defs.hpp"
|
||||
@ -33,14 +34,14 @@ namespace ESM
|
||||
|
||||
struct AADTstruct
|
||||
{
|
||||
int mType;
|
||||
int32_t mType;
|
||||
float mQuality;
|
||||
float mWeight;
|
||||
int mValue;
|
||||
int32_t mValue;
|
||||
};
|
||||
|
||||
AADTstruct mData;
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
RefId mId, mScript;
|
||||
std::string mName, mModel, mIcon;
|
||||
|
||||
|
@ -59,7 +59,7 @@ namespace ESM
|
||||
mName = esm.getHString();
|
||||
break;
|
||||
case fourCC("AODT"):
|
||||
esm.getHTSized<24>(mData);
|
||||
esm.getHT(mData.mType, mData.mWeight, mData.mValue, mData.mHealth, mData.mEnchant, mData.mArmor);
|
||||
hasData = true;
|
||||
break;
|
||||
case fourCC("SCRI"):
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OPENMW_ESM_ARMO_H
|
||||
#define OPENMW_ESM_ARMO_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -90,15 +91,15 @@ namespace ESM
|
||||
|
||||
struct AODTstruct
|
||||
{
|
||||
int mType;
|
||||
int32_t mType;
|
||||
float mWeight;
|
||||
int mValue, mHealth, mEnchant, mArmor;
|
||||
int32_t mValue, mHealth, mEnchant, mArmor;
|
||||
};
|
||||
|
||||
AODTstruct mData;
|
||||
PartReferenceList mParts;
|
||||
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
RefId mId, mScript, mEnchant;
|
||||
std::string mName, mModel, mIcon;
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace ESM
|
||||
mRace = esm.getRefId();
|
||||
break;
|
||||
case fourCC("BYDT"):
|
||||
esm.getHTSized<4>(mData);
|
||||
esm.getHT(mData.mPart, mData.mVampire, mData.mFlags, mData.mType);
|
||||
hasData = true;
|
||||
break;
|
||||
case SREC_DELE:
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "components/esm/defs.hpp"
|
||||
#include "components/esm/refid.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace ESM
|
||||
@ -62,7 +63,7 @@ namespace ESM
|
||||
};
|
||||
|
||||
BYDTstruct mData;
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
RefId mId, mRace;
|
||||
std::string mModel;
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace ESM
|
||||
mName = esm.getHString();
|
||||
break;
|
||||
case fourCC("BKDT"):
|
||||
esm.getHTSized<20>(mData);
|
||||
esm.getHT(mData.mWeight, mData.mValue, mData.mIsScroll, mData.mSkillId, mData.mEnchant);
|
||||
hasData = true;
|
||||
break;
|
||||
case fourCC("SCRI"):
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include "components/esm/defs.hpp"
|
||||
#include "components/esm/refid.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace ESM
|
||||
@ -24,12 +26,12 @@ namespace ESM
|
||||
struct BKDTstruct
|
||||
{
|
||||
float mWeight;
|
||||
int mValue, mIsScroll, mSkillId, mEnchant;
|
||||
int32_t mValue, mIsScroll, mSkillId, mEnchant;
|
||||
};
|
||||
|
||||
BKDTstruct mData;
|
||||
std::string mName, mModel, mIcon, mText;
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
RefId mId;
|
||||
RefId mScript, mEnchant;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OPENMW_ESM_BSGN_H
|
||||
#define OPENMW_ESM_BSGN_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "components/esm/defs.hpp"
|
||||
@ -20,7 +21,7 @@ namespace ESM
|
||||
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
||||
static std::string_view getRecordType() { return "BirthSign"; }
|
||||
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
RefId mId;
|
||||
std::string mName, mDescription, mTexture;
|
||||
|
||||
|
@ -11,12 +11,12 @@ namespace ESM
|
||||
const std::string_view Class::sGmstSpecializationIds[3]
|
||||
= { "sSpecializationCombat", "sSpecializationMagic", "sSpecializationStealth" };
|
||||
|
||||
int& Class::CLDTstruct::getSkill(int index, bool major)
|
||||
int32_t& Class::CLDTstruct::getSkill(int index, bool major)
|
||||
{
|
||||
return mSkills.at(index)[major ? 1 : 0];
|
||||
}
|
||||
|
||||
int Class::CLDTstruct::getSkill(int index, bool major) const
|
||||
int32_t Class::CLDTstruct::getSkill(int index, bool major) const
|
||||
{
|
||||
return mSkills.at(index)[major ? 1 : 0];
|
||||
}
|
||||
@ -41,7 +41,8 @@ namespace ESM
|
||||
mName = esm.getHString();
|
||||
break;
|
||||
case fourCC("CLDT"):
|
||||
esm.getHTSized<60>(mData);
|
||||
esm.getHT(
|
||||
mData.mAttribute, mData.mSpecialization, mData.mSkills, mData.mIsPlayable, mData.mServices);
|
||||
if (mData.mIsPlayable > 1)
|
||||
esm.fail("Unknown bool value");
|
||||
hasData = true;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define OPENMW_ESM_CLAS_H
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "components/esm/defs.hpp"
|
||||
@ -34,20 +35,20 @@ namespace ESM
|
||||
|
||||
struct CLDTstruct
|
||||
{
|
||||
std::array<int, 2> mAttribute; // Attributes that get class bonus
|
||||
int mSpecialization; // 0 = Combat, 1 = Magic, 2 = Stealth
|
||||
std::array<std::array<int, 2>, 5> mSkills; // Minor and major skills.
|
||||
int mIsPlayable; // 0x0001 - Playable class
|
||||
int mServices;
|
||||
std::array<int32_t, 2> mAttribute; // Attributes that get class bonus
|
||||
int32_t mSpecialization; // 0 = Combat, 1 = Magic, 2 = Stealth
|
||||
std::array<std::array<int32_t, 2>, 5> mSkills; // Minor and major skills.
|
||||
int32_t mIsPlayable; // 0x0001 - Playable class
|
||||
int32_t mServices;
|
||||
|
||||
int& getSkill(int index, bool major);
|
||||
int32_t& getSkill(int index, bool major);
|
||||
///< Throws an exception for invalid values of \a index.
|
||||
|
||||
int getSkill(int index, bool major) const;
|
||||
int32_t getSkill(int index, bool major) const;
|
||||
///< Throws an exception for invalid values of \a index.
|
||||
}; // 60 bytes
|
||||
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
std::string mName, mDescription;
|
||||
RefId mId;
|
||||
CLDTstruct mData;
|
||||
|
@ -30,7 +30,7 @@ namespace ESM
|
||||
mName = esm.getHString();
|
||||
break;
|
||||
case fourCC("CTDT"):
|
||||
esm.getHTSized<12>(mData);
|
||||
esm.getHT(mData.mType, mData.mWeight, mData.mValue, mData.mEnchant);
|
||||
hasData = true;
|
||||
break;
|
||||
case fourCC("SCRI"):
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OPENMW_ESM_CLOT_H
|
||||
#define OPENMW_ESM_CLOT_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "components/esm/defs.hpp"
|
||||
@ -40,16 +41,16 @@ namespace ESM
|
||||
|
||||
struct CTDTstruct
|
||||
{
|
||||
int mType;
|
||||
int32_t mType;
|
||||
float mWeight;
|
||||
unsigned short mValue;
|
||||
unsigned short mEnchant;
|
||||
uint16_t mValue;
|
||||
uint16_t mEnchant;
|
||||
};
|
||||
CTDTstruct mData;
|
||||
|
||||
PartReferenceList mParts;
|
||||
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
RefId mId, mEnchant, mScript;
|
||||
std::string mModel, mIcon, mName;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OPENMW_ESM_DOOR_H
|
||||
#define OPENMW_ESM_DOOR_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "components/esm/defs.hpp"
|
||||
@ -19,7 +20,7 @@ namespace ESM
|
||||
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
||||
static std::string_view getRecordType() { return "Door"; }
|
||||
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
RefId mId, mScript, mOpenSound, mCloseSound;
|
||||
std::string mName, mModel;
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace ESM
|
||||
hasName = true;
|
||||
break;
|
||||
case fourCC("ENDT"):
|
||||
esm.getHTSized<16>(mData);
|
||||
esm.getHT(mData.mType, mData.mCost, mData.mCharge, mData.mFlags);
|
||||
hasData = true;
|
||||
break;
|
||||
case fourCC("ENAM"):
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef OPENMW_ESM_ENCH_H
|
||||
#define OPENMW_ESM_ENCH_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "components/esm/defs.hpp"
|
||||
@ -39,13 +40,13 @@ namespace ESM
|
||||
|
||||
struct ENDTstruct
|
||||
{
|
||||
int mType;
|
||||
int mCost;
|
||||
int mCharge;
|
||||
int mFlags;
|
||||
int32_t mType;
|
||||
int32_t mCost;
|
||||
int32_t mCharge;
|
||||
int32_t mFlags;
|
||||
};
|
||||
|
||||
unsigned int mRecordFlags;
|
||||
uint32_t mRecordFlags;
|
||||
RefId mId;
|
||||
ENDTstruct mData;
|
||||
EffectList mEffects;
|
||||
|
Loading…
x
Reference in New Issue
Block a user