Skip to content

Commit

Permalink
Prepare GameSpy wrapper for moving to xrGameSpy.
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Jan 27, 2016
1 parent 16c9796 commit 0843b75
Show file tree
Hide file tree
Showing 24 changed files with 588 additions and 396 deletions.
49 changes: 30 additions & 19 deletions src/xrGame/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "gamespy/GameSpy_Full.h"
#include "gamespy/GameSpy_HTTP.h"
#include "gamespy/GameSpy_Available.h"
#include "gamespy/GameSpy_Browser.h"
#include "CdkeyDecode/cdkeydecode.h"
#include "string_table.h"
#include "xrCore/os_clipboard.h"
Expand Down Expand Up @@ -469,7 +470,19 @@ void CMainMenu::OnFrame()

if(IsActive() || m_sPDProgress.IsInProgress)
{
m_pGameSpyFull->Update();
GSUpdateStatus status = m_pGameSpyFull->Update();
if (status!=GSUpdateStatus::ConnectingToMaster)
Hide_CTMS_Dialog();
switch (status)
{
case GSUpdateStatus::MasterUnreachable:
case GSUpdateStatus::Unknown:
SetErrorDialog(ErrMasterServerConnectFailed);
break;
case GSUpdateStatus::OutOfService:
SetErrorDialog(ErrGSServiceFailed);
break;
}
m_atlas_submit_queue->update();
}

Expand Down Expand Up @@ -549,8 +562,13 @@ void CMainMenu::DestroyInternal(bool bForce)
xr_delete (m_startDialog);
}

void CMainMenu::OnNewPatchFound(LPCSTR VersionName, LPCSTR URL)
void CMainMenu::OnPatchCheck(bool success, LPCSTR VersionName, LPCSTR URL)
{
if (!success)
{
m_pMB_ErrDlgs[NoNewPatch]->ShowDialog(false);
return;
}
if (m_sPDProgress.IsInProgress) return;

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

void CMainMenu::OnNoNewPatchFound()
{
m_pMB_ErrDlgs[NoNewPatch]->ShowDialog(false);
}

void CMainMenu::OnDownloadPatch(CUIWindow*, void*)
{
CGameSpy_Available GSA;
Expand Down Expand Up @@ -608,23 +621,21 @@ void CMainMenu::OnDownloadPatch(CUIWindow*, void*)
m_sPDProgress.Progress = 0;
m_sPDProgress.FileName = m_sPatchFileName;
m_sPDProgress.Status = "";

m_pGameSpyFull->GetGameSpyHTTP()->DownloadFile(*m_sPatchURL, *m_sPatchFileName);
CGameSpy_HTTP::CompletionCallback completionCallback;
completionCallback.bind(this, &CMainMenu::OnDownloadPatchResult);
CGameSpy_HTTP::ProgressCallback progressCallback;
progressCallback.bind(this, &CMainMenu::OnDownloadPatchProgress);
m_pGameSpyFull->GetGameSpyHTTP()->DownloadFile(*m_sPatchURL, *m_sPatchFileName,
completionCallback, progressCallback);
}

void CMainMenu::OnDownloadPatchError()
void CMainMenu::OnDownloadPatchResult(bool success)
{
m_sPDProgress.IsInProgress = false;
m_pMB_ErrDlgs[PatchDownloadError]->ShowDialog(false);
m_sPDProgress.IsInProgress = false;
auto dialogId = success ? PatchDownloadSuccess : PatchDownloadError;
m_pMB_ErrDlgs[dialogId]->ShowDialog(false);
};

void CMainMenu::OnDownloadPatchSuccess ()
{
m_sPDProgress.IsInProgress = false;

m_pMB_ErrDlgs[PatchDownloadSuccess]->ShowDialog(false);
}

void CMainMenu::OnSessionTerminate (LPCSTR reason)
{
if ( m_NeedErrDialog == SessionTerminate && (Device.dwTimeGlobal - m_start_time) < 8000 )
Expand Down
8 changes: 3 additions & 5 deletions src/xrGame/MainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ class CMainMenu :
EErrorDlg GetErrorDialogType () const { return m_NeedErrDialog; } ;
void CheckForErrorDlg ();
void SwitchToMultiplayerMenu ();
void OnNewPatchFound (LPCSTR VersionName, LPCSTR URL);
void OnNoNewPatchFound ();
void xr_stdcall OnPatchCheck (bool success, LPCSTR VersionName, LPCSTR URL);
void xr_stdcall OnDownloadPatch (CUIWindow*, void*);
void xr_stdcall OnConnectToMasterServerOkClicked(CUIWindow*, void*);

Expand All @@ -184,9 +183,8 @@ class CMainMenu :

void OnSessionTerminate (LPCSTR reason);
void OnLoadError (LPCSTR module);
void OnDownloadPatchError ();
void OnDownloadPatchSuccess ();
void OnDownloadPatchProgress (u64 bytesReceived, u64 totalSize);
void xr_stdcall OnDownloadPatchResult(bool success);
void xr_stdcall OnDownloadPatchProgress(u64 received, u64 total);
void xr_stdcall OnRunDownloadedPatch (CUIWindow*, void*);
void Show_CTMS_Dialog ();
void Hide_CTMS_Dialog ();
Expand Down
5 changes: 3 additions & 2 deletions src/xrGame/console_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,8 +1689,9 @@ class CCC_GSCheckForUpdates : public IConsole_Command {
}

// GameSpyPatching.CheckForPatch(InformOfNoPatch);

MainMenu()->GetGS()->GetGameSpyPatching()->CheckForPatch(InformOfNoPatch);
CGameSpy_Patching::PatchCheckCallback cb;
cb.bind(MainMenu(), &CMainMenu::OnPatchCheck);
MainMenu()->GetGS()->GetGameSpyPatching()->CheckForPatch(InformOfNoPatch, cb);
}
};

Expand Down
Loading

0 comments on commit 0843b75

Please sign in to comment.