本文整理汇总了C++中ItemList::end方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemList::end方法的具体用法?C++ ItemList::end怎么用?C++ ItemList::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
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;
}
示例2: create
Item_spawn_data::ItemList Item_group::create( const time_point &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;
}
}
return result;
}
示例3: create
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;
}
示例4: transferToDepot
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;
}
示例5: findItemOfName
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();
}
示例6: transferToDepot
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;
}
示例7:
// 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;
}
示例8: FindItem
/**
* 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; });
}
示例9: createChildLoot
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();
}
示例10: sortItems
void DesktopSortingStrategy::sortItems(ItemList &items)
{
GroupManager *gm = qobject_cast<GroupManager *>(parent());
qStableSort(items.begin(), items.end(), (gm && gm->separateLaunchers()) ?
DesktopSortingStrategy::lessThanSeperateLaunchers :
DesktopSortingStrategy::lessThan);
}
示例11: transferToDepot
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;
}
示例12: create
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;
}
}
for( auto& e : result ) {
bool spawn_ammo = rng( 0, 99 ) < with_ammo;
bool spawn_mags = rng( 0, 99 ) < with_magazine || spawn_ammo;
if( spawn_mags && !e.magazine_integral() && !e.magazine_current() ) {
e.contents.emplace_back( e.magazine_default(), e.bday );
}
if( spawn_ammo && e.ammo_capacity() > 0 && e.ammo_remaining() == 0 ) {
itype_id ammo = default_ammo( e.ammo_type() );
if( e.magazine_current() ) {
e.magazine_current()->contents.emplace_back( ammo, e.bday, e.ammo_capacity() );
} else {
e.set_curammo( ammo );
e.charges = e.ammo_capacity();
}
}
}
return result;
}
示例13: calculateWeight
// 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;
}
示例14: create
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;
}
示例15: dropLoot
void MonsterType::dropLoot(Container* corpse)
{
ItemList items;
for(LootItems::const_iterator it = lootItems.begin(); it != lootItems.end() && !corpse->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))
corpse->__internalAddThing(tmpItem);
else
delete container;
}
else
corpse->__internalAddThing(tmpItem);
}
}
corpse->__startDecaying();
uint32_t ownerId = corpse->getCorpseOwner();
if(!ownerId)
return;
Player* owner = g_game.getPlayerByGuid(ownerId);
if(!owner)
return;
LootMessage_t message = lootMessage;
if(message == LOOTMSG_IGNORE)
message = (LootMessage_t)g_config.getNumber(ConfigManager::LOOT_MESSAGE);
if(message < LOOTMSG_PLAYER)
return;
std::stringstream ss;
ss << "Loot of " << nameDescription << ": " << corpse->getContentDescription() << ".";
if(owner->getParty() && message > LOOTMSG_PLAYER)
owner->getParty()->broadcastMessage((MessageClasses)g_config.getNumber(ConfigManager::LOOT_MESSAGE_TYPE), ss.str());
else if(message == LOOTMSG_PLAYER || message == LOOTMSG_BOTH)
owner->sendTextMessage((MessageClasses)g_config.getNumber(ConfigManager::LOOT_MESSAGE_TYPE), ss.str());
}