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 struct MAPH
{ {
unsigned int size; uint32_t size;
unsigned int value; uint32_t value;
}; };
void ConvertFMAP::read(ESM::ESMReader& esm) void ConvertFMAP::read(ESM::ESMReader& esm)
{ {
MAPH maph; MAPH maph;
esm.getHNTSized<8>(maph, "MAPH"); esm.getHNT("MAPH", maph.size, maph.value);
std::vector<char> data; std::vector<char> data;
esm.getSubNameIs("MAPD"); esm.getSubNameIs("MAPD");
esm.getSubHeader(); esm.getSubHeader();
@ -278,7 +278,7 @@ namespace ESSImport
while (esm.isNextSub("MPCD")) while (esm.isNextSub("MPCD"))
{ {
float notepos[3]; 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. // 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, // 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 /// Actor data, shared by (at least) REFR and CellRef
#pragma pack(push)
#pragma pack(1)
struct ACDT struct ACDT
{ {
// Note, not stored at *all*: // Note, not stored at *all*:
// - Level changes are lost on reload, except for the player (there it's in the NPC record). // - Level changes are lost on reload, except for the player (there it's in the NPC record).
unsigned char mUnknown[12]; unsigned char mUnknown[12];
unsigned int mFlags; uint32_t mFlags;
float mBreathMeter; // Seconds left before drowning float mBreathMeter; // Seconds left before drowning
unsigned char mUnknown2[20]; unsigned char mUnknown2[20];
float mDynamic[3][2]; float mDynamic[3][2];
@ -41,7 +39,7 @@ namespace ESSImport
float mMagicEffects[27]; // Effect attributes: float mMagicEffects[27]; // Effect attributes:
// https://wiki.openmw.org/index.php?title=Research:Magic#Effect_attributes // https://wiki.openmw.org/index.php?title=Research:Magic#Effect_attributes
unsigned char mUnknown4[4]; unsigned char mUnknown4[4];
unsigned int mGoldPool; uint32_t mGoldPool;
unsigned char mCountDown; // seen the same value as in ACSC.mCorpseClearCountdown, maybe unsigned char mCountDown; // seen the same value as in ACSC.mCorpseClearCountdown, maybe
// this one is for respawning? // this one is for respawning?
unsigned char mUnknown5[3]; unsigned char mUnknown5[3];
@ -60,7 +58,6 @@ namespace ESSImport
unsigned char mUnknown[3]; unsigned char mUnknown[3];
float mTime; float mTime;
}; };
#pragma pack(pop)
struct ActorData struct ActorData
{ {

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

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

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

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

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

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

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

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

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

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

@ -18,9 +18,9 @@ namespace ESSImport
void load(ESM::ESMReader& esm); void load(ESM::ESMReader& esm);
/// RefId, kill count /// 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) 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") while (esm.isNextSub("AI_W") || esm.isNextSub("AI_E") || esm.isNextSub("AI_T") || esm.isNextSub("AI_F")
|| esm.isNextSub("AI_A")) || esm.isNextSub("AI_A"))

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

@ -19,7 +19,12 @@ namespace ESSImport
mMNAM = esm.getHString(); 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")) if (esm.isNextSub("SNAM"))
esm.skipHSub(); esm.skipHSub();
@ -54,7 +59,7 @@ namespace ESSImport
if (esm.isNextSub("ENAM")) if (esm.isNextSub("ENAM"))
{ {
mHasENAM = true; mHasENAM = true;
esm.getHTSized<8>(mENAM); esm.getHT(mENAM.mCellX, mENAM.mCellY);
} }
if (esm.isNextSub("LNAM")) if (esm.isNextSub("LNAM"))
@ -63,7 +68,8 @@ namespace ESSImport
while (esm.isNextSub("FNAM")) while (esm.isNextSub("FNAM"))
{ {
FNAM 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); mFactions.push_back(fnam);
} }
@ -71,7 +77,7 @@ namespace ESSImport
if (esm.isNextSub("AADT")) // Attack animation data? if (esm.isNextSub("AADT")) // Attack animation data?
{ {
mHasAADT = true; mHasAADT = true;
esm.getHTSized<44>(mAADT); esm.getHT(mAADT.animGroupIndex, mAADT.mUnknown5);
} }
if (esm.isNextSub("KNAM")) if (esm.isNextSub("KNAM"))

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

@ -10,7 +10,9 @@ namespace ESSImport
while (esm.isNextSub("PNAM")) while (esm.isNextSub("PNAM"))
{ {
PNAM 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); mProjectiles.push_back(pnam);
} }
} }

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

@ -7,7 +7,8 @@ namespace ESSImport
void SCPT::load(ESM::ESMReader& esm) 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); mSCRI.load(esm);

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

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

@ -11,13 +11,15 @@ namespace ESSImport
{ {
ActiveSpell spell; ActiveSpell spell;
esm.getHT(spell.mIndex); 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"); spell.mTarget = esm.getHNOString("TNAM");
while (esm.isNextSub("NPDT")) while (esm.isNextSub("NPDT"))
{ {
ActiveEffect effect; 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: // Effect-specific subrecords can follow:
// - INAM for disintegration and bound effects // - INAM for disintegration and bound effects

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

Loading…
Cancel
Save