/** * Add item to a place (armoury, unit body parts, etc.) * @param x x coordinate of an item inside of place * @param y y coordinate of an item inside of place * @param item_name symbolic name of item * @param item_name symbolic name of item * @param autoload boolean flag, if set to true, the game tries to automatically * load the weapon (if it does not have ammo choice) * @returns success or failure */ bool Place::add_item(int x, int y, const char *item_name, bool autoload) { Item *it = create_item(item_name); if (!it) return false; // Trying to put item here if (put(it, x, y)) { std::vector<std::string> ammo; Item::get_ammo_list(item_name, ammo); if (!autoload || ammo.size() != 1) return true; it = create_item(ammo[0].c_str()); if (!it) return true; } // Maybe it is ammo for already added weapon? Item *weapon = get(x, y); if (weapon) { bool loaded = weapon->loadclip(it); put(weapon, x, y); if (loaded) return true; } // Nowhere to put it, giving up delete it; return false; }
/** Inserts into ordered list if data does not already exist @return The new item or NULL if data already existed */ struct list_d_item* list_d_unique_insert(struct list_d* target, double data) { struct list_d_item* new_item = NULL; if (target->size == 0) { new_item = create_item(data); target->head = new_item; target->tail = new_item; } else { struct list_d_item* item = target->head; // Are we the new head? if (data < item->data) { new_item = create_item(data); new_item->next = target->head; target->head = new_item; } else if (data == item->data) { // The head is a duplicate of data return NULL; } else { do { // Are we inserting at the end of the list? if (item->next == NULL) { new_item = create_item(data); item->next = new_item; target->tail = new_item; break; } else { // Insert just before the next item if (data < item->next->data) { new_item = create_item(data); new_item->next = item->next; item->next = new_item; break; } else if (data == item->next->data) // Found a duplicate- do nothing return NULL; } } while ((item = item->next)); } } target->size++; return new_item; }
void SearchPanel::OnSearchResult(ResultsT * res) { unique_ptr<ResultsT> const guard(res); if (res->IsEndMarker()) { if (res->IsEndedNormal()) { // stop search busy indicator m_pAnimationTimer->stop(); m_pClearButton->setIcon(QIcon(":/ui/x.png")); } } else { ClearResults(); for (ResultsT::IterT i = res->Begin(); i != res->End(); ++i) { ResultT const & e = *i; QString s = QString::fromUtf8(e.GetString()); QString strHigh; int pos = 0; for (size_t r = 0; r < e.GetHighlightRangesCount(); ++r) { pair<uint16_t, uint16_t> const & range = e.GetHighlightRange(r); strHigh.append(s.mid(pos, range.first - pos)); strHigh.append("<font color=\"green\">"); strHigh.append(s.mid(range.first, range.second)); strHigh.append("</font>"); pos = range.first + range.second; } strHigh.append(s.mid(pos)); int const rowCount = m_pTable->rowCount(); m_pTable->insertRow(rowCount); m_pTable->setCellWidget(rowCount, 1, new QLabel(strHigh)); m_pTable->setItem(rowCount, 2, create_item(QString::fromUtf8(e.GetRegionString()))); if (e.GetResultType() == ResultT::RESULT_FEATURE) { m_pTable->setItem(rowCount, 0, create_item(QString::fromUtf8(e.GetFeatureType()))); m_pTable->setItem(rowCount, 3, create_item(m_pDrawWidget->GetDistance(e).c_str())); } m_results.push_back(e); } } }
void pick_berry(int in,int cn) { int ID,n,old_n=0,old_val=0,in2,ripetime; struct flower_ppd *ppd; if (!cn) return; if (ch[cn].citem) { log_char(cn,LOG_SYSTEM,0,"Please empty your hand (mouse cursor) first."); return; } ppd=set_data(cn,DRD_FLOWER_PPD,sizeof(struct flower_ppd)); if (!ppd) return; // oops... ID=(int)it[in].x+((int)(it[in].y)<<8)+(areaID<<16); for (n=0; n<MAXFLOWER; n++) { if (ppd->ID[n]==ID) break; if (realtime-ppd->last_used[n]>old_val) { old_val=realtime-ppd->last_used[n]; old_n=n; } } ripetime=60*60*24; if (n==MAXFLOWER) n=old_n; else if (realtime-ppd->last_used[n]<ripetime) { log_char(cn,LOG_SYSTEM,0,"It's not ripe yet."); return; } ppd->ID[n]=ID; ppd->last_used[n]=realtime; switch(it[in].drdata[0]) { case 1: in2=create_item("lizard_brown_berry"); break; case 2: in2=create_item("picked_flower_h"); break; case 3: in2=create_item("picked_flower_i"); break; case 4: in2=create_item("picked_flower_j"); break; default: log_char(cn,LOG_SYSTEM,0,"Bug # 4111c"); return; } if (ch[cn].flags&CF_PLAYER) dlog(cn,in2,"berry/flower: picked"); ch[cn].citem=in2; ch[cn].flags|=CF_ITEMS; it[in2].carried=cn; }
void warpkeyspawn_driver(int in,int cn) { int in2; char buf[80]; if (!cn) return; if (ch[cn].citem) { log_char(cn,LOG_SYSTEM,0,"Please empty your hand (mouse cursor) first."); return; } sprintf(buf,"warped_teleport_key%d",it[in].drdata[0]); in2=create_item(buf); if (!in2) { log_char(cn,LOG_SYSTEM,0,"It won't come off."); return; } ch[cn].citem=in2; it[in2].carried=cn; ch[cn].flags|=CF_ITEMS; log_char(cn,LOG_SYSTEM,0,"You got a glowing half sphere."); }
PlayerCharacter* PlayerCharacter::createFromSaveData(CharacterData* data) { PlayerCharacter* character = new PlayerCharacter; character->m_name = data->name; character->m_faceTexture = cache::loadTexture(data->textureName); character->m_textureRect = sf::IntRect(data->textureX, data->textureY, data->textureW, data->textureH); character->m_class = player_class_ref(data->className); for (auto it = data->statusEffects.begin(); it != data->statusEffects.end(); ++it) { character->m_status.push_back(get_status_effect(*it)); } for (auto it = data->attributes.begin(); it != data->attributes.end(); ++it) { character->m_attributes[it->first] = it->second; } for (auto it = data->spells.begin(); it != data->spells.end(); ++it) { character->m_spells.push_back(*it); } for (auto it = data->equipment.begin(); it != data->equipment.end(); ++it) { character->m_equipment[it->first] = create_item(it->second, 1); } return character; }
bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name.begins_with("item/")) { int idx = name.get_slicec('/', 1).to_int(); String what = name.get_slicec('/', 2); if (!item_map.has(idx)) create_item(idx); if (what == "name") set_item_name(idx, p_value); else if (what == "mesh") set_item_mesh(idx, p_value); else if (what == "shape") { Vector<ShapeData> shapes; ShapeData sd; sd.shape = p_value; shapes.push_back(sd); set_item_shapes(idx, shapes); } else if (what == "shapes") { _set_item_shapes(idx, p_value); } else if (what == "preview") set_item_preview(idx, p_value); else if (what == "navmesh") set_item_navmesh(idx, p_value); else return false; return true; } return false; }
int main() { sll_item_t *list = create_item(NULL); destroy_cyclic_sll(&list); destroy_cyclic_sll(&list); insert_item(insert_item(&list)); destroy_cyclic_sll(&list); { insert_item(&list); insert_item(&list); insert_item(&list); insert_item(&list); insert_item(&list); insert_item(&list); insert_item(&list); insert_item(&list); insert_item(&list); insert_item(&list); destroy_cyclic_sll(&list); } return 0; }
bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name.begins_with("item/")) { int idx = name.get_slicec('/', 1).to_int(); String what = name.get_slicec('/', 2); if (!item_map.has(idx)) create_item(idx); if (what == "name") set_item_name(idx, p_value); else if (what == "mesh") set_item_mesh(idx, p_value); else if (what == "shape") set_item_shape(idx, p_value); else if (what == "preview") set_item_preview(idx, p_value); else if (what == "navmesh") set_item_navmesh(idx, p_value); else return false; return true; } return false; }
static idn_result_t additem_to_top(idn__aliaslist_t list, const char *pattern, const char *encoding) { aliasitem_t new_item; idn_result_t r; TRACE(("additem_to_top()\n")); assert(list != NULL); assert(pattern != NULL); assert(encoding != NULL); if ((r = create_item(pattern, encoding, &new_item)) != idn_success) { WARNING(("additem_to_top: malloc failed\n")); return (r); } new_item->next = list->first_item; list->first_item = new_item; #ifdef DEBUG dump_list(list); #endif return (idn_success); }
static protocol_binary_response_status add_handler(const void *cookie, const void *key, uint16_t keylen, const void *data, uint32_t datalen, uint32_t flags, uint32_t exptime, uint64_t *cas) { (void)cookie; protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; struct item* item= get_item(key, keylen); if (item == NULL) { item= create_item(key, keylen, data, datalen, flags, (time_t)exptime); if (item == 0) { rval= PROTOCOL_BINARY_RESPONSE_ENOMEM; } else { put_item(item); *cas= item->cas; release_item(item); } } else { rval= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; } return rval; }
void additional_parts_dialog::repopulate() { m_lv_files->DeleteAllItems(); for (size_t idx = 0; m_files.size() > idx; ++idx) create_item(idx); }
static idn_result_t additem_to_bottom(idn__aliaslist_t list, const char *pattern, const char *encoding) { aliasitem_t new_item; idn_result_t r; TRACE(("additem_to_bottom()\n")); assert(list != NULL); assert(pattern != NULL); assert(encoding != NULL); r = create_item(pattern, encoding, &new_item); if (r != idn_success) { WARNING(("additem_to_bottom: malloc failed\n")); return r; } if (list->first_item == NULL) { list->first_item = new_item; } else { aliasitem_t cur_item = list->first_item; for (;;) { if (cur_item->next == NULL) { break; } cur_item = cur_item->next; } cur_item->next = new_item; } return (idn_success); }
void player_realdeath(Player *plr) { plr->deathtime = -DEATH_DELAY-1; plr->moveflags = 0; create_item(plr->pos, 6-15*I, Power); create_item(plr->pos, -6-15*I, Power); plr->pos = VIEWPORT_W/2 + VIEWPORT_H*I+30I; plr->recovery = -(global.frames + DEATH_DELAY + 150); if(plr->bombs < PLR_START_BOMBS) plr->bombs = PLR_START_BOMBS; if(plr->lifes-- == 0 && global.replaymode != REPLAY_PLAY) global.menu = create_gameover_menu(); }
int parse_defs_m4_line(char *line,select_menu *menu) { char *start,*end,*value_start,*value_end,*desc_start; select_item *item; int len=strlen(line); len--; start=memchr(line,'`',len); if (!start) { fprintf(output,"Failed to find macro start\n"); return -1; } start++; end=memchr(start,'\'',line+len-start); if (!end) { fprintf(output,"Failed to find macro end\n"); return -1; } start[end-start]=0; value_start=memchr(end,'`',line+len-end); if (!value_start) { fprintf(output,"Failed to find macro value start\n"); return -1; } value_start++; value_end=memchr(value_start,'\'',line+len-value_start); if (!value_end) { fprintf(output,"Failed to find macro value end\n"); return -1; } desc_start=memchr(value_end,'#',line+len-value_end); if (!desc_start) { fprintf(output,"Failed to find macro description\n"); return -1; } desc_start++; line[len]=0; item = create_item(start,desc_start); if (item == NULL) { fprintf(output,"Failed to create item\n"); return -1; } if (memcmp(value_start,"yes",3)==0) { item->enabled=1; item->prev_state=1; } link_item(menu,item); return 0; }
static void create_local_item_cb(EUserCreatableItemsHandler *handler, const char *item_type_name, void *data) { EMFolderTree *tree = data; char *uri = em_folder_tree_get_selected_uri(tree); create_item(item_type_name, em_folder_tree_get_model(tree), uri, (gpointer) tree); g_free(uri); }
void Menu::create_menu(std::shared_ptr<Resource> menu) { int qty = menu->getNumber("itemqty"); for (int i = 0; i < qty; i++) { std::string item_name = "item" + std::to_string(i); create_item(menu->get(item_name)); } }
dll_item_t* dll_push_front(dll_t *list) { dll_item_t *item = create_item(); if ((item->next = list->beg)) item->next->prev = item; list->beg = item; DLL_SET_IF_NULL(list->end, item); list->size ++; return item; }
dll_item_t* dll_push_back(dll_t *list) { dll_item_t *item = create_item(); if ((item->prev = list->end)) item->prev->next = item; DLL_SET_IF_NULL(list->beg, item); list->end = item; list->size ++; return item; }
void create_all(){ create_warehouse(); create_district(); create_history(); create_new_order(); create_order(); // create_order_line(); create_item(); create_stock(); create_customer(); }
void append_one(list_p list, end_point_t to) { item_p item = create_item(to, (*list)[to]); (*list)[to] = item; if (NULL == (*list)[LIST_BEG]) (*list)[LIST_BEG] = item; if (NULL == (*list)[LIST_END]) (*list)[LIST_END] = item; }
void container_found (const char *container_id) { dest_container = g_strdup (container_id); /* Now create the item container */ create_item ((char *) files->data, title, cds_proxy, dest_container); }
int main() { int res = EXIT_SUCCESS; ews::set_up(); try { const auto env = ews::test::environment(); auto service = ews::service(env.server_uri, env.domain, env.username, env.password); // First create a draft message ews::distinguished_folder_id drafts = ews::standard_folder::drafts; auto message = ews::message(); message.set_subject("This is an e-mail message for our Contains query"); std::vector<ews::mailbox> recipients; recipients.push_back(ews::mailbox("*****@*****.**")); message.set_to_recipients(recipients); auto item_id = service.create_item(message, ews::message_disposition::save_only); // Then search for it auto search_expression = ews::contains(ews::item_property_path::subject, "ess", ews::containment_mode::substring, ews::containment_comparison::ignore_case); auto item_ids = service.find_item(drafts, search_expression); if (item_ids.empty()) { std::cout << "No messages found!\n"; } else { for (const auto& id : item_ids) { auto msg = service.get_message(id); std::cout << msg.get_subject() << std::endl; } } } catch (std::exception& exc) { std::cout << exc.what() << std::endl; res = EXIT_FAILURE; } ews::tear_down(); return res; }
void append_one(list_p list, end_point_t to) { item_p *cursor = (item_p *) &(*list)[to]; item_p item = create_item(to, cursor); if (NULL == (*item)[ITEM_PREV]) (*list)[LIST_BEG] = item; if (NULL == (*list)[ITEM_NEXT]) (*list)[LIST_END] = item; }
void PlayerCharacter::equip(const std::string& equipmentSlot, const std::string& itemName) { if (itemName.empty()) { m_equipment.erase(to_lower(equipmentSlot)); } else { m_equipment[to_lower(equipmentSlot)] = create_item(itemName, 1); } }
void append_one(list_p list) { item_p item = create_item((*list)[LIST_BEG]); (*list)[LIST_BEG] = item; if (((void *)0) == (*list)[LIST_BEG]) (*list)[LIST_BEG] = item; if (((void *)0) == (*list)[LIST_END]) (*list)[LIST_END] = item; }
static void impl_requestCreateItem (PortableServer_Servant servant, const CORBA_char *item_type_name, CORBA_Environment *ev) { MailComponent *mc = MAIL_COMPONENT(bonobo_object_from_servant(servant)); if (create_item(item_type_name, mc->priv->model, NULL, NULL) == -1) { CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL); } }
bool hook_add(WHook *hk, WHookDummy *fn) { WHookItem *item; if(hook_find(hk, fn)) return FALSE; item=create_item(hk); if(item==NULL) return FALSE; item->fn=fn; return TRUE; }
/** Append an item to a list @return a pointer to the LISTITEM created and appended, \p NULL on error, errno - \p ENOMEM memory allocation failed **/ LISTITEM *list_append(GLLIST *list, /**< a pointer to the LIST structure to which the item it to be appended */ void *data) /**< a pointer to the data which the new LISTITEM will contain */ { LISTITEM *item = create_item(data,list->last,NULL); if (item!=NULL) { if (list->first==NULL) list->first = item; if (list->last!=NULL) list->last->next = item; list->last = item; list->size++; } return item; }
static void goto_next_file (void) { files = g_list_next (files); if (files != NULL) { create_item ((char *) files->data, title, cds_proxy, dest_container); } else { /* Exit if there are no more files to upload */ application_exit (); } }