mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-02 01:15:32 +00:00
Add a searchPtr method as required for getting an owner, which may already be dead and disposed of.
This commit is contained in:
parent
bf6d302fba
commit
9127839cc1
4 changed files with 19 additions and 6 deletions
|
@ -157,6 +157,10 @@ namespace MWBase
|
||||||
///< Return a pointer to a liveCellRef with the given name.
|
///< Return a pointer to a liveCellRef with the given name.
|
||||||
/// \param activeOnly do non search inactive cells.
|
/// \param activeOnly do non search inactive cells.
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr searchPtr (const std::string& name, bool activeOnly) = 0;
|
||||||
|
///< Return a pointer to a liveCellRef with the given name.
|
||||||
|
/// \param activeOnly do non search inactive cells.
|
||||||
|
|
||||||
virtual MWWorld::Ptr getPtrViaHandle (const std::string& handle) = 0;
|
virtual MWWorld::Ptr getPtrViaHandle (const std::string& handle) = 0;
|
||||||
///< Return a pointer to a liveCellRef with the given Ogre handle.
|
///< Return a pointer to a liveCellRef with the given Ogre handle.
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item.getCellRef().mOwner.empty())
|
if (!item.getCellRef().mOwner.empty())
|
||||||
victim = MWBase::Environment::get().getWorld()->getPtr(item.getCellRef().mOwner, true);
|
victim = MWBase::Environment::get().getWorld()->searchPtr(item.getCellRef().mOwner, true);
|
||||||
|
|
||||||
return (!isOwned && !isFactionOwned);
|
return (!isOwned && !isFactionOwned);
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,8 +485,9 @@ namespace MWWorld
|
||||||
mLocalScripts.remove (ref);
|
mLocalScripts.remove (ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr World::getPtr (const std::string& name, bool activeOnly)
|
Ptr World::searchPtr (const std::string& name, bool activeOnly)
|
||||||
{
|
{
|
||||||
|
Ptr ret;
|
||||||
// the player is always in an active cell.
|
// the player is always in an active cell.
|
||||||
if (name=="player")
|
if (name=="player")
|
||||||
{
|
{
|
||||||
|
@ -514,12 +515,16 @@ namespace MWWorld
|
||||||
|
|
||||||
if (!activeOnly)
|
if (!activeOnly)
|
||||||
{
|
{
|
||||||
Ptr ptr = mCells.getPtr (lowerCaseName);
|
ret = mCells.getPtr (lowerCaseName);
|
||||||
|
|
||||||
if (!ptr.isEmpty())
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr World::getPtr (const std::string& name, bool activeOnly)
|
||||||
|
{
|
||||||
|
Ptr ret = searchPtr(name, activeOnly);
|
||||||
|
if (!ret.isEmpty())
|
||||||
|
return ret;
|
||||||
throw std::runtime_error ("unknown ID: " + name);
|
throw std::runtime_error ("unknown ID: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,6 +232,10 @@ namespace MWWorld
|
||||||
///< Return a pointer to a liveCellRef with the given name.
|
///< Return a pointer to a liveCellRef with the given name.
|
||||||
/// \param activeOnly do non search inactive cells.
|
/// \param activeOnly do non search inactive cells.
|
||||||
|
|
||||||
|
virtual Ptr searchPtr (const std::string& name, bool activeOnly);
|
||||||
|
///< Return a pointer to a liveCellRef with the given name.
|
||||||
|
/// \param activeOnly do non search inactive cells.
|
||||||
|
|
||||||
virtual Ptr getPtrViaHandle (const std::string& handle);
|
virtual Ptr getPtrViaHandle (const std::string& handle);
|
||||||
///< Return a pointer to a liveCellRef with the given Ogre handle.
|
///< Return a pointer to a liveCellRef with the given Ogre handle.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue