Remove sized reads from essimporter

macos_ci_fix
Evil Eye 1 year ago
parent a9e6e63c4e
commit dbf9d42cc5

@ -90,14 +90,14 @@ namespace ESSImport
struct MAPH
{
unsigned int size;
unsigned int value;
uint32_t size;
uint32_t value;
};
void ConvertFMAP::read(ESM::ESMReader& esm)
{
MAPH maph;
esm.getHNTSized<8>(maph, "MAPH");
esm.getHNT("MAPH", maph.size, maph.value);
std::vector<char> data;
esm.getSubNameIs("MAPD");
esm.getSubHeader();
@ -278,7 +278,7 @@ namespace ESSImport
while (esm.isNextSub("MPCD"))
{
float notepos[3];
esm.getHTSized<3 * sizeof(float)>(notepos);
esm.getHT(notepos);
// Markers seem to be arranged in a 32*32 grid, notepos has grid-indices.
// This seems to be the reason markers can't be placed everywhere in interior cells,

@ -25,14 +25,12 @@ namespace ESSImport
};
/// Actor data, shared by (at least) REFR and CellRef
#pragma pack(push)
#pragma pack(1)
struct ACDT
{
// Note, not stored at *all*:
// - Level changes are lost on reload, except for the player (there it's in the NPC record).
unsigned char mUnknown[12];
unsigned int mFlags;
uint32_t mFlags;
float mBreathMeter; // Seconds left before drowning
unsigned char mUnknown2[20];
float mDynamic[3][2];
@ -41,7 +39,7 @@ namespace ESSImport
float mMagicEffects[27]; // Effect attributes:
// https://wiki.openmw.org/index.php?title=Research:Magic#Effect_attributes
unsigned char mUnknown4[4];
unsigned int mGoldPool;
uint32_t mGoldPool;
unsigned char mCountDown; // seen the same value as in ACSC.mCorpseClearCountdown, maybe
// this one is for respawning?
unsigned char mUnknown5[3];
@ -60,7 +58,6 @@ namespace ESSImport
unsigned char mUnknown[3];
float mTime;
};
#pragma pack(pop)
struct ActorData
{

@ -48,14 +48,18 @@ namespace ESSImport
if (esm.isNextSub("ACDT"))
{
mActorData.mHasACDT = true;
esm.getHTSized<264>(mActorData.mACDT);
esm.getHT(mActorData.mACDT.mUnknown, mActorData.mACDT.mFlags, mActorData.mACDT.mBreathMeter,
mActorData.mACDT.mUnknown2, mActorData.mACDT.mDynamic, mActorData.mACDT.mUnknown3,
mActorData.mACDT.mAttributes, mActorData.mACDT.mMagicEffects, mActorData.mACDT.mUnknown4,
mActorData.mACDT.mGoldPool, mActorData.mACDT.mCountDown, mActorData.mACDT.mUnknown5);
}
mActorData.mHasACSC = false;
if (esm.isNextSub("ACSC"))
{
mActorData.mHasACSC = true;
esm.getHTSized<112>(mActorData.mACSC);
esm.getHT(mActorData.mACSC.mUnknown1, mActorData.mACSC.mFlags, mActorData.mACSC.mUnknown2,
mActorData.mACSC.mCorpseClearCountdown, mActorData.mACSC.mUnknown3);
}
if (esm.isNextSub("ACSL"))
@ -137,7 +141,7 @@ namespace ESSImport
if (esm.isNextSub("ANIS"))
{
mActorData.mHasANIS = true;
esm.getHTSized<8>(mActorData.mANIS);
esm.getHT(mActorData.mANIS.mGroupIndex, mActorData.mANIS.mUnknown, mActorData.mANIS.mTime);
}
if (esm.isNextSub("LVCR"))
@ -155,13 +159,16 @@ namespace ESSImport
// DATA should occur for all references, except levelled creature spawners
// I've seen DATA *twice* on a creature record, and with the exact same content too! weird
// alarmvoi0000.ess
esm.getHNOTSized<24>(mPos, "DATA");
esm.getHNOTSized<24>(mPos, "DATA");
for (int i = 0; i < 2; ++i)
{
if (esm.isNextSub("DATA"))
esm.getHNT("DATA", mPos.pos, mPos.rot);
}
mDeleted = 0;
if (esm.isNextSub("DELE"))
{
unsigned int deleted;
uint32_t deleted;
esm.getHT(deleted);
mDeleted = ((deleted >> 24) & 0x2) != 0; // the other 3 bytes seem to be uninitialized garbage
}

@ -14,7 +14,7 @@ namespace ESSImport
/// Changed container contents
struct CNTC
{
int mIndex;
int32_t mIndex;
Inventory mInventory;

@ -15,7 +15,7 @@ namespace ESSImport
/// Creature changes
struct CREC
{
int mIndex;
int32_t mIndex;
Inventory mInventory;
ESM::AIPackageList mAiPackages;

@ -8,11 +8,11 @@ namespace ESSImport
void DIAL::load(ESM::ESMReader& esm)
{
// See ESM::Dialogue::Type enum, not sure why we would need this here though
int type = 0;
int32_t type = 0;
esm.getHNOT(type, "DATA");
// Deleted dialogue in a savefile. No clue what this means...
int deleted = 0;
int32_t deleted = 0;
esm.getHNOT(deleted, "DELE");
mIndex = 0;

@ -10,7 +10,7 @@ namespace ESSImport
struct DIAL
{
int mIndex; // Journal index
int32_t mIndex; // Journal index
void load(ESM::ESMReader& esm);
};

@ -9,17 +9,17 @@ namespace ESSImport
{
esm.getSubNameIs("GMDT");
esm.getSubHeader();
if (esm.getSubSize() == 92)
{
esm.getExact(&mGMDT, 92);
mGMDT.mSecundaPhase = 0;
}
else if (esm.getSubSize() == 96)
{
esm.getTSized<96>(mGMDT);
}
else
esm.fail("unexpected subrecord size for GAME.GMDT");
bool hasSecundaPhase = esm.getSubSize() == 96;
esm.getT(mGMDT.mCellName);
esm.getT(mGMDT.mFogColour);
esm.getT(mGMDT.mFogDensity);
esm.getT(mGMDT.mCurrentWeather);
esm.getT(mGMDT.mNextWeather);
esm.getT(mGMDT.mWeatherTransition);
esm.getT(mGMDT.mTimeOfNextTransition);
esm.getT(mGMDT.mMasserPhase);
if (hasSecundaPhase)
esm.getT(mGMDT.mSecundaPhase);
mGMDT.mWeatherTransition &= (0x000000ff);
mGMDT.mSecundaPhase &= (0x000000ff);

@ -15,12 +15,12 @@ namespace ESSImport
struct GMDT
{
char mCellName[64]{};
int mFogColour{ 0 };
int32_t mFogColour{ 0 };
float mFogDensity{ 0.f };
int mCurrentWeather{ 0 }, mNextWeather{ 0 };
int mWeatherTransition{ 0 }; // 0-100 transition between weathers, top 3 bytes may be garbage
int32_t mCurrentWeather{ 0 }, mNextWeather{ 0 };
int32_t mWeatherTransition{ 0 }; // 0-100 transition between weathers, top 3 bytes may be garbage
float mTimeOfNextTransition{ 0.f }; // weather changes when gamehour == timeOfNextTransition
int mMasserPhase{ 0 }, mSecundaPhase{ 0 }; // top 3 bytes may be garbage
int32_t mMasserPhase{ 0 }, mSecundaPhase{ 0 }; // top 3 bytes may be garbage
};
GMDT mGMDT;

@ -12,7 +12,7 @@ namespace ESSImport
while (esm.isNextSub("NPCO"))
{
ContItem contItem;
esm.getHTSized<36>(contItem);
esm.getHT(contItem.mCount, contItem.mItem.mData);
InventoryItem item;
item.mId = contItem.mItem.toString();
@ -28,7 +28,7 @@ namespace ESSImport
bool newStack = esm.isNextSub("XIDX");
if (newStack)
{
unsigned int idx;
uint32_t idx;
esm.getHT(idx);
separateStacks = true;
item.mCount = 1;
@ -40,7 +40,7 @@ namespace ESSImport
bool isDeleted = false;
item.ESM::CellRef::loadData(esm, isDeleted);
int charge = -1;
int32_t charge = -1;
esm.getHNOT(charge, "XHLT");
item.mChargeInt = charge;
@ -60,7 +60,7 @@ namespace ESSImport
// this is currently not handled properly.
esm.getSubHeader();
int itemIndex; // index of the item in the NPCO list
int32_t itemIndex; // index of the item in the NPCO list
esm.getT(itemIndex);
if (itemIndex < 0 || itemIndex >= int(mItems.size()))
@ -68,7 +68,7 @@ namespace ESSImport
// appears to be a relative index for only the *possible* slots this item can be equipped in,
// i.e. 0 most of the time
int slotIndex;
int32_t slotIndex;
esm.getT(slotIndex);
mItems[itemIndex].mRelativeEquipmentSlot = slotIndex;

@ -19,7 +19,7 @@ namespace ESSImport
struct ContItem
{
int mCount;
int32_t mCount;
ESM::NAME32 mItem;
};
@ -28,8 +28,8 @@ namespace ESSImport
struct InventoryItem : public ESM::CellRef
{
std::string mId;
int mCount;
int mRelativeEquipmentSlot;
int32_t mCount;
int32_t mRelativeEquipmentSlot;
SCRI mSCRI;
};
std::vector<InventoryItem> mItems;

@ -10,7 +10,7 @@ namespace ESSImport
while (esm.isNextSub("KNAM"))
{
std::string refId = esm.getHString();
int count;
int32_t count;
esm.getHNT(count, "CNAM");
mKillCounter[refId] = count;
}

@ -18,9 +18,9 @@ namespace ESSImport
void load(ESM::ESMReader& esm);
/// RefId, kill count
std::map<std::string, int> mKillCounter;
std::map<std::string, int32_t> mKillCounter;
int mWerewolfKills;
int32_t mWerewolfKills;
};
}

@ -7,7 +7,7 @@ namespace ESSImport
void NPCC::load(ESM::ESMReader& esm)
{
esm.getHNTSized<8>(mNPDT, "NPDT");
esm.getHNT("NPDT", mNPDT.mDisposition, mNPDT.unknown, mNPDT.mReputation, mNPDT.unknown2, mNPDT.mIndex);
while (esm.isNextSub("AI_W") || esm.isNextSub("AI_E") || esm.isNextSub("AI_T") || esm.isNextSub("AI_F")
|| esm.isNextSub("AI_A"))

@ -21,7 +21,7 @@ namespace ESSImport
unsigned char unknown;
unsigned char mReputation;
unsigned char unknown2;
int mIndex;
int32_t mIndex;
} mNPDT;
Inventory mInventory;

@ -19,7 +19,12 @@ namespace ESSImport
mMNAM = esm.getHString();
}
esm.getHNTSized<212>(mPNAM, "PNAM");
esm.getHNT("PNAM", mPNAM.mPlayerFlags, mPNAM.mLevelProgress, mPNAM.mSkillProgress, mPNAM.mSkillIncreases,
mPNAM.mTelekinesisRangeBonus, mPNAM.mVisionBonus, mPNAM.mDetectKeyMagnitude,
mPNAM.mDetectEnchantmentMagnitude, mPNAM.mDetectAnimalMagnitude, mPNAM.mMarkLocation.mX,
mPNAM.mMarkLocation.mY, mPNAM.mMarkLocation.mZ, mPNAM.mMarkLocation.mRotZ, mPNAM.mMarkLocation.mCellX,
mPNAM.mMarkLocation.mCellY, mPNAM.mUnknown3, mPNAM.mVerticalRotation.mData, mPNAM.mSpecIncreases,
mPNAM.mUnknown4);
if (esm.isNextSub("SNAM"))
esm.skipHSub();
@ -54,7 +59,7 @@ namespace ESSImport
if (esm.isNextSub("ENAM"))
{
mHasENAM = true;
esm.getHTSized<8>(mENAM);
esm.getHT(mENAM.mCellX, mENAM.mCellY);
}
if (esm.isNextSub("LNAM"))
@ -63,7 +68,8 @@ namespace ESSImport
while (esm.isNextSub("FNAM"))
{
FNAM fnam;
esm.getHTSized<44>(fnam);
esm.getHT(
fnam.mRank, fnam.mUnknown1, fnam.mReputation, fnam.mFlags, fnam.mUnknown2, fnam.mFactionName.mData);
mFactions.push_back(fnam);
}
@ -71,7 +77,7 @@ namespace ESSImport
if (esm.isNextSub("AADT")) // Attack animation data?
{
mHasAADT = true;
esm.getHTSized<44>(mAADT);
esm.getHT(mAADT.animGroupIndex, mAADT.mUnknown5);
}
if (esm.isNextSub("KNAM"))

@ -17,7 +17,7 @@ namespace ESSImport
/// Other player data
struct PCDT
{
int mBounty;
int32_t mBounty;
std::string mBirthsign;
std::vector<std::string> mKnownDialogueTopics;
@ -41,13 +41,11 @@ namespace ESSImport
PlayerFlags_LevitationDisabled = 0x80000
};
#pragma pack(push)
#pragma pack(1)
struct FNAM
{
unsigned char mRank;
unsigned char mUnknown1[3];
int mReputation;
int32_t mReputation;
unsigned char mFlags; // 0x1: unknown, 0x2: expelled
unsigned char mUnknown2[3];
ESM::NAME32 mFactionName;
@ -59,7 +57,7 @@ namespace ESSImport
{
float mX, mY, mZ; // worldspace position
float mRotZ; // Z angle in radians
int mCellX, mCellY; // grid coordinates; for interior cells this is always (0, 0)
int32_t mCellX, mCellY; // grid coordinates; for interior cells this is always (0, 0)
};
struct Rotation
@ -67,15 +65,15 @@ namespace ESSImport
float mData[3][3];
};
int mPlayerFlags; // controls, camera and draw state
unsigned int mLevelProgress;
int32_t mPlayerFlags; // controls, camera and draw state
uint32_t mLevelProgress;
float mSkillProgress[27]; // skill progress, non-uniform scaled
unsigned char mSkillIncreases[8]; // number of skill increases for each attribute
int mTelekinesisRangeBonus; // in units; seems redundant
int32_t mTelekinesisRangeBonus; // in units; seems redundant
float mVisionBonus; // range: <0.0, 1.0>; affected by light spells and Get/Mod/SetPCVisionBonus
int mDetectKeyMagnitude; // seems redundant
int mDetectEnchantmentMagnitude; // seems redundant
int mDetectAnimalMagnitude; // seems redundant
int32_t mDetectKeyMagnitude; // seems redundant
int32_t mDetectEnchantmentMagnitude; // seems redundant
int32_t mDetectAnimalMagnitude; // seems redundant
MarkLocation mMarkLocation;
unsigned char mUnknown3[4];
Rotation mVerticalRotation;
@ -85,16 +83,15 @@ namespace ESSImport
struct ENAM
{
int mCellX;
int mCellY;
int32_t mCellX;
int32_t mCellY;
};
struct AADT // 44 bytes
{
int animGroupIndex; // See convertANIS() for the mapping.
int32_t animGroupIndex; // See convertANIS() for the mapping.
unsigned char mUnknown5[40];
};
#pragma pack(pop)
std::vector<FNAM> mFactions;
PNAM mPNAM;

@ -10,7 +10,9 @@ namespace ESSImport
while (esm.isNextSub("PNAM"))
{
PNAM pnam;
esm.getHTSized<184>(pnam);
esm.getHT(pnam.mAttackStrength, pnam.mSpeed, pnam.mUnknown, pnam.mFlightTime, pnam.mSplmIndex,
pnam.mUnknown2, pnam.mVelocity.mValues, pnam.mPosition.mValues, pnam.mUnknown3, pnam.mActorId.mData,
pnam.mArrowId.mData, pnam.mBowId.mData);
mProjectiles.push_back(pnam);
}
}

@ -16,15 +16,13 @@ namespace ESSImport
struct PROJ
{
#pragma pack(push)
#pragma pack(1)
struct PNAM // 184 bytes
{
float mAttackStrength;
float mSpeed;
unsigned char mUnknown[4 * 2];
float mFlightTime;
int mSplmIndex; // reference to a SPLM record (0 for ballistic projectiles)
int32_t mSplmIndex; // reference to a SPLM record (0 for ballistic projectiles)
unsigned char mUnknown2[4];
ESM::Vector3 mVelocity;
ESM::Vector3 mPosition;
@ -35,7 +33,6 @@ namespace ESSImport
bool isMagic() const { return mSplmIndex != 0; }
};
#pragma pack(pop)
std::vector<PNAM> mProjectiles;

@ -7,7 +7,8 @@ namespace ESSImport
void SCPT::load(ESM::ESMReader& esm)
{
esm.getHNTSized<52>(mSCHD, "SCHD");
esm.getHNT("SCHD", mSCHD.mName.mData, mSCHD.mData.mNumShorts, mSCHD.mData.mNumLongs, mSCHD.mData.mNumFloats,
mSCHD.mData.mScriptDataSize, mSCHD.mData.mStringTableSize);
mSCRI.load(esm);

@ -29,7 +29,7 @@ namespace ESSImport
SCRI mSCRI;
bool mRunning;
int mRefNum; // Targeted reference, -1: no reference
int32_t mRefNum; // Targeted reference, -1: no reference
void load(ESM::ESMReader& esm);
};

@ -9,7 +9,7 @@ namespace ESSImport
{
mScript = esm.getHNOString("SCRI");
int numShorts = 0, numLongs = 0, numFloats = 0;
int32_t numShorts = 0, numLongs = 0, numFloats = 0;
if (esm.isNextSub("SLCS"))
{
esm.getSubHeader();
@ -23,7 +23,7 @@ namespace ESSImport
esm.getSubHeader();
for (int i = 0; i < numShorts; ++i)
{
short val;
int16_t val;
esm.getT(val);
mShorts.push_back(val);
}
@ -35,7 +35,7 @@ namespace ESSImport
esm.getSubHeader();
for (int i = 0; i < numLongs; ++i)
{
int val;
int32_t val;
esm.getT(val);
mLongs.push_back(val);
}

@ -11,13 +11,15 @@ namespace ESSImport
{
ActiveSpell spell;
esm.getHT(spell.mIndex);
esm.getHNTSized<160>(spell.mSPDT, "SPDT");
esm.getHNT("SPDT", spell.mSPDT.mType, spell.mSPDT.mId.mData, spell.mSPDT.mUnknown,
spell.mSPDT.mCasterId.mData, spell.mSPDT.mSourceId.mData, spell.mSPDT.mUnknown2);
spell.mTarget = esm.getHNOString("TNAM");
while (esm.isNextSub("NPDT"))
{
ActiveEffect effect;
esm.getHTSized<56>(effect.mNPDT);
esm.getHT(effect.mNPDT.mAffectedActorId.mData, effect.mNPDT.mUnknown, effect.mNPDT.mMagnitude,
effect.mNPDT.mSecondsActive, effect.mNPDT.mUnknown2);
// Effect-specific subrecords can follow:
// - INAM for disintegration and bound effects

@ -15,11 +15,9 @@ namespace ESSImport
struct SPLM
{
#pragma pack(push)
#pragma pack(1)
struct SPDT // 160 bytes
{
int mType; // 1 = spell, 2 = enchantment, 3 = potion
int32_t mType; // 1 = spell, 2 = enchantment, 3 = potion
ESM::NAME32 mId; // base ID of a spell/enchantment/potion
unsigned char mUnknown[4 * 4];
ESM::NAME32 mCasterId;
@ -31,31 +29,29 @@ namespace ESSImport
{
ESM::NAME32 mAffectedActorId;
unsigned char mUnknown[4 * 2];
int mMagnitude;
int32_t mMagnitude;
float mSecondsActive;
unsigned char mUnknown2[4 * 2];
};
struct INAM // 40 bytes
{
int mUnknown;
int32_t mUnknown;
unsigned char mUnknown2;
ESM::FixedString<35> mItemId; // disintegrated item / bound item / item to re-equip after expiration
};
struct CNAM // 36 bytes
{
int mUnknown; // seems to always be 0
int32_t mUnknown; // seems to always be 0
ESM::NAME32 mSummonedOrCommandedActor[32];
};
struct VNAM // 4 bytes
{
int mUnknown;
int32_t mUnknown;
};
#pragma pack(pop)
struct ActiveEffect
{
NPDT mNPDT;
@ -63,7 +59,7 @@ namespace ESSImport
struct ActiveSpell
{
int mIndex;
int32_t mIndex;
SPDT mSPDT;
std::string mTarget;
std::vector<ActiveEffect> mActiveEffects;

Loading…
Cancel
Save