aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Durango/Network
diff options
context:
space:
mode:
authorqwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com>2026-03-16 21:44:26 -0500
committerGitHub <noreply@github.com>2026-03-16 21:44:26 -0500
commitce739f6045ec72127491286ea3f3f21e537c1b55 (patch)
treef33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.Client/Durango/Network
parent255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff)
parent5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff)
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.Client/Durango/Network')
-rw-r--r--Minecraft.Client/Durango/Network/ChatIntegrationLayer.h2
-rw-r--r--Minecraft.Client/Durango/Network/DQRNetworkManager.cpp210
-rw-r--r--Minecraft.Client/Durango/Network/DQRNetworkManager.h26
-rw-r--r--Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp12
-rw-r--r--Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp16
-rw-r--r--Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp14
-rw-r--r--Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp2
-rw-r--r--Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp6
-rw-r--r--Minecraft.Client/Durango/Network/PartyController.cpp14
-rw-r--r--Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp60
-rw-r--r--Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h2
-rw-r--r--Minecraft.Client/Durango/Network/base64.cpp6
12 files changed, 185 insertions, 185 deletions
diff --git a/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h b/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h
index 80b4e10a..f81a0f1f 100644
--- a/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h
+++ b/Minecraft.Client/Durango/Network/ChatIntegrationLayer.h
@@ -238,7 +238,7 @@ private:
__in ChatPacketType chatPacketType
);
Concurrency::critical_section m_chatPacketStatsLock;
- int m_chatVoicePacketsStatistic[2][(int)Microsoft::Xbox::GameChat::ChatMessageType::InvalidMessage+1];
+ int m_chatVoicePacketsStatistic[2][static_cast<int>(Microsoft::Xbox::GameChat::ChatMessageType::InvalidMessage)+1];
};
std::shared_ptr<ChatIntegrationLayer> GetChatIntegrationLayer(); \ No newline at end of file
diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp
index 8d502d23..9e9e78c0 100644
--- a/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp
+++ b/Minecraft.Client/Durango/Network/DQRNetworkManager.cpp
@@ -25,7 +25,7 @@ int DQRNetworkManager::m_bootUserIndex;
wstring DQRNetworkManager::m_bootSessionName;
wstring DQRNetworkManager::m_bootServiceConfig;
wstring DQRNetworkManager::m_bootSessionTemplate;
-DQRNetworkManager * DQRNetworkManager::s_pDQRManager = NULL;
+DQRNetworkManager * DQRNetworkManager::s_pDQRManager = nullptr;
//using namespace Windows::Xbox::Networking;
@@ -43,7 +43,7 @@ DQRNetworkManager::SessionInfo::SessionInfo()
}
// This maps internal to extern states, and needs to match element-by-element the eSQRNetworkManagerInternalState enumerated type
-const DQRNetworkManager::eDQRNetworkManagerState DQRNetworkManager::m_INTtoEXTStateMappings[DQRNetworkManager::DNM_INT_STATE_COUNT] =
+const DQRNetworkManager::eDQRNetworkManagerState DQRNetworkManager::m_INTtoEXTStateMappings[DQRNetworkManager::DNM_INT_STATE_COUNT] =
{
DNM_STATE_INITIALISING, // DNM_INT_STATE_INITIALISING
DNM_STATE_INITIALISE_FAILED, // DNM_INT_STATE_INITIALISE_FAILED
@@ -64,7 +64,7 @@ const DQRNetworkManager::eDQRNetworkManagerState DQRNetworkManager::m_INTtoEXTSt
DNM_STATE_PLAYING, // DNM_INT_STATE_PLAYING
DNM_STATE_LEAVING, // DNM_INT_STATE_LEAVING
DNM_STATE_LEAVING, // DNM_INT_STATE_LEAVING_FAILED
- DNM_STATE_ENDING, // DNM_INT_STATE_ENDING
+ DNM_STATE_ENDING, // DNM_INT_STATE_ENDING
};
DQRNetworkManager::DQRNetworkManager(IDQRNetworkManagerListener *listener)
@@ -87,16 +87,16 @@ DQRNetworkManager::DQRNetworkManager(IDQRNetworkManagerListener *listener)
memset(&m_roomSyncData, 0, sizeof(m_roomSyncData));
memset(m_players, 0, sizeof(m_players));
- m_CreateSessionThread = NULL;
- m_GetFriendPartyThread = NULL;
- m_UpdateCustomSessionDataThread = NULL;
+ m_CreateSessionThread = nullptr;
+ m_GetFriendPartyThread = nullptr;
+ m_UpdateCustomSessionDataThread = nullptr;
- m_CheckPartyInviteThread = NULL;
+ m_CheckPartyInviteThread = nullptr;
m_notifyForFullParty = false;
m_customDataDirtyUpdateTicks = 0;
m_sessionResultCount = 0;
- m_sessionSearchResults = NULL;
+ m_sessionSearchResults = nullptr;
m_joinSessionUserMask = 0;
m_cancelJoinFromSearchResult = false;
@@ -146,7 +146,7 @@ void DQRNetworkManager::EnableDebugXBLContext(MXS::XboxLiveContext^ XBLContext)
// Show service calls from Xbox Services on the UI for easy debugging
XBLContext->Settings->EnableServiceCallRoutedEvents = true;
- XBLContext->Settings->ServiceCallRouted += ref new Windows::Foundation::EventHandler<Microsoft::Xbox::Services::XboxServiceCallRoutedEventArgs^>(
+ XBLContext->Settings->ServiceCallRouted += ref new Windows::Foundation::EventHandler<Microsoft::Xbox::Services::XboxServiceCallRoutedEventArgs^>(
[=]( Platform::Object^, Microsoft::Xbox::Services::XboxServiceCallRoutedEventArgs^ args )
{
//if( args->HttpStatus != 200 )
@@ -274,7 +274,7 @@ void DQRNetworkManager::JoinSession(int playerMask)
// If we found the session, then set the status of this member to be active (should be reserved). This will stop our slot timing out and us being dropped out of the session.
if( session != nullptr )
{
- if(!IsPlayerInSession(joiningUser->XboxUserId, session, NULL) )
+ if(!IsPlayerInSession(joiningUser->XboxUserId, session, nullptr) )
{
app.DebugPrintf("DNM_INT_STATE_JOINING_FAILED didn't find required player in session\n");
SetState(DNM_INT_STATE_JOINING_FAILED);
@@ -308,14 +308,14 @@ void DQRNetworkManager::JoinSession(int playerMask)
m_isHosting = false;
sockaddr_in6 localSocketAddressStorage;
-
+
ZeroMemory(&localSocketAddressStorage, sizeof(localSocketAddressStorage));
-
+
localSocketAddressStorage.sin6_family = AF_INET6;
localSocketAddressStorage.sin6_port = htons(m_associationTemplate->AcceptorSocketDescription->BoundPortRangeLower);
-
+
memcpy(&localSocketAddressStorage.sin6_addr, &in6addr_any, sizeof(in6addr_any));
-
+
m_localSocketAddress = Platform::ArrayReference<BYTE>(reinterpret_cast<BYTE*>(&localSocketAddressStorage), sizeof(localSocketAddressStorage));
m_joinCreateSessionAttempts = 0;
@@ -402,7 +402,7 @@ bool DQRNetworkManager::AddUsersToSession(int playerMask, MXSM::MultiplayerSessi
// We need to get a MultiplayerSession for each player that is joining
MXSM::MultiplayerSession^ session = nullptr;
-
+
WXS::User^ newUser = ProfileManager.GetUser(i);
if( newUser == nullptr )
{
@@ -451,12 +451,12 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
// We need to handle this differently for the host and other machines. As the procedure for adding a reserved slot for a local player whilst on the host doesn't seem to work
//
// On the host machine, we:
- //
+ //
// (1) Get a MPSD for the player that is being added
// (2) Call the join method
// (3) Write the MPSD
// (4) Update the player sync data, and broadcast out to all clients
-
+
// On remote machines, we:
//
// (1) join the party
@@ -473,10 +473,10 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
{
return false;
}
-
+
if( !m_isOfflineGame )
{
- // This is going to involve some async processing
+ // This is going to involve some async processing
MXS::XboxLiveContext^ newUserXBLContext = ref new MXS::XboxLiveContext(newUser);
if( newUserXBLContext == nullptr )
@@ -515,7 +515,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
pPlayer->SetSmallId(smallId);
pPlayer->SetName(ProfileManager.GetUser(userIndex)->DisplayInfo->Gamertag->Data());
pPlayer->SetDisplayName(ProfileManager.GetDisplayName(userIndex));
- pPlayer->SetUID(PlayerUID(ProfileManager.GetUser(userIndex)->XboxUserId->Data()));
+ pPlayer->SetUID(static_cast<PlayerUID>(ProfileManager.GetUser(userIndex)->XboxUserId->Data()));
// Also add to the party so that our friends can find us. The host will get notified of this additional player in the party, but we should ignore since we're already in the session
m_partyController->AddLocalUsersToParty(1 << userIndex, ProfileManager.GetUser(0));
@@ -550,7 +550,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
pPlayer->SetSmallId(m_currentSmallId++);
pPlayer->SetName(ProfileManager.GetUser(userIndex)->DisplayInfo->Gamertag->Data());
pPlayer->SetDisplayName(ProfileManager.GetDisplayName(userIndex));
- pPlayer->SetUID(PlayerUID(ProfileManager.GetUser(userIndex)->XboxUserId->Data()));
+ pPlayer->SetUID(static_cast<PlayerUID>(ProfileManager.GetUser(userIndex)->XboxUserId->Data()));
// TODO - could this add fail?
if(AddRoomSyncPlayer( pPlayer, 0, userIndex))
@@ -558,7 +558,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
SendRoomSyncInfo();
m_listener->HandlePlayerJoined(pPlayer); // This is for notifying of local players joining in an offline game
}
- else
+ else
{
// Can fail (notably if m_roomSyncData contains players who've left)
assert(0);
@@ -571,7 +571,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
{
// Check if there's any available slots before attempting to add the player to the party. We can still fail joining later if
// the host can't add a reserved slot for us for some reason but better checking on the client side before even attempting.
-
+
WXS::User^ newUser = ProfileManager.GetUser(userIndex);
MXS::XboxLiveContext^ newUserXBLContext = ref new MXS::XboxLiveContext(newUser);
@@ -600,7 +600,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
m_joinSessionXUIDs[userIndex] = ProfileManager.GetUser(userIndex)->XboxUserId;
m_partyController->AddLocalUsersToParty(1 << userIndex, ProfileManager.GetUser(0));
- m_addLocalPlayerSuccessPlayer = NULL;
+ m_addLocalPlayerSuccessPlayer = nullptr;
m_addLocalPlayerState = DNM_ADD_PLAYER_STATE_COMPLETE_SUCCESS;
}
}
@@ -622,16 +622,16 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
bool DQRNetworkManager::RemoveLocalPlayerByUserIndex(int userIndex)
{
- // We need to handle this differently for the host and other machines.
+ // We need to handle this differently for the host and other machines.
//
// On the host machine, we:
- //
+ //
// (1) Get a MPSD for the player that is being removed
// (2) Call the leave method
// (3) Write the MPSD
// (4) Leave the party
// (5) Update the player sync data, and broadcast out to all clients
-
+
// On remote machines, we:
//
// (1) Get a MPSD for the player that is being removed
@@ -651,7 +651,7 @@ bool DQRNetworkManager::RemoveLocalPlayerByUserIndex(int userIndex)
{
return false;
}
-
+
if( !m_isOfflineGame )
{
if( m_chat )
@@ -714,7 +714,7 @@ bool DQRNetworkManager::IsHost()
}
// Consider as "in session" from the moment that a game is created or joined, until the point where the game itself has been told via state change that we are now idle. The
-// game code requires IsInSession to return true as soon as it has asked to do one of these things (even if the state system hasn't really caught up with this request yet), and
+// game code requires IsInSession to return true as soon as it has asked to do one of these things (even if the state system hasn't really caught up with this request yet), and
// it also requires that it is informed of the state changes leading up to not being in the session, before this should report false.
bool DQRNetworkManager::IsInSession()
{
@@ -763,7 +763,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetPlayerBySmallId(int idx)
}
}
}
- return NULL;
+ return nullptr;
}
DQRNetworkPlayer *DQRNetworkManager::GetPlayerByXuid(PlayerUID xuid)
@@ -778,7 +778,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetPlayerByXuid(PlayerUID xuid)
}
}
}
- return NULL;
+ return nullptr;
}
// Retrieve player display name by gamertag
@@ -788,7 +788,7 @@ wstring DQRNetworkManager::GetDisplayNameByGamertag(wstring gamertag)
{
return m_displayNames[gamertag];
}
- else
+ else
{
return gamertag;
}
@@ -809,7 +809,7 @@ DQRNetworkPlayer *DQRNetworkManager::GetLocalPlayerByUserIndex(int idx)
}
}
}
- return NULL;
+ return nullptr;
}
DQRNetworkPlayer *DQRNetworkManager::GetHostPlayer()
@@ -892,7 +892,7 @@ void DQRNetworkManager::Tick_VoiceChat()
#endif
// If we have to inform the chat integration layer of any players that have joined, do that now
EnterCriticalSection(&m_csVecChatPlayers);
- for( int i = 0; i < m_vecChatPlayersJoined.size(); i++ )
+ for( size_t i = 0; i < m_vecChatPlayersJoined.size(); i++ )
{
int idx = m_vecChatPlayersJoined[i];
if( m_chat )
@@ -902,14 +902,14 @@ void DQRNetworkManager::Tick_VoiceChat()
{
m_chat->AddLocalUser(user);
}
- }
+ }
}
m_vecChatPlayersJoined.clear();
LeaveCriticalSection(&m_csVecChatPlayers);
}
void DQRNetworkManager::Tick_Party()
-{
+{
// If the primary player has been flagged as having left the party, then we don't respond immediately as it is possible we are just transitioning from one party to another, and it would be much
// nicer to handle this kind of transition directly. If we do get a new party within this time period, then we'll handle by asking the user if they want to leave the game they are currently in etc.
if( m_playersLeftParty )
@@ -919,7 +919,7 @@ void DQRNetworkManager::Tick_Party()
// We've waited long enough. User must (hopefully) have just left the party
// Previously we'd switch to offline but that causes a world of pain with forced sign-outs
if( m_playersLeftParty & 1 )
- {
+ {
// Before we switch to an offline game, check to see if there is currently a new party. If this is the case and
// we're here, then its because we were added to a party, but didn't receive a gamesessionready event. So if we have
// a party here that we've joined, and the number of players in the party (including us) is more than MAX_PLAYERS_IN_TEMPLATE,
@@ -955,7 +955,7 @@ void DQRNetworkManager::Tick_Party()
m_playersLeftParty = 0;
}
}
-
+
// Forced sign out
if (m_handleForcedSignOut)
{
@@ -967,19 +967,19 @@ void DQRNetworkManager::Tick_Party()
void DQRNetworkManager::Tick_CustomSessionData()
{
// If there was a thread updaing our custom session data, then clear it up if it is done
- if( m_UpdateCustomSessionDataThread != NULL )
+ if( m_UpdateCustomSessionDataThread != nullptr )
{
if( !m_UpdateCustomSessionDataThread->isRunning() )
{
delete m_UpdateCustomSessionDataThread;
- m_UpdateCustomSessionDataThread = NULL;
+ m_UpdateCustomSessionDataThread = nullptr;
}
}
// If our custom data is dirty, and we aren't currently updating, then kick off a thread to update it
if( m_isHosting && ( !m_isOfflineGame ) )
{
- if( m_UpdateCustomSessionDataThread == NULL )
+ if( m_UpdateCustomSessionDataThread == nullptr )
{
if( m_customDataDirtyUpdateTicks )
{
@@ -1003,7 +1003,7 @@ void DQRNetworkManager::Tick_AddAndRemoveLocalPlayers()
// A lot of handling adding local players is handled asynchronously. Trying to avoid having the callbacks that may result from this being called from the task threads, so handling this aspect of it here in the tick
if( m_addLocalPlayerState == DNM_ADD_PLAYER_STATE_COMPLETE_SUCCESS )
{
- // If we've completed, and we're the host, then we should have the new player to create stored here in m_localPlayerSuccessCreated. For clients, this will just be NULL as the actual
+ // If we've completed, and we're the host, then we should have the new player to create stored here in m_localPlayerSuccessCreated. For clients, this will just be nullptr as the actual
// adding of the player happens as part of a longer process of the host creating us a reserved slot etc. etc.
if( m_addLocalPlayerSuccessPlayer )
{
@@ -1064,7 +1064,7 @@ void DQRNetworkManager::Tick_ResolveGamertags()
HostGamertagResolveDetails *details = m_hostGamertagResolveResults.front();
details->m_pPlayer->SetName(details->m_name.c_str());
-
+
LogComment("Adding a player");
if( AddRoomSyncPlayer(details->m_pPlayer, details->m_sessionAddress, details->m_channel ) )
{
@@ -1154,7 +1154,7 @@ void DQRNetworkManager::Tick_StateMachine()
break;
case DNM_INT_STATE_JOINING_SENDING_UNRELIABLE:
{
- __int64 timeNow = System::currentTimeMillis();
+ int64_t timeNow = System::currentTimeMillis();
// m_firstUnreliableSendTime of 0 indicates that we haven't tried sending an unreliable packet yet so need to send one and initialise things
if( m_firstUnreliableSendTime == 0 )
{
@@ -1188,7 +1188,7 @@ void DQRNetworkManager::Tick_StateMachine()
{
// Timeout if we've been waiting for reserved slots for our joining players for too long. This is most likely because the host doesn't have room for all the slots we wanted, and we weren't able to determine this
// when we went to join the game (ie someone else was joining at the same time). At this point we need to remove any local players that did already join, from both the session and the party.
- __int64 timeNow = System::currentTimeMillis();
+ int64_t timeNow = System::currentTimeMillis();
if( ( timeNow - m_startedWaitingForReservationsTime ) > JOIN_RESERVATION_WAIT_TIME )
{
SetState(DNM_INT_STATE_JOINING_FAILED_TIDY_UP);
@@ -1201,7 +1201,7 @@ void DQRNetworkManager::Tick_StateMachine()
break;
case DNM_INT_STATE_HOSTING_WAITING_TO_PLAY:
delete m_CreateSessionThread;
- m_CreateSessionThread = NULL;
+ m_CreateSessionThread = nullptr;
// If the game is offline we can transition straight to playing
if (m_isOfflineGame) StartGame();
break;
@@ -1247,10 +1247,10 @@ void DQRNetworkManager::Tick_CheckInviteParty()
if( !m_CheckPartyInviteThread->isRunning() )
{
delete m_CheckPartyInviteThread;
- m_CheckPartyInviteThread = NULL;
+ m_CheckPartyInviteThread = nullptr;
}
}
- if( m_CheckPartyInviteThread == NULL )
+ if( m_CheckPartyInviteThread == nullptr )
{
m_inviteReceived = false;
m_CheckPartyInviteThread = new C4JThread(&DQRNetworkManager::_CheckInviteThreadProc, this, "Check invite thread");
@@ -1326,13 +1326,13 @@ void DQRNetworkManager::HandleSessionChange(MXSM::MultiplayerSession^ multiplaye
{
// 4J-JEV: This id is needed to link stats together.
// I thought setting the value from here would be less intrusive than adding an accessor.
- ((DurangoStats*)GenericStats::getInstance())->setMultiplayerCorrelationId(multiplayerSession->MultiplayerCorrelationId);
+ static_cast<DurangoStats *>(GenericStats::getInstance())->setMultiplayerCorrelationId(multiplayerSession->MultiplayerCorrelationId);
}
else
{
- ((DurangoStats*)GenericStats::getInstance())->setMultiplayerCorrelationId( nullptr );
+ static_cast<DurangoStats *>(GenericStats::getInstance())->setMultiplayerCorrelationId( nullptr );
}
-
+
m_multiplayerSession = multiplayerSession;
}
@@ -1362,7 +1362,7 @@ MXSM::MultiplayerSession^ DQRNetworkManager::WriteSessionHelper( MXS::XboxLiveCo
})
.wait();
- if( outputMultiplayerSession != nullptr &&
+ if( outputMultiplayerSession != nullptr &&
outputMultiplayerSession->SessionReference != nullptr )
{
app.DebugPrintf( "Session written OK\n" );
@@ -1403,7 +1403,7 @@ bool DQRNetworkManager::IsPlayerInSession( Platform::String^ xboxUserId, MXSM::M
{
Windows::Data::Json::JsonObject^ customConstant = Windows::Data::Json::JsonObject::Parse(member->MemberCustomConstantsJson);
Windows::Data::Json::JsonValue^ customValue = customConstant->GetNamedValue(L"smallId");
- *smallId = (int)(customValue->GetNumber()) & 255;
+ *smallId = static_cast<int>(customValue->GetNumber()) & 255;
}
catch (Platform::COMException^ ex)
{
@@ -1422,7 +1422,7 @@ WXM::MultiplayerSessionReference^ DQRNetworkManager::ConvertToWindowsXboxMultipl
{
return ref new WXM::MultiplayerSessionReference(
sessionRef->SessionName,
- sessionRef->ServiceConfigurationId,
+ sessionRef->ServiceConfigurationId,
sessionRef->SessionTemplateName
);
}
@@ -1449,7 +1449,7 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
for( int j = 0; j < m_roomSyncData.playerCount; j++ )
{
tempPlayers.push_back(m_players[j]);
- m_players[j] = NULL;
+ m_players[j] = nullptr;
}
// For each new player, it's either:
@@ -1458,7 +1458,7 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
// And when we are done, anything left in the temporary vector must be a player that left
for( int i = 0; i < pNewSyncData->playerCount; i++ )
{
- PlayerSyncData *pNewPlayer = &pNewSyncData->players[i];
+ PlayerSyncData *pNewPlayer = &pNewSyncData->players[i];
bool bAlreadyExisted = false;
for (auto it = tempPlayers.begin(); it != tempPlayers.end(); it++)
{
@@ -1491,7 +1491,7 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
}
LogCommentFormat(L"Adding new player, index %d - type %d, small Id %d, name %s, xuid %s\n",i,m_players[i]->m_type,pNewPlayer->m_smallId,pNewPlayer->m_name,pNewPlayer->m_XUID);
-
+
m_players[i]->SetSmallId(pNewPlayer->m_smallId);
m_players[i]->SetName(pNewPlayer->m_name);
m_players[i]->SetUID(PlayerUID(pNewPlayer->m_XUID));
@@ -1509,12 +1509,12 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
}
memcpy(&m_roomSyncData, pNewSyncData, sizeof(m_roomSyncData));
- for( int i = 0; i < tempPlayers.size(); i++ )
+ for( size_t i = 0; i < tempPlayers.size(); i++ )
{
m_listener->HandlePlayerLeaving(tempPlayers[i]);
delete tempPlayers[i];
}
- for( int i = 0; i < newPlayers.size(); i++ )
+ for( size_t i = 0; i < newPlayers.size(); i++ )
{
m_listener->HandlePlayerJoined(newPlayers[i]); // For clients, this is where we get notified of local and remote players joining
}
@@ -1525,7 +1525,7 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
bool DQRNetworkManager::AddRoomSyncPlayer(DQRNetworkPlayer *pPlayer, unsigned int sessionAddress, int channel)
{
if( m_roomSyncData.playerCount == MAX_ONLINE_PLAYER_COUNT ) return false;
-
+
EnterCriticalSection(&m_csRoomSyncData);
// Find the first entry that isn't us, to decide what to sync before. Don't consider entry #0 as this is reserved to indicate the host.
int insertAtIdx = m_roomSyncData.playerCount;
@@ -1552,11 +1552,11 @@ bool DQRNetworkManager::AddRoomSyncPlayer(DQRNetworkPlayer *pPlayer, unsigned in
{
m_roomSyncData.players[i] = m_roomSyncData.players[i-1];
m_players[i] = m_players[i - 1];
- }
+ }
m_roomSyncData.players[insertAtIdx].m_channel = channel;
m_roomSyncData.players[insertAtIdx].m_sessionAddress = sessionAddress;
int xuidLength = pPlayer->GetUID().toString().length() + 1; // +1 for terminator
- m_roomSyncData.players[insertAtIdx].m_XUID = new wchar_t [xuidLength];
+ m_roomSyncData.players[insertAtIdx].m_XUID = new wchar_t [xuidLength];
wcsncpy(m_roomSyncData.players[insertAtIdx].m_XUID, pPlayer->GetUID().toString().c_str(), xuidLength);
m_roomSyncData.players[insertAtIdx].m_smallId = pPlayer->GetSmallId();
wcscpy_s(m_roomSyncData.players[insertAtIdx].m_name, pPlayer->GetName());
@@ -1587,17 +1587,17 @@ void DQRNetworkManager::RemoveRoomSyncPlayersWithSessionAddress(unsigned int ses
{
m_roomSyncData.players[iWriteIdx] = m_roomSyncData.players[i];
m_players[iWriteIdx] = m_players[i];
- iWriteIdx++;
+ iWriteIdx++;
}
}
m_roomSyncData.playerCount = iWriteIdx;
- for( int i = 0; i < removedPlayers.size(); i++ )
+ for( size_t i = 0; i < removedPlayers.size(); i++ )
{
m_listener->HandlePlayerLeaving(removedPlayers[i]);
delete removedPlayers[i];
memset(&m_roomSyncData.players[m_roomSyncData.playerCount + i], 0, sizeof(PlayerSyncData));
- m_players[m_roomSyncData.playerCount + i] = NULL;
+ m_players[m_roomSyncData.playerCount + i] = nullptr;
}
LeaveCriticalSection(&m_csRoomSyncData);
}
@@ -1618,17 +1618,17 @@ void DQRNetworkManager::RemoveRoomSyncPlayer(DQRNetworkPlayer *pPlayer)
{
m_roomSyncData.players[iWriteIdx] = m_roomSyncData.players[i];
m_players[iWriteIdx] = m_players[i];
- iWriteIdx++;
+ iWriteIdx++;
}
}
m_roomSyncData.playerCount = iWriteIdx;
- for( int i = 0; i < removedPlayers.size(); i++ )
+ for( size_t i = 0; i < removedPlayers.size(); i++ )
{
m_listener->HandlePlayerLeaving(removedPlayers[i]);
delete removedPlayers[i];
memset(&m_roomSyncData.players[m_roomSyncData.playerCount + i], 0, sizeof(PlayerSyncData));
- m_players[m_roomSyncData.playerCount + i] = NULL;
+ m_players[m_roomSyncData.playerCount + i] = nullptr;
}
}
@@ -1643,7 +1643,7 @@ void DQRNetworkManager::SendRoomSyncInfo()
// (2) A single byte internal data tag
// (3) An unsigned int encoding the size of the combined size of all the strings in stage (5)
// (4) The RoomSyncData structure itself
- // (5) A wchar NULL terminated string for every active player to encode the XUID
+ // (5) A wchar nullptr terminated string for every active player to encode the XUID
unsigned int xuidBytes = 0;
for( int i = 0 ; i < m_roomSyncData.playerCount; i++ )
{
@@ -1659,13 +1659,13 @@ void DQRNetworkManager::SendRoomSyncInfo()
uint32_t sizeHigh = internalBytes >> 8;
uint32_t sizeLow = internalBytes & 0xff;
- data[0] = 0x80 | sizeHigh; // Header - flag as internal data (0x80), sending
+ data[0] = 0x80 | sizeHigh; // Header - flag as internal data (0x80), sending
data[1] = sizeLow; // Data following has the a single byte to say what it is, followed by the room sync data itself
data[2] = DQR_INTERNAL_PLAYER_TABLE;
memcpy(data + 3, &xuidBytes, 4);
memcpy(data + 7, &m_roomSyncData, sizeof(RoomSyncData));
- unsigned char *pucCurr = data + 7 + sizeof(RoomSyncData);
+ unsigned char *pucCurr = data + 7 + sizeof(RoomSyncData);
for( int i = 0 ; i < m_roomSyncData.playerCount; i++ )
{
@@ -1689,7 +1689,7 @@ void DQRNetworkManager::SendAddPlayerFailed(Platform::String^ xuid)
// (1) 2 byte general header
// (2) A single byte internal data tag
// (3) An unsigned int encoding the size size of the string
- // (5) A wchar NULL terminated string storing the xuid of the player which has failed to join
+ // (5) A wchar nullptr terminated string storing the xuid of the player which has failed to join
unsigned int xuidBytes = sizeof(wchar_t) * ( xuid->Length() + 1 );
@@ -1701,12 +1701,12 @@ void DQRNetworkManager::SendAddPlayerFailed(Platform::String^ xuid)
uint32_t sizeHigh = internalBytes >> 8;
uint32_t sizeLow = internalBytes & 0xff;
- data[0] = 0x80 | sizeHigh; // Header - flag as internal data (0x80), sending
+ data[0] = 0x80 | sizeHigh; // Header - flag as internal data (0x80), sending
data[1] = sizeLow; // Data following has the a single byte to say what it is, followed by the room sync data itself
data[2] = DQR_INTERNAL_ADD_PLAYER_FAILED;
memcpy(data + 3, &xuidBytes, 4);
- memcpy(data + 7, xuid->Data(), xuidBytes);
+ memcpy(data + 7, xuid->Data(), xuidBytes);
SendBytesRaw(-1, data, totalBytes, true);
@@ -1745,7 +1745,7 @@ void DQRNetworkManager::SendSmallId(bool reliableAndSequential, int playerMask)
{
Windows::Data::Json::JsonObject^ customConstant = Windows::Data::Json::JsonObject::Parse(member->MemberCustomConstantsJson);
Windows::Data::Json::JsonValue^ customValue = customConstant->GetNamedValue(L"smallId");
- smallId = (BYTE)(customValue->GetNumber());
+ smallId = static_cast<BYTE>(customValue->GetNumber());
bFound = true;
}
catch (Platform::COMException^ ex)
@@ -1797,7 +1797,7 @@ int DQRNetworkManager::GetSessionIndexForSmallId(unsigned char smallId)
{
Windows::Data::Json::JsonObject^ customConstant = Windows::Data::Json::JsonObject::Parse(member->MemberCustomConstantsJson);
Windows::Data::Json::JsonValue^ customValue = customConstant->GetNamedValue(L"smallId");
- smallIdMember = (BYTE)(customValue->GetNumber());
+ smallIdMember = static_cast<BYTE>(customValue->GetNumber());
}
catch (Platform::COMException^ ex)
{
@@ -1830,7 +1830,7 @@ int DQRNetworkManager::GetSessionIndexAndSmallIdForHost(unsigned char *smallId)
}
if( smallIdMember > 255 )
{
- *smallId = (BYTE)(smallIdMember);
+ *smallId = static_cast<BYTE>(smallIdMember);
return i;
}
}
@@ -1877,7 +1877,7 @@ Platform::String^ DQRNetworkManager::GetNextSmallIdAsJsonString()
int DQRNetworkManager::_HostGameThreadProc( void* lpParameter )
{
- DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter;
+ DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter);
return pDQR->HostGameThreadProc();
}
@@ -1927,7 +1927,7 @@ int DQRNetworkManager::HostGameThreadProc()
// Actually create the session (locally), using the primary player's context
try
{
- session = ref new MXSM::MultiplayerSession( primaryUserXBLContext,
+ session = ref new MXSM::MultiplayerSession( primaryUserXBLContext,
ref new MXSM::MultiplayerSessionReference( SERVICE_CONFIG_ID, MATCH_SESSION_TEMPLATE_NAME, sessionName ),
0, // this means that it will use the maxMembers specified in the session template.
false,
@@ -1972,7 +1972,7 @@ int DQRNetworkManager::HostGameThreadProc()
session->Join( GetNextSmallIdAsJsonString(), true );
session->SetCurrentUserStatus( MXSM::MultiplayerSessionMemberStatus::Active );
-
+
// Get device ID for current user & set in the session
Platform::String^ secureDeviceAddress = WXN::SecureDeviceAddress::GetLocal()->GetBase64String();
session->SetCurrentUserSecureDeviceAddressBase64( secureDeviceAddress );
@@ -1997,7 +1997,7 @@ int DQRNetworkManager::HostGameThreadProc()
return 0;
}
m_partyController->SetJoinability(m_listener->IsSessionJoinable());
-
+
// Add reservations for anyone in the party, who isn't the primary player. Just adding local players for now, but perhaps this should add
// other party members at this stage?
for ( WXM::PartyMember^ member : partyView->Members )
@@ -2029,8 +2029,8 @@ int DQRNetworkManager::HostGameThreadProc()
session->SetHostDeviceToken( hostMember->DeviceToken );
m_partyController->RegisterGamePlayersChangedEventHandler();
-
- // Update session on the server
+
+ // Update session on the server
HRESULT hr = S_OK;
session = WriteSessionHelper( primaryUserXBLContext, session, MXSM::MultiplayerSessionWriteMode::UpdateExisting, hr );
@@ -2086,14 +2086,14 @@ int DQRNetworkManager::HostGameThreadProc()
if( m_state == DNM_INT_STATE_HOSTING_FAILED) return 0;
sockaddr_in6 localSocketAddressStorage;
-
+
ZeroMemory(&localSocketAddressStorage, sizeof(localSocketAddressStorage));
-
+
localSocketAddressStorage.sin6_family = AF_INET6;
localSocketAddressStorage.sin6_port = htons(m_associationTemplate->AcceptorSocketDescription->BoundPortRangeLower);
-
+
memcpy(&localSocketAddressStorage.sin6_addr, &in6addr_any, sizeof(in6addr_any));
-
+
m_localSocketAddress = Platform::ArrayReference<BYTE>(reinterpret_cast<BYTE*>(&localSocketAddressStorage), sizeof(localSocketAddressStorage));
// This shouldn't ever happen, but seems worth checking that we don't have a pre-existing session in case there's any way to get here with one already running
@@ -2184,13 +2184,13 @@ int DQRNetworkManager::HostGameThreadProc()
if( m_currentUserMask & ( 1 << i ) && ProfileManager.IsSignedIn(i))
{
auto user = ProfileManager.GetUser(i);
- wstring displayName = ProfileManager.GetDisplayName(i);
+ wstring displayName = ProfileManager.GetDisplayName(i);
DQRNetworkPlayer* pPlayer = new DQRNetworkPlayer(this, ( ( smallId == m_hostSmallId ) ? DQRNetworkPlayer::DNP_TYPE_HOST : DQRNetworkPlayer::DNP_TYPE_LOCAL ), true, i, localSessionAddress);
pPlayer->SetSmallId(smallId);
pPlayer->SetName(user->DisplayInfo->Gamertag->Data());
pPlayer->SetDisplayName(displayName);
- pPlayer->SetUID(PlayerUID(user->XboxUserId->Data()));
+ pPlayer->SetUID(static_cast<PlayerUID>(user->XboxUserId->Data()));
AddRoomSyncPlayer( pPlayer, localSessionAddress, i);
@@ -2208,7 +2208,7 @@ int DQRNetworkManager::HostGameThreadProc()
int DQRNetworkManager::_LeaveRoomThreadProc( void* lpParameter )
{
- DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter;
+ DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter);
return pDQR->LeaveRoomThreadProc();
}
@@ -2234,7 +2234,7 @@ int DQRNetworkManager::LeaveRoomThreadProc()
// Request RTS to be terminated
RTS_Terminate();
-
+
// Now leave the game session. We need to do this for each player in turn, writing each time
bool bError = false;
for( int i = 0; i < 4; i++ )
@@ -2311,7 +2311,7 @@ int DQRNetworkManager::LeaveRoomThreadProc()
int DQRNetworkManager::_TidyUpJoinThreadProc( void* lpParameter )
{
- DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter;
+ DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter);
return pDQR->TidyUpJoinThreadProc();
}
@@ -2339,7 +2339,7 @@ int DQRNetworkManager::TidyUpJoinThreadProc()
// We can fail to join at various points, and in at least one case (if it is down to RUDP unreliable packets timing out) then we don't have m_joinSessionUserMask bits set any more,
// but we Do have m_currentUserMask set. Any of these should be considered users we should be attempting to remove from the session.
- int removeSessionMask = m_joinSessionUserMask | m_currentUserMask;
+ int removeSessionMask = m_joinSessionUserMask | m_currentUserMask;
for( int i = 0; i < 4; i++ )
{
if( removeSessionMask & ( 1 << i ) )
@@ -2416,7 +2416,7 @@ int DQRNetworkManager::TidyUpJoinThreadProc()
int DQRNetworkManager::_UpdateCustomSessionDataThreadProc( void* lpParameter )
{
- DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter;
+ DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter);
return pDQR->UpdateCustomSessionDataThreadProc();
}
@@ -2428,7 +2428,7 @@ int DQRNetworkManager::UpdateCustomSessionDataThreadProc()
{
LogComment(L"Starting thread to update custom data");
WXS::User^ primaryUser = ProfileManager.GetUser(0);
-
+
if( primaryUser == nullptr )
{
return 0;
@@ -2491,7 +2491,7 @@ int DQRNetworkManager::UpdateCustomSessionDataThreadProc()
int DQRNetworkManager::_CheckInviteThreadProc(void* lpParameter)
{
- DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter;
+ DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter);
return pDQR->CheckInviteThreadProc();
}
@@ -2550,7 +2550,7 @@ void DQRNetworkManager::HandlePlayerRemovedFromParty(int playerMask)
{
// As a client, we don't have any messy changing to offline game or saving etc. to do, so we can respond immediately to leaving the party
if( playerMask & 1 )
- {
+ {
DQRNetworkManager::LogComment(L"Primary player on this system has left the party - leaving game\n");
app.SetDisconnectReason(DisconnectPacket::eDisconnect_ExitedGame);
LeaveRoom();
@@ -2614,7 +2614,7 @@ void DQRNetworkManager::LeaveRoom()
for( int i = 0; i < m_roomSyncData.playerCount; i++ )
{
delete m_players[i];
- m_players[i] = NULL;
+ m_players[i] = nullptr;
}
memset(&m_roomSyncData, 0, sizeof(m_roomSyncData));
m_displayNames.clear();
@@ -2725,7 +2725,7 @@ bool DQRNetworkManager::JoinPartyFromSearchResult(SessionSearchResult *searchRes
m_joinSessionUserMask = playerMask;
m_isInSession = true;
m_isOfflineGame = false;
-
+
m_startedWaitingForReservationsTime = System::currentTimeMillis();
SetState(DNM_INT_STATE_JOINING_WAITING_FOR_RESERVATIONS);
@@ -2742,7 +2742,7 @@ bool DQRNetworkManager::JoinPartyFromSearchResult(SessionSearchResult *searchRes
if( sessionRef != nullptr )
{
// Allow 2 seconds before we let the player cancel
- __int64 allowCancelTime = System::currentTimeMillis() + (1000 * 2);
+ int64_t allowCancelTime = System::currentTimeMillis() + (1000 * 2);
// Now leave the game session. We need to do this for each player in turn, writing each time. Consider that any of the joining
// members *may* have a slot (reserved or active) depending on how far progressed the joining got.
@@ -2814,7 +2814,7 @@ bool DQRNetworkManager::JoinPartyFromSearchResult(SessionSearchResult *searchRes
break;
}
- __int64 currentTime = System::currentTimeMillis();
+ int64_t currentTime = System::currentTimeMillis();
if( currentTime > allowCancelTime)
{
shownCancelScreen = true;
@@ -2893,7 +2893,7 @@ bool DQRNetworkManager::JoinPartyFromSearchResult(SessionSearchResult *searchRes
SetState(DNM_INT_STATE_JOINING_FAILED);
}
});
-
+
while(!ccTask.is_done())
{
@@ -3013,7 +3013,7 @@ void DQRNetworkManager::RequestDisplayName(DQRNetworkPlayer *player)
{
if (player->IsLocal())
{
- // Player is local so we can just ask profile manager
+ // Player is local so we can just ask profile manager
SetDisplayName(player->GetUID(), ProfileManager.GetDisplayName(player->GetLocalPlayerIndex()));
}
else
@@ -3026,8 +3026,8 @@ void DQRNetworkManager::RequestDisplayName(DQRNetworkPlayer *player)
void DQRNetworkManager::GetProfileCallback(LPVOID pParam, Microsoft::Xbox::Services::Social::XboxUserProfile^ profile)
{
- DQRNetworkManager *dqnm = (DQRNetworkManager *)pParam;
- dqnm->SetDisplayName(PlayerUID(profile->XboxUserId->Data()), profile->GameDisplayName->Data());
+ DQRNetworkManager *dqnm = static_cast<DQRNetworkManager *>(pParam);
+ dqnm->SetDisplayName(static_cast<PlayerUID>(profile->XboxUserId->Data()), profile->GameDisplayName->Data());
}
// Set player display name
diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager.h b/Minecraft.Client/Durango/Network/DQRNetworkManager.h
index 5f7b8d90..b74e079c 100644
--- a/Minecraft.Client/Durango/Network/DQRNetworkManager.h
+++ b/Minecraft.Client/Durango/Network/DQRNetworkManager.h
@@ -131,7 +131,7 @@ public:
static const int MAX_ONLINE_PLAYER_COUNT = 8;
static const int MAX_ONLINE_PLAYER_NAME_LENGTH = 21;
- // This class stores everything about a player that must be synchronised between machines.
+ // This class stores everything about a player that must be synchronised between machines.
class PlayerSyncData
{
public:
@@ -210,7 +210,7 @@ public:
DNM_STATE_JOINING,
DNM_STATE_STARTING,
- DNM_STATE_PLAYING,
+ DNM_STATE_PLAYING,
DNM_STATE_LEAVING,
DNM_STATE_ENDING,
@@ -221,7 +221,7 @@ public:
class SessionSearchResult
{
public:
- SessionSearchResult() { m_extData = NULL; }
+ SessionSearchResult() { m_extData = nullptr; }
~SessionSearchResult() { free(m_extData); }
wstring m_partyId;
wstring m_sessionName;
@@ -339,9 +339,9 @@ private:
static const eDQRNetworkManagerState m_INTtoEXTStateMappings[DNM_INT_STATE_COUNT];
eDQRNetworkManagerInternalState m_state;
eDQRNetworkManagerState m_stateExternal;
- __int64 m_lastUnreliableSendTime;
- __int64 m_firstUnreliableSendTime;
- __int64 m_startedWaitingForReservationsTime;
+ int64_t m_lastUnreliableSendTime;
+ int64_t m_firstUnreliableSendTime;
+ int64_t m_startedWaitingForReservationsTime;
unsigned char *m_customSessionData;
unsigned int m_customSessionDataSize;
int m_customDataDirtyUpdateTicks;
@@ -361,7 +361,7 @@ private:
CRITICAL_SECTION m_csRoomSyncData;
RoomSyncData m_roomSyncData;
- DQRNetworkPlayer *m_players[MAX_ONLINE_PLAYER_COUNT];
+ DQRNetworkPlayer *m_players[MAX_ONLINE_PLAYER_COUNT];
IDQRNetworkManagerListener *m_listener;
PartyController *m_partyController;
@@ -389,7 +389,7 @@ private:
int m_joinCreateSessionAttempts;
C4JThread *m_CreateSessionThread;
- C4JThread *m_LeaveRoomThread;
+ C4JThread *m_LeaveRoomThread;
C4JThread *m_TidyUpJoinThread;
C4JThread *m_UpdateCustomSessionDataThread;
C4JThread *m_RTS_DoWorkThread;
@@ -426,7 +426,7 @@ private:
int GetQueueSizeMessages();
void SendBytesRaw(int smallId, BYTE *bytes, int byteCount, bool reliableAndSequential);
void SendBytesChat(unsigned int address, BYTE *bytes, int byteCount, bool reliable, bool sequential, bool broadcast);
-
+
bool AddRoomSyncPlayer(DQRNetworkPlayer *pPlayer, unsigned int sessionAddress, int channel);
void RemoveRoomSyncPlayersWithSessionAddress(unsigned int sessionAddress);
void RemoveRoomSyncPlayer(DQRNetworkPlayer *pPlayer);
@@ -438,7 +438,7 @@ private:
int GetSessionIndexForSmallId(unsigned char smallId);
int GetSessionIndexAndSmallIdForHost(unsigned char *smallId);
- static void LogComment( Platform::String^ strText );
+ static void LogComment( Platform::String^ strText );
static void LogCommentFormat( LPCWSTR strMsg, ... );
static void LogCommentWithError( Platform::String^ strTest, HRESULT hr );
@@ -491,7 +491,7 @@ public:
void SetDisplayName(PlayerUID xuid, wstring displayName);
private:
- __int64 m_playersLeftPartyTime;
+ int64_t m_playersLeftPartyTime;
int m_playersLeftParty;
bool GetBestPartyUserIndex();
@@ -502,7 +502,7 @@ private:
bool GetGameSessionData(MXSM::MultiplayerSession^ session, void *gameSessionData);
public:
- static Platform::Collections::Vector<Platform::String^>^ GetFriends();
+ static Platform::Collections::Vector<Platform::String^>^ GetFriends();
private:
SessionSearchResult *m_sessionSearchResults;
@@ -551,7 +551,7 @@ private:
void Process_RTS_MESSAGE_STATUS_TERMINATED(RTS_Message &message);
// Outgoing messages - to be called from the RTS work thread, to process requests from the main thread
-
+
void ProcessRTSMessagesOutgoing();
void Process_RTS_MESSAGE_START_CLIENT(RTS_Message &message);
void Process_RTS_MESSAGE_START_HOST(RTS_Message &message);
diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp
index 3a14a2d5..0822a93c 100644
--- a/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp
+++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_FriendSessions.cpp
@@ -49,7 +49,7 @@ bool DQRNetworkManager::FriendPartyManagerSearch()
m_sessionResultCount = 0;
delete [] m_sessionSearchResults;
- m_sessionSearchResults = NULL;
+ m_sessionSearchResults = nullptr;
m_GetFriendPartyThread = new C4JThread(&_GetFriendsThreadProc,this,"GetFriendsThreadProc");
m_GetFriendPartyThread->Run();
@@ -61,7 +61,7 @@ bool DQRNetworkManager::FriendPartyManagerSearch()
void DQRNetworkManager::FriendPartyManagerGetSessionInfo(int idx, SessionSearchResult *searchResult)
{
assert( idx < m_sessionResultCount );
- assert( ( m_GetFriendPartyThread == NULL ) || ( !m_GetFriendPartyThread->isRunning()) );
+ assert( ( m_GetFriendPartyThread == nullptr ) || ( !m_GetFriendPartyThread->isRunning()) );
// Need to make sure that copied data has independently allocated m_extData, so both copies can be freed
*searchResult = m_sessionSearchResults[idx];
@@ -71,7 +71,7 @@ void DQRNetworkManager::FriendPartyManagerGetSessionInfo(int idx, SessionSearchR
int DQRNetworkManager::_GetFriendsThreadProc(void* lpParameter)
{
- DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter;
+ DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter);
return pDQR->GetFriendsThreadProc();
}
@@ -410,7 +410,7 @@ int DQRNetworkManager::GetFriendsThreadProc()
for( int j = 0; j < nameResolveVector[i]->Size; j++ )
{
m_sessionSearchResults[i].m_playerNames[j] = nameResolveVector[i]->GetAt(j)->GameDisplayName->Data();
- m_sessionSearchResults[i].m_playerXuids[j] = PlayerUID(nameResolveVector[i]->GetAt(j)->XboxUserId->Data());
+ m_sessionSearchResults[i].m_playerXuids[j] = static_cast<PlayerUID>(nameResolveVector[i]->GetAt(j)->XboxUserId->Data());
}
m_sessionSearchResults[i].m_playerCount = nameResolveVector[i]->Size;
m_sessionSearchResults[i].m_usedSlotCount = newSessionVector[i]->Members->Size;
@@ -556,7 +556,7 @@ bool DQRNetworkManager::IsSessionFriendsOfFriends(MXSM::MultiplayerSession^ sess
if (result)
{
- friendsOfFriends = app.GetGameHostOption(((GameSessionData *)gameSessionData)->m_uiGameHostSettings, eGameHostOption_FriendsOfFriends);
+ friendsOfFriends = app.GetGameHostOption(static_cast<GameSessionData *>(gameSessionData)->m_uiGameHostSettings, eGameHostOption_FriendsOfFriends);
}
free(gameSessionData);
@@ -577,7 +577,7 @@ bool DQRNetworkManager::GetGameSessionData(MXSM::MultiplayerSession^ session, vo
Platform::String ^customValueString = customValue->GetString();
if( customValueString )
{
- base64_decode( customValueString, (unsigned char *)gameSessionData, sizeof(GameSessionData) );
+ base64_decode( customValueString, static_cast<unsigned char *>(gameSessionData), sizeof(GameSessionData) );
return true;
}
}
diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp
index 9232d095..eed3e851 100644
--- a/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp
+++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_SendReceive.cpp
@@ -24,7 +24,7 @@ void DQRNetworkManager::BytesReceived(int smallId, BYTE *bytes, int byteCount)
DQRNetworkPlayer *host = GetPlayerBySmallId(m_hostSmallId);
DQRNetworkPlayer *client = GetPlayerBySmallId(smallId);
- if( ( host == NULL ) || ( client == NULL ) )
+ if( ( host == nullptr ) || ( client == nullptr ) )
{
return;
}
@@ -113,7 +113,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo,
case DQRConnectionInfo::ConnectionState_InternalAssignSmallId2:
case DQRConnectionInfo::ConnectionState_InternalAssignSmallId3:
{
- int channel = ((int)connectionInfo->m_internalDataState) - DQRConnectionInfo::ConnectionState_InternalAssignSmallId0;
+ int channel = static_cast<int>(connectionInfo->m_internalDataState) - DQRConnectionInfo::ConnectionState_InternalAssignSmallId0;
if( ( connectionInfo->m_smallIdReadMask & ( 1 << channel ) ) && ( !connectionInfo->m_channelActive[channel] ) )
{
@@ -137,7 +137,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo,
DQRNetworkPlayer *pPlayer = new DQRNetworkPlayer(this, DQRNetworkPlayer::DNP_TYPE_REMOTE, true, 0, sessionAddress);
pPlayer->SetSmallId(byte);
- pPlayer->SetUID(PlayerUID(m_multiplayerSession->Members->GetAt(sessionIndex)->XboxUserId->Data()));
+ pPlayer->SetUID(static_cast<PlayerUID>(m_multiplayerSession->Members->GetAt(sessionIndex)->XboxUserId->Data()));
HostGamertagResolveDetails *resolveDetails = new HostGamertagResolveDetails();
resolveDetails->m_pPlayer = pPlayer;
@@ -238,7 +238,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo,
UpdateRoomSyncPlayers((RoomSyncData *)connectionInfo->m_pucRoomSyncData);
delete connectionInfo->m_pucRoomSyncData;
- connectionInfo->m_pucRoomSyncData = NULL;
+ connectionInfo->m_pucRoomSyncData = nullptr;
connectionInfo->m_internalDataState = DQRConnectionInfo::ConnectionState_InternalHeaderByte;
// If we haven't actually established a connection yet for this channel, then this is the point where we can consider this active
@@ -267,7 +267,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo,
{
if( m_currentUserMask & ( 1 << i ) )
{
- if( GetLocalPlayerByUserIndex(i) == NULL )
+ if( GetLocalPlayerByUserIndex(i) == nullptr )
{
allLocalPlayersHere = false;
}
@@ -307,7 +307,7 @@ void DQRNetworkManager::BytesReceivedInternal(DQRConnectionInfo *connectionInfo,
// XUID fully read, can now handle what to do with it
AddPlayerFailed(ref new Platform::String( (wchar_t *)connectionInfo->m_pucAddFailedPlayerData ) );
delete [] connectionInfo->m_pucAddFailedPlayerData;
- connectionInfo->m_pucAddFailedPlayerData = NULL;
+ connectionInfo->m_pucAddFailedPlayerData = nullptr;
connectionInfo->m_internalDataState = DQRConnectionInfo::ConnectionState_InternalHeaderByte;
}
@@ -371,7 +371,7 @@ void DQRNetworkManager::SendBytesChat(unsigned int address, BYTE *bytes, int byt
void DQRNetworkManager::SendBytes(int smallId, BYTE *bytes, int byteCount)
{
EnterCriticalSection(&m_csSendBytes);
- unsigned char *tempSendBuffer = (unsigned char *)malloc(8191 + 2);
+ unsigned char *tempSendBuffer = static_cast<unsigned char *>(malloc(8191 + 2));
BYTE *data = bytes;
BYTE *dataEnd = bytes + byteCount;
@@ -381,7 +381,7 @@ void DQRNetworkManager::SendBytes(int smallId, BYTE *bytes, int byteCount)
// blocks of this size.
do
{
- int bytesToSend = (int)(dataEnd - data);
+ int bytesToSend = static_cast<int>(dataEnd - data);
if( bytesToSend > 8191 ) bytesToSend = 8191;
// Send header with data sending mode - see full comment in DQRNetworkManagerEventHandlers::DataReceivedHandler
diff --git a/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp b/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp
index c985a191..ae7094fb 100644
--- a/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp
+++ b/Minecraft.Client/Durango/Network/DQRNetworkManager_XRNSEvent.cpp
@@ -84,7 +84,7 @@ void DQRNetworkManagerEventHandlers::DataReceivedHandler(Platform::Object^ sessi
}
rtsMessage.m_sessionAddress = args->SessionAddress;
rtsMessage.m_dataSize = args->Data->Length;
- rtsMessage.m_pucData = (unsigned char *)malloc(rtsMessage.m_dataSize);
+ rtsMessage.m_pucData = static_cast<unsigned char *>(malloc(rtsMessage.m_dataSize));
memcpy( rtsMessage.m_pucData, args->Data->Data, rtsMessage.m_dataSize );
m_pDQRNet->m_RTSMessageQueueIncoming.push(rtsMessage);
LeaveCriticalSection(&m_pDQRNet->m_csRTSMessageQueueIncoming);
@@ -311,7 +311,7 @@ void DQRNetworkManager::Process_RTS_MESSAGE_DATA_RECEIVED(RTS_Message &message)
break;
case DQRConnectionInfo::ConnectionState_ReadBytes:
// At this stage we can send up to connectionInfo->m_bytesRemaining bytes, or the number of bytes that we have remaining in the data received, whichever is lowest.
- int bytesInBuffer = (int)(pEndByte - pNextByte);
+ int bytesInBuffer = static_cast<int>(pEndByte - pNextByte);
int bytesToReceive = ( ( connectionInfo->m_bytesRemaining < bytesInBuffer ) ? connectionInfo->m_bytesRemaining : bytesInBuffer );
if( connectionInfo->m_internalFlag )
@@ -438,7 +438,7 @@ void DQRNetworkManager::Process_RTS_MESSAGE_STATUS_TERMINATED(RTS_Message &messa
int DQRNetworkManager::_RTSDoWorkThread(void* lpParameter)
{
- DQRNetworkManager *pDQR = (DQRNetworkManager *)lpParameter;
+ DQRNetworkManager *pDQR = static_cast<DQRNetworkManager *>(lpParameter);
return pDQR->RTSDoWorkThread();
}
@@ -603,7 +603,7 @@ void DQRNetworkManager::RTS_StartCient()
EnterCriticalSection(&m_csRTSMessageQueueOutgoing);
RTS_Message message;
message.m_eType = eRTSMessageType::RTS_MESSAGE_START_CLIENT;
- message.m_pucData = NULL;
+ message.m_pucData = nullptr;
message.m_dataSize = 0;
m_RTSMessageQueueOutgoing.push(message);
LeaveCriticalSection(&m_csRTSMessageQueueOutgoing);
@@ -614,7 +614,7 @@ void DQRNetworkManager::RTS_StartHost()
EnterCriticalSection(&m_csRTSMessageQueueOutgoing);
RTS_Message message;
message.m_eType = eRTSMessageType::RTS_MESSAGE_START_HOST;
- message.m_pucData = NULL;
+ message.m_pucData = nullptr;
message.m_dataSize = 0;
m_RTSMessageQueueOutgoing.push(message);
LeaveCriticalSection(&m_csRTSMessageQueueOutgoing);
@@ -625,7 +625,7 @@ void DQRNetworkManager::RTS_Terminate()
EnterCriticalSection(&m_csRTSMessageQueueOutgoing);
RTS_Message message;
message.m_eType = eRTSMessageType::RTS_MESSAGE_TERMINATE;
- message.m_pucData = NULL;
+ message.m_pucData = nullptr;
message.m_dataSize = 0;
m_RTSMessageQueueOutgoing.push(message);
LeaveCriticalSection(&m_csRTSMessageQueueOutgoing);
@@ -636,7 +636,7 @@ void DQRNetworkManager::RTS_SendData(unsigned char *pucData, unsigned int dataSi
EnterCriticalSection(&m_csRTSMessageQueueOutgoing);
RTS_Message message;
message.m_eType = eRTSMessageType::RTS_MESSAGE_SEND_DATA;
- message.m_pucData = (unsigned char *)malloc(dataSize);
+ message.m_pucData = static_cast<unsigned char *>(malloc(dataSize));
memcpy(message.m_pucData, pucData, dataSize);
message.m_dataSize = dataSize;
message.m_sessionAddress = sessionAddress;
diff --git a/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp b/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp
index e2d82a90..a8140764 100644
--- a/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp
+++ b/Minecraft.Client/Durango/Network/DQRNetworkPlayer.cpp
@@ -97,7 +97,7 @@ bool DQRNetworkPlayer::HasVoice()
Microsoft::Xbox::GameChat::ChatUser^ chatUser = m_manager->m_chat->GetChatUserByXboxUserId(ref new Platform::String(m_UID.toString().c_str()));
if( chatUser == nullptr ) return false;
- if( ((int)chatUser->ParticipantType) & ((int)Windows::Xbox::Chat::ChatParticipantTypes::Talker) )
+ if( static_cast<int>(chatUser->ParticipantType) & static_cast<int>(Windows::Xbox::Chat::ChatParticipantTypes::Talker) )
{
return true;
}
diff --git a/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp b/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp
index fd2181df..84a34a97 100644
--- a/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp
+++ b/Minecraft.Client/Durango/Network/NetworkPlayerDurango.cpp
@@ -4,7 +4,7 @@
NetworkPlayerDurango::NetworkPlayerDurango(DQRNetworkPlayer *qnetPlayer)
{
m_dqrPlayer = qnetPlayer;
- m_pSocket = NULL;
+ m_pSocket = nullptr;
}
unsigned char NetworkPlayerDurango::GetSmallId()
@@ -14,12 +14,12 @@ unsigned char NetworkPlayerDurango::GetSmallId()
void NetworkPlayerDurango::SendData(INetworkPlayer *player, const void *pvData, int dataSize, bool lowPriority)
{
- m_dqrPlayer->SendData( ((NetworkPlayerDurango *)player)->m_dqrPlayer, pvData, dataSize );
+ m_dqrPlayer->SendData( static_cast<NetworkPlayerDurango *>(player)->m_dqrPlayer, pvData, dataSize );
}
bool NetworkPlayerDurango::IsSameSystem(INetworkPlayer *player)
{
- return m_dqrPlayer->IsSameSystem(((NetworkPlayerDurango *)player)->m_dqrPlayer);
+ return m_dqrPlayer->IsSameSystem(static_cast<NetworkPlayerDurango *>(player)->m_dqrPlayer);
}
int NetworkPlayerDurango::GetSendQueueSizeBytes( INetworkPlayer *player, bool lowPriority )
diff --git a/Minecraft.Client/Durango/Network/PartyController.cpp b/Minecraft.Client/Durango/Network/PartyController.cpp
index 753a71ac..1dfd5eb0 100644
--- a/Minecraft.Client/Durango/Network/PartyController.cpp
+++ b/Minecraft.Client/Durango/Network/PartyController.cpp
@@ -103,7 +103,7 @@ void PartyController::RefreshPartyView()
}
catch ( Platform::Exception^ ex )
{
- if( ex->HResult != (int)Windows::Xbox::Multiplayer::PartyErrorStatus::EmptyParty )
+ if( ex->HResult != static_cast<int>(Windows::Xbox::Multiplayer::PartyErrorStatus::EmptyParty) )
{
// LogCommentWithError( L"GetPartyView failed", ex->HResult );
}
@@ -181,7 +181,7 @@ bool PartyController::AddLocalUsersToParty(int userMask, Windows::Xbox::System::
bool alreadyInSession = false;
if( session )
{
- if( m_pDQRNet->IsPlayerInSession( ProfileManager.GetUser(i, true)->XboxUserId, session, NULL ) )
+ if( m_pDQRNet->IsPlayerInSession( ProfileManager.GetUser(i, true)->XboxUserId, session, nullptr ) )
{
alreadyInSession = true;
}
@@ -577,7 +577,7 @@ void PartyController::OnPartyRosterChanged( PartyRosterChangedEventArgs^ eventAr
// Still a party, find out who left
for( int i = 0; i < eventArgs->RemovedMembers->Size; i++ )
{
- DQRNetworkPlayer *player = m_pDQRNet->GetPlayerByXuid(PlayerUID(eventArgs->RemovedMembers->GetAt(i)->Data()));
+ DQRNetworkPlayer *player = m_pDQRNet->GetPlayerByXuid(static_cast<PlayerUID>(eventArgs->RemovedMembers->GetAt(i)->Data()));
if( player )
{
if( player->IsLocal() )
@@ -621,7 +621,7 @@ void PartyController::AddAvailableGamePlayers(IVectorView<GamePlayer^>^ availabl
}
#endif
- if( m_pDQRNet->IsPlayerInSession(player->XboxUserId, currentSession, NULL))
+ if( m_pDQRNet->IsPlayerInSession(player->XboxUserId, currentSession, nullptr))
{
DQRNetworkManager::LogComment( L"Player is already in session; skipping join request: " + player->XboxUserId->ToString() );
continue;
@@ -639,7 +639,7 @@ void PartyController::AddAvailableGamePlayers(IVectorView<GamePlayer^>^ availabl
{
bFoundLocal = true;
// Check that they aren't in the game already (don't see how this could be the case anyway)
- if( m_pDQRNet->GetPlayerByXuid( PlayerUID(player->XboxUserId->Data()) ) == NULL )
+ if( m_pDQRNet->GetPlayerByXuid( static_cast<PlayerUID>(player->XboxUserId->Data()) ) == nullptr )
{
// And check whether they are signed in yet or not
int userIdx = -1;
@@ -838,7 +838,7 @@ void PartyController::OnGameSessionReady( GameSessionReadyEventArgs^ eventArgs )
if( !isAJoiningXuid ) // Isn't someone we are actively trying to join
{
if( (!bInSession) || // If not in a game session at all
- ( ( m_pDQRNet->GetState() == DQRNetworkManager::DNM_INT_STATE_PLAYING ) && ( m_pDQRNet->GetPlayerByXuid( PlayerUID(memberXUID->Data()) ) == NULL ) ) // Or we're fully in, and this player isn't in it
+ ( ( m_pDQRNet->GetState() == DQRNetworkManager::DNM_INT_STATE_PLAYING ) && ( m_pDQRNet->GetPlayerByXuid( static_cast<PlayerUID>(memberXUID->Data()) ) == nullptr ) ) // Or we're fully in, and this player isn't in it
)
{
for( int j = 4; j < 12; j++ ) // Final check that we have a gamepad for this xuid so that we might possibly be able to pair someone up
@@ -1201,5 +1201,5 @@ double PartyController::GetTimeBetweenInSeconds(Windows::Foundation::DateTime dt
{
const uint64 tickPerSecond = 10000000i64;
uint64 deltaTime = dt2.UniversalTime - dt1.UniversalTime;
- return (double)deltaTime / (double)tickPerSecond;
+ return static_cast<double>(deltaTime) / static_cast<double>(tickPerSecond);
} \ No newline at end of file
diff --git a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp
index 925a37a8..5e3a0824 100644
--- a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp
+++ b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.cpp
@@ -87,7 +87,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerJoined(DQRNetworkPlayer *pDQRPl
bool createFakeSocket = false;
bool localPlayer = false;
- NetworkPlayerDurango *networkPlayer = (NetworkPlayerDurango *)addNetworkPlayer(pDQRPlayer);
+ NetworkPlayerDurango *networkPlayer = static_cast<NetworkPlayerDurango *>(addNetworkPlayer(pDQRPlayer));
// Request full display name for this player
m_pDQRNet->RequestDisplayName(pDQRPlayer);
@@ -166,7 +166,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerJoined(DQRNetworkPlayer *pDQRPl
for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
{
- if(playerChangedCallback[idx] != NULL)
+ if(playerChangedCallback[idx] != nullptr)
playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, false );
}
@@ -175,7 +175,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerJoined(DQRNetworkPlayer *pDQRPl
int localPlayerCount = 0;
for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
{
- if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount;
+ if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount;
}
float appTime = app.getAppTime();
@@ -198,7 +198,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP
{
// Get our wrapper object associated with this player.
Socket *socket = networkPlayer->GetSocket();
- if( socket != NULL )
+ if( socket != nullptr )
{
// If we are in game then remove this player from the game as well.
// We may get here either from the player requesting to exit the game,
@@ -214,14 +214,14 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP
// We need this as long as the game server still needs to communicate with the player
//delete socket;
- networkPlayer->SetSocket( NULL );
+ networkPlayer->SetSocket( nullptr );
}
if( m_pDQRNet->IsHost() && !m_bHostChanged )
{
if( isSystemPrimaryPlayer(pDQRPlayer) )
{
- DQRNetworkPlayer *pNewDQRPrimaryPlayer = NULL;
+ DQRNetworkPlayer *pNewDQRPrimaryPlayer = nullptr;
for(unsigned int i = 0; i < m_pDQRNet->GetPlayerCount(); ++i )
{
DQRNetworkPlayer *pDQRPlayer2 = m_pDQRNet->GetPlayerByIndex( i );
@@ -238,7 +238,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP
m_machineDQRPrimaryPlayers.erase( it );
}
- if( pNewDQRPrimaryPlayer != NULL )
+ if( pNewDQRPrimaryPlayer != nullptr )
m_machineDQRPrimaryPlayers.push_back( pNewDQRPrimaryPlayer );
}
@@ -251,7 +251,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP
for( int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
{
- if(playerChangedCallback[idx] != NULL)
+ if(playerChangedCallback[idx] != nullptr)
playerChangedCallback[idx]( playerChangedCallbackParam[idx], networkPlayer, true );
}
@@ -260,7 +260,7 @@ void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRP
int localPlayerCount = 0;
for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx)
{
- if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != NULL ) ++localPlayerCount;
+ if( m_pDQRNet->GetLocalPlayerByUserIndex(idx) != nullptr ) ++localPlayerCount;
}
float appTime = app.getAppTime();
@@ -289,7 +289,7 @@ void CPlatformNetworkManagerDurango::HandleDataReceived(DQRNetworkPlayer *player
INetworkPlayer *pPlayerFrom = getNetworkPlayer(playerFrom);
Socket *socket = pPlayerFrom->GetSocket();
- if(socket != NULL)
+ if(socket != nullptr)
socket->pushDataToQueue(data, dataSize, false);
}
else
@@ -298,7 +298,7 @@ void CPlatformNetworkManagerDurango::HandleDataReceived(DQRNetworkPlayer *player
INetworkPlayer *pPlayerTo = getNetworkPlayer(playerTo);
Socket *socket = pPlayerTo->GetSocket();
//app.DebugPrintf( "Pushing data into read queue for user \"%ls\"\n", apPlayersTo[dwPlayer]->GetGamertag());
- if(socket != NULL)
+ if(socket != nullptr)
socket->pushDataToQueue(data, dataSize);
}
}
@@ -319,7 +319,7 @@ bool CPlatformNetworkManagerDurango::Initialise(CGameNetworkManager *pGameNetwor
g_pPlatformNetworkManager = this;
for( int i = 0; i < XUSER_MAX_COUNT; i++ )
{
- playerChangedCallback[ i ] = NULL;
+ playerChangedCallback[ i ] = nullptr;
}
m_bLeavingGame = false;
@@ -330,14 +330,14 @@ bool CPlatformNetworkManagerDurango::Initialise(CGameNetworkManager *pGameNetwor
m_bSearchPending = false;
m_bIsOfflineGame = false;
- m_pSearchParam = NULL;
- m_SessionsUpdatedCallback = NULL;
+ m_pSearchParam = nullptr;
+ m_SessionsUpdatedCallback = nullptr;
m_searchResultsCount = 0;
m_lastSearchStartTime = 0;
// The results that will be filled in with the current search
- m_pSearchResults = NULL;
+ m_pSearchResults = nullptr;
Windows::Networking::Connectivity::NetworkInformation::NetworkStatusChanged += ref new Windows::Networking::Connectivity::NetworkStatusChangedEventHandler( []( Platform::Object^ pxObject )
{
@@ -585,8 +585,8 @@ void CPlatformNetworkManagerDurango::UnRegisterPlayerChangedCallback(int iPad, v
{
if(playerChangedCallbackParam[iPad] == callbackParam)
{
- playerChangedCallback[iPad] = NULL;
- playerChangedCallbackParam[iPad] = NULL;
+ playerChangedCallback[iPad] = nullptr;
+ playerChangedCallbackParam[iPad] = nullptr;
}
}
@@ -613,12 +613,12 @@ bool CPlatformNetworkManagerDurango::_RunNetworkGame()
return true;
}
-void CPlatformNetworkManagerDurango::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= NULL*/)
+void CPlatformNetworkManagerDurango::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving /*= nullptr*/)
{
if( this->m_bLeavingGame )
return;
- if( GetHostPlayer() == NULL )
+ if( GetHostPlayer() == nullptr )
return;
m_hostGameSessionData.m_uiGameHostSettings = app.GetGameHostOption(eGameHostOption_All);
@@ -628,18 +628,18 @@ void CPlatformNetworkManagerDurango::UpdateAndSetGameSessionData(INetworkPlayer
int CPlatformNetworkManagerDurango::RemovePlayerOnSocketClosedThreadProc( void* lpParam )
{
- INetworkPlayer *pNetworkPlayer = (INetworkPlayer *)lpParam;
+ INetworkPlayer *pNetworkPlayer = static_cast<INetworkPlayer *>(lpParam);
Socket *socket = pNetworkPlayer->GetSocket();
- if( socket != NULL )
+ if( socket != nullptr )
{
//printf("Waiting for socket closed event\n");
socket->m_socketClosedEvent->WaitForSignal(INFINITE);
//printf("Socket closed event has fired\n");
// 4J Stu - Clear our reference to this socket
- pNetworkPlayer->SetSocket( NULL );
+ pNetworkPlayer->SetSocket( nullptr );
delete socket;
}
@@ -712,7 +712,7 @@ void CPlatformNetworkManagerDurango::SystemFlagReset()
void CPlatformNetworkManagerDurango::SystemFlagSet(INetworkPlayer *pNetworkPlayer, int index)
{
if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return;
- if( pNetworkPlayer == NULL ) return;
+ if( pNetworkPlayer == nullptr ) return;
for( unsigned int i = 0; i < m_playerFlags.size(); i++ )
{
@@ -728,7 +728,7 @@ void CPlatformNetworkManagerDurango::SystemFlagSet(INetworkPlayer *pNetworkPlaye
bool CPlatformNetworkManagerDurango::SystemFlagGet(INetworkPlayer *pNetworkPlayer, int index)
{
if( ( index < 0 ) || ( index >= m_flagIndexSize ) ) return false;
- if( pNetworkPlayer == NULL )
+ if( pNetworkPlayer == nullptr )
{
return false;
}
@@ -769,7 +769,7 @@ void CPlatformNetworkManagerDurango::TickSearch()
}
m_bSearchPending = false;
- if( m_SessionsUpdatedCallback != NULL ) m_SessionsUpdatedCallback(m_pSearchParam);
+ if( m_SessionsUpdatedCallback != nullptr ) m_SessionsUpdatedCallback(m_pSearchParam);
}
}
else
@@ -777,7 +777,7 @@ void CPlatformNetworkManagerDurango::TickSearch()
if( !m_pDQRNet->FriendPartyManagerIsBusy() )
{
// Don't start searches unless we have registered a callback
- if( m_SessionsUpdatedCallback != NULL && (m_lastSearchStartTime + MINECRAFT_DURANGO_PARTY_SEARCH_DELAY_MILLISECONDS) < GetTickCount() )
+ if( m_SessionsUpdatedCallback != nullptr && (m_lastSearchStartTime + MINECRAFT_DURANGO_PARTY_SEARCH_DELAY_MILLISECONDS) < GetTickCount() )
{
if( m_pDQRNet->FriendPartyManagerSearch() );
{
@@ -794,13 +794,13 @@ vector<FriendSessionInfo *> *CPlatformNetworkManagerDurango::GetSessionList(int
vector<FriendSessionInfo *> *filteredList = new vector<FriendSessionInfo *>();
for( int i = 0; i < m_searchResultsCount; i++ )
{
- GameSessionData *gameSessionData = (GameSessionData *)m_pSearchResults[i].m_extData;
+ GameSessionData *gameSessionData = static_cast<GameSessionData *>(m_pSearchResults[i].m_extData);
if( ( gameSessionData->netVersion == MINECRAFT_NET_VERSION ) &&
( gameSessionData->isReadyToJoin ) )
{
FriendSessionInfo *session = new FriendSessionInfo();
session->searchResult = m_pSearchResults[i];
- session->searchResult.m_extData = NULL; // We have another copy of the GameSessionData, so don't need to make another copy of this here
+ session->searchResult.m_extData = nullptr; // We have another copy of the GameSessionData, so don't need to make another copy of this here
session->displayLabelLength = session->searchResult.m_playerNames[0].size();
session->displayLabel = new wchar_t[ session->displayLabelLength + 1 ];
memcpy(&session->data, gameSessionData, sizeof(GameSessionData));
@@ -832,7 +832,7 @@ void CPlatformNetworkManagerDurango::ForceFriendsSessionRefresh()
m_lastSearchStartTime = 0;
m_searchResultsCount = 0;
delete [] m_pSearchResults;
- m_pSearchResults = NULL;
+ m_pSearchResults = nullptr;
}
INetworkPlayer *CPlatformNetworkManagerDurango::addNetworkPlayer(DQRNetworkPlayer *pDQRPlayer)
@@ -858,7 +858,7 @@ void CPlatformNetworkManagerDurango::removeNetworkPlayer(DQRNetworkPlayer *pDQRP
INetworkPlayer *CPlatformNetworkManagerDurango::getNetworkPlayer(DQRNetworkPlayer *pDQRPlayer)
{
- return pDQRPlayer ? (INetworkPlayer *)(pDQRPlayer->GetCustomDataValue()) : NULL;
+ return pDQRPlayer ? (INetworkPlayer *)(pDQRPlayer->GetCustomDataValue()) : nullptr;
}
diff --git a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h
index 55807227..5626b012 100644
--- a/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h
+++ b/Minecraft.Client/Durango/Network/PlatformNetworkManagerDurango.h
@@ -87,7 +87,7 @@ private:
bool m_hostGameSessionIsJoinable;
CGameNetworkManager *m_pGameNetworkManager;
public:
- virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL);
+ virtual void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = nullptr);
private:
// TODO 4J Stu - Do we need to be able to have more than one of these?
diff --git a/Minecraft.Client/Durango/Network/base64.cpp b/Minecraft.Client/Durango/Network/base64.cpp
index c5af745c..c916725f 100644
--- a/Minecraft.Client/Durango/Network/base64.cpp
+++ b/Minecraft.Client/Durango/Network/base64.cpp
@@ -109,13 +109,13 @@ void base64_decode(Platform::String ^encoded_string, unsigned char *output, unsi
while (in_len-- && ( encoded_string->Data()[in_] != L'=') && is_base64(encoded_string->Data()[in_]))
{
- char_array_4[i++] = (unsigned char)(encoded_string->Data()[in_]);
+ char_array_4[i++] = static_cast<unsigned char>(encoded_string->Data()[in_]);
in_++;
if (i ==4)
{
for (i = 0; i <4; i++)
{
- char_array_4[i] = (unsigned char )base64_chars.find(char_array_4[i]);
+ char_array_4[i] = static_cast<unsigned char>(base64_chars.find(char_array_4[i]));
}
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
@@ -140,7 +140,7 @@ void base64_decode(Platform::String ^encoded_string, unsigned char *output, unsi
for (j = 0; j <4; j++)
{
- char_array_4[j] = (unsigned char )base64_chars.find(char_array_4[j]);
+ char_array_4[j] = static_cast<unsigned char>(base64_chars.find(char_array_4[j]));
}
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);