Ejemplo n.º 1
0
SMMChosenSessionEvent::SMMChosenSessionEvent( const char* name, CrySessionID id, const char* rulesDescription, bool created, int32 searchID, bool primary  )
{
	cry_strncpy( m_sessionName, name, sizeof(m_sessionName) );
	cry_strncpy( m_rulesDescription, rulesDescription, sizeof(m_rulesDescription) );
	id->AsCStr( m_sessionID, sizeof(m_sessionID) );

	m_created = created;
	m_primary = primary;
	m_searchID = searchID;

	size = sizeof( SMMChosenSessionEvent );
	type = eMMTelE_ChosenSession;
}
Ejemplo n.º 2
0
//----------------------------------------------------------
const char * CSingleAllocTextBlock::StoreText(const char * textIn, bool doDuplicateCheck)
{
	const char * reply = NULL;

	if (textIn)
	{
		reply = doDuplicateCheck ? FindDuplicate(textIn) : NULL;
		if (reply == NULL)
		{
			CRY_ASSERT_MESSAGE(m_mem != NULL, "No memory has been allocated!");
			if (cry_strncpy(m_mem + m_numBytesUsed, textIn, m_sizeNeeded - m_numBytesUsed))
			{
				reply = m_mem + m_numBytesUsed;
				m_numBytesUsed += strlen(reply) + 1;
				if (doDuplicateCheck)
				{
					RememberPossibleDuplicate(reply);
				}
			}
#ifndef _RELEASE
			else
			{
				GameWarning("Tried to store too much text in a single-alloc text block of size %" PRISIZE_T " (%" PRISIZE_T " bytes have already been used, no room for '%s')", m_sizeNeeded, m_numBytesUsed, textIn);
			}
#endif
		}
		SingleAllocTextBlockLog ("Storing a copy of '%s', now used %u/%u bytes, %u bytes left", textIn, m_numBytesUsed, m_sizeNeeded, m_sizeNeeded - m_numBytesUsed);
	}

	CRY_ASSERT_TRACE (m_numBytesUsed <= m_sizeNeeded, ("Counters have been set to invalid values! Apparently used %d/%d bytes!", m_numBytesUsed, m_sizeNeeded));

	return reply;
}
Ejemplo n.º 3
0
SMMGenericLogEvent::SMMGenericLogEvent( const char* pMessage, bool isError )
{
	cry_strncpy( m_message, pMessage, sizeof(m_message) );
	m_bError = isError;

	size = sizeof( SMMGenericLogEvent );
	type = eMMTelE_GenericLog;
}
Ejemplo n.º 4
0
SMMNoServerSelectedEvent::SMMNoServerSelectedEvent( const char* reason, int32 searchID )
{
	cry_strncpy( m_reason, reason, sizeof(m_reason) );
	m_searchID = searchID;

	size = sizeof( SMMNoServerSelectedEvent );
	type = eMMTelE_NoServerSelected;
}
Ejemplo n.º 5
0
SMMMigrateCompletedEvent::SMMMigrateCompletedEvent( CryFixedStringT<DISPLAY_NAME_LENGTH>& newServer, CrySessionID& sessionId )
{
	cry_strncpy( m_newServer, newServer.c_str(), sizeof(m_newServer) );
	sessionId->AsCStr( m_newSessionID, sizeof(m_newSessionID) );

	size = sizeof( SMMMigrateCompletedEvent );
	type = eMMTelE_MigrateCompleted;
}
//------------------------------------------------------------------------
void CGameRulesHoldObjectiveBase::ReadAudioSignal( const XmlNodeRef node, const char* name, CAudioSignalPlayer* signalPlayer )
{
	if(node->haveAttr(name))
	{
		const static int k_maxAudioSignalLength = 32;
		char signalName[k_maxAudioSignalLength];
		cry_strncpy(signalName, node->getAttr(name), k_maxAudioSignalLength);
		signalPlayer->SetSignal(signalName);
	}
}
Ejemplo n.º 7
0
void CryWatch3DAdd(const char *text, const Vec3 &posIn, float lifetime, const Vec3 *velocity, float gravity)
{
	if(text && text[0])
	{
		SLingeringWatch3D *slot = & s_lingeringWatch3D[s_lingeringWatch3D_num];
		s_lingeringWatch3D_num = (s_lingeringWatch3D_num + 1) % MAX_LINGERING_WATCH_3D;
		cry_strncpy(slot->m_text, text, sizeof(slot->m_text));
		slot->m_timeLeft = lifetime;
		slot->m_gravity = gravity;
		slot->m_pos = posIn;
		slot->m_vel = velocity ? *velocity : Vec3(0.f, 0.f, 0.f);
	}
};
//---------------------------------------
void CAreaAnnouncer::LoadAnnouncementArea(const IEntity* pEntity, const char* areaName)
{
	TAudioSignalID signal[AREA_ANNOUNCERS];

	stack_string signalName;
	for(int i = 0; i < AREA_ANNOUNCERS; i++)
	{
		signalName.Format("%s_%d", areaName, i + 1);
		signal[i] = g_pGame->GetGameAudio()->GetSignalID(signalName.c_str(), false);
	}

#if !defined(_RELEASE)
	if(aa_debug)
	{
		CryLogAlways("[AA] Found area '%s' with Signals %d, %d", areaName, signal[0], signal[1]);
	}
#endif

	if(signal[0] != INVALID_AUDIOSIGNAL_ID && signal[1] != INVALID_AUDIOSIGNAL_ID)
	{
		SAnnouncementArea area;
		area.m_areaProxyId = pEntity->GetId();
		COMPILE_TIME_ASSERT(sizeof(area.m_signal) == sizeof(signal));
		memcpy(area.m_signal, signal, sizeof(area.m_signal));

#if !defined(_RELEASE)
		cry_strncpy(&area.m_name[0], areaName, SAnnouncementArea::k_maxNameLength);
#endif

		DesignerWarning(m_areaList.size() < k_maxAnnouncementAreas, "Too many AreaAnnouncer area boxes loaded");
		if(m_areaList.size() < k_maxAnnouncementAreas)
		{
			m_areaList.push_back(area);
		}
	}

#if !defined(_RELEASE)
	//Found one signal but not both
	if(signal[0] != signal[1] && (signal[0] == INVALID_AUDIOSIGNAL_ID || signal[1] == INVALID_AUDIOSIGNAL_ID))
	{
#if defined(USER_benp)
		CRY_ASSERT_MESSAGE(0, ("'%s' only has signal for 1 team!", areaName));
#endif
		CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "'%s' only has signal for 1 team!", areaName);
	}
#endif

}
Ejemplo n.º 9
0
SMMFoundSessionEvent::SMMFoundSessionEvent( SCrySessionSearchResult* pSession, uint16 sessionStatus, int rankDiff, int32 region, int32 language, bool isBadServer, float score )
{
	cry_strncpy( m_sessionName, pSession->m_data.m_name, sizeof(m_sessionName) );

	pSession->m_id->AsCStr( m_sessionID, sizeof(m_sessionID) );

	m_ping = pSession->m_ping;
	m_filledSlots = pSession->m_numFilledSlots;
	m_status = sessionStatus;
	m_rankDiff = rankDiff;
	m_badServer = isBadServer;
	m_score = score;
	m_region = region;
	m_language = language;

	size = sizeof( SMMFoundSessionEvent );
	type = eMMTelE_FoundSession;
}
Ejemplo n.º 10
0
void CGameBrowser::ConfigurationCallback(ECryLobbyService service, SConfigurationParams *requestedParams, uint32 paramCount)
{
	uint32 a;
	for (a=0;a<paramCount;a++)
	{
		switch (requestedParams[a].m_fourCCID)
		{
		case CLCC_LAN_USER_NAME:
			{
				IPlayerProfileManager *pPlayerProfileManager = gEnv->pGame->GetIGameFramework()->GetIPlayerProfileManager();
				uint32 userIndex = pPlayerProfileManager ? pPlayerProfileManager->GetExclusiveControllerDeviceIndex() : 0;

				IPlatformOS *pPlatformOS = gEnv->pSystem->GetPlatformOS();
				IPlatformOS::TUserName tUserName = "";
				if(pPlatformOS)
				{
					pPlatformOS->UserGetName(userIndex, tUserName);
				}
			
				// this will null terminate for us if necessary	
				cry_strncpy(s_profileName, tUserName.c_str(), CRYLOBBY_USER_NAME_LENGTH);

				requestedParams[a].m_pData = s_profileName;
			}
			break;

#if defined(PS3) || USE_CRYLOBBY_GAMESPY
		case CLCC_CRYLOBBY_PRESENCE_CONVERTER:
			{
				SCryLobbyPresenceConverter* pConverter = (SCryLobbyPresenceConverter*)requestedParams[a].m_pData;
				if (pConverter)
				{
					//-- Use the pConverter->m_numData data items in pConverter->m_pData to create a string in pConverter->m_pStringBuffer
					//-- Use the initial value of pConverter->sizeOfStringBuffer as a maximum string length allowed, but
					//-- update pConverter->sizeOfStringBuffer to the correct length when the string is filled in.
					//-- Set pConverter->sizeOfStringBuffer = 0 to invalidate bad data so it isn't sent to PSN.
					CryFixedStringT<MAX_PRESENCE_STRING_SIZE> strPresence;
					if(CreatePresenceString(strPresence, pConverter->m_pData, pConverter->m_numData))
					{
						CryLog("[RichPresence] Succeeded %s", strPresence.c_str());
						sprintf((char*)pConverter->m_pStringBuffer, "%s", strPresence.c_str());
						pConverter->m_sizeOfStringBuffer = strlen((char*)pConverter->m_pStringBuffer);









					}
					else
					{
						CryLog("[RichPresence] Failed to create rich presence string");
						pConverter->m_sizeOfStringBuffer = 0;
					}
				}
			}
			break;
#endif

#if USE_CRYLOBBY_GAMESPY
			// The following GameSpy data are always available.

		case CLCC_GAMESPY_TITLE:
			requestedParams[ a ].m_pData = ObfuscateGameSpyTitle();
			break;
		case CLCC_GAMESPY_SECRETKEY:
			requestedParams[ a ].m_pData = ObfuscateGameSpySecretKey();
			break;
		case CLCC_GAMESPY_GAMEVERSION:
			requestedParams[ a ].m_32 = GameLobbyData::GetVersion();
			break;
		case CLCC_GAMESPY_GAMEVERSIONSTRING:
			requestedParams[ a ].m_pData = ( void* )GAMESPY_GAMEVERSIONSTRING;
			break;
		case CLCC_GAMESPY_DISTRIBUTIONID:
			requestedParams[ a ].m_32 = GAMESPY_DISTRIBUTIONID;
			break;
		case CLCC_GAMESPY_PRODUCTID:
			requestedParams[ a ].m_32 = GAMESPY_PRODUCTID;
			break;
		case CLCC_GAMESPY_GAMEID:
			requestedParams[ a ].m_32 = GAMESPY_GAMEID;
			break;
		case CLCC_GAMESPY_NAMESPACEID:
			requestedParams[ a ].m_32 = GAMESPY_NAMESPACEID;
			break;
		case CLCC_GAMESPY_PARTNERID:
			requestedParams[ a ].m_32 = GAMESPY_PARTNERID;
			break;
		case CLCC_GAMESPY_REQUIREDNICK:
			requestedParams[ a ].m_pData = GAMESPY_REQUIREDNICK;
			break;
		case CLCC_GAMESPY_D2GCATALOGREGION:
			if ( g_pGameCVars )
			{
				requestedParams[a].m_pData = ( void* )g_pGameCVars->g_gamespy_catalog_region;
			}
			else
			{
				requestedParams[a].m_pData = NULL;
			}
			break;
		case CLCC_GAMESPY_D2GCATALOGVERSION:
			if ( g_pGameCVars )
			{
				requestedParams[a].m_32 = g_pGameCVars->g_gamespy_catalog_version->GetIVal();
			}
			else
			{
				requestedParams[a].m_32 = 0;
			}
			break;
		case CLCC_GAMESPY_D2GCATALOGTOKEN:
			if ( g_pGameCVars )
			{
				requestedParams[a].m_pData = ( void* )g_pGameCVars->g_gamespy_catalog_token;
			}
			else
			{
				requestedParams[a].m_pData = 0;
			}
			break;

			// CLCC_CRYLOBBY_LOGINGUISTATE is common to all online services for
			// which login is not handled by the OS. It will be requested if any
			// other requested data may require a login GUI to be displayed.

		case CLCC_CRYLOBBY_LOGINGUISTATE:
			//CRY_TODO( 30, 4, 2010, "Display a real GUI, don't use these hard coded values" );
			if ( g_pGameCVars )
			{
				ECryLobbyLoginGUIState requestedGUIState = eCLLGS_ExistingAccount;//eCLLGS_NotFinished;
				
				if(gEnv->IsDedicated() || g_pGameCVars->g_gamespy_loginUI==0)
				{
					requestedGUIState = eCLLGS_ExistingAccount;
				}
				else if(g_pGame->GetGameBrowser())
				{
				//	requestedGUIState = g_pGame->GetGameBrowser()->GetLoginGUIState();
				}

				requestedParams[ a ].m_32 = requestedGUIState;
			}
			else
			{
				requestedParams[ a ].m_32 = eCLLGS_Cancelled;
			}
			break;

		case CLCC_CRYLOBBY_LOGINGUICOUNT:
			if ( g_pGameCVars )
			{
				requestedParams[ a ].m_32 = 0;//g_pGameCVars->g_gamespy_loginCount;
			}
			else
			{
				requestedParams[ a ].m_32 = 0;
			}
			break;

			// The following GameSpy data may require a login GUI to be displayed.

		case CLCC_GAMESPY_EMAIL:
			if ( g_pGameCVars )
			{
				string email = "crysis2.";
				email.append(g_pGameCVars->g_gamespy_accountnumber->GetString());
				email.append("*****@*****.**");
				requestedParams[a].m_pData = (void*)email.c_str();//(void*)g_pGameCVars->g_gamespy_email->GetString();
			}
			else
			{
				requestedParams[a].m_pData = NULL;
			}
			break;
		case CLCC_GAMESPY_UNIQUENICK:
			if ( g_pGameCVars )
			{
				string nick = "crysis2_";
				nick.append(g_pGameCVars->g_gamespy_accountnumber->GetString());
				nick.append("_paulm");
				requestedParams[a].m_pData = (void*)nick.c_str();//(void*)g_pGameCVars->g_gamespy_unique_nick->GetString();
			}
			else
			{
				requestedParams[a].m_pData = NULL;
			}
			break;
		case CLCC_GAMESPY_PASSWORD:
			if ( g_pGameCVars )
			{
				requestedParams[a].m_pData = "upple?9!";//(void*)g_pGameCVars->g_gamespy_password->GetString();
			}
			else
			{
				requestedParams[a].m_pData = NULL;
			}
			break;
		case CLCC_GAMESPY_CDKEY:
			if ( g_pGameCVars )
			{
				requestedParams[a].m_pData = (void*)g_pGameCVars->g_gamespy_cdkey->GetString();
			}
			else
			{
				requestedParams[a].m_pData = NULL;
			}
			break;

		case CLCC_GAMESPY_KEYNAME:

			// Session user data IDs map to GameSpy keys, which must be named.
			// CLCC_GAMESPY_KEYNAME will be requested for each session user data ID
			// greater than or equal to NUM_RESERVED_KEYS.
			//
			// IN:	requestedParams[ a ].m_8 holds a session user data ID.
			// OUT:	requestedParams[ a ].m_pData holds the GameSpy key name.
			//
			// NOTE: m_8 and m_pData are members of a union, so setting m_pData
			// will overwrite m_8.

			switch ( requestedParams[ a ].m_8 )
			{
			case LID_MATCHDATA_GAMEMODE:

				requestedParams[ a ].m_pData = GAMESPY_KEYNAME_MATCHDATA_GAMEMODE;
				break;

			case LID_MATCHDATA_MAP:

				requestedParams[ a ].m_pData = GAMESPY_KEYNAME_MATCHDATA_MAP;
				break;

			case LID_MATCHDATA_ACTIVE:

				requestedParams[ a ].m_pData = GAMESPY_KEYNAME_MATCHDATA_ACTIVE;
				break;

			case LID_MATCHDATA_VERSION:

				requestedParams[ a ].m_pData = GAMESPY_KEYNAME_MATCHDATA_VERSION;
				break;

			case LID_MATCHDATA_REQUIRED_DLCS:

				requestedParams[ a ].m_pData = GAMESPY_KEYNAME_MATCHDATA_REQUIRED_DLCS;
				break;

			case LID_MATCHDATA_PLAYLIST:

				requestedParams[ a ].m_pData = GAMESPY_KEYNAME_MATCHDATA_PLAYLIST;
				break;

			case LID_MATCHDATA_LANGUAGE:

				requestedParams[ a ].m_pData = GAMESPY_KEYNAME_MATCHDATA_LANGUAGE;
				break;

			case LID_MATCHDATA_OFFICIAL:

				requestedParams[ a ].m_pData = GAMESPY_KEYNAME_MATCHDATA_OFFICIAL;
				break;

			case LID_MATCHDATA_FAVOURITE_ID:

				requestedParams[ a ].m_pData = GAMESPY_KEYNAME_MATCHDATA_FAVOURITE_ID;
				break;

			default:

				CRY_ASSERT_MESSAGE( 0, "Session user data ID has no GameSpy key name" );
				requestedParams[ a ].m_pData = NULL;
				break;
			}

			break;

		case CLCC_GAMESPY_KEYSTRINGVALUE:

			{
				SCryLobbyUserDataStringParam*	pParam = static_cast< SCryLobbyUserDataStringParam* >( requestedParams[ a ].m_pData );

				switch ( pParam->id )
				{
				case LID_MATCHDATA_MAP:
					requestedParams[ a ].m_pData = const_cast< void* >( static_cast< const void* >( GameLobbyData::GetMapFromHash( pParam->value ) ) );
					break;
				case LID_MATCHDATA_GAMEMODE:
					requestedParams[ a ].m_pData = const_cast< void* >( static_cast< const void* >( GameLobbyData::GetGameRulesFromHash( pParam->value ) ) );
					break;
				default:
					requestedParams[ a ].m_pData = NULL;
					break;
				}
			}

			break;

		case CLCC_GAMESPY_P2PLEADERBOARDFMT:

			requestedParams[a].m_pData = ( void* )GAMESPY_P2P_LEADERBOARD_FORMAT;
			break;

		case CLCC_GAMESPY_DEDICATEDLEADERBOARDFMT:

			requestedParams[a].m_pData = ( void* )GAMESPY_DEDICATED_LEADERBOARD_FORMAT;
			break;

		case CLCC_GAMESPY_P2PSTATSTABLE:

			requestedParams[a].m_pData = ( void* )GAMESPY_P2P_STATS_TABLE;
			break;

		case CLCC_GAMESPY_DEDICATEDSTATSTABLE:

			requestedParams[a].m_pData = ( void* )GAMESPY_DEDICATED_STATS_TABLE;
			break;

		case CLCC_GAMESPY_TITLECDKEYSERVER:

			requestedParams[a].m_32 = 1;
			break;

#if defined( DEDICATED_SERVER )
		case CLCC_GAMESPY_DEDIVERSION:

			requestedParams[a].m_32 = GAMESPY_DEDI_VERSION;
			break;
#endif

#if USE_CRYLOBBY_GAMESPY_VOIP
		case CLCC_GAMESPY_VOICE_CODEC:
			requestedParams[a].m_pData = (void*)CCryGameSpyVoiceCodec::Initialise();
			break;
#endif // USE_CRYLOBBY_GAMESPY_VOIP
#endif // USE_CRYLOBBY_GAMESPY































































































































		case CLCC_MATCHMAKING_SESSION_PASSWORD_MAX_LENGTH:
			requestedParams[a].m_8 = MATCHMAKING_SESSION_PASSWORD_MAX_LENGTH;
			break;

		default:
			CRY_ASSERT_MESSAGE(0,"Unknown Configuration Parameter Requested!");
			break;
		}
	}
}
Ejemplo n.º 11
0
void CAutoTester::Start(const char *stateSetup, const char *outputPath, bool quitWhenDone)
{
	// If the string has any '#' characters in it (the "new" seperator) then we'll split the string up at those characters...
	// If not, we'll use '!' (the "old" seperator)
	char breakAtChar = strchr(stateSetup, '#') ? '#' : '!';

	CryLogAlways("CAutoTester::Start() stateSetup=\"%s\" outputPath=\"%s\" seperator=\"%c\"", stateSetup, outputPath, breakAtChar);
	assert(!m_started);
	m_started=true;
	
	m_outputPath=outputPath;
	m_quitWhenDone = quitWhenDone;

	const char *str=stateSetup;

	// .dll hell stops simple access to memReplay functionality so can't look for running -memReplay
	// memReplay commands all early exit if they fail anyways
	gEnv->pConsole->ExecuteString("memReplayDumpSymbols");

#define MAX_TOKEN_LEN 128

	char tokenName[MAX_TOKEN_LEN];
	char valueName[MAX_TOKEN_LEN];
	bool success;

	memset(&m_stateData, 0, sizeof(m_stateData));

	success = GetParam(&str, tokenName, MAX_TOKEN_LEN, valueName, MAX_TOKEN_LEN, breakAtChar);

	assert (m_state == ATEST_STATE_NONE);

	if (success && stricmp(tokenName, "state") == 0)
	{
		m_state = FindStateFromStr(valueName);
		cry_strncpy(m_includeThisInFileName, valueName, sizeof(m_includeThisInFileName));

		CryLogAlways("CAutoTester::Start initializing state (name='%s', id=%d, %s)", valueName, m_state, (m_state == ATEST_STATE_NONE) ? "invalid" : "valid");
		DesignerWarning (m_state != ATEST_STATE_NONE, "'%s' is not the name of an auto-test state", valueName);

		// If anything needs to default to something non-zero, set it here... 
		switch (m_state)
		{
			case ATEST_STATE_TEST_PERFORMANCE:
				m_stateData.testPerformance.m_subState = CAutoTester::k_testPerformance_substate_ingame;
				break;
		}

		// Read each parameter...
		while (GetParam(&str, tokenName, MAX_TOKEN_LEN, valueName, MAX_TOKEN_LEN, breakAtChar))
		{
			bool paramUsed = false;

			if (stricmp(tokenName, "outputName") == 0)
			{
				cry_strncpy(m_includeThisInFileName, valueName, sizeof(m_includeThisInFileName));
				CryLogAlways("CAutoTester::Start has set output name to '%s'", m_includeThisInFileName);
				m_createVerboseFilename=false;
				paramUsed = true;
			}
			else
			{
				switch (m_state)
				{
				case ATEST_STATE_TEST_NUM_CLIENTS:
					if (stricmp(tokenName, "timeToRun") == 0)
					{
						m_stateData.testNumClients.m_timeOut = (float)atof(valueName);
						paramUsed = true;
					}
					else if (stricmp(tokenName, "numClients") == 0)
					{
						m_stateData.testNumClients.m_numClientsExpected = atoi(valueName);
						paramUsed = true;
					}
					break;

				case ATEST_STATE_TEST_NUM_CLIENTS_LEVEL_ROTATE:
					if (stricmp(tokenName, "timeToRunEachLevel") == 0)
					{
						m_stateData.testNumClientsRotate.m_levelTimeOut = (float)atof(valueName);
						paramUsed = true;
					}
					else if (stricmp(tokenName, "numClients") == 0)
					{
						m_stateData.testNumClientsRotate.m_numClientsExpected = atoi(valueName);
						paramUsed = true;
					}
					else if (stricmp(tokenName, "timeToRunFirstLevel") == 0)
					{														 
						m_stateData.testNumClientsRotate.m_firstLevelTimeOut = (float)atof(valueName);
						paramUsed = true;
					}
					break;

#if ENABLE_FEATURE_TESTER
				case ATEST_STATE_TEST_FEATURES:
					if (stricmp(tokenName, "rules") == 0)
					{
						CryLogAlways ("CAutoTester::Start executing 'sv_gamerules %s'", valueName);
						gEnv->pConsole->ExecuteString(string().Format("sv_gamerules %s", valueName));
						paramUsed = true;
					}
					else if (stricmp(tokenName, "level") == 0)
					{
						IGameRulesSystem * gameRulesSystem = gEnv->pGame->GetIGameFramework()->GetIGameRulesSystem();
						const char * sv_gamerules = gEnv->pConsole->GetCVar("sv_gamerules")->GetString();
						const char * fullGameRulesName = gameRulesSystem->GetGameRulesName(sv_gamerules);
						bool isMultiPlayerMode = (fullGameRulesName && strcmp(fullGameRulesName, "SinglePlayer") != 0);
						const char * additionalParams = isMultiPlayerMode ? " s nb" : "";
						if (gEnv->bMultiplayer != isMultiPlayerMode)
						{
							GameWarning("Auto-tester is loading '%s' in mode '%s' while environment is set up for %s", valueName, sv_gamerules, gEnv->bMultiplayer ? "multi-player" : "single-player");
						}
						CryLogAlways ("CAutoTester::Start executing 'map %s%s' (mode is '%s' i.e. '%s' so isMultiPlayer=%d)", valueName, additionalParams, sv_gamerules, fullGameRulesName, isMultiPlayerMode);
						if (isMultiPlayerMode)
						{
							gEnv->pConsole->ExecuteString("net_setonlinemode lan");
						}
						gEnv->pConsole->ExecuteString(string().Format("map %s%s", valueName, additionalParams));
						paramUsed = true;
					}
					else if (stricmp(tokenName, "set") == 0)
					{
						cry_strncpy(m_stateData.testRunFeatureTests.m_setNames, valueName, sizeof(m_stateData.testRunFeatureTests.m_setNames));
						paramUsed = true;
					}
					else if (stricmp(tokenName, "file") == 0)
					{
						cry_strncpy(m_stateData.testRunFeatureTests.m_loadFileName, valueName, sizeof(m_stateData.testRunFeatureTests.m_loadFileName));
						paramUsed = true;
					}
					break;
#endif

				case ATEST_STATE_TEST_PERFORMANCE:
					if (stricmp(tokenName, "configFile") == 0)
					{
						cry_strncpy(m_stateData.testPerformance.m_configFile, valueName, 256);
						//m_stateData.testPerformance.m_configFile = valueName;
						CryLogAlways ("CAutoTester::Start configFile set '%s'", valueName);
						paramUsed = true;
					}
					else if (stricmp(tokenName, "timeToRun") == 0)
					{
						m_stateData.testPerformance.m_timeOut = (float)atof(valueName);
						paramUsed = true;
					}
					else if (stricmp(tokenName, "delayToStart") == 0)
					{
						m_stateData.testPerformance.m_delayToStart = (float)atof(valueName);
						paramUsed = true;
					}
					break;
				}

				DesignerWarning(paramUsed, "Unexpected key/value pair '%s'='%s' in %s setup string!", tokenName, valueName, s_autoTesterStateNames[m_state]);
			}
		}

		// All parameters have been read... now finish initialization
		switch (m_state)
		{
		case ATEST_STATE_TEST_NUM_CLIENTS_LEVEL_ROTATE:
			{
				if (m_stateData.testNumClientsRotate.m_firstLevelTimeOut == 0)
				{
					CryLogAlways("no timeToRunFirstLevel set, setting to timeToRunEachLevel=%d", (int)m_stateData.testNumClientsRotate.m_levelTimeOut);
					m_stateData.testNumClientsRotate.m_firstLevelTimeOut = m_stateData.testNumClientsRotate.m_levelTimeOut;
				}

				float timeSeconds=gEnv->pTimer->GetFrameStartTime().GetSeconds();
				m_stateData.testNumClientsRotate.m_nextTimeOut = timeSeconds + m_stateData.testNumClientsRotate.m_firstLevelTimeOut;

				// level rotation is setup with +sv_levelrotation levelrotation.xml and also -root to override looking in the profile dir






				gEnv->pConsole->ExecuteString("g_nextlevel");	// has to be a better way of doing this

				break;
			}

		case ATEST_STATE_TEST_FEATURES:
#if ENABLE_FEATURE_TESTER
			m_writeResultsCompleteTestCasePass = true;

			if (m_stateData.testRunFeatureTests.m_loadFileName[0])
			{
				gEnv->pConsole->ExecuteString(string().Format("ft_load %s", m_stateData.testRunFeatureTests.m_loadFileName));
			}

			if (m_stateData.testRunFeatureTests.m_setNames[0])
			{
				CFeatureTester::GetInstance()->InformAutoTesterOfResults(this);
				gEnv->pConsole->ExecuteString(string().Format("ft_runAll %s", m_stateData.testRunFeatureTests.m_setNames));
			}
#else
			DesignerWarning(false, "Feature tester is not included in this build!");
#endif
			break;
		}
	}
	else
	{
		CRY_ASSERT_MESSAGE(0, string().Format("CAutoTester::Start() failed to find state at start in %s", stateSetup));
	}

	// TODO will maybe need to load in the existing file if we want all tests in the same file... junit/bamboo should cope with each test in a different file?
}
Ejemplo n.º 12
0
void CAutoTester::WriteResults(TBitfield flags, const string * additionalTestSuiteName, const XmlNodeRef * additionalTestCase)
{
	const int& autotest_enabled = g_pGameCVars->autotest_enabled;
	if (!autotest_enabled)
	{
		return;
	}

	//If result generation is skipped, exit early
	if (autotest_enabled == 2)
	{
		if (m_quitWhenDone)
		{
			gEnv->pConsole->ExecuteString("quit");
		}

		return;
	}

	// test workaround
	//DesignerWarning(0, "test warning");
	// test workaround

	const char * mapName;
	string gameRulesName;
	const char * serverText = "";
	const char * dedicatedText = gEnv->IsDedicated() ? "_Dedicated" : "";

	CGameRules * rules = g_pGame ? g_pGame->GetGameRules() : NULL;
	if (rules)
	{
		gameRulesName = rules->GetEntity()->GetClass()->GetName();
		serverText = gEnv->bServer ? "_Server" : "_Client";
	}
	else
	{
		gameRulesName = "FrontEnd";
	}

	 if (g_pGame && g_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel())
	 {
		 mapName = g_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel()->GetLevelInfo()->GetName();
	 }
	 else
	 {
		 mapName = "NoMapLoaded";
	 }

#ifndef _RELEASE
	 CryLogAlways ("CAutoTester::WriteResults(%s): map is '%s', game mode is '%s'", AutoEnum_GetStringFromBitfield(flags, s_writeResultsFlagNames, WriteResultsFlagList_numBits).c_str(), mapName, gameRulesName.c_str());
#endif
















	XmlNodeRef testSuites = GetISystem()->CreateXmlNode("testSuites");
	testSuites->setTag("testsuites");

	for (TTestSuites::const_iterator it=m_testSuites.begin(); it!=m_testSuites.end(); ++it)
	{
		const STestSuite &testSuiteStruct = it->second;
		int numTests = testSuiteStruct.m_testCases.size();
		int numFails = testSuiteStruct.m_numTestCasesFailed;

		XmlNodeRef testSuite = GetISystem()->CreateXmlNode("AutoTest");
		testSuite->setTag("testsuite");
		testSuite->setAttr("name", it->first);
		testSuite->setAttr("LevelName", mapName);
		testSuite->setAttr("GameRulesName", gameRulesName);

		if (additionalTestSuiteName && it->first == *additionalTestSuiteName)
		{
			CryLog ("Writing additional test case to existing '%s' suite", additionalTestSuiteName->c_str());
			++ numFails; // Assumption here that any additional test data provided is a failure... [TF]
			++ numTests;
			testSuite->addChild(*additionalTestCase);
			additionalTestSuiteName = NULL;
		}

		testSuite->setAttr("tests", numTests);
		testSuite->setAttr("failures", numFails);
		testSuite->setAttr("errors", 0);
		testSuite->setAttr("time", 0);

		for (size_t i = 0; i < testSuiteStruct.m_testCases.size(); i++)
		{
			testSuite->addChild(testSuiteStruct.m_testCases[i]);
		}

		testSuites->addChild(testSuite);
	}

	if (additionalTestSuiteName) // Still haven't written our additional test case because the suite name didn't match any existing suite...
	{
		CryLog ("CAutoTester writing additional test case to unique '%s' suite", additionalTestSuiteName->c_str());
		XmlNodeRef testSuite = GetISystem()->CreateXmlNode("AutoTest");
		testSuite->setTag("testsuite");
		testSuite->setAttr("name", *additionalTestSuiteName);
		testSuite->setAttr("LevelName", mapName);
		testSuite->setAttr("GameRulesName", gameRulesName);
		testSuite->setAttr("tests", 1);
		testSuite->setAttr("failures", 1);
		testSuite->setAttr("errors", 0);
		testSuite->setAttr("time", 0);
		testSuite->addChild(*additionalTestCase);
		testSuites->addChild(testSuite);
	}

	char mapNameChrs[256];
	char gameRulesNameChrs[256];

	cry_strncpy(mapNameChrs, mapName, sizeof(mapNameChrs));
	cry_strncpy(gameRulesNameChrs, gameRulesName, sizeof(gameRulesNameChrs));

	for (int i=0; mapNameChrs[i]; i++)
	{
		if (mapNameChrs[i] == '/' || mapNameChrs[i] == ' ')
		{
			mapNameChrs[i] = '_'; 
		}
	}

	for (int i=0; gameRulesNameChrs[i]; i++)
	{
		if (gameRulesNameChrs[i] == '/' || gameRulesNameChrs[i] == ' ')
		{
			gameRulesNameChrs[i] = '_';
		}
	}

	const char * resultsCompleteFailMessage = NULL;

	if (flags & kWriteResultsFlag_unfinished)
	{
		resultsCompleteFailMessage = "Didn't finish all tests!";
	}
	else if (m_testSuites.size() == 0)
	{
		resultsCompleteFailMessage = "Ran zero tests!";
	}

	if (resultsCompleteFailMessage || m_writeResultsCompleteTestCasePass)
	{
		int numFailures = 0;
		XmlNodeRef testSuite = GetISystem()->CreateXmlNode("testsuite");
		testSuite->setAttr("name", "Are results complete?");

		XmlNodeRef unfinishedFailure = GetISystem()->CreateXmlNode("testcase");

		if (m_createVerboseFilename)
		{
			unfinishedFailure->setAttr("name", string().Format("%s_%s_%s%s%s", m_includeThisInFileName, mapNameChrs, gameRulesNameChrs, dedicatedText, serverText));
		}
		else
		{
			unfinishedFailure->setAttr("name", string().Format("%s%s", m_includeThisInFileName, dedicatedText));
		}

		if (resultsCompleteFailMessage)
		{
			XmlNodeRef failedCase = GetISystem()->CreateXmlNode("failure");
			failedCase->setAttr("type", "Unfinished");
			failedCase->setAttr("message", resultsCompleteFailMessage);
			unfinishedFailure->addChild(failedCase);
			++ numFailures;
		}
		else
		{
			unfinishedFailure->setAttr("status", "run");
		}

		testSuite->setAttr("tests", 1);
		testSuite->setAttr("errors", 0);
		testSuite->setAttr("time", 0);
		testSuite->setAttr("failures", numFailures);
		testSuite->addChild(unfinishedFailure);

		testSuites->addChild(testSuite);
	}

	string justTheFilename;

	if (m_createVerboseFilename)
	{
		justTheFilename.Format("autotest_%s_%s_%s%s%s.xml", m_includeThisInFileName, mapNameChrs, gameRulesNameChrs, dedicatedText, serverText); // TODO add datestamp if needed
	}
	else
	{
		// If m_createVerboseFilename is false, then only include things in the filename which WON'T CHANGE between the test starting and ending [TF]
		justTheFilename.Format("autotest_%s%s.xml", m_includeThisInFileName, dedicatedText);
	}





	m_outputPath.Format("../Xml-Reports/%s", justTheFilename.c_str());


#ifndef _RELEASE
	CryLogAlways ("Outputting test to %s", m_outputPath.c_str());
#endif

	SaveToValidXmlFile(testSuites, m_outputPath.c_str());

	if (flags & kWriteResultsFlag_writeDoneMarkerFile)
	{
		XmlNodeRef finished = GetISystem()->CreateXmlNode("Finished");
		SaveToValidXmlFile(finished, m_outputPath + ".done");

		if (m_quitWhenDone)
		{
			gEnv->pConsole->ExecuteString("unload");
			gEnv->pConsole->ExecuteString("quit");
		}
	}
}
Ejemplo n.º 13
0
void CGameBrowser::ConfigurationCallback(ECryLobbyService service, SConfigurationParams *requestedParams, uint32 paramCount)
{
	uint32 a;
	for (a=0;a<paramCount;++a)
	{
		switch (requestedParams[a].m_fourCCID)
		{
		case CLCC_LAN_USER_NAME:
			{
				uint32 userIndex = g_pGame->GetExclusiveControllerDeviceIndex();

				IPlatformOS *pPlatformOS = gEnv->pSystem->GetPlatformOS();
				IPlatformOS::TUserName tUserName = "";
				if(pPlatformOS)
				{
					pPlatformOS->UserGetName(userIndex, tUserName);
				}
			
				// this will null terminate for us if necessary	
				cry_strncpy(s_profileName, tUserName.c_str(), CRYLOBBY_USER_NAME_LENGTH);
				int instance = gEnv->pSystem->GetApplicationInstance();
				if (instance>0)
				{
					size_t length = strlen(s_profileName);
					if (length + 3 < CRYLOBBY_USER_NAME_LENGTH)
					{
						s_profileName[length] = '(';
						s_profileName[length+1] = '0' + instance;
						s_profileName[length+2] = ')';
						s_profileName[length+3] = 0;
					}
				}

				requestedParams[a].m_pData = s_profileName;
			}
			break;

#if defined(PS3) || defined(ORBIS) || USE_STEAM
		case CLCC_CRYLOBBY_PRESENCE_CONVERTER:
			{
				SCryLobbyPresenceConverter* pConverter = (SCryLobbyPresenceConverter*)requestedParams[a].m_pData;
				if (pConverter)
				{
					//-- Use the pConverter->m_numData data items in pConverter->m_pData to create a string in pConverter->m_pStringBuffer
					//-- Use the initial value of pConverter->sizeOfStringBuffer as a maximum string length allowed, but
					//-- update pConverter->sizeOfStringBuffer to the correct length when the string is filled in.
					//-- Set pConverter->sizeOfStringBuffer = 0 to invalidate bad data so it isn't sent to PSN.
					CryFixedStringT<MAX_PRESENCE_STRING_SIZE> strPresence;
					if(CreatePresenceString(strPresence, pConverter->m_pData, pConverter->m_numData))
					{
						CryLog("[RichPresence] Succeeded %s", strPresence.c_str());
						sprintf((char*)pConverter->m_pStringBuffer, "%s", strPresence.c_str());
						pConverter->m_sizeOfStringBuffer = strlen((char*)pConverter->m_pStringBuffer);

#if defined(PS3)
						if (g_pGame)
						{
							pConverter->m_sessionId = g_pGame->GetPendingRichPresenceSessionID();
						}
#endif
					}
					else
					{
						CryLog("[RichPresence] Failed to create rich presence string");
						pConverter->m_sizeOfStringBuffer = 0;
					}
				}
			}
			break;
#endif

#if defined(XENON)
		case CLCC_LIVE_TITLE_ID:
			requestedParams[a].m_32 = LIVE_TITLE_ID;
			break;
#endif//XENON

#if defined(PS3)
		case CLCC_PSN_COMMUNICATION_ID:
			requestedParams[a].m_pData = (void*)&s_communication_id;
			break;
		case CLCC_PSN_COMMUNICATION_PASSPHRASE:
			requestedParams[a].m_pData = (void*)&s_communication_passphrase;
			break;
		case CLCC_PSN_COMMUNICATION_SIGNATURE:
			requestedParams[a].m_pData = (void*)&s_communication_signature;
			break;
		case CLCC_PSN_CUSTOM_MENU_GAME_INVITE_STRING:
			GetXMBString("@xmb_invite_button", (SCryLobbyXMBString*)requestedParams[a].m_pData);			// <= SCE_NP_CUSTOM_MENU_ACTION_CHARACTER_MAX (max 21 chars + nul)	
			break;
		case CLCC_PSN_CUSTOM_MENU_GAME_JOIN_STRING:
			GetXMBString("@xmb_join_button", (SCryLobbyXMBString*)requestedParams[a].m_pData);				// <= SCE_NP_CUSTOM_MENU_ACTION_CHARACTER_MAX (max 21 chars + nul)	
			break;
		case CLCC_PSN_INVITE_SUBJECT_STRING:
			GetXMBString("@xmb_invite_sub", (SCryLobbyXMBString*)requestedParams[a].m_pData);					// < SCE_NP_BASIC_SUBJECT_CHARACTER_MAX (max 17 chars + nul)
			break;
		case CLCC_PSN_INVITE_BODY_STRING:
			GetXMBString("@xmb_invite_body", (SCryLobbyXMBString*)requestedParams[a].m_pData);				// < SCE_NP_BASIC_BODY_CHARACTER_MAX (max 511 chars + nul)																
			break;
		case CLCC_PSN_FRIEND_REQUEST_SUBJECT_STRING:
			GetXMBString("@xmb_friendrq_sub", (SCryLobbyXMBString*)requestedParams[a].m_pData);				// < SCE_NP_BASIC_SUBJECT_CHARACTER_MAX (max 17 chars + nul)																
			break;
		case CLCC_PSN_FRIEND_REQUEST_BODY_STRING:
			GetXMBString("@xmb_friendrq_body", (SCryLobbyXMBString*)requestedParams[a].m_pData);			// < SCE_NP_BASIC_BODY_CHARACTER_MAX	(max 511 chars + nul)																
			break;
		case CLCC_PSN_AGE_LIMIT:
			{
				SAgeData *pAgeData = (SAgeData*)requestedParams[a].m_pData;

				int userRegion = (pAgeData->countryCode[0] << 8) + pAgeData->countryCode[1];
				g_pGame->SetUserRegion(userRegion);

				if (strncmp(gPS3Env->sTitleID,"BLES",4)==0)
				{
					if (strncmp(pAgeData->countryCode,"de",2)==0)
					{
						// GERMANY
						requestedParams[a].m_32 = 18;
					}
					else if(strncmp(pAgeData->countryCode,"au",2)==0)
					{
						// AUSTRALIA
						requestedParams[a].m_32 = 15;
					}
					else
					{
						// EUROPE EXCLUDING GERMANY AND AUSTRALIA
						requestedParams[a].m_32 = 16;
					}
				}
				else
				{
					// US AND JAPAN (and any unknown).
					requestedParams[a].m_32 = 17;
				}
			}
			break;
		case CLCC_PSN_STORE_ID:
			if (strncmp(gPS3Env->sTitleID,"BLES",4)==0)
			{
				requestedParams[a].m_pData = (void*)s_sceeStore_id;
				break;
			}
			if (strncmp(gPS3Env->sTitleID,"BLUS",4)==0)
			{
				requestedParams[a].m_pData = (void*)s_sceaStore_id;
				break;
			}
			if (strncmp(gPS3Env->sTitleID,"BLJM",4)==0)
			{
				requestedParams[a].m_pData = (void*)s_scejStore_id;
				break;
			}
			requestedParams[a].m_pData = (void*)s_testStore_id;
			break;
		case CLCC_PSN_IS_DLC_INSTALLED:
			if (g_pGame && g_pGame->GetDLCManager() && g_pGame->GetDLCManager()->IsDLCLoaded(requestedParams[a].m_8))
			{
				requestedParams[a].m_8 = 1;
			}
			else
			{
				requestedParams[a].m_8 = 0;
			}
			break;
#endif//PS3

		case CLCC_CRYSTATS_ENCRYPTION_KEY:
			{
#if defined(XENON)
				requestedParams[a].m_pData = (void*)"";
#elif defined(PS3) || defined(ORBIS)
				requestedParams[a].m_pData = (void*)"";
#else
				requestedParams[a].m_pData = (void*)"";
#endif
			}
			break;

		case CLCC_MATCHMAKING_SESSION_PASSWORD_MAX_LENGTH:
			requestedParams[a].m_8 = MATCHMAKING_SESSION_PASSWORD_MAX_LENGTH;
			break;

#if USE_STEAM
#if !defined(RELEASE)
		case CLCC_STEAM_APPID:
			requestedParams[a].m_32 = STEAM_APPID;
			break;
#endif // !defined(RELEASE)
#endif // USE_STEAM

		default:
			CRY_ASSERT_MESSAGE(0,"Unknown Configuration Parameter Requested!");
			break;
		}
	}
}
Ejemplo n.º 14
0
void CGameBrowser::ConfigurationCallback(ECryLobbyService service, SConfigurationParams *requestedParams, uint32 paramCount)
{
	uint32 a;
	for (a=0;a<paramCount;++a)
	{
		switch (requestedParams[a].m_fourCCID)
		{
		case CLCC_LAN_USER_NAME:
			{
				uint32 userIndex = g_pGame->GetExclusiveControllerDeviceIndex();

				IPlatformOS *pPlatformOS = gEnv->pSystem->GetPlatformOS();
				IPlatformOS::TUserName tUserName = "";
				if(pPlatformOS)
				{
					pPlatformOS->UserGetName(userIndex, tUserName);
				}
			
				// this will null terminate for us if necessary	
				cry_strncpy(s_profileName, tUserName.c_str(), CRYLOBBY_USER_NAME_LENGTH);
				int instance = gEnv->pSystem->GetApplicationInstance();
				if (instance>0)
				{
					size_t length = strlen(s_profileName);
					if (length + 3 < CRYLOBBY_USER_NAME_LENGTH)
					{
						s_profileName[length] = '(';
						s_profileName[length+1] = '0' + instance;
						s_profileName[length+2] = ')';
						s_profileName[length+3] = 0;
					}
				}

				requestedParams[a].m_pData = s_profileName;
			}
			break;

#if defined(ORBIS)
		case CLCC_CRYLOBBY_PRESENCE_CONVERTER:
			{
				SCryLobbyPresenceConverter* pConverter = (SCryLobbyPresenceConverter*)requestedParams[a].m_pData;
				if (pConverter)
				{
					//-- Use the pConverter->m_numData data items in pConverter->m_pData to create a string in pConverter->m_pStringBuffer
					//-- Use the initial value of pConverter->sizeOfStringBuffer as a maximum string length allowed, but
					//-- update pConverter->sizeOfStringBuffer to the correct length when the string is filled in.
					//-- Set pConverter->sizeOfStringBuffer = 0 to invalidate bad data so it isn't sent to PSN.
					CryFixedStringT<MAX_PRESENCE_STRING_SIZE> strPresence;
					if(CreatePresenceString(strPresence, pConverter->m_pData, pConverter->m_numData))
					{
						CryLog("[RichPresence] Succeeded %s", strPresence.c_str());
						sprintf((char*)pConverter->m_pStringBuffer, "%s", strPresence.c_str());
						pConverter->m_sizeOfStringBuffer = strlen((char*)pConverter->m_pStringBuffer);
					}
					else
					{
						CryLog("[RichPresence] Failed to create rich presence string");
						pConverter->m_sizeOfStringBuffer = 0;
					}
				}
			}
			break;
#endif
			
#if defined(DURANGO)
		case CLCC_LIVE_TITLE_ID:
			requestedParams[a].m_32 = DURANGO_LIVE_TITLE_ID;
			break;
		case CLCC_LIVE_SERVICE_CONFIG_ID:
			requestedParams[a].m_pData = DURANGO_LIVE_SERVICE_CONFIG_ID;
			break;
#endif//DURANGO

#if defined(ORBIS)
		case CLCC_PSN_TITLE_ID:
			requestedParams[a].m_pData = (void*)&s_title_id;
			break;

		case CLCC_PSN_TITLE_SECRET:
			requestedParams[a].m_pData = (void*)&s_title_secret;
			break;

		case CLCC_PSN_AGE_LIMIT:
			requestedParams[a].m_pData = (void*)&s_age_restrictions;
			break;

		case CLCC_PSN_PLUS_TEST_REQUIRED:
			requestedParams[a].m_32 = FALSE;
			break;

		case CLCC_PSN_CREATE_SESSION_ADVERTISEMENT:
			{
				SCryLobbySessionAdvertisement* pAdvertisement = (SCryLobbySessionAdvertisement*)requestedParams[a].m_pData;
				if (pAdvertisement)
				{
					pAdvertisement->m_numLanguages = s_NumLocalisedSessionAdvertisementLanguages;
					pAdvertisement->m_pLocalisedLanguages = (char**)s_LocalisedLanguages;
					pAdvertisement->m_pLocalisedSessionNames = (char**)s_LocalisedSessionAdvertisementName;
					pAdvertisement->m_pLocalisedSessionStatus = (char**)s_LocalisedSessionAdvertisementStatus;
					pAdvertisement->m_pJPGImage = (void*)s_SessionAdvertisementImage;
					pAdvertisement->m_sizeofJPGImage = strlen(s_SessionAdvertisementImage);
					// pAdvertisement->m_pData already points to a buffer of maximum size. It just needs to be filled in correctly.
					// pAdvertisement->m_sizeofData currently set to maximum size. You should change this to be correct size of actual data.
					// eg:	SAdvertDataStruct* pData = (SAdvertDataStruct*)pAdvertisement->m_pData;
					//			pData->id = 12345;
					//			pAdvertisement->m_sizeofData = sizeof(SAdvertDataStruct);
					uint32* pRealmId = (uint32*)pAdvertisement->m_pData;
					*pRealmId = 12345;
					pAdvertisement->m_sizeofData = sizeof(uint32);
				}
			}
			break;

		case CLCC_PSN_UPDATE_SESSION_ADVERTISEMENT:
			{
				SCryLobbySessionAdvertisement* pAdvertisement = (SCryLobbySessionAdvertisement*)requestedParams[a].m_pData;
				if (pAdvertisement)
				{
					// If pAdvertisement->m_numLanguages == 0, no attempt to alter the advertisement language settings will be made.
					// If pAdvertisement->m_numLanguages > 0, the previous language strings will all be overwritten with new ones.
					// (All strings are replaced or removed if not specified again)
					pAdvertisement->m_numLanguages = s_NumLocalisedSessionAdvertisementLanguages;
					pAdvertisement->m_pLocalisedLanguages = (char**)s_LocalisedLanguages;
					pAdvertisement->m_pLocalisedSessionNames = (char**)s_LocalisedSessionAdvertisementName;
					pAdvertisement->m_pLocalisedSessionStatus = (char**)s_LocalisedSessionAdvertisementStatus;
					// If pAdvertisement->m_pJPGImage is non-null and pAdvertisement->m_sizeofJPGImage > 0, the JPG data for the advertisement will be overwritten with a new JPG
					pAdvertisement->m_pJPGImage = (void*)s_SessionAdvertisementImage;
					pAdvertisement->m_sizeofJPGImage = strlen(s_SessionAdvertisementImage);
					// pAdvertisement->m_pData already points to a buffer containing a copy of the data passed into CryMatchmaking::SessionSetAdvertisementData.
					// and pAdvertisement->m_sizeofData is set to the correct size.
					// There should be no need to alter the contents of m_pData in this configuration callback.
				}
			}
			break;

		case CLCC_PSN_INVITE_BODY_STRING:
			{
				SCryLobbyXMBString* pStringData = (SCryLobbyXMBString*)requestedParams[a].m_pData;
				sprintf((char*)pStringData->m_pStringBuffer, "This is a test invite message");
				pStringData->m_sizeOfStringBuffer = strlen((char*)pStringData->m_pStringBuffer);
			}
			break;
#endif

		case CLCC_CRYSTATS_ENCRYPTION_KEY:
			{
#if defined(ORBIS)
				requestedParams[a].m_pData = (void*)"";
#else
				requestedParams[a].m_pData = (void*)"";
#endif
			}
			break;

		case CLCC_MATCHMAKING_SESSION_PASSWORD_MAX_LENGTH:
			requestedParams[a].m_8 = MATCHMAKING_SESSION_PASSWORD_MAX_LENGTH;
			break;

#if USE_STEAM
#if !defined(RELEASE)
		case CLCC_STEAM_APPID:
			requestedParams[a].m_32 = STEAM_APPID;
			break;
#endif // !defined(RELEASE)
#endif // USE_STEAM

		default:
			CRY_ASSERT_MESSAGE(0,"Unknown Configuration Parameter Requested!");
			break;
		}
	}
}
Ejemplo n.º 15
0
//------------------------------------------------------------------------
void CMatchMakingHandler::OnSearchResult( SCrySessionSearchResult* pSession )
{
	//session will expire at the end of the callback
	//so copy it into a results structure (we need lots of details to pass to the matchmaking part
	//store it in a map (indexed via sessionID?)
	//pass the index to the lua

	CGameLobby* pLobby = g_pGame->GetGameLobby();

	const CGameLobby::EActiveStatus activeStatus = (CGameLobby::EActiveStatus) GameLobbyData::GetSearchResultsData( pSession, LID_MATCHDATA_ACTIVE );
	bool bIsBadServer = pLobby->IsBadServer( pSession->m_id );
	const int skillRank = pLobby->CalculateAverageSkill();
	const int sessionSkillRank = GameLobbyData::GetSearchResultsData( pSession, LID_MATCHDATA_SKILL );
	const int sessionLanguageId = GameLobbyData::GetSearchResultsData( pSession, LID_MATCHDATA_LANGUAGE );

	float sessionScore = LegacyC2MatchMakingScore( pSession, pLobby, false );

	int32 region = 0;
#if USE_CRYLOBBY_GAMESPY
	region = GameLobbyData::GetSearchResultsData( pSession, LID_MATCHDATA_REGION );
#endif //USE_CRYLOBBY_GAMESPY

#if defined(TRACK_MATCHMAKING)
	if( CMatchmakingTelemetry* pMMTel = g_pGame->GetMatchMakingTelemetry() )
	{
		pMMTel->AddEvent( SMMFoundSessionEvent( pSession, activeStatus, skillRank - sessionSkillRank, region, sessionLanguageId, bIsBadServer, sessionScore ) );
	}
#endif //defined(TRACK_MATCHMAKING)

	HSCRIPTFUNCTION scriptFunction;

	if( m_pScript->GetValue( "OnSearchResult", scriptFunction ) )  
	{
		//Make a table to hold the search result
		SmartScriptTable result( gEnv->pScriptSystem );

		SessionDetails newSession;
		newSession.m_id = pSession->m_id;
		cry_strncpy( newSession.m_name, pSession->m_data.m_name, sizeof( newSession.m_name ) );

		//capture the session ID in a map
		std::pair< TSessionIdMap::iterator, bool > insertResult = m_sessionIdMap.insert( std::make_pair( m_sessionIdIndex++, newSession ) );

		if( insertResult.second )
		{
			result->SetValue( "SessionId", insertResult.first->first );
			result->SetValue( "SearchId", s_currentMMSearchID );

			float timeSinceStarted = gEnv->pTimer->GetFrameStartTime().GetSeconds() - m_startTime;
			result->SetValue( "TimeFound", timeSinceStarted );
				
			//make a sub table to hold all the known session parameters	
			SmartScriptTable parameters( gEnv->pScriptSystem );
			result->SetValue( "Parameters", parameters );

			parameters->SetValue( "ActiveStatus", activeStatus );
			parameters->SetValue( "ServerAvSkill", sessionSkillRank );
			parameters->SetValue( "Region", region );
			parameters->SetValue( "Language", sessionLanguageId );
			parameters->SetValue( "BadServer", bIsBadServer );
			parameters->SetValue( "Ping", pSession->m_ping );
			parameters->SetValue( "FilledSlots", pSession->m_numFilledSlots );

			Script::Call( gEnv->pScriptSystem, scriptFunction, m_pScript, result );
			gEnv->pScriptSystem->ReleaseFunc( scriptFunction );
		}
	}
}
Ejemplo n.º 16
0
bool CControllerInputRenderInfo::SetText(const char * text)
{
	m_type = kCITV_text;
	return cry_strncpy(m_text, CHUDUtils::LocalizeString(text, NULL, NULL), sizeof(m_text));
}