1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 21:06:43 +00:00

Merge pull request #2370 from akortunov/herbalism

Container search tweaks
This commit is contained in:
Alexei Dobrohotov 2019-05-06 22:34:12 +03:00 committed by GitHub
commit 1d12d778ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 8 deletions

View file

@ -176,7 +176,7 @@ 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; virtual MWWorld::Ptr searchPtr (const std::string& name, bool activeOnly, bool searchInContainers = true) = 0;
///< 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.

View file

@ -994,7 +994,7 @@ namespace MWMechanics
} }
if (!cellref.getOwner().empty()) if (!cellref.getOwner().empty())
victim = MWBase::Environment::get().getWorld()->searchPtr(cellref.getOwner(), true); victim = MWBase::Environment::get().getWorld()->searchPtr(cellref.getOwner(), true, false);
return (!isOwned && !isFactionOwned); return (!isOwned && !isFactionOwned);
} }

View file

@ -37,6 +37,9 @@ namespace
{ {
MWWorld::Ptr container (&*iter, 0); MWWorld::Ptr container (&*iter, 0);
if (container.getRefData().getCustomData() == nullptr)
continue;
MWWorld::Ptr ptr = MWWorld::Ptr ptr =
container.getClass().getContainerStore (container).search (id); container.getClass().getContainerStore (container).search (id);

View file

@ -679,7 +679,7 @@ namespace MWWorld
mLocalScripts.remove (ref); mLocalScripts.remove (ref);
} }
Ptr World::searchPtr (const std::string& name, bool activeOnly) Ptr World::searchPtr (const std::string& name, bool activeOnly, bool searchInContainers)
{ {
Ptr ret; Ptr ret;
// the player is always in an active cell. // the player is always in an active cell.
@ -706,11 +706,14 @@ namespace MWWorld
return ret; return ret;
} }
for (CellStore* cellstore : mWorldScene->getActiveCells()) if (searchInContainers)
{ {
Ptr ptr = cellstore->searchInContainer(lowerCaseName); for (CellStore* cellstore : mWorldScene->getActiveCells())
if (!ptr.isEmpty()) {
return ptr; Ptr ptr = cellstore->searchInContainer(lowerCaseName);
if (!ptr.isEmpty())
return ptr;
}
} }
Ptr ptr = mPlayer->getPlayer().getClass() Ptr ptr = mPlayer->getPlayer().getClass()

View file

@ -285,7 +285,7 @@ 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.
Ptr searchPtr (const std::string& name, bool activeOnly) override; Ptr searchPtr (const std::string& name, bool activeOnly, bool searchInContainers = true) override;
///< 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.