本文整理汇总了C++中XmlNodeRef::isTag方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlNodeRef::isTag方法的具体用法?C++ XmlNodeRef::isTag怎么用?C++ XmlNodeRef::isTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNodeRef
的用法示例。
在下文中一共展示了XmlNodeRef::isTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadAntiCheatVars
void CAntiCheatManager::LoadAntiCheatVars(XmlNodeRef child)
{
int numVars = child->getChildCount();
for (int i=0; i<numVars; ++i)
{
XmlNodeRef varsChild = child->getChild(i);
if (varsChild->isTag("Var"))
{
const char* sVarName = varsChild->getAttr("name");
TAntiCheatVarIdx antiCheatVarIdx = FindAntiCheatVarIdx_Float(sVarName);
if (antiCheatVarIdx != eAV_Invalid_Float)
{
varsChild->getAttr("value", m_cheatVarsFloat[antiCheatVarIdx]);
}
else
{
antiCheatVarIdx = FindAntiCheatVarIdx_Int(sVarName);
if (antiCheatVarIdx != eAV_Invalid_Int)
{
varsChild->getAttr("value", m_cheatVarsInt[antiCheatVarIdx]);
}
else
{
CryLog("Unrecognised anti cheat var '%s'", sVarName);
}
}
}
else
{
CryLog("Unrecognised child node '%s'", varsChild->getTag());
}
}
}
示例2: LoadEquipmentPacks
// Loads equipment packs from rootNode
void CEquipmentManager::LoadEquipmentPacks(const XmlNodeRef& rootNode)
{
MEMSTAT_CONTEXT(EMemStatContextTypes::MSC_Other, 0, "Equipment Packs");
if (rootNode->isTag("EquipPacks") == false)
return;
for (int i=0; i<rootNode->getChildCount(); ++i)
{
XmlNodeRef packNode = rootNode->getChild(i);
LoadEquipmentPack(packNode, true);
}
}
示例3: InitXML
//---------------------------------------
void CMiscAnnouncer::InitXML(XmlNodeRef root)
{
IEntityClassRegistry *pEntityClassRegistry = gEnv->pEntitySystem->GetClassRegistry();
XmlNodeRef onWeaponFiringRoot = root->findChild("OnWeaponFiring");
CryLog("CMiscAnnouncer::InitXML()");
if(onWeaponFiringRoot)
{
const int numChildren = onWeaponFiringRoot->getChildCount();
CryLog("CMiscAnnouncer::InitXML() found OnWeaponFiringRoot with %d children", numChildren);
for(int i=0; i<numChildren; ++i)
{
XmlNodeRef child = onWeaponFiringRoot->getChild(i);
if(child->isTag("OnWeaponFired"))
{
const char *pWeaponClassName = child->getAttr("weaponClass");
CRY_ASSERT(pWeaponClassName && pWeaponClassName[0] != 0);
CryLog("CMiscAnnouncer::InitXML() OnWeaponFired tag - pWeaponClassName=%s", pWeaponClassName ? pWeaponClassName : "NULL");
if(IEntityClass* pWeaponEntityClass = pEntityClassRegistry->FindClass(pWeaponClassName))
{
const char *pAnnouncement = child->getAttr("announcement");
CRY_ASSERT(pAnnouncement && pAnnouncement[0] != 0);
EAnnouncementID announcementID = CAnnouncer::NameToID(pAnnouncement);
CryLog("CMiscAnnouncer::InitXML() found weapon entity class for pWeaponClassName=%s; found pAnnouncement=%s announcementID=%x", pWeaponClassName, pAnnouncement ? pAnnouncement : "NULL", announcementID);
SOnWeaponFired newWeaponFired(pWeaponEntityClass, pAnnouncement, announcementID);
m_weaponFiredMap.insert(TWeaponFiredMap::value_type(pWeaponEntityClass, newWeaponFired));
}
else
{
CryLog("CMiscAnnouncer::InitXML() failed to find entityClass for pWeaponClassName=%s", pWeaponClassName);
CRY_ASSERT_MESSAGE(0, string().Format("CMiscAnnouncer::InitXML() failed to find entityClass for pWeaponClassName=%s", pWeaponClassName));
}
}
else
{
CryLog("CMiscAnnouncer::InitXML() unhandled childtag of %s found", child->getTag());
}
}
}
}
示例4: LoadClassDescription
void CEntityClassRegistry::LoadClassDescription( XmlNodeRef &root,bool bOnlyNewClasses )
{
assert( root != (IXmlNode*)NULL );
if (root->isTag("Entity"))
{
const char *sName = root->getAttr("Name");
if (*sName == 0)
return; // Empty name.
const char *sScript = root->getAttr("Script");
IEntityClass *pClass = FindClass( sName );
if (!pClass)
{
// New class.
SEntityClassDesc cd;
cd.flags = 0;
cd.sName = sName;
cd.sScriptFile = sScript;
bool bInvisible = false;
if (root->getAttr("Invisible",bInvisible))
{
if (bInvisible)
cd.flags |= ECLF_INVISIBLE;
}
bool bBBoxSelection = false;
if (root->getAttr("BBoxSelection",bBBoxSelection))
{
if (bBBoxSelection)
cd.flags |= ECLF_BBOX_SELECTION;
}
RegisterStdClass( cd );
}
else
{
// This class already registered.
if (!bOnlyNewClasses)
{
EntityWarning( "[CEntityClassRegistry] LoadClassDescription failed, Entity Class name %s already registered",sName );
}
}
}
}
示例5: FetchMetaData
bool CCommonSaveGameHelper::FetchMetaData(XmlNodeRef& root, CPlayerProfileManager::SSaveGameMetaData& metaData)
{
// TODO: use CXmlLoadGame for this
XmlNodeRef metaDataNode = root;
if (metaDataNode->isTag("Metadata") == false)
metaDataNode = root->findChild("Metadata");
if (metaDataNode == 0)
return false;
bool ok = true;
ok &= GetAttr(metaDataNode, "level", metaData.levelName);
ok &= GetAttr(metaDataNode, "gameRules", metaData.gameRules);
ok &= GetAttr(metaDataNode, "version", metaData.fileVersion);
ok &= GetAttr(metaDataNode, "build", metaData.buildVersion);
ok &= GetTimeAttr(metaDataNode, "saveTime", metaData.saveTime);
metaData.loadTime = metaData.saveTime;
metaData.xmlMetaDataNode = metaDataNode;
return ok;
}
示例6: LoadScript
bool CDialogLoader::LoadScript(const string& filename, TDialogScriptMap& outScriptMap)
{
// parse MS Excel spreadsheet
XmlNodeRef rootNode = GetISystem()->LoadXmlFromFile(filename);
if (!rootNode)
{
GameWarning("[DIALOG] CDialogLoader::LoadScripts: Cannot find file '%s'", filename.c_str());
return false;
}
// iterate over all children and load all worksheets
int nChilds = rootNode->getChildCount();
if (nChilds == 0)
{
GameWarning("[DIALOG] CDialogLoader::LoadScripts: Cannot find any 'Worksheet's in file '%s'", filename.c_str());
return false;
}
int numScripts = 0;
string baseName = PathUtil::GetFileName(filename);
for (int i=0; i<nChilds; ++i)
{
XmlNodeRef childNode = rootNode->getChild(i);
if (childNode && childNode->isTag("Worksheet"))
{
const char* wsName = childNode->getAttr("ss:Name");
XmlNodeRef tableNode = childNode->findChild("Table");
if (!tableNode)
{
GameWarning("[DIALOG] CDialogLoader::LoadScripts: Worksheet '%s' in file '%s' has no Table", wsName ? wsName : "<noname>", filename.c_str());
}
else
{
const string& groupName = baseName; // maybe we add the Worksheets name later on!
numScripts = LoadFromTable(tableNode, groupName, outScriptMap);
break; // only load first worksheet
}
}
}
return numScripts > 0;
}
示例7: FillMapping
void FillMapping(XmlNodeRef row, unsigned char* pIndexToAttrMap)
{
int nCellIndex = 0;
int nNewIndex = 0;
for (int cell=0; cell<row->getChildCount(); ++cell)
{
if (cell >= MAX_CELL_COUNT)
continue;
XmlNodeRef nodeCell = row->getChild(cell);
if (!nodeCell->isTag("Cell"))
continue;
if (nodeCell->getAttr("ss:Index",nNewIndex))
{
// Check if some cells are skipped.
nCellIndex = nNewIndex-1;
}
XmlNodeRef nodeCellData = nodeCell->findChild("Data");
if (!nodeCellData)
{
++nCellIndex;
continue;
}
const char *sCellContent = nodeCellData->getContent();
for (int i = 0; i < sizeof(sColumnNames)/sizeof(*sColumnNames); ++i)
{
// this is a begins-with-check!
if (CryStringUtils::stristr(sCellContent, sColumnNames[i]) == sCellContent)
{
pIndexToAttrMap[nCellIndex] = i;
break;
}
}
++nCellIndex;
}
}
示例8:
bool CDialogLoaderMK2::ProcessScript(CDialogScript* pScript, const XmlNodeRef& node)
{
CDialogScript::SScriptLine scriptLine;
const char* scriptID = pScript->GetID();
string desc = node->getAttr("Description");
pScript->SetDescription(desc);
for (int i=0; i<node->getChildCount(); ++i)
{
XmlNodeRef lineNode = node->getChild(i);
if (lineNode && lineNode->isTag("Line"))
{
ResetLine(scriptLine);
if (ReadLine (lineNode, scriptLine, scriptID, i) == true)
{
pScript->AddLine(scriptLine);
}
}
}
return true;
}
示例9: CompareNodes
bool CEntityPoolSignature::CompareNodes(const XmlNodeRef &a, const XmlNodeRef &b, bool bRecursive)
{
FUNCTION_PROFILER(GetISystem(), PROFILE_ENTITY);
assert(bool(a));
assert(bool(b));
bool bResult = (a && b && a->isTag(b->getTag()));
// Check value
bResult &= (bResult && 0 == strcmp(a->getContent(), b->getContent()));
// Check attributes
bResult &= (bResult && CompareNodeAttributes(a, b));
// Check children if recursive
if (bResult && bRecursive)
{
const int childCount_a = a->getChildCount();
const int childCount_b = b->getChildCount();
bResult &= (childCount_a == childCount_b);
if (bResult)
{
for (int child = 0; bResult && child < childCount_a; ++child)
{
XmlNodeRef child_a = a->getChild(child);
XmlNodeRef child_b = b->getChild(child);
if (child_a && child_b)
{
bResult &= CompareNodes(child_a, child_b, true);
}
}
}
}
return bResult;
}
示例10: GetISystem
bool CDialogLoaderMK2::LoadScript(const string& stripPath, const string& filename, TDialogScriptMap& outScriptMap)
{
XmlNodeRef rootNode = GetISystem()->LoadXmlFromFile(filename);
if (!rootNode)
{
GameWarning("[DIALOG] CDialogLoaderMK2::LoadScripts: Cannot find/load file '%s'", filename.c_str());
return false;
}
if (rootNode->isTag("DialogScript") == false)
{
GameWarning("[DIALOG] CDialogLoaderMK2::LoadScripts: File '%s' not a dialog script.", filename.c_str());
return false;
}
string scriptName = PathUtil::ToUnixPath(filename);
// now remove prefix
if (CryStringUtils::stristr(scriptName.c_str(), stripPath.c_str()) == scriptName.c_str())
scriptName = scriptName.Mid(stripPath.length());
PathUtil::RemoveExtension(scriptName);
scriptName.replace('/', '.');
// Make nice uppercase name, if storedId and filename match case-insensitive
const char* storedId = rootNode->getAttr("Name");
if (storedId!=0 && stricmp(storedId, scriptName.c_str()) == 0)
{
scriptName.assign(storedId);
}
CDialogScript* pScript = new CDialogScript(scriptName);
bool bOK = ProcessScript(pScript, rootNode);
if (bOK)
{
// try to complete the script
if (pScript->Complete() == true)
{
// add it to the map
std::pair<TDialogScriptMap::iterator, bool> inserted =
outScriptMap.insert(TDialogScriptMap::value_type(pScript->GetID(), pScript));
if (inserted.second == false)
{
bOK = false;
GameWarning("[DIALOG] CDialogLoaderMK2::ProcessScript '%s': Script already defined. Discarded", scriptName.c_str());
}
}
// completion not successful -> discard
else
{
bOK = false;
GameWarning("[DIALOG] CDialogLoaderMK2::ProcessScript '%s': Cannot complete Script. Discarded.", scriptName.c_str());
}
}
// discard pScript
if (bOK == false)
{
delete pScript;
}
return bOK;
}
示例11: LoadFromFile
bool CommunicationVoiceLibrary::LoadFromFile(const char* fileName)
{
MEMSTAT_CONTEXT(EMemStatContextTypes::MSC_Other, 0, "Communication Voice Library" );
MEMSTAT_CONTEXT_FMT(EMemStatContextTypes::MSC_Other, 0, "Voice Lib: %s",fileName );
XmlNodeRef root = GetISystem()->LoadXmlFromFile(fileName);
if (!root)
return false;
XmlNodeRef nodeWorksheet = root->findChild("Worksheet");
if (!nodeWorksheet)
return false;
XmlNodeRef nodeTable = nodeWorksheet->findChild("Table");
if (!nodeTable)
return false;
stack_string libName(PathUtil::GetFileName(fileName));
VoiceLibraryID libraryID = GetVoiceLibraryID(libName.c_str());
std::pair<VoiceLibraries::iterator, bool> iresult = m_libraries.insert(
VoiceLibraries::value_type(libraryID, VoiceLibrary()));
if (!iresult.second)
{
if (iresult.first->second.name == libName.c_str())
{
AIWarningID("<AICommunicationVoiceLibrary::LoadFromFile> ",
"Duplicate voice library '%s'!", libName.c_str());
return false;
}
else
{
AIWarningID("<AICommunicationVoiceLibrary::LoadFromFile> ",
"Hash collision for voice library name '%s' and '%s'!", libName.c_str(), iresult.first->second.name.c_str());
return false;
}
}
VoiceLibrary& library = iresult.first->second;
library.name = string(libName);
VoiceGroup* voiceGroup = 0;
string signalName;
string lastSignalName;
string voiceName;
for (int rowCntr = 0, childN = 0; childN < nodeTable->getChildCount(); ++childN)
{
XmlNodeRef nodeRow = nodeTable->getChild(childN);
if (!nodeRow->isTag("Row"))
continue;
++rowCntr;
if (rowCntr == 1) // skip language
continue;
if (rowCntr == 2) // path
{
int cellN = 0;
for (int childrenCntr = 0; childrenCntr < nodeRow->getChildCount(); ++childrenCntr)
{
XmlNodeRef nodeCell = nodeRow->getChild(childrenCntr);
if (!nodeCell->isTag("Cell"))
continue;
++cellN;
if (cellN == 2)
{
XmlNodeRef nodeCellData = nodeCell->findChild("Data");
if (!nodeCellData)
break;
library.base = PathUtil::GetLocalizationFolder() + nodeCellData->getContent();
if (!library.base.empty())
{
library.base.replace("\\", "/");
if (library.base[library.base.length()-1] != '/')
library.base.append("/");
}
break;
}
}
continue;
}
if (rowCntr == 3) // headers
continue;
signalName.clear();
voiceName.clear();
for (int childrenCntr = 0, cellIndex = 1; childrenCntr < nodeRow->getChildCount(); ++childrenCntr, ++cellIndex)
{
XmlNodeRef nodeCell = nodeRow->getChild(childrenCntr);
if (!nodeCell->isTag("Cell"))
//.........这里部分代码省略.........
示例12: LoadFromTable
int CDialogLoader::LoadFromTable(XmlNodeRef tableNode, const string& groupName, TDialogScriptMap& outScriptMap)
{
unsigned char nCellIndexToType[MAX_CELL_COUNT];
memset(nCellIndexToType, ATTR_SKIP, sizeof(nCellIndexToType) );
IMScript theScript;
int nNumGoodScripts = 0;
int nRowIndex = 0;
int nChilds = tableNode->getChildCount();
for (int i=0; i<nChilds; ++i)
{
XmlNodeRef rowNode = tableNode->getChild(i);
if (!rowNode || !rowNode->isTag("Row"))
continue;
++nRowIndex;
// skip first row as it should only contain column description
if (nRowIndex == 1)
{
FillMapping(rowNode, nCellIndexToType);
continue;
}
IMScriptLine scriptLine;
bool bLineValid = false;
int nColCount = rowNode->getChildCount();
int nCellIndex = 0;
for (int j=0; j<nColCount; ++j)
{
XmlNodeRef cellNode = rowNode->getChild(j);
if (!cellNode || !cellNode->isTag("Cell"))
continue;
int tmpIndex = 0;
if (cellNode->getAttr("ss:Index", tmpIndex))
{
nCellIndex = tmpIndex-1;
}
if (nCellIndex < 0 || nCellIndex >= MAX_CELL_COUNT)
break;
XmlNodeRef cellDataNode = cellNode->findChild("Data");
if (!cellDataNode)
{
++nCellIndex;
continue;
}
unsigned char nCellType = nCellIndexToType[nCellIndex];
const char* content = cellDataNode->getContent();
// nRowIndex and nCellIndex should be correct now [1-based, not 0-based!]
switch (nCellType)
{
case ATTR_SKIP:
break;
case ATTR_DIALOG:
if (theScript.IsValid())
{
const bool ok = ProcessScript(theScript, groupName, outScriptMap);
if (ok)
++nNumGoodScripts;
theScript.Reset();
}
theScript.name = content;
break;
case ATTR_ACTOR:
scriptLine.actor = content;
bLineValid = true;
break;
case ATTR_AUDIO:
if (bLineValid)
{
if(content == 0)
scriptLine.audioID = INVALID_AUDIO_CONTROL_ID;
else
gEnv->pAudioSystem->GetAudioTriggerID(content, scriptLine.audioID);
}
break;
case ATTR_ANIM:
if (bLineValid)
scriptLine.anim = content;
break;
case ATTR_FACIAL:
if (bLineValid)
{
size_t n = strcspn(content, ":; ");
if (n == strlen(content))
{
scriptLine.facial = content;
scriptLine.facialWeight = 0.5f;
scriptLine.facialFadeTime = 0.5f;
}
else
{
//.........这里部分代码省略.........
示例13: ParseAntiCheatConfig
void CAntiCheatManager::ParseAntiCheatConfig(XmlNodeRef xmlData)
{
ResetAntiCheatVars();
// Reset the previous configuration so that we can call this function multiple times
for (int i=0; i<eCT_Num; ++i)
{
m_cheats[i].actions.clear();
}
m_globalActions.clear();
m_assetGroupWeights.clear();
m_assetGroupWeights.resize(eAG_Num);
m_totalAssetWeighting = 0;
m_fileProtectConfig = NULL;
int numChildren = xmlData->getChildCount();
for (int i=0; i<numChildren; ++i)
{
XmlNodeRef child = xmlData->getChild(i);
if (child->isTag("Cheat"))
{
int numActions = child->getChildCount();
const char* sTypeName = child->getAttr("type");
TCheatType cheatType = FindCheatType(sTypeName);
if (cheatType != eCT_Invalid)
{
SCheatType &cheat = m_cheats[cheatType];
cheat.actions.reserve(numActions);
for (int j=0; j<numActions; ++j)
{
XmlNodeRef actionChild = child->getChild(j);
if (actionChild->isTag("Action"))
{
bool addAction = true;
int numConditions = actionChild->getChildCount();
SCheatAction cheatAction;
const char* sActionName = actionChild->getAttr("value");
cheatAction.action = FindCheatAction(sActionName);
if (cheatAction.action != eCA_Invalid)
{
int nConfidence = kDefaultConfidence;
actionChild->getAttr("confidence", nConfidence);
cheatAction.confidence = nConfidence;
if (cheatAction.action == eCA_Infraction)
{
actionChild->getAttr("severity", cheatAction.severity);
if (cheatAction.severity <= 0.f)
{
CryLog("Invalid severity %f", cheatAction.severity);
cheatAction.severity = 0.f;
}
}
else if (cheatAction.action == eCA_Ban)
{
actionChild->getAttr("timeout", cheatAction.banTimeout);
}
cheatAction.conditions.reserve(numConditions);
for (int k=0; k<numConditions; ++k)
{
XmlNodeRef conditionChild = actionChild->getChild(k);
if (conditionChild->isTag("Condition"))
{
SCheatCondition cheatCondition;
const char* sOperatorName = conditionChild->getAttr("operator");
cheatCondition.op = FindCheatOperator(sOperatorName);
if (cheatCondition.op != eCO_Invalid)
{
conditionChild->getAttr("value", cheatCondition.value);
conditionChild->getAttr("param", cheatCondition.paramNum);
cheatAction.conditions.push_back(cheatCondition);
}
else
{
CryLog("Unrecognised operator %s", sOperatorName);
}
}
else if (conditionChild->isTag("DediVersion"))
{
#if defined(DEDICATED_SERVER)
const char* sOperatorName = conditionChild->getAttr("operator");
ECheatOperator op = FindCheatOperator(sOperatorName);
if (op != eCO_Invalid)
{
int value;
if (conditionChild->getAttr("value", value))
{
if (!MeetsCondition(op, DEDI_VERSION, value))
{
// Ignore this action if it doesn't meet the gamespy dedi version check
addAction = false;
break;
}
}
}
else
{
CryLog("Unrecognised operator %s", sOperatorName);
}
//.........这里部分代码省略.........
示例14: LoadEquipmentPack
// Load an equipment pack from an XML node
bool CEquipmentManager::LoadEquipmentPack(const XmlNodeRef& rootNode, bool bOverrideExisting)
{
if (rootNode->isTag("EquipPack") == false)
return false;
const char* packName = rootNode->getAttr("name");
const char* primaryName = rootNode->getAttr("primary");
if (!packName || packName[0] == 0)
return false;
// re-use existing pack
SEquipmentPack* pPack = GetPack(packName);
if (pPack == 0)
{
pPack = new SEquipmentPack;
m_equipmentPacks.push_back(pPack);
}
else if (bOverrideExisting == false)
return false;
pPack->Init(packName);
for (int iChild=0; iChild<rootNode->getChildCount(); ++iChild)
{
const XmlNodeRef childNode = rootNode->getChild(iChild);
if (childNode == 0)
continue;
if (childNode->isTag("Items"))
{
pPack->PrepareForItems(childNode->getChildCount());
for (int i=0; i<childNode->getChildCount(); ++i)
{
XmlNodeRef itemNode = childNode->getChild(i);
const char* itemName = itemNode->getTag();
const char* itemType = itemNode->getAttr("type");
const char* itemSetup = itemNode->getAttr("setup");
pPack->AddItem(itemName, itemType, itemSetup);
}
}
else if (childNode->isTag("Ammo")) // legacy
{
const char *ammoName = "";
const char *ammoCount = "";
int nAttr = childNode->getNumAttributes();
for (int j=0; j<nAttr; ++j)
{
if (childNode->getAttributeByIndex(j, &ammoName, &ammoCount))
{
int nAmmoCount = atoi(ammoCount);
pPack->m_ammoCount[ammoName] = nAmmoCount;
}
}
}
else if (childNode->isTag("Ammos"))
{
for (int i=0; i<childNode->getChildCount(); ++i)
{
XmlNodeRef ammoNode = childNode->getChild(i);
if (ammoNode->isTag("Ammo") == false)
continue;
const char* ammoName = ammoNode->getAttr("name");
if (ammoName == 0 || ammoName[0] == '\0')
continue;
int nAmmoCount = 0;
ammoNode->getAttr("amount", nAmmoCount);
pPack->m_ammoCount[ammoName] = nAmmoCount;
}
}
}
// assign primary.
if (pPack->HasItem(primaryName))
pPack->m_primaryItem = primaryName;
else
pPack->m_primaryItem = "";
return true;
}
示例15: ApplyCVarPatch
void CDataPatchDownloader::ApplyCVarPatch()
{
// Open the file regardless of whether or not we're going to use it - makes sure the file is in the MP mode
// switch pak
FILE * f = gEnv->pCryPak->FOpen( "Scripts/DataPatcher/patchablecvars.txt", "rt" );
if (!f)
{
// Failed to open whitelist - don't patch any cvars
return;
}
if (m_patchingEnabled)
{
AssertPatchDownloaded();
if (m_patchXML)
{
std::vector<string> cvarsWhiteList;
cvarsWhiteList.reserve(64);
// Parse the cvars white list - code taken from CVarListProcessor.cpp
const int BUFSZ = 4096;
char buf[BUFSZ];
size_t nRead;
string cvar;
bool comment = false;
do
{
cvar.resize(0);
buf[0]='\0';
nRead = gEnv->pCryPak->FRead( buf, BUFSZ, f );
for (size_t i=0; i<nRead; i++)
{
char c = buf[i];
if (comment)
{
if (c == '\r' || c == '\n')
comment = false;
}
else
{
if (c == '_' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || (c == '.'))
{
cvar += c;
}
else if (c == '\t' || c == '\r' || c == '\n' || c == ' ')
{
if (ICVar * pV = gEnv->pConsole->GetCVar(cvar.c_str()))
{
cvarsWhiteList.push_back(cvar);
}
cvar.resize(0);
}
else if (c == '#')
{
comment = true;
}
}
}
}
while (nRead != 0);
// Now apply the patch
const int numAllowedCVars = cvarsWhiteList.size();
const int numChildren = m_patchXML->getChildCount();
for (int i = 0; i < numChildren; i ++)
{
XmlNodeRef xmlChild = m_patchXML->getChild(i);
if (xmlChild->isTag("cvarpatch"))
{
const int numCVars = xmlChild->getChildCount();
const char *pCVar = NULL;
const char *pValue = NULL;
for (int cvarIndex = 0; cvarIndex < numCVars; ++ cvarIndex)
{
XmlNodeRef xmlCVar = xmlChild->getChild(cvarIndex);
if (xmlCVar->isTag("cvar"))
{
if (xmlCVar->getAttr("name", &pCVar) && xmlCVar->getAttr("value", &pValue))
{
bool bAllowed = false;
for (int allowedIndex = 0; allowedIndex < numAllowedCVars; ++ allowedIndex)
{
string &allowedCVar = cvarsWhiteList[allowedIndex];
if (!stricmp(allowedCVar.c_str(), pCVar))
{
bAllowed = true;
break;
}
}
//.........这里部分代码省略.........