diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 5be9a1988..4f616b312 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -389,7 +389,7 @@ namespace MWGui // Unset OnPCEquip Variable on item's script, if it has a script with that variable declared if(script != "") - (*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 0); + (*it).getRefData().getLocals().setVarByInt(script, "onpcequip", 0); return; } diff --git a/apps/openmw/mwworld/actionequip.cpp b/apps/openmw/mwworld/actionequip.cpp index 85e73a056..0f1a85dda 100644 --- a/apps/openmw/mwworld/actionequip.cpp +++ b/apps/openmw/mwworld/actionequip.cpp @@ -82,6 +82,6 @@ namespace MWWorld /* Set OnPCEquip Variable on item's script, if the player is equipping it, and it has a script with that variable declared */ if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && script != "") - (object).mRefData->getLocals().setVarByInt(script, "onpcequip", 1); + object.getRefData().getLocals().setVarByInt(script, "onpcequip", 1); } } diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index cd30f1ac0..ed424005a 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -59,16 +59,16 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end() bool MWWorld::ContainerStore::stacks(const Ptr& ptr1, const Ptr& ptr2) { /// \todo add current enchantment charge here when it is implemented - if ( ptr1.mCellRef->mRefID == ptr2.mCellRef->mRefID + if ( ptr1.getCellRef().mRefID == ptr2.getCellRef().mRefID && MWWorld::Class::get(ptr1).getScript(ptr1) == "" // item with a script never stacks && MWWorld::Class::get(ptr1).getEnchantment(ptr1) == "" // item with enchantment never stacks (we could revisit this later, but for now it makes selecting items in the spell window much easier) - && ptr1.mCellRef->mOwner == ptr2.mCellRef->mOwner - && ptr1.mCellRef->mSoul == ptr2.mCellRef->mSoul + && ptr1.getCellRef().mOwner == ptr2.getCellRef().mOwner + && ptr1.getCellRef().mSoul == ptr2.getCellRef().mSoul // item that is already partly used up never stacks - && (!MWWorld::Class::get(ptr1).hasItemHealth(ptr1) || ptr1.mCellRef->mCharge == -1 - || MWWorld::Class::get(ptr1).getItemMaxHealth(ptr1) == ptr1.mCellRef->mCharge) - && (!MWWorld::Class::get(ptr2).hasItemHealth(ptr2) || ptr2.mCellRef->mCharge == -1 - || MWWorld::Class::get(ptr2).getItemMaxHealth(ptr2) == ptr2.mCellRef->mCharge)) + && (!MWWorld::Class::get(ptr1).hasItemHealth(ptr1) || ptr1.getCellRef().mCharge == -1 + || MWWorld::Class::get(ptr1).getItemMaxHealth(ptr1) == ptr1.getCellRef().mCharge) + && (!MWWorld::Class::get(ptr2).hasItemHealth(ptr2) || ptr2.getCellRef().mCharge == -1 + || MWWorld::Class::get(ptr2).getItemMaxHealth(ptr2) == ptr2.getCellRef().mCharge)) return true; return false; @@ -91,7 +91,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr cell = 0; // Items in player's inventory have cell set to 0, so their scripts will never be removed // Set OnPCAdd special variable, if it is declared - item.mRefData->getLocals().setVarByInt(script, "onpcadd", 1); + item.getRefData().getLocals().setVarByInt(script, "onpcadd", 1); } else cell = player.getCell(); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index e737ab827..98cb6d347 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -138,7 +138,7 @@ void MWWorld::InventoryStore::unequipAll(const MWWorld::Ptr& actor) // Unset OnPCEquip Variable on item's script, if it has a script with that variable declared if((actor.getRefData().getHandle() == "player") && (script != "")) - (*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 0); + (*it).getRefData().getLocals().setVarByInt(script, "onpcequip", 0); } } } diff --git a/apps/openmw/mwworld/ptr.cpp b/apps/openmw/mwworld/ptr.cpp index 8a43dd981..88bb10122 100644 --- a/apps/openmw/mwworld/ptr.cpp +++ b/apps/openmw/mwworld/ptr.cpp @@ -9,22 +9,22 @@ const std::string MWWorld::Ptr::sEmptyString; ESM::CellRef& MWWorld::Ptr::getCellRef() const { - assert (mCellRef); + assert(mRef); if (mContainerStore) mContainerStore->flagAsModified(); - return *mCellRef; + return mRef->mRef; } MWWorld::RefData& MWWorld::Ptr::getRefData() const { - assert (mRefData); + assert(mRef); if (mContainerStore) mContainerStore->flagAsModified(); - return *mRefData; + return mRef->mData; } void MWWorld::Ptr::setContainerStore (ContainerStore *store) diff --git a/apps/openmw/mwworld/ptr.hpp b/apps/openmw/mwworld/ptr.hpp index e56aa3d71..4ee223950 100644 --- a/apps/openmw/mwworld/ptr.hpp +++ b/apps/openmw/mwworld/ptr.hpp @@ -18,44 +18,40 @@ namespace MWWorld typedef MWWorld::CellStore CellStore; ///< \deprecated - MWWorld::LiveCellRefBase *mPtr; - ESM::CellRef *mCellRef; - RefData *mRefData; + MWWorld::LiveCellRefBase *mRef; CellStore *mCell; ContainerStore *mContainerStore; public: - Ptr() : mPtr (0), mCellRef (0), mRefData (0), mCell (0), mContainerStore (0) {} + Ptr() : mRef(0), mCell(0), mContainerStore(0) { } bool isEmpty() const { - return mPtr == 0; + return mRef == 0; } const std::string& getTypeName() const { - return mPtr ? mPtr->mTypeName : sEmptyString; + return mRef ? mRef->mTypeName : sEmptyString; } Ptr (MWWorld::LiveCellRefBase *liveCellRef, CellStore *cell) : mContainerStore (0) { - mPtr = liveCellRef; - mCellRef = &liveCellRef->mRef; - mRefData = &liveCellRef->mData; + mRef = liveCellRef; mCell = cell; } template MWWorld::LiveCellRef *get() const { - if(mPtr && mPtr->mTypeName == typeid(T).name()) - return static_cast*>(mPtr); + if(mRef && mRef->mTypeName == typeid(T).name()) + return static_cast*>(mRef); std::stringstream str; str<< "Bad LiveCellRef cast to "<mTypeName; + if(mRef != 0) str<< mRef->mTypeName; else str<< "an empty object"; throw std::runtime_error(str.str()); @@ -85,7 +81,7 @@ namespace MWWorld inline bool operator== (const Ptr& left, const Ptr& right) { - return left.mRefData==right.mRefData; + return left.mRef==right.mRef; } inline bool operator!= (const Ptr& left, const Ptr& right) @@ -95,7 +91,7 @@ namespace MWWorld inline bool operator< (const Ptr& left, const Ptr& right) { - return left.mRefData= (const Ptr& left, const Ptr& right) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 3b0288610..0ba948318 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1446,7 +1446,7 @@ namespace MWWorld // Set OnPCDrop Variable on item's script, if it has a script with that variable declared if(script != "") - item.mRefData->getLocals().setVarByInt(script, "onpcdrop", 1); + item.getRefData().getLocals().setVarByInt(script, "onpcdrop", 1); } bool World::placeObject (const Ptr& object, float cursorX, float cursorY) @@ -1764,7 +1764,7 @@ namespace MWWorld (*cellIt)->forEach(functor); for (std::vector::iterator it = functor.mHandles.begin(); it != functor.mHandles.end(); ++it) - if (Misc::StringUtils::ciEqual(searchPtrViaHandle(*it).mCellRef->mOwner, npc.getCellRef().mRefID)) + if (Misc::StringUtils::ciEqual(searchPtrViaHandle(*it).getCellRef().mOwner, npc.getCellRef().mRefID)) out.push_back(searchPtrViaHandle(*it)); } }