void CVehicleModificationParams::InitModification( XmlNodeRef xmlModificationData )
{
	assert( xmlModificationData );

	bool hasParentModification = xmlModificationData->haveAttr( "parent" );
	if ( hasParentModification )
	{
		XmlNodeRef xmlModificationsGroup = xmlModificationData->getParent();

		const char* parentModificationName = xmlModificationData->getAttr( "parent" );
		XmlNodeRef xmlParentModificationData = FindModificationNodeByName( parentModificationName, xmlModificationsGroup );
		if ( xmlParentModificationData && ( xmlParentModificationData != xmlModificationData ) )
		{
			InitModification( xmlParentModificationData );
		}
	}

	XmlNodeRef xmlElemsGroup = xmlModificationData->findChild( "Elems" );
	if ( ! xmlElemsGroup )
	{
		return;
	}

	for ( int i = 0; i < xmlElemsGroup->getChildCount(); ++i )
	{
		XmlNodeRef xmlElem = xmlElemsGroup->getChild( i );

		InitModificationElem( xmlElem );
	}
}
Пример #2
0
void CWorldState::SetString(const char * entityName,  char * valueName , string value)
{
//	CryLog("CWorldState::SetString()");
	if(worldStateXml)
	{
		XmlNodeRef entityNode = worldStateXml->findChild(entityName);

		if(!entityNode)
		{
			CreateChild(entityName);
			entityNode = worldStateXml->findChild(entityName);
		}
		const uint32 Count = entityNode->getChildCount();

		for (uint32 Index = 0; Index < Count; ++Index)
		{
			XmlNodeRef child = entityNode->getChild(Index);

			if(strcmp(child->getTag(),valueName)==0)
			{
				child->setAttr("value",value);
				worldStateXml->saveToFile(szSaveFile);
				return;
			}
		}

		//CryLog("CWorldState::CreateString()");

		XmlNodeRef child = entityNode->newChild(valueName);
		child->setAttr("value",value);
		worldStateXml->saveToFile(szSaveFile);
	}
	else
		return;
}
//------------------------------------------------------------------------
void CGameRulesHoldObjectiveBase::Init( XmlNodeRef xml )
{
	const int numChildren = xml->getChildCount();
	for (int childIdx = 0; childIdx < numChildren; ++ childIdx)
	{
		XmlNodeRef xmlChild = xml->getChild(childIdx);
		if (!stricmp(xmlChild->getTag(), "SpawnParams"))
		{
			const char *pType = 0;
			if (xmlChild->getAttr("type", &pType))
			{
				if (!stricmp(pType, "avoid"))
				{
					m_spawnPOIType = eSPT_Avoid;
				}
				else
				{
					CryLog("CGameRulesHoldObjectiveBase::Init: ERROR: Unknown spawn point of interest type ('%s')", pType);
				}
				xmlChild->getAttr("distance", m_spawnPOIDistance);
			}
		}
		else if (!stricmp(xmlChild->getTag(), "EffectData"))
		{
			InitEffectData(xmlChild);
		}
	}

	for (int i = 0; i < HOLD_OBJECTIVE_MAX_ENTITIES; ++ i)
	{
		m_entities[i].Reset();
	}
}
Пример #4
0
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());
		}
	}
}
Пример #5
0
//-------------------------------------------------------------------------
void CGameRulesStandardState::Init( XmlNodeRef xml )
{
	m_pGameRules = g_pGame->GetGameRules();

	m_state = EGRS_Intro; 
	m_lastReceivedServerState = m_state; 
	m_timeInPostGame = 0.f;
	m_introMessageShown = false;
	m_isStarting = false;
	m_isWaitingForOverrideTimer = false;
	m_startTimerOverrideWait = 0.0f;
	m_timeInCurrentPostGameState = 0.f;
	m_postGameState = ePGS_Unknown;
	m_bHaveNotifiedIntroListeners = false; 
	m_bHasShownHighlightReel = false;

	ChangeState(EGRS_Intro);

	int numChildren = xml->getChildCount();
	for (int i = 0; i < numChildren; ++ i)
	{
		XmlNodeRef xmlChild = xml->getChild(i);
		if (!stricmp(xmlChild->getTag(), "StartStrings"))
		{
			const char *pString = 0;
			if (xmlChild->getAttr("startMatch", &pString))
			{
				m_startMatchString.Format("@%s", pString);
			}
		}
	}
}
Пример #6
0
bool CWorldState::GetBool(const char * entityName, char * valueName)
{
//	CryLog("CWorldState::GetBool()");
	bool result = false;

	if(worldStateXml)
	{

		XmlNodeRef entityNode = worldStateXml->findChild(entityName);

		if(entityNode)
		{
			const uint32 Count = entityNode->getChildCount();
			for (uint32 Index = 0; Index < Count; ++Index)
			{
				const XmlNodeRef currentNode = entityNode->getChild(Index);
				if(strcmp(currentNode->getTag(),valueName)==0)
				{
					if(strcmp(currentNode->getAttr("value"),"true")==0)
						result = true;
					break;
				}
			}
		}
		else
			CryWarning( VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "CWorldState::Failed to get world state value!");
	}
	else
		CryWarning( VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "CWorldState::Failed to get world state value!");

	return result;
}
Пример #7
0
void CEditorGame::InitGlobalFileEnums(IGameToEditorInterface* pGTE)
{
	// Read in enums stored offline XML. Format is
	// <GlobalEnums>
	//   <EnumName>
	//     <entry enum="someName=someValue" />  <!-- displayed name != value -->
	// 	   <entry enum="someNameValue" />       <!-- displayed name == value -->
	//   </EnumName>
	// </GlobalEnums>
	//
	XmlNodeRef rootNode = GetISystem()->LoadXmlFromFile("Libs/GlobalEnums.xml");
	if (!rootNode || !rootNode->getTag() || stricmp(rootNode->getTag(), "GlobalEnums") != 0)
	{
		// GameWarning("CEditorGame::InitUIEnums: File 'Libs/GlobalEnums.xml' is not a GlobalEnums file");
		return;
	}
	for (int i = 0; i < rootNode->getChildCount(); ++i)
	{
		XmlNodeRef enumNameNode = rootNode->getChild(i);
		const char* enumId = enumNameNode->getTag();
		if (enumId == 0 || *enumId=='\0')
			continue;
		int maxChilds = enumNameNode->getChildCount();
		if (maxChilds > 0)
		{
			// allocate enough space to hold all strings
			const char** nameValueStrings = new const char*[maxChilds];
			int curEntryIndex = 0;
			for (int j = 0; j < maxChilds; ++j)
			{
				XmlNodeRef enumNode = enumNameNode->getChild(j);
				const char* nameValue = enumNode->getAttr("enum");
				if (nameValue != 0 && *nameValue!='\0')
				{
					// put in the nameValue pair
					nameValueStrings[curEntryIndex++] = nameValue;
				}
			}
			// if we found some entries inform CUIDataBase about it
			if (curEntryIndex > 0)
				pGTE->SetUIEnums(enumId, nameValueStrings, curEntryIndex);

			// be nice and free our array
			delete[] nameValueStrings;
		}
	}
}
Пример #8
0
void CScriptProperties::Assign( XmlNodeRef &propsNode,IScriptTable* pPropsTable )
{
	const char* key    = "";
	const char* value  = "";
	int         nAttrs = propsNode->getNumAttributes();
	for (int attr = 0; attr < nAttrs; attr++)
	{
		if (!propsNode->getAttributeByIndex( attr,&key,&value ))
			continue;

		ScriptVarType varType = pPropsTable->GetValueType(key);
		switch (varType)
		{
		case svtNull:
			break;
		case svtString:
			pPropsTable->SetValue( key,value );
			break;
		case svtNumber:
		{
			float fValue = (float)atof(value);
			pPropsTable->SetValue( key,fValue );
		}
		break;
		case svtBool:
		{
			bool const bValue = (stricmp(value, "true") == 0) || (stricmp(value, "1") == 0);
			pPropsTable->SetValue(key, bValue);
		}
		break;
		case svtObject:
		{
			Vec3 vec;
			propsNode->getAttr(key,vec);
			CScriptVector vecTable;
			pPropsTable->GetValue( key,vecTable );
			vecTable.Set( vec );
			//pPropsTable->SetValue( key,vec );
		}
		break;
		case svtPointer:
		case svtUserData:
		case svtFunction:
			// Ignore invalid property types.
			break;
		}
	}

	for (int i = 0; i < propsNode->getChildCount(); i++)
	{
		XmlNodeRef       childNode = propsNode->getChild(i);
		SmartScriptTable pChildPropTable;
		if (pPropsTable->GetValue(childNode->getTag(),pChildPropTable))
		{
			// Recurse.
			Assign( childNode,pChildPropTable );
		}
	}
}
Пример #9
0
//------------------------------------------------------------------------
bool CPlayerProfile::LoadAttributes(const XmlNodeRef& root, int requiredVersion)
{
	int version = 0;
	const bool bHaveVersion = root->getAttr(VERSION_TAG, version);
	
	if (requiredVersion > 0)
	{
		if (bHaveVersion && version < requiredVersion)
		{
			GameWarning("CPlayerProfile::LoadAttributes: Attributes of profile '%s' have different version (%d != %d). Updated.", GetName(), version, requiredVersion);
			return false;
		}
		else if (!bHaveVersion)
		{
			GameWarning("CPlayerProfile::LoadAttributes: Attributes of legacy profile '%s' has no version (req=%d). Loading anyway.", GetName(), requiredVersion);
		}
		m_attributesVersion = requiredVersion;
	}
	else
		// for default profile we set the version we found in the rootNode
		m_attributesVersion = version;

	int nChilds = root->getChildCount();
	for (int i=0; i<nChilds; ++i)
	{
		XmlNodeRef child = root->getChild(i);
		if (child && strcmp(child->getTag(), "Attr") == 0)
		{
			const char* name = child->getAttr("name");
			const char* value = child->getAttr("value");
			const char* platform = child->getAttr("platform");

			bool platformValid = true;
			if(platform != NULL && platform[0])
			{
#if defined(DURANGO)
				platformValid = (strstr(platform, "xbox")!=0);
#elif defined(ORBIS)
				platformValid = (strstr(platform, "ps4")!=0);
#else
				platformValid = (strstr(platform, "pc")!=0);
#endif
			}

			if (name && value && platformValid)
			{
				m_attributeMap[name] = TFlowInputData(string(value));
			}
		}
	}

	if(m_pManager->HasEnabledOnlineAttributes() && m_pManager->CanProcessOnlineAttributes() && !IsDefault())
	{
		m_pManager->LoadOnlineAttributes(this);
	}

	return true;
}
Пример #10
0
bool CFlowGraphModule::PreLoadModule(const char* fileName)
{
	m_fileName = fileName;

	XmlNodeRef moduleRef = gEnv->pSystem->LoadXmlFromFile(fileName);

	if (!moduleRef)
	{
		CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "Unable to preload Flowgraph Module: %s", PathUtil::GetFileName(fileName).c_str());
		return false;
	}

	assert(!stricmp(moduleRef->getTag(), "Graph"));

	bool module = false;
	moduleRef->getAttr("isModule", module);
	assert(module);

	XmlString tempName;
	if (moduleRef->getAttr("moduleName", tempName))
		m_name = tempName;

	bool bResult = (m_pRootGraph != NULL);
	assert(m_pRootGraph == NULL);

	// first handle module ports
	XmlNodeRef modulePorts = moduleRef->findChild("ModuleInputsOutputs");
	RemoveModulePorts();
	if (modulePorts)
	{
		int nPorts = modulePorts->getChildCount();
		for (int i = 0; i < nPorts; ++i)
		{
			XmlString portName;
			int       portType;
			bool      isInput;

			XmlNodeRef port = modulePorts->getChild(i);
			port->getAttr("Name", portName);
			port->getAttr("Type", portType);
			port->getAttr("Input", isInput);

			IFlowGraphModule::SModulePortConfig portConfig;
			portConfig.name  = portName.c_str();
			portConfig.type  = (EFlowDataTypes)portType;
			portConfig.input = isInput;

			AddModulePort(portConfig);
		}
	}

	// and create nodes for this module (needs to be done before actual graph load, so that the
	//	nodes can be created there)
	RegisterNodes();

	return bResult;
}
//------------------------------------------------------------------------
void CGameRulesCommonDamageHandling::Init( XmlNodeRef xml )
{
	m_pGameRules = g_pGame->GetGameRules();

	// Reserved hit types - in sync with RESERVED_HIT_TYPES
	/*00*/ //m_pGameRules->RegisterHitType("invalid",							CGameRules::EHitTypeFlag::None);
	/*01*/ m_pGameRules->RegisterHitType("melee",								CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::IgnoreHeadshots);
	/*02*/ m_pGameRules->RegisterHitType("collision",						CGameRules::EHitTypeFlag::Server);
	/*03*/ m_pGameRules->RegisterHitType("frag",								CGameRules::EHitTypeFlag::Server | CGameRules::EHitTypeFlag::AllowPostDeathDamage);
	/*04*/ m_pGameRules->RegisterHitType("explosion",						CGameRules::EHitTypeFlag::Server | CGameRules::EHitTypeFlag::AllowPostDeathDamage);
	/*05*/ m_pGameRules->RegisterHitType("stealthKill",					CGameRules::EHitTypeFlag::Server | CGameRules::EHitTypeFlag::AllowPostDeathDamage);
	/*06*/ m_pGameRules->RegisterHitType("silentMelee",					CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::SinglePlayerOnly | CGameRules::EHitTypeFlag::IgnoreHeadshots);
	/*07*/ m_pGameRules->RegisterHitType("punish",							CGameRules::EHitTypeFlag::ClientSelfHarm);
	/*08*/ m_pGameRules->RegisterHitType("punishFall",					CGameRules::EHitTypeFlag::ClientSelfHarm);
	/*10*/ m_pGameRules->RegisterHitType("fall",								CGameRules::EHitTypeFlag::ClientSelfHarm);
	/*11*/ m_pGameRules->RegisterHitType("normal",							CGameRules::EHitTypeFlag::Server);	//Used for killing players so they can switch teams
	/*12*/ m_pGameRules->RegisterHitType("fire",								CGameRules::EHitTypeFlag::Server); // used by PressurizedObject.lua
	/*14*/ m_pGameRules->RegisterHitType("heavyBullet",					CGameRules::EHitTypeFlag::ValidationRequired);
	/*18*/ m_pGameRules->RegisterHitType("environmentalThrow",	CGameRules::EHitTypeFlag::CustomValidationRequired | CGameRules::EHitTypeFlag::AllowPostDeathDamage | CGameRules::EHitTypeFlag::IgnoreHeadshots);
	/*19*/ m_pGameRules->RegisterHitType("meleeLeft",						CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::SinglePlayerOnly | CGameRules::EHitTypeFlag::IgnoreHeadshots);
	/*20*/ m_pGameRules->RegisterHitType("meleeRight",					CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::SinglePlayerOnly | CGameRules::EHitTypeFlag::IgnoreHeadshots);
	/*21*/ m_pGameRules->RegisterHitType("meleeKick",						CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::SinglePlayerOnly | CGameRules::EHitTypeFlag::IgnoreHeadshots);
	/*22*/ m_pGameRules->RegisterHitType("meleeUppercut",				CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::SinglePlayerOnly | CGameRules::EHitTypeFlag::IgnoreHeadshots);
	/*23*/ m_pGameRules->RegisterHitType("vehicleDestruction",	CGameRules::EHitTypeFlag::Server | CGameRules::EHitTypeFlag::AllowPostDeathDamage);
	/*27*/ m_pGameRules->RegisterHitType("eventDamage",					CGameRules::EHitTypeFlag::ClientSelfHarm);
	/*29*/ m_pGameRules->RegisterHitType("environmentalMelee",	CGameRules::EHitTypeFlag::IsMeleeAttack | CGameRules::EHitTypeFlag::CustomValidationRequired | CGameRules::EHitTypeFlag::AllowPostDeathDamage | CGameRules::EHitTypeFlag::IgnoreHeadshots);
	
	CRY_ASSERT(m_pGameRules->GetHitTypesCount() == CGameRules::EHitType::Unreserved);

	// Read any non-native hit_types from the HitTypes.xml file!
	XmlNodeRef xmlNode = gEnv->pSystem->LoadXmlFromFile( "Scripts/Entities/Items/HitTypes.xml" );

	if( xmlNode )
	{
		const int numEntries = xmlNode->getChildCount();
		for (int i = 0; i < numEntries; ++i)
		{
			XmlNodeRef hitTypeXML = xmlNode->getChild(i);

			if (strcmp(hitTypeXML->getTag(), "hit_type") != 0)
				continue;

			if( const char* pHitType = hitTypeXML->getAttr("name") )
			{
				TBitfield flags = CGameRules::EHitTypeFlag::None;

				if( const char * pHitTypeFlags = hitTypeXML->getAttr("flags"))
				{
					flags = AutoEnum_GetBitfieldFromString(pHitTypeFlags, CGameRules::s_hitTypeFlags, CGameRules::EHitTypeFlag::HIT_TYPES_FLAGS_numBits);
				}

				m_pGameRules->RegisterHitType( pHitType, flags );
			}
		}
	}
	m_scriptHitInfo.Create(gEnv->pScriptSystem);
}
Пример #12
0
void CD6ArmorManager::LoadFromXML(XmlNodeRef& rootNode)
{
	int childCount = rootNode->getChildCount();
	for (int i = 0; i < childCount; ++i)
	{
		XmlNodeRef node = rootNode->getChild(i);
		if (NULL == node)
			continue;

		if (0 == strcmp(node->getTag(), "Armor"))
		{
			XmlString armorName;
			SArmorDef armorDef;

			// Read the Armor tag's name attribute
			if (!node->getAttr("name", armorName))
				continue;
			armorDef.szArmorName = armorName;

			// Read warheads
			int childCount = node->getChildCount();
			for (int i = 0; i < childCount; ++i)
			{
				XmlNodeRef warhead = node->getChild(i);
				if (0 == strcmp(warhead->getTag(), "Warhead"))
				{
					SArmorWarheadDef warheadDef;
					XmlString name;

					if (!warhead->getAttr("name", name))
						break;
					warheadDef.szWarheadName = name;
					if (!warhead->getAttr("multiplier", warheadDef.fMultiplier))
						warheadDef.fMultiplier = 1.0f;

					armorDef.warheads.push_back(warheadDef);
				}
			}

			m_ArmorDefs.insert(std::make_pair(m_NextArmorId++, armorDef));
		}
	}
}
Пример #13
0
void CHUD::LoadWeaponsAccessories()
{
	XmlNodeRef weaponAccessoriesXmlNode = GetISystem()->LoadXmlFile("Libs/UI/WeaponAccessories.xml");
	if(weaponAccessoriesXmlNode)
	{
		int iNumChildren = weaponAccessoriesXmlNode->getChildCount();
		for(int iChild=0; iChild<iNumChildren; iChild++)
		{
			LoadWeaponAccessories(weaponAccessoriesXmlNode->getChild(iChild));
		}
	}
}
Пример #14
0
// 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);
	}
}
Пример #15
0
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;
}
Пример #16
0
//--------------------------------------------------------------------------------------------
void CUIObjectives::UpdateObjectiveInfo()
{
	m_ObjectiveMap.clear();

	string path = "Libs/UI/Objectives_new.xml";
	XmlNodeRef missionObjectives = GetISystem()->LoadXmlFromFile( path.c_str() );
	if (missionObjectives == 0)
	{
		gEnv->pLog->LogError("Error while loading MissionObjective file '%s'", path.c_str() );
		return;
	}

	for(int tag = 0; tag < missionObjectives->getChildCount(); ++tag)
	{
		XmlNodeRef mission = missionObjectives->getChild(tag);
		const char* attrib;
		const char* objective;
		const char* text;
		for(int obj = 0; obj < mission->getChildCount(); ++obj)
		{
			XmlNodeRef objectiveNode = mission->getChild(obj);
			string id(mission->getTag());
			id += ".";
			id += objectiveNode->getTag();
			if(objectiveNode->getAttributeByIndex(0, &attrib, &objective) && objectiveNode->getAttributeByIndex(1, &attrib, &text))
			{
				m_ObjectiveMap[ id ].Name = objective;
				m_ObjectiveMap[ id ].Desc = text;
			}
			else
			{
				gEnv->pLog->LogError("Error while loading MissionObjective file '%s'", path.c_str() );
				return;
			}
		}
	}
}
Пример #17
0
//---------------------------------------
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());
			}
		}
	}
}
Пример #18
0
void CDLCManager::PopulateDLCContents(const XmlNodeRef &rootNode, int dlcId, const char* name )
{
	mbstowcs( m_dlcContents[dlcId].name, name, MAX_DLC_NAME );

	XmlNodeRef levelsNode = rootNode->findChild("levels");
	if (levelsNode)
	{
		XmlString levelName;
		int numLevels = levelsNode->getChildCount();

		CryLog( "Found %d levels in the DLC", numLevels );
		
		m_dlcContents[dlcId].levels.reserve(numLevels);
		for (int i=0; i<numLevels; ++i)
		{
			XmlNodeRef levelNode = levelsNode->getChild(i);
			if (levelNode->getAttr("name", levelName))
			{
				CryLog( "Found level %s and added to the DLC manager", levelName.c_str() );
				m_dlcContents[dlcId].levels.push_back(levelName);
			}
		}
	}

	XmlNodeRef bonusNode = rootNode->findChild("bonus");
	if( bonusNode )
	{
		CryLog( "DLC pak includes a pre-sale bonus" );
		uint32 bonusID = 0;
		bonusNode->getAttr("id", bonusID );
		m_dlcContents[dlcId].bonusID = bonusID;
	}

	XmlNodeRef uniqueIdNode = rootNode->findChild("uniqueId");
	if( uniqueIdNode )
	{
		uint32 uniqueID = 0;
		uniqueIdNode->getAttr("id", uniqueID );
		m_dlcContents[dlcId].uniqueID = uniqueID;
	}

	XmlNodeRef uniqueTagNode = rootNode->findChild("uniqueTag");
	if( uniqueTagNode )
	{
		const char* str =	uniqueTagNode->getAttr( "tag" );
		m_dlcContents[dlcId].uniqueTag.Format( str );
	}
}
Пример #19
0
void CDLCManager::DoDLCUnlocks( XmlNodeRef unlocksXml, int dlcId )
{
	//handle any direct unlocks
	const int unlockCount = unlocksXml->getChildCount();

	for (int iUnlock = 0; iUnlock < unlockCount; ++iUnlock)
	{
		XmlNodeRef unlockNode = unlocksXml->getChild(iUnlock);
		SUnlock unlock(unlockNode, 0);
		unlock.Unlocked(true);
		m_itemUnlocks.push_back( unlock );
		m_itemUnlockDLCids.push_back( dlcId );

		CryLog( "DLC: Found a dlc item unlock, %s", unlockNode->getAttr("name") );
	}
}
Пример #20
0
bool CItemParamsNode::ConvertFromXMLWithFiltering(const XmlNodeRef &root, const char * keepWithThisAttrValue)
{
	bool filteringRequired = false;
	int nattributes = root->getNumAttributes();
	m_attributes.reserve(nattributes);
	for (int a=0; a<nattributes; a++)
	{
		const char *name=0;
		const char *value=0;
		if (root->getAttributeByIndex(a, &name, &value))
		{
			float f;
			int i;
			Vec3 v;
			if (!stricmp(value, "true"))
				SetAttribute(name, 1);
			else if (!stricmp(value, "false"))
				SetAttribute(name, 0);
			else if (IsInteger(value, &i))
				SetAttribute(name, i);
			else if (IsFloat(value, &f))
				SetAttribute(name, f);
			else if (IsVec3(value, &v))
				SetAttribute(name, v);
			else
				SetAttribute(name, value);
		}
	}

	int nchildren = root->getChildCount();
	m_children.reserve(nchildren);
	for (int c=0; c<nchildren; c++)
	{
		XmlNodeRef child = root->getChild(c);
		EXMLFilterType filterType = ShouldConvertNodeFromXML(child, keepWithThisAttrValue);
		filteringRequired = (filterType != eXMLFT_none) || filteringRequired ? true : false;

		if(filterType != eXMLFT_remove)
		{
			filteringRequired = (InsertChild(child->getTag())->ConvertFromXMLWithFiltering(child, keepWithThisAttrValue) || filteringRequired);
		}		
	}

	return filteringRequired;
}
XmlNodeRef CVehicleModificationParams::FindModificationNodeByName( const char* name, XmlNodeRef xmlModificationsGroup )
{
	assert( name != NULL );
	assert( xmlModificationsGroup );

	int numNodes = xmlModificationsGroup->getChildCount();
	for ( int i = 0; i < numNodes; i++ )
	{
		XmlNodeRef xmlModification = xmlModificationsGroup->getChild( i );
		const char* modificationName = xmlModification->getAttr( "name" );
		if ( modificationName!=0 && ( strcmpi( name, modificationName ) == 0 ) )
		{
			return xmlModification;
		}
	}

	return XmlNodeRef();
}
Пример #22
0
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;
}
Пример #23
0
void CHUD::LoadWeaponAccessories(XmlNodeRef weaponXmlNode)
{
	if(weaponXmlNode)
	{
		TMapWeaponAccessoriesHelperOffsets mapWeaponAccessoriesHelpersOffsets;

		int iNumChildren = weaponXmlNode->getChildCount();
		for(int iChild=0; iChild<iNumChildren; iChild++)
		{
			XmlNodeRef helperXmlNode = weaponXmlNode->getChild(iChild);
			SWeaponAccessoriesHelpersOffsets offsets;
			offsets.iX = atoi(helperXmlNode->getAttr("X"));
			offsets.iY = atoi(helperXmlNode->getAttr("Y"));
			mapWeaponAccessoriesHelpersOffsets.insert(std::make_pair(helperXmlNode->getTag(),offsets));
		}

		m_mapWeaponAccessoriesHelpersOffsets.insert(std::make_pair(weaponXmlNode->getTag(),mapWeaponAccessoriesHelpersOffsets));
	}
}
void CForceFeedBackSystem::LoadEnvelopes( XmlNodeRef& envelopesNode )
{
	const int envelopesCount = envelopesNode->getChildCount();

	m_envelopes.reserve(envelopesCount);

	TSamplesBuffer samplesBuffer;
	const int maxSampleCount = FFSYSTEM_MAX_ENVELOPE_SAMPLES / 2;
	float readValues[maxSampleCount];

	for (int i = 0; i < envelopesCount; ++i)
	{
		XmlNodeRef envelopeChildNode = envelopesNode->getChild(i);

		const char* customEnvelopeName = envelopeChildNode->getAttr("name");
		if (!customEnvelopeName || (customEnvelopeName[0] == '\0'))
		{
			FORCEFEEDBACK_LOG("Could not load envelope without name (at line %d)", envelopeChildNode->getLine());
			continue;
		}

		samplesBuffer = envelopeChildNode->haveAttr("name") ? envelopeChildNode->getAttr("samples") : "";

		int samplesFound = ParseSampleBuffer(samplesBuffer, &readValues[0], maxSampleCount);

		if (samplesFound != 0)
		{
			SEnvelope customEnvelope;
			customEnvelope.ResetToDefault();

			DistributeSamples(&readValues[0], samplesFound, &customEnvelope.m_envelopeSamples[0], FFSYSTEM_MAX_ENVELOPE_SAMPLES);

			customEnvelope.m_envelopeId.Set(customEnvelopeName);
			m_envelopes.push_back(customEnvelope);
		}
		else
		{
			FORCEFEEDBACK_LOG("Envelope '%s' (at line %d) has not samples, skipping", customEnvelopeName, envelopeChildNode->getLine());
		}
	}

	std::sort(m_envelopes.begin(), m_envelopes.end());
}
Пример #25
0
void CRichPresence::LoadXmlFromFile(const char* path)
{
	XmlNodeRef node = g_pGame->GetIGameFramework()->GetISystem()->LoadXmlFromFile(path);
	if(node)
	{
		int numElements = node->getChildCount();
		for (int i = 0; i < numElements; ++ i)
		{
			XmlNodeRef childNode = node->getChild(i);
			const char *levelName = NULL;
			int id = -1;

			if (childNode->getAttr("name", &levelName) && childNode->getAttr("id", id))
			{
				m_richPresence[levelName] = id;
			}
		}
	}
}
void CForceFeedBackSystem::LoadPatters( XmlNodeRef& patternsNode )
{
	const int patterCount = patternsNode->getChildCount();

	m_patters.reserve(patterCount);

	TSamplesBuffer samplesBuffer;
	const int maxSampleCount = FFSYSTEM_MAX_PATTERN_SAMPLES / 2;
	float readValues[maxSampleCount];

	for (int i = 0; i < patterCount; ++i)
	{
		XmlNodeRef childPatternNode = patternsNode->getChild(i);

		const char* customPatternName = childPatternNode->getAttr("name");
		if (!customPatternName || (customPatternName[0] == '\0'))
		{
			FORCEFEEDBACK_LOG("Could not load pattern without name (at line %d)", childPatternNode->getLine());
			continue;
		}

		samplesBuffer = childPatternNode->haveAttr("name") ? childPatternNode->getAttr("samples") : "";

		int samplesFound = ParseSampleBuffer(samplesBuffer, &readValues[0], maxSampleCount);

		if (samplesFound != 0)
		{
			SPattern customPattern;
			customPattern.ResetToDefault();

			DistributeSamples(&readValues[0], samplesFound, &customPattern.m_patternSamples[0], FFSYSTEM_MAX_PATTERN_SAMPLES);

			customPattern.m_patternId.Set(customPatternName);
			m_patters.push_back(customPattern);
		}
		else
		{
			FORCEFEEDBACK_LOG("Pattern '%s' (at line %d) has not samples, skipping", customPatternName, childPatternNode->getLine());
		}
	}

	std::sort(m_patters.begin(), m_patters.end());
}
Пример #27
0
void GetArchetypesFromLib(XmlNodeRef root, string& name, std::vector<string>* archetypeNames)
{
	if (!root)
		return;

	const int iChildCount = root->getChildCount();
	for (int iChild = 0; iChild < iChildCount; ++iChild)
	{
		XmlNodeRef pChild = root->getChild(iChild);
		if (!pChild || stricmp(pChild->getTag(), "EntityPrototype"))
			continue;

		XmlString sChildName;
		pChild->getAttr("Name", sChildName);

		string sFullName;
		sFullName.Format("%s.%s", name.c_str(), sChildName.c_str());
		archetypeNames->push_back(sFullName);
	}
}
Пример #28
0
bool CDLCManager::VerifyCRCs(const XmlNodeRef &crcNode, const char* sDLCRootFolder)
{
	bool success = true;
	CryFixedStringT<ICryPak::g_nMaxPath> path;
	int numFiles = crcNode->getChildCount();
	XmlString fileName;
	uint32 storedCrc;
	for (int i=0; i<numFiles; ++i)
	{
		XmlNodeRef fileNode = crcNode->getChild(i);
		if (fileNode->getAttr("name", fileName) &&
			fileNode->getAttr("crc", storedCrc))
		{
			bool useCryFile = false;

#if defined(WIN32) || defined(WIN64)
			path.Format("%s/%s", sDLCRootFolder, fileName.c_str());
			useCryFile = true;
#else
			CryWarning( VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "No Platform defined in DLCManager" );
#endif
			CryLog( "CRC: Checking CRC of %s", path.c_str() );

			success = gEnv->pCryPak->OpenPack( path.c_str() );

			if( !success )
			{
					CryLog( "CRC: Failed to open pack" );
			}

			uint32 computedCrc = gEnv->pCryPak->ComputeCachedPakCDR_CRC( path.c_str(), useCryFile );
			if (computedCrc != storedCrc)
			{
				CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "CRC on file %s (%u) does not match stored value (%u)", path.c_str(), computedCrc, storedCrc);
				success = false;
			}
			gEnv->pCryPak->ClosePack( path.c_str() );
		}
	}
	return success;
}
Пример #29
0
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;
	}
}
Пример #30
0
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;
}