From 55231bb8d3e1a4e2752ac3d444c4287eb0ca4e8b Mon Sep 17 00:00:00 2001 From: void_17 <61356189+void2012@users.noreply.github.com> Date: Fri, 6 Mar 2026 02:11:18 +0700 Subject: Remove AUTO_VAR macro and _toString function (#592) --- .../Common/Network/GameNetworkManager.cpp | 107 ++++++++++----------- .../Common/Network/PlatformNetworkManagerStub.cpp | 39 ++++---- .../Network/Sony/PlatformNetworkManagerSony.cpp | 76 +++++++-------- 3 files changed, 109 insertions(+), 113 deletions(-) (limited to 'Minecraft.Client/Common/Network') diff --git a/Minecraft.Client/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Common/Network/GameNetworkManager.cpp index a65a61aa..dbae3010 100644 --- a/Minecraft.Client/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Common/Network/GameNetworkManager.cpp @@ -75,7 +75,7 @@ void CGameNetworkManager::Initialise() #else s_pPlatformNetworkManager = new CPlatformNetworkManagerStub(); #endif - s_pPlatformNetworkManager->Initialise( this, flagIndexSize ); + s_pPlatformNetworkManager->Initialise( this, flagIndexSize ); m_bNetworkThreadRunning = false; m_bInitialised = true; } @@ -105,7 +105,7 @@ void CGameNetworkManager::DoWork() if((g_NetworkManager.GetLockedProfile()!=-1) && iPrimaryPlayer!=-1 && bConnected == false && g_NetworkManager.IsInSession() ) { app.SetAction(iPrimaryPlayer,eAppAction_EthernetDisconnected); - } + } } break; case XN_LIVE_INVITE_ACCEPTED: @@ -162,7 +162,7 @@ bool CGameNetworkManager::_RunNetworkGame(LPVOID lpParameter) success = s_pPlatformNetworkManager->_RunNetworkGame(); if(!success) - { + { app.SetAction(ProfileManager.GetPrimaryPad(),eAppAction_ExitWorld,(void *)TRUE); return true; } @@ -172,7 +172,7 @@ bool CGameNetworkManager::_RunNetworkGame(LPVOID lpParameter) // Client needs QNET_STATE_GAME_PLAY so that IsInGameplay() returns true s_pPlatformNetworkManager->SetGamePlayState(); } - + if( g_NetworkManager.IsLeavingGame() ) return false; app.SetGameStarted(true); @@ -199,7 +199,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame { NetworkGameInitData *param = (NetworkGameInitData *)lpParameter; seed = param->seed; - + app.setLevelGenerationOptions(param->levelGen); if(param->levelGen != NULL) { @@ -305,7 +305,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame ServerReadyWait(); ServerReadyDestroy(); - if( MinecraftServer::serverHalted() ) + if( MinecraftServer::serverHalted() ) return false; // printf("Server ready to go!\n"); @@ -316,7 +316,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame } #ifndef _XBOX - Minecraft *pMinecraft = Minecraft::GetInstance(); + Minecraft *pMinecraft = Minecraft::GetInstance(); // Make sure that we have transitioned through any joining/creating stages and are actually playing the game, so that we know the players should be valid bool changedMessage = false; while(!IsReadyToPlayOrIdle()) @@ -492,9 +492,10 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame do { // We need to keep ticking the connections for players that already logged in - for(AUTO_VAR(it, createdConnections.begin()); it < createdConnections.end(); ++it) - { - (*it)->tick(); + for (auto& it : createdConnections ) + { + if ( it ) + it->tick(); } // 4J Stu - We were ticking this way too fast which could cause the connection to time out @@ -522,8 +523,8 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame else { connection->close(); - AUTO_VAR(it, find( createdConnections.begin(), createdConnections.end(), connection )); - if(it != createdConnections.end() ) createdConnections.erase( it ); + auto it = find(createdConnections.begin(), createdConnections.end(), connection); + if(it != createdConnections.end() ) createdConnections.erase( it ); } } @@ -536,12 +537,12 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame return false; } - + if(g_NetworkManager.IsLeavingGame() || !IsInSession() ) { - for(AUTO_VAR(it, createdConnections.begin()); it < createdConnections.end(); ++it) - { - (*it)->close(); + for (auto& it : createdConnections) + { + it->close(); } // assert(false); MinecraftServer::HaltServer(); @@ -832,7 +833,7 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin ProfileManager.SetPrimaryPad(iPad); g_NetworkManager.SetLocalGame(false); - + // If the player was signed in before selecting play, we'll not have read the profile yet, so query the sign-in status to get this to happen ProfileManager.QuerySigninStatus(); @@ -848,7 +849,7 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin pInviteInfo ); // pInviteInfo if( !success ) { - app.DebugPrintf( "Failed joining game from invite\n" ); + app.DebugPrintf( "Failed joining game from invite\n" ); } } } @@ -894,7 +895,7 @@ int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter ) Compression::UseDefaultThreadStorage(); Tile::CreateNewThreadStorage(); IntCache::CreateNewThreadStorage(); - + g_NetworkManager.m_bNetworkThreadRunning = true; bool success = g_NetworkManager._RunNetworkGame(lpParameter); g_NetworkManager.m_bNetworkThreadRunning = false; @@ -906,7 +907,7 @@ int CGameNetworkManager::RunNetworkGameThreadProc( void* lpParameter ) Sleep(1); } ui.CleanUpSkinReload(); - if(app.GetDisconnectReason() == DisconnectPacket::eDisconnect_None) + if(app.GetDisconnectReason() == DisconnectPacket::eDisconnect_None) { app.SetDisconnectReason( DisconnectPacket::eDisconnect_ConnectionCreationFailed ); } @@ -949,7 +950,7 @@ int CGameNetworkManager::ServerThreadProc( void* lpParameter ) SetThreadName(-1, "Minecraft Server thread"); AABB::CreateNewThreadStorage(); Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); + IntCache::CreateNewThreadStorage(); Compression::UseDefaultThreadStorage(); OldChunkStorage::UseDefaultThreadStorage(); Entity::useSmallIds(); @@ -958,7 +959,7 @@ int CGameNetworkManager::ServerThreadProc( void* lpParameter ) FireworksRecipe::CreateNewThreadStorage(); MinecraftServer::main(seed, lpParameter); //saveData, app.GetGameHostOption(eGameHostOption_All)); - + Tile::ReleaseThreadStorage(); AABB::ReleaseThreadStorage(); Vec3::ReleaseThreadStorage(); @@ -1012,7 +1013,7 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc( void* lpParam ) // The pair of methods MustSignInReturned_0 & PSNSignInReturned_0 handle this int CGameNetworkManager::MustSignInReturned_0(void *pParam,int iPad,C4JStorage::EMessageResult result) { - if(result==C4JStorage::EMessage_ResultAccept) + if(result==C4JStorage::EMessage_ResultAccept) { #ifdef __PS3__ SQRNetworkManager_PS3::AttemptPSNSignIn(&CGameNetworkManager::PSNSignInReturned_0, pParam,true); @@ -1072,7 +1073,7 @@ int CGameNetworkManager::PSNSignInReturned_0(void* pParam, bool bContinue, int i // The pair of methods MustSignInReturned_1 & PSNSignInReturned_1 handle this int CGameNetworkManager::MustSignInReturned_1(void *pParam,int iPad,C4JStorage::EMessageResult result) { - if(result==C4JStorage::EMessage_ResultAccept) + if(result==C4JStorage::EMessage_ResultAccept) { #ifdef __PS3__ SQRNetworkManager_PS3::AttemptPSNSignIn(&CGameNetworkManager::PSNSignInReturned_1, pParam,true); @@ -1104,7 +1105,7 @@ int CGameNetworkManager::PSNSignInReturned_1(void* pParam, bool bContinue, int i #elif defined __ORBIS__ // TODO: No Orbis equivalent (should there be?) #endif - + } } @@ -1129,7 +1130,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) Vec3::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); - Minecraft *pMinecraft = Minecraft::GetInstance(); + Minecraft *pMinecraft = Minecraft::GetInstance(); MinecraftServer *pServer = MinecraftServer::getInstance(); #if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__ @@ -1168,7 +1169,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) pMinecraft->progressRenderer->progressStartNoAbort( g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE_NO_EXIT) ); pMinecraft->progressRenderer->progressStage( IDS_PROGRESS_CONVERTING_TO_OFFLINE_GAME ); } - + #else pMinecraft->progressRenderer->progressStartNoAbort( g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE_NO_EXIT) ); pMinecraft->progressRenderer->progressStage( IDS_PROGRESS_CONVERTING_TO_OFFLINE_GAME ); @@ -1182,7 +1183,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) // wait for the server to be in a non-ticking state pServer->m_serverPausedEvent->WaitForSignal(INFINITE); - + #if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__ // Swap these two messages around as one is too long to display at 480 pMinecraft->progressRenderer->progressStartNoAbort( IDS_PROGRESS_CONVERTING_TO_OFFLINE_GAME ); @@ -1218,9 +1219,8 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) if( pServer != NULL ) { PlayerList *players = pServer->getPlayers(); - for(AUTO_VAR(it, players->players.begin()); it < players->players.end(); ++it) + for(auto& servPlayer : players->players) { - shared_ptr servPlayer = *it; if( servPlayer->connection->isLocal() && !servPlayer->connection->isGuest() ) { servPlayer->connection->connection->getSocket()->setPlayer(NULL); @@ -1244,7 +1244,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) { Sleep(1); } - + // Reset this flag as the we don't need to know that we only lost the room only from this point onwards, the behaviour is exactly the same g_NetworkManager.m_bLastDisconnectWasLostRoomOnly = false; g_NetworkManager.m_bFullSessionMessageOnNextSessionChange = false; @@ -1275,7 +1275,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) { Sleep(1); } - + // Restore the network player of all the server players that are local if( pServer != NULL ) { @@ -1286,9 +1286,8 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) PlayerUID localPlayerXuid = pMinecraft->localplayers[index]->getXuid(); PlayerList *players = pServer->getPlayers(); - for(AUTO_VAR(it, players->players.begin()); it < players->players.end(); ++it) + for(auto& servPlayer : players->players) { - shared_ptr servPlayer = *it; if( servPlayer->getXuid() == localPlayerXuid ) { servPlayer->connection->connection->getSocket()->setPlayer( g_NetworkManager.GetLocalPlayerByUserIndex(index) ); @@ -1302,7 +1301,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) pMinecraft->m_pendingLocalConnections[index]->getConnection()->getSocket()->setPlayer(g_NetworkManager.GetLocalPlayerByUserIndex(index)); } else if ( pMinecraft->m_connectionFailed[index] && (pMinecraft->m_connectionFailedReason[index] == DisconnectPacket::eDisconnect_ConnectionCreationFailed) ) - { + { pMinecraft->removeLocalPlayerIdx(index); #ifdef _XBOX_ONE ProfileManager.RemoveGamepadFromGame(index); @@ -1311,7 +1310,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) } } } - + pMinecraft->progressRenderer->progressStagePercentage(100); #ifndef _XBOX @@ -1333,7 +1332,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) #endif // Start the game again - app.SetGameStarted(true); + app.SetGameStarted(true); app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_PauseServer,(void *)FALSE); app.SetChangingSessionType(false); app.SetReallyChangingSessionType(false); @@ -1387,7 +1386,7 @@ void CGameNetworkManager::StateChange_AnyToJoining() app.DebugPrintf("Disabling Guest Signin\n"); XEnableGuestSignin(FALSE); Minecraft::GetInstance()->clearPendingClientTextureRequests(); - + ConnectionProgressParams *param = new ConnectionProgressParams(); param->iPad = ProfileManager.GetPrimaryPad(); param->stringId = -1; @@ -1435,7 +1434,7 @@ void CGameNetworkManager::StateChange_AnyToStarting() completionData->type = e_ProgressCompletion_CloseAllPlayersUIScenes; completionData->iPad = ProfileManager.GetPrimaryPad(); loadingParams->completionData = completionData; - + ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); } } @@ -1559,7 +1558,7 @@ void CGameNetworkManager::PlayerJoining( INetworkPlayer *pNetworkPlayer ) bool multiplayer = g_NetworkManager.GetPlayerCount() > 1, localgame = g_NetworkManager.IsLocalGame(); for (int iPad=0; iPadIsHost() ) - { + { for(int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if(Minecraft::GetInstance()->localplayers[idx] != NULL) @@ -1640,7 +1639,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * } // Need to check we're signed in to PSN - bool isSignedInLive = true; + bool isSignedInLive = true; bool isLocalMultiplayerAvailable = app.IsLocalMultiplayerAvailable(); int iPadNotSignedInLive = -1; for(unsigned int i = 0; i < XUSER_MAX_COUNT; i++) @@ -1680,7 +1679,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * ui.RequestErrorMessage( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, iPadNotSignedInLive); } else - { + { // Not signed in to PSN UINT uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; @@ -1700,10 +1699,10 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * { m_pInviteInfo = (INVITE_INFO *) pInviteInfo; m_iPlayerInvited = userIndex; - + m_pUpsell = new PsPlusUpsellWrapper(index); m_pUpsell->displayUpsell(); - + return; } } @@ -1723,9 +1722,9 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * // 4J-PB we shouldn't bring any inactive players into the game, except for the invited player (who may be an inactive player) // 4J Stu - If we are not in a game, then bring in all players signed in if(index==userIndex || pMinecraft->localplayers[index]!=NULL ) - { + { ++joiningUsers; - if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true; + if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true; localUsersMask |= GetLocalPlayerMask( index ); } } @@ -1742,7 +1741,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; #endif - + #if defined(_XBOX) || defined(__PS3__) if(joiningUsers > 1 && !RenderManager.IsHiDef() && userIndex != ProfileManager.GetPrimaryPad()) { @@ -1796,10 +1795,10 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * } #endif if( !g_NetworkManager.IsInSession() ) - { + { #if defined (__PS3__) || defined (__PSVITA__) // PS3 is more complicated here - we need to make sure that the player is online. If they are then we can do the same as the xbox, if not we need to try and get them online and then, if they do sign in, go down the same path - + // Determine why they're not "signed in live" // MGH - On Vita we need to add a new message at some point for connecting when already signed in if(ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad())) @@ -1816,7 +1815,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * #else - HandleInviteWhenInMenus(userIndex, pInviteInfo); + HandleInviteWhenInMenus(userIndex, pInviteInfo); #endif } else @@ -1856,7 +1855,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I if(!ProfileManager.IsFullVersion()) { // The marketplace will fail with the primary player set to -1 - ProfileManager.SetPrimaryPad(userIndex); + ProfileManager.SetPrimaryPad(userIndex); app.SetAction(userIndex,eAppAction_DashboardTrialJoinFromInvite); } @@ -1900,7 +1899,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I ProfileManager.QuerySigninStatus(); // 4J-PB - clear any previous connection errors - Minecraft::GetInstance()->clearConnectionFailed(); + Minecraft::GetInstance()->clearConnectionFailed(); g_NetworkManager.SetLocalGame(false); @@ -1910,7 +1909,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I bool success = g_NetworkManager.JoinGameFromInviteInfo( userIndex, localUsersMask, pInviteInfo ); if( !success ) { - app.DebugPrintf( "Failed joining game from invite\n" ); + app.DebugPrintf( "Failed joining game from invite\n" ); } } } diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp index e5824bd4..6dd465d1 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "..\..\..\Minecraft.World\Socket.h" #include "..\..\..\Minecraft.World\StringHelpers.h" #include "PlatformNetworkManagerStub.h" @@ -64,9 +64,8 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer ) { // Do we already have a primary player for this system? bool systemHasPrimaryPlayer = false; - for(AUTO_VAR(it, m_machineQNetPrimaryPlayers.begin()); it < m_machineQNetPrimaryPlayers.end(); ++it) - { - IQNetPlayer *pQNetPrimaryPlayer = *it; + for (auto& pQNetPrimaryPlayer : m_machineQNetPrimaryPlayers) + { if( pQNetPlayer->IsSameSystem(pQNetPrimaryPlayer) ) { systemHasPrimaryPlayer = true; @@ -78,7 +77,7 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer ) } } g_NetworkManager.PlayerJoining( networkPlayer ); - + if( createFakeSocket == true && !m_bHostChanged ) { g_NetworkManager.CreateSocket( networkPlayer, localPlayer ); @@ -98,7 +97,7 @@ void CPlatformNetworkManagerStub::NotifyPlayerJoined(IQNetPlayer *pQNetPlayer ) // g_NetworkManager.UpdateAndSetGameSessionData(); SystemFlagAddPlayer( networkPlayer ); } - + for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if(playerChangedCallback[idx] != NULL) @@ -162,7 +161,7 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa { playerChangedCallback[ i ] = NULL; } - + m_bLeavingGame = false; m_bLeaveGameOnTick = false; m_bHostChanged = false; @@ -318,8 +317,8 @@ bool CPlatformNetworkManagerStub::LeaveGame(bool bMigrateHost) m_pIQNet->EndGame(); } - for (AUTO_VAR(it, currentNetworkPlayers.begin()); it != currentNetworkPlayers.end(); it++) - delete* it; + for (auto & it : currentNetworkPlayers) + delete it; currentNetworkPlayers.clear(); m_machineQNetPrimaryPlayers.clear(); SystemFlagReset(); @@ -473,7 +472,7 @@ void CPlatformNetworkManagerStub::UnRegisterPlayerChangedCallback(int iPad, void void CPlatformNetworkManagerStub::HandleSignInChange() { - return; + return; } bool CPlatformNetworkManagerStub::_RunNetworkGame() @@ -500,24 +499,24 @@ bool CPlatformNetworkManagerStub::_RunNetworkGame() void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= NULL*/) { // DWORD playerCount = m_pIQNet->GetPlayerCount(); -// +// // if( this->m_bLeavingGame ) // return; -// +// // if( GetHostPlayer() == NULL ) // return; -// +// // for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) // { // if( i < playerCount ) // { // INetworkPlayer *pNetworkPlayer = GetPlayerByIndex(i); -// +// // // We can call this from NotifyPlayerLeaving but at that point the player is still considered in the session // if( pNetworkPlayer != pNetworkPlayerLeaving ) // { // m_hostGameSessionData.players[i] = ((NetworkPlayerXbox *)pNetworkPlayer)->GetUID(); -// +// // char *temp; // temp = (char *)wstringtofilename( pNetworkPlayer->GetOnlineName() ); // memcpy(m_hostGameSessionData.szPlayers[i],temp,XUSER_NAME_SIZE); @@ -534,7 +533,7 @@ void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData(INetworkPlayer *pN // memset(m_hostGameSessionData.szPlayers[i],0,XUSER_NAME_SIZE); // } // } -// +// // m_hostGameSessionData.hostPlayerUID = ((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetXuid(); // m_hostGameSessionData.m_uiGameHostSettings = app.GetGameHostOption(eGameHostOption_All); } @@ -823,7 +822,7 @@ void CPlatformNetworkManagerStub::GetFullFriendSessionInfo( FriendSessionInfo *f void CPlatformNetworkManagerStub::ForceFriendsSessionRefresh() { app.DebugPrintf("Resetting friends session search data\n"); - + for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { m_searchResultsCount[i] = 0; @@ -844,8 +843,8 @@ INetworkPlayer *CPlatformNetworkManagerStub::addNetworkPlayer(IQNetPlayer *pQNet void CPlatformNetworkManagerStub::removeNetworkPlayer(IQNetPlayer *pQNetPlayer) { INetworkPlayer *pNetworkPlayer = getNetworkPlayer(pQNetPlayer); - for( AUTO_VAR(it, currentNetworkPlayers.begin()); it != currentNetworkPlayers.end(); it++ ) - { + for (auto it = currentNetworkPlayers.begin(); it != currentNetworkPlayers.end(); it++) + { if( *it == pNetworkPlayer ) { currentNetworkPlayers.erase(it); @@ -862,7 +861,7 @@ INetworkPlayer *CPlatformNetworkManagerStub::getNetworkPlayer(IQNetPlayer *pQNet INetworkPlayer *CPlatformNetworkManagerStub::GetLocalPlayerByUserIndex(int userIndex ) { - return getNetworkPlayer(m_pIQNet->GetLocalPlayerByUserIndex(userIndex)); + return getNetworkPlayer(m_pIQNet->GetLocalPlayerByUserIndex(userIndex)); } INetworkPlayer *CPlatformNetworkManagerStub::GetPlayerByIndex(int playerIndex) diff --git a/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.cpp b/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.cpp index 67fd058c..a9799d26 100644 --- a/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.cpp +++ b/Minecraft.Client/Common/Network/Sony/PlatformNetworkManagerSony.cpp @@ -7,21 +7,21 @@ CPlatformNetworkManagerSony *g_pPlatformNetworkManager; -bool CPlatformNetworkManagerSony::IsLocalGame() -{ - return m_bIsOfflineGame; +bool CPlatformNetworkManagerSony::IsLocalGame() +{ + return m_bIsOfflineGame; } -bool CPlatformNetworkManagerSony::IsPrivateGame() -{ - return m_bIsPrivateGame; +bool CPlatformNetworkManagerSony::IsPrivateGame() +{ + return m_bIsPrivateGame; } -bool CPlatformNetworkManagerSony::IsLeavingGame() -{ - return m_bLeavingGame; +bool CPlatformNetworkManagerSony::IsLeavingGame() +{ + return m_bLeavingGame; } -void CPlatformNetworkManagerSony::ResetLeavingGame() -{ - m_bLeavingGame = false; +void CPlatformNetworkManagerSony::ResetLeavingGame() +{ + m_bLeavingGame = false; } @@ -188,9 +188,8 @@ void CPlatformNetworkManagerSony::HandlePlayerJoined(SQRNetworkPlayer * { // Do we already have a primary player for this system? bool systemHasPrimaryPlayer = false; - for(AUTO_VAR(it, m_machineSQRPrimaryPlayers.begin()); it < m_machineSQRPrimaryPlayers.end(); ++it) + for( SQRNetworkPlayer *pQNetPrimaryPlayer : m_machineSQRPrimaryPlayers ) { - SQRNetworkPlayer *pQNetPrimaryPlayer = *it; if( pSQRPlayer->IsSameSystem(pQNetPrimaryPlayer) ) { systemHasPrimaryPlayer = true; @@ -202,7 +201,7 @@ void CPlatformNetworkManagerSony::HandlePlayerJoined(SQRNetworkPlayer * } } g_NetworkManager.PlayerJoining( networkPlayer ); - + if( createFakeSocket == true && !m_bHostChanged ) { g_NetworkManager.CreateSocket( networkPlayer, localPlayer ); @@ -224,7 +223,7 @@ void CPlatformNetworkManagerSony::HandlePlayerJoined(SQRNetworkPlayer * g_NetworkManager.UpdateAndSetGameSessionData(); SystemFlagAddPlayer( networkPlayer ); } - + for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if(playerChangedCallback[idx] != NULL) @@ -293,7 +292,7 @@ void CPlatformNetworkManagerSony::HandlePlayerLeaving(SQRNetworkPlayer *pSQRPlay break; } } - AUTO_VAR(it, find( m_machineSQRPrimaryPlayers.begin(), m_machineSQRPrimaryPlayers.end(), pSQRPlayer)); + auto it = find( m_machineSQRPrimaryPlayers.begin(), m_machineSQRPrimaryPlayers.end(), pSQRPlayer); if( it != m_machineSQRPrimaryPlayers.end() ) { m_machineSQRPrimaryPlayers.erase( it ); @@ -309,7 +308,7 @@ void CPlatformNetworkManagerSony::HandlePlayerLeaving(SQRNetworkPlayer *pSQRPlay } g_NetworkManager.PlayerLeaving( networkPlayer ); - + for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if(playerChangedCallback[idx] != NULL) @@ -374,7 +373,7 @@ bool CPlatformNetworkManagerSony::Initialise(CGameNetworkManager *pGameNetworkMa #ifdef __ORBIS__ m_pSQRNet = new SQRNetworkManager_Orbis(this); m_pSQRNet->Initialise(); -#elif defined __PS3__ +#elif defined __PS3__ m_pSQRNet = new SQRNetworkManager_PS3(this); m_pSQRNet->Initialise(); #else // __PSVITA__ @@ -405,7 +404,7 @@ bool CPlatformNetworkManagerSony::Initialise(CGameNetworkManager *pGameNetworkMa { playerChangedCallback[ i ] = NULL; } - + m_bLeavingGame = false; m_bLeaveGameOnTick = false; m_bHostChanged = false; @@ -419,7 +418,7 @@ bool CPlatformNetworkManagerSony::Initialise(CGameNetworkManager *pGameNetworkMa m_searchResultsCount = 0; m_pSearchResults = NULL; - + m_lastSearchStartTime = 0; // Success! @@ -458,7 +457,7 @@ int CPlatformNetworkManagerSony::CorrectErrorIDS(int IDS) bool preferSignoutError = false; int state; -#if defined __PSVITA__ // MGH - to fix devtrack #6258 +#if defined __PSVITA__ // MGH - to fix devtrack #6258 if(!ProfileManager.IsSignedInPSN(ProfileManager.GetPrimaryPad())) preferSignoutError = true; #elif defined __ORBIS__ @@ -529,9 +528,8 @@ int CPlatformNetworkManagerSony::CorrectErrorIDS(int IDS) bool CPlatformNetworkManagerSony::isSystemPrimaryPlayer(SQRNetworkPlayer *pSQRPlayer) { bool playerIsSystemPrimary = false; - for(AUTO_VAR(it, m_machineSQRPrimaryPlayers.begin()); it < m_machineSQRPrimaryPlayers.end(); ++it) + for( SQRNetworkPlayer *pSQRPrimaryPlayer : m_machineSQRPrimaryPlayers ) { - SQRNetworkPlayer *pSQRPrimaryPlayer = *it; if( pSQRPrimaryPlayer == pSQRPlayer ) { playerIsSystemPrimary = true; @@ -552,7 +550,7 @@ void CPlatformNetworkManagerSony::DoWork() m_notificationListener, 0, // Any notification &dwNotifyId, - &ulpNotifyParam) + &ulpNotifyParam) ) { @@ -650,7 +648,7 @@ bool CPlatformNetworkManagerSony::IsInStatsEnabledSession() DWORD dataSize = sizeof(QNET_LIVE_STATS_MODE); QNET_LIVE_STATS_MODE statsMode; m_pIQNet->GetOpt(QNET_OPTION_LIVE_STATS_MODE, &statsMode , &dataSize ); - + // Use QNET_LIVE_STATS_MODE_AUTO if there is another way to check if stats are enabled or not bool statsEnabled = statsMode == QNET_LIVE_STATS_MODE_ENABLED; return m_pIQNet->GetState() != QNET_STATE_IDLE && statsEnabled; @@ -732,7 +730,7 @@ bool CPlatformNetworkManagerSony::LeaveGame(bool bMigrateHost) // If we are the host wait for the game server to end if(m_pSQRNet->IsHost() && g_NetworkManager.ServerStoppedValid()) - { + { m_pSQRNet->EndGame(); g_NetworkManager.ServerStoppedWait(); g_NetworkManager.ServerStoppedDestroy(); @@ -887,7 +885,7 @@ void CPlatformNetworkManagerSony::UnRegisterPlayerChangedCallback(int iPad, void void CPlatformNetworkManagerSony::HandleSignInChange() { - return; + return; } bool CPlatformNetworkManagerSony::_RunNetworkGame() @@ -930,7 +928,7 @@ void CPlatformNetworkManagerSony::UpdateAndSetGameSessionData(INetworkPlayer *pN { m_hostGameSessionData.hostPlayerUID.setForAdhoc(); } -#endif +#endif m_hostGameSessionData.m_uiGameHostSettings = app.GetGameHostOption(eGameHostOption_All); @@ -1066,8 +1064,8 @@ bool CPlatformNetworkManagerSony::SystemFlagGet(INetworkPlayer *pNetworkPlayer, wstring CPlatformNetworkManagerSony::GatherStats() { #if 0 - return L"Queue messages: " + _toString(((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_MESSAGES ) ) - + L" Queue bytes: " + _toString( ((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_BYTES ) ); + return L"Queue messages: " + std::to_wstring(((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_MESSAGES ) ) + + L" Queue bytes: " + std::to_wstring( ((NetworkPlayerXbox *)GetHostPlayer())->GetQNetPlayer()->GetSendQueueSize( NULL, QNET_GETSENDQUEUESIZE_BYTES ) ); #else return L""; #endif @@ -1192,7 +1190,7 @@ bool CPlatformNetworkManagerSony::GetGameSessionInfo(int iPad, SessionID session bool foundSession = false; FriendSessionInfo *sessionInfo = NULL; - AUTO_VAR(itFriendSession, friendsSessions[iPad].begin()); + auto itFriendSession = friendsSessions[iPad].begin(); for(itFriendSession = friendsSessions[iPad].begin(); itFriendSession < friendsSessions[iPad].end(); ++itFriendSession) { sessionInfo = *itFriendSession; @@ -1224,7 +1222,7 @@ bool CPlatformNetworkManagerSony::GetGameSessionInfo(int iPad, SessionID session else { swprintf(sessionInfo->displayLabel,app.GetString(IDS_GAME_HOST_NAME_UNKNOWN)); - } + } sessionInfo->displayLabelLength = wcslen( sessionInfo->displayLabel ); // If this host wasn't disabled use this one. @@ -1283,7 +1281,7 @@ INetworkPlayer *CPlatformNetworkManagerSony::addNetworkPlayer(SQRNetworkPlayer * void CPlatformNetworkManagerSony::removeNetworkPlayer(SQRNetworkPlayer *pSQRPlayer) { INetworkPlayer *pNetworkPlayer = getNetworkPlayer(pSQRPlayer); - for( AUTO_VAR(it, currentNetworkPlayers.begin()); it != currentNetworkPlayers.end(); it++ ) + for( auto it = currentNetworkPlayers.begin(); it != currentNetworkPlayers.end(); it++ ) { if( *it == pNetworkPlayer ) { @@ -1301,7 +1299,7 @@ INetworkPlayer *CPlatformNetworkManagerSony::getNetworkPlayer(SQRNetworkPlayer * INetworkPlayer *CPlatformNetworkManagerSony::GetLocalPlayerByUserIndex(int userIndex ) { - return getNetworkPlayer(m_pSQRNet->GetLocalPlayerByUserIndex(userIndex)); + return getNetworkPlayer(m_pSQRNet->GetLocalPlayerByUserIndex(userIndex)); } INetworkPlayer *CPlatformNetworkManagerSony::GetPlayerByIndex(int playerIndex) @@ -1400,7 +1398,7 @@ bool CPlatformNetworkManagerSony::setAdhocMode( bool bAdhoc ) { if(m_bUsingAdhocMode != bAdhoc) { - m_bUsingAdhocMode = bAdhoc; + m_bUsingAdhocMode = bAdhoc; if(m_bUsingAdhocMode) { // uninit the PSN, and init adhoc @@ -1419,14 +1417,14 @@ bool CPlatformNetworkManagerSony::setAdhocMode( bool bAdhoc ) else { if(m_pSQRNet_Vita_Adhoc->IsInitialised()) - { - int ret = sceNetCtlAdhocDisconnect(); + { + int ret = sceNetCtlAdhocDisconnect(); // uninit the adhoc, and init psn m_pSQRNet_Vita_Adhoc->UnInitialise(); } if(m_pSQRNet_Vita->IsInitialised()==false) - { + { m_pSQRNet_Vita->Initialise(); } -- cgit v1.2.3