1
0
mirror of https://github.com/jummy0/sb2-decomp synced 2025-03-14 20:23:30 +01:00

fix network init

This commit is contained in:
jummy 2024-10-29 19:09:34 -05:00
parent 6e939d8a8a
commit 05c5c24f33
4 changed files with 17 additions and 14 deletions

View File

@ -779,6 +779,11 @@ static BOOL DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
g_pSound->SetState(TRUE);
g_pSound->SetCDAudio(g_bCDAudio);
g_pNetwork = new CNetwork;
if (g_pNetwork == NULL) return InitFail("New network", TRUE);
g_pNetwork->CreateProvider(0);
g_pMovie = new CMovie;
if (g_pMovie == NULL) return InitFail("New movie", FALSE);
@ -796,10 +801,6 @@ static BOOL DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
g_pEvent->SetFullScreen(g_bFullScreen);
g_pEvent->SetMouseType(g_mouseType);
g_pNetwork = new CNetwork;
if (g_pNetwork == NULL) return InitFail("New network", TRUE);
g_pNetwork->CreateProvider(0);
#if _INTRO
g_pEvent->ChangePhase(WM_PHASE_INTRO1);
#else

View File

@ -26,6 +26,7 @@
#define MAXNETPLAYER 4
#define MAXTEAM 4
#define MAXNETMESSAGE 20
#define MAXSESSION 100
#define MAXMOVEOBJECT 200
#define MAXNOTIF 5
#define MAXFIFOPOS 10

View File

@ -35,10 +35,12 @@ CNetwork::~CNetwork()
static BOOL EnumProvidersCallback(LPGUID lpguidSP, LPSTR lpSPName,
DWORD dwMajorVersion, DWORD dwMinorVersion, NamedGUIDList* lpContext)
{
NamedGUID* lpGuid;
if (lpContext->nb < MAXSESSION)
{
lpContext->pList[lpContext->nb]->guid = *lpguidSP;
strcpy(lpContext->pList[lpContext->nb]->name, lpSPName);
lpGuid = lpContext->pList[lpContext->nb];
lpGuid->guid = *lpguidSP;
strcpy(lpGuid->name, lpSPName);
lpContext->nb++;
}
return TRUE;
@ -95,7 +97,7 @@ BOOL CNetwork::CreateProvider(int index)
void CNetwork::FreeProviderList()
{
if (m_providers.pList) free(m_providers.pList); // wrong
if (m_providers.pList) free(m_providers.pList);
m_providers.nb = 0;
m_providers.pList = NULL;
@ -105,12 +107,14 @@ void CNetwork::FreeProviderList()
static BOOL EnumSessionsCallback(LPDPSESSIONDESC2 lpThisSD,
LPDWORD lpdwTimeOut, DWORD dwFlags, NamedGUIDList* lpContext)
{
NamedGUID* lpGuid;
if (dwFlags & DPESC_TIMEDOUT) return FALSE;
if (lpContext->nb < MAXSESSION)
{
lpContext->pList[lpContext->nb]->guid = lpThisSD->guidInstance;
strcpy(lpContext->pList[lpContext->nb]->name, lpThisSD->lpszSessionNameA);
lpGuid = lpContext->pList[lpContext->nb];
lpGuid->guid = lpThisSD->guidInstance;
strcpy(lpGuid->name, lpThisSD->lpszSessionNameA);
lpContext->nb++;
}
return TRUE;

View File

@ -4,11 +4,10 @@
#define NETWORK_H
#include "dplay.h"
#include "def.h"
/////////////////////////////////////////////////////////////////////////////
#define MAXSESSION 100
typedef struct
{
char bIsPresent;
@ -57,7 +56,7 @@ public:
void FreeUnknownList();
BOOL IsHost();
NetPlayer m_players[4];
NetPlayer m_players[MAXNETPLAYER];
DPID m_dpid;
protected:
@ -66,8 +65,6 @@ protected:
NamedGUIDList m_sessions;
NamedGUIDList m_unknown;
BOOL m_bHost;
// NetPlayer m_players[4];
};
static BOOL EnumProvidersCallback(LPGUID lpguidSP, LPSTR lpSTName,