//------------------------------------------------------------------------- bool CCryLobbySessionHandler::ShouldCallMapCommand( const char *pLevelName, const char *pGameRules ) { bool result = false; CGameLobby* pGameLobby = g_pGame->GetGameLobby(); if (pGameLobby) { result = pGameLobby->ShouldCallMapCommand(pLevelName, pGameRules); if(result) { IPlatformOS* pPlatform = gEnv->pSystem->GetPlatformOS(); SStreamingInstallProgress progress; pPlatform->QueryStreamingInstallProgressForLevel(pLevelName, &progress); const bool bLevelReady = SStreamingInstallProgress::eState_Completed == progress.m_state; if(!bLevelReady) { // we can jump directly into MP from system game invitation avoiding frontend, so update streaming install priorities here pPlatform->SwitchStreamingInstallPriorityToLevel(pLevelName); gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent( ESYSTEM_EVENT_LEVEL_NOT_READY, (UINT_PTR)pLevelName, 0 ); } return bLevelReady; } } return result; }
bool CGameSessionHandler::ShouldCallMapCommand( const char *pLevelName, const char *pGameRules ) { IPlatformOS* pPlatform = gEnv->pSystem->GetPlatformOS(); SStreamingInstallProgress progress; pPlatform->QueryStreamingInstallProgressForLevel(pLevelName, &progress); const bool bLevelReady = SStreamingInstallProgress::eState_Completed == progress.m_state; if(!bLevelReady) { gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent( ESYSTEM_EVENT_LEVEL_NOT_READY, (UINT_PTR)pLevelName, 0 ); } return bLevelReady; }
//------------------------------------------------------------------------ bool CPlayerProfileImplConsole::LoginUser(SUserEntry* pEntry) { // lookup stored profiles of the user (pEntry->userId) and fill in the pEntry->profileDesc // vector pEntry->profileDesc.clear(); IPlatformOS *os = gEnv->pSystem->GetPlatformOS(); unsigned int userIndex; bool signedIn = os->UserIsSignedIn(pEntry->userId.c_str(), userIndex); CryLogAlways("LoginUser::UserIsSignedIn %d\n", signedIn); if (signedIn) { pEntry->profileDesc.push_back(SLocalProfileInfo(pEntry->userId)); // Check the profile data exists - if not create it string path; InternalMakeFSPath(pEntry, pEntry->userId, path); IPlatformOS::IFileFinderPtr fileFinder = os->GetFileFinder(userIndex); //this assumes there is a profile if a directory exists if(!fileFinder->FileExists(path)) { // Create new profile based on the defaults CPlayerProfile* profile = m_pMgr->GetDefaultCPlayerProfile(); string name = profile->GetName(); profile->SetName(pEntry->userId); m_pMgr->LoadGamerProfileDefaults(profile); #if !CRY_PLATFORM_DURANGO // Durango: no reason to overwrite user profile with default profile, mainly for that we're always online. SaveProfile(pEntry, profile, pEntry->userId.c_str(), true); #endif profile->SetName(name); } } else { printf( "OS No User signed in\n" ); } return signedIn; }
virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { switch (event) { case eFE_Initialize: { } break; case eFE_Activate: #if CRY_PLATFORM_DURANGO if(IsPortActive(pActInfo, EIP_Poll)) { // leaderboard IPlatformOS* pPlatformOS = GetISystem()->GetPlatformOS(); int userIndex = pPlatformOS->GetFirstSignedInUser(); auto user = Live::State::Manager::Instance().GetUserById( pPlatformOS->UserGetId(userIndex) ); wstring leaderboardName(L"EnemiesDefeated"); int startIndex = 0; int numEntries = 5; if ( user != nullptr ) { user->RequestLeaderboardDataAsync(leaderboardName, startIndex, numEntries).then( []( std::tuple<HRESULT, Live::LeaderboardData > result ) { HRESULT hr = std::get<0>(result); if ( hr == S_OK ) { Live::LeaderboardData data; data = std::get<1>(result); int breakhere = 0; CryLogAlways("got some data"); } }); } } #endif break; } }
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; } } }
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; } } }
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; } } }
bool CCommonSaveGameHelper::GetSaveGames(CPlayerProfileManager::SUserEntry* pEntry, CPlayerProfileManager::TSaveGameInfoVec& outVec, const char* altProfileName="") { // Scan savegames directory for XML files // we scan only for save game meta information string path; string profileName = (altProfileName && *altProfileName) ? altProfileName : pEntry->pCurrentProfile->GetName(); m_pImpl->InternalMakeFSSaveGamePath(pEntry, profileName, path, true); const bool bNeedProfilePrefix = m_pImpl->GetManager()->IsSaveGameFolderShared(); string profilePrefix = profileName; profilePrefix+='_'; size_t profilePrefixLen = profilePrefix.length(); path.TrimRight("/\\"); string search; search.Format("%s/*%s", path.c_str(), CRY_SAVEGAME_FILE_EXT); IPlatformOS* os = GetISystem()->GetPlatformOS(); IPlatformOS::IFileFinderPtr fileFinder = os->GetFileFinder(IPlatformOS::Unknown_User); _finddata_t fd; intptr_t handle = fileFinder->FindFirst(search.c_str(), &fd); if (handle != -1) { CPlayerProfileManager::SSaveGameInfo sgInfo; do { if (strcmp(fd.name, ".") == 0 || strcmp(fd.name, "..") == 0) continue; if (bNeedProfilePrefix) { if (strnicmp(profilePrefix, fd.name, profilePrefixLen) != 0) continue; } sgInfo.name = fd.name; if (bNeedProfilePrefix) // skip profile_ prefix (we made sure this is valid by comparism above) sgInfo.humanName = fd.name+profilePrefixLen; else sgInfo.humanName = fd.name; PathUtil::RemoveExtension(sgInfo.humanName); sgInfo.description = "no description"; bool ok = false; // filename construction #if defined(PS3) || defined(XENON) //don't use meta files on PS3 or 360 sgInfo.metaData.saveTime = static_cast<time_t>(fd.time_write); // the time gets used to find the most recent save sgInfo.metaData.loadTime = sgInfo.metaData.saveTime; ok = true; #else string metaFilename = path; metaFilename.append("/"); metaFilename.append(fd.name); metaFilename = PathUtil::ReplaceExtension(metaFilename, ".meta"); XmlNodeRef rootNode = LoadXMLFile(metaFilename.c_str()); // see if the root tag is o.k. if (rootNode && stricmp(rootNode->getTag(), "Metadata") == 0) { // get meta data ok = FetchMetaData(rootNode, sgInfo.metaData); } else { // when there is no meta information, we currently reject the savegame //ok = true; // un-comment this, if you want to accept savegames without meta } // Use the file modified time for the load time as we touch the saves when they are used to keep most recent checkpoint sgInfo.metaData.loadTime = static_cast<time_t>(fd.time_write); #endif if (ok) { outVec.push_back(sgInfo); } else { GameWarning("CPlayerProfileImplFS::GetSaveGames: SaveGame '%s' of user '%s' is invalid", fd.name, pEntry->userId.c_str()); } } while ( fileFinder->FindNext(handle, &fd) >= 0 ); fileFinder->FindClose( handle ); } return true; }
//------------------------------------------------------------------------ bool CPlayerProfileImplFSDir::LoginUser(SUserEntry* pEntry) { // lookup stored profiles of the user (pEntry->userId) and fill in the pEntry->profileDesc // vector pEntry->profileDesc.clear(); // scan directory for profiles string path; InternalMakeFSPath(pEntry, "", path); // no profile name -> only path std::multimap<time_t, SLocalProfileInfo> profiles; ICryPak * pCryPak = gEnv->pCryPak; _finddata_t fd; path.TrimRight("/\\"); string search = path + "/*.*"; IPlatformOS* pOS = GetISystem()->GetPlatformOS(); IPlatformOS::IFileFinderPtr fileFinder = pOS->GetFileFinder(IPlatformOS::Unknown_User); intptr_t handle = fileFinder->FindFirst(search.c_str(), &fd); if (handle != -1) { do { if (strcmp(fd.name, ".") == 0 || strcmp(fd.name, "..") == 0) continue; if (fd.attrib & _A_SUBDIR) { // profile name = folder name // but make sure there is a profile.xml in it string filename = path + "/" + fd.name; filename += "/" ; filename += "profile.xml"; XmlNodeRef rootNode = LoadXMLFile(filename.c_str()); // see if the root tag is o.k. if (rootNode && stricmp(rootNode->getTag(), PROFILE_ROOT_TAG) == 0) { string profileName = fd.name; if (rootNode->haveAttr(PROFILE_NAME_TAG)) { const char* profileHumanName = rootNode->getAttr(PROFILE_NAME_TAG); if (profileHumanName!=0 && stricmp(profileHumanName, profileName) == 0) { profileName = profileHumanName; } } time_t time = NULL; if (rootNode->haveAttr(PROFILE_LAST_PLAYED)) { rootNode->getAttr(PROFILE_LAST_PLAYED, time); } SLocalProfileInfo info(profileName); info.SetLastLoginTime(time); profiles.insert(std::make_pair(time, info)); } else { GameWarning("CPlayerProfileImplFSDir::LoginUser: Profile '%s' of User '%s' seems to exists but is invalid (File '%s). Skipped", fd.name, pEntry->userId.c_str(), filename.c_str()); } } } while ( fileFinder->FindNext( handle, &fd ) >= 0 ); fileFinder->FindClose( handle ); } // Insert in most recently played order std::multimap<time_t, SLocalProfileInfo>::const_reverse_iterator itend = profiles.rend(); for(std::multimap<time_t, SLocalProfileInfo>::const_reverse_iterator it = profiles.rbegin(); it != itend; ++it) pEntry->profileDesc.push_back(it->second); return true; }