本文整理汇总了C++中ItemFactory::GetItem方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemFactory::GetItem方法的具体用法?C++ ItemFactory::GetItem怎么用?C++ ItemFactory::GetItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemFactory
的用法示例。
在下文中一共展示了ItemFactory::GetItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadContents
bool Inventory::LoadContents(ItemFactory &factory)
{
// check if the contents has already been loaded...
if( ContentsLoaded() )
{
return true;
}
sLog.Debug("Inventory", "Recursively loading contents of inventory %u", inventoryID() );
//load the list of items we need
std::vector<uint32> items;
if( !GetItems( factory, items ) )
{
sLog.Error("Inventory", "Failed to get items of %u", inventoryID() );
return false;
}
//Now get each one from the factory (possibly recursing)
ItemData into;
uint32 characterID;
uint32 corporationID;
uint32 locationID;
std::vector<uint32>::iterator cur, end;
cur = items.begin();
end = items.end();
for(; cur != end; cur++)
{
// Each "cur" item should be checked to see if they are "owned" by the character connected to this client,
// and if not, then do not "get" the entire contents of this for() loop for that item, except in the case that
// this item is located in space or belongs to this character's corporation:
factory.db().GetItem( *cur, into );
if( factory.GetUsingClient() != NULL )
{
characterID = factory.GetUsingClient()->GetCharacterID();
corporationID = factory.GetUsingClient()->GetCorporationID();
locationID = factory.GetUsingClient()->GetLocationID();
}
else
sLog.Error( "Inventory::LoadContents()", "Failed to resolve pointer to Client object currently using the ItemFactory." );
if( (into.ownerID == characterID) || (characterID == 0) || (into.ownerID == corporationID) || (into.locationID == locationID) )
{
// Continue to GetItem() if the client calling this is owned by the character that owns this item
// --OR--
// The characterID == 0, which means this is attempting to load the character of this client for the first time.
InventoryItemRef i = factory.GetItem( *cur );
if( !i )
{
sLog.Error("Inventory::LoadContents()", "Failed to load item %u contained in %u. Skipping.", *cur, inventoryID() );
continue;
}
AddItem( i );
}
}
mContentsLoaded = true;
return true;
}