bool House::transferToDepot(Player* player) const { if (townid == 0 || owner == 0) { return false; } ItemList moveItemList; for (HouseTile* tile : houseTiles) { if (const TileItemVector* items = tile->getItemList()) { for (Item* item : *items) { if (item->isPickupable()) { moveItemList.push_back(item); } else { Container* container = item->getContainer(); if (container) { for (Item* containerItem : container->getItemList()) { moveItemList.push_back(containerItem); } } } } } } for (Item* item : moveItemList) { g_game.internalMoveItem(item->getParent(), player->getInbox(), INDEX_WHEREEVER, item, item->getItemCount(), nullptr, FLAG_NOLIMIT); } return true; }
// LinkItems - This function is the main entry point into linking. It takes a // list of LinkItem which indicates the order the files should be linked and // how each file should be treated (plain file or with library search). The // function only links bitcode and produces a result list of items that are // native objects. bool Linker::LinkInItems(const ItemList& Items, ItemList& NativeItems) { // Clear the NativeItems just in case NativeItems.clear(); // For each linkage item ... for (ItemList::const_iterator I = Items.begin(), E = Items.end(); I != E; ++I) { if (I->second) { // Link in the library suggested. bool is_native = false; if (LinkInLibrary(I->first, is_native)) return true; if (is_native) NativeItems.push_back(*I); } else { // Link in the file suggested bool is_native = false; if (LinkInFile(sys::Path(I->first), is_native)) return true; if (is_native) NativeItems.push_back(*I); } } return false; }
bool House::transferToDepot(Player* player) { if (townid == 0 || houseOwner == 0) { return false; } ItemList moveItemList; for (HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it) { if (const TileItemVector* items = (*it)->getItemList()) { for (ItemVector::const_iterator iit = items->begin(), iend = items->end(); iit != iend; ++iit) { Item* item = *iit; if (item->isPickupable()) { moveItemList.push_back(item); } else { Container* container = item->getContainer(); if (container) { for (ItemDeque::const_iterator cit = container->getItems(); cit != container->getEnd(); ++cit) { moveItemList.push_back(*cit); } } } } } } for (ItemList::iterator it = moveItemList.begin(); it != moveItemList.end(); ++it) { Item* item = *it; g_game.internalMoveItem(item->getParent(), player->getInbox(), INDEX_WHEREEVER, item, item->getItemCount(), NULL, FLAG_NOLIMIT); } return true; }
bool House::transferToDepot() { if(!townId) return false; Player* player = NULL; if(owner) { uint32_t tmp = owner; if(isGuild() && !IOGuild::getInstance()->swapGuildIdToOwner(tmp)) tmp = 0; if(tmp) player = g_game.getPlayerByGuidEx(tmp); } Item* item = NULL; Container* tmpContainer = NULL; ItemList moveList; for(HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it) { for(uint32_t i = 0; i < (*it)->getThingCount(); ++i) { if(!(item = (*it)->__getThing(i)->getItem())) continue; if(item->isPickupable()) moveList.push_back(item); else if((tmpContainer = item->getContainer())) { for(ItemList::const_iterator it = tmpContainer->getItems(); it != tmpContainer->getEnd(); ++it) moveList.push_back(*it); } } } if(player) { Depot* depot = player->getDepot(townId, true); for(ItemList::iterator it = moveList.begin(); it != moveList.end(); ++it) g_game.internalMoveItem(NULL, (*it)->getParent(), depot, INDEX_WHEREEVER, (*it), (*it)->getItemCount(), NULL, FLAG_NOLIMIT); if(player->isVirtual()) { IOLoginData::getInstance()->savePlayer(player); delete player; } } else { for(ItemList::iterator it = moveList.begin(); it != moveList.end(); ++it) g_game.internalRemoveItem(NULL, (*it), (*it)->getItemCount(), false, FLAG_NOLIMIT); } return true; }
bool House::transferToDepot() { if(!townId) return false; Player* player = NULL; if(owner) { uint32_t tmp = owner; if(isGuild() && !IOGuild::getInstance()->swapGuildIdToOwner(tmp)) tmp = 0; if(tmp) player = g_game.getPlayerByGuidEx(tmp); } Container* tmpContainer = NULL; TileItemVector* items = NULL; ItemList moveList; for(HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it) { if(!(items = (*it)->getItemList())) continue; for(ItemVector::iterator iit = items->begin(); iit != items->end(); ++iit) { if((*iit)->isPickupable()) moveList.push_back(*iit); else if((tmpContainer = (*iit)->getContainer())) { for(ItemList::const_iterator cit = tmpContainer->getItems(); cit != tmpContainer->getEnd(); ++cit) moveList.push_back(*cit); } } } if(player) { for(ItemList::iterator it = moveList.begin(); it != moveList.end(); ++it) g_game.internalMoveItem(NULL, (*it)->getParent(), player->getInbox(), INDEX_WHEREEVER, (*it), (*it)->getItemCount(), NULL, FLAG_NOLIMIT); if(player->isVirtual()) { IOLoginData::getInstance()->savePlayer(player); delete player; } } else { for(ItemList::iterator it = moveList.begin(); it != moveList.end(); ++it) g_game.internalRemoveItem(NULL, (*it), (*it)->getItemCount(), false, FLAG_NOLIMIT); } return true; }
bool qmimap4::CopyOfflineJob::merge(OfflineJob* pOfflineJob) { assert(pOfflineJob); if (pOfflineJob->getType() == TYPE_COPY && wcscmp(getFolder(), pOfflineJob->getFolder()) == 0) { CopyOfflineJob* p = static_cast<CopyOfflineJob*>(pOfflineJob); if (wcscmp(wstrFolderTo_.get(), p->wstrFolderTo_.get()) == 0 && bMove_ == p->bMove_) { UidList listUidFrom; listUidFrom.reserve(listUidFrom_.size() + p->listUidFrom_.size()); ItemList listItemTo; listItemTo.reserve(listItemTo_.size() + p->listItemTo_.size()); UidList::const_iterator itUS = listUidFrom_.begin(); UidList::const_iterator itUO = p->listUidFrom_.begin(); ItemList::const_iterator itIS = listItemTo_.begin(); ItemList::const_iterator itIO = p->listItemTo_.begin(); while (true) { if (itUS != listUidFrom_.end()) { if (itUO != p->listUidFrom_.end()) { if (*itUS < *itUO) { listUidFrom.push_back(*itUS++); listItemTo.push_back(*itIS++); } else { listUidFrom.push_back(*itUO++); listItemTo.push_back(*itIO++); } } else { listUidFrom.push_back(*itUS++); listItemTo.push_back(*itIS++); } } else { if (itUO != p->listUidFrom_.end()) { listUidFrom.push_back(*itUO++); listItemTo.push_back(*itIO++); } else { break; } } } listUidFrom_.swap(listUidFrom); listItemTo_.swap(listItemTo); return true; } } return false; }
Item_spawn_data::ItemList Single_item_creator::create(int birthday, RecursionList &rec) const { ItemList result; int cnt = 1; if (modifier.get() != NULL) { cnt = (modifier->count.first == modifier->count.second) ? modifier->count.first : rng( modifier->count.first, modifier->count.second); } for( ; cnt > 0; cnt--) { if (type == S_ITEM) { result.push_back(create_single(birthday, rec)); } else { if (std::find(rec.begin(), rec.end(), id) != rec.end()) { debugmsg("recursion in item spawn list %s", id.c_str()); return result; } rec.push_back(id); Item_spawn_data *isd = item_controller->get_group(id); if (isd == NULL) { debugmsg("unknown item spawn list %s", id.c_str()); return result; } ItemList tmplist = isd->create(birthday, rec); if (modifier.get() != NULL) { for(ItemList::iterator a = tmplist.begin(); a != tmplist.end(); ++a) { modifier->modify(*a); } } result.insert(result.end(), tmplist.begin(), tmplist.end()); } } return result; }
void GraphViewBaseImpl::updatePartList() { treeWidget.clear(); int numParts = 0; if(!itemInfos.empty()){ ItemList<Item> items; for(list<ItemInfo>::iterator p = itemInfos.begin(); p != itemInfos.end(); ++p){ items.push_back(p->item.get()); } numParts = self->currentNumParts(items); } for(int i=0; i < numParts; ++i){ PartItem* partItem = new PartItem(); partItem->setText(0, QString::number(i)); partItem->setTextAlignment(0, Qt::AlignHCenter); partItem->index = i; treeWidget.addTopLevelItem(partItem); } treeWidget.header()->updateGeometry(); treeWidget.updateGeometry(); updateSelections(); }
Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) const { ItemList result; if (type == G_COLLECTION) { for(prop_list::const_iterator a = items.begin(); a != items.end(); ++a) { if(rng(0, 99) >= (*a)->probability) { continue; } ItemList tmp = (*a)->create(birthday, rec); result.insert(result.end(), tmp.begin(), tmp.end()); } } else if (type == G_DISTRIBUTION) { int p = rng(0, sum_prob - 1); for(prop_list::const_iterator a = items.begin(); a != items.end(); ++a) { p -= (*a)->probability; if (p >= 0) { continue; } ItemList tmp = (*a)->create(birthday, rec); result.insert(result.end(), tmp.begin(), tmp.end()); break; } } if (with_ammo && !result.empty()) { it_gun *maybe_gun = dynamic_cast<it_gun *>(result.front().type); if (maybe_gun != NULL) { item ammo(default_ammo(maybe_gun->ammo), birthday); // TODO: change the spawn lists to contain proper references to containers ammo = ammo.in_its_container(); result.push_back(ammo); } } return result; }
ItemList<BodyItem> WorldItem::coldetBodyItems() const { ItemList<BodyItem> bodyItems; for(auto& info : impl->coldetBodyInfos){ bodyItems.push_back(info.bodyItem); } return bodyItems; }
virtual void fillItems(ItemList& items, IItemCreator const& creator) { while (this->hasData()) { db::IItem* item = creator.create(); this->fetchone().fillItem(*item); items.push_back(*item); } }
// LinkItems - This function is the main entry point into linking. It takes a // list of LinkItem which indicates the order the files should be linked and // how each file should be treated (plain file or with library search). The // function only links bitcode and produces a result list of items that are // native objects. bool Linker::LinkInItems(const ItemList& Items, ItemList& NativeItems) { // Clear the NativeItems just in case NativeItems.clear(); // For each linkage item ... for (ItemList::const_iterator I = Items.begin(), E = Items.end(); I != E; ++I) { if (I->second) { // Link in the library suggested. bool is_native = false; if (LinkInLibrary(I->first, is_native)) return true; if (is_native) NativeItems.push_back(*I); } else { // Link in the file suggested bool is_native = false; if (LinkInFile(sys::Path(I->first), is_native)) return true; if (is_native) NativeItems.push_back(*I); } } // At this point we have processed all the link items provided to us. Since // we have an aggregated module at this point, the dependent libraries in // that module should also be aggregated with duplicates eliminated. This is // now the time to process the dependent libraries to resolve any remaining // symbols. bool is_native; for (Module::lib_iterator I = Composite->lib_begin(), E = Composite->lib_end(); I != E; ++I) { if(LinkInLibrary(*I, is_native)) return true; if (is_native) NativeItems.push_back(std::make_pair(*I, true)); } return false; }
void ItemTreeViewImpl::extractCheckedItems(QTreeWidgetItem* twItem, int column, ItemList<>& checkedItemList) { ItvItem* itvItem = dynamic_cast<ItvItem*>(twItem); if(itvItem){ if(itvItem->checkState(column) == Qt::Checked){ checkedItemList.push_back(itvItem->item.get()); } } int n = twItem->childCount(); for(int i=0; i < n; ++i){ extractCheckedItems(twItem->child(i), column, checkedItemList); } }
void CLxItemSelection::GetList ( ItemList &list) { CLxUser_Item item; LXtScanInfoID scan; void *pkt; list.clear (); scan = 0; while (scan = srv_sel.ScanLoop (scan, sel_ID, &pkt)) { pkt_trans.GetItem (pkt, item); if (Include (item)) list.push_back (item); } }
Item_spawn_data::ItemList Single_item_creator::create( const time_point &birthday, RecursionList &rec ) const { ItemList result; int cnt = 1; if( modifier ) { auto modifier_count = modifier->count; cnt = ( modifier_count.first == modifier_count.second ) ? modifier_count.first : rng( modifier_count.first, modifier_count.second ); } for( ; cnt > 0; cnt-- ) { if( type == S_ITEM ) { const auto itm = create_single( birthday, rec ); if( !itm.is_null() ) { result.push_back( itm ); } } else { if( std::find( rec.begin(), rec.end(), id ) != rec.end() ) { debugmsg( "recursion in item spawn list %s", id.c_str() ); return result; } rec.push_back( id ); Item_spawn_data *isd = item_controller->get_group( id ); if( isd == nullptr ) { debugmsg( "unknown item spawn list %s", id.c_str() ); return result; } ItemList tmplist = isd->create( birthday, rec ); rec.erase( rec.end() - 1 ); if( modifier ) { for( auto &elem : tmplist ) { modifier->modify( elem ); } } result.insert( result.end(), tmplist.begin(), tmplist.end() ); } } return result; }
ItemList MonsterType::createLoot(const LootBlock& lootBlock) { uint16_t item = lootBlock.ids[0], random = Monsters::getLootRandom(), count = 0; if(lootBlock.ids.size() > 1) item = lootBlock.ids[random_range((size_t)0, lootBlock.ids.size() - 1)]; ItemList items; if(random < lootBlock.chance) count = random % lootBlock.count + 1; Item* tmpItem = NULL; while(count > 0) { uint16_t n = 0; if(Item::items[item].stackable) n = std::min(count, (uint16_t)100); if(!(tmpItem = Item::CreateItem(item, n))) break; count -= (!n ? 1 : n); if(lootBlock.subType != -1) tmpItem->setSubType(lootBlock.subType); if(lootBlock.actionId != -1) tmpItem->setActionId(lootBlock.actionId, false); if(lootBlock.uniqueId != -1) tmpItem->setUniqueId(lootBlock.uniqueId); if(!lootBlock.text.empty()) tmpItem->setText(lootBlock.text); items.push_back(tmpItem); } return items; }
Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) const { ItemList result; if (type == G_COLLECTION) { for( const auto &elem : items ) { if( rng( 0, 99 ) >= ( elem )->probability ) { continue; } ItemList tmp = ( elem )->create( birthday, rec ); result.insert(result.end(), tmp.begin(), tmp.end()); } } else if (type == G_DISTRIBUTION) { int p = rng(0, sum_prob - 1); for( const auto &elem : items ) { p -= ( elem )->probability; if (p >= 0) { continue; } ItemList tmp = ( elem )->create( birthday, rec ); result.insert(result.end(), tmp.begin(), tmp.end()); break; } } if (with_ammo && !result.empty()) { const auto t = result.front().type; if( t->gun ) { const std::string ammoid = default_ammo( t->gun->ammo ); if ( !ammoid.empty() ) { item ammo( ammoid, birthday ); // TODO: change the spawn lists to contain proper references to containers ammo = ammo.in_its_container(); result.push_back( ammo ); } } } return result; }
bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue& upq, std::vector<ConfigItem::Ptr>& newItems) { typedef std::pair<ConfigItem::Ptr, bool> ItemPair; std::vector<ItemPair> items; { boost::mutex::scoped_lock lock(m_Mutex); BOOST_FOREACH(const TypeMap::value_type& kv, m_Items) { BOOST_FOREACH(const ItemMap::value_type& kv2, kv.second) { if (kv2.second->m_Abstract || kv2.second->m_Object) continue; if (kv2.second->m_ActivationContext != context) continue; items.push_back(std::make_pair(kv2.second, false)); } } ItemList newUnnamedItems; BOOST_FOREACH(const ConfigItem::Ptr& item, m_UnnamedItems) { if (item->m_ActivationContext != context) { newUnnamedItems.push_back(item); continue; } if (item->m_Abstract || item->m_Object) continue; items.push_back(std::make_pair(item, true)); } m_UnnamedItems.swap(newUnnamedItems); }
Corpse* Corpse::LoadCharacterCorpseEntity(uint32 in_dbid, uint32 in_charid, std::string in_charname, const glm::vec4& position, std::string time_of_death, bool rezzed, bool was_at_graveyard) { uint32 item_count = database.GetCharacterCorpseItemCount(in_dbid); char *buffer = new char[sizeof(PlayerCorpse_Struct) + (item_count * sizeof(player_lootitem::ServerLootItem_Struct))]; PlayerCorpse_Struct *pcs = (PlayerCorpse_Struct*)buffer; database.LoadCharacterCorpseData(in_dbid, pcs); /* Load Items */ ItemList itemlist; ServerLootItem_Struct* tmp = 0; for (unsigned int i = 0; i < pcs->itemcount; i++) { tmp = new ServerLootItem_Struct; memcpy(tmp, &pcs->items[i], sizeof(player_lootitem::ServerLootItem_Struct)); itemlist.push_back(tmp); } /* Create Corpse Entity */ Corpse* pc = new Corpse( in_dbid, // uint32 in_dbid in_charid, // uint32 in_charid in_charname.c_str(), // char* in_charname &itemlist, // ItemList* in_itemlist pcs->copper, // uint32 in_copper pcs->silver, // uint32 in_silver pcs->gold, // uint32 in_gold pcs->plat, // uint32 in_plat position, pcs->size, // float in_size pcs->gender, // uint8 in_gender pcs->race, // uint16 in_race pcs->class_, // uint8 in_class pcs->deity, // uint8 in_deity pcs->level, // uint8 in_level pcs->texture, // uint8 in_texture pcs->helmtexture, // uint8 in_helmtexture pcs->exp, // uint32 in_rezexp was_at_graveyard // bool wasAtGraveyard ); if (pcs->locked) pc->Lock(); /* Load Item Tints */ pc->item_tint[0].Color = pcs->item_tint[0].Color; pc->item_tint[1].Color = pcs->item_tint[1].Color; pc->item_tint[2].Color = pcs->item_tint[2].Color; pc->item_tint[3].Color = pcs->item_tint[3].Color; pc->item_tint[4].Color = pcs->item_tint[4].Color; pc->item_tint[5].Color = pcs->item_tint[5].Color; pc->item_tint[6].Color = pcs->item_tint[6].Color; pc->item_tint[7].Color = pcs->item_tint[7].Color; pc->item_tint[8].Color = pcs->item_tint[8].Color; /* Load Physical Appearance */ pc->haircolor = pcs->haircolor; pc->beardcolor = pcs->beardcolor; pc->eyecolor1 = pcs->eyecolor1; pc->eyecolor2 = pcs->eyecolor2; pc->hairstyle = pcs->hairstyle; pc->luclinface = pcs->face; pc->beard = pcs->beard; pc->drakkin_heritage = pcs->drakkin_heritage; pc->drakkin_tattoo = pcs->drakkin_tattoo; pc->drakkin_details = pcs->drakkin_details; pc->IsRezzed(rezzed); pc->become_npc = false; pc->m_Light.Level.Innate = pc->m_Light.Type.Innate = 0; pc->UpdateEquipmentLight(); // itemlist populated above..need to determine actual values pc->m_Light.Level.Spell = pc->m_Light.Type.Spell = 0; safe_delete_array(pcs); return pc; }