Skip to content

Commit

Permalink
Merge branch 'alignyorefs' into 'master'
Browse files Browse the repository at this point in the history
Reorder RefData members to decrease its size

See merge request OpenMW/openmw!4020
  • Loading branch information
Capostrophic committed Apr 12, 2024
2 parents bdbbe34 + cb92d34 commit 55c5f21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
30 changes: 15 additions & 15 deletions apps/openmw/mwworld/refdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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.
Expand Down
14 changes: 5 additions & 9 deletions apps/openmw/mwworld/refdata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ namespace MWWorld

MWScript::Locals mLocals;
std::shared_ptr<MWLua::LocalScripts> mLuaScripts;
ESM::Position mPosition;
ESM::AnimationState mAnimationState;
std::unique_ptr<CustomData> mCustomData;
unsigned int mFlags;

/// separate delete flag used for deletion by a content file
/// @note not stored in the save game file.
Expand All @@ -58,20 +62,12 @@ namespace MWWorld
bool mPhysicsPostponed : 1;

private:
ESM::Position mPosition;

ESM::AnimationState mAnimationState;

std::unique_ptr<CustomData> mCustomData;
bool mChanged : 1;

void copy(const RefData& refData);

void cleanup();

bool mChanged;

unsigned int mFlags;

public:
RefData();

Expand Down

0 comments on commit 55c5f21

Please sign in to comment.