mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 03:59:56 +00:00
Move TimeStamp to ESM3 and remove sized reads
This commit is contained in:
parent
d2f16774d9
commit
79b3855c5b
14 changed files with 87 additions and 46 deletions
|
@ -4,7 +4,7 @@
|
|||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm3/timestamp.hpp>
|
||||
|
||||
#include "duration.hpp"
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ add_component_dir (esm3
|
|||
inventorystate containerstate npcstate creaturestate dialoguestate statstate npcstats creaturestats
|
||||
weatherstate quickkeys fogstate spellstate activespells creaturelevliststate doorstate projectilestate debugprofile
|
||||
aisequence magiceffects custommarkerstate stolenitems transport animationstate controlsstate mappings readerscache
|
||||
infoorder
|
||||
infoorder timestamp
|
||||
)
|
||||
|
||||
add_component_dir (esm3terrain
|
||||
|
|
|
@ -15,12 +15,6 @@
|
|||
namespace ESM
|
||||
{
|
||||
|
||||
struct TimeStamp
|
||||
{
|
||||
float mHour;
|
||||
int mDay;
|
||||
};
|
||||
|
||||
struct EpochTimeStamp
|
||||
{
|
||||
float mGameHour;
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace ESM
|
|||
if (esm.isNextSub("WORS"))
|
||||
{
|
||||
esm.getHT(params.mWorsenings);
|
||||
esm.getHNTSized<8>(params.mNextWorsening, "TIME");
|
||||
params.mNextWorsening.load(esm);
|
||||
}
|
||||
else
|
||||
params.mWorsenings = -1;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "cellref.hpp"
|
||||
#include "components/esm/defs.hpp"
|
||||
#include "components/esm/refid.hpp"
|
||||
#include "timestamp.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -27,15 +28,15 @@ namespace ESM
|
|||
Flag_Ignore_SpellAbsorption = 1 << 4
|
||||
};
|
||||
|
||||
int mEffectId;
|
||||
int32_t mEffectId;
|
||||
float mMagnitude;
|
||||
float mMinMagnitude;
|
||||
float mMaxMagnitude;
|
||||
int mArg; // skill or attribute
|
||||
int32_t mArg; // skill or attribute
|
||||
float mDuration;
|
||||
float mTimeLeft;
|
||||
int mEffectIndex;
|
||||
int mFlags;
|
||||
int32_t mEffectIndex;
|
||||
int32_t mFlags;
|
||||
};
|
||||
|
||||
// format 0, saved games only
|
||||
|
@ -55,10 +56,10 @@ namespace ESM
|
|||
RefId mId;
|
||||
std::vector<ActiveEffect> mEffects;
|
||||
std::string mDisplayName;
|
||||
int mCasterActorId;
|
||||
int32_t mCasterActorId;
|
||||
RefNum mItem;
|
||||
EffectType mType;
|
||||
int mWorsenings;
|
||||
int32_t mWorsenings;
|
||||
TimeStamp mNextWorsening;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ namespace ESM
|
|||
|
||||
mLastRespawn.mDay = 0;
|
||||
mLastRespawn.mHour = 0;
|
||||
esm.getHNOTSized<8>(mLastRespawn, "RESP");
|
||||
if (esm.peekNextSub("RESP"))
|
||||
mLastRespawn.load(esm, "RESP");
|
||||
}
|
||||
|
||||
void CellState::save(ESMWriter& esm) const
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "components/esm/defs.hpp"
|
||||
#include "components/esm/refid.hpp"
|
||||
#include "timestamp.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -18,7 +19,7 @@ namespace ESM
|
|||
bool mIsInterior;
|
||||
float mWaterLevel;
|
||||
|
||||
int mHasFogOfWar; // Do we have fog of war state (0 or 1)? (see fogstate.hpp)
|
||||
int32_t mHasFogOfWar; // Do we have fog of war state (0 or 1)? (see fogstate.hpp)
|
||||
|
||||
TimeStamp mLastRespawn;
|
||||
|
||||
|
|
|
@ -21,9 +21,10 @@ namespace ESM
|
|||
|
||||
mTradeTime.mDay = 0;
|
||||
mTradeTime.mHour = 0;
|
||||
esm.getHNOTSized<8>(mTradeTime, "TIME");
|
||||
if (esm.peekNextSub("TIME"))
|
||||
mTradeTime.load(esm);
|
||||
|
||||
int flags = 0;
|
||||
int32_t flags = 0;
|
||||
mDead = false;
|
||||
mDeathAnimationFinished = false;
|
||||
mDied = false;
|
||||
|
@ -108,7 +109,8 @@ namespace ESM
|
|||
|
||||
mTimeOfDeath.mDay = 0;
|
||||
mTimeOfDeath.mHour = 0;
|
||||
esm.getHNOTSized<8>(mTimeOfDeath, "DTIM");
|
||||
if (esm.peekNextSub("DTIM"))
|
||||
mTimeOfDeath.load(esm, "DTIM");
|
||||
|
||||
mSpells.load(esm);
|
||||
mActiveSpells.load(esm);
|
||||
|
@ -119,12 +121,12 @@ namespace ESM
|
|||
{
|
||||
while (esm.isNextSub("SUMM"))
|
||||
{
|
||||
int magicEffect;
|
||||
int32_t magicEffect;
|
||||
esm.getHT(magicEffect);
|
||||
ESM::RefId source = esm.getHNORefId("SOUR");
|
||||
int effectIndex = -1;
|
||||
int32_t effectIndex = -1;
|
||||
esm.getHNOT(effectIndex, "EIND");
|
||||
int actorId;
|
||||
int32_t actorId;
|
||||
esm.getHNT(actorId, "ACID");
|
||||
mSummonedCreatureMap[SummonKey(magicEffect, source, effectIndex)] = actorId;
|
||||
mSummonedCreatures.emplace(magicEffect, actorId);
|
||||
|
@ -134,9 +136,9 @@ namespace ESM
|
|||
{
|
||||
while (esm.isNextSub("SUMM"))
|
||||
{
|
||||
int magicEffect;
|
||||
int32_t magicEffect;
|
||||
esm.getHT(magicEffect);
|
||||
int actorId;
|
||||
int32_t actorId;
|
||||
esm.getHNT(actorId, "ACID");
|
||||
mSummonedCreatures.emplace(magicEffect, actorId);
|
||||
}
|
||||
|
@ -144,7 +146,7 @@ namespace ESM
|
|||
|
||||
while (esm.isNextSub("GRAV"))
|
||||
{
|
||||
int actorId;
|
||||
int32_t actorId;
|
||||
esm.getHT(actorId);
|
||||
mSummonGraveyard.push_back(actorId);
|
||||
}
|
||||
|
@ -164,7 +166,7 @@ namespace ESM
|
|||
|
||||
CorprusStats stats;
|
||||
esm.getHNT(stats.mWorsenings, "WORS");
|
||||
esm.getHNTSized<8>(stats.mNextWorsening, "TIME");
|
||||
stats.mNextWorsening.load(esm);
|
||||
|
||||
mCorprusSpells[id] = stats;
|
||||
}
|
||||
|
@ -191,7 +193,7 @@ namespace ESM
|
|||
if (mTradeTime.mDay != 0 || mTradeTime.mHour != 0)
|
||||
esm.writeHNT("TIME", mTradeTime);
|
||||
|
||||
int flags = 0;
|
||||
int32_t flags = 0;
|
||||
if (mDead)
|
||||
flags |= Dead;
|
||||
if (mDeathAnimationFinished)
|
||||
|
@ -260,7 +262,7 @@ namespace ESM
|
|||
esm.writeHNT("ACID", actorId);
|
||||
}
|
||||
|
||||
for (int key : mSummonGraveyard)
|
||||
for (int32_t key : mSummonGraveyard)
|
||||
{
|
||||
esm.writeHNT("GRAV", key);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "components/esm/refid.hpp"
|
||||
#include "magiceffects.hpp"
|
||||
#include "spellstate.hpp"
|
||||
#include "timestamp.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -27,7 +28,7 @@ namespace ESM
|
|||
{
|
||||
struct CorprusStats
|
||||
{
|
||||
std::array<int, Attribute::Length> mWorsenings;
|
||||
std::array<int32_t, Attribute::Length> mWorsenings;
|
||||
TimeStamp mNextWorsening;
|
||||
};
|
||||
|
||||
|
@ -78,15 +79,15 @@ namespace ESM
|
|||
bool mKnockdownOverOneFrame;
|
||||
bool mHitRecovery;
|
||||
bool mBlock;
|
||||
unsigned int mMovementFlags;
|
||||
uint32_t mMovementFlags;
|
||||
float mFallHeight;
|
||||
ESM::RefId mLastHitObject;
|
||||
ESM::RefId mLastHitAttemptObject;
|
||||
bool mRecalcDynamicStats;
|
||||
int mDrawState;
|
||||
signed char mDeathAnimation;
|
||||
int32_t mDrawState;
|
||||
int8_t mDeathAnimation;
|
||||
TimeStamp mTimeOfDeath;
|
||||
int mLevel;
|
||||
int32_t mLevel;
|
||||
bool mMissingACDT;
|
||||
|
||||
std::map<ESM::RefId, CorprusStats> mCorprusSpells;
|
||||
|
|
|
@ -128,6 +128,17 @@ namespace ESM
|
|||
getHNTSized<sizeof(X)>(x, name);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
void getHNT(NAME name, Args&... args)
|
||||
{
|
||||
constexpr size_t size = (0 + ... + sizeof(Args));
|
||||
getSubNameIs(name);
|
||||
getSubHeader();
|
||||
if (mCtx.leftSub != size)
|
||||
reportSubSizeMismatch(size, mCtx.leftSub);
|
||||
(getT(args), ...);
|
||||
}
|
||||
|
||||
// Optional version of getHNT
|
||||
template <typename X, typename = std::enable_if_t<IsReadable<X>>>
|
||||
void getHNOT(X& x, NAME name)
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace ESM
|
|||
SpellParams state;
|
||||
while (esm.isNextSub("INDX"))
|
||||
{
|
||||
int index;
|
||||
int32_t index;
|
||||
esm.getHT(index);
|
||||
|
||||
float magnitude;
|
||||
|
@ -28,7 +28,7 @@ namespace ESM
|
|||
|
||||
while (esm.isNextSub("PURG"))
|
||||
{
|
||||
int index;
|
||||
int32_t index;
|
||||
esm.getHT(index);
|
||||
state.mPurgedEffects.insert(index);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace ESM
|
|||
|
||||
CorprusStats stats;
|
||||
esm.getHNT(stats.mWorsenings, "WORS");
|
||||
esm.getHNTSized<8>(stats.mNextWorsening, "TIME");
|
||||
stats.mNextWorsening.load(esm);
|
||||
|
||||
mCorprusSpells[id] = stats;
|
||||
}
|
||||
|
@ -87,10 +87,7 @@ namespace ESM
|
|||
while (esm.isNextSub("USED"))
|
||||
{
|
||||
ESM::RefId id = esm.getRefId();
|
||||
TimeStamp time;
|
||||
esm.getHNTSized<8>(time, "TIME");
|
||||
|
||||
mUsedPowers[id] = time;
|
||||
mUsedPowers[id].load(esm);
|
||||
}
|
||||
|
||||
mSelectedSpell = esm.getHNORefId("SLCT");
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "components/esm/defs.hpp"
|
||||
#include "components/esm/refid.hpp"
|
||||
#include "timestamp.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -20,21 +21,21 @@ namespace ESM
|
|||
{
|
||||
struct CorprusStats
|
||||
{
|
||||
int mWorsenings;
|
||||
int32_t mWorsenings;
|
||||
TimeStamp mNextWorsening;
|
||||
};
|
||||
|
||||
struct PermanentSpellEffectInfo
|
||||
{
|
||||
int mId;
|
||||
int mArg;
|
||||
int32_t mId;
|
||||
int32_t mArg;
|
||||
float mMagnitude;
|
||||
};
|
||||
|
||||
struct SpellParams
|
||||
{
|
||||
std::map<int, float> mEffectRands; // <effect index, normalised random magnitude>
|
||||
std::set<int> mPurgedEffects; // indices of purged effects
|
||||
std::map<int32_t, float> mEffectRands; // <effect index, normalised random magnitude>
|
||||
std::set<int32_t> mPurgedEffects; // indices of purged effects
|
||||
};
|
||||
std::vector<ESM::RefId> mSpells;
|
||||
|
||||
|
|
11
components/esm3/timestamp.cpp
Normal file
11
components/esm3/timestamp.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "timestamp.hpp"
|
||||
|
||||
#include "esmreader.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
void TimeStamp::load(ESMReader& esm, NAME name)
|
||||
{
|
||||
esm.getHNT(name, mHour, mDay);
|
||||
}
|
||||
}
|
21
components/esm3/timestamp.hpp
Normal file
21
components/esm3/timestamp.hpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef OPENMW_COMPONENTS_ESM3_TIMESTAMP_H
|
||||
#define OPENMW_COMPONENTS_ESM3_TIMESTAMP_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <components/esm/esmcommon.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
|
||||
struct TimeStamp
|
||||
{
|
||||
float mHour;
|
||||
int32_t mDay;
|
||||
|
||||
void load(ESMReader& esm, NAME name = "TIME");
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue