当前位置: 首页>>代码示例>>C++>>正文


C++ Inventory::GetItem方法代码示例

本文整理汇总了C++中Inventory::GetItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::GetItem方法的具体用法?C++ Inventory::GetItem怎么用?C++ Inventory::GetItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Inventory的用法示例。


在下文中一共展示了Inventory::GetItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InventoryToStorage

void CharacterScene::InventoryToStorage( int slot )
{
	// Always succeeds in the inv->storage directory
	Inventory* inv = unit->GetInventory();
	Item item = inv->GetItem( slot );

	if ( item.IsSomething() ) {
		inventoryWidget->SetInfoText( item.GetItemDef() );	
		storage->AddItem( item );
		inv->RemoveItem( slot );
	}
}
开发者ID:chrisBGithub,项目名称:unflobtactical,代码行数:12,代码来源:characterscene.cpp

示例2: GetCharSelectInfo


//.........这里部分代码省略.........
				/* Otherwise, use the zone and coordinates given */
				else {
					pp.binds[4].zoneId = (uint32)atoi(row_d[0]);
					float x = atof(row_d[2]);
					float y = atof(row_d[3]);
					float z = atof(row_d[4]);
					if (x == 0 && y == 0 && z == 0){ GetSafePoints(pp.binds[4].zoneId, 0, &x, &y, &z); }
					pp.binds[4].x = x; pp.binds[4].y = y; pp.binds[4].z = z;
				}
			}
			pp.binds[0] = pp.binds[4];
			/* If no home bind set, set it */
			if (has_home == 0) {
				std::string query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, slot)"
					" VALUES (%u, %u, %u, %f, %f, %f, %f, %i)",
					character_id, pp.binds[4].zoneId, 0, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z, pp.binds[4].heading, 4);
				auto results_bset = QueryDatabase(query);
			}
			/* If no regular bind set, set it */
			if (has_bind == 0) {
				std::string query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, slot)"
					" VALUES (%u, %u, %u, %f, %f, %f, %f, %i)",
					character_id, pp.binds[0].zoneId, 0, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z, pp.binds[0].heading, 0);
				auto results_bset = QueryDatabase(query);
			}
		}
		/* Bind End */

		/* Load Character Material Data for Char Select */
		cquery = StringFormat("SELECT slot, red, green, blue, use_tint, color FROM `character_material` WHERE `id` = %u", character_id);
		auto results_b = database.QueryDatabase(cquery); uint8 slot = 0;
		for (auto row_b = results_b.begin(); row_b != results_b.end(); ++row_b) {
			slot = atoi(row_b[0]);
			pp.item_tint[slot].RGB.Red = atoi(row_b[1]);
			pp.item_tint[slot].RGB.Green = atoi(row_b[2]);
			pp.item_tint[slot].RGB.Blue = atoi(row_b[3]);
			pp.item_tint[slot].RGB.UseTint = atoi(row_b[4]);
		}
		/* Character Material Data End */

		/* Load Inventory */
		// If we ensure that the material data is updated appropriately, we can do away with inventory loads
		if (GetInventory(accountID, cse->Name, &inv)) {
			const Item_Struct* item = nullptr;
			const ItemInst* inst = nullptr;
			int16 invslot = 0;

			for (uint32 matslot = 0; matslot < _MaterialCount; matslot++) {
				invslot = Inventory::CalcSlotFromMaterial(matslot);
				if (invslot == INVALID_INDEX) { continue; }
				inst = inv.GetItem(invslot);
				if (inst == nullptr) { continue; }
				item = inst->GetItem();
				if (item == nullptr) { continue; }

				if (matslot > 6) {
					uint32 idfile = 0;
					// Weapon Models 
					if (inst->GetOrnamentationIDFile() != 0) {
						idfile = inst->GetOrnamentationIDFile();
						cse->Equip[matslot].Material = idfile;
					}
					else {
						if (strlen(item->IDFile) > 2) {
							idfile = atoi(&item->IDFile[2]);
							cse->Equip[matslot].Material = idfile;
						}
					}
					if (matslot == MaterialPrimary) {
						cse->PrimaryIDFile = idfile;
					}
					else {
						cse->SecondaryIDFile = idfile;
					}
				}
				else {
					uint32 color = 0;
					if (pp.item_tint[matslot].RGB.UseTint) {
						color = pp.item_tint[matslot].Color;
					}
					else {
						color = inst->GetColor();
					}

					// Armor Materials/Models
					cse->Equip[matslot].Material = item->Material;
					cse->Equip[matslot].EliteMaterial = item->EliteMaterial;
					cse->Equip[matslot].HeroForgeModel = inst->GetOrnamentHeroModel(matslot);
					cse->Equip[matslot].Color.Color = color;
				}
			}
		}
		else {
			printf("Error loading inventory for %s\n", cse->Name);
		}
		/* Load Inventory End */

		buff_ptr += sizeof(CharacterSelectEntry_Struct);
	}
}
开发者ID:clucksoft,项目名称:Server,代码行数:101,代码来源:worlddb.cpp

示例3: GetCharSelectInfo


//.........这里部分代码省略.........
							if(atoi(row2[1]) != 0) {		// if a bind_id is specified, make them start there
								pp->binds[4].zoneId = (uint32)atoi(row2[1]);
								GetSafePoints(pp->binds[4].zoneId, 0, &pp->binds[4].x, &pp->binds[4].y, &pp->binds[4].z);
							}
							else {	// otherwise, use the zone and coordinates given
								pp->binds[4].zoneId = (uint32)atoi(row2[0]);
								float x = atof(row2[2]);
								float y = atof(row2[3]);
								float z = atof(row2[4]);
								if(x == 0 && y == 0 && z == 0)
									GetSafePoints(pp->binds[4].zoneId, 0, &x, &y, &z);

								pp->binds[4].x = x;
								pp->binds[4].y = y;
								pp->binds[4].z = z;
							}
							altered = true;
						}

						mysql_free_result(result2);
					}

					// update the player profile
					if(altered) {
						uint32 char_id = GetCharacterID(cs->name[char_num]);
						RunQuery(query,MakeAnyLenString(&query,"SELECT extprofile FROM character_ WHERE id=%i",char_id), errbuf, &result2);
						safe_delete_array(query);
						if(result2) {
							row2 = mysql_fetch_row(result2);
							ExtendedProfile_Struct* ext = (ExtendedProfile_Struct*)row2[0];
							SetPlayerProfile(account_id,char_id,pp,inv,ext, 0, 0, 5);
						}
						mysql_free_result(result2);
					}
				}	// end of "set start zone" block


				// Character's equipped items
				// @merth: Haven't done bracer01/bracer02 yet.
				// Also: this needs a second look after items are a little more solid
				// NOTE: items don't have a color, players MAY have a tint, if the
				// use_tint part is set. otherwise use the regular color
				inv = new Inventory;
				if(GetInventory(account_id, cs->name[char_num], inv))
				{
					for (uint8 material = 0; material <= 8; material++)
					{
						uint32 color;
						ItemInst *item = inv->GetItem(Inventory::CalcSlotFromMaterial(material));
						if(item == 0)
							continue;

						cs->equip[char_num][material] = item->GetItem()->Material;

						if(pp->item_tint[material].rgb.use_tint)	// they have a tint (LoY dye)
							color = pp->item_tint[material].color;
						else	// no tint, use regular item color
							color = item->GetItem()->Color;

						cs->cs_colors[char_num][material].color = color;

						// the weapons are kept elsewhere
						if ((material==MaterialPrimary) || (material==MaterialSecondary))
						{
							if(strlen(item->GetItem()->IDFile) > 2) {
								uint32 idfile=atoi(&item->GetItem()->IDFile[2]);
								if (material==MaterialPrimary)
									cs->primary[char_num]=idfile;
								else
									cs->secondary[char_num]=idfile;
							}
						}
					}
				}
				else
				{
					printf("Error loading inventory for %s\n", cs->name[char_num]);
				}
				safe_delete(inv);
				if (++char_num > 10)
					break;
			}
			else
			{
				std::cout << "Got a bogus character (" << row[0] << ") Ignoring!!!" << std::endl;
				std::cout << "PP length ="<<lengths[1]<<" but PP should be "<<sizeof(PlayerProfile_Struct) << std::endl;
				//DeleteCharacter(row[0]);
			}
		}
		mysql_free_result(result);
	}
	else
	{
		std::cerr << "Error in GetCharSelectInfo query '" << query << "' " << errbuf << std::endl;
		safe_delete_array(query);
		return;
	}

	return;
}
开发者ID:Corysia,项目名称:Server,代码行数:101,代码来源:worlddb.cpp


注:本文中的Inventory::GetItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。