mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:53:53 +00:00
Remove some unnecessary fields from Ptr
This commit is contained in:
parent
74f855e948
commit
48c07fbd98
7 changed files with 27 additions and 31 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<typename T>
|
||||
MWWorld::LiveCellRef<T> *get() const
|
||||
{
|
||||
if(mPtr && mPtr->mTypeName == typeid(T).name())
|
||||
return static_cast<MWWorld::LiveCellRef<T>*>(mPtr);
|
||||
if(mRef && mRef->mTypeName == typeid(T).name())
|
||||
return static_cast<MWWorld::LiveCellRef<T>*>(mRef);
|
||||
|
||||
std::stringstream str;
|
||||
str<< "Bad LiveCellRef cast to "<<typeid(T).name()<<" from ";
|
||||
if(mPtr != 0) str<< mPtr->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<right.mRefData;
|
||||
return left.mRef<right.mRef;
|
||||
}
|
||||
|
||||
inline bool operator>= (const Ptr& left, const Ptr& right)
|
||||
|
|
|
@ -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<ListHandlesFunctor>(functor);
|
||||
|
||||
for (std::vector<std::string>::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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue