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(); mName = esm.getHString();
break; break;
case fourCC("RIDT"): case fourCC("RIDT"):
esm.getHTSized<16>(mData); esm.getHT(mData.mWeight, mData.mValue, mData.mUses, mData.mQuality);
hasData = true; hasData = true;
break; break;
case fourCC("SCRI"): case fourCC("SCRI"):

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

@ -12,12 +12,12 @@ namespace ESM
{ {
void Script::loadSCVR(ESMReader& esm) void Script::loadSCVR(ESMReader& esm)
{ {
int s = mData.mStringTableSize; uint32_t s = mData.mStringTableSize;
std::vector<char> tmp(s); std::vector<char> tmp(s);
// not using getHExact, vanilla doesn't seem to mind unused bytes at the end // not using getHExact, vanilla doesn't seem to mind unused bytes at the end
esm.getSubHeader(); esm.getSubHeader();
int left = esm.getSubSize(); uint32_t left = esm.getSubSize();
if (left < s) if (left < s)
esm.fail("SCVR string list is smaller than specified"); esm.fail("SCVR string list is smaller than specified");
esm.getExact(tmp.data(), s); esm.getExact(tmp.data(), s);
@ -99,7 +99,11 @@ namespace ESM
{ {
esm.getSubHeader(); esm.getSubHeader();
mId = esm.getMaybeFixedRefIdSize(32); 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; hasHeader = true;
break; break;
@ -114,7 +118,7 @@ namespace ESM
esm.getSubHeader(); esm.getSubHeader();
uint32_t subSize = esm.getSubSize(); uint32_t subSize = esm.getSubSize();
if (subSize != static_cast<uint32_t>(mData.mScriptDataSize)) if (subSize != mData.mScriptDataSize)
{ {
std::stringstream ss; std::stringstream ss;
ss << "Script data size defined in SCHD subrecord does not match size of SCDT subrecord"; 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. /// Data from script-precompling in the editor.
/// \warning Do not use them. OpenCS currently does not precompile scripts. /// \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 struct SCHD
{ {
@ -37,7 +37,7 @@ namespace ESM
Script::SCHDstruct mData; Script::SCHDstruct mData;
}; };
unsigned int mRecordFlags; uint32_t mRecordFlags;
RefId mId; RefId mId;
SCHDstruct mData; SCHDstruct mData;

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

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

@ -29,7 +29,8 @@ namespace ESM
mName = esm.getHString(); mName = esm.getHString();
break; break;
case fourCC("WPDT"): 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; hasData = true;
break; break;
case fourCC("SCRI"): case fourCC("SCRI"):

@ -62,19 +62,19 @@ namespace ESM
struct WPDTstruct struct WPDTstruct
{ {
float mWeight; float mWeight;
int mValue; int32_t mValue;
short mType; int16_t mType;
unsigned short mHealth; uint16_t mHealth;
float mSpeed, mReach; 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 unsigned char mChop[2], mSlash[2], mThrust[2]; // Min and max
int mFlags; int32_t mFlags;
}; // 32 bytes }; // 32 bytes
#pragma pack(pop) #pragma pack(pop)
WPDTstruct mData; WPDTstruct mData;
unsigned int mRecordFlags; uint32_t mRecordFlags;
RefId mId, mEnchant, mScript; RefId mId, mEnchant, mScript;
std::string mName, mModel, mIcon; std::string mName, mModel, mIcon;

Loading…
Cancel
Save