diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 3821862ecb..c2107155ac 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -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; diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 7876013e64..22313a61f5 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -85,13 +85,13 @@ namespace MWGui { MWWorld::Ptr item = *mKey[index].button->getUserData(); // 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); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 178562f4c4..91c980b823 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -192,7 +192,7 @@ namespace MWGui else if (type == "ItemPtr") { mFocusObject = *focus->getUserData(); - if (!mFocusObject) + if (mFocusObject.isEmpty()) return; tooltipSize = getToolTipViaPtr(mFocusObject.getRefData().getCount(), false, checkOwned()); diff --git a/apps/openmw/mwmechanics/aicast.cpp b/apps/openmw/mwmechanics/aicast.cpp index 2b8582d261..583a85c538 100644 --- a/apps/openmw/mwmechanics/aicast.cpp +++ b/apps/openmw/mwmechanics/aicast.cpp @@ -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)) diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index f17854ae9b..516d52cc91 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -583,10 +583,10 @@ namespace MWWorld Ptr CellStore::searchViaActorId(int id) { - if (Ptr ptr = ::searchViaActorId(get(), id, this, mMovedToAnotherCell)) + if (Ptr ptr = ::searchViaActorId(get(), id, this, mMovedToAnotherCell); !ptr.isEmpty()) return ptr; - if (Ptr ptr = ::searchViaActorId(get(), id, this, mMovedToAnotherCell)) + if (Ptr ptr = ::searchViaActorId(get(), 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(), id)) + if (Ptr ptr = searchInContainerList(get(), id); !ptr.isEmpty()) return ptr; - if (Ptr ptr = searchInContainerList(get(), id)) + if (Ptr ptr = searchInContainerList(get(), id); !ptr.isEmpty()) return ptr; - if (Ptr ptr = searchInContainerList(get(), id)) + if (Ptr ptr = searchInContainerList(get(), id); !ptr.isEmpty()) return ptr; mHasState = oldState; diff --git a/apps/openmw/mwworld/ptr.hpp b/apps/openmw/mwworld/ptr.hpp index 5dd6cf6b7b..fdf69b8818 100644 --- a/apps/openmw/mwworld/ptr.hpp +++ b/apps/openmw/mwworld/ptr.hpp @@ -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