mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
Issue #217: made Ptr track container; fixed a cmake script bug
This commit is contained in:
parent
95d27090d7
commit
0adbe258fd
4 changed files with 50 additions and 16 deletions
|
@ -44,7 +44,7 @@ add_openmw_dir (mwsound
|
|||
add_openmw_dir (mwworld
|
||||
refdata world physicssystem scene environment globals class action nullaction actionteleport
|
||||
containerstore actiontalk actiontake manualref player cellfunctors
|
||||
cells localscripts customdata weather inventorystore
|
||||
cells localscripts customdata weather inventorystore ptr
|
||||
)
|
||||
|
||||
add_openmw_dir (mwclass
|
||||
|
@ -92,7 +92,7 @@ target_link_libraries(openmw
|
|||
MyGUIOgrePlatform
|
||||
)
|
||||
|
||||
# Fix for not visible pthreads functions for linker with glibc 2.15
|
||||
# Fix for not visible pthreads functions for linker with glibc 2.15
|
||||
if (UNIX AND NOT APPLE)
|
||||
target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
|
|
@ -301,23 +301,30 @@ MWWorld::Ptr *MWWorld::ContainerStoreIterator::operator->() const
|
|||
|
||||
MWWorld::Ptr MWWorld::ContainerStoreIterator::operator*() const
|
||||
{
|
||||
Ptr ptr;
|
||||
|
||||
switch (mType)
|
||||
{
|
||||
case ContainerStore::Type_Potion: return MWWorld::Ptr (&*mPotion, 0);
|
||||
case ContainerStore::Type_Apparatus: return MWWorld::Ptr (&*mApparatus, 0);
|
||||
case ContainerStore::Type_Armor: return MWWorld::Ptr (&*mArmor, 0);
|
||||
case ContainerStore::Type_Book: return MWWorld::Ptr (&*mBook, 0);
|
||||
case ContainerStore::Type_Clothing: return MWWorld::Ptr (&*mClothing, 0);
|
||||
case ContainerStore::Type_Ingredient: return MWWorld::Ptr (&*mIngredient, 0);
|
||||
case ContainerStore::Type_Light: return MWWorld::Ptr (&*mLight, 0);
|
||||
case ContainerStore::Type_Lockpick: return MWWorld::Ptr (&*mLockpick, 0);
|
||||
case ContainerStore::Type_Miscellaneous: return MWWorld::Ptr (&*mMiscellaneous, 0);
|
||||
case ContainerStore::Type_Probe: return MWWorld::Ptr (&*mProbe, 0);
|
||||
case ContainerStore::Type_Repair: return MWWorld::Ptr (&*mRepair, 0);
|
||||
case ContainerStore::Type_Weapon: return MWWorld::Ptr (&*mWeapon, 0);
|
||||
case ContainerStore::Type_Potion: ptr = MWWorld::Ptr (&*mPotion, 0); break;
|
||||
case ContainerStore::Type_Apparatus: ptr = MWWorld::Ptr (&*mApparatus, 0); break;
|
||||
case ContainerStore::Type_Armor: ptr = MWWorld::Ptr (&*mArmor, 0); break;
|
||||
case ContainerStore::Type_Book: ptr = MWWorld::Ptr (&*mBook, 0); break;
|
||||
case ContainerStore::Type_Clothing: ptr = MWWorld::Ptr (&*mClothing, 0); break;
|
||||
case ContainerStore::Type_Ingredient: ptr = MWWorld::Ptr (&*mIngredient, 0); break;
|
||||
case ContainerStore::Type_Light: ptr = MWWorld::Ptr (&*mLight, 0); break;
|
||||
case ContainerStore::Type_Lockpick: ptr = MWWorld::Ptr (&*mLockpick, 0); break;
|
||||
case ContainerStore::Type_Miscellaneous: ptr = MWWorld::Ptr (&*mMiscellaneous, 0); break;
|
||||
case ContainerStore::Type_Probe: ptr = MWWorld::Ptr (&*mProbe, 0); break;
|
||||
case ContainerStore::Type_Repair: ptr = MWWorld::Ptr (&*mRepair, 0); break;
|
||||
case ContainerStore::Type_Weapon: ptr = MWWorld::Ptr (&*mWeapon, 0); break;
|
||||
}
|
||||
|
||||
throw std::runtime_error ("invalid pointer");
|
||||
if (ptr.isEmpty())
|
||||
throw std::runtime_error ("invalid iterator");
|
||||
|
||||
ptr.setContainerStore (mContainer);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
MWWorld::ContainerStoreIterator& MWWorld::ContainerStoreIterator::operator++()
|
||||
|
|
17
apps/openmw/mwworld/ptr.cpp
Normal file
17
apps/openmw/mwworld/ptr.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
#include "ptr.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
void MWWorld::Ptr::setContainerStore (ContainerStore *store)
|
||||
{
|
||||
assert (store);
|
||||
assert (!mCell);
|
||||
|
||||
mContainerStore = store;
|
||||
}
|
||||
|
||||
MWWorld::ContainerStore *MWWorld::Ptr::getContainerStore() const
|
||||
{
|
||||
return mContainerStore;
|
||||
}
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
class ContainerStore;
|
||||
|
||||
/// \brief Pointer to a LiveCellRef
|
||||
|
||||
class Ptr
|
||||
|
@ -26,10 +28,11 @@ namespace MWWorld
|
|||
RefData *mRefData;
|
||||
CellStore *mCell;
|
||||
std::string mTypeName;
|
||||
ContainerStore *mContainerStore;
|
||||
|
||||
public:
|
||||
|
||||
Ptr() : mCellRef (0), mRefData (0), mCell (0) {}
|
||||
Ptr() : mCellRef (0), mRefData (0), mCell (0), mContainerStore (0) {}
|
||||
|
||||
bool isEmpty() const
|
||||
{
|
||||
|
@ -49,6 +52,7 @@ namespace MWWorld
|
|||
|
||||
template<typename T>
|
||||
Ptr (ESMS::LiveCellRef<T, RefData> *liveCellRef, CellStore *cell)
|
||||
: mContainerStore (0)
|
||||
{
|
||||
mPtr = liveCellRef;
|
||||
mCellRef = &liveCellRef->ref;
|
||||
|
@ -80,6 +84,12 @@ namespace MWWorld
|
|||
assert (mCell);
|
||||
return mCell;
|
||||
}
|
||||
|
||||
void setContainerStore (ContainerStore *store);
|
||||
///< Must not be called on references that are in a cell.
|
||||
|
||||
ContainerStore *getContainerStore() const;
|
||||
///< May return a 0-pointer, if reference is not in a container.
|
||||
};
|
||||
|
||||
inline bool operator== (const Ptr& left, const Ptr& right)
|
||||
|
|
Loading…
Reference in a new issue