コード例 #1
0
ファイル: StringUtils.cpp プロジェクト: AiYong/CryGame
//---------------------------------------------------------------------
void StrToWstr(const char* str, wstring& dstr)
{
	CryStackStringT<wchar_t, 64> tmp;
	tmp.resize(strlen(str));
	tmp.clear();

	while (const wchar_t c=(wchar_t)(*str++))
	{
		tmp.append(1, c);
	}

	dstr.assign(tmp.data(), tmp.length());
}
コード例 #2
0
ファイル: AntiCheatManager.cpp プロジェクト: aronarts/FireNET
void CAntiCheatManager::InitSession()
{
	OpenLogFile();

	const char * pSessionName = NULL;
	char sessionID[CRYSESSIONID_STRINGLEN];
	sessionID[0] = 0;
	
	if(CGameLobby * pGameLobby = g_pGame->GetGameLobby())
	{
		pSessionName = pGameLobby->GetSessionName();
		if (pSessionName && pSessionName[0]==0)
			pSessionName=NULL;
		pGameLobby->GetSessionIDAsString(sessionID, CRYSESSIONID_STRINGLEN);
	} 

	//This can't be logged via the cleaner XML method as we need to open the tag now, and close it later on, without leaving everything in memory the whole time
	CryStackStringT<char, 512> sessionStartTag;

	const char * pTelemetrySessionName = NULL;

	if(ITelemetryCollector * pTelemetryCollector = g_pGame->GetITelemetryCollector())
	{
		pTelemetrySessionName = pTelemetryCollector->GetSessionId().c_str();
	}

	sessionStartTag.Format("<Session name=\"%s\" telemetry_name=\"%s\" id=\"%s\">\n", pSessionName ? pSessionName : "UNKNOWN", pTelemetrySessionName ? pTelemetrySessionName : "UNKNOWN", sessionID[0] ? sessionID : "UNKNOWN");

	if (m_pLogFile)
	{
		gEnv->pCryPak->FWrite(sessionStartTag.c_str(), 1, sessionStartTag.length(), m_pLogFile);
	}

	if(CGameRules * pGameRules = g_pGame->GetGameRules())
	{
		XmlNodeRef sessionGameInfo = GetISystem()->CreateXmlNode("GameInfo");

		ILevel * pLevel = g_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel();

		sessionGameInfo->setAttr("map",				pLevel->GetLevelInfo()->GetName());
		sessionGameInfo->setAttr("gamemode",	CGameRules::S_GetGameModeNamesArray()[pGameRules->GetGameMode()]);

		CheatLogInternalXml(sessionGameInfo);
	}
}