diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-08 19:08:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 18:08:36 -0500 |
| commit | 28614b922fb77149a54da1a87bebfbc98736f296 (patch) | |
| tree | 7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.Client/PSVita/Network | |
| parent | 88798b501d0cf6287b6f87acb2592676e3cec58d (diff) | |
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266
* Replaced every C-style cast with C++ ones
* Replaced every C-style cast with C++ ones
* Fixed boats falling and a TP glitch #266
* Updated NULL to nullptr and fixing some type issues
* Modernized and fixed a few bugs
- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.
* Fixing more conflicts
* Replace int loops with size_t and start work on overrides
* Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.Client/PSVita/Network')
10 files changed, 182 insertions, 182 deletions
diff --git a/Minecraft.Client/PSVita/Network/PSVita_NPToolkit.cpp b/Minecraft.Client/PSVita/Network/PSVita_NPToolkit.cpp index 1c5c45e3..9ed61d21 100644 --- a/Minecraft.Client/PSVita/Network/PSVita_NPToolkit.cpp +++ b/Minecraft.Client/PSVita/Network/PSVita_NPToolkit.cpp @@ -331,7 +331,7 @@ void hexStrToBin( val <<= 4; } else { - if (pBinBuf != NULL && binOffset < binBufSize) { + if (pBinBuf != nullptr && binOffset < binBufSize) { memcpy(pBinBuf + binOffset, &val, 1); val = 0; } @@ -339,7 +339,7 @@ void hexStrToBin( } } - if (val != 0 && pBinBuf != NULL && binOffset < binBufSize) { + if (val != 0 && pBinBuf != nullptr && binOffset < binBufSize) { memcpy(pBinBuf + binOffset, &val, 1); } @@ -403,7 +403,7 @@ void PSVitaNPToolkit::init() // extern void npStateCallback(SceNpServiceState state, int retCode, void *userdata); - ret = sceNpRegisterServiceStateCallback(npStateCallback, NULL); + ret = sceNpRegisterServiceStateCallback(npStateCallback, nullptr); if (ret < 0) { app.DebugPrintf("sceNpRegisterServiceStateCallback() failed. ret = 0x%x\n", ret); diff --git a/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.cpp b/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.cpp index dc9ad61e..4ba6ae2e 100644 --- a/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.cpp @@ -45,8 +45,8 @@ int SQRNetworkManager_AdHoc_Vita::m_adhocStatus = false; static unsigned char s_Matching2Pool[SCE_NET_ADHOC_MATCHING_POOLSIZE_DEFAULT]; -int (* SQRNetworkManager_AdHoc_Vita::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = NULL; -void * SQRNetworkManager_AdHoc_Vita::s_SignInCompleteParam = NULL; +int (* SQRNetworkManager_AdHoc_Vita::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = nullptr; +void * SQRNetworkManager_AdHoc_Vita::s_SignInCompleteParam = nullptr; sce::Toolkit::NP::PresenceDetails SQRNetworkManager_AdHoc_Vita::s_lastPresenceInfo; int SQRNetworkManager_AdHoc_Vita::s_resendPresenceCountdown = 0; bool SQRNetworkManager_AdHoc_Vita::s_presenceStatusDirty = false; @@ -127,8 +127,8 @@ SQRNetworkManager_AdHoc_Vita::SQRNetworkManager_AdHoc_Vita(ISQRNetworkManagerLis m_isInSession = false; m_offlineGame = false; m_offlineSQR = false; - m_aServerId = NULL; -// m_gameBootInvite = NULL; + m_aServerId = nullptr; +// m_gameBootInvite = nullptr; m_adhocStatus = false; m_bLinkDisconnected = false; m_bIsInitialised=false; @@ -166,7 +166,7 @@ void SQRNetworkManager_AdHoc_Vita::Initialise() int32_t ret = 0; // int32_t libCtxId = 0; -// ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, NULL); +// ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, nullptr); // assert (ret >= 0); // libCtxId = ret; @@ -203,7 +203,7 @@ void SQRNetworkManager_AdHoc_Vita::Initialise() // npConf.commId = &s_npCommunicationId; // npConf.commPassphrase = &s_npCommunicationPassphrase; // npConf.commSignature = &s_npCommunicationSignature; -// ret = sceNpInit(&npConf, NULL); +// ret = sceNpInit(&npConf, nullptr); // if (ret < 0 && ret != SCE_NP_ERROR_ALREADY_INITIALIZED) // { // app.DebugPrintf("sceNpInit failed, ret=%x\n", ret); @@ -388,14 +388,14 @@ bool SQRNetworkManager_AdHoc_Vita::CreateMatchingContext(bool bServer /*= false* // Free up any external data that we received from the previous search - for( int i = 0; i < m_aFriendSearchResults.size(); i++ ) + for( size_t i = 0; i < m_aFriendSearchResults.size(); i++ ) { if(m_aFriendSearchResults[i].m_RoomExtDataReceived) free(m_aFriendSearchResults[i].m_RoomExtDataReceived); - m_aFriendSearchResults[i].m_RoomExtDataReceived = NULL; + m_aFriendSearchResults[i].m_RoomExtDataReceived = nullptr; if(m_aFriendSearchResults[i].m_gameSessionData) free(m_aFriendSearchResults[i].m_gameSessionData); - m_aFriendSearchResults[i].m_gameSessionData = NULL; + m_aFriendSearchResults[i].m_gameSessionData = nullptr; } m_friendCount = 0; m_aFriendSearchResults.clear(); @@ -406,7 +406,7 @@ bool SQRNetworkManager_AdHoc_Vita::CreateMatchingContext(bool bServer /*= false* ret = sceNetAdhocMatchingStart(m_matchingContext, SCE_KERNEL_DEFAULT_PRIORITY_USER, MATCHING_EVENT_HANDLER_STACK_SIZE, SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT, - 0, NULL);//sizeof(g_myInfo.name), &g_myInfo.name); + 0, nullptr);//sizeof(g_myInfo.name), &g_myInfo.name); if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_CONTEXT_START_ASYNC ) ) { @@ -448,7 +448,7 @@ void SQRNetworkManager_AdHoc_Vita::InitialiseAfterOnline() if( s_SignInCompleteCallbackFn ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } return; } @@ -512,7 +512,7 @@ void SQRNetworkManager_AdHoc_Vita::Tick() // if( ( m_gameBootInvite m) && ( s_safeToRespondToGameBootInvite ) ) // { // m_listener->HandleInviteReceived( ProfileManager.GetPrimaryPad(), m_gameBootInvite ); -// m_gameBootInvite = NULL; +// m_gameBootInvite = nullptr; // } ErrorHandlingTick(); @@ -585,7 +585,7 @@ void SQRNetworkManager_AdHoc_Vita::ErrorHandlingTick() { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } app.DebugPrintf("Network error: SNM_INT_STATE_INITIALISE_FAILED\n"); if( m_isInSession && m_offlineSQR ) @@ -777,7 +777,7 @@ void SQRNetworkManager_AdHoc_Vita::FriendSearchTick() // { // m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_INFO; // delete m_getFriendCountThread; -// m_getFriendCountThread = NULL; +// m_getFriendCountThread = nullptr; FriendRoomManagerSearch2(); // } } @@ -797,7 +797,7 @@ int SQRNetworkManager_AdHoc_Vita::BasicEventThreadProc( void *lpParameter ) // // do // { -// ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, NULL); +// ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, nullptr); // // // If the sys_event_t we've sent here from the handler has a non-zero data1 element, this is to signify that we should terminate the thread // if( event.udata == 0 ) @@ -855,7 +855,7 @@ int SQRNetworkManager_AdHoc_Vita::BasicEventThreadProc( void *lpParameter ) // // There shouldn't ever be more than 100 friends returned but limit here just in case // if( manager->m_friendCount > 100 ) manager->m_friendCount = 100; // -// SceNpId* friendIDs = NULL; +// SceNpId* friendIDs = nullptr; // if(manager->m_friendCount > 0) // { // // grab all the friend IDs first @@ -995,7 +995,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerByIndex(int idx) } else { - return NULL; + return nullptr; } } @@ -1012,7 +1012,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerBySmallId(int idx) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetLocalPlayerByUserIndex(int idx) @@ -1028,7 +1028,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetLocalPlayerByUserIndex(int id } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetHostPlayer() @@ -1041,11 +1041,11 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetHostPlayer() SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerIfReady(SQRNetworkPlayer *player) { - if( player == NULL ) return NULL; + if( player == nullptr ) return nullptr; if( player->IsReady() ) return player; - return NULL; + return nullptr; } // Update state internally @@ -1086,7 +1086,7 @@ void SQRNetworkManager_AdHoc_Vita::ResetToIdle() { memberIDs.push_back(m_aRoomSlotPlayers[i]->m_roomMemberId); } - for(int i=0;i<memberIDs.size();i++) + for(size_t i=0;i<memberIDs.size();i++) { if(memberIDs[i] != m_hostMemberId) RemoveRemotePlayersAndSync(memberIDs[i], 15); @@ -1117,7 +1117,7 @@ bool SQRNetworkManager_AdHoc_Vita::JoinRoom(SQRNetworkManager_AdHoc_Vita::Sessio { // Set up the presence info we would like to synchronise out when we have fully joined the game // CPlatformNetworkManagerSony::SetSQRPresenceInfoFromExtData(&s_lastPresenceSyncInfo, searchResult->m_extData, searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId); - return JoinRoom(searchResult->m_netAddr, localPlayerMask, NULL); + return JoinRoom(searchResult->m_netAddr, localPlayerMask, nullptr); } bool SQRNetworkManager_AdHoc_Vita::JoinRoom(SceNpMatching2RoomId roomId, SceNpMatching2ServerId serverId, int localPlayerMask, const PresenceSyncInfo *presence) @@ -1137,7 +1137,7 @@ bool SQRNetworkManager_AdHoc_Vita::JoinRoom(SceNetInAddr netAddr, int localPlaye } else { - for(int i=0;i<m_aFriendSearchResults.size();i++) + for(size_t i=0;i<m_aFriendSearchResults.size();i++) { if(m_aFriendSearchResults[i].m_netAddr.s_addr == netAddr.s_addr) { @@ -1162,7 +1162,7 @@ bool SQRNetworkManager_AdHoc_Vita::JoinRoom(SceNetInAddr netAddr, int localPlaye if(!CreateMatchingContext()) return false; - int err = sceNetAdhocMatchingSelectTarget(m_matchingContext, &netAddr, 0, NULL); + int err = sceNetAdhocMatchingSelectTarget(m_matchingContext, &netAddr, 0, nullptr); m_hostMemberId = getRoomMemberID(&netAddr); m_hostIPAddr = netAddr; @@ -1323,7 +1323,7 @@ void SQRNetworkManager_AdHoc_Vita::FindOrCreateNonNetworkPlayer(int slot, int pl } } // Create the player - non-network players can be considered complete as soon as we create them as we aren't waiting on their network connections becoming complete, so can flag them as such and notify via callback - PlayerUID *pUID = NULL; + PlayerUID *pUID = nullptr; PlayerUID localUID; if( ( playerType == SQRNetworkPlayer::SNP_TYPE_LOCAL ) || m_isHosting && ( playerType == SQRNetworkPlayer::SNP_TYPE_HOST ) ) @@ -1390,7 +1390,7 @@ void SQRNetworkManager_AdHoc_Vita::MapRoomSlotPlayers(int roomSlotPlayerCount/*= if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_REMOTE ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1446,7 +1446,7 @@ void SQRNetworkManager_AdHoc_Vita::MapRoomSlotPlayers(int roomSlotPlayerCount/*= if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_LOCAL ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1538,7 +1538,7 @@ void SQRNetworkManager_AdHoc_Vita::UpdatePlayersFromRoomSyncUIDs() } // Host only - add remote players to our internal storage of player slots, and synchronise this with other room members. -bool SQRNetworkManager_AdHoc_Vita::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==NULL*/ ) +bool SQRNetworkManager_AdHoc_Vita::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==nullptr*/ ) { assert( m_isHosting ); @@ -1658,7 +1658,7 @@ void SQRNetworkManager_AdHoc_Vita::RemoveRemotePlayersAndSync( SceNpMatching2Roo } // Zero last element, that isn't part of the currently sized array anymore memset(&m_roomSyncData.players[m_roomSyncData.getPlayerCount()],0,sizeof(PlayerSyncData)); - m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = nullptr; } else { @@ -1701,7 +1701,7 @@ void SQRNetworkManager_AdHoc_Vita::RemoveNetworkPlayers( int mask ) { if( m_aRoomSlotPlayers[i] == player ) { - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } // And delete the reference from the ctx->player map @@ -1807,7 +1807,7 @@ void SQRNetworkManager_AdHoc_Vita::MatchingEventHandler(int id, int event, SceNe // check we don't have this already int currIndex = -1; bool bChanged = false; - for(int i=0; i<manager->m_aFriendSearchResults.size(); i++) + for(size_t i=0; i<manager->m_aFriendSearchResults.size(); i++) { if(manager->m_aFriendSearchResults[i].m_netAddr.s_addr == peer->s_addr) { @@ -1843,7 +1843,7 @@ void SQRNetworkManager_AdHoc_Vita::MatchingEventHandler(int id, int event, SceNe case SCE_NET_ADHOC_MATCHING_EVENT_REQUEST: // A join request was received app.DebugPrintf("P2P SCE_NET_ADHOC_MATCHING_EVENT_REQUEST Received!!\n"); - if (optlen > 0 && opt != NULL) + if (optlen > 0 && opt != nullptr) { ret = SCE_OK;// parentRequestAdd(opt); if (ret != SCE_OK) @@ -1987,7 +1987,7 @@ void SQRNetworkManager_AdHoc_Vita::MatchingEventHandler(int id, int event, SceNe { app.DebugPrintf("P2P SCE_NET_ADHOC_MATCHING_EVENT_DATA Received!!\n"); - if (optlen <= 0 || opt == NULL) + if (optlen <= 0 || opt == nullptr) { assert(0); break; @@ -2270,7 +2270,7 @@ bool SQRNetworkManager_AdHoc_Vita::CreateRudpConnections(SceNetInAddr peer) if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_RUDP_CONTEXT) ) return false; if( m_isHosting ) { - m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, getRoomMemberID((&peer)), 0, rudpCtx, NULL ); + m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, getRoomMemberID((&peer)), 0, rudpCtx, nullptr ); m_RudpCtxToIPAddrMap[ rudpCtx ] = peer; } else @@ -2311,7 +2311,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerFromRudpCtx(int rudpCtx { return it->second; } - return NULL; + return nullptr; } @@ -2322,7 +2322,7 @@ SceNetInAddr* SQRNetworkManager_AdHoc_Vita::GetIPAddrFromRudpCtx(int rudpCtx) { return &it->second; } - return NULL; + return nullptr; } @@ -2336,7 +2336,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerFromRoomMemberAndLocalI return it->second; } } - return NULL; + return nullptr; } @@ -2406,7 +2406,7 @@ void SQRNetworkManager_AdHoc_Vita::HandleMatchingContextStart() if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { SetState( SNM_INT_STATE_IDLE ); - GetExtDataForRoom(0, NULL, NULL, NULL); + GetExtDataForRoom(0, nullptr, nullptr, nullptr); } else if( m_state == SNM_INT_STATE_HOSTING_STARTING_MATCHING_CONTEXT ) { @@ -2431,7 +2431,7 @@ void SQRNetworkManager_AdHoc_Vita::HandleMatchingContextStart() if(s_SignInCompleteCallbackFn) { s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, 0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -2446,7 +2446,7 @@ int SQRNetworkManager_AdHoc_Vita::BasicEventCallback(int event, int retCode, uin PSVITA_STUBBED; // SQRNetworkManager_AdHoc_Vita *manager = (SQRNetworkManager_AdHoc_Vita *)arg; // // We aren't allowed to actually get the event directly from this callback, so send our own internal event to a thread dedicated to doing this - // sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, NULL); + // sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, nullptr); return 0; } @@ -2490,7 +2490,7 @@ void SQRNetworkManager_AdHoc_Vita::SysUtilCallback(uint64_t status, uint64_t par // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); // } - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } // return; // } @@ -2505,7 +2505,7 @@ void SQRNetworkManager_AdHoc_Vita::SysUtilCallback(uint64_t status, uint64_t par // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); // } - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } // } // @@ -2542,7 +2542,7 @@ void SQRNetworkManager_AdHoc_Vita::updateNetCheckDialog() if( s_SignInCompleteCallbackFn ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } else @@ -2561,7 +2561,7 @@ void SQRNetworkManager_AdHoc_Vita::updateNetCheckDialog() { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -2577,7 +2577,7 @@ void SQRNetworkManager_AdHoc_Vita::RudpContextCallback(int ctx_id, int event_id, { case SCE_RUDP_CONTEXT_EVENT_CLOSED: { - SQRVoiceConnection* pVoice = NULL; + SQRVoiceConnection* pVoice = nullptr; if(sc_voiceChatEnabled) SonyVoiceChat_Vita::GetVoiceConnectionFromRudpCtx(ctx_id); @@ -2638,7 +2638,7 @@ void SQRNetworkManager_AdHoc_Vita::RudpContextCallback(int ctx_id, int event_id, case SCE_RUDP_CONTEXT_EVENT_READABLE: if( manager->m_listener ) { - SQRVoiceConnection* pVoice = NULL; + SQRVoiceConnection* pVoice = nullptr; if(sc_voiceChatEnabled) { SonyVoiceChat_Vita::GetVoiceConnectionFromRudpCtx(ctx_id); @@ -2698,7 +2698,7 @@ void SQRNetworkManager_AdHoc_Vita::RudpContextCallback(int ctx_id, int event_id, playerFrom = manager->m_aRoomSlotPlayers[0]; playerTo = manager->GetPlayerFromRudpCtx( ctx_id ); } - if( ( playerFrom != NULL ) && ( playerTo != NULL ) ) + if( ( playerFrom != nullptr ) && ( playerTo != nullptr ) ) { manager->m_listener->HandleDataReceived( playerFrom, playerTo, data, bytesRead ); } @@ -2761,7 +2761,7 @@ void SQRNetworkManager_AdHoc_Vita::ServerContextValid_CreateRoom() int ret = -1; if( !ForceErrorPoint(SNM_FORCE_ERROR_GET_WORLD_INFO_LIST) ) { - ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, NULL, &m_getWorldRequestId); + ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, nullptr, &m_getWorldRequestId); } if (ret < 0) { @@ -2790,7 +2790,7 @@ void SQRNetworkManager_AdHoc_Vita::ServerContextValid_JoinRoom() reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, NULL, &m_joinRoomRequestId ); + int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, nullptr, &m_joinRoomRequestId ); if ( (ret < 0) || ForceErrorPoint(SNM_FORCE_ERROR_JOIN_ROOM) ) { if( ret == SCE_NP_MATCHING2_SERVER_ERROR_NAT_TYPE_MISMATCH) @@ -2814,14 +2814,14 @@ const SceNpCommunicationSignature* SQRNetworkManager_AdHoc_Vita::GetSceNpCommsSi const SceNpTitleId* SQRNetworkManager_AdHoc_Vita::GetSceNpTitleId() { PSVITA_STUBBED; - return NULL; + return nullptr; // return &s_npTitleId; } const SceNpTitleSecret* SQRNetworkManager_AdHoc_Vita::GetSceNpTitleSecret() { PSVITA_STUBBED; - return NULL; + return nullptr; // return &s_npTitleSecret; } @@ -2852,7 +2852,7 @@ int SQRNetworkManager_AdHoc_Vita::GetRemovedMask(int newMask, int oldMask) void SQRNetworkManager_AdHoc_Vita::GetExtDataForRoom( SceNpMatching2RoomId roomId, void *extData, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ) { - for(int i=0;i<m_aFriendSearchResults.size();i++) + for(size_t i=0;i<m_aFriendSearchResults.size();i++) { if(m_aFriendSearchResults[i].m_netAddr.s_addr == roomId) { @@ -2964,7 +2964,7 @@ void SQRNetworkManager_AdHoc_Vita::AttemptAdhocSignIn(int (*SignInCompleteCallba { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -3039,7 +3039,7 @@ void SQRNetworkManager_AdHoc_Vita::AttemptPSNSignIn(int (*SignInCompleteCallback { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -3234,7 +3234,7 @@ SQRNetworkPlayer *SQRNetworkManager_AdHoc_Vita::GetPlayerByXuid(PlayerUID xuid) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } void SQRNetworkManager_AdHoc_Vita::UpdateLocalIPAddress() diff --git a/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.h b/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.h index c1b2d266..a5b9513e 100644 --- a/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.h +++ b/Minecraft.Client/PSVita/Network/SQRNetworkManager_AdHoc_Vita.h @@ -163,7 +163,7 @@ private: void LocalDataSend(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, const void *data, unsigned int dataSize); int GetSessionIndex(SQRNetworkPlayer *player); - bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = NULL ); + bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = nullptr ); void RemoveRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int mask ); void RemoveNetworkPlayers( int mask ); void SetLocalPlayersAndSync(); diff --git a/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.cpp b/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.cpp index a1534f54..e38280d8 100644 --- a/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.cpp @@ -16,8 +16,8 @@ // image used for the invite gui, filesize must be smaller than SCE_NP_MESSAGE_DIALOG_MAX_INDEX_ICON_SIZE ( 64K ) #define SESSION_IMAGE_PATH "app0:PSVita/session_image.png" -int (* SQRNetworkManager_Vita::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = NULL; -void * SQRNetworkManager_Vita::s_SignInCompleteParam = NULL; +int (* SQRNetworkManager_Vita::s_SignInCompleteCallbackFn)(void *pParam, bool bContinue, int pad) = nullptr; +void * SQRNetworkManager_Vita::s_SignInCompleteParam = nullptr; sce::Toolkit::NP::PresenceDetails SQRNetworkManager_Vita::s_lastPresenceInfo; int SQRNetworkManager_Vita::s_resendPresenceCountdown = 0; bool SQRNetworkManager_Vita::s_presenceStatusDirty = false; @@ -98,8 +98,8 @@ SQRNetworkManager_Vita::SQRNetworkManager_Vita(ISQRNetworkManagerListener *liste m_isInSession = false; m_offlineGame = false; m_offlineSQR = false; - m_aServerId = NULL; - m_gameBootInvite = NULL; + m_aServerId = nullptr; + m_gameBootInvite = nullptr; m_onlineStatus = false; m_bLinkDisconnected = false; m_bShuttingDown = false; @@ -129,7 +129,7 @@ void SQRNetworkManager_Vita::Initialise() m_bShuttingDown = false; int32_t ret = 0; // int32_t libCtxId = 0; - // ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, NULL); + // ret = sceNpInGameMessageInitialize(NP_IN_GAME_MESSAGE_POOL_SIZE, nullptr); // assert (ret >= 0); // libCtxId = ret; @@ -162,7 +162,7 @@ void SQRNetworkManager_Vita::Initialise() } SetState(SNM_INT_STATE_SIGNING_IN); - // AttemptPSNSignIn(NULL, NULL); + // AttemptPSNSignIn(nullptr, nullptr); // SonyHttp::init(); @@ -170,7 +170,7 @@ void SQRNetworkManager_Vita::Initialise() // npConf.commId = &s_npCommunicationId; // npConf.commPassphrase = &s_npCommunicationPassphrase; // npConf.commSignature = &s_npCommunicationSignature; - // ret = sceNpInit(&npConf, NULL); + // ret = sceNpInit(&npConf, nullptr); // if (ret < 0 && ret != SCE_NP_ERROR_ALREADY_INITIALIZED) // { // app.DebugPrintf("sceNpInit failed, ret=%x\n", ret); @@ -295,7 +295,7 @@ void SQRNetworkManager_Vita::InitialiseAfterOnline() if( s_SignInCompleteCallbackFn ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } return; } @@ -329,7 +329,7 @@ void SQRNetworkManager_Vita::InitialiseAfterOnline() app.DebugPrintf("sceNpMatching2CreateContext\n"); ret = sceNpMatching2CreateContext(&npID, GetSceNpCommsId(), &s_npCommunicationPassphrase, &m_matchingContext); - //ret = sceNpMatching2CreateContext(&npID, NULL, NULL, &m_matchingContext); + //ret = sceNpMatching2CreateContext(&npID, nullptr, nullptr, &m_matchingContext); if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_CREATE_MATCHING_CONTEXT ) ) { @@ -377,7 +377,7 @@ void SQRNetworkManager_Vita::Tick() if( ( m_gameBootInvite ) && ( s_safeToRespondToGameBootInvite ) ) { m_listener->HandleInviteReceived( ProfileManager.GetPrimaryPad(), m_gameBootInvite ); - m_gameBootInvite = NULL; + m_gameBootInvite = nullptr; } ErrorHandlingTick(); @@ -444,12 +444,12 @@ void SQRNetworkManager_Vita::Tick() if( s_signInCompleteCallbackIfFailed ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } else if(s_SignInCompleteCallbackFn) { s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, 0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } @@ -467,7 +467,7 @@ void SQRNetworkManager_Vita::ErrorHandlingTick() { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } app.DebugPrintf("Network error: SNM_INT_STATE_INITIALISE_FAILED\n"); if( m_isInSession && m_offlineGame) // m_offlineSQR ) // MGH - changed this to m_offlineGame, as m_offlineSQR can be true when running an online game but the init has failed because the servers are down @@ -578,7 +578,7 @@ void SQRNetworkManager_Vita::UpdateExternalRoomData() reqParam.roomBinAttrExternal = &roomBinAttr; app.DebugPrintf("sceNpMatching2SetRoomDataExternal\n"); - int ret = sceNpMatching2SetRoomDataExternal ( m_matchingContext, &reqParam, NULL, &m_setRoomDataRequestId ); + int ret = sceNpMatching2SetRoomDataExternal ( m_matchingContext, &reqParam, nullptr, &m_setRoomDataRequestId ); app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2SetRoomDataExternal returns 0x%x, number of players %d\n",ret,((char *)m_joinExtData)[174]); if( ( ret < 0 ) || ForceErrorPoint( SNM_FORCE_ERROR_SET_EXTERNAL_ROOM_DATA ) ) { @@ -608,11 +608,11 @@ bool SQRNetworkManager_Vita::FriendRoomManagerSearch() } // Free up any external data that we received from the previous search - for( int i = 0; i < m_aFriendSearchResults.size(); i++ ) + for( size_t i = 0; i < m_aFriendSearchResults.size(); i++ ) { if(m_aFriendSearchResults[i].m_RoomExtDataReceived) free(m_aFriendSearchResults[i].m_RoomExtDataReceived); - m_aFriendSearchResults[i].m_RoomExtDataReceived = NULL; + m_aFriendSearchResults[i].m_RoomExtDataReceived = nullptr; } m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_COUNT; @@ -675,7 +675,7 @@ void SQRNetworkManager_Vita::FriendSearchTick() { m_friendSearchState = SNM_FRIEND_SEARCH_STATE_GETTING_FRIEND_INFO; delete m_getFriendCountThread; - m_getFriendCountThread = NULL; + m_getFriendCountThread = nullptr; FriendRoomManagerSearch2(); } } @@ -695,7 +695,7 @@ int SQRNetworkManager_Vita::BasicEventThreadProc( void *lpParameter ) // // do // { - // ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, NULL); + // ret = sceKernelWaitEqueue(manager->m_basicEventQueue, &event, 1, &outEv, nullptr); // // // If the sys_event_t we've sent here from the handler has a non-zero data1 element, this is to signify that we should terminate the thread // if( event.udata == 0 ) @@ -753,7 +753,7 @@ int SQRNetworkManager_Vita::GetFriendsThreadProc( void* lpParameter ) // There shouldn't ever be more than 100 friends returned but limit here just in case if( manager->m_friendCount > 100 ) manager->m_friendCount = 100; - SceNpId* friendIDs = NULL; + SceNpId* friendIDs = nullptr; if(manager->m_friendCount > 0) { // grab all the friend IDs first @@ -890,7 +890,7 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerByIndex(int idx) } else { - return NULL; + return nullptr; } } @@ -907,7 +907,7 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerBySmallId(int idx) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_Vita::GetLocalPlayerByUserIndex(int idx) @@ -923,7 +923,7 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetLocalPlayerByUserIndex(int idx) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } SQRNetworkPlayer *SQRNetworkManager_Vita::GetHostPlayer() @@ -936,11 +936,11 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetHostPlayer() SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerIfReady(SQRNetworkPlayer *player) { - if( player == NULL ) return NULL; + if( player == nullptr ) return nullptr; if( player->IsReady() ) return player; - return NULL; + return nullptr; } // Update state internally @@ -1039,7 +1039,7 @@ bool SQRNetworkManager_Vita::JoinRoom(SQRNetworkManager_Vita::SessionSearchResul { // Set up the presence info we would like to synchronise out when we have fully joined the game CPlatformNetworkManagerSony::SetSQRPresenceInfoFromExtData(&s_lastPresenceSyncInfo, searchResult->m_extData, searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId); - return JoinRoom(searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId, localPlayerMask, NULL); + return JoinRoom(searchResult->m_sessionId.m_RoomId, searchResult->m_sessionId.m_ServerId, localPlayerMask, nullptr); } // Join room with a specified roomId. This is used when joining from an invite, as well as by the previous method @@ -1106,7 +1106,7 @@ void SQRNetworkManager_Vita::LeaveRoom(bool bActuallyLeaveRoom) SetState(SNM_INT_STATE_LEAVING); app.DebugPrintf("sceNpMatching2LeaveRoom\n"); - int ret = sceNpMatching2LeaveRoom( m_matchingContext, &reqParam, NULL, &m_leaveRoomRequestId ); + int ret = sceNpMatching2LeaveRoom( m_matchingContext, &reqParam, nullptr, &m_leaveRoomRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_LEAVE_ROOM) ) { SetState(SNM_INT_STATE_LEAVING_FAILED); @@ -1214,7 +1214,7 @@ bool SQRNetworkManager_Vita::AddLocalPlayerByUserIndex(int idx) reqParam.roomMemberBinAttrInternal = &binAttr; app.DebugPrintf("sceNpMatching2SetRoomMemberDataInternal\n"); - int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, nullptr, &m_setRoomMemberInternalDataRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL) ) { @@ -1264,7 +1264,7 @@ bool SQRNetworkManager_Vita::RemoveLocalPlayerByUserIndex(int idx) // And do any adjusting necessary to the mappings from this room data, to the SQRNetworkPlayers. // This will also delete the SQRNetworkPlayer and do all the callbacks that requires etc. MapRoomSlotPlayers(roomSlotPlayerCount); - m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = nullptr; // Sync this back out to our networked clients... SyncRoomData(); @@ -1302,7 +1302,7 @@ bool SQRNetworkManager_Vita::RemoveLocalPlayerByUserIndex(int idx) reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, NULL, &m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( m_matchingContext, &reqParam, nullptr, &m_setRoomMemberInternalDataRequestId ); if( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_SET_ROOM_MEMBER_DATA_INTERNAL2) ) { @@ -1526,14 +1526,14 @@ void SQRNetworkManager_Vita::TickJoinablePresenceData() // // Signed in to PSN but not connected (no internet access) // UINT uiIDA[1]; // uiIDA[0] = IDS_OK; - // ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL, app.GetStringTable()); + // ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, nullptr, app.GetStringTable()); // } // else { // Not signed in to PSN UINT uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; - ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), &MustSignInReturnedPresenceInvite, NULL); + ui.RequestAlertMessage( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), &MustSignInReturnedPresenceInvite, nullptr); } } @@ -1573,7 +1573,7 @@ void SQRNetworkManager_Vita::FindOrCreateNonNetworkPlayer(int slot, int playerTy } } // Create the player - non-network players can be considered complete as soon as we create them as we aren't waiting on their network connections becoming complete, so can flag them as such and notify via callback - PlayerUID *pUID = NULL; + PlayerUID *pUID = nullptr; PlayerUID localUID; if( ( playerType == SQRNetworkPlayer::SNP_TYPE_LOCAL ) || m_isHosting && ( playerType == SQRNetworkPlayer::SNP_TYPE_HOST ) ) @@ -1640,7 +1640,7 @@ void SQRNetworkManager_Vita::MapRoomSlotPlayers(int roomSlotPlayerCount/*=-1*/) if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_REMOTE ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1696,7 +1696,7 @@ void SQRNetworkManager_Vita::MapRoomSlotPlayers(int roomSlotPlayerCount/*=-1*/) if( m_aRoomSlotPlayers[i]->m_type != SQRNetworkPlayer::SNP_TYPE_LOCAL ) { m_vecTempPlayers.push_back(m_aRoomSlotPlayers[i]); - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } } @@ -1788,7 +1788,7 @@ void SQRNetworkManager_Vita::UpdatePlayersFromRoomSyncUIDs() } // Host only - add remote players to our internal storage of player slots, and synchronise this with other room members. -bool SQRNetworkManager_Vita::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==NULL*/ ) +bool SQRNetworkManager_Vita::AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull/*==nullptr*/ ) { assert( m_isHosting ); @@ -1908,7 +1908,7 @@ void SQRNetworkManager_Vita::RemoveRemotePlayersAndSync( SceNpMatching2RoomMembe } // Zero last element, that isn't part of the currently sized array anymore memset(&m_roomSyncData.players[m_roomSyncData.getPlayerCount()],0,sizeof(PlayerSyncData)); - m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = NULL; + m_aRoomSlotPlayers[m_roomSyncData.getPlayerCount()] = nullptr; } else { @@ -1951,7 +1951,7 @@ void SQRNetworkManager_Vita::RemoveNetworkPlayers( int mask ) { if( m_aRoomSlotPlayers[i] == player ) { - m_aRoomSlotPlayers[i] = NULL; + m_aRoomSlotPlayers[i] = nullptr; } } // And delete the reference from the ctx->player map @@ -2004,7 +2004,7 @@ void SQRNetworkManager_Vita::SyncRoomData() roomBinAttr.size = sizeof( m_roomSyncData ); reqParam.roomBinAttrInternalNum = 1; reqParam.roomBinAttrInternal = &roomBinAttr; - sceNpMatching2SetRoomDataInternal ( m_matchingContext, &reqParam, NULL, &m_setRoomDataRequestId ); + sceNpMatching2SetRoomDataInternal ( m_matchingContext, &reqParam, nullptr, &m_setRoomDataRequestId ); } // Check if the matching context is valid, and if not attempt to create one. If to do this requires starting an asynchronous process, then sets the internal state to the state passed in @@ -2037,7 +2037,7 @@ bool SQRNetworkManager_Vita::GetMatchingContext(eSQRNetworkManagerInternalState // Create context app.DebugPrintf("sceNpMatching2CreateContext\n"); ret = sceNpMatching2CreateContext(&npId, &s_npCommunicationId, &s_npCommunicationPassphrase, &m_matchingContext/*, option*/); - //ret = sceNpMatching2CreateContext(&npId, NULL,NULL, &m_matchingContext/*, option*/); + //ret = sceNpMatching2CreateContext(&npId, nullptr,nullptr, &m_matchingContext/*, option*/); if( ret < 0 ) { app.DebugPrintf("SQRNetworkManager::GetMatchingContext - sceNpMatching2CreateContext failed with code 0x%08x\n", ret); @@ -2137,7 +2137,7 @@ bool SQRNetworkManager_Vita::GetServerContext(SceNpMatching2ServerId serverId) // { // // Get list of server IDs of servers allocated to the application. We don't actually need to do this, but it is as good a way as any to try a matching2 service and check that // // the context *really* is valid. - // int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, NULL, 0 ); + // int serverCount = sceNpMatching2GetServerIdListLocal( m_matchingContext, nullptr, 0 ); // // If an error is returned here, we need to destroy and recerate our server - if this goes ok we should come back through this path again // if( ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_UNAVAILABLE ) || // This error has been seen (occasionally) in a normal working environment // ( serverCount == SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_STARTED ) ) // Also checking for this as a means of simulating the previous error @@ -2233,7 +2233,7 @@ void SQRNetworkManager_Vita::RoomCreateTick() app.DebugPrintf(CMinecraftApp::USER_RR,">> Creating room start\n"); s_roomStartTime = System::currentTimeMillis(); app.DebugPrintf("sceNpMatching2CreateJoinRoom\n"); - int ret = sceNpMatching2CreateJoinRoom( m_matchingContext, &reqParam, NULL, &m_createRoomRequestId ); + int ret = sceNpMatching2CreateJoinRoom( m_matchingContext, &reqParam, nullptr, &m_createRoomRequestId ); if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_JOIN_ROOM) ) { SetState(SNM_INT_STATE_HOSTING_CREATE_ROOM_FAILED); @@ -2468,7 +2468,7 @@ bool SQRNetworkManager_Vita::CreateVoiceRudpConnections(SceNpMatching2RoomId roo // create this connection if we don't have it already SQRVoiceConnection* pConnection = SonyVoiceChat_Vita::getVoiceConnectionFromRoomMemberID(peerMemberId); - if(pConnection == NULL) + if(pConnection == nullptr) { // Create an Rudp context for the voice connection, this will happen regardless of whether the peer is client or host @@ -2542,7 +2542,7 @@ bool SQRNetworkManager_Vita::CreateRudpConnections(SceNpMatching2RoomId roomId, if ( ( ret < 0 ) || ForceErrorPoint(SNM_FORCE_ERROR_CREATE_RUDP_CONTEXT) ) return false; if( m_isHosting ) { - m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, playersMemberId, i, rudpCtx, NULL ); + m_RudpCtxToPlayerMap[ rudpCtx ] = new SQRNetworkPlayer( this, SQRNetworkPlayer::SNP_TYPE_REMOTE, true, playersMemberId, i, rudpCtx, nullptr ); } else { @@ -2576,7 +2576,7 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerFromRudpCtx(int rudpCtx) { return it->second; } - return NULL; + return nullptr; } @@ -2590,7 +2590,7 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerFromRoomMemberAndLocalIdx(int return it->second; } } - return NULL; + return nullptr; } @@ -2693,7 +2693,7 @@ void SQRNetworkManager_Vita::ContextCallback(SceNpMatching2ContextId id, SceNpM if( manager->m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { manager->SetState( SNM_INT_STATE_IDLE ); - manager->GetExtDataForRoom(0, NULL, NULL, NULL); + manager->GetExtDataForRoom(0, nullptr, nullptr, nullptr); break; } @@ -2729,7 +2729,7 @@ void SQRNetworkManager_Vita::ContextCallback(SceNpMatching2ContextId id, SceNpM // if(s_SignInCompleteCallbackFn) // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam, true, 0); - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } @@ -2966,12 +2966,12 @@ void SQRNetworkManager_Vita::DefaultRequestCallback(SceNpMatching2ContextId id, // Set flag to indicate whether we were kicked for being out of room or not reqParam.optData.data[0] = isFull ? 1 : 0; reqParam.optData.len = 1; - int ret = sceNpMatching2KickoutRoomMember(manager->m_matchingContext, &reqParam, NULL, &manager->m_kickRequestId); + int ret = sceNpMatching2KickoutRoomMember(manager->m_matchingContext, &reqParam, nullptr, &manager->m_kickRequestId); app.DebugPrintf(CMinecraftApp::USER_RR,"sceNpMatching2KickoutRoomMember returns error 0x%x\n",ret); } else { - if(pRoomMemberData->roomMemberDataInternal->roomMemberBinAttrInternal->data.ptr == NULL) + if(pRoomMemberData->roomMemberDataInternal->roomMemberBinAttrInternal->data.ptr == nullptr) { // the host doesn't send out data, so this must be the host we're connecting to @@ -3220,7 +3220,7 @@ void SQRNetworkManager_Vita::RoomEventCallback(SceNpMatching2ContextId id, SceNp reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2SetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, NULL, &manager->m_setRoomMemberInternalDataRequestId ); + int ret = sceNpMatching2SetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, nullptr, &manager->m_setRoomMemberInternalDataRequestId ); } else { @@ -3309,7 +3309,7 @@ void SQRNetworkManager_Vita::SignallingCallback(SceNpMatching2ContextId ctxId, S { SonyVoiceChat_Vita::disconnectRemoteConnection(pVoice); } - if(peerMemberId == manager->m_hostMemberId || pVoice == NULL) // MGH - added check for voice, as we sometime get here before m_hostMemberId has been filled in + if(peerMemberId == manager->m_hostMemberId || pVoice == nullptr) // MGH - added check for voice, as we sometime get here before m_hostMemberId has been filled in { // Host has left the game... so its all over for this client too. Finish everything up now, including deleting the server context which belongs to this gaming session // This also might be a response to a request to leave the game from our end too so don't need to do anything in that case @@ -3336,7 +3336,7 @@ void SQRNetworkManager_Vita::SignallingCallback(SceNpMatching2ContextId ctxId, S reqParam.attrId = attrs; reqParam.attrIdNum = 1; - sceNpMatching2GetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, NULL, &manager->m_roomMemberDataRequestId); + sceNpMatching2GetRoomMemberDataInternal( manager->m_matchingContext, &reqParam, nullptr, &manager->m_roomMemberDataRequestId); } break; } @@ -3349,7 +3349,7 @@ int SQRNetworkManager_Vita::BasicEventCallback(int event, int retCode, uint32_t PSVITA_STUBBED; // SQRNetworkManager_Vita *manager = (SQRNetworkManager_Vita *)arg; // // We aren't allowed to actually get the event directly from this callback, so send our own internal event to a thread dedicated to doing this - // sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, NULL); + // sceKernelTriggerUserEvent(m_basicEventQueue, sc_UserEventHandle, nullptr); return 0; } @@ -3408,7 +3408,7 @@ void SQRNetworkManager_Vita::SysUtilCallback(uint64_t status, uint64_t param, vo // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); // } - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } // return; // } @@ -3423,7 +3423,7 @@ void SQRNetworkManager_Vita::SysUtilCallback(uint64_t status, uint64_t param, vo // { // s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); // } - // s_SignInCompleteCallbackFn = NULL; + // s_SignInCompleteCallbackFn = nullptr; // } // } // @@ -3472,7 +3472,7 @@ void SQRNetworkManager_Vita::updateNetCheckDialog() if( s_SignInCompleteCallbackFn ) { s_SignInCompleteCallbackFn(s_SignInCompleteParam,true,0); - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } else @@ -3488,7 +3488,7 @@ void SQRNetworkManager_Vita::updateNetCheckDialog() { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -3611,7 +3611,7 @@ void SQRNetworkManager_Vita::RudpContextCallback(int ctx_id, int event_id, int e playerFrom = manager->m_aRoomSlotPlayers[0]; playerTo = manager->GetPlayerFromRudpCtx( ctx_id ); } - if( ( playerFrom != NULL ) && ( playerTo != NULL ) ) + if( ( playerFrom != nullptr ) && ( playerTo != nullptr ) ) { manager->m_listener->HandleDataReceived( playerFrom, playerTo, data, bytesRead ); } @@ -3677,7 +3677,7 @@ void SQRNetworkManager_Vita::ServerContextValid_CreateRoom() { app.DebugPrintf("sceNpMatching2GetWorldInfoList\n"); m_getWorldRequestId=0; - ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, NULL, &m_getWorldRequestId); + ret = sceNpMatching2GetWorldInfoList( m_matchingContext, &reqParam, nullptr, &m_getWorldRequestId); } if (ret < 0) { @@ -3706,7 +3706,7 @@ void SQRNetworkManager_Vita::ServerContextValid_JoinRoom() reqParam.roomMemberBinAttrInternalNum = 1; reqParam.roomMemberBinAttrInternal = &binAttr; - int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, NULL, &m_joinRoomRequestId ); + int ret = sceNpMatching2JoinRoom( m_matchingContext, &reqParam, nullptr, &m_joinRoomRequestId ); if ( (ret < 0) || ForceErrorPoint(SNM_FORCE_ERROR_JOIN_ROOM) ) { if( ret == SCE_NP_MATCHING2_SERVER_ERROR_NAT_TYPE_MISMATCH) @@ -3730,14 +3730,14 @@ const SceNpCommunicationSignature* SQRNetworkManager_Vita::GetSceNpCommsSig() const SceNpTitleId* SQRNetworkManager_Vita::GetSceNpTitleId() { PSVITA_STUBBED; - return NULL; + return nullptr; // return &s_npTitleId; } const SceNpTitleSecret* SQRNetworkManager_Vita::GetSceNpTitleSecret() { PSVITA_STUBBED; - return NULL; + return nullptr; // return &s_npTitleSecret; } @@ -3771,9 +3771,9 @@ void SQRNetworkManager_Vita::GetExtDataForRoom( SceNpMatching2RoomId roomId, voi static SceNpMatching2RoomId aRoomId[1]; static SceNpMatching2AttributeId attr[1]; - // All parameters will be NULL if this is being called a second time, after creating a new matching context via one of the paths below (using GetMatchingContext). - // NULL parameters therefore basically represents an attempt to retry the last sceNpMatching2GetRoomDataExternalList - if( extData != NULL ) + // All parameters will be nullptr if this is being called a second time, after creating a new matching context via one of the paths below (using GetMatchingContext). + // nullptr parameters therefore basically represents an attempt to retry the last sceNpMatching2GetRoomDataExternalList + if( extData != nullptr ) { aRoomId[0] = roomId; attr[0] = SCE_NP_MATCHING2_ROOM_BIN_ATTR_EXTERNAL_1_ID; @@ -3797,14 +3797,14 @@ void SQRNetworkManager_Vita::GetExtDataForRoom( SceNpMatching2RoomId roomId, voi return; } - // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with NULL params) once done, so we can reattempt. Don't do anything more now. + // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with nullptr params) once done, so we can reattempt. Don't do anything more now. if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { app.DebugPrintf("Having to recreate matching context, setting state to SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT\n"); return; } - int ret = sceNpMatching2GetRoomDataExternalList( m_matchingContext, &reqParam, NULL, &m_roomDataExternalListRequestId ); + int ret = sceNpMatching2GetRoomDataExternalList( m_matchingContext, &reqParam, nullptr, &m_roomDataExternalListRequestId ); // If we hadn't properly detected that a matching context was unvailable, we might still get an error indicating that it is from the previous call. Handle similarly, but we need // to destroy the context first. @@ -3818,7 +3818,7 @@ void SQRNetworkManager_Vita::GetExtDataForRoom( SceNpMatching2RoomId roomId, voi m_FriendSessionUpdatedFn(false, m_pParamFriendSessionUpdated); return; }; - // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with NULL params) once done, so we can reattempt. Don't do anything more now. + // Kicked off an asynchronous thing that will create a matching context, and then call this method back again (with nullptr params) once done, so we can reattempt. Don't do anything more now. if( m_state == SNM_INT_STATE_IDLE_RECREATING_MATCHING_CONTEXT ) { return; @@ -3957,7 +3957,7 @@ void SQRNetworkManager_Vita::AttemptPSNSignIn(int (*SignInCompleteCallbackFn)(vo { s_SignInCompleteCallbackFn(s_SignInCompleteParam,false,0); } - s_SignInCompleteCallbackFn = NULL; + s_SignInCompleteCallbackFn = nullptr; } } } @@ -4127,6 +4127,6 @@ SQRNetworkPlayer *SQRNetworkManager_Vita::GetPlayerByXuid(PlayerUID xuid) } } LeaveCriticalSection(&m_csRoomSyncData); - return NULL; + return nullptr; } diff --git a/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.h b/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.h index 0fd0b414..79befe03 100644 --- a/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.h +++ b/Minecraft.Client/PSVita/Network/SQRNetworkManager_Vita.h @@ -149,7 +149,7 @@ private: void LocalDataSend(SQRNetworkPlayer *playerFrom, SQRNetworkPlayer *playerTo, const void *data, unsigned int dataSize); int GetSessionIndex(SQRNetworkPlayer *player); - bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = NULL ); + bool AddRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int playerMask, bool *isFull = nullptr ); void RemoveRemotePlayersAndSync( SceNpMatching2RoomMemberId memberId, int mask ); void RemoveNetworkPlayers( int mask ); void SetLocalPlayersAndSync(); diff --git a/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.cpp index 09852ccb..88e661c6 100644 --- a/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.cpp @@ -10,22 +10,22 @@ bool SonyCommerce_Vita::m_bCommerceInitialised = false; // SceNpCommerce2SessionInfo SonyCommerce_Vita::m_sessionInfo; SonyCommerce_Vita::State SonyCommerce_Vita::m_state = e_state_noSession; int SonyCommerce_Vita::m_errorCode = 0; -LPVOID SonyCommerce_Vita::m_callbackParam = NULL; +LPVOID SonyCommerce_Vita::m_callbackParam = nullptr; -void* SonyCommerce_Vita::m_receiveBuffer = NULL; +void* SonyCommerce_Vita::m_receiveBuffer = nullptr; SonyCommerce_Vita::Event SonyCommerce_Vita::m_event; std::queue<SonyCommerce_Vita::Message> SonyCommerce_Vita::m_messageQueue; -std::vector<SonyCommerce_Vita::ProductInfo>* SonyCommerce_Vita::m_pProductInfoList = NULL; -SonyCommerce_Vita::ProductInfoDetailed* SonyCommerce_Vita::m_pProductInfoDetailed = NULL; -SonyCommerce_Vita::ProductInfo* SonyCommerce_Vita::m_pProductInfo = NULL; +std::vector<SonyCommerce_Vita::ProductInfo>* SonyCommerce_Vita::m_pProductInfoList = nullptr; +SonyCommerce_Vita::ProductInfoDetailed* SonyCommerce_Vita::m_pProductInfoDetailed = nullptr; +SonyCommerce_Vita::ProductInfo* SonyCommerce_Vita::m_pProductInfo = nullptr; -SonyCommerce_Vita::CategoryInfo* SonyCommerce_Vita::m_pCategoryInfo = NULL; -const char* SonyCommerce_Vita::m_pProductID = NULL; -char* SonyCommerce_Vita::m_pCategoryID = NULL; +SonyCommerce_Vita::CategoryInfo* SonyCommerce_Vita::m_pCategoryInfo = nullptr; +const char* SonyCommerce_Vita::m_pProductID = nullptr; +char* SonyCommerce_Vita::m_pCategoryID = nullptr; SonyCommerce_Vita::CheckoutInputParams SonyCommerce_Vita::m_checkoutInputParams; SonyCommerce_Vita::DownloadListInputParams SonyCommerce_Vita::m_downloadInputParams; -SonyCommerce_Vita::CallbackFunc SonyCommerce_Vita::m_callbackFunc = NULL; +SonyCommerce_Vita::CallbackFunc SonyCommerce_Vita::m_callbackFunc = nullptr; // sys_memory_container_t SonyCommerce_Vita::m_memContainer = SYS_MEMORY_CONTAINER_ID_INVALID; bool SonyCommerce_Vita::m_bUpgradingTrial = false; @@ -39,7 +39,7 @@ bool SonyCommerce_Vita::m_contextCreated=false; ///< npcommerce2 conte SonyCommerce_Vita::Phase SonyCommerce_Vita::m_currentPhase = e_phase_stopped; ///< Current commerce2 util // char SonyCommerce_Vita::m_commercebuffer[SCE_NP_COMMERCE2_RECV_BUF_SIZE]; -C4JThread* SonyCommerce_Vita::m_tickThread = NULL; +C4JThread* SonyCommerce_Vita::m_tickThread = nullptr; bool SonyCommerce_Vita::m_bLicenseChecked=false; // Check the trial/full license for the game bool SonyCommerce_Vita::m_bLicenseInstalled=false; // set to true when the licence has been downloaded and installed (but maybe not checked yet) bool SonyCommerce_Vita::m_bDownloadsPending=false; // set to true if there are any downloads happening in the background, so we check for them completing, and install when finished @@ -60,12 +60,12 @@ static bool s_showingPSStoreIcon = false; SonyCommerce_Vita::ProductInfoDetailed s_trialUpgradeProductInfoDetailed; void SonyCommerce_Vita::Delete() { - m_pProductInfoList=NULL; - m_pProductInfoDetailed=NULL; - m_pProductInfo=NULL; - m_pCategoryInfo = NULL; - m_pProductID = NULL; - m_pCategoryID = NULL; + m_pProductInfoList=nullptr; + m_pProductInfoDetailed=nullptr; + m_pProductInfo=nullptr; + m_pCategoryInfo = nullptr; + m_pProductID = nullptr; + m_pCategoryID = nullptr; } void SonyCommerce_Vita::Init() @@ -108,7 +108,7 @@ bool SonyCommerce_Vita::LicenseChecked() void SonyCommerce_Vita::CheckForTrialUpgradeKey() { - StorageManager.CheckForTrialUpgradeKey(CheckForTrialUpgradeKey_Callback, NULL); + StorageManager.CheckForTrialUpgradeKey(CheckForTrialUpgradeKey_Callback, nullptr); } int SonyCommerce_Vita::Shutdown() @@ -163,7 +163,7 @@ void SonyCommerce_Vita::checkBackgroundDownloadStatus() // install the content if(bInstallContent) { - InstallContent(InstallContentCallback, NULL); + InstallContent(InstallContentCallback, nullptr); } } } @@ -665,7 +665,7 @@ int SonyCommerce_Vita::createContext() // } // // // Create commerce2 context - // ret = sceNpCommerce2CreateCtx(SCE_NP_COMMERCE2_VERSION, &npId, commerce2Handler, NULL, &m_contextId); + // ret = sceNpCommerce2CreateCtx(SCE_NP_COMMERCE2_VERSION, &npId, commerce2Handler, nullptr, &m_contextId); // if (ret < 0) // { // app.DebugPrintf(4,"createContext sceNpCommerce2CreateCtx problem\n"); @@ -771,7 +771,7 @@ void SonyCommerce_Vita::commerce2Handler( const sce::Toolkit::NP::Event& event) // if(ret == SCE_OK) // { copyCategoryInfo(m_pCategoryInfo, g_categoryInfo.get()); - m_pCategoryInfo = NULL; + m_pCategoryInfo = nullptr; m_event = e_event_commerceGotCategoryInfo; // } @@ -781,7 +781,7 @@ void SonyCommerce_Vita::commerce2Handler( const sce::Toolkit::NP::Event& event) case sce::Toolkit::NP::Event::UserEvent::commerceGotProductList: { copyProductList(m_pProductInfoList, g_productList.get()); - m_pProductInfoDetailed = NULL; + m_pProductInfoDetailed = nullptr; m_event = e_event_commerceGotProductList; break; } @@ -791,12 +791,12 @@ void SonyCommerce_Vita::commerce2Handler( const sce::Toolkit::NP::Event& event) if(m_pProductInfoDetailed) { copyDetailedProductInfo(m_pProductInfoDetailed, g_detailedProductInfo.get()); - m_pProductInfoDetailed = NULL; + m_pProductInfoDetailed = nullptr; } else { copyAddDetailedProductInfo(m_pProductInfo, g_detailedProductInfo.get()); - m_pProductInfo = NULL; + m_pProductInfo = nullptr; } m_event = e_event_commerceGotDetailedProductInfo; break; @@ -1180,7 +1180,7 @@ void SonyCommerce_Vita::processEvent() break; case e_event_commerceProductBrowseFinished: app.DebugPrintf(4,"e_event_commerceProductBrowseFinished succeeded: 0x%x\n", m_errorCode); - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { runCallback(); } @@ -1232,7 +1232,7 @@ void SonyCommerce_Vita::processEvent() ProfileManager.SetSysUIShowing(false); // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { // get the detailed product info again, to see if the purchase has happened or not EnterCriticalSection(&m_queueLock); @@ -1260,7 +1260,7 @@ void SonyCommerce_Vita::processEvent() ProfileManager.SetSysUIShowing(false); // 4J-PB - if there's been an error - like dlc already purchased, the runcallback has already happened, and will crash this time - if(m_callbackFunc!=NULL) + if(m_callbackFunc!=nullptr) { runCallback(); } @@ -1328,10 +1328,10 @@ void SonyCommerce_Vita::CreateSession( CallbackFunc cb, LPVOID lpParam ) if(m_tickThread && (m_tickThread->isRunning() == false)) { delete m_tickThread; - m_tickThread = NULL; + m_tickThread = nullptr; } - if(m_tickThread == NULL) - m_tickThread = new C4JThread(TickLoop, NULL, "SonyCommerce_Vita tick"); + if(m_tickThread == nullptr) + m_tickThread = new C4JThread(TickLoop, nullptr, "SonyCommerce_Vita tick"); if(m_tickThread->isRunning() == false) { m_currentPhase = e_phase_idle; @@ -1439,7 +1439,7 @@ void SonyCommerce_Vita::DownloadAlreadyPurchased_Game( CallbackFunc cb, LPVOID l void SonyCommerce_Vita::InstallContent( CallbackFunc cb, LPVOID lpParam ) { - if(m_callbackFunc == NULL && m_messageQueue.size() == 0) // wait till other processes have finished + if(m_callbackFunc == nullptr && m_messageQueue.size() == 0) // wait till other processes have finished { EnterCriticalSection(&m_queueLock); m_bInstallingContent = true; diff --git a/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.h b/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.h index 6285832c..c8f76bf7 100644 --- a/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.h +++ b/Minecraft.Client/PSVita/Network/SonyCommerce_Vita.h @@ -121,14 +121,14 @@ class SonyCommerce_Vita : public SonyCommerce { assert(m_callbackFunc); CallbackFunc func = m_callbackFunc; - m_callbackFunc = NULL; + m_callbackFunc = nullptr; if(func) func(m_callbackParam, m_errorCode); m_errorCode = SCE_OK; } static void setCallback(CallbackFunc cb,LPVOID lpParam) { - assert(m_callbackFunc == NULL); + assert(m_callbackFunc == nullptr); m_callbackFunc = cb; m_callbackParam = lpParam; } diff --git a/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp index 9110edf5..2015f930 100644 --- a/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyHttp_Vita.cpp @@ -131,10 +131,10 @@ int SonyHttp_Vita::sslCallback(SceUInt32 verifyErr, SceSslCert * const sslCert[] (void)userArg; app.DebugPrintf("Ssl callback:\n"); - app.DebugPrintf("\tbase tmpl[%x]\n", (SceInt32)userArg); + app.DebugPrintf("\tbase tmpl[%x]\n", static_cast<SceInt32>(userArg)); if (verifyErr != 0){ - printSslError((SceInt32)SCE_HTTPS_ERROR_CERT, verifyErr); + printSslError(static_cast<SceInt32>(SCE_HTTPS_ERROR_CERT), verifyErr); } for (i = 0; i < certNum; i++){ printSslCertInfo(sslCert[i]); @@ -192,7 +192,7 @@ bool SonyHttp_Vita::http_get(const char *targetUrl, void** ppOutData, int* pData } /* Register SSL callback */ - ret = sceHttpsSetSslCallback(tmplId, sslCallback, (void*)&tmplId); + ret = sceHttpsSetSslCallback(tmplId, sslCallback, static_cast<void *>(&tmplId)); if (ret < 0) { app.DebugPrintf("sceHttpsSetSslCallback() error: 0x%08X\n", ret); @@ -215,7 +215,7 @@ bool SonyHttp_Vita::http_get(const char *targetUrl, void** ppOutData, int* pData } reqId = ret; - ret = sceHttpSendRequest(reqId, NULL, 0); + ret = sceHttpSendRequest(reqId, nullptr, 0); if (ret < 0) { app.DebugPrintf("sceHttpSendRequest() error: 0x%08X\n", ret); diff --git a/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp index c103b32f..dd6c8372 100644 --- a/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyRemoteStorage_Vita.cpp @@ -26,7 +26,7 @@ static SceRemoteStorageData s_getDataOutput; void SonyRemoteStorage_Vita::staticInternalCallback(const SceRemoteStorageEvent event, int32_t retCode, void * userData) { - ((SonyRemoteStorage_Vita*)userData)->internalCallback(event, retCode); + static_cast<SonyRemoteStorage_Vita *>(userData)->internalCallback(event, retCode); } void SonyRemoteStorage_Vita::internalCallback(const SceRemoteStorageEvent event, int32_t retCode) @@ -218,7 +218,7 @@ bool SonyRemoteStorage_Vita::init(CallbackFunc cb, LPVOID lpParam) params.timeout.receiveMs = 120 * 1000; //120 seconds is the default params.timeout.sendMs = 120 * 1000; //120 seconds is the default params.pool.memPoolSize = 7 * 1024 * 1024; - if(m_memPoolBuffer == NULL) + if(m_memPoolBuffer == nullptr) m_memPoolBuffer = malloc(params.pool.memPoolSize); params.pool.memPoolBuffer = m_memPoolBuffer; @@ -298,8 +298,8 @@ bool SonyRemoteStorage_Vita::setDataInternal() snprintf(m_saveFilename, sizeof(m_saveFilename), "%s:%s/GAMEDATA.bin", "savedata0", m_setDataSaveInfo->UTF8SaveFilename); - SceFiosSize outSize = sceFiosFileGetSizeSync(NULL, m_saveFilename); - m_uploadSaveSize = (int)outSize; + SceFiosSize outSize = sceFiosFileGetSizeSync(nullptr, m_saveFilename); + m_uploadSaveSize = static_cast<int>(outSize); strcpy(m_saveFileDesc, m_setDataSaveInfo->UTF8SaveTitle); m_status = e_setDataInProgress; diff --git a/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp b/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp index 842e6b8d..37fea828 100644 --- a/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp +++ b/Minecraft.Client/PSVita/Network/SonyVoiceChat_Vita.cpp @@ -67,7 +67,7 @@ void LoadPCMVoiceData() { char filename[64]; sprintf(filename, "voice%d.pcm", i+1); - HANDLE file = CreateFile(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE file = CreateFile(filename, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); DWORD dwHigh=0; g_loadedPCMVoiceDataSizes[i] = GetFileSize(file,&dwHigh); @@ -75,7 +75,7 @@ void LoadPCMVoiceData() { g_loadedPCMVoiceData[i] = new char[g_loadedPCMVoiceDataSizes[i]]; DWORD bytesRead; - BOOL bSuccess = ReadFile(file, g_loadedPCMVoiceData[i], g_loadedPCMVoiceDataSizes[i], &bytesRead, NULL); + BOOL bSuccess = ReadFile(file, g_loadedPCMVoiceData[i], g_loadedPCMVoiceDataSizes[i], &bytesRead, nullptr); assert(bSuccess); } g_loadedPCMVoiceDataPos[i] = 0; @@ -285,7 +285,7 @@ void SQRVoiceConnection::readRemoteData() if( dataSize > 0 ) { VoicePacket packet; - unsigned int bytesRead = sceRudpRead( m_rudpCtx, &packet, dataSize, 0, NULL ); + unsigned int bytesRead = sceRudpRead( m_rudpCtx, &packet, dataSize, 0, nullptr ); unsigned int writeSize; if( bytesRead > 0 ) { @@ -378,7 +378,7 @@ uint32_t lastReadFrameCnt = 0; void PrintAllOutputVoiceStates( std::vector<SQRVoiceConnection*>& connections) { - for(int rIdx=0;rIdx<connections.size(); rIdx++) + for(size_t rIdx=0;rIdx<connections.size(); rIdx++) { SQRVoiceConnection* pVoice = connections[rIdx]; SceVoiceBasePortInfo portInfo; @@ -470,7 +470,7 @@ void SonyVoiceChat_Vita::sendAllVoiceData() if(m_localVoiceDevices[i].isValid()) { bool bChatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(i,true,&bChatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(i,true,&bChatRestricted,nullptr,nullptr); if(bChatRestricted) { @@ -565,7 +565,7 @@ void SonyVoiceChat_Vita::sendAllVoiceData() EnterCriticalSection(&m_csRemoteConnections); // send this packet out to all our remote connections - for(int rIdx=0;rIdx<m_remoteConnections.size(); rIdx++) + for(size_t rIdx=0;rIdx<m_remoteConnections.size(); rIdx++) { SQRVoiceConnection* pVoice = m_remoteConnections[rIdx]; if(pVoice->m_bConnected) @@ -668,7 +668,7 @@ void SonyVoiceChat_Vita::tick() EnterCriticalSection(&m_csRemoteConnections); - for(int i=m_remoteConnections.size()-1;i>=0;i--) + for(int i = (int)m_remoteConnections.size() - 1; i >= 0; i--) { if(m_remoteConnections[i]->m_bFlaggedForShutdown) { @@ -911,7 +911,7 @@ void SonyVoiceChat_Vita::initLocalPlayer(int playerIndex) if(m_localVoiceDevices[playerIndex].isValid() == false) { bool chatRestricted = false; - ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,NULL,NULL); + ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),false,&chatRestricted,nullptr,nullptr); // create all device ports required m_localVoiceDevices[playerIndex].init(chatRestricted); @@ -948,7 +948,7 @@ SQRVoiceConnection* SonyVoiceChat_Vita::GetVoiceConnectionFromRudpCtx( int RudpC if(m_remoteConnections[i]->m_rudpCtx == RudpCtx) return m_remoteConnections[i]; } - return NULL; + return nullptr; } void SonyVoiceChat_Vita::connectPlayerToAll( int playerIndex ) @@ -973,7 +973,7 @@ SQRVoiceConnection* SonyVoiceChat_Vita::getVoiceConnectionFromRoomMemberID( SceN } } - return NULL; + return nullptr; } void SonyVoiceChat_Vita::disconnectLocalPlayer( int localIdx ) @@ -998,7 +998,7 @@ void SonyVoiceChat_Vita::disconnectLocalPlayer( int localIdx ) if(m_numLocalDevicesConnected == 0) // no more local players, kill all the remote connections { - for(int i=0;i<m_remoteConnections.size();i++) + for(size_t i=0;i<m_remoteConnections.size();i++) { delete m_remoteConnections[i]; } |
