void CGameQueryListener::ConnectToServer(const char* server)
{
	//first check the version of the server ...
	char myVersion[32];
	GetISystem()->GetProductVersion().ToShortString(myVersion);
	string version(myVersion);

	SGameServer* targetServer = FindServer(server);
	if(!targetServer)
	{
		CryWarning(VALIDATOR_MODULE_NETWORK, VALIDATOR_WARNING, "Selected server not found in list!");
		return;
	}

	if(version.compare(targetServer->GetServerGameVersion()) != 0)
	{
		CryWarning(VALIDATOR_MODULE_NETWORK, VALIDATOR_WARNING, "Game versions differ - not connecting!");
		return;
	}

	string addr(server);
	string port;
	int pos = addr.find(":");
	if(pos != string::npos)	//space for port
	{
		port = addr.substr(pos+1, addr.size()-pos);
		addr.erase(pos, addr.size()-pos);
	}

	IConsole* pConsole = gEnv->pConsole;

	pConsole->GetCVar("cl_serveraddr")->Set(addr.c_str());
	if(port.size() > 0)
		pConsole->GetCVar("cl_serverport")->Set(port.c_str());

	string tempHost = pConsole->GetCVar("cl_serveraddr")->GetString();

	SGameStartParams params;	//this would connect to a server
	params.flags = eGSF_Client;
	params.hostname = tempHost.c_str();
	params.pContextParams = NULL;
	params.port = pConsole->GetCVar("cl_serverport")->GetIVal();

	CCryAction *action = (CCryAction*) (gEnv->pGame->GetIGameFramework());
	if(action)
	{
		gEnv->pConsole->ExecuteString("net_lanbrowser 0");
		action->StartGameContext(&params);
	}
}
CTargetTrackThreatModifier::CTargetTrackThreatModifier()
{
	ITargetTrackManager *pTargetTrackManager = gEnv->pAISystem->GetTargetTrackManager();
	if (pTargetTrackManager)
		pTargetTrackManager->SetTargetTrackThreatModifier(this);

	IConsole *pConsole = gEnv->pConsole;
	assert(pConsole);

	m_pCVar_CloakMinDist = pConsole->GetCVar("ai_CloakMinDist");
	m_pCVar_CloakMaxDist = pConsole->GetCVar("ai_CloakMaxDist");
	m_pCVar_SOMSpeedRelaxed = pConsole->GetCVar("ai_SOMSpeedRelaxed");
	m_pCVar_SOMSpeedCombat = pConsole->GetCVar("ai_SOMSpeedCombat");
}
Esempio n. 3
0
//--------------------------------------------------------------------------------------------------
// Name: CBreakableGlassSystem
// Desc: Constructor
//--------------------------------------------------------------------------------------------------
CBreakableGlassSystem::CBreakableGlassSystem()
: m_enabled(false)
{
	// Add physics callback
	if (IPhysicalWorld* pPhysWorld = gEnv->pPhysicalWorld)
	{
		const float listenerPriority = 2001.0f;
		pPhysWorld->AddEventClient(EventPhysCollision::id, &CBreakableGlassSystem::HandleImpact, 1, listenerPriority);
	}

	// Hook up debug cvars
	if (m_pGlassCVars = new SBreakableGlassCVars())
	{
#ifdef GLASS_DEBUG_MODE
		// Rendering
		REGISTER_CVAR2("g_glassSystem_draw",								&m_pGlassCVars->m_draw,						1,			VF_CHEAT,	"Toggles drawing of glass nodes");
		REGISTER_CVAR2("g_glassSystem_drawWireframe",				&m_pGlassCVars->m_drawWireframe,	0,			VF_CHEAT,	"Toggles drawing of glass node wireframe");
		REGISTER_CVAR2("g_glassSystem_drawDebugData",				&m_pGlassCVars->m_drawDebugData,	0,			VF_CHEAT,	"Toggles drawing of glass node break/impact data");
		REGISTER_CVAR2("g_glassSystem_drawFragData",				&m_pGlassCVars->m_drawFragData,		0,			VF_CHEAT,	"Toggles drawing of glass physicalized fragment data");

		// Impact decals
		REGISTER_CVAR2("g_glassSystem_decalAlwaysRebuild",	&m_pGlassCVars->m_decalAlwaysRebuild,	0,			VF_CHEAT,	"Forces decals to rebuild every frame, allowing real-time tweaking.");
		REGISTER_CVAR2("g_glassSystem_decalScale",					&m_pGlassCVars->m_decalScale,					2.5f,		VF_CHEAT,	"Scale of procedural impact decals on glass");
		REGISTER_CVAR2("g_glassSystem_decalMinRadius",			&m_pGlassCVars->m_decalMinRadius,			0.25f,	VF_CHEAT,	"Minimum size of decal around impact");	
		REGISTER_CVAR2("g_glassSystem_decalMaxRadius",			&m_pGlassCVars->m_decalMaxRadius,			1.25f,	VF_CHEAT,	"Maximum size of decal around impact");
		REGISTER_CVAR2("g_glassSystem_decalRandChance",			&m_pGlassCVars->m_decalRandChance,		0.67f,	VF_CHEAT,	"Chance for a decal to randomly be scaled up");
		REGISTER_CVAR2("g_glassSystem_decalRandScale",			&m_pGlassCVars->m_decalRandScale,			1.6f,		VF_CHEAT,	"Scale of decal if selected randomly");
		REGISTER_CVAR2("g_glassSystem_decalMinImpactSpeed", &m_pGlassCVars->m_minImpactSpeed,			400.0f,	VF_CHEAT,	"Minimum speed for an impact to use the bullet decal");

		// Physicalized fragments
		REGISTER_CVAR2("g_glassSystem_fragImpulseScale",			&m_pGlassCVars->m_fragImpulseScale,			5.0f,	VF_CHEAT,	"Scales impulse applied to fragments when physicalized");
		REGISTER_CVAR2("g_glassSystem_fragAngImpulseScale",		&m_pGlassCVars->m_fragAngImpulseScale,	0.1f,	VF_CHEAT,	"Scales *angular* impulse applied to fragments when physicalized");
		REGISTER_CVAR2("g_glassSystem_fragImpulseDampen",			&m_pGlassCVars->m_fragImpulseDampen,		0.3f,	VF_CHEAT,	"Dampens impulse applied to non-directly impacted fragments");
		REGISTER_CVAR2("g_glassSystem_fragAngImpulseDampen",	&m_pGlassCVars->m_fragAngImpulseDampen,	0.4f,	VF_CHEAT,	"Dampens *angular* impulse applied to non-directly impacted fragments");
		REGISTER_CVAR2("g_glassSystem_fragSpread",						&m_pGlassCVars->m_fragSpread,						1.5f,	VF_CHEAT,	"Spread velocity to apply to impacted fragments");
		REGISTER_CVAR2("g_glassSystem_fragMaxSpeed",					&m_pGlassCVars->m_fragMaxSpeed,					4.0f,	VF_CHEAT,	"Maximum speed to apply to physicalized fragments");

		// Impact breaks
		REGISTER_CVAR2("g_glassSystem_impactSplitMinRadius",	&m_pGlassCVars->m_impactSplitMinRadius,	0.05f,	VF_CHEAT,	"Minimum radius for split around impact");
		REGISTER_CVAR2("g_glassSystem_impactSplitRandMin",		&m_pGlassCVars->m_impactSplitRandMin,		0.5f,		VF_CHEAT,	"Minimum radius variation for split around impact");
		REGISTER_CVAR2("g_glassSystem_impactSplitRandMax",		&m_pGlassCVars->m_impactSplitRandMax,		1.5f,		VF_CHEAT,	"Maximum radius variation for split around impact");
		REGISTER_CVAR2("g_glassSystem_impactEdgeFadeScale",		&m_pGlassCVars->m_impactEdgeFadeScale,	2.0f,		VF_CHEAT,	"Scales radial crack fade distance");

		// Particle effects
		REGISTER_CVAR2("g_glassSystem_particleFXEnable",			&m_pGlassCVars->m_particleFXEnable,			1,			VF_CHEAT,	"Toggles particle effects being played when fragments are broken");
		REGISTER_CVAR2("g_glassSystem_particleFXUseColours",	&m_pGlassCVars->m_particleFXUseColours,	0,			VF_CHEAT,	"Toggles particle effects being coloured to match the glass");
		REGISTER_CVAR2("g_glassSystem_particleFXScale",				&m_pGlassCVars->m_particleFXScale,			0.25f,	VF_CHEAT,	"Scales the glass particle effects spawned");
#endif // GLASS_DEBUG_MODE
	}

	// Add callback for system enabled cvar
	IConsole* pConsole = gEnv->pConsole;
	ICVar* pSysEnabledCvar = pConsole ? pConsole->GetCVar("g_glassSystemEnable") : NULL;

	if (pSysEnabledCvar)
	{
		m_enabled = (pSysEnabledCvar->GetIVal() != 0);
		pSysEnabledCvar->SetOnChangeCallback(OnEnabledCVarChange);
	}
}//-------------------------------------------------------------------------------------------------
void CEditorGame::SetGameRules()
{
	IGameFramework *pGameFramework = g_pGame->GetIGameFramework();
	IConsole *pConsole = gEnv->pConsole;
	const char *szGameRules = NULL;
	const char *szLevelName = pConsole->GetCVar("sv_map")->GetString();
	ILevelInfo *pLevelInfo = pGameFramework->GetILevelSystem()->GetLevelInfo(szLevelName);

	if (pLevelInfo)
	{
		szGameRules = pLevelInfo->GetDefaultGameRules();
	}

	if (!szGameRules)
	{
		szGameRules = s_pEditorGame->m_bUsingMultiplayerGameRules ? "DeathMatch" : "SinglePlayer";
	}

	pGameFramework->GetIGameRulesSystem()->CreateGameRules(szGameRules);
	pConsole->GetCVar("sv_gamerules")->Set(szGameRules);
}
Esempio n. 5
0
//--------------------------------------------------------------------------------------------------
// Name: ~CBreakableGlassSystem
// Desc: Destructor
//--------------------------------------------------------------------------------------------------
CBreakableGlassSystem::~CBreakableGlassSystem()
{
	// Release all nodes and data
	ResetAll();

#ifdef GLASS_DEBUG_MODE
	// Remove debug cvars after all nodes that could be using them
	if (IConsole* pConsole = gEnv->pConsole)
	{
		pConsole->UnregisterVariable("g_glassSystem_draw");
		pConsole->UnregisterVariable("g_glassSystem_drawWireframe");
		pConsole->UnregisterVariable("g_glassSystem_drawDebugData");
		pConsole->UnregisterVariable("g_glassSystem_drawFragData");

		pConsole->UnregisterVariable("g_glassSystem_decalAlwaysRebuild");
		pConsole->UnregisterVariable("g_glassSystem_decalScale");
		pConsole->UnregisterVariable("g_glassSystem_decalMinRadius");
		pConsole->UnregisterVariable("g_glassSystem_decalMaxRadius");
		pConsole->UnregisterVariable("g_glassSystem_decalRandChance");
		pConsole->UnregisterVariable("g_glassSystem_decalRandScale");
		pConsole->UnregisterVariable("g_glassSystem_decalMinImpactSpeed");

		pConsole->UnregisterVariable("g_glassSystem_fragImpulseScale");
		pConsole->UnregisterVariable("g_glassSystem_fragAngImpulseScale");	
		pConsole->UnregisterVariable("g_glassSystem_fragImpulseDampen");
		pConsole->UnregisterVariable("g_glassSystem_fragAngImpulseDampen");
		pConsole->UnregisterVariable("g_glassSystem_fragSpread");
		pConsole->UnregisterVariable("g_glassSystem_fragMaxSpeed");

		pConsole->UnregisterVariable("g_glassSystem_particleFXEnable");
		pConsole->UnregisterVariable("g_glassSystem_particleFXUseColours");
		pConsole->UnregisterVariable("g_glassSystem_particleFXScale");
	}
#endif // GLASS_DEBUG_MODE

	SAFE_DELETE(m_pGlassCVars);

	// Remove system enabled cvar callback
	IConsole* pConsole = gEnv->pConsole;
	ICVar* pSysEnabledCVar = pConsole ? pConsole->GetCVar("g_glassSystemEnable") : NULL;

	if (pSysEnabledCVar)
	{
		pSysEnabledCVar->SetOnChangeCallback(NULL);
	}

	// Remove physics callback
	if (IPhysicalWorld* pPhysWorld = gEnv->pPhysicalWorld)
	{
		pPhysWorld->RemoveEventClient(EventPhysCollision::id, &CBreakableGlassSystem::HandleImpact, 1);
	}
}//-------------------------------------------------------------------------------------------------