CHR_REF Passage::whoIsBlockingPassage( const CHR_REF isrc, IDSZ idsz, const BIT_FIELD targeting_bits, IDSZ require_item ) const { // Skip if the one who is looking doesn't exist if ( !_currentModule->getObjectHandler().exists( isrc ) ) return INVALID_CHR_REF; Object *psrc = _currentModule->getObjectHandler().get( isrc ); // Look at each character for ( CHR_REF character = 0; character < OBJECTS_MAX; character++ ) { if ( !_currentModule->getObjectHandler().exists( character ) ) continue; Object * pchr = _currentModule->getObjectHandler().get( character ); // dont do scenery objects unless we allow items if ( !HAS_SOME_BITS( targeting_bits, TARGET_ITEMS ) && ( CHR_INFINITE_WEIGHT == pchr->phys.weight ) ) continue; //Check if the object has the requirements if ( !chr_check_target( psrc, character, idsz, targeting_bits ) ) continue; //Now check if it actually is inside the passage area if ( objectIsInPassage( pchr->getPosX(), pchr->getPosY(), pchr->bump_1.size ) ) { // Found a live one, do we need to check for required items as well? if ( IDSZ_NONE == require_item ) { return character; } // It needs to have a specific item as well else { // I: Check left hand if ( chr_is_type_idsz( pchr->holdingwhich[SLOT_LEFT], require_item ) ) { // It has the item... return character; } // II: Check right hand if ( chr_is_type_idsz( pchr->holdingwhich[SLOT_RIGHT], require_item ) ) { // It has the item... return character; } // III: Check the pack for(const std::shared_ptr<Object> pitem : pchr->getInventory().iterate()) { if ( chr_is_type_idsz( pitem->getCharacterID(), require_item ) ) { // It has the ipacked in inventory... return character; } } } } } // No characters found return INVALID_CHR_REF; }
ObjectRef Passage::whoIsBlockingPassage( ObjectRef objRef, const IDSZ2& idsz, const BIT_FIELD targeting_bits, const IDSZ2& require_item ) const { // Skip if the one who is looking doesn't exist if ( !_module.getObjectHandler().exists(objRef) ) return ObjectRef::Invalid; Object *psrc = _module.getObjectHandler().get(objRef); // Look at each character for(const std::shared_ptr<Object> &pchr : _module.getObjectHandler().iterator()) { if(pchr->isTerminated()) { continue; } // dont do scenery objects unless we allow items if (!HAS_SOME_BITS(targeting_bits, TARGET_ITEMS) && pchr->isScenery()) continue; //Check if the object has the requirements if ( !chr_check_target( psrc, pchr, idsz, targeting_bits ) ) continue; //Now check if it actually is inside the passage area if (objectIsInPassage(pchr)) { // Found a live one, do we need to check for required items as well? if ( IDSZ2::None == require_item ) { return pchr->getObjRef(); } // It needs to have a specific item as well else { // I: Check hands if(pchr->isWieldingItemIDSZ(require_item)) { return pchr->getObjRef(); } // II: Check the pack for(const std::shared_ptr<Object> pitem : pchr->getInventory().iterate()) { if ( pitem->getProfile()->hasTypeIDSZ(require_item) ) { // It has the required item in inventory... return pchr->getObjRef(); } } } } } // No characters found return ObjectRef::Invalid; }