mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-31 15:32:45 +00:00
Remove implicit conversion MWWorld::Ptr -> bool
This commit is contained in:
parent
a7e37509de
commit
e9420b2b68
@ -509,7 +509,7 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
|
||||
{
|
||||
MWWorld::Ptr target;
|
||||
mActor.getClass().getCreatureStats(mActor).getAiSequence().getCombatTarget(target);
|
||||
if (target)
|
||||
if (!target.isEmpty())
|
||||
{
|
||||
if (target.getClass().isNpc() && target.getClass().getNpcStats(target).isWerewolf())
|
||||
return 2;
|
||||
|
@ -85,13 +85,13 @@ namespace MWGui
|
||||
{
|
||||
MWWorld::Ptr item = *mKey[index].button->getUserData<MWWorld::Ptr>();
|
||||
// Make sure the item is available and is not broken
|
||||
if (!item || item.getRefData().getCount() < 1
|
||||
if (item.isEmpty() || item.getRefData().getCount() < 1
|
||||
|| (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0))
|
||||
{
|
||||
// Try searching for a compatible replacement
|
||||
item = store.findReplacement(mKey[index].id);
|
||||
|
||||
if (item)
|
||||
if (!item.isEmpty())
|
||||
mKey[index].button->setUserData(MWWorld::Ptr(item));
|
||||
|
||||
break;
|
||||
@ -382,12 +382,12 @@ namespace MWGui
|
||||
item = nullptr;
|
||||
|
||||
// check the item is available and not broken
|
||||
if (!item || item.getRefData().getCount() < 1
|
||||
if (item.isEmpty() || item.getRefData().getCount() < 1
|
||||
|| (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0))
|
||||
{
|
||||
item = store.findReplacement(key->id);
|
||||
|
||||
if (!item || item.getRefData().getCount() < 1)
|
||||
if (item.isEmpty() || item.getRefData().getCount() < 1)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sQuickMenu5} " + key->name);
|
||||
|
||||
|
@ -192,7 +192,7 @@ namespace MWGui
|
||||
else if (type == "ItemPtr")
|
||||
{
|
||||
mFocusObject = *focus->getUserData<MWWorld::Ptr>();
|
||||
if (!mFocusObject)
|
||||
if (mFocusObject.isEmpty())
|
||||
return;
|
||||
|
||||
tooltipSize = getToolTipViaPtr(mFocusObject.getRefData().getCount(), false, checkOwned());
|
||||
|
@ -45,7 +45,7 @@ bool MWMechanics::AiCast::execute(const MWWorld::Ptr& actor, MWMechanics::Charac
|
||||
else
|
||||
{
|
||||
target = getTarget();
|
||||
if (!target)
|
||||
if (target.isEmpty())
|
||||
return true;
|
||||
|
||||
if (!mManual && !pathTo(actor, target.getRefData().getPosition().asVec3(), duration, mDistance))
|
||||
|
@ -583,10 +583,10 @@ namespace MWWorld
|
||||
|
||||
Ptr CellStore::searchViaActorId(int id)
|
||||
{
|
||||
if (Ptr ptr = ::searchViaActorId(get<ESM::NPC>(), id, this, mMovedToAnotherCell))
|
||||
if (Ptr ptr = ::searchViaActorId(get<ESM::NPC>(), id, this, mMovedToAnotherCell); !ptr.isEmpty())
|
||||
return ptr;
|
||||
|
||||
if (Ptr ptr = ::searchViaActorId(get<ESM::Creature>(), id, this, mMovedToAnotherCell))
|
||||
if (Ptr ptr = ::searchViaActorId(get<ESM::Creature>(), id, this, mMovedToAnotherCell); !ptr.isEmpty())
|
||||
return ptr;
|
||||
|
||||
for (const auto& [base, _] : mMovedHere)
|
||||
@ -805,13 +805,13 @@ namespace MWWorld
|
||||
|
||||
mHasState = true;
|
||||
|
||||
if (Ptr ptr = searchInContainerList(get<ESM::Container>(), id))
|
||||
if (Ptr ptr = searchInContainerList(get<ESM::Container>(), id); !ptr.isEmpty())
|
||||
return ptr;
|
||||
|
||||
if (Ptr ptr = searchInContainerList(get<ESM::Creature>(), id))
|
||||
if (Ptr ptr = searchInContainerList(get<ESM::Creature>(), id); !ptr.isEmpty())
|
||||
return ptr;
|
||||
|
||||
if (Ptr ptr = searchInContainerList(get<ESM::NPC>(), id))
|
||||
if (Ptr ptr = searchInContainerList(get<ESM::NPC>(), id); !ptr.isEmpty())
|
||||
return ptr;
|
||||
|
||||
mHasState = oldState;
|
||||
|
@ -98,10 +98,16 @@ namespace MWWorld
|
||||
return mContainerStore;
|
||||
}
|
||||
|
||||
operator const void*() const
|
||||
///< Return a 0-pointer, if Ptr is empty; return a non-0-pointer, if Ptr is not empty
|
||||
template <template <class> class TypeTransform2>
|
||||
bool operator==(const PtrBase<TypeTransform2>& other) const
|
||||
{
|
||||
return mRef;
|
||||
return mRef == other.mRef;
|
||||
}
|
||||
|
||||
template <template <class> class TypeTransform2>
|
||||
bool operator<(const PtrBase<TypeTransform2>& other) const
|
||||
{
|
||||
return mRef < other.mRef;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -999,9 +999,11 @@ namespace MWWorld
|
||||
Ptr Scene::searchPtrViaActorId(int actorId)
|
||||
{
|
||||
for (CellStoreCollection::const_iterator iter(mActiveCells.begin()); iter != mActiveCells.end(); ++iter)
|
||||
if (Ptr ptr = (*iter)->searchViaActorId(actorId))
|
||||
{
|
||||
Ptr ptr = (*iter)->searchViaActorId(actorId);
|
||||
if (!ptr.isEmpty())
|
||||
return ptr;
|
||||
|
||||
}
|
||||
return Ptr();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user