本文整理汇总了C++中create_item函数的典型用法代码示例。如果您正苦于以下问题:C++ create_item函数的具体用法?C++ create_item怎么用?C++ create_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_item函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: create_item
/**
* 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;
}
开发者ID:Fomka,项目名称:ufo2000,代码行数:39,代码来源:place.cpp
示例2: list_d_unique_insert
/**
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;
}
开发者ID:JohnPJenkins,项目名称:swift-t,代码行数:61,代码来源:list_d.c
示例3: guard
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);
}
}
}
开发者ID:morsya,项目名称:omim,代码行数:51,代码来源:search_panel.cpp
示例4: pick_berry
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;
}
开发者ID:AstoniaDev,项目名称:Astonia-3.5,代码行数:51,代码来源:warrmines.c
示例5: warpkeyspawn_driver
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.");
}
开发者ID:jwaibel,项目名称:v3.0-server,代码行数:25,代码来源:warped.c
示例6: player_class_ref
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;
}
开发者ID:smarmy,项目名称:DPOC,代码行数:32,代码来源:PlayerCharacter.cpp
示例7: create_item
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;
}
开发者ID:93i,项目名称:godot,代码行数:34,代码来源:mesh_library.cpp
示例8: main
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;
}
开发者ID:Orwel,项目名称:forester,代码行数:25,代码来源:test-0010.c
示例9: create_item
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;
}
开发者ID:MattUV,项目名称:godot,代码行数:28,代码来源:mesh_library.cpp
示例10: additem_to_top
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);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:27,代码来源:aliaslist.c
示例11: add_handler
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;
}
开发者ID:jam2in,项目名称:arcus-c-client,代码行数:33,代码来源:interface_v1.c
示例12: create_item
void
additional_parts_dialog::repopulate() {
m_lv_files->DeleteAllItems();
for (size_t idx = 0; m_files.size() > idx; ++idx)
create_item(idx);
}
开发者ID:CheesyWiggles,项目名称:mkvtoolnix,代码行数:7,代码来源:additional_parts_dlg.cpp
示例13: additem_to_bottom
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);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:33,代码来源:aliaslist.c
示例14: player_realdeath
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();
}
开发者ID:miton,项目名称:taisei,代码行数:17,代码来源:player.c
示例15: parse_defs_m4_line
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;
}
开发者ID:GeorgeShaw,项目名称:opensips,代码行数:58,代码来源:parser.c
示例16: create_local_item_cb
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);
}
开发者ID:ebbywiselyn,项目名称:evolution,代码行数:9,代码来源:mail-component.c
示例17: create_item
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));
}
}
开发者ID:luissifu,项目名称:tankcoder,代码行数:9,代码来源:Menu.cpp
示例18: dll_push_front
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;
}
开发者ID:jpokorny,项目名称:predator,代码行数:10,代码来源:test-0174.c
示例19: dll_push_back
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;
}
开发者ID:jpokorny,项目名称:predator,代码行数:10,代码来源:test-0174.c
示例20: create_all
void create_all(){
create_warehouse();
create_district();
create_history();
create_new_order();
create_order();
// create_order_line();
create_item();
create_stock();
create_customer();
}
开发者ID:kmikmy,项目名称:p-wal,代码行数:11,代码来源:create_tables.cpp
注:本文中的create_item函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论