Merge branch 'ducksinarow' into 'master'

Improve memory alignment of CreatureStats to reduce memory usage

See merge request OpenMW/openmw!4433
pull/3236/head
psi29a 2 months ago
commit 6c52d92832

@ -20,31 +20,6 @@ namespace MWMechanics
int CreatureStats::sActorId = 0;
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>())
{

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

Loading…
Cancel
Save