mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 21:35:24 +00:00
Merge branch 'sizeup' into 'master'
Replace more sized reads See merge request OpenMW/openmw!3322
This commit is contained in:
commit
c9f03b4174
@ -13,13 +13,13 @@ namespace ESM
|
|||||||
|
|
||||||
void AiWander::load(ESMReader& esm)
|
void AiWander::load(ESMReader& esm)
|
||||||
{
|
{
|
||||||
esm.getHNTSized<14>(mData, "DATA");
|
esm.getHNT("DATA", mData.mDistance, mData.mDuration, mData.mTimeOfDay, mData.mIdle, mData.mShouldRepeat);
|
||||||
esm.getHNTSized<8>(mDurationData, "STAR"); // was mStartTime
|
esm.getHNT("STAR", mDurationData.mRemainingDuration, mDurationData.unused); // was mStartTime
|
||||||
mStoredInitialActorPosition = false;
|
mStoredInitialActorPosition = false;
|
||||||
if (esm.isNextSub("POS_"))
|
if (esm.isNextSub("POS_"))
|
||||||
{
|
{
|
||||||
mStoredInitialActorPosition = true;
|
mStoredInitialActorPosition = true;
|
||||||
esm.getHTSized<12>(mInitialActorPosition);
|
esm.getHT(mInitialActorPosition.mValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ namespace ESM
|
|||||||
|
|
||||||
void AiTravel::load(ESMReader& esm)
|
void AiTravel::load(ESMReader& esm)
|
||||||
{
|
{
|
||||||
esm.getHNTSized<12>(mData, "DATA");
|
esm.getHNT("DATA", mData.mX, mData.mY, mData.mZ);
|
||||||
esm.getHNOT(mHidden, "HIDD");
|
esm.getHNOT(mHidden, "HIDD");
|
||||||
mRepeat = false;
|
mRepeat = false;
|
||||||
esm.getHNOT(mRepeat, "REPT");
|
esm.getHNOT(mRepeat, "REPT");
|
||||||
@ -49,7 +49,7 @@ namespace ESM
|
|||||||
|
|
||||||
void AiEscort::load(ESMReader& 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");
|
mTargetId = esm.getHNRefId("TARG");
|
||||||
mTargetActorId = -1;
|
mTargetActorId = -1;
|
||||||
esm.getHNOT(mTargetActorId, "TAID");
|
esm.getHNOT(mTargetActorId, "TAID");
|
||||||
@ -81,7 +81,7 @@ namespace ESM
|
|||||||
|
|
||||||
void AiFollow::load(ESMReader& 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");
|
mTargetId = esm.getHNRefId("TARG");
|
||||||
mTargetActorId = -1;
|
mTargetActorId = -1;
|
||||||
esm.getHNOT(mTargetActorId, "TAID");
|
esm.getHNOT(mTargetActorId, "TAID");
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef OPENMW_COMPONENTS_ESM_AISEQUENCE_H
|
#ifndef OPENMW_COMPONENTS_ESM_AISEQUENCE_H
|
||||||
#define OPENMW_COMPONENTS_ESM_AISEQUENCE_H
|
#define OPENMW_COMPONENTS_ESM_AISEQUENCE_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -38,8 +39,8 @@ namespace ESM
|
|||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct AiWanderData
|
struct AiWanderData
|
||||||
{
|
{
|
||||||
short mDistance;
|
int16_t mDistance;
|
||||||
short mDuration;
|
int16_t mDuration;
|
||||||
unsigned char mTimeOfDay;
|
unsigned char mTimeOfDay;
|
||||||
unsigned char mIdle[8];
|
unsigned char mIdle[8];
|
||||||
unsigned char mShouldRepeat;
|
unsigned char mShouldRepeat;
|
||||||
@ -47,7 +48,7 @@ namespace ESM
|
|||||||
struct AiWanderDuration
|
struct AiWanderDuration
|
||||||
{
|
{
|
||||||
float mRemainingDuration;
|
float mRemainingDuration;
|
||||||
int unused;
|
int32_t unused;
|
||||||
};
|
};
|
||||||
struct AiTravelData
|
struct AiTravelData
|
||||||
{
|
{
|
||||||
@ -56,7 +57,7 @@ namespace ESM
|
|||||||
struct AiEscortData
|
struct AiEscortData
|
||||||
{
|
{
|
||||||
float mX, mY, mZ;
|
float mX, mY, mZ;
|
||||||
short mDuration;
|
int16_t mDuration;
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
@ -89,7 +90,7 @@ namespace ESM
|
|||||||
{
|
{
|
||||||
AiEscortData mData;
|
AiEscortData mData;
|
||||||
|
|
||||||
int mTargetActorId;
|
int32_t mTargetActorId;
|
||||||
ESM::RefId mTargetId;
|
ESM::RefId mTargetId;
|
||||||
std::string mCellId;
|
std::string mCellId;
|
||||||
float mRemainingDuration;
|
float mRemainingDuration;
|
||||||
@ -103,7 +104,7 @@ namespace ESM
|
|||||||
{
|
{
|
||||||
AiEscortData mData;
|
AiEscortData mData;
|
||||||
|
|
||||||
int mTargetActorId;
|
int32_t mTargetActorId;
|
||||||
ESM::RefId mTargetId;
|
ESM::RefId mTargetId;
|
||||||
std::string mCellId;
|
std::string mCellId;
|
||||||
float mRemainingDuration;
|
float mRemainingDuration;
|
||||||
@ -129,7 +130,7 @@ namespace ESM
|
|||||||
|
|
||||||
struct AiCombat : AiPackage
|
struct AiCombat : AiPackage
|
||||||
{
|
{
|
||||||
int mTargetActorId;
|
int32_t mTargetActorId;
|
||||||
|
|
||||||
void load(ESMReader& esm);
|
void load(ESMReader& esm);
|
||||||
void save(ESMWriter& esm) const;
|
void save(ESMWriter& esm) const;
|
||||||
@ -137,7 +138,7 @@ namespace ESM
|
|||||||
|
|
||||||
struct AiPursue : AiPackage
|
struct AiPursue : AiPackage
|
||||||
{
|
{
|
||||||
int mTargetActorId;
|
int32_t mTargetActorId;
|
||||||
|
|
||||||
void load(ESMReader& esm);
|
void load(ESMReader& esm);
|
||||||
void save(ESMWriter& esm) const;
|
void save(ESMWriter& esm) const;
|
||||||
@ -145,7 +146,7 @@ namespace ESM
|
|||||||
|
|
||||||
struct AiPackageContainer
|
struct AiPackageContainer
|
||||||
{
|
{
|
||||||
int mType;
|
int32_t mType;
|
||||||
|
|
||||||
std::unique_ptr<AiPackage> mPackage;
|
std::unique_ptr<AiPackage> mPackage;
|
||||||
};
|
};
|
||||||
@ -155,7 +156,7 @@ namespace ESM
|
|||||||
AiSequence() { mLastAiPackage = -1; }
|
AiSequence() { mLastAiPackage = -1; }
|
||||||
|
|
||||||
std::vector<AiPackageContainer> mPackages;
|
std::vector<AiPackageContainer> mPackages;
|
||||||
int mLastAiPackage;
|
int32_t mLastAiPackage;
|
||||||
|
|
||||||
void load(ESMReader& esm);
|
void load(ESMReader& esm);
|
||||||
void save(ESMWriter& esm) const;
|
void save(ESMWriter& esm) const;
|
||||||
|
@ -13,7 +13,7 @@ namespace ESM
|
|||||||
|
|
||||||
if (esm.isNextSub("CIDX"))
|
if (esm.isNextSub("CIDX"))
|
||||||
{
|
{
|
||||||
esm.getHTSized<8>(mIndex);
|
esm.getHT(mIndex.mX, mIndex.mY);
|
||||||
mPaged = true;
|
mPaged = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define OPENMW_ESM_CELLID_H
|
#define OPENMW_ESM_CELLID_H
|
||||||
|
|
||||||
#include <components/esm/refid.hpp>
|
#include <components/esm/refid.hpp>
|
||||||
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
@ -13,8 +14,8 @@ namespace ESM
|
|||||||
{
|
{
|
||||||
struct CellIndex
|
struct CellIndex
|
||||||
{
|
{
|
||||||
int mX;
|
int32_t mX;
|
||||||
int mY;
|
int32_t mY;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string mWorldspace;
|
std::string mWorldspace;
|
||||||
|
@ -112,7 +112,7 @@ namespace ESM
|
|||||||
case fourCC("DODT"):
|
case fourCC("DODT"):
|
||||||
if constexpr (load)
|
if constexpr (load)
|
||||||
{
|
{
|
||||||
esm.getHTSized<24>(cellRef.mDoorDest);
|
esm.getHT(cellRef.mDoorDest.pos, cellRef.mDoorDest.rot);
|
||||||
cellRef.mTeleport = true;
|
cellRef.mTeleport = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -132,7 +132,7 @@ namespace ESM
|
|||||||
break;
|
break;
|
||||||
case fourCC("DATA"):
|
case fourCC("DATA"):
|
||||||
if constexpr (load)
|
if constexpr (load)
|
||||||
esm.getHTSized<24>(cellRef.mPos);
|
esm.getHT(cellRef.mPos.pos, cellRef.mPos.rot);
|
||||||
else
|
else
|
||||||
esm.skipHTSized<24, decltype(cellRef.mPos)>();
|
esm.skipHTSized<24, decltype(cellRef.mPos)>();
|
||||||
break;
|
break;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef OPENMW_ESM_CELLREF_H
|
#ifndef OPENMW_ESM_CELLREF_H
|
||||||
#define OPENMW_ESM_CELLREF_H
|
#define OPENMW_ESM_CELLREF_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "components/esm/defs.hpp"
|
#include "components/esm/defs.hpp"
|
||||||
@ -48,7 +49,7 @@ namespace ESM
|
|||||||
ESM::RefId mFaction;
|
ESM::RefId mFaction;
|
||||||
|
|
||||||
// PC faction rank required to use the item. Sometimes is -1, which means "any rank".
|
// PC faction rank required to use the item. Sometimes is -1, which means "any rank".
|
||||||
int mFactionRank;
|
int32_t mFactionRank;
|
||||||
|
|
||||||
// For weapon or armor, this is the remaining item health.
|
// For weapon or armor, this is the remaining item health.
|
||||||
// For tools (lockpicks, probes, repair hammer) it is the remaining uses.
|
// For tools (lockpicks, probes, repair hammer) it is the remaining uses.
|
||||||
@ -56,7 +57,7 @@ namespace ESM
|
|||||||
// This could be -1 if the charge was not touched yet (i.e. full).
|
// This could be -1 if the charge was not touched yet (i.e. full).
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
int mChargeInt; // Used by everything except lights
|
int32_t mChargeInt; // Used by everything except lights
|
||||||
float mChargeFloat; // Used only by lights
|
float mChargeFloat; // Used only by lights
|
||||||
};
|
};
|
||||||
float mChargeIntRemainder; // Stores amount of charge not subtracted from mChargeInt
|
float mChargeIntRemainder; // Stores amount of charge not subtracted from mChargeInt
|
||||||
@ -65,7 +66,7 @@ namespace ESM
|
|||||||
float mEnchantmentCharge;
|
float mEnchantmentCharge;
|
||||||
|
|
||||||
// This is 5 for Gold_005 references, 100 for Gold_100 and so on.
|
// This is 5 for Gold_005 references, 100 for Gold_100 and so on.
|
||||||
int mGoldValue;
|
int32_t mGoldValue;
|
||||||
|
|
||||||
// For doors - true if this door teleports to somewhere else, false
|
// For doors - true if this door teleports to somewhere else, false
|
||||||
// if it should open through animation.
|
// if it should open through animation.
|
||||||
@ -78,7 +79,7 @@ namespace ESM
|
|||||||
std::string mDestCell;
|
std::string mDestCell;
|
||||||
|
|
||||||
// Lock level for doors and containers
|
// Lock level for doors and containers
|
||||||
int mLockLevel;
|
int32_t mLockLevel;
|
||||||
bool mIsLocked{};
|
bool mIsLocked{};
|
||||||
ESM::RefId mKey, mTrap; // Key and trap ID names, if any
|
ESM::RefId mKey, mTrap; // Key and trap ID names, if any
|
||||||
|
|
||||||
|
@ -172,10 +172,14 @@ namespace ESM
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get data of a given type/size, including subrecord header
|
// Get data of a given type/size, including subrecord header
|
||||||
template <typename X, typename = std::enable_if_t<IsReadable<X>>>
|
template <class... Args>
|
||||||
void getHT(X& x)
|
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>>>
|
template <typename T, typename = std::enable_if_t<IsReadable<T>>>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user