From e11da5c0a3aec68078dd967fc0582f7908311941 Mon Sep 17 00:00:00 2001 From: "Alex \"rainChu\" Haddad" Date: Wed, 16 Oct 2013 15:13:36 -0400 Subject: [PATCH] Added a constructor to Light CustomData --- apps/openmw/mwclass/light.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 4cf4ae37e..906ae8a1c 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -30,6 +30,13 @@ namespace float mTime; ///< Time remaining + CustomData(MWWorld::Ptr ptr) + { + MWWorld::LiveCellRef *ref = ptr.get(); + mTime = ref->mBase->mData.mTime; + } + ///< Constructs this CustomData from the base values for Ptr. + virtual MWWorld::CustomData *clone() const { return new CustomData (*this); @@ -225,15 +232,7 @@ namespace MWClass void Light::ensureCustomData (const MWWorld::Ptr& ptr) const { if (!ptr.getRefData().getCustomData()) - { - MWWorld::LiveCellRef *ref = ptr.get(); - - CustomData *data = new CustomData; - - data->mTime = ref->mBase->mData.mTime; - - ptr.getRefData().setCustomData(data); - } + ptr.getRefData().setCustomData(new CustomData(ptr)); } bool Light::canSell (const MWWorld::Ptr& item, int npcServices) const