本文整理汇总了C++中idDict::FindKey方法的典型用法代码示例。如果您正苦于以下问题:C++ idDict::FindKey方法的具体用法?C++ idDict::FindKey怎么用?C++ idDict::FindKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idDict
的用法示例。
在下文中一共展示了idDict::FindKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromDict
void CShop::LoadFromDict(const idDict& dict)
{
// greebo: Assemble the difficulty prefix (e.g. "diff_0_")
idStr diffPrefix = "diff_" + idStr(gameLocal.m_DifficultyManager.GetDifficultyLevel()) + "_";
if (dict.GetBool("shop_skip","0") || dict.GetBool(diffPrefix + "shop_skip","0"))
{
// if skip flag is set, skip the shop
_skipShop = true;
// No need to parse any further, the shop will be skipped anyway
return;
}
// Check for loot carry-over rules
LoadLootRules(dict);
// Check for an "all-difficulty" gold value
if (dict.FindKey("shop_gold_start") != NULL)
{
SetGold(dict.GetInt("shop_gold_start"));
}
// Try to retrieve the starting gold for the given difficulty level
if (dict.FindKey(diffPrefix + "shop_gold_start") != NULL)
{
SetGold(dict.GetInt(diffPrefix + "shop_gold_start"));
}
// items for sale
AddItems(dict, "shopItem", _itemsForSale);
// starting items (items that player already has
AddItems(dict, "startingItem", _startingItems);
}
示例2: AddItems
int CShop::AddItems(const idDict& mapDict, const idStr& itemKey, ShopItemList& list)
{
int diffLevel = gameLocal.m_DifficultyManager.GetDifficultyLevel();
int itemsAdded = 0;
// grayman (#2376)
// Convert itemKey to lowercase. mapDict methods ignore case, but
// StripLeadingOnce() doesn't. This change allows recognition of shop items defined as
// "startingItem_*", "startingitem_*", "shopItem_*", and "shopitem_*.
idStr itemKeyLower = itemKey;
itemKeyLower.ToLower();
bool isShopList = (itemKeyLower.Find("shop") >= 0); // for lockpick checking
for (const idKeyValue* kv = mapDict.MatchPrefix(itemKeyLower); kv != NULL; kv = mapDict.MatchPrefix(itemKeyLower, kv))
{
// Inspect the matching prefix, check whether the difficulty level applies
idStr postfix = kv->GetKey();
postfix.ToLower(); // grayman (#2376) convert postfix to lowercase so StripLeadingOnce()
// matches lowercase against lowercase
// Cut off the prefix including the following underscore _
postfix.StripLeadingOnce(itemKeyLower + "_");
int pos = postfix.Find("_item");
if (pos == -1 || pos != postfix.Length() - 5)
{
continue; // no suitable "_item" found
}
// This is the number portion, like "1_2" or merely "2"
idStr indexStr = postfix.Mid(0, pos);
// Check if we have still an underscore in the index string, this implies
// that there is a difficulty number included
int underScorePos = indexStr.Find('_');
// Extract the item index
int itemIndex = (underScorePos != -1) ? atoi(indexStr.Mid(0, underScorePos)) : atoi(indexStr);
if (underScorePos != -1)
{
// Check out the second number, this is the difficulty level
idStr diffStr = indexStr.Mid(underScorePos + 1, indexStr.Length() - underScorePos);
// Check if the difficulty level matches
if (atoi(diffStr) != diffLevel)
{
// Ignore this spawnarg
continue;
}
}
idStr itemName = kv->GetValue();
if (itemName.IsEmpty())
{
continue; // Empty names are not considered
}
// greebo: Assemble the item prefix (e.g. "shopItem_1_") to look up the rest of the spawnargs
idStr itemPrefix = itemKey + "_" + idStr(itemIndex);
idStr diffLevelStr = "_" + idStr(diffLevel);
// look for quantity, but let a difficulty-specific setting override the general one
int quantity = mapDict.GetInt(itemPrefix + "_qty");
if (mapDict.FindKey(itemPrefix + diffLevelStr + "_qty") != NULL)
{
quantity = mapDict.GetInt(itemPrefix + diffLevelStr + "_qty");
}
// put the item in the shop
if (quantity > 0)
{
// grayman (#2376) - Special handling for weapon quantities.
int index = itemName.Find("weapon_");
if (index >= 0)
{
// A shop entity should use atdm:weapon_*, but there's at least one
// that uses weapon_*, so convert the latter to the former.
idStr weaponName;
if (index == 0)
{
weaponName = "atdm:" + itemName;
}
else
{
weaponName = itemName;
}
// Weapon quantities have limits. (Arrows in particular.)
int max_ammo = GetMaxAmmo(weaponName);
quantity = (quantity > max_ammo) ? max_ammo : quantity;
//.........这里部分代码省略.........