From cb92d34ddda7c8b10613ae9a09d3817d1659d250 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Thu, 11 Apr 2024 17:04:55 +0200 Subject: [PATCH] Reorder RefData members to decrease its size --- apps/openmw/mwworld/refdata.cpp | 30 +++++++++++++++--------------- apps/openmw/mwworld/refdata.hpp | 14 +++++--------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwworld/refdata.cpp b/apps/openmw/mwworld/refdata.cpp index f7ba76da21..dc49ff0a4e 100644 --- a/apps/openmw/mwworld/refdata.cpp +++ b/apps/openmw/mwworld/refdata.cpp @@ -58,12 +58,12 @@ namespace MWWorld RefData::RefData() : mBaseNode(nullptr) + , mCustomData(nullptr) + , mFlags(0) , mDeletedByContentFile(false) , mEnabled(true) , mPhysicsPostponed(false) - , mCustomData(nullptr) , mChanged(false) - , mFlags(0) { for (int i = 0; i < 3; ++i) { @@ -74,50 +74,50 @@ namespace MWWorld RefData::RefData(const ESM::CellRef& cellRef) : mBaseNode(nullptr) + , mPosition(cellRef.mPos) + , mCustomData(nullptr) + , mFlags(0) // Loading from ESM/ESP files -> assume unchanged , mDeletedByContentFile(false) , mEnabled(true) , mPhysicsPostponed(false) - , mPosition(cellRef.mPos) - , mCustomData(nullptr) , mChanged(false) - , mFlags(0) // Loading from ESM/ESP files -> assume unchanged { } RefData::RefData(const ESM4::Reference& ref) : mBaseNode(nullptr) + , mPosition(ref.mPos) + , mCustomData(nullptr) + , mFlags(0) , mDeletedByContentFile(ref.mFlags & ESM4::Rec_Deleted) , mEnabled(!(ref.mFlags & ESM4::Rec_Disabled)) , mPhysicsPostponed(false) - , mPosition(ref.mPos) - , mCustomData(nullptr) , mChanged(false) - , mFlags(0) { } RefData::RefData(const ESM4::ActorCharacter& ref) : mBaseNode(nullptr) + , mPosition(ref.mPos) + , mCustomData(nullptr) + , mFlags(0) , mDeletedByContentFile(ref.mFlags & ESM4::Rec_Deleted) , mEnabled(!(ref.mFlags & ESM4::Rec_Disabled)) , mPhysicsPostponed(false) - , mPosition(ref.mPos) - , mCustomData(nullptr) , mChanged(false) - , mFlags(0) { } RefData::RefData(const ESM::ObjectState& objectState, bool deletedByContentFile) : mBaseNode(nullptr) - , mDeletedByContentFile(deletedByContentFile) - , mEnabled(objectState.mEnabled != 0) - , mPhysicsPostponed(false) , mPosition(objectState.mPosition) , mAnimationState(objectState.mAnimationState) , mCustomData(nullptr) - , mChanged(true) , mFlags(objectState.mFlags) // Loading from a savegame -> assume changed + , mDeletedByContentFile(deletedByContentFile) + , mEnabled(objectState.mEnabled != 0) + , mPhysicsPostponed(false) + , mChanged(true) { // "Note that the ActivationFlag_UseEnabled is saved to the reference, // which will result in permanently suppressed activation if the reference script is removed. diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index 1b57971f11..e0b62c94b6 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -47,6 +47,10 @@ namespace MWWorld MWScript::Locals mLocals; std::shared_ptr mLuaScripts; + ESM::Position mPosition; + ESM::AnimationState mAnimationState; + std::unique_ptr mCustomData; + unsigned int mFlags; /// separate delete flag used for deletion by a content file /// @note not stored in the save game file. @@ -58,20 +62,12 @@ namespace MWWorld bool mPhysicsPostponed : 1; private: - ESM::Position mPosition; - - ESM::AnimationState mAnimationState; - - std::unique_ptr mCustomData; + bool mChanged : 1; void copy(const RefData& refData); void cleanup(); - bool mChanged; - - unsigned int mFlags; - public: RefData();