diff --git a/3rdParty/Storm/Source/storm.cpp b/3rdParty/Storm/Source/storm.cpp index 583be190c..180521443 100644 --- a/3rdParty/Storm/Source/storm.cpp +++ b/3rdParty/Storm/Source/storm.cpp @@ -231,8 +231,8 @@ BOOLEAN __stdcall SFileSetBasePath(char *) rBool; void __cdecl SDrawRealizePalette(void) rVoid; BOOL __cdecl SVidPlayContinue(void) rBool; BOOL __stdcall SNetGetOwnerTurnsWaiting(DWORD *) rBool; -void * __stdcall SNetUnregisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)) rPVoid; -void * __stdcall SNetRegisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)) rPVoid; +BOOL __stdcall SNetUnregisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)) rPVoid; +BOOL __stdcall SNetRegisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)) rPVoid; BOOLEAN __stdcall SNetSetBasePlayer(int) rBool; int __stdcall SNetInitializeProvider(unsigned long,struct _SNETPROGRAMDATA *,struct _SNETPLAYERDATA *,struct _SNETUIDATA *,struct _SNETVERSIONDATA *) rInt; int __stdcall SNetGetProviderCaps(struct _SNETCAPS *) rInt; diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h index d765bf160..adb798f82 100644 --- a/3rdParty/Storm/Source/storm.h +++ b/3rdParty/Storm/Source/storm.h @@ -1316,8 +1316,8 @@ BOOLEAN __stdcall SFileSetBasePath(char *); void __cdecl SDrawRealizePalette(void); BOOL __cdecl SVidPlayContinue(void); BOOL __stdcall SNetGetOwnerTurnsWaiting(DWORD *); -void * __stdcall SNetUnregisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)); -void * __stdcall SNetRegisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)); +BOOL __stdcall SNetUnregisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)); +BOOL __stdcall SNetRegisterEventHandler(int,void (__stdcall*)(struct _SNETEVENT *)); BOOLEAN __stdcall SNetSetBasePlayer(int); int __stdcall SNetInitializeProvider(unsigned long,struct _SNETPROGRAMDATA *,struct _SNETPLAYERDATA *,struct _SNETUIDATA *,struct _SNETVERSIONDATA *); int __stdcall SNetGetProviderCaps(struct _SNETCAPS *); diff --git a/Source/multi.cpp b/Source/multi.cpp index 51066cd32..c97f894a8 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -609,35 +609,29 @@ void NetClose() nthread_cleanup(); dthread_cleanup(); tmsg_cleanup(); - multi_event_handler(0); + multi_event_handler(FALSE); SNetLeaveGame(3); msgcmd_cmd_cleanup(); if (gbMaxPlayers > 1) Sleep(2000); } -char multi_event_handler(int a1) -{ - int v1; // edi - void *(__stdcall * v2)(int, void(__stdcall *)(_SNETEVENT *)); // ebx - unsigned int v3; // esi - int v4; // eax - char *v5; // eax - - v1 = a1; - v2 = SNetRegisterEventHandler; - if (!a1) - v2 = SNetUnregisterEventHandler; - v3 = 0; - do { - v4 = (int)v2(event_types[v3], multi_handle_events); - if (!v4 && v1) { - v5 = TraceLastError(); - app_fatal("SNetRegisterEventHandler:\n%s", v5); +void multi_event_handler(BOOL add) +{ + DWORD i; + BOOL(__stdcall * fn) + (int, void(__stdcall *)(_SNETEVENT *)); + + if (add) + fn = SNetRegisterEventHandler; + else + fn = SNetUnregisterEventHandler; + + for (i = 0; i < 3; i++) { + if (!fn(event_types[i], multi_handle_events) && add) { + app_fatal("SNetRegisterEventHandler:\n%s", TraceLastError()); } - ++v3; - } while (v3 < 3); - return v4; + } } void __stdcall multi_handle_events(_SNETEVENT *pEvt) @@ -774,11 +768,6 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram) return TRUE; } -// 6761B8: using guessed type char gbSomebodyWonGameKludge; -// 67862D: using guessed type char gbGameDestroyed; -// 678640: using guessed type char byte_678640; -// 6796E4: using guessed type char gbDeltaSender; -// 6796E8: using guessed type int sgbNetInited; void buffer_init(TBuffer *pBuf) { @@ -877,7 +866,7 @@ BOOL multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, plr[0].pBattleNet = 1; } - multi_event_handler(1); + multi_event_handler(TRUE); if (UiSelectGame(1, client_info, user_info, ui_info, &fileinfo, &playerId)) break; diff --git a/Source/multi.h b/Source/multi.h index 6e9e103e3..26330aa5f 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -43,7 +43,7 @@ void multi_handle_all_packets(int players, TPkt *packet, int a3); void multi_process_tmsgs(); void multi_send_zero_packet(int pnum, char a2, void *pbSrc, int dwLen); void NetClose(); -char multi_event_handler(int a1); +void multi_event_handler(BOOL add); void __stdcall multi_handle_events(_SNETEVENT *pEvt); BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram); void buffer_init(TBuffer *pBuf);