bool MonsterType::createChildLoot(Container* parent, const LootBlock& lootBlock) { LootItems::const_iterator it = lootBlock.childLoot.begin(); if(it == lootBlock.childLoot.end()) return true; ItemList items; for(; it != lootBlock.childLoot.end() && !parent->full(); ++it) { items = createLoot(*it); if(items.empty()) continue; for(ItemList::iterator iit = items.begin(); iit != items.end(); ++iit) { Item* tmpItem = *iit; if(Container* container = tmpItem->getContainer()) { if(createChildLoot(container, *it)) parent->__internalAddThing(tmpItem); else delete container; } else parent->__internalAddThing(tmpItem); } } return !parent->empty(); }
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; }
std::auto_ptr<OfflineJob> qmimap4::CopyOfflineJob::create(qs::InputStream* pStream) { wstring_ptr wstrFolderFrom; READ_STRING(WSTRING, wstrFolderFrom); if (!wstrFolderFrom.get()) return std::auto_ptr<OfflineJob>(0); wstring_ptr wstrFolderTo; READ_STRING(WSTRING, wstrFolderTo); if (!wstrFolderTo.get()) return std::auto_ptr<OfflineJob>(0); unsigned int nSize = 0; READ(&nSize, sizeof(nSize)); if (nSize == 0) return std::auto_ptr<OfflineJob>(0); UidList listUidFrom; listUidFrom.resize(nSize); ItemList listItemTo; listItemTo.resize(nSize); READ(&listUidFrom[0], nSize*sizeof(UidList::value_type)); READ(&listItemTo[0], nSize*sizeof(ItemList::value_type)); bool bMove = false; READ(&bMove, sizeof(bMove)); return std::auto_ptr<OfflineJob>(new CopyOfflineJob(wstrFolderFrom.get(), wstrFolderTo.get(), listUidFrom, listItemTo, bMove)); }
bool KSIImpl::setupBodies() { if(TRACE_FUNCTIONS){ cout << "KSIImpl::setupBodies()" << endl; } mainFrameRate = 0; bodyUnits.clear(); WorldItemPtr worldItem = self->findOwnerItem<WorldItem>(); if(worldItem){ ItemList<BodyItem> bodyItems = worldItem->getBodyItems(); for(size_t i=0; i < bodyItems.size(); ++i){ BodyUnit unit; if(unit.initialize(bodyItems[i])){ bodyUnits.push_back(unit); if(unit.frameRate > mainFrameRate){ mainFrameRate = unit.frameRate; } } } } return (!bodyUnits.empty() && mainFrameRate > 0); }
void AbstractSortingStrategy::check(AbstractGroupableItem *itemToCheck) { AbstractGroupableItem *item; if (!itemToCheck) { item = dynamic_cast<AbstractGroupableItem *>(sender()); } else { item = itemToCheck; } if (!item) { qWarning() << "invalid item" << itemToCheck; return; } //qDebug() << item->name(); if (item->itemType() == TaskItemType) { if (!(qobject_cast<TaskItem*>(item))->task()) { //ignore startup tasks return; } } if (!item->parentGroup()) { //qDebug() << "No parent group"; return; } ItemList sortedList = item->parentGroup()->members(); sortItems(sortedList); int oldIndex = item->parentGroup()->members().indexOf(item); int newIndex = sortedList.indexOf(item); if (oldIndex != newIndex) { item->parentGroup()->moveItem(oldIndex, newIndex); } }
bool EditableSceneBodyImpl::storeProperties(Archive& archive) { ListingPtr states = new Listing(); ItemList<BodyItem> bodyItems; bodyItems.extractChildItems(RootItem::instance()); for(size_t i=0; i < bodyItems.size(); ++i){ BodyItem* bodyItem = bodyItems[i]; EditableSceneBody* sceneBody = bodyItem->existingSceneBody(); if(sceneBody){ ValueNodePtr id = archive.getItemId(bodyItem); if(id){ EditableSceneBodyImpl* impl = sceneBody->impl; MappingPtr state = new Mapping(); state->insert("bodyItem", id); state->write("showCenterOfMass", impl->isCmVisible); state->write("showZmp", impl->isZmpVisible); states->append(state); } } } if(!states->empty()){ archive.insert("editableSceneBodies", states); return true; } return false; }
DropList::DropList (Window &win, const ItemList &items_, size_t default_select) : Control (win) , FocusColorControl (win) , items (items_.empty () ? ItemList (1) : items_) , select (default_select < items_.size () ? default_select : 0) { }
void ScriptBar::executeCheckedScriptItems() { ItemList<ScriptItem> scripts = ItemTreeView::mainInstance()->checkedItems<ScriptItem>(); for(int i=0; i < scripts.size(); ++i){ scripts[i]->execute(); } }
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; }
/** * Calculate prefix paths that end with a node that has the given ItemID. * These nodes can be retrieved very quickly using the FPTree's itemPaths. * A prefix path is a list of Items that reflects a path from the bottom * of the tree to the root (but excluding the root), following along the * path of an FPNode that has the ItemID itemID. Because it is a list of * Items, it also includes both the ItemID and the SupportCount. The * original SupportCount of the Item encapsulated by the FPNode is erased * and replaced by the SupportCount of the FPNode we started from, i.e. a * node that has the ItemID itemID, because we're looking at only the * paths that include this node. * Exclude the leaf node itself, as it will no longer be needed. */ QList<ItemList> FPTree::calculatePrefixPaths(ItemID itemID) const { QList<ItemList> prefixPaths; ItemList prefixPath; FPNode<SupportCount> * node; SupportCount supportCount; Item item; QList<FPNode<SupportCount> *> leafNodes = this->getItemPath(itemID); foreach (FPNode<SupportCount> * leafNode, leafNodes) { // Build the prefix path starting from the given leaf node, by // traversing up the tree (but do not include the leaf node's item // in the prefix path). // Don't copy the item's original count, but the count of the leaf // node instead, because we're looking at only the paths that // include this leaf node. node = leafNode; supportCount = leafNode->getValue(); while ((node = node->getParent()) != NULL && node->getItemID() != ROOT_ITEMID) { item.id = node->getItemID(); item.supportCount = supportCount; prefixPath.prepend(item); } // Store the built prefix path & clear it, so we can calculate the // next. Of course only if there *is* a prefix path, which is not // the case if the given itemID is at the root level. if (prefixPath.size() > 0) { prefixPaths.append(prefixPath); prefixPath.clear(); } }
/** * Find an existing item by its FLARM id. This is a simple linear * search that doesn't scale well with a large list. */ gcc_pure ItemList::iterator FindItem(FlarmId id) { assert(id.IsDefined()); return std::find_if(items.begin(), items.end(), [id](const Item &item) { return item.id == id; }); }
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(); }
void DesktopSortingStrategy::sortItems(ItemList &items) { GroupManager *gm = qobject_cast<GroupManager *>(parent()); qStableSort(items.begin(), items.end(), (gm && gm->separateLaunchers()) ? DesktopSortingStrategy::lessThanSeperateLaunchers : DesktopSortingStrategy::lessThan); }
// 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; }
void ItemDocument::raiseZ(const ItemList & itemList) { if (m_zOrder.empty()) slotUpdateZOrdering(); if (m_zOrder.empty()) return; IntItemMap::iterator begin = m_zOrder.begin(); IntItemMap::iterator previous = m_zOrder.end(); IntItemMap::iterator it = --m_zOrder.end(); do { Item *previousData = (previous == m_zOrder.end()) ? 0 : previous->second; Item *currentData = it->second; if (currentData && previousData && itemList.contains(currentData) && !itemList.contains(previousData)) { previous->second = currentData; it->second = previousData; } previous = it; --it; } while (previous != begin); slotUpdateZOrdering(); }
void TrafficListWidget::UpdateList() { assert(filter_widget != nullptr); items.clear(); last_update.Clear(); const TCHAR *callsign = filter_widget->GetValueString(CALLSIGN); if (!StringIsEmpty(callsign)) { FlarmId ids[30]; unsigned count = FlarmDetails::FindIdsByCallSign(callsign, ids, 30); for (unsigned i = 0; i < count; ++i) AddItem(ids[i]); } else { /* if no filter was set, show a list of current traffic and known traffic */ /* add live FLARM traffic */ for (const auto &i : CommonInterface::Basic().flarm.traffic.list) { AddItem(i.id); } /* add FLARM peers that have a user-defined color */ for (const auto &i : traffic_databases->flarm_colors) { Item &item = AddItem(i.first); item.color = i.second; } /* add FLARM peers that have a user-defined name */ for (const auto &i : traffic_databases->flarm_names) { AddItem(i.id); } #ifdef HAVE_SKYLINES_TRACKING_HANDLER /* show SkyLines traffic unless this is a FLARM traffic picker dialog (from dlgTeamCode) */ if (action_listener == nullptr) { const auto &data = tracking->GetSkyLinesData(); const ScopeLock protect(data.mutex); for (const auto &i : data.traffic) { items.emplace_back(i.first, i.second.location); Item &item = items.back(); if (i.second.location.IsValid() && CommonInterface::Basic().location_available) item.vector = GeoVector(CommonInterface::Basic().location, i.second.location); } } #endif } GetList().SetLength(items.size()); UpdateVolatile(); UpdateButtons(); }
void CollisionSeq::readCollisionData(int nFrames, const Listing& values) { /* WorldItem* worldItem = collisionSeqItem_->findOwnerItem<WorldItem>(); if(!worldItem) return; */ WorldItem* worldItem = 0; RootItem* rootItem = RootItem::instance(); ItemList<WorldItem> worldItems; if(worldItems.extractChildItems(rootItem)){ worldItem = worldItems.front(); } if(!worldItem) return; for(int i=0; i < nFrames; ++i){ const Mapping& frameNode = *values[i].toMapping(); const Listing& linkPairs = *frameNode.findListing("LinkPairs"); Frame f = frame(i); f[0] = std::make_shared<CollisionLinkPairList>(); for(int j=0; j<linkPairs.size(); j++){ CollisionLinkPairPtr destLinkPair = std::make_shared<CollisionLinkPair>(); const Mapping& linkPair = *linkPairs[j].toMapping(); string body0name = linkPair["body0"].toString(); string body1name = linkPair["body1"].toString(); string link0name = linkPair["link0"].toString(); string link1name = linkPair["link1"].toString(); BodyItem* body0Item = worldItem->findChildItem<BodyItem>(body0name); Body* body0=0; Body* body1=0; Link* link0=0; Link* link1=0; if(body0Item){ body0 = body0Item->body(); link0 = body0->link(link0name); } BodyItem* body1Item = worldItem->findChildItem<BodyItem>(body1name); if(body1Item){ body1 = body1Item->body(); link1 = body1->link(link1name); } destLinkPair->body[0] = body0; destLinkPair->link[0] = link0; destLinkPair->body[1] = body1; destLinkPair->link[1] = link1; const Listing& collisions = *linkPair.findListing("Collisions"); for(int k=0; k<collisions.size(); k++){ destLinkPair->collisions.push_back(Collision()); Collision& destCol = destLinkPair->collisions.back(); const Listing& collision = *collisions[k].toListing(); destCol.point = Vector3(collision[0].toDouble(), collision[1].toDouble(), collision[2].toDouble()); destCol.normal = Vector3(collision[3].toDouble(), collision[4].toDouble(), collision[5].toDouble()); destCol.depth = collision[6].toDouble(); } f[0]->push_back(destLinkPair); } } }
ItemList<BodyItem> WorldItem::coldetBodyItems() const { ItemList<BodyItem> bodyItems; for(auto& info : impl->coldetBodyInfos){ bodyItems.push_back(info.bodyItem); } return bodyItems; }
/** * Add a new item to the list, unless the given FLARM id already * exists. */ Item &AddItem(FlarmId id) { auto existing = FindItem(id); if (existing != items.end()) return *existing; items.emplace_back(id); return items.back(); }
void KinematicFaultCheckerImpl::apply() { bool processed = false; ItemList<BodyMotionItem> items = ItemTreeView::mainInstance()->selectedItems<BodyMotionItem>(); if(items.empty()){ mes.notify(_("No BodyMotionItems are selected.")); } else { for(size_t i=0; i < items.size(); ++i){ BodyMotionItem* motionItem = items.get(i); BodyItem* bodyItem = motionItem->findOwnerItem<BodyItem>(); if(!bodyItem){ mes.notify(str(fmt(_("%1% is not owned by any BodyItem. Check skiped.")) % motionItem->name())); } else { mes.putln(); mes.notify(str(fmt(_("Applying the Kinematic Fault Checker to %1% ...")) % motionItem->headItem()->name())); dynamic_bitset<> linkSelection; if(selectedJointsRadio.isChecked()){ linkSelection = LinkSelectionView::mainInstance()->linkSelection(bodyItem); } else if(nonSelectedJointsRadio.isChecked()){ linkSelection = LinkSelectionView::mainInstance()->linkSelection(bodyItem); linkSelection.flip(); } else { linkSelection.resize(bodyItem->body()->numLinks(), true); } double beginningTime = 0.0; double endingTime = motionItem->motion()->getTimeLength(); std::numeric_limits<double>::max(); if(onlyTimeBarRangeCheck.isChecked()){ TimeBar* timeBar = TimeBar::instance(); beginningTime = timeBar->minTime(); endingTime = timeBar->maxTime(); } int n = checkFaults(bodyItem, motionItem, mes.cout(), positionCheck.isChecked(), velocityCheck.isChecked(), collisionCheck.isChecked(), linkSelection, beginningTime, endingTime); if(n > 0){ if(n == 1){ mes.notify(_("A fault has been detected.")); } else { mes.notify(str(fmt(_("%1% faults have been detected.")) % n)); } } else { mes.notify(_("No faults have been detected.")); } processed = true; } } } }
TrafficListWidget(ActionListener &_action_listener, const FlarmId *array, size_t count) :action_listener(&_action_listener), filter_widget(nullptr), buttons(nullptr) { items.reserve(count); for (unsigned i = 0; i < count; ++i) items.emplace_back(array[i]); }
void TimelineItem::removeIncidence( KCal::Incidence *incidence ) { typedef QList<TimelineSubItem*> ItemList; ItemList list = mItemMap[incidence]; for ( ItemList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it ) { delete *it; } mItemMap.remove( incidence ); }
ItemList<BodyItem>::iterator findItemOfName(ItemList<BodyItem>& items, const std::string& name) { for(ItemList<BodyItem>::iterator p = items.begin(); p != items.end(); ++p){ if((*p)->name() == name){ return p; } } return items.end(); }
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 WorldItemImpl::updateColdetBodyInfos(vector<ColdetBodyInfo>& infos) { infos.clear(); ItemList<BodyItem> bodyItems; bodyItems.extractChildItems(self); for(auto bodyItem : bodyItems){ if(bodyItem->isCollisionDetectionEnabled()){ infos.push_back(ColdetBodyInfo(bodyItem)); } } }
void TimelineItem::moveItems( KCal::Incidence *incidence, int delta, int duration ) { typedef QList<TimelineSubItem*> ItemList; ItemList list = mItemMap[incidence]; for ( ItemList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it ) { QDateTime start = (*it)->originalStart().dateTime(); start = start.addSecs( delta ); (*it)->setStartTime( start ); (*it)->setOriginalStart( KDateTime(start) ); (*it)->setEndTime( start.addSecs( duration ) ); } }
// Berechnungsmethoden void Inventory::calculateWeight(ItemList items) { ItemList::iterator it = items.begin(); Ogre::Real totalWeight = 0.0; while (it != items.end()) { totalWeight += (*it)->getMass(); it++; } mCurrentWeight = totalWeight; }
void OpenHRPOnlineViewerItemImpl::updatesub(const WorldState& state) { if(!worldItem){ RootItem* rootItem = RootItem::instance(); ItemList<WorldItem> worldItems; if(worldItems.extractChildItems(rootItem)){ worldItem = worldItems.front(); } else { worldItem = new WorldItem(); worldItem->setName("World"); rootItem->addChildItem(worldItem); ItemTreeView::instance()->checkItem(worldItem, true); } worldItemConnections.add( worldItem->sigDisconnectedFromRoot().connect( boost::bind(&OpenHRPOnlineViewerItemImpl::onWorldItemDetachedFromRoot, this))); } if(!collisionSeqItem){ collisionSeqItem = worldItem->findChildItem<CollisionSeqItem>(collisionLogName); if(!collisionSeqItem){ collisionSeqItem = new CollisionSeqItem(); collisionSeqItem->setTemporal(); collisionSeqItem->setName(collisionLogName); worldItem->addChildItem(collisionSeqItem); } resetCollisionLogItem(collisionSeqItem); needToSelectCollisionLogItem = true; } if(needToSelectCollisionLogItem){ ItemTreeView::instance()->selectItem(collisionSeqItem, true); needToSelectCollisionLogItem = false; } const CollisionSeqPtr& colSeq = collisionSeqItem->collisionSeq(); int frame = colSeq->frameOfTime(state.time); int lastFrame = std::max(0, std::min(frame, colSeq->numFrames())); colSeq->setNumFrames(frame + 1); CollisionLinkPairListPtr collisionPairs = boost::make_shared<CollisionLinkPairList>(); updateCollision(state, collisionPairs.get()); for(int i=lastFrame; i <= frame; ++i){ CollisionSeq::Frame collisionPairs0 = colSeq->frame(i); collisionPairs0[0] = collisionPairs; } forEachBody(state, boost::bind(&OpenHRPOnlineViewerItemImpl::updateLog, this, _1, _2, _3, _4)); }
void ExportThread::exportItems( const QString& name, ItemList& items, quint32& currentItem, QTime& time ) { if( !items.isEmpty() ) { QDir dir( m_directory ); if( dir.exists() ) { if( !dir.cd( name ) ) dir.mkdir( name ); dir.cd( name ); QTime rate; rate.start(); quint32 count = 0; foreach( TibiaItem* item, items ) { if( isCanceled() ) break; if( exportItem( dir, item ) ) { emit valueChanged( currentItem ); currentItem++; if( ( float )( rate.elapsed() / 1000 ) >= 1 ) { emit labelText( tr( "%1\n\nElapsed Time: %2\nTime left: %3" ).arg( m_labelText ).arg( QTime().addMSecs( time.elapsed() ).toString( "hh:mm:ss" ) ).arg( QTime().addMSecs( ( int )( ( ( float )( m_maximum - currentItem ) / count ) * ( float )1000 ) ).toString( "hh:mm:ss" ) ) ); //emit rateChanged( count, libraryFile->getCount() - i, time.elapsed() ); // Items/sec, Items remaining rate.restart(); count = 0; } count++; } } } }
void BodyBarImpl::onItemSelectionChanged(const ItemList<BodyItem>& bodyItems) { bool selectedBodyItemsChanged = false; if(selectedBodyItems != bodyItems){ selectedBodyItems = bodyItems; selectedBodyItemsChanged = true; } BodyItem* firstItem = bodyItems.toSingle(); if(firstItem && firstItem != currentBodyItem){ currentBodyItem = firstItem; connectionOfCurrentBodyItemDetachedFromRoot.disconnect(); connectionOfCurrentBodyItemDetachedFromRoot = currentBodyItem->sigDetachedFromRoot().connect( std::bind(&BodyBarImpl::onBodyItemDetachedFromRoot, this)); sigCurrentBodyItemChanged(currentBodyItem.get()); } if(selectedBodyItemsChanged){ sigBodyItemSelectionChanged(selectedBodyItems); } targetBodyItems.clear(); if(selectedBodyItems.empty()){ if(currentBodyItem){ targetBodyItems.push_back(currentBodyItem); } } else { targetBodyItems = selectedBodyItems; } }