From 7dc47ed8ceadf693d0593ac8a4e2e0e500b222b3 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 26 Apr 2019 01:19:24 +0200 Subject: [PATCH] Clean up multi_player_left_msg --- Source/msg.cpp | 2 +- Source/multi.cpp | 49 +++++++++++++++++++++--------------------------- structs.h | 2 +- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/Source/msg.cpp b/Source/msg.cpp index 19b4f1466..5393609d5 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -2247,7 +2247,7 @@ int On_PLAYER_JOINLEVEL(TCmdLocParam1 *pCmd, int pnum) else { plr[pnum]._pLvlChanging = 0; if (plr[pnum]._pName[0] && !plr[pnum].plractive) { - plr[pnum].plractive = 1; + plr[pnum].plractive = TRUE; gbActivePlayers++; EventPlrMsg("Player '%s' (level %d) just joined the game", plr[pnum]._pName, plr[pnum]._pLevel); } diff --git a/Source/multi.cpp b/Source/multi.cpp index 01f9fa0b5..cbbff43b0 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -295,39 +295,32 @@ void multi_clear_left_tbl() void multi_player_left_msg(int pnum, int left) { - int v2; // edi - int v3; // ebx - int v4; // esi - char *v5; // eax - int v6; // edi - - v2 = pnum; - v3 = left; - v4 = pnum; + char *pszFmt; + if (plr[pnum].plractive) { RemovePlrFromMap(pnum); - RemovePortalMissile(v2); - DeactivatePortal(v2); - RemovePlrPortal(v2); - RemovePlrMissiles(v2); - if (v3) { - v5 = "Player '%s' just left the game"; - v6 = sgdwPlayerLeftReasonTbl[v2] - 0x40000004; - if (v6) { - if (v6 == 2) - v5 = "Player '%s' dropped due to timeout"; - } else { - v5 = "Player '%s' killed Diablo and left the game!"; + RemovePortalMissile(pnum); + DeactivatePortal(pnum); + RemovePlrPortal(pnum); + RemovePlrMissiles(pnum); + if (left) { + pszFmt = "Player '%s' just left the game"; + switch (sgdwPlayerLeftReasonTbl[pnum]) { + case 0x40000004: + pszFmt = "Player '%s' killed Diablo and left the game!"; gbSomebodyWonGameKludge = TRUE; + break; + case 0x40000006: + pszFmt = "Player '%s' dropped due to timeout"; + break; } - EventPlrMsg(v5, plr[v4]._pName); + EventPlrMsg(pszFmt, plr[pnum]._pName); } - plr[v4].plractive = 0; - plr[v4]._pName[0] = 0; - --gbActivePlayers; + plr[pnum].plractive = FALSE; + plr[pnum]._pName[0] = '\0'; + gbActivePlayers--; } } -// 6761B8: using guessed type char gbSomebodyWonGameKludge; void multi_net_ping() { @@ -775,7 +768,7 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram) SetupLocalCoords(); multi_send_pinfo(-2, CMD_SEND_PLRINFO); gbActivePlayers = 1; - plr[myplr].plractive = 1; + plr[myplr].plractive = TRUE; if (sgbPlayerTurnBitTbl[myplr] == 0 || msg_wait_resync()) break; NetClose(); @@ -979,7 +972,7 @@ void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv) return; } - plr[pnum].plractive = 1; + plr[pnum].plractive = TRUE; gbActivePlayers++; if (sgbPlayerTurnBitTbl[pnum] != 0) { diff --git a/structs.h b/structs.h index 9071368d1..b489f3ccb 100644 --- a/structs.h +++ b/structs.h @@ -172,7 +172,7 @@ typedef struct ItemStruct { typedef struct PlayerStruct { int _pmode; char walkpath[25]; - unsigned char plractive; + BOOLEAN plractive; int destAction; int destParam1; int destParam2;