Esempio n. 1
0
 bool pump(id_t funnelId) const
 {
     const Funnel& funnel = seeker->farm.funnel(funnelId);
     CS_DUMP(funnel.size());
     if (!funnel.empty()) {
         for (Funnel::const_iterator it = funnel.begin(); it != funnel.end(); ++it) {
             CS_DUMP(it->second);
             if (seeker->items.size() < maxMatch) {
                 if (recorded.find(it->second) == recorded.end()) {
                     CS_SAY("not recorded");
                     const SharedItem& item = seeker->farm.item(it->second);
                     CS_DUMP(!!item);
                     if (item && seeker->filter.apply(item)) {
                         CS_DUMP(item->id);
                         recorded.insert(item->id);
                         seeker->items.push_back(item);
                     }
                 }
             }
         }
     }
     CS_DUMP(seeker->items.size());
     return seeker->items.size() < maxMatch;
 }
Esempio n. 2
0
void Inventory::initialise()
{
    assert(!mDelayed);

    InventoryData::iterator it1;
    EquipData::const_iterator it2, it2_end = mPoss->equipSlots.end();
    /*
     * Apply all exists triggers.
     * Remove unknown inventory items.
     */

    ItemIdSet itemIds;

    /*
     * Construct a set of itemIds to keep track of duplicate itemIds.
     */
    for (it1 = mPoss->inventory.begin(); it1 != mPoss->inventory.end();)
    {
        ItemClass *item = itemManager->getItem(it1->second.itemId);
        if (item)
        {
            if (itemIds.insert(it1->second.itemId).second)
                item->useTrigger(mClient, ITT_IN_INVY);
            ++it1;
        }
        else
        {
            LOG_WARN("Inventory: deleting unknown item type "
                     << it1->second.itemId << " from the inventory of '"
                     << mClient->getName()
                     << "'!");
            mPoss->inventory.erase(it1++);
        }
    }

    itemIds.clear();

    typedef std::set<unsigned int> SlotSet;
    SlotSet equipment;

    /*
     * Construct a set of slot references from equipment to keep track of
     * duplicate slot usage.
     */
    for (it2 = mPoss->equipSlots.begin(); it2 != it2_end; ++it2)
    {
        if (equipment.insert(it2->second).second)
        {
            /*
             * Perform checks for equipped items - check that all needed slots are available.
             */
            // TODO - Not needed for testing everything else right now, but
            //        will be needed for production
            /*
             * Apply all equip triggers.
             */
            itemManager->getItem(mPoss->inventory.at(it2->second).itemId)
                    ->useTrigger(mClient, ITT_EQUIP);
        }
    }

    equipment.clear();

    checkSize();
}