Skip to content

Commit 0843b75

Browse files
author
nitrocaster
committed
Prepare GameSpy wrapper for moving to xrGameSpy.
1 parent 16c9796 commit 0843b75

24 files changed

+588
-396
lines changed

src/xrGame/MainMenu.cpp

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "gamespy/GameSpy_Full.h"
1515
#include "gamespy/GameSpy_HTTP.h"
1616
#include "gamespy/GameSpy_Available.h"
17+
#include "gamespy/GameSpy_Browser.h"
1718
#include "CdkeyDecode/cdkeydecode.h"
1819
#include "string_table.h"
1920
#include "xrCore/os_clipboard.h"
@@ -469,7 +470,19 @@ void CMainMenu::OnFrame()
469470

470471
if(IsActive() || m_sPDProgress.IsInProgress)
471472
{
472-
m_pGameSpyFull->Update();
473+
GSUpdateStatus status = m_pGameSpyFull->Update();
474+
if (status!=GSUpdateStatus::ConnectingToMaster)
475+
Hide_CTMS_Dialog();
476+
switch (status)
477+
{
478+
case GSUpdateStatus::MasterUnreachable:
479+
case GSUpdateStatus::Unknown:
480+
SetErrorDialog(ErrMasterServerConnectFailed);
481+
break;
482+
case GSUpdateStatus::OutOfService:
483+
SetErrorDialog(ErrGSServiceFailed);
484+
break;
485+
}
473486
m_atlas_submit_queue->update();
474487
}
475488

@@ -549,8 +562,13 @@ void CMainMenu::DestroyInternal(bool bForce)
549562
xr_delete (m_startDialog);
550563
}
551564

552-
void CMainMenu::OnNewPatchFound(LPCSTR VersionName, LPCSTR URL)
565+
void CMainMenu::OnPatchCheck(bool success, LPCSTR VersionName, LPCSTR URL)
553566
{
567+
if (!success)
568+
{
569+
m_pMB_ErrDlgs[NoNewPatch]->ShowDialog(false);
570+
return;
571+
}
554572
if (m_sPDProgress.IsInProgress) return;
555573

556574
if (m_pMB_ErrDlgs[NewPatchFound])
@@ -573,11 +591,6 @@ void CMainMenu::OnNewPatchFound(LPCSTR VersionName, LPCSTR URL)
573591
m_pMB_ErrDlgs[NewPatchFound]->ShowDialog(false);
574592
};
575593

576-
void CMainMenu::OnNoNewPatchFound()
577-
{
578-
m_pMB_ErrDlgs[NoNewPatch]->ShowDialog(false);
579-
}
580-
581594
void CMainMenu::OnDownloadPatch(CUIWindow*, void*)
582595
{
583596
CGameSpy_Available GSA;
@@ -608,23 +621,21 @@ void CMainMenu::OnDownloadPatch(CUIWindow*, void*)
608621
m_sPDProgress.Progress = 0;
609622
m_sPDProgress.FileName = m_sPatchFileName;
610623
m_sPDProgress.Status = "";
611-
612-
m_pGameSpyFull->GetGameSpyHTTP()->DownloadFile(*m_sPatchURL, *m_sPatchFileName);
624+
CGameSpy_HTTP::CompletionCallback completionCallback;
625+
completionCallback.bind(this, &CMainMenu::OnDownloadPatchResult);
626+
CGameSpy_HTTP::ProgressCallback progressCallback;
627+
progressCallback.bind(this, &CMainMenu::OnDownloadPatchProgress);
628+
m_pGameSpyFull->GetGameSpyHTTP()->DownloadFile(*m_sPatchURL, *m_sPatchFileName,
629+
completionCallback, progressCallback);
613630
}
614631

615-
void CMainMenu::OnDownloadPatchError()
632+
void CMainMenu::OnDownloadPatchResult(bool success)
616633
{
617-
m_sPDProgress.IsInProgress = false;
618-
m_pMB_ErrDlgs[PatchDownloadError]->ShowDialog(false);
634+
m_sPDProgress.IsInProgress = false;
635+
auto dialogId = success ? PatchDownloadSuccess : PatchDownloadError;
636+
m_pMB_ErrDlgs[dialogId]->ShowDialog(false);
619637
};
620638

621-
void CMainMenu::OnDownloadPatchSuccess ()
622-
{
623-
m_sPDProgress.IsInProgress = false;
624-
625-
m_pMB_ErrDlgs[PatchDownloadSuccess]->ShowDialog(false);
626-
}
627-
628639
void CMainMenu::OnSessionTerminate (LPCSTR reason)
629640
{
630641
if ( m_NeedErrDialog == SessionTerminate && (Device.dwTimeGlobal - m_start_time) < 8000 )

src/xrGame/MainMenu.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ class CMainMenu :
173173
EErrorDlg GetErrorDialogType () const { return m_NeedErrDialog; } ;
174174
void CheckForErrorDlg ();
175175
void SwitchToMultiplayerMenu ();
176-
void OnNewPatchFound (LPCSTR VersionName, LPCSTR URL);
177-
void OnNoNewPatchFound ();
176+
void xr_stdcall OnPatchCheck (bool success, LPCSTR VersionName, LPCSTR URL);
178177
void xr_stdcall OnDownloadPatch (CUIWindow*, void*);
179178
void xr_stdcall OnConnectToMasterServerOkClicked(CUIWindow*, void*);
180179

@@ -184,9 +183,8 @@ class CMainMenu :
184183

185184
void OnSessionTerminate (LPCSTR reason);
186185
void OnLoadError (LPCSTR module);
187-
void OnDownloadPatchError ();
188-
void OnDownloadPatchSuccess ();
189-
void OnDownloadPatchProgress (u64 bytesReceived, u64 totalSize);
186+
void xr_stdcall OnDownloadPatchResult(bool success);
187+
void xr_stdcall OnDownloadPatchProgress(u64 received, u64 total);
190188
void xr_stdcall OnRunDownloadedPatch (CUIWindow*, void*);
191189
void Show_CTMS_Dialog ();
192190
void Hide_CTMS_Dialog ();

src/xrGame/console_commands.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,8 +1689,9 @@ class CCC_GSCheckForUpdates : public IConsole_Command {
16891689
}
16901690

16911691
// GameSpyPatching.CheckForPatch(InformOfNoPatch);
1692-
1693-
MainMenu()->GetGS()->GetGameSpyPatching()->CheckForPatch(InformOfNoPatch);
1692+
CGameSpy_Patching::PatchCheckCallback cb;
1693+
cb.bind(MainMenu(), &CMainMenu::OnPatchCheck);
1694+
MainMenu()->GetGS()->GetGameSpyPatching()->CheckForPatch(InformOfNoPatch, cb);
16941695
}
16951696
};
16961697

0 commit comments

Comments
 (0)