This commit is contained in:
romkazvo
2023-08-07 19:29:24 +08:00
commit 34d6c5d489
4832 changed files with 1389451 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
[MSClient]
ConnectURL=http://gsconnect.ubisoft.com/gsinit.php?user=%s&dp=%s
Username=user10
Password=testtest
Version=RSPC1.0
Gamename=RAVENSHIELD
GamePassword=
ServerIP=srv-gstest
ServerPort=41000

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
// Registry.h: interface for the CRegistry class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_REGISTRY_H__E7B8045A_B6E3_11D2_AF1A_00105A9F8688__INCLUDED_)
#define AFX_REGISTRY_H__E7B8045A_B6E3_11D2_AF1A_00105A9F8688__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef UBI_CREGISTRY_NAMEBUFFERSIZE
#define UBI_CREGISTRY_NAMEBUFFERSIZE _MAX_PATH+1
#endif // UBI_CREGISTRY_NAMEBUFFERSIZE
#include "StdAfx.h"
#include "GSTypes.h"
/*#ifdef WITHIN_THE_GLOBJECTLIB_PROJECT
class __declspec(dllexport) CRegistry
#else // WITHIN_THE_GLOBJECTLIB_PROJECT
class __declspec(dllimport) CRegistry : public CObject
#endif // WITHIN_THE_GLOBJECTLIB_PROJECT
*/
class CRegistry : public CObject
{
public:
CRegistry();
CRegistry(HKEY hKey, LPCTSTR lpszPath, GSbool bShouldCreateKeyIfNotExist = GS_TRUE, REGSAM samSecurity = KEY_ALL_ACCESS);
virtual ~CRegistry();
GSbool CreateKey(DWORD dwOptions = REG_OPTION_NON_VOLATILE);
GSbool DeleteKey();
GSbool OpenKey();
GSbool CloseKey();
GSbool DoesKeyExist();
HKEY SetRootKey(HKEY hRootKey = HKEY_LOCAL_MACHINE);
CString SetPath(LPCTSTR lpszPath = "");
REGSAM SetSecurity(REGSAM samSecurity = KEY_ALL_ACCESS);
GSvoid SetShouldCreateKeyIfNotExist(GSbool bShouldCreateKeyIfNotExist = GS_TRUE);
GSbool ReadBinary(LPCTSTR lpszValueName, LPVOID lpBuffer, GSuint uiBufferSize);
GSbool ReadDWord (LPCTSTR lpszValueName, LPDWORD lpBuffer);
GSbool ReadString(LPCTSTR lpszValueName, CString* pcsBuffer);
GSbool EnumKeys(CStringList* pcslKeys);
GSbool WriteBinary(LPCTSTR lpszValueName, LPVOID lpBuffer, GSuint uiBufferSize);
GSbool WriteDWord (LPCTSTR lpszValueName, DWORD dwBuffer);
GSbool WriteString(LPCTSTR lpszValueName, LPCTSTR lpszBuffer);
GSbool DeleteValue(LPCTSTR lpszValueName);
GSbool DeleteKeyValues();
protected:
CString m_csPath; // Subpath within the root key
HKEY m_hRootKey; // Root registry key
HKEY m_hKey; // Handle to current key
REGSAM m_samSecurity; // Security descriptor (access-rights specifier)
GSbool m_bShouldCreateKeyIfNotExist; // Flag indicating if key should be created if don't exist when it is to be opened
GSbool m_bKeyOpen; // Flag indicating wether or not the current key is open
};
#endif // !defined(AFX_REGISTRY_H__E7B8045A_B6E3_11D2_AF1A_00105A9F8688__INCLUDED_)

View File

@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// gsMasterServerClient.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,27 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__57EDECC9_FB36_43F9_AC7F_5A2CDFC974D6__INCLUDED_)
#define AFX_STDAFX_H__57EDECC9_FB36_43F9_AC7F_5A2CDFC974D6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxsock.h> // MFC socket extensions
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__57EDECC9_FB36_43F9_AC7F_5A2CDFC974D6__INCLUDED_)

View File

@@ -0,0 +1,125 @@
// SubmitScoresdlg.cpp : implementation file
//
#include "stdafx.h"
#include "gsMasterServerClient.h"
#include "SubmitScoresdlg.h"
#include "GSTypes.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSubmitScoresdlg dialog
CSubmitScoresdlg::CSubmitScoresdlg(CWnd* pParent /*=NULL*/)
: CDialog(CSubmitScoresdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSubmitScoresdlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_uiMatchID = 0;
m_iLobbyID = 0;
m_iRoomID = 0;
m_pParentDlg = (CGsMasterServerClientDlg*)pParent;
}
void CSubmitScoresdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSubmitScoresdlg)
DDX_Control(pDX, IDC_EDITUsername, m_editUsername);
DDX_Control(pDX, IDC_EDITLobbyID, m_editLobbyID);
DDX_Control(pDX, IDC_EDITRoomID, m_editRoomID);
DDX_Control(pDX, IDC_EDITMatchID, m_editMatchID);
DDX_Control(pDX, IDC_EDITFieldValue, m_editFieldValue);
DDX_Control(pDX, IDC_EDITFieldID, m_editFieldID);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSubmitScoresdlg, CDialog)
//{{AFX_MSG_MAP(CSubmitScoresdlg)
ON_BN_CLICKED(IDC_BUTTONinit, OnBUTTONinit)
ON_BN_CLICKED(IDC_BUTTONSet, OnBUTTONSet)
ON_BN_CLICKED(IDC_BUTTONSubmit, OnBUTTONSubmit)
ON_BN_CLICKED(IDC_BUTTONUninit, OnBUTTONUninit)
ON_BN_CLICKED(IDC_BUTTONFinished, OnBUTTONFinished)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSubmitScoresdlg message handlers
GSvoid CSubmitScoresdlg::SetServerID(GSint iLobbyID,GSint iRoomID)
{
m_iLobbyID = iLobbyID;
m_iRoomID = iRoomID;
}
GSvoid CSubmitScoresdlg::SetMatchID(GSuint uiMatchID)
{
m_uiMatchID = uiMatchID;
}
BOOL CSubmitScoresdlg::OnInitDialog()
{
CDialog::OnInitDialog();
GSchar szText[1024];
_snprintf(szText,1024,"%i",m_iLobbyID);
m_editLobbyID.SetWindowText(szText);
_snprintf(szText,1024,"%i",m_iRoomID);
m_editRoomID.SetWindowText(szText);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSubmitScoresdlg::OnBUTTONinit()
{
m_pParentDlg->InitMatchResult(m_uiMatchID);
}
void CSubmitScoresdlg::OnBUTTONSet()
{
GSchar szUsername[NICKNAMELENGTH];
GSchar szText[1024];
GSuint uiFieldID;
GSint iFieldValue;
m_editUsername.GetWindowText(szUsername,NICKNAMELENGTH);
m_editFieldID.GetWindowText(szText,1024);
uiFieldID = atol(szText);
m_editFieldValue.GetWindowText(szText,1024);
iFieldValue = atol(szText);
m_pParentDlg->SetMatchResult(szUsername,uiFieldID,iFieldValue);
}
void CSubmitScoresdlg::OnBUTTONSubmit()
{
m_pParentDlg->SubmitMatchResult(m_iLobbyID,m_iRoomID);
}
void CSubmitScoresdlg::OnBUTTONUninit()
{
m_pParentDlg->UninitMatchResult();
}
void CSubmitScoresdlg::OnBUTTONFinished()
{
m_pParentDlg->MatchFinished(m_iLobbyID,m_iRoomID);
}

View File

@@ -0,0 +1,66 @@
#if !defined(AFX_SUBMITSCORESDLG_H__95720E33_2611_47EF_BA0C_4DD5EC46E091__INCLUDED_)
#define AFX_SUBMITSCORESDLG_H__95720E33_2611_47EF_BA0C_4DD5EC46E091__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "gsMasterServerClientDlg.h"
// SubmitScoresdlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSubmitScoresdlg dialog
class CSubmitScoresdlg : public CDialog
{
// Construction
public:
CSubmitScoresdlg(CWnd* pParent = NULL); // standard constructor
GSvoid SetServerID(GSint iLobbyID, GSint iRoomID);
GSvoid SetMatchID(GSuint uiMatchID);
// Dialog Data
//{{AFX_DATA(CSubmitScoresdlg)
enum { IDD = IDD_DIALOGAddScores };
CEdit m_editUsername;
CEdit m_editLobbyID;
CEdit m_editRoomID;
CEdit m_editMatchID;
CEdit m_editFieldValue;
CEdit m_editFieldID;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSubmitScoresdlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
GSint m_iLobbyID;
GSint m_iRoomID;
GSuint m_uiMatchID;
CGsMasterServerClientDlg *m_pParentDlg;
// Generated message map functions
//{{AFX_MSG(CSubmitScoresdlg)
virtual BOOL OnInitDialog();
afx_msg void OnBUTTONinit();
afx_msg void OnBUTTONSet();
afx_msg void OnBUTTONSubmit();
afx_msg void OnBUTTONUninit();
afx_msg void OnBUTTONFinished();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SUBMITSCORESDLG_H__95720E33_2611_47EF_BA0C_4DD5EC46E091__INCLUDED_)

View File

@@ -0,0 +1,110 @@
// gsMasterServerClient.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "gsMasterServerClient.h"
#include "gsMasterServerClientDlg.h"
#include "GSTypes.h"
#include "InitSockets.h"
#include "define.h"
//UBI.COM: These functions are called by the GSlibraries to allocate/free memory
extern "C"{
void * __stdcall ExtAlloc_Malloc(int iSize)
{
return malloc(iSize);
}
void __stdcall ExtAlloc_Free(void * ptr)
{
free(ptr);
}
void __stdcall ExtAlloc_Realloc(void * ptr, unsigned int iSize)
{
realloc(ptr,iSize);
}
}
//UBI.COM: The GSLibraries are not thread safe. This mutex will stop us from
// calling into the library twice at the same time
HANDLE g_Mutex;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGsMasterServerClientApp
BEGIN_MESSAGE_MAP(CGsMasterServerClientApp, CWinApp)
//{{AFX_MSG_MAP(CGsMasterServerClientApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGsMasterServerClientApp construction
CGsMasterServerClientApp::CGsMasterServerClientApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CGsMasterServerClientApp object
CGsMasterServerClientApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CGsMasterServerClientApp initialization
BOOL CGsMasterServerClientApp::InitInstance()
{
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
//UBI.COM: Initialize the Socket library. InitializeSockets will return the
// local IPAddress that is found.
GSchar szIPAddress[IPADDRESSLENGTH]="";
g_Mutex = CreateMutex(NULL,false,NULL);
LOCKMUTEX();
InitializeSockets(szIPAddress);
UNLOCKMUTEX();
CGsMasterServerClientDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
//UBI.COM: Uninitialize the socket library and exit the program
LOCKMUTEX();
UninitializeSockets();
UNLOCKMUTEX();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}

View File

@@ -0,0 +1,166 @@
# Microsoft Developer Studio Project File - Name="gsMasterServerClient" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=gsMasterServerClient - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "gsMasterServerClient.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "gsMasterServerClient.mak" CFG="gsMasterServerClient - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "gsMasterServerClient - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "gsMasterServerClient - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/GSServices/tools-gui/gs-masterserverclient", JLGEAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "gsMasterServerClient - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 5
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /Gz /MT /W3 /GX /O2 /I "../../sdks/gs-sdk-common/include" /I "../../sdks/gs-sdk-msclient/include" /I "../../sdks/gs-sdk-base/include" /I "../../sdks/versions" /D "NDEBUG" /D "DEFVERSION_LIBGSSOCKET" /D "DEFVERSION_LIBGSUTILITY" /D "DEFVERSION_LIBGSCONNECT" /D "DEFVERSION_LIBGSCLIENT" /D "DEFVERSION_LIBGSPROXYCLIENT" /D "DEFVERSION_LIBGSRESULt" /D "DEFVERSION_LIBGSMSCLIENT" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "GS_WIN32" /D "_STLP_NO_IOSTREAMS" /D "DEFVER_LIBGSSOCKET" /D "DEFVER_LIBGSUTILITY" /D "DEFVER_LIBGSCONNECT" /D "DEFVER_LIBGSCLIENT" /D "DEFVER_LIBGSPROXYCLIENT" /D "DEFVER_LIBGSRESULT" /D "DEFVER_LIBGSMSCLIENT" /FD /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x1009 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x1009 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 libgssocket.lib libgsutility.lib libgsconnect.lib libgscrypto.lib libgsproxyclient.lib libgsresult.lib libgsclient.lib libgsmsclient.lib Ws2_32.lib /nologo /subsystem:windows /machine:I386 /libpath:"../../sdks/gs-sdk-http/lib_win32" /libpath:"../../sdks/gs-sdk-msclient/lib_win32../../sdks/gs-sdk-result/lib_win32" /libpath:"../../sdks/gs-sdk-common/lib_win32" /libpath:"../../sdks/gs-sdk-msclient/lib_win32" /libpath:"../../sdks/gs-sdk-result/lib_win32" /libpath:"../../sdks/gs-sdk-proxyclient/lib_win32" /libpath:"../../sdks/gs-sdk-base/lib_win32"
!ELSEIF "$(CFG)" == "gsMasterServerClient - Win32 Debug"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 5
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../sdks/gs-sdk-common/include" /I "../../sdks/gs-sdk-msclient/include" /I "../../sdks/gs-sdk-base/include" /I "../../sdks/versions" /D "_DEBUG" /D "DEFVER_LIBGSSOCKET" /D "DEFVER_LIBGSUTILITY" /D "DEFVER_LIBGSCONNECT" /D "DEFVER_LIBGSCLIENT" /D "DEFVER_LIBGSPROXYCLIENT" /D "DEFVER_LIBGSRESULT" /D "DEFVER_LIBGSMSCLIENT" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "GS_WIN32" /D "_STLP_NO_IOSTREAMS" /FD /GZ /c
# SUBTRACT CPP /YX /Yc /Yu
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x1009 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x1009 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 libgssocket_debug.lib libgsutility_debug.lib libgsconnect_debug.lib libgscrypto_debug.lib libgsproxyclient_debug.lib libgsresult_debug.lib libgsclient_debug.lib libgsmsclient_debug.lib Ws2_32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"../../sdks/gs-sdk-http/lib_win32" /libpath:"../../sdks/gs-sdk-msclient/lib_win32" /libpath:"../../sdks/gs-sdk-result/lib_win32" /libpath:"../../sdks/gs-sdk-common/lib_win32" /libpath:"../../sdks/gs-sdk-proxyclient/lib_win32" /libpath:"../../sdks/gs-sdk-base/lib_win32"
!ENDIF
# Begin Target
# Name "gsMasterServerClient - Win32 Release"
# Name "gsMasterServerClient - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\gsMasterServerClient.cpp
# End Source File
# Begin Source File
SOURCE=.\gsMasterServerClient.rc
# End Source File
# Begin Source File
SOURCE=.\gsMasterServerClientDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\Registry.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# Begin Source File
SOURCE=.\SubmitScoresdlg.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\gsMasterServerClient.h
# End Source File
# Begin Source File
SOURCE=.\gsMasterServerClientDlg.h
# End Source File
# Begin Source File
SOURCE=.\Registry.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\SubmitScoresdlg.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\gsMasterServerClient.ico
# End Source File
# Begin Source File
SOURCE=.\res\gsMasterServerClient.rc2
# End Source File
# End Group
# Begin Source File
SOURCE=.\MSClient.ini
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,73 @@
// gsMasterServerClient.h : main header file for the GSMASTERSERVERCLIENT application
//
#if !defined(AFX_GSMASTERSERVERCLIENT_H__105658B5_BC80_41F6_9297_FE8034DAE519__INCLUDED_)
#define AFX_GSMASTERSERVERCLIENT_H__105658B5_BC80_41F6_9297_FE8034DAE519__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#include "GSTypes.h"
//UBI.COM: Macros to help with locking the Mutex defined in gsMasterServerClient.cpp
#define LOCKMUTEX() WaitForSingleObject(g_Mutex,INFINITE)
#define UNLOCKMUTEX() ReleaseMutex(g_Mutex)
/////////////////////////////////////////////////////////////////////////////
// CGsMasterServerClientApp:
// See gsMasterServerClient.cpp for the implementation of this class
//
class CGsMasterServerClientApp : public CWinApp
{
public:
CGsMasterServerClientApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGsMasterServerClientApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CGsMasterServerClientApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//UBI.COM: The callbacks to register.
GSvoid __stdcall MSGameServer(GSuint uiID,
GSshort siGroupType,GSchar *szGroupName, GSint iConfig,
GSchar *szMaster,GSchar *szAllowedGames,GSchar *szGames,
GSchar *szGameVersion,GSchar *szGSVersion,GSvoid *vpInfo,GSint iSize,
GSuint uiMaxPlayer,GSuint uiNbrPlayer,GSuint uiMaxVisitor,
GSuint uiNbrVisitor,GSchar *szIPAddress,GSchar *szAltIPAddress,
GSint iEventID);
GSvoid __stdcall MSError(GSint iReason);
GSvoid __stdcall MSInitFinished();
GSvoid __stdcall MSRequestFinished();
GSvoid __stdcall MSJoinFinished(GSuint uiID,GSvoid *vpGameData,GSint iSize,
GSchar *szIPAddress,GSchar *szAltIPAddress,GSushort usPort);
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GSMASTERSERVERCLIENT_H__105658B5_BC80_41F6_9297_FE8034DAE519__INCLUDED_)

View File

@@ -0,0 +1,284 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_GSMASTERSERVERCLIENT_DIALOG DIALOGEX 0, 0, 447, 293
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "gsMasterServerClient"
FONT 8, "Arial"
BEGIN
EDITTEXT IDC_EDITServerIP,64,26,65,13,ES_AUTOHSCROLL
EDITTEXT IDC_EDITPort,64,44,65,13,ES_AUTOHSCROLL
EDITTEXT IDC_EDITUsername,181,25,65,13,ES_AUTOHSCROLL
EDITTEXT IDC_EDITPassword,181,44,65,13,ES_AUTOHSCROLL
EDITTEXT IDC_EDITVersion,181,61,65,13,ES_AUTOHSCROLL
PUSHBUTTON "Download config",IDC_BUTTONDownload,285,25,65,14
EDITTEXT IDC_EDITGameName,64,61,65,13,ES_AUTOHSCROLL
PUSHBUTTON "Initialize",IDC_BUTTONInitialize,285,43,65,14
PUSHBUTTON "Uninitialize",IDC_BUTTONUninitialize,285,60,65,14
PUSHBUTTON "Request",IDC_BUTTONRequest,358,25,65,14
CONTROL "List4",IDC_LISTGameServers,"SysListView32",LVS_REPORT |
WS_BORDER | WS_TABSTOP,22,103,405,115
EDITTEXT IDC_EDITGamePassword,137,244,65,13,ES_AUTOHSCROLL
DEFPUSHBUTTON "Join Server",IDC_BUTTONJoin,22,244,65,14
PUSHBUTTON "Leave Server",IDC_BUTTONLeave,22,264,65,14
PUSHBUTTON "Exit",IDEXIT,368,264,60,14
LTEXT "Game name",IDC_STATIC,20,65,43,8
LTEXT "Server IP",IDC_STATIC,20,30,30,8
LTEXT "Server port",IDC_STATIC,20,48,36,8
LTEXT "Username",IDC_STATIC,139,29,33,8
LTEXT "Password",IDC_STATIC,139,48,32,8
LTEXT "Version",IDC_STATIC,139,65,24,8
LTEXT "Password",IDC_STATIC,97,247,34,8
PUSHBUTTON "About",IDC_BUTTONAbout,368,245,60,14
PUSHBUTTON "Refresh",IDC_BUTTONRefresh,358,60,65,14
PUSHBUTTON "Scores",IDC_BUTTONScores,358,43,65,14
PUSHBUTTON "Get Alt Info",IDC_BUTTONGetAlt,213,244,65,14
PUSHBUTTON "Start Match",IDC_BUTTONStartMatch,213,264,65,14
PUSHBUTTON "Connected",IDC_BUTTONConnected,137,264,65,14
GROUPBOX "Operations",IDC_STATIC,272,12,163,70
GROUPBOX "Connection properties",IDC_STATIC,13,12,243,70
GROUPBOX "Server list",IDC_STATIC,13,88,422,140
GROUPBOX "Game server operations",IDC_STATIC,13,232,274,53
GROUPBOX "Misc",IDC_STATIC,294,232,141,53
PUSHBUTTON "Get MOTD",IDC_BUTTON_GETMOTD,300,245,60,14
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "gsMasterServerClient MFC Application\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "gsMasterServerClient\0"
VALUE "LegalCopyright", "Copyright (C) 2002\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "gsMasterServerClient.EXE\0"
VALUE "ProductName", "gsMasterServerClient Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_GSMASTERSERVERCLIENT_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 440
TOPMARGIN, 7
BOTTOMMARGIN, 286
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed."
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (Canada) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENC)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOGAddScores DIALOG DISCARDABLE 0, 0, 247, 239
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Submit Scores"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Init Match",IDC_BUTTONinit,182,7,57,14
PUSHBUTTON "Set Match",IDC_BUTTONSet,182,25,57,14
LTEXT "Lobby ID:",IDC_STATIC,7,13,32,8
EDITTEXT IDC_EDITLobbyID,45,7,40,14,ES_AUTOHSCROLL | ES_READONLY |
ES_NUMBER
LTEXT "Match ID:",IDC_STATIC,7,68,32,8
EDITTEXT IDC_EDITMatchID,45,62,40,14,ES_AUTOHSCROLL | ES_READONLY |
ES_NUMBER
LTEXT "Username:",IDC_STATIC,7,90,35,8
EDITTEXT IDC_EDITUsername,45,84,40,14,ES_AUTOHSCROLL
LTEXT "Field ID:",IDC_STATIC,7,112,27,8
EDITTEXT IDC_EDITFieldID,45,106,40,14,ES_AUTOHSCROLL | ES_NUMBER
LTEXT "Field Value:",IDC_STATIC,7,134,38,8
EDITTEXT IDC_EDITFieldValue,45,128,40,14,ES_AUTOHSCROLL |
ES_NUMBER
PUSHBUTTON "Submit Match",IDC_BUTTONSubmit,182,43,57,14
PUSHBUTTON "Uninit Match",IDC_BUTTONUninit,182,61,57,14
PUSHBUTTON "Match Finish",IDC_BUTTONFinished,182,79,58,14
LTEXT "Room ID:",IDC_STATIC,7,36,31,8
EDITTEXT IDC_EDITRoomID,45,30,40,14,ES_AUTOHSCROLL | ES_READONLY |
ES_NUMBER
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_DIALOGAddScores, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 240
TOPMARGIN, 7
BOTTOMMARGIN, 232
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif //_WIN32\r\n"
"#include ""res\\gsMasterServerClient.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\gsMasterServerClient.ico"
#endif // English (Canada) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "res\gsMasterServerClient.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,803 @@
// gsMasterServerClientDlg.cpp : implementation file
//
#include "stdafx.h"
#include "gsMasterServerClient.h"
#include "gsMasterServerClientDlg.h"
#include "SubmitScoresdlg.h"
//#include "GSHttpInterface.h"
#include "wininet.h"
#include "define.h"
#include "Registry.h"
#include "version_manager.h"
extern HANDLE g_Mutex;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGsMasterServerClientDlg dialog
CGsMasterServerClientDlg::CGsMasterServerClientDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGsMasterServerClientDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGsMasterServerClientDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bInitialized = false;
m_iLobbyID = 0;
m_iRoomID = 0;
m_uiMatchID = 0;
}
CGsMasterServerClientDlg::~CGsMasterServerClientDlg()
{
LOCKMUTEX();
}
void CGsMasterServerClientDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGsMasterServerClientDlg)
DDX_Control(pDX, IDC_EDITGamePassword, m_editGamePassword);
DDX_Control(pDX, IDC_LISTGameServers, m_listGameServers);
DDX_Control(pDX, IDC_EDITVersion, m_editVersion);
DDX_Control(pDX, IDC_EDITUsername, m_editUsername);
DDX_Control(pDX, IDC_EDITServerIP, m_editServerIP);
DDX_Control(pDX, IDC_EDITPort, m_editPort);
DDX_Control(pDX, IDC_EDITPassword, m_editPassword);
DDX_Control(pDX, IDC_EDITGameName, m_editGameName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGsMasterServerClientDlg, CDialog)
//{{AFX_MSG_MAP(CGsMasterServerClientDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDEXIT, OnExit)
ON_BN_CLICKED(IDC_BUTTONInitialize, OnBUTTONInitialize)
ON_BN_CLICKED(IDC_BUTTONRequest, OnBUTTONRequest)
ON_BN_CLICKED(IDC_BUTTONJoin, OnBUTTONJoin)
ON_NOTIFY(NM_DBLCLK, IDC_LISTGameServers, OnDblclkLISTGameServers)
ON_BN_CLICKED(IDC_BUTTONLeave, OnBUTTONLeave)
ON_BN_CLICKED(IDC_BUTTONUninitialize, OnBUTTONUninitialize)
ON_BN_CLICKED(IDC_BUTTONDownload, OnBUTTONDownload)
ON_BN_CLICKED(IDC_BUTTONAbout, OnBUTTONAbout)
ON_BN_CLICKED(IDC_BUTTONRefresh, OnBUTTONRefresh)
ON_BN_CLICKED(IDC_BUTTONScores, OnBUTTONScores)
ON_BN_CLICKED(IDC_BUTTONGetAlt, OnBUTTONGetAlt)
ON_BN_CLICKED(IDC_BUTTONStartMatch, OnBUTTONStartMatch)
ON_BN_CLICKED(IDC_BUTTONConnected, OnBUTTONConnected)
ON_BN_CLICKED(IDC_BUTTON_GETMOTD,OnButtonGetMOTD)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGsMasterServerClientDlg message handlers
//UBI.COM: This thread just calls the MSClient_Engine function. It is safe
// to call this even thought the library has not been initialized,
// but we do have to make sure no to call it at the same time as
// one of the other functions, therefore we use a Mutex.
DWORD ThreadEngine(void* pArg)
{
CGsMasterServerClientDlg *pMSClient = (CGsMasterServerClientDlg *)pArg;
while (true)
{
Sleep(10);
LOCKMUTEX();
if (pMSClient->m_bInitialized)
pMSClient->Engine();
UNLOCKMUTEX();
}
return 0;
}
BOOL CGsMasterServerClientDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
char szUsername[NICKNAMELENGTH],szGamename[GAMELENGTH],szPassword[PASSWORDLENGTH];
char szVersion[VERSIONLENGTH],szGamePassword[PASSWORDLENGTH];
char szServerIP[IPADDRESSLENGTH],szServerPort[100];
char szDirectory[1024];
GetCurrentDirectory(1024,szDirectory);
CString csMSClientIniFile = szDirectory;
csMSClientIniFile += "\\MSClient.ini";
GetPrivateProfileString("MSClient","Username",
"user10",szUsername,NICKNAMELENGTH,csMSClientIniFile);
GetPrivateProfileString("MSClient","Gamename",
"GHOSTRECON",szGamename,GAMELENGTH,csMSClientIniFile);
GetPrivateProfileString("MSClient","Password",
"testtest",szPassword,PASSWORDLENGTH,csMSClientIniFile);
GetPrivateProfileString("MSClient","Version",
"PC4.2",szVersion,VERSIONLENGTH,csMSClientIniFile);
GetPrivateProfileString("MSClient","GamePassword",
"",szGamePassword,PASSWORDLENGTH,csMSClientIniFile);
GetPrivateProfileString("MSClient","ServerIP",
"",szServerIP,IPADDRESSLENGTH,csMSClientIniFile);
GetPrivateProfileString("MSClient","ServerPort",
"",szServerPort,100,csMSClientIniFile);
m_editGameName.SetWindowText(szGamename);
m_editPassword.SetWindowText(szPassword);
m_editPort.SetWindowText(szServerPort);
m_editServerIP.SetWindowText(szServerIP);
m_editUsername.SetWindowText(szUsername);
m_editVersion.SetWindowText(szVersion);
m_editGamePassword.SetWindowText(szGamePassword);
m_listGameServers.InsertColumn(0,"LobbyID",LVCFMT_LEFT,60);
m_listGameServers.InsertColumn(1,"RoomID",LVCFMT_LEFT,60);
m_listGameServers.InsertColumn(2,"Server Name",LVCFMT_LEFT,85);
m_listGameServers.InsertColumn(3,"Master Name",LVCFMT_LEFT,75);
m_listGameServers.InsertColumn(4,"Version",LVCFMT_LEFT,60);
m_listGameServers.InsertColumn(5,"Players",LVCFMT_LEFT,60);
m_listGameServers.InsertColumn(6,"IPAddress",LVCFMT_LEFT,60);
m_listGameServers.InsertColumn(7,"Alt IPAddress",LVCFMT_LEFT,75);
m_listGameServers.InsertColumn(8,"GroupData",LVCFMT_LEFT,75);
m_listGameServers.SetExtendedStyle(LVS_EX_FULLROWSELECT);
//UBI.COM: Create the thread that keeps calling MSClient_Engine
DWORD iThread;
CreateThread(NULL,0,ThreadEngine,this,0,&iThread);
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CGsMasterServerClientDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CGsMasterServerClientDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CGsMasterServerClientDlg::OnExit()
{
Shutdown();
}
//UBI.COM: Uninitialize the library and close the window.
void CGsMasterServerClientDlg::Shutdown()
{
LOCKMUTEX();
Uninitialize();
m_bInitialized = false;
UNLOCKMUTEX();
this->DestroyWindow();
}
void CGsMasterServerClientDlg::OnBUTTONInitialize()
{
GSchar szServer[IPADDRESSLENGTH];
GSchar szPort[10];
GSushort usPort;
GSchar szUsername[NICKNAMELENGTH];
GSchar szPassword[PASSWORDLENGTH];
GSchar szVersion[VERSIONLENGTH];
m_editServerIP.GetWindowText(szServer,IPADDRESSLENGTH);
m_editPort.GetWindowText(szPort,10);
usPort = (GSushort)atol(szPort);
m_editUsername.GetWindowText(szUsername,NICKNAMELENGTH);
m_editPassword.GetWindowText(szPassword,PASSWORDLENGTH);
m_editVersion.GetWindowText(szVersion,VERSIONLENGTH);
//UBI.COM: Initialize the library
LOCKMUTEX();
if (!Initialize(szServer,usPort,szUsername,szPassword,szVersion))
{
MessageBox("Initialize Failed");
UNLOCKMUTEX();
return;
}
m_bInitialized = true;
UNLOCKMUTEX();
}
//UBI.COM: Callbacks
//UBI.COM: Add the recieved Game Server to the list box.
GSvoid CGsMasterServerClientDlg::GameServerCB(GSint iLobbyID,GSint iRoomID,
GSshort siGroupType,GSchar *szGroupName, GSint iConfig,
GSchar *szMaster,GSchar *szAllowedGames,GSchar *szGames,
GSchar *szGameVersion,GSchar *szGSVersion,GSvoid *vpInfo,GSint iSize,
GSuint uiMaxPlayer,GSuint uiNbrPlayer,GSuint uiMaxVisitor,
GSuint uiNbrVisitor,GSchar *szIPAddress,GSchar *szAltIPAddress,
GSint iEventID)
{
GSchar szText[100];
m_listGameServers.InsertItem(m_iNbrGameServers,ltoa(iLobbyID,szText,10));
m_listGameServers.SetItemText(m_iNbrGameServers,1,ltoa(iRoomID,szText,10));
m_listGameServers.SetItemText(m_iNbrGameServers,2,szGroupName);
m_listGameServers.SetItemText(m_iNbrGameServers,3,szMaster);
m_listGameServers.SetItemText(m_iNbrGameServers,4,szGSVersion);
sprintf(szText,"%i/%i",uiNbrPlayer,uiMaxPlayer);
m_listGameServers.SetItemText(m_iNbrGameServers,5,szText);
m_listGameServers.SetItemText(m_iNbrGameServers,6,szIPAddress);
m_listGameServers.SetItemText(m_iNbrGameServers,7,szAltIPAddress);
m_listGameServers.SetItemText(m_iNbrGameServers,8,(char*)vpInfo);
m_iNbrGameServers++;
}
GSvoid CGsMasterServerClientDlg::AlternateInfoCB(GSint iLobbyID,GSint iRoomID,const GSvoid* pcAltGroupInfo,
GSint iAltGroupInfoSize)
{
GSchar szText[100];
sprintf(szText,"AltInfo: %s",pcAltGroupInfo);
MessageBox(szText);
}
//UBI.COM: Display a message box with the error code received
GSvoid CGsMasterServerClientDlg::ErrorCB(GSint iReason,GSint iLobbyID,GSint iRoomID)
{
GSchar szText[100];
sprintf(szText,"Error Code: %i %i %i",iReason,iLobbyID,iRoomID);
MessageBox(szText);
}
//UBI.COM: Display a message box saying that the init has finished
GSvoid CGsMasterServerClientDlg::InitFinishedCB(GSubyte ubType,GSint iError,GSchar *szUserName)
{
GSchar szText[100];
if (ubType == GSSUCCESS)
{
sprintf(szText,"Initialization Finished %s",szUserName);
MessageBox(szText);
}
else
{
sprintf(szText,"Initialization Error : %i",iError);
MessageBox(szText);
}
}
//UBI.COM: Display a message box that we've been disconnect from the Router
GSvoid CGsMasterServerClientDlg::LoginDisconnectCB()
{
GSchar szText[100];
sprintf(szText,"Login Disconnected\n");
MessageBox(szText);
}
//UBI.COM: Display a message box that we've been disconnect from the Lobby
GSvoid CGsMasterServerClientDlg::LobbyDisconnectCB()
{
GSchar szText[100];
sprintf(szText,"Lobby Disconnected\n");
MessageBox(szText);
}
//UBI.COM: Display a message box saying that the request has finished
GSvoid CGsMasterServerClientDlg::RequestFinishedCB()
{
MessageBox("Request Finished");
}
//UBI.COM: Display a message box saying that the join has finished
GSvoid CGsMasterServerClientDlg::JoinFinishedCB(GSint iLobbyID,GSint iRoomID,GSvoid *vpGameData,GSint iSize,
GSchar *szIPAddress,GSchar *szAltIPAddress,GSushort usPort)
{
char szText[1024];
sprintf(szText,"Join Finished: %s %s %s %i",vpGameData,szIPAddress,szAltIPAddress,usPort);
MessageBox(szText);
}
GSvoid CGsMasterServerClientDlg::AccountCreationCB(GSubyte ucType,GSint iReason)
{
char szText[1024];
if (ucType == GSSUCCESS)
sprintf(szText,"Account Creation succeeded");
else
sprintf(szText,"Account Creation failed %i",iReason);
MessageBox(szText);
}
GSvoid CGsMasterServerClientDlg::ModifyAccountCB(GSubyte ucType,GSint iReason)
{
char szText[1024];
if (ucType == GSSUCCESS)
sprintf(szText,"Modify Account Creation succeeded");
else
sprintf(szText,"Modify Account failed %i",iReason);
MessageBox(szText);
}
GSvoid CGsMasterServerClientDlg::MatchStartedCB(GSint iLobbyID,GSint iRoomID,GSuint uiMatchID)
{
char szText[1024];
sprintf(szText,"Match Started: %i %i %i",iLobbyID,iRoomID, uiMatchID);
MessageBox(szText);
m_iLobbyID = iLobbyID;
m_iRoomID = iRoomID;
m_uiMatchID = uiMatchID;
}
GSvoid CGsMasterServerClientDlg::SubmitMatchCB(GSubyte ucType,GSint iReason,GSuint uiMatchID)
{
char szText[1024];
if (ucType == GSSUCCESS)
{
sprintf(szText,"Submit Match Sucessfull: %i",uiMatchID);
MessageBox(szText);
}
else
{
sprintf(szText,"Submit Match Fail: %i %i",iReason,uiMatchID);
MessageBox(szText);
}
}
GSvoid CGsMasterServerClientDlg::RequestMOTDCB(GSubyte ubType, GSchar *szUbiMOTD,
GSchar *szGameMOTD, GSint iReason)
{
CString csText;
if (ubType == GSSUCCESS)
{
csText.Format("Message of the day request successfull.\r\nUbi motd: %s\r\nGame motd: %s",szUbiMOTD,szGameMOTD);
AfxMessageBox(csText,MB_OK);
}
else
{
csText.Format("Message of the day request failure. Error id: %d",iReason);
AfxMessageBox(csText,MB_ICONERROR);
}
}
void CGsMasterServerClientDlg::OnBUTTONRequest()
{
GSchar szGameName[GAMELENGTH];
m_editGameName.GetWindowText(szGameName,GAMELENGTH);
//UBI.COM: Request the list of gameserver with the game name
LOCKMUTEX();
clMSClientClass::RequestGameServers(szGameName);
UNLOCKMUTEX();
m_listGameServers.DeleteAllItems();
m_iNbrGameServers = 0;
}
void CGsMasterServerClientDlg::OnBUTTONJoin()
{
POSITION pos = m_listGameServers.GetFirstSelectedItemPosition();
if (pos == NULL)
MessageBox("No Game Server Seleted");
else
{
if (pos)
{
int iItem = m_listGameServers.GetNextSelectedItem(pos);
JoinGameServer(iItem);
}
}
}
void CGsMasterServerClientDlg::JoinGameServer(int iItem)
{
char szText[10];
char szPassword[PASSWORDLENGTH]="";
char szVersion[VERSIONLENGTH]="";
char szGameName[GAMELENGTH]="";
GSint iLobbyID,iRoomID;
m_listGameServers.GetItemText(iItem,0,szText,10);
iLobbyID = atol(szText);
m_listGameServers.GetItemText(iItem,1,szText,10);
iRoomID = atol(szText);
m_listGameServers.GetItemText(iItem,4,szVersion,VERSIONLENGTH);
m_editGamePassword.GetWindowText(szPassword,PASSWORDLENGTH);
m_editGameName.GetWindowText(szGameName,GAMELENGTH);
//UBI.COM: Join the selected game server
LOCKMUTEX();
clMSClientClass::JoinGameServer(iLobbyID,iRoomID,szPassword,szVersion,szGameName,
"test",5);
UNLOCKMUTEX();
}
void CGsMasterServerClientDlg::LeaveGameServer(int iItem)
{
char szText[10];
GSint iLobbyID,iRoomID;
m_listGameServers.GetItemText(iItem,0,szText,10);
iLobbyID = atol(szText);
m_listGameServers.GetItemText(iItem,1,szText,10);
iRoomID = atol(szText);
//UBI.COM: Leave the selected game server
LOCKMUTEX();
clMSClientClass::LeaveGameServer(iLobbyID,iRoomID);
UNLOCKMUTEX();
}
void CGsMasterServerClientDlg::OnDblclkLISTGameServers(NMHDR* pNMHDR, LRESULT* pResult)
{
POSITION pos = m_listGameServers.GetFirstSelectedItemPosition();
if (pos == NULL)
MessageBox("No Game Server Seleted");
else
{
while (pos)
{
int iItem = m_listGameServers.GetNextSelectedItem(pos);
JoinGameServer(iItem);
}
}
*pResult = 0;
}
void CGsMasterServerClientDlg::OnBUTTONLeave()
{
POSITION pos = m_listGameServers.GetFirstSelectedItemPosition();
if (pos == NULL)
MessageBox("No Game Server Seleted");
else
{
if (pos)
{
int iItem = m_listGameServers.GetNextSelectedItem(pos);
LeaveGameServer(iItem);
}
}
}
//UBI.COM: Uninitialize the Library but don't close the window.
void CGsMasterServerClientDlg::OnBUTTONUninitialize()
{
LOCKMUTEX();
Uninitialize();
m_bInitialized = false;
UNLOCKMUTEX();
}
void CGsMasterServerClientDlg::OnBUTTONDownload()
{
CRegistry registry(HKEY_LOCAL_MACHINE, CString("SOFTWARE\\Ubi Soft\\Game Service"),
false,KEY_READ);
CString csGSIniURL;
char szDirectory[100];
GetCurrentDirectory(100,szDirectory);
CString csGSIniFile = szDirectory;
csGSIniFile += "\\GS.ini";
CString csMSClientIniFile = szDirectory;
csMSClientIniFile += "\\MSClient.ini";
registry.OpenKey();
//UBI.COM: Try to read the ConnectURL from the registry
// If it fails we'll look in Launcher.ini
if (!registry.ReadString(CString("ConnectURL"), &csGSIniURL))
{
char szUrl[1024];
MessageBox("Registry failed; using MSClient.ini");
GetPrivateProfileString("MSClient","ConnectURL",
"http://gsconnect.ubisoft.com/gsinit.php?user=%s&dp=%s",szUrl,
1024,csMSClientIniFile);
csGSIniURL = szUrl;
}
registry.CloseKey();
char szUsername[NICKNAMELENGTH],szGamename[GAMELENGTH];
m_editUsername.GetWindowText(szUsername,NICKNAMELENGTH);
m_editGameName.GetWindowText(szGamename,GAMELENGTH);
//UBI.COM: Replace the strings in the URL
csGSIniURL.Replace("user=%s",(CString("user=")+szUsername));
csGSIniURL.Replace("dp=%s",(CString("dp=")+szGamename));
//UBI.COM: Try to download the file GS.ini file if it fails
// we can use the old local one
HINTERNET hNet = InternetOpen("",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,NULL);
if (!hNet)
MessageBox("InternetOpen Failed");
else
{
HINTERNET hURL = InternetOpenUrl(hNet,csGSIniURL,NULL,0,INTERNET_FLAG_HYPERLINK,NULL);
if (!hURL)
MessageBox("InternetOpenUrl Failed");
else
{
GSchar szBuffer[1024];
GSint iSize = 1024;
DWORD iRead = 0;
FILE *pFile = fopen(csGSIniFile,"w");
while (InternetReadFile(hURL,szBuffer,iSize,&iRead))
{
if (iRead != 0)
{
fwrite(szBuffer,sizeof(GSchar),iRead,pFile);
}
else
{
fclose(pFile);
break;
}
}
}
}
char szIPAddress[IPADDRESSLENGTH];
char szPort[100];
//UBI.COM: Read in the Address of the GSRouter.
// We'll only read in the first address, in a real application
// you should get both so that if one fails you can try the
// other.
GetPrivateProfileString("Servers","RouterIP0","srv-gstest",szIPAddress,
IPADDRESSLENGTH,csGSIniFile);
//UBI.COM: Read in the Port of the GSRouter
GetPrivateProfileString("Servers","RouterPort0","41000",szPort,
100,csGSIniFile);
m_editServerIP.SetWindowText(szIPAddress);
m_editPort.SetWindowText(szPort);
MessageBox("Download Finished");
return;
}
void CGsMasterServerClientDlg::OnBUTTONAbout()
{
char *szBuffer;
unsigned int iBufferSize;
CGSVersion ver;
ver.PrintModulesVersion(NULL,&iBufferSize);
szBuffer = (char*)malloc(iBufferSize);
ver.PrintModulesVersion(szBuffer,&iBufferSize);
MessageBox(szBuffer);
free(szBuffer);
}
void CGsMasterServerClientDlg::OnBUTTONRefresh()
{
POSITION pos = m_listGameServers.GetFirstSelectedItemPosition();
if (pos == NULL)
MessageBox("No Game Server Seleted");
else
{
GSuint iCount = m_listGameServers.GetSelectedCount();
GSint iNum=0;
while (pos)
{
char szText[10];
GSint iLobbyID;
GSint iRoomID;
GSint iItem= m_listGameServers.GetNextSelectedItem(pos);
m_listGameServers.GetItemText(iItem,0,szText,10);
iLobbyID = atol(szText);
m_listGameServers.GetItemText(iItem,1,szText,10);
iRoomID = atol(szText);
LOCKMUTEX();
clMSClientClass::RefreshGameServer(iLobbyID,iRoomID);
UNLOCKMUTEX();
}
m_listGameServers.DeleteAllItems();
m_iNbrGameServers = 0;
}
}
void CGsMasterServerClientDlg::OnBUTTONScores()
{
if (m_iLobbyID)
{
CSubmitScoresdlg dlgSubmitScores(this);
dlgSubmitScores.SetServerID(m_iLobbyID,m_iRoomID);
dlgSubmitScores.SetMatchID(m_uiMatchID);
dlgSubmitScores.DoModal();
m_iLobbyID = 0;
m_iRoomID = 0;
m_uiMatchID = 0;
}
//else
// MessageBox("Have not received MatchStarted\n");
}
/*void CGsMasterServerClientDlg::OnBUTTONJoinID()
{
GSchar szGameName[GAMELENGTH];
m_editGameName.GetWindowText(szGameName,GAMELENGTH);
LOCKMUTEX();
clMSClientClass::JoinGameServer(7,-154,"","2.0",szGameName);
UNLOCKMUTEX();
}*/
void CGsMasterServerClientDlg::OnBUTTONGetAlt()
{
POSITION pos = m_listGameServers.GetFirstSelectedItemPosition();
if (pos == NULL)
MessageBox("No Game Server Seleted");
else
{
while (pos)
{
int iItem = m_listGameServers.GetNextSelectedItem(pos);
GSchar szText[10];
GSint iLobbyID,iRoomID;
m_listGameServers.GetItemText(iItem,0,szText,10);
iLobbyID = atol(szText);
m_listGameServers.GetItemText(iItem,1,szText,10);
iRoomID = atol(szText);
//UBI.COM: Join the request the game servers Alt Info
LOCKMUTEX();
clMSClientClass::RequestAlternateInfo(iLobbyID,iRoomID);
UNLOCKMUTEX();
}
}
}
void CGsMasterServerClientDlg::OnBUTTONStartMatch()
{
POSITION pos = m_listGameServers.GetFirstSelectedItemPosition();
if (pos == NULL)
MessageBox("No Game Server Seleted");
else
{
while (pos)
{
int iItem = m_listGameServers.GetNextSelectedItem(pos);
GSchar szText[10];
GSint iLobbyID,iRoomID;
m_listGameServers.GetItemText(iItem,0,szText,10);
iLobbyID = atol(szText);
m_listGameServers.GetItemText(iItem,1,szText,10);
iRoomID = atol(szText);
//UBI.COM: Join the request the game servers Alt Info
LOCKMUTEX();
clMSClientClass::MatchStarted(iLobbyID,iRoomID);
UNLOCKMUTEX();
}
}
}
void CGsMasterServerClientDlg::OnBUTTONConnected()
{
POSITION pos = m_listGameServers.GetFirstSelectedItemPosition();
if (pos == NULL)
MessageBox("No Game Server Seleted");
else
{
while (pos)
{
int iItem = m_listGameServers.GetNextSelectedItem(pos);
GSchar szText[10];
GSint iLobbyID,iRoomID;
m_listGameServers.GetItemText(iItem,0,szText,10);
iLobbyID = atol(szText);
m_listGameServers.GetItemText(iItem,1,szText,10);
iRoomID = atol(szText);
//UBI.COM: Tell The Lobby server we've connected to the game
LOCKMUTEX();
clMSClientClass::GameServerConnected(iLobbyID,iRoomID);
UNLOCKMUTEX();
}
}
}
void CGsMasterServerClientDlg::OnButtonGetMOTD()
{
LOCKMUTEX();
RequestMOTD("fr");
UNLOCKMUTEX();
}

View File

@@ -0,0 +1,114 @@
// gsMasterServerClientDlg.h : header file
//
#if !defined(AFX_GSMASTERSERVERCLIENTDLG_H__14918F3D_F9D7_4962_9438_7CB4C4CDEDB4__INCLUDED_)
#define AFX_GSMASTERSERVERCLIENTDLG_H__14918F3D_F9D7_4962_9438_7CB4C4CDEDB4__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "MSClientClass.h"
/////////////////////////////////////////////////////////////////////////////
// CGsMasterServerClientDlg dialog
class CGsMasterServerClientDlg : public CDialog, public clMSClientClass
{
// Construction
public:
void Shutdown();
CGsMasterServerClientDlg(CWnd* pParent = NULL); // standard constructor
~CGsMasterServerClientDlg();
// Dialog Data
//{{AFX_DATA(CGsMasterServerClientDlg)
enum { IDD = IDD_GSMASTERSERVERCLIENT_DIALOG };
CEdit m_editGamePassword;
CListCtrl m_listGameServers;
CEdit m_editVersion;
CEdit m_editUsername;
CEdit m_editServerIP;
CEdit m_editPort;
CEdit m_editPassword;
CEdit m_editGameName;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGsMasterServerClientDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CGsMasterServerClientDlg)
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnExit();
afx_msg void OnBUTTONInitialize();
afx_msg void OnBUTTONRequest();
afx_msg void OnBUTTONJoin();
afx_msg void OnDblclkLISTGameServers(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnBUTTONLeave();
afx_msg void OnBUTTONUninitialize();
afx_msg void OnBUTTONDownload();
afx_msg void OnBUTTONAbout();
afx_msg void OnBUTTONRefresh();
afx_msg void OnBUTTONScores();
afx_msg void OnBUTTONGetAlt();
afx_msg void OnBUTTONStartMatch();
afx_msg void OnBUTTONConnected();
afx_msg void OnButtonGetMOTD();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
GSvoid GameServerCB(GSint iLobbyID,GSint iRoomID,
GSshort siGroupType,GSchar *szGroupName, GSint iConfig,
GSchar *szMaster,GSchar *szAllowedGames,GSchar *szGames,
GSchar *szGameVersion,GSchar *szGSVersion,GSvoid *vpInfo,GSint iSize,
GSuint uiMaxPlayer,GSuint uiNbrPlayer,GSuint uiMaxVisitor,
GSuint uiNbrVisitor,GSchar *szIPAddress,GSchar *szAltIPAddress,
GSint iEventID);
GSvoid AlternateInfoCB(GSint iLobbyID,GSint iRoomID,const GSvoid* pcAltGroupInfo,
GSint iAltGroupInfoSize);
GSvoid ErrorCB(GSint iReason,GSint iLobbyId,GSint iRoomID);
GSvoid InitFinishedCB(GSubyte ubType,GSint iError,GSchar *szUserName);
GSvoid LoginDisconnectCB();
GSvoid LobbyDisconnectCB();
GSvoid RequestFinishedCB();
GSvoid JoinFinishedCB(GSint iLobbyID,GSint iRoomID,GSvoid *vpGameData,GSint iSize,
GSchar *szIPAddress,GSchar *szAltIPAddress,GSushort usPort);
GSvoid AccountCreationCB(GSubyte ucType,GSint iReason);
GSvoid ModifyAccountCB(GSubyte ucType,GSint iReason);
GSvoid MatchStartedCB(GSint iLobbyID,GSint iRoomID,GSuint uiMatchID);
GSvoid SubmitMatchCB(GSubyte ucType,GSint iReason,GSuint uiMatchID);
GSvoid RequestMOTDCB(GSubyte ubType, GSchar *szUbiMOTD,
GSchar *szGameMOTD, GSint iReason);
GSbool m_bInitialized;
private:
GSint m_iNbrGameServers;
GSuint m_uiMatchID;
GSint m_iLobbyID;
GSint m_iRoomID;
void JoinGameServer(GSint iItem);
void LeaveGameServer(GSint iItem);
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GSMASTERSERVERCLIENTDLG_H__14918F3D_F9D7_4962_9438_7CB4C4CDEDB4__INCLUDED_)

View File

@@ -0,0 +1,383 @@
/***SDOC*******************************************************************************************
*
* UbiSoft Development Network
* ---------------------------
*
* FILE........: httpconfig.cpp
* CREATION....: 11 Dec. 2001
* AUTHOR......: Guillaume Plante
*
* DESCRIPTION.: implementation of the CGSHttpConfig class
*
**************************************************************************************************
* FILE HISTORY
**************************************************************************************************
*
* DATE........:
* AUTHOR......:
* DESCRIPTION.:
*
******************************************************************************************EDOC***/
#include "httpconfig.h"
//these 2 are included for the binary mode in case of binary download
#include <io.h>
#include <fcntl.h>
#include <winsock2.h>
//===================================================================================================
// CLASS CGSHttpConfig
// METHOD CGSHttpConfig
// AUTHOR: Guillaume Plante
// CREATION: April 4, 2002
//
// DESCRIPTION: Default constructor
//===================================================================================================
CGSHttpConfig::CGSHttpConfig()
{
m_iTimeOut = 0;
m_bInitialised = false;
}
//===================================================================================================
// CLASS CGSHttpConfig
// METHOD PrintError
// AUTHOR: Guillaume Plante
// CREATION: April 4, 2002
//
// DESCRIPTION: Print error code on stderr
//===================================================================================================
void CGSHttpConfig::PrintError(const char * szError)
{
fprintf(stderr,"\nerror: %s\nwsalasterror: %d\n", szError, WSAGetLastError());
}
//===================================================================================================
// CLASS CGSHttpConfig
// METHOD Initialize
// AUTHOR: Guillaume Plante
// CREATION: April 4, 2002
//
// DESCRIPTION: Initialize the class (winsock2)
//===================================================================================================
bool CGSHttpConfig::Initialize()
{
if(m_bInitialised)
return false;
// set the default time out value
m_iTimeOut = _DEFAULT_TIMEOUT;
m_bInitialised = true;
return true;
}
//===================================================================================================
// CLASS CGSHttpConfig
// METHOD Uninitialize
// AUTHOR: Guillaume Plante
// CREATION: April 4, 2002
//
// DESCRIPTION: Uninitialize the class (winsock2)
//===================================================================================================
bool CGSHttpConfig::Uninitialize()
{
if(!m_bInitialised)
return false;
m_bInitialised = false;
return true;
}
//===================================================================================================
// CLASS CGSHttpConfig
// METHOD GetWebFile
// AUTHOR: Guillaume Plante
// CREATION: April 4, 2002
//
// DESCRIPTION: Get the a file given a url and write it to a location
//===================================================================================================
int CGSHttpConfig::GetWebFile(const char * szURL,const char * szLocalFileName)
{
_urlinfo UrlInfo;
if(!ParseURL(szURL,&UrlInfo))
return -1;
// Lookup host
LPHOSTENT lpHostEntry;
lpHostEntry = gethostbyname(UrlInfo.szHost);
if (lpHostEntry == NULL)
{
PrintError("gethostbyname()");
return -1;
}
// file object
FILE *fData = NULL;
// make sure the file is empty first
if(szLocalFileName)
{
// write to file
if(!(fData = fopen(szLocalFileName,"w")))
{
PrintError("Could not open local file");
return -1;
}
// set the output as binary in case of a jpg or else
_setmode(_fileno(fData), _O_BINARY);
fwrite("", 1, 1, fData);
fclose(fData);
}
// Fill in the server address structure
SOCKADDR_IN sa;
sa.sin_family = AF_INET;
sa.sin_addr = *((LPIN_ADDR)*lpHostEntry->h_addr_list);
sa.sin_port = htons(UrlInfo.usPort);
// Create a TCP/IP stream socket
SOCKET Socket;
Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (Socket == INVALID_SOCKET)
{
PrintError("socket()");
return -1;
}
//
// Create an event object to be used with this socket
//
WSAEVENT hEvent;
hEvent = WSACreateEvent();
if (hEvent == WSA_INVALID_EVENT)
{
PrintError("WSACreateEvent()");
closesocket(Socket);
return -1;
}
// Make the socket non-blocking and
// associate it with network event
int nRet;
nRet = WSAEventSelect(Socket,
hEvent,
FD_READ|FD_CONNECT|FD_CLOSE);
if (nRet == SOCKET_ERROR)
{
PrintError("EventSelect()");
closesocket(Socket);
WSACloseEvent(hEvent);
return -1;
}
// Request a connection
nRet = connect(Socket, (LPSOCKADDR)&sa, sizeof(SOCKADDR_IN));
if (nRet == SOCKET_ERROR)
{
nRet = WSAGetLastError();
if (nRet == WSAEWOULDBLOCK)
{
fprintf(stderr,"\nConnect would block");
}
else
{
PrintError("connect()");
closesocket(Socket);
WSACloseEvent(hEvent);
return -1;
}
}
// Handle async network events
char szBuffer[4096];
WSANETWORKEVENTS events;
while(1)
{
// Wait for something to happen
//fprintf(stderr,"\nWaitForMultipleEvents()");
DWORD dwRet;
dwRet = WSAWaitForMultipleEvents(1,
&hEvent,
FALSE,
1000,
FALSE);
if (dwRet == WSA_WAIT_TIMEOUT)
{
fprintf(stderr,"\nWait timed out");
break;
}
// Figure out what happened
//fprintf(stderr,"\nWSAEnumNetworkEvents()");
nRet = WSAEnumNetworkEvents(Socket, hEvent,&events);
if (nRet == SOCKET_ERROR)
{
PrintError("WSAEnumNetworkEvents()");
break;
}
// handling events
// Connect event
if (events.lNetworkEvents & FD_CONNECT)
{
// Send the http request
// make the request
MakeRequest(szBuffer,UrlInfo.szObject,UrlInfo.szHost);
nRet = send(Socket, szBuffer, strlen(szBuffer), 0);
if (nRet == SOCKET_ERROR)
{
PrintError("send()");
break;
}
}
// Read event
if (events.lNetworkEvents & FD_READ)
{
// Read the data and write it to stdout
nRet = recv(Socket, szBuffer, sizeof(szBuffer), 0);
if (nRet == SOCKET_ERROR)
{
PrintError("recv()");
break;
}
//fprintf(stderr,"\nRead %d bytes", nRet);
if(szLocalFileName)
{
// write to file
if(!(fData = fopen(szLocalFileName,"a+")))
{
PrintError("Could not open local file");
return -1;
}
// set the output as binary in case of a jpg or else
_setmode(_fileno(fData), _O_BINARY);
fwrite(szBuffer, nRet, 1, fData);
fclose(fData);
}
else
{
// set the output as binary in case of a jpg or else
_setmode(_fileno(stdout), _O_BINARY);
// Write to stdout
fwrite(szBuffer, nRet, 1, stdout);
}
}
// Close event
if (events.lNetworkEvents & FD_CLOSE)
break;
}
closesocket(Socket);
WSACloseEvent(hEvent);
return 1;
}
//===================================================================================================
// CLASS CGSHttpConfig
// METHOD MakeRequest
// AUTHOR: Guillaume Plante
// CREATION: April 4, 2002
//
// DESCRIPTION: Make a standard http "GET" request based on a absolute file path and hostname
//===================================================================================================
char *CGSHttpConfig::MakeRequest(char * szBuffer,const char * szFile,const char * szHostname)
{
sprintf(szBuffer, "GET %s HTTP/1.1\nHost: %s\n\n", szFile,szHostname);
return szBuffer;
}
//===================================================================================================
// CLASS CGSHttpConfig
// METHOD ParseURL
// AUTHOR: Guillaume Plante
// CREATION: April 4, 2002
//
// DESCRIPTION: Parse a URL to give back the server, object, service name and port number in a struct
//===================================================================================================
bool CGSHttpConfig::ParseURL(const char *szURL,_urlinfo *UrlInfo)
{
char szTempURL[256];
char *pc = NULL;
char *pcPort = NULL;
char *pcObj = NULL;
int cpt = 0;
int len = 0;
memset(UrlInfo->szHost,0,sizeof(UrlInfo->szHost));
memset(UrlInfo->szService,0,sizeof(UrlInfo->szService));
memset(UrlInfo->szObject,0,sizeof(UrlInfo->szObject));
UrlInfo->usPort = 0;
// make a copy of the url
strncpy(szTempURL,szURL,255);
if(!strstr(szTempURL,HTTP_SEP_PROTO_HOST))
return false;
// first find the service type
pc = strtok(szTempURL,HTTP_SEP_PROTO_HOST);
if(!pc)
return false;
// put service in uppercase
len = strlen(pc);
for(cpt = 0;cpt<=len;cpt++)
{
pc[cpt] = tolower(pc[cpt]);
}
// copy the service name
strncpy(UrlInfo->szService,pc,sizeof(UrlInfo->szService));
// check for invalid service.
if((strcmp(UrlInfo->szService,NET_SERVICE_HTTP))&&(strcmp(UrlInfo->szService,NET_SERVICE_FTP))&&
(strcmp(UrlInfo->szService,NET_SERVICE_GOPHER)))
return false;
// make a copy of the url
strncpy(szTempURL,szURL,255);
// find the port is there is none, port is 80 (standard)
pc = strchr(szTempURL,':');
if(pc)
{
if(pc = strtok(++pc,HTTP_SEP_SLASH))
pcPort = strrchr(pc,HTTP_SEP_COLON_INT);
else
return false; // could not determine hostname
if(pcPort)
{
UrlInfo->usPort = atoi(++pcPort);
if(pc = strtok(pc,HTTP_SEP_COLON))
strncpy(UrlInfo->szHost,pc,sizeof(UrlInfo->szHost));
else
return false; // could not find hostname
}
else
{
strncpy(UrlInfo->szHost,pc,sizeof(UrlInfo->szHost));
UrlInfo->usPort = HTTP_DEFAULT_PORT; // well known http port
}
}
else
return false;
// in case of badly formed url put the default http port
if(!UrlInfo->usPort)
UrlInfo->usPort = HTTP_DEFAULT_PORT;
// make a copy of the url
strncpy(szTempURL,szURL,255);
// now find the object
pcObj = strstr(szTempURL,UrlInfo->szHost);
if(pcObj)
{
if(pcObj = strchr(pcObj+cpt,HTTP_SEP_SLASH_INT))
strncpy(UrlInfo->szObject,pcObj,sizeof(UrlInfo->szObject));
else
strncpy(UrlInfo->szObject,"/",sizeof(UrlInfo->szObject));
}
else
return false;
return true;
}

View File

@@ -0,0 +1,74 @@
/***SDOC*******************************************************************************************
*
* UbiSoft Development Network
* ---------------------------
*
* FILE........: httpconfig.h
* CREATION....: 11 Dec. 2001
* AUTHOR......: Guillaume Plante
*
* DESCRIPTION.: wrapper class around winsock to get a file on the net via the http protocol,
* using event objects and WSASelectEvent()
*
**************************************************************************************************
* FILE HISTORY
**************************************************************************************************
*
* DATE........:
* AUTHOR......:
* DESCRIPTION.:
*
******************************************************************************************EDOC***/
#ifndef _HTTPCONFIG_H_
#define _HTTPCONFIG_H_
#include <stdio.h>
#define _DEFAULT_TIMEOUT 10
#define NET_SERVICE_HTTP "http"
#define NET_SERVICE_FTP "ftp"
#define NET_SERVICE_GOPHER "gopher"
#define HTTP_DEFAULT_PORT 80
#define HTTP_SEP_COLON ":"
#define HTTP_SEP_COLON_INT ':'
#define HTTP_SEP_SLASH "/"
#define HTTP_SEP_SLASH_INT '/'
#define HTTP_SEP_PROTO_HOST "://"
typedef struct
{
char szService[12];
char szHost[128];
char szObject[128];
unsigned short int usPort;
} _urlinfo;
class CGSHttpConfig
{
public:
CGSHttpConfig(); // constructor
~CGSHttpConfig(){}; // destructor
bool Initialize(); // Initialize winsock.
bool Uninitialize(); // clean up the place.
// set the time out for a http query
void SetTimeOut(int iTimeout){m_iTimeOut = iTimeout;};
// get the timeout in second for a query
int GetTimeOut(){return m_iTimeOut;};
// get the file and write it into a buffer
// (stdout if szFileBuf is NULL)
int GetWebFile(const char *szURL,const char *szFileBuf = NULL);
private:
bool ParseURL(const char *szURL,_urlinfo *UrlInfo);
// create a http GET request
char *MakeRequest(char *szBuffer,const char *szFile,const char *szHost);
void PrintError(const char *szError);// print the last error encountered
bool m_bInitialised; // initialisation flag
int m_iTimeOut; // Time out value in second for a query
};
#endif //_HTTPCONFIG_H_

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,13 @@
//
// GSMASTERSERVERCLIENT.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,53 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by gsMasterServerClient.rc
//
#define IDD_GSMASTERSERVERCLIENT_DIALOG 102
#define IDP_SOCKETS_INIT_FAILED 103
#define IDR_MAINFRAME 128
#define IDD_DIALOGAddScores 129
#define IDC_EDITGameName 1001
#define IDC_BUTTONRequest 1002
#define IDC_BUTTONJoin 1003
#define IDEXIT 1004
#define IDC_EDITServerIP 1005
#define IDC_EDITPort 1006
#define IDC_EDITUsername 1008
#define IDC_EDITPassword 1009
#define IDC_EDITVersion 1010
#define IDC_BUTTONInitialize 1011
#define IDC_LISTGameServers 1014
#define IDC_BUTTONLeave 1015
#define IDC_BUTTONUninitialize 1016
#define IDC_EDITGamePassword 1017
#define IDC_BUTTONDownload 1018
#define IDC_BUTTONAbout 1019
#define IDC_BUTTONRefresh 1020
#define IDC_EDITServerID 1021
#define IDC_EDITLobbyID 1021
#define IDC_EDITMatchID 1022
#define IDC_BUTTONinit 1023
#define IDC_EDITRoomID 1024
#define IDC_EDITFieldID 1025
#define IDC_EDITFieldValue 1026
#define IDC_BUTTONSet 1027
#define IDC_BUTTONSubmit 1028
#define IDC_BUTTONUninit 1029
#define IDC_BUTTONFinished 1030
#define IDC_BUTTONScores 1031
#define IDC_BUTTONJoinID 1032
#define IDC_BUTTONGetAlt 1033
#define IDC_BUTTONStartMatch 1034
#define IDC_BUTTONConnected 1035
#define IDC_BUTTON_GETMOTD 1036
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1036
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif