mirror of
https://git.revela.dev/itsRevela/LCE-Revelations.git
synced 2026-05-21 19:24:55 +00:00
Add cancel join
Adds the Cancel Join tooltip to the "Connecting to host" progress bar
This commit is contained in:
@@ -54,6 +54,8 @@ int64_t CGameNetworkManager::messageQueue[512];
|
||||
int64_t CGameNetworkManager::byteQueue[512];
|
||||
int CGameNetworkManager::messageQueuePos = 0;
|
||||
|
||||
CRITICAL_SECTION bCancelRequestedCS;
|
||||
|
||||
CGameNetworkManager::CGameNetworkManager()
|
||||
{
|
||||
m_bInitialised = false;
|
||||
@@ -80,9 +82,12 @@ void CGameNetworkManager::Initialise()
|
||||
#else
|
||||
s_pPlatformNetworkManager = new CPlatformNetworkManagerStub();
|
||||
#endif
|
||||
m_bCancelRequested = false;
|
||||
s_pPlatformNetworkManager->Initialise( this, flagIndexSize );
|
||||
m_bNetworkThreadRunning = false;
|
||||
m_bInitialised = true;
|
||||
|
||||
InitializeCriticalSection(&bCancelRequestedCS);
|
||||
}
|
||||
|
||||
void CGameNetworkManager::Terminate()
|
||||
@@ -435,6 +440,24 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
|
||||
app.DebugPrintf("ticking connection A\n");
|
||||
connection->tick();
|
||||
|
||||
EnterCriticalSection(&bCancelRequestedCS);
|
||||
bool bCancelled = g_NetworkManager.m_bCancelRequested;
|
||||
|
||||
if (bCancelled)
|
||||
{
|
||||
if (!app.GetGameStarted())
|
||||
{
|
||||
app.DebugPrintf("Cancel requested, closing connection\n");
|
||||
g_NetworkManager.m_bCancelRequested = false;
|
||||
LeaveCriticalSection(&bCancelRequestedCS);
|
||||
connection->close();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&bCancelRequestedCS);
|
||||
|
||||
|
||||
// 4J Stu - We were ticking this way too fast which could cause the connection to time out
|
||||
// The connections should tick at 20 per second
|
||||
Sleep(50);
|
||||
@@ -551,7 +574,10 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
|
||||
}
|
||||
else if ( connection->isClosed() || !IsInSession())
|
||||
{
|
||||
// assert(false);
|
||||
// assert(false);
|
||||
// Set to NULL because we're returning to home
|
||||
// The level is not reset when you leave the progress UI which causes a crash
|
||||
Minecraft::GetInstance()->setLevel(NULL);
|
||||
MinecraftServer::HaltServer();
|
||||
return false;
|
||||
}
|
||||
@@ -769,6 +795,9 @@ CGameNetworkManager::eJoinGameResult CGameNetworkManager::JoinGame(FriendSession
|
||||
|
||||
void CGameNetworkManager::CancelJoinGame(LPVOID lpParam)
|
||||
{
|
||||
EnterCriticalSection(&bCancelRequestedCS);
|
||||
g_NetworkManager.m_bCancelRequested = true;
|
||||
LeaveCriticalSection(&bCancelRequestedCS);
|
||||
#ifdef _XBOX_ONE
|
||||
s_pPlatformNetworkManager->CancelJoinGame();
|
||||
#endif
|
||||
@@ -1455,6 +1484,9 @@ void CGameNetworkManager::StateChange_AnyToStarting()
|
||||
LoadingInputParams *loadingParams = new LoadingInputParams();
|
||||
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
|
||||
loadingParams->lpParam = nullptr;
|
||||
loadingParams->cancelText = IDS_TOOLTIPS_CANCEL_JOIN;
|
||||
loadingParams->cancelFunc = &CGameNetworkManager::CancelJoinGame;
|
||||
loadingParams->waitForThreadToDelete = TRUE;
|
||||
|
||||
UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
|
||||
completionData->bShowBackground=TRUE;
|
||||
|
||||
Reference in New Issue
Block a user