From e4a9eefc2aceb75d491f98e9b36985f70f93e7ee Mon Sep 17 00:00:00 2001 From: Bo Svensson <90132211+bosvensson1@users.noreply.github.com> Date: Mon, 4 Oct 2021 10:12:00 +0000 Subject: [PATCH] uses a bitfield in refdata.hpp (#3143) * uses a bitfield in refdata.hpp With this simple change we pack boolean values to reduce the memory requirements of game objects. * refdata.hpp [ci skip] * refdata.cpp --- apps/openmw/mwworld/refdata.cpp | 8 ++++---- apps/openmw/mwworld/refdata.hpp | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwworld/refdata.cpp b/apps/openmw/mwworld/refdata.cpp index 7398aef77e..f4c4beb7e8 100644 --- a/apps/openmw/mwworld/refdata.cpp +++ b/apps/openmw/mwworld/refdata.cpp @@ -65,21 +65,21 @@ namespace MWWorld } RefData::RefData (const ESM::CellRef& cellRef) - : mBaseNode(nullptr), mDeletedByContentFile(false), mEnabled (true), + : mBaseNode(nullptr), mDeletedByContentFile(false), mEnabled (true), mPhysicsPostponed(false), mCount (1), mPosition (cellRef.mPos), mCustomData (nullptr), - mChanged(false), mFlags(0), mPhysicsPostponed(false) // Loading from ESM/ESP files -> assume unchanged + mChanged(false), mFlags(0) // Loading from ESM/ESP files -> assume unchanged { } RefData::RefData (const ESM::ObjectState& objectState, bool deletedByContentFile) : mBaseNode(nullptr), mDeletedByContentFile(deletedByContentFile), - mEnabled (objectState.mEnabled != 0), + mEnabled (objectState.mEnabled != 0), mPhysicsPostponed(false), mCount (objectState.mCount), mPosition (objectState.mPosition), mAnimationState(objectState.mAnimationState), mCustomData (nullptr), - mChanged(true), mFlags(objectState.mFlags), mPhysicsPostponed(false) // Loading from a savegame -> assume changed + mChanged(true), mFlags(objectState.mFlags) // Loading from a savegame -> assume changed { // "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 d90224b9bb..c98eb0f2af 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -41,9 +41,12 @@ namespace MWWorld /// separate delete flag used for deletion by a content file /// @note not stored in the save game file. - bool mDeletedByContentFile; + bool mDeletedByContentFile:1; - bool mEnabled; + bool mEnabled:1; + public: + bool mPhysicsPostponed:1; + private: /// 0: deleted int mCount; @@ -63,9 +66,6 @@ namespace MWWorld unsigned int mFlags; public: - - bool mPhysicsPostponed; - RefData(); /// @param cellRef Used to copy constant data such as position into this class where it can