Replace more explicitly sized reads

macos_ci_fix
Evil Eye 1 year ago
parent bb6fdc1e21
commit 1c47062083

@ -28,7 +28,7 @@ namespace ESM
mName = esm.getHString();
break;
case fourCC("RIDT"):
esm.getHTSized<16>(mData);
esm.getHT(mData.mWeight, mData.mValue, mData.mUses, mData.mQuality);
hasData = true;
break;
case fourCC("SCRI"):

@ -22,14 +22,14 @@ namespace ESM
struct Data
{
float mWeight;
int mValue;
int32_t mValue;
int mUses;
int32_t mUses;
float mQuality;
}; // Size = 16
Data mData;
unsigned int mRecordFlags;
uint32_t mRecordFlags;
RefId mId, mScript;
std::string mName, mModel, mIcon;

@ -12,12 +12,12 @@ namespace ESM
{
void Script::loadSCVR(ESMReader& esm)
{
int s = mData.mStringTableSize;
uint32_t s = mData.mStringTableSize;
std::vector<char> tmp(s);
// not using getHExact, vanilla doesn't seem to mind unused bytes at the end
esm.getSubHeader();
int left = esm.getSubSize();
uint32_t left = esm.getSubSize();
if (left < s)
esm.fail("SCVR string list is smaller than specified");
esm.getExact(tmp.data(), s);
@ -99,7 +99,11 @@ namespace ESM
{
esm.getSubHeader();
mId = esm.getMaybeFixedRefIdSize(32);
esm.getTSized<20>(mData);
esm.getT(mData.mNumShorts);
esm.getT(mData.mNumLongs);
esm.getT(mData.mNumFloats);
esm.getT(mData.mScriptDataSize);
esm.getT(mData.mStringTableSize);
hasHeader = true;
break;
@ -114,7 +118,7 @@ namespace ESM
esm.getSubHeader();
uint32_t subSize = esm.getSubSize();
if (subSize != static_cast<uint32_t>(mData.mScriptDataSize))
if (subSize != mData.mScriptDataSize)
{
std::stringstream ss;
ss << "Script data size defined in SCHD subrecord does not match size of SCDT subrecord";

@ -29,7 +29,7 @@ namespace ESM
{
/// Data from script-precompling in the editor.
/// \warning Do not use them. OpenCS currently does not precompile scripts.
int mNumShorts, mNumLongs, mNumFloats, mScriptDataSize, mStringTableSize;
uint32_t mNumShorts, mNumLongs, mNumFloats, mScriptDataSize, mStringTableSize;
};
struct SCHD
{
@ -37,7 +37,7 @@ namespace ESM
Script::SCHDstruct mData;
};
unsigned int mRecordFlags;
uint32_t mRecordFlags;
RefId mId;
SCHDstruct mData;

@ -55,7 +55,7 @@ namespace ESM
hasIndex = true;
break;
case fourCC("SKDT"):
esm.getHTSized<24>(mData);
esm.getHT(mData.mAttribute, mData.mSpecialization, mData.mUseValue);
hasData = true;
break;
case fourCC("DESC"):

@ -24,7 +24,7 @@ namespace ESM
ESM::RefId mFailureSound;
ESM::RefId mHitSound;
std::string mName;
int mAutoCalcMax;
int32_t mAutoCalcMax;
static constexpr int Length = 6;
@ -44,13 +44,13 @@ namespace ESM
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "Skill"; }
unsigned int mRecordFlags;
uint32_t mRecordFlags;
SkillId mId;
struct SKDTstruct
{
int mAttribute; // see defs.hpp
int mSpecialization; // 0 - Combat, 1 - Magic, 2 - Stealth
int32_t mAttribute; // see defs.hpp
int32_t mSpecialization; // 0 - Combat, 1 - Magic, 2 - Stealth
float mUseValue[4]; // How much skill improves through use. Meaning
// of each field depends on what skill this
// is. We should document this better later.

@ -29,7 +29,8 @@ namespace ESM
mName = esm.getHString();
break;
case fourCC("WPDT"):
esm.getHTSized<32>(mData);
esm.getHT(mData.mWeight, mData.mValue, mData.mType, mData.mHealth, mData.mSpeed, mData.mReach,
mData.mEnchant, mData.mChop, mData.mSlash, mData.mThrust, mData.mFlags);
hasData = true;
break;
case fourCC("SCRI"):

@ -62,19 +62,19 @@ namespace ESM
struct WPDTstruct
{
float mWeight;
int mValue;
short mType;
unsigned short mHealth;
int32_t mValue;
int16_t mType;
uint16_t mHealth;
float mSpeed, mReach;
unsigned short mEnchant; // Enchantment points. The real value is mEnchant/10.f
uint16_t mEnchant; // Enchantment points. The real value is mEnchant/10.f
unsigned char mChop[2], mSlash[2], mThrust[2]; // Min and max
int mFlags;
int32_t mFlags;
}; // 32 bytes
#pragma pack(pop)
WPDTstruct mData;
unsigned int mRecordFlags;
uint32_t mRecordFlags;
RefId mId, mEnchant, mScript;
std::string mName, mModel, mIcon;

Loading…
Cancel
Save