本文整理汇总了C++中XmlNodeRef::getChildCount方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlNodeRef::getChildCount方法的具体用法?C++ XmlNodeRef::getChildCount怎么用?C++ XmlNodeRef::getChildCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNodeRef
的用法示例。
在下文中一共展示了XmlNodeRef::getChildCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XmlNodeRef
void CUIHUD3D::SpawnHudEntities()
{
RemoveHudEntities();
if(gEnv->IsEditor() && gEnv->IsEditing())
return;
XmlNodeRef node = gEnv->pSystem->LoadXmlFromFile(HUD3D_PREFAB_LIB);
if(node)
{
// get the prefab with the name defined in HUD3D_PREFAB_NAME
XmlNodeRef prefab = NULL;
for(int i = 0; i < node->getChildCount(); ++i)
{
const char *name = node->getChild(i)->getAttr("Name");
if(name && strcmp(name, HUD3D_PREFAB_NAME) == 0)
{
prefab = node->getChild(i);
prefab = prefab ? prefab->findChild("Objects") : XmlNodeRef();
break;
}
}
if(prefab)
{
// get the PIVOT entity and collect childs
XmlNodeRef pivotNode = NULL;
std::vector<XmlNodeRef> childs;
const int count = prefab->getChildCount();
childs.reserve(count-1);
for(int i = 0; i < count; ++i)
{
const char *name = prefab->getChild(i)->getAttr("Name");
if(strcmp("PIVOT", name) == 0)
{
assert(pivotNode == NULL);
pivotNode = prefab->getChild(i);
}
else
{
childs.push_back(prefab->getChild(i));
}
}
if(pivotNode)
{
// spawn pivot entity
IEntityClass *pEntClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(pivotNode->getAttr("EntityClass"));
if(pEntClass)
{
SEntitySpawnParams params;
params.nFlags = ENTITY_FLAG_CLIENT_ONLY;
params.pClass = pEntClass;
m_pHUDRootEntity = gEnv->pEntitySystem->SpawnEntity(params);
}
if(!m_pHUDRootEntity) return;
m_HUDRootEntityId = m_pHUDRootEntity->GetId();
// spawn the childs and link to the pivot enity
for(std::vector<XmlNodeRef>::iterator it = childs.begin(); it != childs.end(); ++it)
{
XmlNodeRef child = *it;
pEntClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(child->getAttr("EntityClass"));
if(pEntClass)
{
const char *material = child->getAttr("Material");
Vec3 pos;
Vec3 scale;
Quat rot;
child->getAttr("Pos", pos);
child->getAttr("Rotate", rot);
child->getAttr("Scale", scale);
SEntitySpawnParams params;
params.nFlags = ENTITY_FLAG_CLIENT_ONLY;
params.pClass = pEntClass;
params.vPosition = pos;
params.qRotation = rot;
params.vScale = scale;
IEntity *pEntity = gEnv->pEntitySystem->SpawnEntity(params);
if(pEntity)
{
IScriptTable *pScriptTable = pEntity->GetScriptTable();
if(pScriptTable)
{
SmartScriptTable probs;
pScriptTable->GetValue("Properties", probs);
XmlNodeRef properties = child->findChild("Properties");
//.........这里部分代码省略.........
示例2: Init
//------------------------------------------------------------------------
void CGameRulesManager::Init()
{
XmlNodeRef root = gEnv->pSystem->LoadXmlFromFile( GAMERULES_DEFINITIONS_XML_PATH );
if (root)
{
if (!stricmp(root->getTag(), "Modes"))
{
IGameRulesSystem *pGameRulesSystem = g_pGame->GetIGameFramework()->GetIGameRulesSystem();
int numModes = root->getChildCount();
for (int i = 0; i < numModes; ++ i)
{
XmlNodeRef modeXml = root->getChild(i);
if (!stricmp(modeXml->getTag(), "GameMode"))
{
const char *modeName;
if (modeXml->getAttr("name", &modeName))
{
pGameRulesSystem->RegisterGameRules(modeName, "GameRules");
SGameRulesData gameRulesData;
int numModeChildren = modeXml->getChildCount();
for (int j = 0; j < numModeChildren; ++ j)
{
XmlNodeRef modeChildXml = modeXml->getChild(j);
const char *nodeTag = modeChildXml->getTag();
if (!stricmp(nodeTag, "Alias"))
{
const char *alias;
if (modeChildXml->getAttr("name", &alias))
{
pGameRulesSystem->AddGameRulesAlias(modeName, alias);
}
}
else if (!stricmp(nodeTag, "LevelLocation"))
{
const char *path;
if (modeChildXml->getAttr("path", &path))
{
pGameRulesSystem->AddGameRulesLevelLocation(modeName, path);
}
}
else if (!stricmp(nodeTag, "Rules"))
{
const char *path;
if (modeChildXml->getAttr("path", &path))
{
gameRulesData.m_rulesXMLPath = path;
}
}
else if( !stricmp(nodeTag, "DefaultHudState"))
{
const char *name;
if (modeChildXml->getAttr("name", &name))
{
gameRulesData.m_defaultHud = name;
}
}
}
// Check if we're a team game
if (!gameRulesData.m_rulesXMLPath.empty())
{
XmlNodeRef rulesXml = gEnv->pSystem->LoadXmlFromFile( gameRulesData.m_rulesXMLPath.c_str() );
if (rulesXml)
{
XmlNodeRef teamXml = rulesXml->findChild("Teams");
gameRulesData.m_bIsTeamGame = (teamXml != (IXmlNode *)NULL);
}
}
// Insert gamerule specific data
m_rulesData.insert(TDataMap::value_type(modeName, gameRulesData));
}
else
{
CryLogAlways("CGameRulesModulesManager::Init(), invalid 'GameMode' node, requires 'name' attribute");
}
}
else
{
CryLogAlways("CGameRulesModulesManager::Init(), invalid xml, expected 'GameMode' node, got '%s'", modeXml->getTag());
}
}
}
else
{
CryLogAlways("CGameRulesModulesManager::Init(), invalid xml, expected 'Modes' node, got '%s'", root->getTag());
}
}
//.........这里部分代码省略.........
示例3: InitEffectData
//------------------------------------------------------------------------
void CGameRulesHoldObjectiveBase::InitEffectData(XmlNodeRef xmlEffectNode)
{
const int numChildren = xmlEffectNode->getChildCount();
for(int childIdx=0; childIdx<numChildren; childIdx++)
{
XmlNodeRef xmlChild = xmlEffectNode->getChild(childIdx);
if(!stricmp(xmlChild->getTag(), "ParticleEffect"))
{
const char* pParticleEffectName = NULL;
if (xmlChild->getAttr("name", &pParticleEffectName))
{
m_effectData.pParticleEffect = gEnv->pParticleManager->FindEffect(pParticleEffectName, "CGameRulesHoldObjectiveBase");
if(m_effectData.pParticleEffect)
{
m_effectData.pParticleEffect->AddRef();
}
}
const char* pParticleGeomMaterialName = NULL;
if (xmlChild->getAttr("particleGeomMaterial", &pParticleGeomMaterialName))
{
m_effectData.pParticleGeomMaterial = gEnv->p3DEngine->GetMaterialManager()->LoadMaterial(pParticleGeomMaterialName);
if(m_effectData.pParticleGeomMaterial)
{
m_effectData.pParticleGeomMaterial->AddRef();
}
}
}
else if(!stricmp(xmlChild->getTag(), "RingEntity"))
{
const char* pRingEntityGeomName = NULL;
if (xmlChild->getAttr("geom", &pRingEntityGeomName))
{
// Create ring effect entity
SEntitySpawnParams ringSpawnParams;
ringSpawnParams.pClass = gEnv->pEntitySystem->GetClassRegistry()->GetDefaultClass();
ringSpawnParams.sName = "crashSiteRing";
ringSpawnParams.nFlags = ENTITY_FLAG_NO_PROXIMITY | ENTITY_FLAG_CLIENT_ONLY | ENTITY_FLAG_NO_SAVE;
IEntity* pRingEntity = gEnv->pEntitySystem->SpawnEntity(ringSpawnParams);
if(pRingEntity)
{
pRingEntity->LoadGeometry(0,pRingEntityGeomName);
pRingEntity->Hide(true);
m_effectData.ringEntityID = pRingEntity->GetId();
}
}
}
else if(!stricmp(xmlChild->getTag(), "Params"))
{
float param = 0.0f;
xmlChild->getAttr("alphaLerpSpeed", param);
m_effectData.alphaLerp.SetLerpSpeed(param);
xmlChild->getAttr("materialColorLerpSpeed", param);
m_effectData.materialColorLerp.SetLerpSpeed(param);
xmlChild->getAttr("particleColorLerpSpeed", param);
m_effectData.particleColorLerp.SetLerpSpeed(param);
xmlChild->getAttr("alphaFadeInDelayDuration", m_effectData.alphaFadeInDelayDuration);
xmlChild->getAttr("particleEffectScale", m_effectData.particleEffectScale);
xmlChild->getAttr("ringGeomScale", m_effectData.ringGeomScale);
xmlChild->getAttr("friendlyColor", m_effectData.friendlyColor);
xmlChild->getAttr("enemyColor", m_effectData.enemyColor);
xmlChild->getAttr("neutralColor", m_effectData.neutralColor);
}
}
SetNewEffectColor(eRPT_Neutral);
}
示例4: 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
{
//.........这里部分代码省略.........
示例5: ResetDefaults
void COptionsManager::ResetDefaults(const char* option)
{
if(!m_pPlayerProfileManager)
return;
const char* user = m_pPlayerProfileManager->GetCurrentUser();
IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user);
if(!pProfile)
return;
XmlNodeRef root = GetISystem()->LoadXmlFile("libs/config/profiles/default/attributes.xml");
bool resetAll = (option==NULL);
bool detectHardware = false;
for (int i = 0; i < root->getChildCount(); ++i)
{
XmlNodeRef enumNameNode = root->getChild(i);
const char *name = enumNameNode->getAttr("name");
const char *value = enumNameNode->getAttr("value");
if(name && value)
{
const char* attribCVar = "";
bool bWriteToCfg = false;
const bool bIsOption = IsOption(name, attribCVar, bWriteToCfg);
if(bIsOption)
{
if(!resetAll && strcmp(attribCVar,option))
continue;
if(!strcmp(attribCVar, "sys_spec_Shadows"))
{
detectHardware = true;
}
if(!strcmp(attribCVar, "hud_colorLine"))
{
CryFixedStringT<32> color;
color.Format("%d", g_pGameCVars->hud_colorLine);
SetCrysisProfileColor(color.c_str());
}
if(!strcmp(attribCVar,"pb_client"))
{
if(atoi(value)==0)
{
m_pbEnabled = false;
gEnv->pConsole->ExecuteString("net_pb_cl_enable false");
}
else
{
m_pbEnabled = true;
gEnv->pConsole->ExecuteString("net_pb_cl_enable true");
}
}
else if(!strcmp(attribCVar, "g_difficultyLevel"))
{
SetDifficulty(value);
}
else
{
ICVar *pCVar = gEnv->pConsole->GetCVar(attribCVar);
if(pCVar)
{
pCVar->Set(value);
}
}
if(!resetAll)
break;
}
}
}
if(detectHardware)
AutoDetectHardware("");
}
示例6: InitTeamVisualizationData
void CTeamVisualizationManager::InitTeamVisualizationData( XmlNodeRef xmlNode )
{
if(m_teamVisualizationPartsMap.empty())
{
IMaterialManager *pMaterialManager = gEnv->p3DEngine->GetMaterialManager();
// Parse Team vis data and add to m_teamVisualizationPartsMap;
XmlNodeRef pPlayerTeamVisualization = xmlNode->findChild("PlayerTeamVisualization");
DesignerWarning(pPlayerTeamVisualization, "expected to find <PlayerTeamVisualization> </PlayerTeamVisualization>, not found");
if(pPlayerTeamVisualization)
{
Crc32Gen* pCRCGen = gEnv->pSystem->GetCrc32Gen();
// Grab each model setup node
const int modelCount = pPlayerTeamVisualization->getChildCount();
for(int i = 0; i < modelCount; ++i)
{
XmlNodeRef pModelSetup = pPlayerTeamVisualization->getChild(i);
if(pModelSetup)
{
// Friendly
XmlNodeRef friendlyNode = pModelSetup->findChild("Friendly");
DesignerWarning(friendlyNode, "missing <Friendly> </Friendly> tags in model setup <%d> - PlayerTeamVisualization.xml", i);
if(friendlyNode)
{
// Hostile
XmlNodeRef hostileNode = pModelSetup->findChild("Hostile");
DesignerWarning(hostileNode, "missing <Hostile> </Hostile> tags in model setup <%d> - PlayerTeamVisualization.xml", i);
if(hostileNode)
{
XmlNodeRef attachmentsNode = pModelSetup->findChild("BodyAttachments");
const int numAttachments = attachmentsNode->getChildCount();
DesignerWarning(attachmentsNode && numAttachments > 0, "missing <BodyAttachments> </bodyAttachments> tags in model setup <%d> or no child <BodyAttachment> elements - PlayerTeamVisualization.xml", i);
if(attachmentsNode && numAttachments > 0)
{
const char* pModelName = pModelSetup->getAttr("name");
DesignerWarning(pModelName && pModelName[0], "missing <Model> tag - or <Model name=""> attribute invalid - in model setup <%d> - PlayerTeamVisualization.xml", i);
if(pModelName && pModelName[0])
{
// Add new + Fill in details
TModelNameCRC modelNameCRC = pCRCGen->GetCRC32Lowercase(pModelName);
CRY_ASSERT(m_teamVisualizationPartsMap.find(modelNameCRC) == m_teamVisualizationPartsMap.end());
m_teamVisualizationPartsMap[modelNameCRC] = SModelMaterialSetup();
SModelMaterialSetup& newConfig = m_teamVisualizationPartsMap[modelNameCRC];
// Get materials
newConfig.SetMaterial(eMI_AliveFriendly, pMaterialManager->LoadMaterial(friendlyNode->getAttr("MaterialName")));
newConfig.SetMaterial(eMI_AliveHostile, pMaterialManager->LoadMaterial(hostileNode->getAttr("MaterialName")));
// Hostile
XmlNodeRef deadFriendlyNode = pModelSetup->findChild("DeadFriendly");
DesignerWarning(deadFriendlyNode, "missing <DeadFriendly> </DeadFriendly> tags in model setup <%d> - PlayerTeamVisualization.xml", i);
if(deadFriendlyNode)
{
newConfig.SetMaterial(eMI_DeadFriendly, pMaterialManager->LoadMaterial(deadFriendlyNode->getAttr("MaterialName")));
}
XmlNodeRef deadHostileNode = pModelSetup->findChild("DeadHostile");
DesignerWarning(deadHostileNode, "missing <deadHostileNode> </deadHostileNode> tags in model setup <%d> - PlayerTeamVisualization.xml", i);
if(deadHostileNode)
{
newConfig.SetMaterial(eMI_DeadHostile, pMaterialManager->LoadMaterial(deadHostileNode->getAttr("MaterialName")));
}
// Attachments
newConfig.m_attachments.reserve(numAttachments);
for(int j = 0; j < numAttachments; ++j)
{
XmlNodeRef attachmentNode = attachmentsNode->getChild(j);
newConfig.m_attachments.push_back(pCRCGen->GetCRC32Lowercase(attachmentNode->getAttr("name")));
}
continue;
}
}
}
}
}
}
}
}
}
示例7: CreateConnectionFromXMLNode
TConnectionPtr CAudioSystemEditor_wwise::CreateConnectionFromXMLNode(XmlNodeRef pNode, EACEControlType eATLControlType)
{
if (pNode)
{
const string sTag = pNode->getTag();
TImplControlType type = TagToType(sTag);
if (type != AUDIO_IMPL_INVALID_TYPE)
{
string sName = pNode->getAttr("wwise_name");
string sLocalised = pNode->getAttr("wwise_localised");
bool bLocalised = (sLocalised.compareNoCase("true") == 0);
// If control not found, create a placeholder.
// We want to keep that connection even if it's not in the middleware.
// The user could be using the engine without the wwise project
IAudioSystemControl* pControl = GetControlByName(sName, bLocalised);
if (pControl == nullptr)
{
pControl = CreateControl(SControlDef(sName, type));
if (pControl)
{
pControl->SetPlaceholder(true);
pControl->SetLocalised(bLocalised);
}
}
// If it's a switch we actually connect to one of the states within the switch
if (type == eWCT_WWISE_SWITCH_GROUP || type == eWCT_WWISE_GAME_STATE_GROUP)
{
if (pNode->getChildCount() == 1)
{
pNode = pNode->getChild(0);
if (pNode)
{
string sChildName = pNode->getAttr("wwise_name");
IAudioSystemControl* pChildControl = GetControlByName(sChildName, false, pControl);
if (pChildControl == nullptr)
{
pChildControl = CreateControl(SControlDef(sChildName, type == eWCT_WWISE_SWITCH_GROUP ? eWCT_WWISE_SWITCH : eWCT_WWISE_GAME_STATE, false, pControl));
}
pControl = pChildControl;
}
}
else
{
CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_ERROR, "Audio Controls Editor (Wwise): Error reading connection to Wwise control %s", sName);
}
}
if (pControl)
{
pControl->SetConnected(true);
++m_connectionsByID[pControl->GetId()];
if (type == eWCT_WWISE_RTPC)
{
switch (eATLControlType)
{
case EACEControlType::eACET_RTPC:
{
TRtpcConnectionPtr pConnection = std::make_shared<CRtpcConnection>(pControl->GetId());
float mult = 1.0f;
float shift = 0.0f;
if (pNode->haveAttr("atl_mult"))
{
const string sProperty = pNode->getAttr("atl_mult");
mult = (float)std::atof(sProperty.c_str());
}
if (pNode->haveAttr("atl_shift"))
{
const string sProperty = pNode->getAttr("atl_shift");
shift = (float)std::atof(sProperty.c_str());
}
pConnection->fMult = mult;
pConnection->fShift = shift;
return pConnection;
}
case EACEControlType::eACET_SWITCH_STATE:
{
TStateConnectionPtr pConnection = std::make_shared<CStateToRtpcConnection>(pControl->GetId());
float value = 0.0f;
if (pNode->haveAttr("atl_mult"))
{
const string sProperty = pNode->getAttr("wwise_value");
value = (float)std::atof(sProperty.c_str());
}
pConnection->fValue = value;
return pConnection;
}
}
}
else
{
return std::make_shared<IAudioConnection>(pControl->GetId());
}
}
}
//.........这里部分代码省略.........
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:101,代码来源:AudioSystemEditor_wwise.cpp
示例8: LoadLevelObjectivesInternal
void CHUDMissionObjectiveSystem::LoadLevelObjectivesInternal(const char* levelpath)
{
CryFixedStringT<128> filename;
if (levelpath==NULL)
{
// there is no Objectives_global.xml, but there is a file with the previous standard naming
// load the file with old name for backwards compatibility
if (!gEnv->pCryPak->IsFileExist("Libs/UI/Objectives_global.xml")
&& gEnv->pCryPak->IsFileExist("Libs/UI/Objectives_new.xml"))
{
CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "File 'Objectives_new.xml' is deprecated and should be renamed to 'Objectives_global.xml'");
filename = "Libs/UI/Objectives_new.xml";
}
else
{
filename = "Libs/UI/Objectives_global.xml";
}
}
else
{
filename.Format("%s/leveldata/Objectives.xml", levelpath);
}
/*if(gEnv->bMultiplayer)
{
CGameRules *pGameRules = g_pGame->GetGameRules();
if(stricmp (pGameRules->GetEntity()->GetClass()->GetName(), "Coop"))
filename = "Libs/UI/MP_Objectives.xml";
}*/
XmlNodeRef missionObjectives = GetISystem()->LoadXmlFromFile(filename.c_str());
if (missionObjectives == 0)
return;
for(int tag = 0; tag < missionObjectives->getChildCount(); ++tag)
{
XmlNodeRef mission = missionObjectives->getChild(tag);
const char* attrib;
const char* objective;
const char* text;
const char* optional;
const char* levelName;
if (!mission->getAttr("name", &levelName))
{
levelName = mission->getTag();
}
for(int obj = 0; obj < mission->getChildCount(); ++obj)
{
XmlNodeRef objectiveNode = mission->getChild(obj);
string id(levelName);
id.append(".");
id.append(objectiveNode->getTag());
if(objectiveNode->getAttributeByIndex(0, &attrib, &objective) && objectiveNode->getAttributeByIndex(1, &attrib, &text))
{
bool secondaryObjective = false;
int attribs = objectiveNode->getNumAttributes();
for(int attribIndex = 2; attribIndex < attribs; ++attribIndex)
{
if(objectiveNode->getAttributeByIndex(attribIndex, &attrib, &optional))
{
if(attrib)
{
if(!stricmp(attrib, "Secondary"))
{
if(!stricmp(optional, "true"))
secondaryObjective = true;
}
}
}
}
m_currentMissionObjectives.push_back(CHUDMissionObjective(this, id.c_str(), objective, text, secondaryObjective));
}
else
GameWarning("Error reading mission objectives.");
}
}
}
示例9: 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;
}
示例10: 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);
}
//.........这里部分代码省略.........
示例11: 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;
}
}
//.........这里部分代码省略.........
示例12: xmlParamReader
//--------------------------------------------------------------------------------------------------
// Name: CFrontEndModelCache
// Desc: Constructor
//--------------------------------------------------------------------------------------------------
CFrontEndModelCache::CFrontEndModelCache()
{
#if FEMC_USE_LEVEL_HEAP
SwitchToLevelHeap();
#endif // #if FEMC_USE_LEVEL_HEAP
FE_LOG("Front End model cache creation");
INDENT_LOG_DURING_SCOPE();
IGameFramework* pGameFramework = g_pGame->GetIGameFramework();
if(pGameFramework)
{
pGameFramework->StartNetworkStallTicker(true);
}
m_bIsMultiplayerCache = gEnv->bMultiplayer;
#if FEMC_FILE_ACCESS_LOG
gEnv->pConsole->GetCVar("sys_FileAccessLog")->Set(1);
#endif // #if FEMC_FILE_ACCESS_LOG
#ifdef FEMC_LOG_CACHE_TIME
const float startTime = gEnv->pTimer->GetAsyncCurTime();
#endif // #ifdef FEMC_LOG_CACHE_TIME
#if FEMC_CACHE_FILE_ACCESSES
if (g_pGameCVars->g_FEMenuCacheSaveList)
{
gEnv->pCryPak->RegisterFileAccessSink(this);
m_recordedFiles.clear();
}
int oldSaveLevelResourceList = 0;
ICVar* pPakSaveLevelResourceListCvar = gEnv->pConsole->GetCVar("sys_PakSaveLevelResourceList");
if(pPakSaveLevelResourceListCvar)
{
oldSaveLevelResourceList = pPakSaveLevelResourceListCvar->GetIVal();
pPakSaveLevelResourceListCvar->Set(0);
}
m_pReasonForReportingFileOpen = "CFrontEndModelCache constructor";
#endif // #if FEMC_CACHE_FILE_ACCESSES
CRY_ASSERT(s_pSingletonInstance == NULL);
s_pSingletonInstance = this;
// Load model list from xml, and cache each entry
XmlNodeRef pRootNode = gEnv->pSystem->LoadXmlFromFile(FEMC_CACHE_LIST_FILENAME);
if(pRootNode)
{
CGameXmlParamReader xmlParamReader(pRootNode);
const char* pPakName = NULL;
// Pak
const char* const pGameFolder = gEnv->pCryPak->GetGameFolder();
const XmlNodeRef pPakData = xmlParamReader.FindFilteredChild("PakData");
if(pPakData && pPakData->getChildCount())
{
const XmlNodeRef pPak = pPakData->getChild(0);
if(pPak)
{
pPakName = pPak->getAttr("name");
bool bSucceeded = gEnv->pCryPak->OpenPack(pGameFolder,pPakName,ICryPak::FLAGS_FILENAMES_AS_CRC32);
bSucceeded |= gEnv->pCryPak->LoadPakToMemory(pPakName,ICryPak::eInMemoryPakLocale_GPU);
FE_LOG ("%s to open pack file '%s' bound to %s", bSucceeded ? "Managed" : "Failed", pPakName, pGameFolder);
}
// There is a pak, so reserve space for some materials in cache
const uint materialCacheReserve = 64;
m_materialCache.reserve(materialCacheReserve);
}
// Cache character models
const XmlNodeRef pCharacterModelList = xmlParamReader.FindFilteredChild("CharacterModels");
if(pCharacterModelList)
{
const int characterModelCount = pCharacterModelList->getChildCount();
if(characterModelCount)
{
CreateSupportForFrontEnd3dModels();
}
for(int i=0; i<characterModelCount; i++)
{
const XmlNodeRef pCharacterModel = pCharacterModelList->getChild(i);
if(pCharacterModel)
{
const char* pCharacterModelName = pCharacterModel->getAttr("name");
CacheCharacterModel(pCharacterModelName);
}
}
}
// Cache item models
const XmlNodeRef pItemModelsList = xmlParamReader.FindFilteredChild("ItemModels");
if(pItemModelsList)
{
const int itemModelCount = pItemModelsList->getChildCount();
//.........这里部分代码省略.........
示例13: Init
//------------------------------------------------------------------------
void CGameRulesKingOfTheHillObjective::Init( XmlNodeRef xml )
{
BaseType::Init(xml);
if (xml->getAttr("scoreTime", m_scoreTimerMaxLength))
{
CryLog("CGameRulesKingOfTheHillObjective::Init, using score timer, length=%f", m_scoreTimerMaxLength);
}
xml->getAttr("additionalPlayerTimerMultiplier", m_scoreTimerAdditionalPlayerMultiplier);
if (m_scoreTimerAdditionalPlayerMultiplier == 0.f)
{
m_scoreTimerAdditionalPlayerMultiplier = 1.f;
}
CryLog("CGameRulesKingOfTheHillObjective::Init, multiplier for additional players=%f", m_scoreTimerAdditionalPlayerMultiplier);
int numChildren = xml->getChildCount();
for (int childIdx = 0; childIdx < numChildren; ++ childIdx)
{
XmlNodeRef xmlChild = xml->getChild(childIdx);
const char *pTag = xmlChild->getTag();
if (!stricmp(pTag, "Icons"))
{
CRY_ASSERT_MESSAGE(!m_useIcons, "KingOfTheHillObjective xml contains more than one 'Icons' node, we only support one");
m_useIcons = true;
m_neutralIcon = SGameRulesMissionObjectiveInfo::GetIconId(xmlChild->getAttr("neutral"));
m_friendlyIcon = SGameRulesMissionObjectiveInfo::GetIconId(xmlChild->getAttr("friendly"));
m_hostileIcon = SGameRulesMissionObjectiveInfo::GetIconId(xmlChild->getAttr("hostile"));
m_contestedIcon = SGameRulesMissionObjectiveInfo::GetIconId(xmlChild->getAttr("contested"));
m_shouldShowIconFunc.Format("%s", xmlChild->getAttr("checkFunc"));
CryLog("CGameRulesKingOfTheHillObjective::Init, using on-screen icons [%i %i %i %i]", m_neutralIcon, m_friendlyIcon, m_hostileIcon, m_contestedIcon);
}
else if(strcmp(pTag,"Audio") == 0)
{
if(xmlChild->haveAttr("capturedLoop"))
{
m_captureSignalId = g_pGame->GetGameAudio()->GetSignalID(xmlChild->getAttr("capturedLoop"));
}
}
else if (!stricmp(pTag, "Strings"))
{
const char *pString = 0;
if (xmlChild->getAttr("friendlyCapture", &pString))
{
m_friendlyCaptureString.Format("@%s", pString);
}
if (xmlChild->getAttr("enemyCapture", &pString))
{
m_enemyCaptureString.Format("@%s", pString);
}
if (xmlChild->getAttr("friendlyLost", &pString))
{
m_friendlyLostString.Format("@%s", pString);
}
if (xmlChild->getAttr("enemyLost", &pString))
{
m_enemyLostString.Format("@%s", pString);
}
if (xmlChild->getAttr("newEntity", &pString))
{
m_newEntityString.Format("@%s", pString);
}
if (xmlChild->getAttr("gameStateNeutral", &pString))
{
m_gameStateNeutralString.Format("@%s", pString);
}
if (xmlChild->getAttr("gameStateFriendly", &pString))
{
m_gameStateFriendlyString.Format("@%s", pString);
}
if (xmlChild->getAttr("gameStateEnemy", &pString))
{
m_gameStateEnemyString.Format("@%s", pString);
}
if (xmlChild->getAttr("gameStateDestructing", &pString))
{
m_gameStateDestructingString.Format("@%s", pString);
}
if (xmlChild->getAttr("gameStateIncoming", &pString))
{
m_gameStateIncomingString.Format("@%s", pString);
}
if (xmlChild->getAttr("iconTextDefend", &pString))
{
m_iconTextDefend.Format("@%s", pString);
m_iconTextDefend = CHUDUtils::LocalizeString(m_iconTextDefend.c_str());
}
if (xmlChild->getAttr("iconTextClear", &pString))
{
m_iconTextClear.Format("@%s", pString);
m_iconTextClear = CHUDUtils::LocalizeString(m_iconTextClear.c_str());
}
if (xmlChild->getAttr("iconTextCapture", &pString))
{
m_iconTextCapture.Format("@%s", pString);
m_iconTextCapture = CHUDUtils::LocalizeString(m_iconTextCapture.c_str());
}
//.........这里部分代码省略.........
示例14: LoadEffects
void CForceFeedBackSystem::LoadEffects( XmlNodeRef& effectsNode )
{
CGameXmlParamReader paramReader(effectsNode);
const int effectsCount = paramReader.GetUnfilteredChildCount();
m_effectToIndexMap.reserve(effectsCount);
m_effects.reserve(effectsCount);
m_effectNames.reserve(effectsCount);
for (int i = 0; i < effectsCount; ++i)
{
XmlNodeRef childEffectNode = paramReader.GetFilteredChildAt(i);
if( childEffectNode )
{
SEffect newEffect;
const int effectDataCount = childEffectNode->getChildCount();
const char* effectName = childEffectNode->getAttr("name");
//Check for invalid name
if ((effectName == NULL) || (effectName[0] == '\0'))
{
FORCEFEEDBACK_LOG("Could not load effect without name (at line %d)", childEffectNode->getLine());
continue;
}
//Check for duplicates
if (m_effectToIndexMap.find(FFBInternalId::GetIdForName(effectName)) != m_effectToIndexMap.end())
{
FORCEFEEDBACK_LOG("Effect '%s' does already exists, skipping", effectName);
continue;
}
childEffectNode->getAttr("time", newEffect.time);
for (int j = 0; j < effectDataCount; ++j)
{
XmlNodeRef motorNode = childEffectNode->getChild(j);
const char* motorTag = motorNode->getTag();
if (strcmp(motorTag, "MotorAB") == 0)
{
newEffect.patternA.Set( motorNode->haveAttr("pattern") ? motorNode->getAttr("pattern") : "" );
newEffect.patternB = newEffect.patternA;
newEffect.envelopeA.Set( motorNode->haveAttr("envelope") ? motorNode->getAttr("envelope") : "" );
newEffect.envelopeB = newEffect.envelopeA;
motorNode->getAttr("frequency", newEffect.frequencyA);
newEffect.frequencyB = newEffect.frequencyA;
}
else if (strcmp(motorTag, "MotorA") == 0)
{
newEffect.patternA.Set( motorNode->haveAttr("pattern") ? motorNode->getAttr("pattern") : "" );
newEffect.envelopeA.Set( motorNode->haveAttr("envelope") ? motorNode->getAttr("envelope") : "" );
motorNode->getAttr("frequency", newEffect.frequencyA);
}
else if (strcmp(motorTag, "MotorB") == 0)
{
newEffect.patternB.Set( motorNode->haveAttr("pattern") ? motorNode->getAttr("pattern") : "" );
newEffect.envelopeB.Set( motorNode->haveAttr("envelope") ? motorNode->getAttr("envelope") : "" );
motorNode->getAttr("frequency", newEffect.frequencyB);
}
}
newEffect.frequencyA = (float)__fsel(-newEffect.frequencyA, 1.0f, newEffect.frequencyA);
newEffect.frequencyB = (float)__fsel(-newEffect.frequencyB, 1.0f, newEffect.frequencyB);
m_effects.push_back(newEffect);
m_effectNames.push_back(effectName);
FFBInternalId internalId;
internalId.Set(effectName);
m_effectToIndexMap.insert(TEffectToIndexMap::value_type(internalId, ((int)m_effects.size() - 1)));
}
}
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:77,代码来源:ForceFeedbackSystem.cpp
示例15: ProcessEffectInfo
void CClientHitEffectsMP::ProcessEffectInfo(SHitEffectInfoSet& hitEffectSet, XmlNodeRef xmlNode, const char* libraryName)
{
bool foundDefault = false;
bool foundMelee = false;
const uint numEffects = xmlNode->getChildCount();
IMaterialEffects* pMaterialEffects = gEnv->pMaterialEffects;
IEntityClassRegistry* pClassRegistry = gEnv->pEntitySystem->GetClassRegistry();
hitEffectSet.m_effectInfos.reserve(numEffects);
for (uint i = 0; i < numEffects; i++)
{
if(XmlNodeRef childNode = xmlNode->getChild(i))
{
if(const char* nameTag = childNode->getTag())
{
if(!foundDefault && !strcmp("default", nameTag))
{
const char* effectName = childNode->getAttr("effect");
if(effectName)
{
hitEffectSet.m_default = pMaterialEffects->GetEffectIdByName(libraryName, effectName);
}
foundDefault = true;
}
else if(!foundMelee && !strcmp("melee", nameTag))
{
const char* effectName = childNode->getAttr("effect");
if(effectName)
{
hitEffectSet.m_melee = pMaterialEffects->GetEffectIdByName(libraryName, effectName);
}
foundMelee = true;
}
else
{
SHitEffectInfo newInfo;
newInfo.pAmmoClass = pClassRegistry->FindClass(nameTag);
const char* effectName = childNode->getAttr("effect");
if(effectName)
{
newInfo.effectId = pMaterialEffects->GetEffectIdByName(libraryName, effectName);
}
if(newInfo.pAmmoClass && newInfo.effectId)
{
hitEffectSet.m_effectInfos.push_back(newInfo);
}
else
{
if(!newInfo.pAmmoClass)
{
GameWarning("Class type %s does not exist", nameTag);
}
if(!newInfo.effectId)
{
GameWarning("Material Effect %s does not exist", effectName ? effectName : "");
}
}
}
}
}
}
if(!hitEffectSet.m_melee)
{
hitEffectSet.m_melee = hitEffectSet.m_default;
}
}