Improve memory alignment of CreatureStats to reduce memory usage

pull/3236/head
Evil Eye 2 months ago
parent 4c11dcdd7d
commit ee16dbd2e2

@ -20,31 +20,6 @@ namespace MWMechanics
int CreatureStats::sActorId = 0; int CreatureStats::sActorId = 0;
CreatureStats::CreatureStats() CreatureStats::CreatureStats()
: mDrawState(DrawState::Nothing)
, mDead(false)
, mDeathAnimationFinished(false)
, mDied(false)
, mMurdered(false)
, mFriendlyHits(0)
, mTalkedTo(false)
, mAlarmed(false)
, mAttacked(false)
, mKnockdown(false)
, mKnockdownOneFrame(false)
, mKnockdownOverOneFrame(false)
, mHitRecovery(false)
, mBlock(false)
, mMovementFlags(0)
, mFallHeight(0)
, mLastRestock(0, 0)
, mGoldPool(0)
, mActorId(-1)
, mHitAttemptActorId(-1)
, mDeathAnimation(-1)
, mTimeOfDeath()
, mSideMovementAngle(0)
, mLevel(0)
, mAttackingOrSpell(false)
{ {
for (const ESM::Attribute& attribute : MWBase::Environment::get().getESMStore()->get<ESM::Attribute>()) for (const ESM::Attribute& attribute : MWBase::Environment::get().getESMStore()->get<ESM::Attribute>())
{ {

@ -39,30 +39,30 @@ namespace MWMechanics
class CreatureStats class CreatureStats
{ {
static int sActorId; static int sActorId;
DrawState mDrawState;
std::map<ESM::RefId, AttributeValue> mAttributes; std::map<ESM::RefId, AttributeValue> mAttributes;
DynamicStat<float> mDynamic[3]; // health, magicka, fatigue DynamicStat<float> mDynamic[3]; // health, magicka, fatigue
DrawState mDrawState = DrawState::Nothing;
Spells mSpells; Spells mSpells;
ActiveSpells mActiveSpells; ActiveSpells mActiveSpells;
MagicEffects mMagicEffects; MagicEffects mMagicEffects;
Stat<int> mAiSettings[4]; Stat<int> mAiSettings[4];
AiSequence mAiSequence; AiSequence mAiSequence;
bool mDead; bool mDead = false;
bool mDeathAnimationFinished; bool mDeathAnimationFinished = false;
bool mDied; // flag for OnDeath script function bool mDied = false; // flag for OnDeath script function
bool mMurdered; bool mMurdered = false;
int mFriendlyHits; int mFriendlyHits = 0;
bool mTalkedTo; bool mTalkedTo = false;
bool mAlarmed; bool mAlarmed = false;
bool mAttacked; bool mAttacked = false;
bool mKnockdown; bool mKnockdown = false;
bool mKnockdownOneFrame; bool mKnockdownOneFrame = false;
bool mKnockdownOverOneFrame; bool mKnockdownOverOneFrame = false;
bool mHitRecovery; bool mHitRecovery = false;
bool mBlock; bool mBlock = false;
unsigned int mMovementFlags; unsigned int mMovementFlags = 0;
float mFallHeight; float mFallHeight = 0.f;
ESM::RefId mLastHitObject; // The last object to hit this actor ESM::RefId mLastHitObject; // The last object to hit this actor
ESM::RefId mLastHitAttemptObject; // The last object to attempt to hit this actor ESM::RefId mLastHitAttemptObject; // The last object to attempt to hit this actor
@ -71,21 +71,17 @@ namespace MWMechanics
MWWorld::TimeStamp mLastRestock; MWWorld::TimeStamp mLastRestock;
// The pool of merchant gold (not in inventory) // The pool of merchant gold (not in inventory)
int mGoldPool; int mGoldPool = 0;
int mActorId; int mActorId = -1;
int mHitAttemptActorId; // Stores an actor that attacked this actor. Only one is stored at a time, // Stores an actor that attacked this actor. Only one is stored at a time, and it is not changed if a different
// and it is not changed if a different actor attacks. It is cleared when combat ends. // actor attacks. It is cleared when combat ends.
int mHitAttemptActorId = -1;
// The index of the death animation that was played, or -1 if none played
signed char mDeathAnimation;
MWWorld::TimeStamp mTimeOfDeath;
// The difference between view direction and lower body direction. // The difference between view direction and lower body direction.
float mSideMovementAngle; float mSideMovementAngle = 0;
bool mTeleported = false; MWWorld::TimeStamp mTimeOfDeath;
private: private:
std::multimap<int, int> mSummonedCreatures; // <Effect, ActorId> std::multimap<int, int> mSummonedCreatures; // <Effect, ActorId>
@ -95,9 +91,15 @@ namespace MWMechanics
std::vector<int> mSummonGraveyard; std::vector<int> mSummonGraveyard;
protected: protected:
int mLevel;
bool mAttackingOrSpell;
std::string mAttackType; std::string mAttackType;
int mLevel = 0;
bool mAttackingOrSpell = false;
private:
// The index of the death animation that was played, or -1 if none played
signed char mDeathAnimation = -1;
bool mTeleported = false;
public: public:
CreatureStats(); CreatureStats();

Loading…
Cancel
Save