mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 08:15:37 +00:00
Replace explicitly sized reads in aisequence
This commit is contained in:
parent
84e71f4977
commit
48484c9416
3 changed files with 24 additions and 19 deletions
|
@ -13,13 +13,13 @@ namespace ESM
|
|||
|
||||
void AiWander::load(ESMReader& esm)
|
||||
{
|
||||
esm.getHNTSized<14>(mData, "DATA");
|
||||
esm.getHNTSized<8>(mDurationData, "STAR"); // was mStartTime
|
||||
esm.getHNT("DATA", mData.mDistance, mData.mDuration, mData.mTimeOfDay, mData.mIdle, mData.mShouldRepeat);
|
||||
esm.getHNT("STAR", mDurationData.mRemainingDuration, mDurationData.unused); // was mStartTime
|
||||
mStoredInitialActorPosition = false;
|
||||
if (esm.isNextSub("POS_"))
|
||||
{
|
||||
mStoredInitialActorPosition = true;
|
||||
esm.getHTSized<12>(mInitialActorPosition);
|
||||
esm.getHT(mInitialActorPosition.mValues);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace ESM
|
|||
|
||||
void AiTravel::load(ESMReader& esm)
|
||||
{
|
||||
esm.getHNTSized<12>(mData, "DATA");
|
||||
esm.getHNT("DATA", mData.mX, mData.mY, mData.mZ);
|
||||
esm.getHNOT(mHidden, "HIDD");
|
||||
mRepeat = false;
|
||||
esm.getHNOT(mRepeat, "REPT");
|
||||
|
@ -49,7 +49,7 @@ namespace ESM
|
|||
|
||||
void AiEscort::load(ESMReader& esm)
|
||||
{
|
||||
esm.getHNTSized<14>(mData, "DATA");
|
||||
esm.getHNT("DATA", mData.mX, mData.mY, mData.mZ, mData.mDuration);
|
||||
mTargetId = esm.getHNRefId("TARG");
|
||||
mTargetActorId = -1;
|
||||
esm.getHNOT(mTargetActorId, "TAID");
|
||||
|
@ -81,7 +81,7 @@ namespace ESM
|
|||
|
||||
void AiFollow::load(ESMReader& esm)
|
||||
{
|
||||
esm.getHNTSized<14>(mData, "DATA");
|
||||
esm.getHNT("DATA", mData.mX, mData.mY, mData.mZ, mData.mDuration);
|
||||
mTargetId = esm.getHNRefId("TARG");
|
||||
mTargetActorId = -1;
|
||||
esm.getHNOT(mTargetActorId, "TAID");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef OPENMW_COMPONENTS_ESM_AISEQUENCE_H
|
||||
#define OPENMW_COMPONENTS_ESM_AISEQUENCE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -38,8 +39,8 @@ namespace ESM
|
|||
#pragma pack(push, 1)
|
||||
struct AiWanderData
|
||||
{
|
||||
short mDistance;
|
||||
short mDuration;
|
||||
int16_t mDistance;
|
||||
int16_t mDuration;
|
||||
unsigned char mTimeOfDay;
|
||||
unsigned char mIdle[8];
|
||||
unsigned char mShouldRepeat;
|
||||
|
@ -47,7 +48,7 @@ namespace ESM
|
|||
struct AiWanderDuration
|
||||
{
|
||||
float mRemainingDuration;
|
||||
int unused;
|
||||
int32_t unused;
|
||||
};
|
||||
struct AiTravelData
|
||||
{
|
||||
|
@ -56,7 +57,7 @@ namespace ESM
|
|||
struct AiEscortData
|
||||
{
|
||||
float mX, mY, mZ;
|
||||
short mDuration;
|
||||
int16_t mDuration;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
@ -89,7 +90,7 @@ namespace ESM
|
|||
{
|
||||
AiEscortData mData;
|
||||
|
||||
int mTargetActorId;
|
||||
int32_t mTargetActorId;
|
||||
ESM::RefId mTargetId;
|
||||
std::string mCellId;
|
||||
float mRemainingDuration;
|
||||
|
@ -103,7 +104,7 @@ namespace ESM
|
|||
{
|
||||
AiEscortData mData;
|
||||
|
||||
int mTargetActorId;
|
||||
int32_t mTargetActorId;
|
||||
ESM::RefId mTargetId;
|
||||
std::string mCellId;
|
||||
float mRemainingDuration;
|
||||
|
@ -129,7 +130,7 @@ namespace ESM
|
|||
|
||||
struct AiCombat : AiPackage
|
||||
{
|
||||
int mTargetActorId;
|
||||
int32_t mTargetActorId;
|
||||
|
||||
void load(ESMReader& esm);
|
||||
void save(ESMWriter& esm) const;
|
||||
|
@ -137,7 +138,7 @@ namespace ESM
|
|||
|
||||
struct AiPursue : AiPackage
|
||||
{
|
||||
int mTargetActorId;
|
||||
int32_t mTargetActorId;
|
||||
|
||||
void load(ESMReader& esm);
|
||||
void save(ESMWriter& esm) const;
|
||||
|
@ -145,7 +146,7 @@ namespace ESM
|
|||
|
||||
struct AiPackageContainer
|
||||
{
|
||||
int mType;
|
||||
int32_t mType;
|
||||
|
||||
std::unique_ptr<AiPackage> mPackage;
|
||||
};
|
||||
|
@ -155,7 +156,7 @@ namespace ESM
|
|||
AiSequence() { mLastAiPackage = -1; }
|
||||
|
||||
std::vector<AiPackageContainer> mPackages;
|
||||
int mLastAiPackage;
|
||||
int32_t mLastAiPackage;
|
||||
|
||||
void load(ESMReader& esm);
|
||||
void save(ESMWriter& esm) const;
|
||||
|
|
|
@ -172,10 +172,14 @@ namespace ESM
|
|||
}
|
||||
|
||||
// Get data of a given type/size, including subrecord header
|
||||
template <typename X, typename = std::enable_if_t<IsReadable<X>>>
|
||||
void getHT(X& x)
|
||||
template <class... Args>
|
||||
void getHT(Args&... args)
|
||||
{
|
||||
getHTSized<sizeof(X)>(x);
|
||||
constexpr size_t size = (0 + ... + sizeof(Args));
|
||||
getSubHeader();
|
||||
if (mCtx.leftSub != size)
|
||||
reportSubSizeMismatch(size, mCtx.leftSub);
|
||||
(getT(args), ...);
|
||||
}
|
||||
|
||||
template <typename T, typename = std::enable_if_t<IsReadable<T>>>
|
||||
|
|
Loading…
Reference in a new issue