Permalink
Browse files

Changes to include flags for findobjtypeincontainer.

  • Loading branch information...
sigmantium committed Sep 6, 2018
1 parent 7b0b906 commit b9071bbde83c16e2c6e96d2398282e39ac79b618
Showing with 37 additions and 2 deletions.
  1. +24 −0 pol-core/pol/containr.cpp
  2. +1 −0 pol-core/pol/containr.h
  3. +3 −0 pol-core/pol/core.h
  4. +4 −1 pol-core/pol/module/uomod.cpp
  5. +5 −1 pol-core/support/scripts/uo.em
View
@@ -421,6 +421,30 @@ Items::Item* UContainer::find_addable_stack( const Items::Item* adding_item ) co
return nullptr;
}
Items::Item* UContainer::find_objtype(u32 objtype, int flags) const
{
Items::Item* _item = find_toplevel_objtype(objtype);
if (_item != nullptr)
return _item;
if (!(flags & FINDOBJTYPE_ROOT_ONLY))
{
for (const auto& item : contents_)
{
if (item && item->isa(UOBJ_CLASS::CLASS_CONTAINER) && !item->inuse())
{
UContainer* cont = static_cast<UContainer*>(item);
if (!cont->locked() || (flags & FINDOBJTYPE_IGNORE_LOCKED) )
{
auto child_item = cont->find_objtype_noninuse(objtype);
if (child_item != nullptr)
return child_item;
}
}
}
}
return nullptr;
}
Items::Item* UContainer::find_objtype_noninuse( u32 objtype ) const
{
View
@@ -148,6 +148,7 @@ class UContainer : public ULockable
Items::Item* find_toplevel_objtype_noninuse( u32 objtype ) const;
Items::Item* find_toplevel_objtype_noninuse( u32 objtype, unsigned short maxamount ) const;
Items::Item* find_objtype_noninuse( u32 objtype ) const;
Items::Item* find_objtype(u32 objtype, int flags) const;
virtual void for_each_item( void ( *f )( Item* item, void* a ), void* arg );
View
@@ -79,6 +79,9 @@ const int SAVE_INCREMENTAL = 0x01;
const int LOG_DATETIME = 0x01;
const int FINDOBJTYPE_IGNORE_LOCKED = 0x01;
const int FINDOBJTYPE_ROOT_ONLY = 0x02;
const int FINDSUBSTANCE_IGNORE_LOCKED = 0x01;
const int FINDSUBSTANCE_ROOT_ONLY = 0x02;
const int FINDSUBSTANCE_FIND_ALL = 0x04;
@@ -670,6 +670,7 @@ BObjectImp* UOExecutorModule::mf_FindObjtypeInContainer()
{
Item* item;
unsigned int objtype;
int flags;
if ( !getItemParam( exec, 0, item ) || !getObjtypeParam( exec, 1, objtype ) )
{
return new BError( "Invalid parameter type" );
@@ -678,9 +679,11 @@ BObjectImp* UOExecutorModule::mf_FindObjtypeInContainer()
{
return new BError( "That is not a container" );
}
if (!getParam(4, flags))
flags = 0;
UContainer* cont = static_cast<UContainer*>( item );
Item* found = cont->find_toplevel_objtype( objtype );
Item* found = cont->find_objtype( objtype, flags );
if ( found == nullptr )
return new BError( "No items were found" );
else
@@ -137,6 +137,10 @@ const DELETE_BY_SCRIPT := 1;
const ENUMERATE_IGNORE_LOCKED := 0x1; // List content of locked container.
const ENUMERATE_ROOT_ONLY := 0x2; // Do not list contents of sub-containers.
// FindObjtypeInContainer constants
const FINDOBJTYPE_IGNORE_LOCKED := 0x1; // Find matches in locked containers
const FINDOBJTYPE_ROOT_ONLY := 0x2; // Do not find matches in sub-containers.
// FindSubstance constants
const FINDSUBSTANCE_IGNORE_LOCKED := 0x1; // Find matches in locked containers
const FINDSUBSTANCE_ROOT_ONLY := 0x2; // Do not find matches in sub-containers.
@@ -280,7 +284,7 @@ EquipItem( mobile, item );
EraseGlobalProperty( propname );
EraseObjProperty( object, propname );
FindAccount( acctname );
FindObjtypeInContainer( container, objtype );
FindObjtypeInContainer( container, objtype, flags := 0 );
FindPath( x1, y1, z1, x2, y2, z2, realm := _DEFAULT_REALM, flags := FP_IGNORE_MOBILES, searchskirt := 5 );
FindSubstance( container, objtype, amount, makeinuse := 0, flags := 0 );
GetAmount( item );

0 comments on commit b9071bb

Please sign in to comment.