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; }
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; }