本文整理汇总了C++中CGameItemPtr::computeRequirementFromForm方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameItemPtr::computeRequirementFromForm方法的具体用法?C++ CGameItemPtr::computeRequirementFromForm怎么用?C++ CGameItemPtr::computeRequirementFromForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameItemPtr
的用法示例。
在下文中一共展示了CGameItemPtr::computeRequirementFromForm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadNamedItemsFromFile
//-----------------------------------------------------------------------------
void CNamedItems::loadNamedItemsFromFile(const std::string & fileName)
{
CHashMap<std::string, CGameItemPtr>::iterator it;
for (it = _NamedItems.begin(); it != _NamedItems.end(); ++it)
{
GameItemManager.destroyItem((*it).second);
}
_NamedItems.clear();
string path;
try
{
path = CPath::lookup(fileName);
}
catch (Exception &)
{
nlwarning("<NAMED_ITEMS> file '%s' was not found", fileName.c_str());
return;
}
static CPersistentDataRecord pdr;
pdr.clear();
pdr.readFromTxtFile(path.c_str());
CInventoryPtr inv = loadFromPdr(pdr);
if (inv == NULL)
{
nlwarning("<NAMED_ITEMS> error while loading items from the PDR");
return;
}
const uint size = inv->getSlotCount();
nlinfo("loading '%u' named items", size);
for (uint i = 0; inv->getFreeSlotCount() != inv->getSlotCount() && i < size; ++i)
{
if (inv->getItem(i) == NULL)
continue;
CGameItemPtr item = inv->removeItem(i);
if (item != NULL)
{
if (item->getSheetId() == CSheetId::Unknown)
{
nlwarning("<NAMED_ITEMS> item '%u' has invalid sheet id", i);
GameItemManager.destroyItem(item);
continue;
}
if (item->getPhraseId().empty())
{
nlwarning("<NAMED_ITEMS> item '%u' has no name", i);
GameItemManager.destroyItem(item);
continue;
}
if (_NamedItems.find(item->getPhraseId()) != _NamedItems.end())
{
nlwarning("<NAMED_ITEMS> item '%u', name '%s' exists more than once", i, item->getPhraseId().c_str());
GameItemManager.destroyItem(item);
continue;
}
// Yoyo: force this item to work with the new form requirement system.
// BUT: do it only if _UseNewSystemRequirement==false (if LDs put true, we suppose that the named item has special req value)
if(item->getUseNewSystemRequirement()==false)
item->computeRequirementFromForm();
nldebug("<NAMED_ITEMS> creating named item '%s'",item->getPhraseId().c_str());
_NamedItems.insert(make_pair(item->getPhraseId(), item));
}
}
}