Example #1
0
void SAmmoParams::LoadGeometry(const XmlNodeRef& ammoParamsNode)
{
	CGameXmlParamReader reader(ammoParamsNode);

	XmlNodeRef geometryNode = reader.FindFilteredChild("geometry");
	if (!geometryNode)
		return;

	CGameXmlParamReader geometryReader(geometryNode);

	XmlNodeRef firstpersonNode = geometryReader.FindFilteredChild("firstperson");
	if (firstpersonNode)
	{
		const char *modelName = firstpersonNode->getAttr("name");

		if (modelName && modelName[0])
		{
			Ang3 angles(0,0,0);
			Vec3 position(0,0,0);
			float scale=1.0f;
			firstpersonNode->getAttr("position", position);
			firstpersonNode->getAttr("angles", angles);
			firstpersonNode->getAttr("scale", scale);

			fpLocalTM = Matrix34(Matrix33::CreateRotationXYZ(DEG2RAD(angles)));
			fpLocalTM.ScaleColumn(Vec3(scale, scale, scale));
			fpLocalTM.SetTranslation(position);

			fpGeometryName = modelName;
		}
	}
}
void CCheckpointSystem::SerializeWorldTM(IEntity *pEntity, XmlNodeRef data, bool writing)
{
	if(!pEntity || !data)
		return;

	if(writing)
	{
		//write all TM columns to checkpoint node
		const Matrix34 &tm = pEntity->GetWorldTM();
		data->setAttr("TMcol0", tm.GetColumn0());
		data->setAttr("TMcol1", tm.GetColumn1());
		data->setAttr("TMcol2", tm.GetColumn2());
		data->setAttr("TMcol3", tm.GetColumn3());
	}
	else
	{
		//read and set TM columns from node
		Matrix34 tm;
		Vec3 temp = Vec3(0,0,0);
		bool foundData = data->getAttr("TMcol0", temp);
		tm.SetColumn(0, temp);
		foundData &= data->getAttr("TMcol1", temp);
		tm.SetColumn(1, temp);
		foundData &= data->getAttr("TMcol2", temp);
		tm.SetColumn(2, temp);
		foundData &= data->getAttr("TMcol3", temp);
		tm.SetColumn(3, temp);
		CRY_ASSERT(foundData);
		//set matrix to entity
		pEntity->SetWorldTM(tm);
	}
}
void CPlayerPlugin_InteractiveEntityMonitor::PrecacheLevel()
{
	XmlNodeRef rootNode = gEnv->pSystem->LoadXmlFromFile(INTERACTIVE_ENTITY__MONITOR_DATA_FILE);
	if(rootNode)
	{
		const char* pLevelName = gEnv->pGame->GetIGameFramework()->GetLevelName();
		if(!pLevelName)
		{
			pLevelName = "default";
		}
		else if( const char * pTrim = strstr(pLevelName, "/") )
		{
			pLevelName = pTrim+1;
		}
		CGameXmlParamReader nodeDataReader(rootNode);
		XmlNodeRef levelNode = nodeDataReader.FindFilteredChild(pLevelName);
		if(!levelNode)
		{
			levelNode = nodeDataReader.FindFilteredChild("default");
		}
		if(levelNode)
		{
			ColorB color;
			if(levelNode->getAttr("color", color))
			{
				m_silhouetteInteractColor = ColorF(color.r, color.g, color.b, color.a) / 255.f;
			}
			if(levelNode->getAttr("shoot_color", color))
			{
				m_silhouetteShootColor = ColorF(color.r, color.g, color.b, color.a) / 255.f;
			}
		}
	}
}
void CCheckpointSystem::LoadExternalEntities(XmlNodeRef parentNode)
{
	XmlNodeRef data = parentNode->findChild(EXTERNAL_ENTITIES_SECTION);
	if(!data)
		return;

	int numEntities = data->getChildCount();
	for(int i = 0; i < numEntities; ++i)
	{
		XmlNodeRef nextEntity = data->getChild(i);
		if(nextEntity)
		{
			EntityId id = 0;
			nextEntity->getAttr("id", id);
			const char *name = nextEntity->getAttr("name");
			
			//fix entityId if broken
			if(RepairEntityId(id, name))
			{
				IEntity *pEntity = gEnv->pEntitySystem->GetEntity(id);
				//setup entity
				bool bActive = false;
				bool bHidden = false;
				nextEntity->getAttr("active", bActive);
				nextEntity->getAttr("hidden", bHidden);
				pEntity->Activate(bActive);
				pEntity->Hide(bHidden);
				//load matrix
				SerializeWorldTM(pEntity, nextEntity, false);
			}
		}
	}
}
void SRecoilHints::Reset(const XmlNodeRef& paramsNode, bool defaultInit /* = true */)
{
	if (defaultInit)
	{
		hints.resize(0);
	}

	CGameXmlParamReader reader(paramsNode);

	XmlNodeRef hintsNode = reader.FindFilteredChild("hints");
	if (hintsNode && (hintsNode->getChildCount() > 0))
	{
		//Replacing hints, delete previous ones
		hints.resize(0);

		CGameXmlParamReader hintsReader(hintsNode);

		Vec2 hintPoint;
		const int hintCount = hintsReader.GetUnfilteredChildCount();
		hints.reserve(hintCount);

		for (int i = 0; i < hintCount; i++)
		{
			XmlNodeRef hintNode = hintsReader.GetFilteredChildAt(i);
			if (hintNode && hintNode->getAttr("x", hintPoint.x) && hintNode->getAttr("y", hintPoint.y))
			{
				hints.push_back(hintPoint);
			}
		}
	}

}
//-------------------------------------------------------------------------
/* static */ void CStatsEntityIdRegistry::ReadStringIds( XmlNodeRef xmlNode, uint16 &defaultId, TStringIdVec &vec )
{
	const char *pDefault;
	if (xmlNode->getAttr("default", &pDefault))
	{
		defaultId = atoi(pDefault);
	}

	const int numEntities = xmlNode->getChildCount();
	vec.reserve(numEntities);
	for (int i = 0; i < numEntities; ++ i)
	{
		XmlNodeRef xmlEntity = xmlNode->getChild(i);

		const char *pName;
		const char *pValue;
		if (xmlEntity->getAttr("name", &pName) && xmlEntity->getAttr("value", &pValue))
		{
			SStringId entity;
			entity.m_name = pName;
			entity.m_id = atoi(pValue);
			vec.push_back(entity);
		}
	}
}
//-------------------------------------------------------------------------
/* static */ void CStatsEntityIdRegistry::ReadClassIds( XmlNodeRef xmlNode, uint16 &defaultId, TClassIdVec &vec )
{
	const char *pDefault;
	if (xmlNode->getAttr("default", &pDefault))
	{
		defaultId = atoi(pDefault);
	}

	const IEntityClassRegistry *pClassRegistry = gEnv->pEntitySystem->GetClassRegistry();
	const int numEntities = xmlNode->getChildCount();
	vec.reserve(numEntities);
	for (int i = 0; i < numEntities; ++ i)
	{
		XmlNodeRef xmlEntity = xmlNode->getChild(i);

		const char *pName;
		const char *pValue;
		if (xmlEntity->getAttr("name", &pName) && xmlEntity->getAttr("value", &pValue))
		{
			SClassId entity;
			entity.m_pClass = pClassRegistry->FindClass(pName);
			CRY_ASSERT_TRACE(entity.m_pClass, ("Failed to find class '%s' referenced in StatsEntityIds.xml", pName));
			entity.m_id = atoi(pValue);
			vec.push_back(entity);
		}
	}
}
//------------------------------------------------------------------------
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();
	}
}
Example #9
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());
		}
	}
}
Example #10
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;
}
//------------------------------------------------------------------------
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);
}
Example #12
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;
}
Example #13
0
void CProfileOptions::AddOption(const XmlNodeRef node)
{
	const char *platform = node->getAttr("platform");
	if(platform != NULL && platform[0])
	{
		bool result = (strstr(platform, "pc")==0);

		if (result)
			return;
	}

	// Ignore gameOnly attributes in the editor
	bool gameOnly = false;
	node->getAttr("gameOnly",gameOnly);
	if(gameOnly && gEnv->IsEditor())
		return;

	const char* name = node->getAttr("name");
	const char* val = node->getAttr("value");
	const char* cvar = node->getAttr("cvar");

	bool preview = false;
	node->getAttr("preview", preview);

	bool confirmation = false;
	node->getAttr("confirmation", confirmation);

	bool restart = false;
	node->getAttr("requiresRestart", restart);

	bool writeToConfig = false;
	node->getAttr("writeToConfig", writeToConfig);

	AddOption(name, val, cvar, preview, confirmation, restart, restart||writeToConfig); //options that require restart also need to be written to the config
}
void CGameRulesSpawningBase::Init(XmlNodeRef xml)
{
	m_pGameRules = g_pGame->GetGameRules();

	int ival;
	if (xml->getAttr("team1AlwaysUsesInitialSpawns", ival))
	{
		m_bTeamAlwaysUsesInitialSpawns[0] = (ival != 0);
	}
	if (xml->getAttr("team2AlwaysUsesInitialSpawns", ival))
	{
		m_bTeamAlwaysUsesInitialSpawns[1] = (ival != 0);
	}
}
Example #15
0
void CMFXForceFeedbackEffect::ReadXMLNode(XmlNodeRef &node)
{
	IMFXEffect::ReadXMLNode(node);

	m_forceFeedbackParams.forceFeedbackEventName = node->getAttr("name");

	float minFallOffDistance = 0.0f;
	node->getAttr("minFallOffDistance", minFallOffDistance);
	float maxFallOffDistance = 5.0f;
	node->getAttr("maxFallOffDistance", maxFallOffDistance);

	m_forceFeedbackParams.intensityFallOffMinDistanceSqr = minFallOffDistance * minFallOffDistance;
	m_forceFeedbackParams.intensityFallOffMaxDistanceSqr = maxFallOffDistance * maxFallOffDistance;
}
Example #16
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 );
	}
}
Example #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());
			}
		}
	}
}
EAudioRequestStatus CAudioSystemImpl_sdlmixer::ParseAudioFileEntry(XmlNodeRef const pAudioFileEntryNode, SATLAudioFileEntryInfo* const pFileEntryInfo)
{
	EAudioRequestStatus eResult = eARS_FAILURE;

	if ((_stricmp(pAudioFileEntryNode->getTag(), ms_sSDLFileTag) == 0) && (pFileEntryInfo != NPTR))
	{
		char const* const sFileName = pAudioFileEntryNode->getAttr(ms_sSDLCommonAttribute);

		// Currently the SDLMixer Implementation does not support localized files.
		pFileEntryInfo->bLocalized = false;

		if (sFileName != NPTR && sFileName[0] != '\0')
		{
			pFileEntryInfo->sFileName = sFileName;
			pFileEntryInfo->nMemoryBlockAlignment	= m_nMemoryAlignment;
			POOL_NEW(SSDLMixerAudioFileEntryData, pFileEntryInfo->pImplData);

			eResult = eARS_SUCCESS;
		}
		else
		{
			pFileEntryInfo->sFileName = NPTR;
			pFileEntryInfo->nMemoryBlockAlignment	= 0;
			pFileEntryInfo->pImplData = NPTR;
		}
	}

	return eResult;
}
//-------------------------------------------------------------------------
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);
			}
		}
	}
}
Example #20
0
float CWorldState::GetFloat(const char * entityName, char * valueName)
{
//	CryLog("CWorldState::GetFloat()");
	float result = 0.f;

	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)
				{
					currentNode->getAttr("value",result);
					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;
}
XmlNodeRef CCheckpointSystem::LoadXMLNode(const char *identifier)
{
	if(!identifier)
		return NULL;
	//check whether a checkpoint is currently open
	if(!CHECKPOINT_LOAD_XML_NODE)
	{
		CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Tried reading checkpoint section %s while checkpoint was not open.", identifier);
		return NULL;
	}

	int numChildren = CHECKPOINT_LOAD_XML_NODE->getChildCount();
	for(int i = 0; i < numChildren; ++i)
	{
		XmlNodeRef child = CHECKPOINT_LOAD_XML_NODE->getChild(i);
		//return external section if name matches
		const char *key = "external";
		const char *attribName = child->getAttr(key);
		if(attribName)
		{
			//check name
			if(!stricmp(identifier, attribName))
				return child;
		}
	}

	return NULL;
}
Example #22
0
void CEditorGame::InitDialogBuffersEnum( IGameToEditorInterface* pGTE )
{
	static const char* BUFFERS_FILENAME = "Libs/FlowNodes/DialogFlowNodeBuffers.xml";

	XmlNodeRef xmlNodeRoot = gEnv->pSystem->LoadXmlFromFile( BUFFERS_FILENAME );
	if (xmlNodeRoot==NULL)
	{
		CryWarning( VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "CEditorGame::InitDialogBuffersEnum() - Failed to load '%s'. flownode dialog buffers drop down list will be empty.", BUFFERS_FILENAME);
		return;
	}

	uint32 count = xmlNodeRoot->getChildCount();

	const char** bufferNames = new const char*[count];
	bool bOk = true;

	for (uint32 i=0; i<count; ++i)
	{
		XmlNodeRef xmlNode = xmlNodeRoot->getChild( i );
		bufferNames[i] = xmlNode->getAttr("name");
		if (!bufferNames[i])
		{
			CryWarning( VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "CEditorGame::InitDialogBuffersEnum() - file: '%s' child: %d is missing the 'name' field. flownode dialog buffers drop down list will be empty", BUFFERS_FILENAME, i);
			bOk = false;
		}
	}
	if (bOk)
		pGTE->SetUIEnums("dialogBuffers", bufferNames, count);
	delete[] bufferNames;
}
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 );
	}
}
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;
		}
	}
}
Example #25
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 );
		}
	}
}
Example #26
0
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 );
			}
		}
	}
}
void CMFXParticleEffect::LoadParamsFromXml(const XmlNodeRef& paramsNode)
{
	// Xml data format
	/*
	<Particle>
		<Name userdata="..." scale="..." maxdist="..." minscale="..." maxscale="..." maxscaledist="..." attach="...">particle.name</Name>
		<Direction>DirectionType</Direction>
	</Particle>
	*/

  for (int i=0; i<paramsNode->getChildCount(); ++i)
  {
    XmlNodeRef child = paramsNode->getChild(i);
    if (!strcmp(child->getTag(), "Name"))
    {
      SMFXParticleEntry entry;            
      entry.name = child->getContent();

			if (child->haveAttr("userdata"))
				entry.userdata = child->getAttr("userdata");
	      
			if (child->haveAttr("scale"))
				child->getAttr("scale", entry.scale);

			if (child->haveAttr("maxdist"))
				child->getAttr("maxdist", entry.maxdist);

			if (child->haveAttr("minscale"))
				child->getAttr("minscale", entry.minscale);

			if (child->haveAttr("maxscale"))
				child->getAttr("maxscale", entry.maxscale);

			if (child->haveAttr("maxscaledist"))
				child->getAttr("maxscaledist", entry.maxscaledist);

			if (child->haveAttr("attach"))
				child->getAttr("attach", entry.attachToTarget);
	      
			m_particleParams.m_entries.push_back(entry);
    }
  }
  
  SMFXParticleParams::EDirectionType directionType = SMFXParticleParams::eDT_Normal;
	XmlNodeRef dirType = paramsNode->findChild("Direction");
	if (dirType)
	{
		const char *val = dirType->getContent();
		if (!strcmp(val, "Normal"))
		{
			directionType = SMFXParticleParams::eDT_Normal;
		}
		else if (!strcmp(val, "Ricochet"))
		{
			directionType = SMFXParticleParams::eDT_Ricochet;
		}
	}
	m_particleParams.directionType = directionType;
	
}
Example #28
0
void CDownloadableResource::LoadConfig(
	XmlNodeRef				inNode)
{
	XmlString	str;

	inNode->getAttr("port",m_port);
	inNode->getAttr("maxSize",m_maxDownloadSize);

#define ReadXMLStr(key,out)		if (inNode->getAttr(key,str)) { out=str.c_str(); }
	ReadXMLStr("server",m_server);
	ReadXMLStr("name",m_descName);
	ReadXMLStr("prefix",m_urlPrefix);
	if (inNode->getAttr("url",str))
	{
		m_url.Format("%s/%s",k_platformPrefix,str.c_str());
	}
#undef ReadXMLStr
}
//------------------------------------------------------------------------
void CGameRulesHoldObjectiveBase::ReadAudioSignal( const XmlNodeRef node, const char* name, CAudioSignalPlayer* signalPlayer )
{
	if(node->haveAttr(name))
	{
		char signalName[32];
		cry_strcpy(signalName, node->getAttr(name));
		signalPlayer->SetSignal(signalName);
	}
}
Example #30
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;
			}
		}
	}
}