From 87c63ffb345f0408243a348bd4f8225c324c1cb4 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sun, 26 May 2019 21:39:17 -0500 Subject: [PATCH 1/9] DRLG_HoldThemeRooms --- Source/gendung.cpp | 53 +++++++++++----------------------------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/Source/gendung.cpp b/Source/gendung.cpp index fa91f5605..ea85561d3 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -975,48 +975,19 @@ void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, int rnd void DRLG_HoldThemeRooms() { - int *v0; // esi - int v1; // edi - int v2; // edx - int v3; // ebx - int v4; // edi - int v5; // ecx - int v6; // eax - int v7; // [esp+0h] [ebp-Ch] - int v8; // [esp+4h] [ebp-8h] - int v9; // [esp+8h] [ebp-4h] - - if (themeCount > 0) { - v0 = &themeLoc[0].height; - v8 = themeCount; - do { - v1 = *(v0 - 3); - if (v1 < v1 + *v0 - 1) { - v2 = *(v0 - 4); - v3 = 2 * v1 + 16; - v7 = v2 + *(v0 - 1) - 1; - v9 = *v0 - 1; - do { - if (v2 < v7) { - v4 = 224 * (v2 + 8); - v5 = v7 - v2; - do { - v6 = v3 + v4; - v4 += 224; - dFlags[0][v6] |= DFLAG_POPULATED; - dFlags[1][v6] |= DFLAG_POPULATED; - dFlags[0][v6 + 1] |= DFLAG_POPULATED; - dFlags[1][v6 + 1] |= DFLAG_POPULATED; - --v5; - } while (v5); - } - v3 += 2; - --v9; - } while (v9); + int i, x, y, xx, yy; + + for(i = 0; i < themeCount; i++) { + for(y = themeLoc[i].y; y < themeLoc[i].y + themeLoc[i].height - 1; y++) { + for(x = themeLoc[i].x; x < themeLoc[i].x + themeLoc[i].width - 1; x++) { + xx = 2 * x + 16; + yy = 2 * y + 16; + dFlags[xx][yy] |= DFLAG_POPULATED; + dFlags[xx + 1][yy] |= DFLAG_POPULATED; + dFlags[xx][yy + 1] |= DFLAG_POPULATED; + dFlags[xx + 1][yy + 1] |= DFLAG_POPULATED; } - v0 += 5; - --v8; - } while (v8); + } } } From 4c5748a0c5086b561ad547baa72a2df293a94bd3 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Mon, 27 May 2019 08:06:50 +0300 Subject: [PATCH 2/9] Clean up control_press_enter. --- Source/control.cpp | 51 ++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index ae15b8893..98f8041ca 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1,6 +1,6 @@ #include "diablo.h" -char sgbNextTalkSave; // weak +BYTE sgbNextTalkSave; BYTE sgbTalkSavePos; BYTE *pDurIcons; BYTE *pChrButtons; @@ -2573,7 +2573,7 @@ void control_release_talk_btn() } } -void control_reset_talk_msg() +void control_reset_talk_msg(char* msg) { int i, pmask; pmask = 0; @@ -2669,43 +2669,32 @@ BOOL control_presskeys(int vkey) void control_press_enter() { - signed int v0; // esi - char(*v1)[80]; // ebp - char v2; // al - int v3; // ecx - char *v4; // ebp + int i; + BYTE talk_save; if (sgszTalkMsg[0]) { - control_reset_talk_msg(); - v0 = 0; - v1 = sgszTalkSave; - do { - if (!strcmp((const char *)v1, sgszTalkMsg)) + control_reset_talk_msg(sgszTalkMsg); + for (i = 0; i < 8; i++) { + if (!strcmp(sgszTalkSave[i], sgszTalkMsg)) break; - ++v1; - ++v0; - } while ((signed int)v1 < (signed int)&sgszTalkSave[8]); - if (v0 < 8) { - v2 = sgbNextTalkSave; - v3 = (sgbNextTalkSave - 1) & 7; - if (v0 != v3) { - v4 = sgszTalkSave[v3]; - strcpy(sgszTalkSave[v0], sgszTalkSave[v3]); - strcpy(v4, sgszTalkMsg); - v2 = sgbNextTalkSave; - } + } + if (i >= 8) { + strcpy(sgszTalkSave[sgbNextTalkSave], sgszTalkMsg); + sgbNextTalkSave = sgbNextTalkSave + 1; + sgbNextTalkSave &= 7; } else { - strcpy(sgszTalkSave[(unsigned char)sgbNextTalkSave], sgszTalkMsg); - v2 = (sgbNextTalkSave + 1) & 7; - sgbNextTalkSave = (sgbNextTalkSave + 1) & 7; + talk_save = sgbNextTalkSave - 1; + talk_save &= 7; + if (i != talk_save) { + strcpy(sgszTalkSave[i], sgszTalkSave[talk_save]); + strcpy(sgszTalkSave[talk_save], sgszTalkMsg); + } } - sgszTalkMsg[0] = 0; - sgbTalkSavePos = v2; + sgszTalkMsg[0] = '\0'; + sgbTalkSavePos = sgbNextTalkSave; } control_reset_talk(); } -// 4B84CC: using guessed type char sgbNextTalkSave; -// 4B84CD: using guessed type char sgbTalkSavePos; void control_up_down(int v) { From 0d8f206caffed7fe197eb2a9c39165d066a77443 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Sun, 26 May 2019 16:34:15 +0300 Subject: [PATCH 3/9] Fix min diff in MoveMissilePos. --- Source/missiles.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 8fd640df3..487df8029 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -426,7 +426,7 @@ void GetMissilePos(int i) void MoveMissilePos(int i) { - int dx, dy; + int dx, dy, x, y; switch (missile[i]._mimfnum) { case DIR_S: @@ -462,7 +462,9 @@ void MoveMissilePos(int i) dy = 1; break; } - if (PosOkMonst(missile[i]._misource, missile[i]._mix + dx, missile[i]._miy + dy)) { + x = missile[i]._mix + dx; + y = missile[i]._miy + dy; + if (PosOkMonst(missile[i]._misource, x, y)) { missile[i]._mix += dx; missile[i]._miy += dy; missile[i]._mixoff += (dy << 5) - (dx << 5); From 6a68d6b27185b2cc57747f97897e8c8bc9ea992c Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sun, 26 May 2019 22:28:41 -0500 Subject: [PATCH 4/9] DRLG_MRectTrans --- Source/gendung.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/Source/gendung.cpp b/Source/gendung.cpp index ea85561d3..27a9f5e30 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -565,28 +565,20 @@ void DRLG_InitTrans() void DRLG_MRectTrans(int x1, int y1, int x2, int y2) { - int v4; // esi - int v5; // edi - int i; // eax - char *v7; // edx - int j; // ecx - int ty_enda; // [esp+10h] [ebp+8h] - - v4 = 2 * x1 + 17; - v5 = 2 * x2 + 16; - i = 2 * y1 + 17; - for (ty_enda = 2 * y2 + 16; i <= ty_enda; ++i) { - if (v4 <= v5) { - v7 = &dTransVal[v4][i]; - j = v5 - v4 + 1; - do { - *v7 = TransVal; - v7 += 112; - --j; - } while (j); + int i, j; + + x1 = 2 * x1 + 17; + y1 = 2 * y1 + 17; + x2 = 2 * x2 + 16; + y2 = 2 * y2 + 16; + + for(j = y1; j <= y2; j++) { + for(i = x1; i <= x2; i++) { + dTransVal[i][j] = TransVal; } } - ++TransVal; + + TransVal++; } // 5A5590: using guessed type char TransVal; From 66f160a9624e631e041d7f09a2330108d68176a3 Mon Sep 17 00:00:00 2001 From: qndel Date: Wed, 15 May 2019 11:11:36 +0200 Subject: [PATCH 5/9] gmenu_left_mouse bin exact --- Source/diablo.cpp | 4 +-- Source/gmenu.cpp | 83 ++++++++++++++++++++++++++++------------------- Source/gmenu.h | 2 +- 3 files changed, 53 insertions(+), 36 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 068421ce2..e89a1cf85 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -791,7 +791,7 @@ LRESULT CALLBACK GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) BOOL LeftMouseDown(int wParam) { - if (gmenu_left_mouse(1) || control_check_talk_btn() || sgnTimeoutCurs) + if (gmenu_left_mouse(TRUE) || control_check_talk_btn() || sgnTimeoutCurs) return 0; if (deathflag) { control_check_btn_press(); @@ -982,7 +982,7 @@ BOOL TryIconCurs() void LeftMouseUp() { - gmenu_left_mouse(0); + gmenu_left_mouse(FALSE); control_release_talk_btn(); if (panbtndown) CheckBtnUp(); diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 6d4999f6d..d97ad5e9a 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -339,49 +339,66 @@ BOOLEAN gmenu_valid_mouse_pos(int *plOffset) return 1; } -int gmenu_left_mouse(int a1) +BOOL gmenu_left_mouse(BOOL isDown) { - int result; // eax - unsigned int v2; // eax - unsigned int v3; // eax - TMenuItem *v4; // esi - unsigned int v5; // eax - //LPARAM v6; // ecx - int a1a; // [esp+4h] [ebp-4h] - - if (a1) { - if (!sgpCurrentMenu || MouseY >= 352) - return 0; + BOOL result; + TMenuItem *v3; + DWORD v4, v5; + int dummy; + + if (!isDown) { + if (mouseNavigation) { + mouseNavigation = 0; + result = TRUE; + } else { + result = FALSE; + } + + } else { + + if (!sgpCurrentMenu) { + return FALSE; + } + if (MouseY >= 352) { + return FALSE; + } if (MouseY - 117 >= 0) { - v2 = (MouseY - 117) / 45; - if (v2 < sgCurrentMenuIdx) { - v3 = v2; - v4 = &sgpCurrentMenu[v3]; - if ((v4->dwFlags & 0x80000000) != 0) { - v5 = (unsigned int)gmenu_get_lfont(&sgpCurrentMenu[v3]) >> 1; - if (MouseX >= 320 - v5 && MouseX <= v5 + 320) { - sgpCurrItem = v4; - PlaySFX(IS_TITLEMOV); - if (v4->dwFlags & 0x40000000) { - mouseNavigation = gmenu_valid_mouse_pos(&a1a); - gmenu_on_mouse_move(); + v4 = (MouseY - 117) / 45; + //v4 /= 45; + if (v4 < sgCurrentMenuIdx) { + v3 = &sgpCurrentMenu[v4]; + if ((sgpCurrentMenu[v4].dwFlags & 0x80000000) != 0) { + v5 = gmenu_get_lfont(v3); + if (MouseX >= 320 - (v5 >> 1)) { + if (MouseX <= (v5 >> 1) + 320) { + sgpCurrItem = v3; + PlaySFX(IS_TITLEMOV); + if (v3->dwFlags & 0x40000000) { + mouseNavigation = gmenu_valid_mouse_pos(&dummy); + gmenu_on_mouse_move(); + } else { + sgpCurrItem->fnMenu(TRUE); + } + result = TRUE; } else { - sgpCurrItem->fnMenu(TRUE); + result = TRUE; } + } else { + result = TRUE; } + } else { + result = TRUE; } + } else { + result = TRUE; } + } else { + result = TRUE; } - } else { - result = 0; - if (!mouseNavigation) - return result; - mouseNavigation = 0; } - return 1; + return result; } -// 634464: using guessed type char mouseNavigation; -// 63448C: using guessed type int sgCurrentMenuIdx; + void gmenu_enable(TMenuItem *pMenuItem, BOOL enable) { diff --git a/Source/gmenu.h b/Source/gmenu.h index 5d960ee07..8c2be2277 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -28,7 +28,7 @@ BOOL gmenu_presskeys(int a1); void gmenu_left_right(BOOL isRight); BOOL gmenu_on_mouse_move(); BOOLEAN gmenu_valid_mouse_pos(int *plOffset); -int gmenu_left_mouse(int a1); +BOOL gmenu_left_mouse(BOOL isDown); void gmenu_enable(TMenuItem *pMenuItem, BOOL enable); void gmenu_slider_set(TMenuItem *pItem, int min, int max, int gamma); int gmenu_slider_get(TMenuItem *pItem, int min, int max); From 565bb5aa7d0b4972d14c1aeff3b4e2adb96911e6 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 29 May 2019 17:21:35 +0200 Subject: [PATCH 6/9] Adust dFlag enums --- Source/automap.cpp | 2 +- Source/cursor.cpp | 32 +++++++++++++++---------------- Source/debug.cpp | 4 ++-- Source/diablo.cpp | 4 ++-- Source/drlg_l2.cpp | 4 ++-- Source/gendung.cpp | 8 ++++---- Source/items.cpp | 2 +- Source/lighting.cpp | 14 +++++++------- Source/loadsave.cpp | 4 ++-- Source/missiles.cpp | 8 ++++---- Source/monster.cpp | 46 ++++++++++++++++++++++----------------------- Source/msg.cpp | 2 +- Source/multi.cpp | 2 +- Source/objects.cpp | 6 +++--- Source/player.cpp | 20 ++++++++++---------- Source/portal.cpp | 2 +- Source/scrollrt.cpp | 44 +++++++++++++++++++++---------------------- Source/themes.cpp | 4 ++-- Source/town.cpp | 24 +++++++++++------------ Source/trigs.cpp | 2 +- enums.h | 16 ++++++++-------- 21 files changed, 125 insertions(+), 125 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index c351b1be2..f20077062 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -102,7 +102,7 @@ void InitAutomap() for (y = 0; y < MAXDUNY; y++) { for (x = 0; x < MAXDUNX; x++) - dFlags[x][y] &= ~DFLAG_EXPLORED; + dFlags[x][y] &= ~BFLAG_EXPLORED; } } diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 80b2044ea..dc8095d6a 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -291,7 +291,7 @@ void CheckCursMove() if(leveltype != DTYPE_TOWN) { if(pcurstemp != -1) { - if(!flipflag && dMonster[mx + 2][my + 1] != 0 && dFlags[mx + 2][my + 1] & DFLAG_LIT) { + if(!flipflag && dMonster[mx + 2][my + 1] != 0 && dFlags[mx + 2][my + 1] & BFLAG_LIT) { mi = dMonster[mx + 2][my + 1] > 0 ? dMonster[mx + 2][my + 1] - 1 : -(dMonster[mx + 2][my + 1] + 1); if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { cursmx = mx + 1; /// BUGFIX: 'mx + 2' @@ -299,7 +299,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(flipflag && dMonster[mx + 1][my + 2] != 0 && dFlags[mx + 1][my + 2] & DFLAG_LIT) { + if(flipflag && dMonster[mx + 1][my + 2] != 0 && dFlags[mx + 1][my + 2] & BFLAG_LIT) { mi = dMonster[mx + 1][my + 2] > 0 ? dMonster[mx + 1][my + 2] - 1 : -(dMonster[mx + 1][my + 2] + 1); if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { cursmx = mx + 1; @@ -307,7 +307,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(dMonster[mx + 2][my + 2] != 0 && dFlags[mx + 2][my + 2] & DFLAG_LIT) { + if(dMonster[mx + 2][my + 2] != 0 && dFlags[mx + 2][my + 2] & BFLAG_LIT) { mi = dMonster[mx + 2][my + 2] > 0 ? dMonster[mx + 2][my + 2] - 1 : -(dMonster[mx + 2][my + 2] + 1); if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { cursmx = mx + 2; @@ -315,7 +315,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(!flipflag && dMonster[mx + 1][my] != 0 && dFlags[mx + 1][my] & DFLAG_LIT) { + if(!flipflag && dMonster[mx + 1][my] != 0 && dFlags[mx + 1][my] & BFLAG_LIT) { mi = dMonster[mx + 1][my] > 0 ? dMonster[mx + 1][my] - 1 : -(dMonster[mx + 1][my] + 1); if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { cursmx = mx + 1; @@ -323,7 +323,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(flipflag && dMonster[mx][my + 1] != 0 && dFlags[mx][my + 1] & DFLAG_LIT) { + if(flipflag && dMonster[mx][my + 1] != 0 && dFlags[mx][my + 1] & BFLAG_LIT) { mi = dMonster[mx][my + 1] > 0 ? dMonster[mx][my + 1] - 1 : -(dMonster[mx][my + 1] + 1); if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { cursmx = mx; @@ -331,7 +331,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(dMonster[mx][my] != 0 && dFlags[mx][my] & DFLAG_LIT) { + if(dMonster[mx][my] != 0 && dFlags[mx][my] & BFLAG_LIT) { mi = dMonster[mx][my] > 0 ? dMonster[mx][my] - 1 : -(dMonster[mx][my] + 1); if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 1) { cursmx = mx; @@ -339,7 +339,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(dMonster[mx + 1][my + 1] != 0 && dFlags[mx + 1][my + 1] & DFLAG_LIT) { + if(dMonster[mx + 1][my + 1] != 0 && dFlags[mx + 1][my + 1] & BFLAG_LIT) { mi = dMonster[mx + 1][my + 1] > 0 ? dMonster[mx + 1][my + 1] - 1 : -(dMonster[mx + 1][my + 1] + 1); if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { cursmx = mx + 1; @@ -359,7 +359,7 @@ void CheckCursMove() return; } } - if(!flipflag && dMonster[mx + 2][my + 1] != 0 && dFlags[mx + 2][my + 1] & DFLAG_LIT) { + if(!flipflag && dMonster[mx + 2][my + 1] != 0 && dFlags[mx + 2][my + 1] & BFLAG_LIT) { mi = dMonster[mx + 2][my + 1] > 0 ? dMonster[mx + 2][my + 1] - 1 : -(dMonster[mx + 2][my + 1] + 1); if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { cursmx = mx + 2; @@ -367,7 +367,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(flipflag && dMonster[mx + 1][my + 2] != 0 && dFlags[mx + 1][my + 2] & DFLAG_LIT) { + if(flipflag && dMonster[mx + 1][my + 2] != 0 && dFlags[mx + 1][my + 2] & BFLAG_LIT) { mi = dMonster[mx + 1][my + 2] > 0 ? dMonster[mx + 1][my + 2] - 1 : -(dMonster[mx + 1][my + 2] + 1); if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { cursmx = mx + 1; @@ -375,7 +375,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(dMonster[mx + 2][my + 2] != 0 && dFlags[mx + 2][my + 2] & DFLAG_LIT) { + if(dMonster[mx + 2][my + 2] != 0 && dFlags[mx + 2][my + 2] & BFLAG_LIT) { mi = dMonster[mx + 2][my + 2] > 0 ? dMonster[mx + 2][my + 2] - 1 : -(dMonster[mx + 2][my + 2] + 1); if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { cursmx = mx + 2; @@ -383,7 +383,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(!flipflag && dMonster[mx + 1][my] != 0 && dFlags[mx + 1][my] & DFLAG_LIT) { + if(!flipflag && dMonster[mx + 1][my] != 0 && dFlags[mx + 1][my] & BFLAG_LIT) { mi = dMonster[mx + 1][my] > 0 ? dMonster[mx + 1][my] - 1 : -(dMonster[mx + 1][my] + 1); if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { cursmx = mx + 1; @@ -391,7 +391,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(flipflag && dMonster[mx][my + 1] != 0 && dFlags[mx][my + 1] & DFLAG_LIT) { + if(flipflag && dMonster[mx][my + 1] != 0 && dFlags[mx][my + 1] & BFLAG_LIT) { mi = dMonster[mx][my + 1] > 0 ? dMonster[mx][my + 1] - 1 : -(dMonster[mx][my + 1] + 1); if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { cursmx = mx; @@ -399,7 +399,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(dMonster[mx][my] != 0 && dFlags[mx][my] & DFLAG_LIT) { + if(dMonster[mx][my] != 0 && dFlags[mx][my] & BFLAG_LIT) { mi = dMonster[mx][my] > 0 ? dMonster[mx][my] - 1 : -(dMonster[mx][my] + 1); if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 1) { cursmx = mx; @@ -407,7 +407,7 @@ void CheckCursMove() pcursmonst = mi; } } - if(dMonster[mx + 1][my + 1] != 0 && dFlags[mx + 1][my + 1] & DFLAG_LIT) { + if(dMonster[mx + 1][my + 1] != 0 && dFlags[mx + 1][my + 1] & BFLAG_LIT) { mi = dMonster[mx + 1][my + 1] > 0 ? dMonster[mx + 1][my + 1] - 1 : -(dMonster[mx + 1][my + 1] + 1); if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { cursmx = mx + 1; @@ -474,7 +474,7 @@ void CheckCursMove() pcursplr = bv; } } - if(dFlags[mx][my] & DFLAG_DEAD_PLAYER) { + if(dFlags[mx][my] & BFLAG_DEAD_PLAYER) { for(i = 0; i < MAX_PLRS; i++) { if(plr[i].WorldX == mx && plr[i].WorldY == my && i != myplr) { cursmx = mx; @@ -486,7 +486,7 @@ void CheckCursMove() if(pcurs == CURSOR_RESURRECT) { for(xx = -1; xx < 2; xx++) { for(yy = -1; yy < 2; yy++) { - if(dFlags[mx + xx][my + yy] & DFLAG_DEAD_PLAYER) { + if(dFlags[mx + xx][my + yy] & BFLAG_DEAD_PLAYER) { for(i = 0; i < MAX_PLRS; i++) { if(plr[i].WorldX == mx + xx && plr[i].WorldY == my + yy && i != myplr) { cursmx = mx + xx; diff --git a/Source/debug.cpp b/Source/debug.cpp index 770e8ba40..0a500b777 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -86,8 +86,8 @@ void CheckDungeonClear() if (dPlayer[i][j]) app_fatal("Players not cleared"); - dMonsDbg[currlevel][i][j] = dFlags[i][j] & DFLAG_VISIBLE; - dFlagDbg[currlevel][i][j] = dFlags[i][j] & DFLAG_POPULATED; + dMonsDbg[currlevel][i][j] = dFlags[i][j] & BFLAG_VISIBLE; + dFlagDbg[currlevel][i][j] = dFlags[i][j] & BFLAG_POPULATED; } } } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index e89a1cf85..7246cc321 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1770,7 +1770,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir) } else { for (i = 0; i < MAXDUNX; i++) { for (j = 0; j < MAXDUNY; j++) - dFlags[i][j] |= DFLAG_LIT; + dFlags[i][j] |= BFLAG_LIT; } InitTowners(); @@ -1836,7 +1836,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir) else SyncInitPlrPos(i); } else { - dFlags[plr[i].WorldX][plr[i].WorldY] |= DFLAG_DEAD_PLAYER; + dFlags[plr[i].WorldX][plr[i].WorldY] |= BFLAG_DEAD_PLAYER; } } } diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index fb5b37d32..97a5ea7ee 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -353,7 +353,7 @@ void LoadL2Dungeon(char *sFileName, int vx, int vy) for (i = 0; i < rw; i++) { if (*lm != 0) { dungeon[i][j] = *lm; - dflags[i][j] |= DFLAG_EXPLORED; + dflags[i][j] |= 0x80; } else { dungeon[i][j] = 3; } @@ -528,7 +528,7 @@ void LoadPreL2Dungeon(char *sFileName, int vx, int vy) for (i = 0; i < rw; i++) { if (*lm != 0) { dungeon[i][j] = *lm; - dflags[i][j] |= DFLAG_EXPLORED; + dflags[i][j] |= 0x80; } else { dungeon[i][j] = 3; } diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 27a9f5e30..6675303ae 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -974,10 +974,10 @@ void DRLG_HoldThemeRooms() for(x = themeLoc[i].x; x < themeLoc[i].x + themeLoc[i].width - 1; x++) { xx = 2 * x + 16; yy = 2 * y + 16; - dFlags[xx][yy] |= DFLAG_POPULATED; - dFlags[xx + 1][yy] |= DFLAG_POPULATED; - dFlags[xx][yy + 1] |= DFLAG_POPULATED; - dFlags[xx + 1][yy + 1] |= DFLAG_POPULATED; + dFlags[xx][yy] |= BFLAG_POPULATED; + dFlags[xx + 1][yy] |= BFLAG_POPULATED; + dFlags[xx][yy + 1] |= BFLAG_POPULATED; + dFlags[xx + 1][yy + 1] |= BFLAG_POPULATED; } } } diff --git a/Source/items.cpp b/Source/items.cpp index 12bdb9ba7..37f371eb4 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -206,7 +206,7 @@ BOOL ItemPlace(int xp, int yp) return FALSE; if (dObject[xp][yp]) return FALSE; - if (dFlags[xp][yp] & DFLAG_POPULATED) + if (dFlags[xp][yp] & BFLAG_POPULATED) return FALSE; if (nSolidTable[dPiece[xp][yp]]) return FALSE; diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 95a1956ef..832ec3ddd 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -656,7 +656,7 @@ void DoUnVision(int nXPos, int nYPos, int nRadius) for (i = x1; i < x2; i++) { for (j = y1; j < y2; j++) { - dFlags[i][j] &= ~(DFLAG_VISIBLE | DFLAG_LIT); + dFlags[i][j] &= ~(BFLAG_VISIBLE | BFLAG_LIT); } } } @@ -671,12 +671,12 @@ void DoVision(int nXPos, int nYPos, int nRadius, BOOL doautomap, BOOL visible) if (dFlags[nXPos][nYPos] >= 0) { SetAutomapView(nXPos, nXPos); } - dFlags[nXPos][nYPos] |= DFLAG_EXPLORED; + dFlags[nXPos][nYPos] |= BFLAG_EXPLORED; } if (visible) { - dFlags[nXPos][nYPos] |= DFLAG_LIT; + dFlags[nXPos][nYPos] |= BFLAG_LIT; } - dFlags[nXPos][nYPos] |= DFLAG_VISIBLE; + dFlags[nXPos][nYPos] |= BFLAG_VISIBLE; } for (v = 0; v < 4; v++) { @@ -730,12 +730,12 @@ void DoVision(int nXPos, int nYPos, int nRadius, BOOL doautomap, BOOL visible) if (dFlags[nCrawlX][nCrawlY] >= 0) { SetAutomapView(nCrawlX, nCrawlY); } - dFlags[nCrawlX][nCrawlY] |= DFLAG_EXPLORED; + dFlags[nCrawlX][nCrawlY] |= BFLAG_EXPLORED; } if (visible) { - dFlags[nCrawlX][nCrawlY] |= DFLAG_LIT; + dFlags[nCrawlX][nCrawlY] |= BFLAG_LIT; } - dFlags[nCrawlX][nCrawlY] |= DFLAG_VISIBLE; + dFlags[nCrawlX][nCrawlY] |= BFLAG_VISIBLE; if (!nBlockerFlag) { nTrans = dTransVal[nCrawlX][nCrawlY]; if (nTrans != 0) { diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 1f1cb2309..48fdf847d 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -356,7 +356,7 @@ void SaveGame() } for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) - BSave(dFlags[i][j] & ~(DFLAG_MISSILE | DFLAG_VISIBLE | DFLAG_DEAD_PLAYER)); + BSave(dFlags[i][j] & ~(BFLAG_MISSILE | BFLAG_VISIBLE | BFLAG_DEAD_PLAYER)); } for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) @@ -556,7 +556,7 @@ void SaveLevel() for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) - BSave(dFlags[i][j] & ~(DFLAG_MISSILE | DFLAG_VISIBLE | DFLAG_DEAD_PLAYER)); + BSave(dFlags[i][j] & ~(BFLAG_MISSILE | BFLAG_VISIBLE | BFLAG_DEAD_PLAYER)); } for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 487df8029..67e9b7df1 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -384,7 +384,7 @@ void PutMissile(int i) if (x <= 0 || y <= 0 || x >= MAXDUNX || y >= MAXDUNY) missile[i]._miDelFlag = TRUE; if (!missile[i]._miDelFlag) { - dFlags[x][y] |= DFLAG_MISSILE; + dFlags[x][y] |= BFLAG_MISSILE; if (dMissile[x][y] == 0) dMissile[x][y] = i + 1; else @@ -1203,7 +1203,7 @@ void InitMissiles() } for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { - dFlags[i][j] &= ~DFLAG_MISSILE; + dFlags[i][j] &= ~BFLAG_MISSILE; } } } @@ -4065,7 +4065,7 @@ void ProcessMissiles() int i, mi; for (i = 0; i < nummissiles; i++) { - dFlags[missile[missileactive[i]]._mix][missile[missileactive[i]]._miy] &= ~DFLAG_MISSILE; + dFlags[missile[missileactive[i]]._mix][missile[missileactive[i]]._miy] &= ~BFLAG_MISSILE; dMissile[missile[missileactive[i]]._mix][missile[missileactive[i]]._miy] = 0; } @@ -4146,6 +4146,6 @@ void missiles_process_charge() void ClearMissileSpot(int mi) { - dFlags[missile[mi]._mix][missile[mi]._miy] &= ~DFLAG_MISSILE; + dFlags[missile[mi]._mix][missile[mi]._miy] &= ~BFLAG_MISSILE; dMissile[missile[mi]._mix][missile[mi]._miy] = 0; } diff --git a/Source/monster.cpp b/Source/monster.cpp index 39bb198fa..10e3b70c3 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -532,11 +532,11 @@ BOOL MonstPlace(int xp, int yp) f = dFlags[xp][yp]; - if (f & DFLAG_VISIBLE) { + if (f & BFLAG_VISIBLE) { return FALSE; } - if (f & DFLAG_POPULATED) { + if (f & BFLAG_POPULATED) { return FALSE; } @@ -1344,7 +1344,7 @@ void M_StartWalk3(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int y dMonster[fx][fy] = -(i + 1); monster[i]._mVar4 = x; monster[i]._mVar5 = y; - dFlags[x][y] |= DFLAG_MONSTER; + dFlags[x][y] |= BFLAG_MONSTLR; monster[i]._moldx = monster[i]._mx; monster[i]._moldy = monster[i]._my; monster[i]._mfutx = fx; @@ -1462,9 +1462,9 @@ void M_ClearSquares(int i) } if (mx + 1 < MAXDUNX) - dFlags[mx + 1][my] &= ~DFLAG_MONSTER; + dFlags[mx + 1][my] &= ~BFLAG_MONSTLR; if (my + 1 < MAXDUNY) - dFlags[mx][my + 1] &= ~DFLAG_MONSTER; + dFlags[mx][my + 1] &= ~BFLAG_MONSTLR; } void M_GetKnockback(int i) @@ -1965,7 +1965,7 @@ BOOL M_DoWalk3(int i) dMonster[monster[i]._mx][monster[i]._my] = 0; monster[i]._mx = monster[i]._mVar1; monster[i]._my = monster[i]._mVar2; - dFlags[monster[i]._mVar4][monster[i]._mVar5] &= ~DFLAG_MONSTER; + dFlags[monster[i]._mVar4][monster[i]._mVar5] &= ~BFLAG_MONSTLR; dMonster[monster[i]._mx][monster[i]._my] = i + 1; if (monster[i]._uniqtype) ChangeLightXY(monster[i].mlid, monster[i]._mx, monster[i]._my); @@ -2901,7 +2901,7 @@ void MAI_Zombie(int i) mx = Monst->_mx; my = Monst->_my; - if (!(dFlags[mx][my] & DFLAG_VISIBLE)) { + if (!(dFlags[mx][my] & BFLAG_VISIBLE)) { return; } @@ -4188,13 +4188,13 @@ void MAI_Garbud(int i) if (Monst->mtalkmsg < QUEST_GARBUD4 && Monst->mtalkmsg > QUEST_DOOM10 - && !(dFlags[_mx][_my] & DFLAG_VISIBLE) + && !(dFlags[_mx][_my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { Monst->_mgoal = MGOAL_INQUIRING; Monst->mtalkmsg++; } - if (dFlags[_mx][_my] & DFLAG_VISIBLE) { + if (dFlags[_mx][_my] & BFLAG_VISIBLE) { if (Monst->mtalkmsg == QUEST_GARBUD4) { if (!effect_is_playing(USFX_GARBUD4) && Monst->_mgoal == MGOAL_TALKING) { Monst->_mgoal = MGOAL_NORMAL; @@ -4229,12 +4229,12 @@ void MAI_Zhar(int i) my = Monst->_my; mx = Monst->_mx; md = M_GetDir(i); - if (Monst->mtalkmsg == QUEST_ZHAR1 && !(dFlags[mx][my] & DFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { + if (Monst->mtalkmsg == QUEST_ZHAR1 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { Monst->mtalkmsg = QUEST_ZHAR2; Monst->_mgoal = MGOAL_INQUIRING; } - if (dFlags[mx][my] & DFLAG_VISIBLE) { + if (dFlags[mx][my] & BFLAG_VISIBLE) { _mx = Monst->_mx - Monst->_menemyx; _my = Monst->_my - Monst->_menemyy; if (abs(_mx) > abs(_my)) @@ -4276,7 +4276,7 @@ void MAI_SnotSpil(int i) my = Monst->_my; md = M_GetDir(i); - if (Monst->mtalkmsg == QUEST_BANNER10 && !(dFlags[mx][my] & DFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { + if (Monst->mtalkmsg == QUEST_BANNER10 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { Monst->mtalkmsg = QUEST_BANNER11; Monst->_mgoal = MGOAL_INQUIRING; } @@ -4286,7 +4286,7 @@ void MAI_SnotSpil(int i) Monst->_mgoal = MGOAL_NORMAL; } - if (dFlags[mx][my] & DFLAG_VISIBLE) { + if (dFlags[mx][my] & BFLAG_VISIBLE) { if (Monst->mtalkmsg == QUEST_BANNER12) { if (!effect_is_playing(USFX_SNOT3) && Monst->_mgoal == MGOAL_TALKING) { ObjChangeMap(setpc_x, setpc_y, setpc_x + setpc_w + 1, setpc_y + setpc_h + 1); @@ -4325,7 +4325,7 @@ void MAI_Lazurus(int i) mx = Monst->_mx; my = Monst->_my; md = M_GetDir(i); - if (dFlags[mx][my] & DFLAG_VISIBLE) { + if (dFlags[mx][my] & BFLAG_VISIBLE) { if (gbMaxPlayers == 1) { if (Monst->mtalkmsg == QUEST_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && plr[myplr].WorldX == QUEST_VILE13 && plr[myplr].WorldY == 46) { PlayInGameMovie("gendata\\fprst3.smk"); @@ -4375,7 +4375,7 @@ void MAI_Lazhelp(int i) _my = Monst->_my; md = M_GetDir(i); - if (dFlags[_mx][_my] & DFLAG_VISIBLE) { + if (dFlags[_mx][_my] & BFLAG_VISIBLE) { if (gbMaxPlayers == 1) { if (quests[QTYPE_VB]._qvar1 <= 5) { Monst->_mgoal = MGOAL_INQUIRING; @@ -4409,12 +4409,12 @@ void MAI_Lachdanan(int i) _mx = Monst->_mx; _my = Monst->_my; md = M_GetDir(i); - if (Monst->mtalkmsg == QUEST_VEIL9 && !(dFlags[_mx][_my] & DFLAG_VISIBLE) && monster[i]._mgoal == MGOAL_TALKING) { + if (Monst->mtalkmsg == QUEST_VEIL9 && !(dFlags[_mx][_my] & BFLAG_VISIBLE) && monster[i]._mgoal == MGOAL_TALKING) { Monst->mtalkmsg = QUEST_VEIL10; monster[i]._mgoal = MGOAL_INQUIRING; } - if (dFlags[_mx][_my] & DFLAG_VISIBLE) { + if (dFlags[_mx][_my] & BFLAG_VISIBLE) { if (Monst->mtalkmsg == QUEST_VEIL11) { if (!effect_is_playing(USFX_LACH3) && Monst->_mgoal == MGOAL_TALKING) { Monst->mtalkmsg = 0; @@ -4446,7 +4446,7 @@ void MAI_Warlord(int i) mx = Monst->_mx; my = Monst->_my; md = M_GetDir(i); - if (dFlags[mx][my] & DFLAG_VISIBLE) { + if (dFlags[mx][my] & BFLAG_VISIBLE) { if (Monst->mtalkmsg == QUEST_WARLRD9 && Monst->_mgoal == MGOAL_INQUIRING) Monst->_mmode = MM_TALK; if (Monst->mtalkmsg == QUEST_WARLRD9 && !effect_is_playing(USFX_WARLRD1) && Monst->_mgoal == MGOAL_TALKING) { @@ -4517,7 +4517,7 @@ void ProcessMonsters() } mx = Monst->_mx; my = Monst->_my; - if(dFlags[mx][my] & DFLAG_VISIBLE && Monst->_msquelch == 0 && Monst->MType->mtype == MT_CLEAVER) { + if(dFlags[mx][my] & BFLAG_VISIBLE && Monst->_msquelch == 0 && Monst->MType->mtype == MT_CLEAVER) { PlaySFX(USFX_CLEAVER); } if(Monst->_mFlags & MFLAG_TARGETS_MONSTER) { @@ -4536,7 +4536,7 @@ void ProcessMonsters() } Monst->_menemyx = plr[Monst->_menemy]._px; Monst->_menemyy = plr[Monst->_menemy]._py; - if(dFlags[mx][my] & DFLAG_VISIBLE) { + if(dFlags[mx][my] & BFLAG_VISIBLE) { Monst->_msquelch = 255; Monst->_lastx = plr[Monst->_menemy]._px; Monst->_lasty = plr[Monst->_menemy]._py; @@ -4662,11 +4662,11 @@ BOOL DirOK(int i, int mdir) if (fy < 0 || fy >= MAXDUNY || fx < 0 || fx >= MAXDUNX || !PosOkMonst(i, fx, fy)) return FALSE; if (mdir == DIR_E) { - if (SolidLoc(fx, fy + 1) || dFlags[fx][fy + 1] & DFLAG_MONSTER) + if (SolidLoc(fx, fy + 1) || dFlags[fx][fy + 1] & BFLAG_MONSTLR) return FALSE; } if (mdir == DIR_W) { - if (SolidLoc(fx + 1, fy) || dFlags[fx + 1][fy] & DFLAG_MONSTER) + if (SolidLoc(fx + 1, fy) || dFlags[fx + 1][fy] & BFLAG_MONSTLR) return FALSE; } if (mdir == DIR_N) { @@ -4706,7 +4706,7 @@ BOOL DirOK(int i, int mdir) BOOL PosOkMissile(int x, int y) { - return !nMissileTable[dPiece[x][y]] && !(dFlags[x][y] & DFLAG_MONSTER); + return !nMissileTable[dPiece[x][y]] && !(dFlags[x][y] & BFLAG_MONSTLR); } BOOL CheckNoSolid(int x, int y) diff --git a/Source/msg.cpp b/Source/msg.cpp index e40393b6f..0fd20006f 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -2277,7 +2277,7 @@ int On_PLAYER_JOINLEVEL(TCmdLocParam1 *pCmd, int pnum) NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth); plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1; plr[pnum]._pVar8 = plr[pnum]._pAnimLen << 1; - dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; + dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= BFLAG_DEAD_PLAYER; } plr[pnum]._pvid = AddVision(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad, pnum == myplr); diff --git a/Source/multi.cpp b/Source/multi.cpp index e870b4d4d..f9b29a81d 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -955,7 +955,7 @@ void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv) NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth); plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1; plr[pnum]._pVar8 = 2 * plr[pnum]._pAnimLen; - dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; + dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= BFLAG_DEAD_PLAYER; } } #ifdef _DEBUG diff --git a/Source/objects.cpp b/Source/objects.cpp index 15b92f6ba..f1952cb11 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -130,7 +130,7 @@ BOOL RndLocOk(int xp, int yp) return FALSE; if (dObject[xp][yp]) return FALSE; - if (dFlags[xp][yp] & DFLAG_POPULATED) + if (dFlags[xp][yp] & BFLAG_POPULATED) return FALSE; if (nSolidTable[dPiece[xp][yp]]) return FALSE; @@ -419,7 +419,7 @@ void AddL3Objs(int x1, int y1, int x2, int y2) BOOL WallTrapLocOk(int xp, int yp) { - if (dFlags[xp][yp] & DFLAG_POPULATED) + if (dFlags[xp][yp] & BFLAG_POPULATED) return FALSE; return TRUE; } @@ -451,7 +451,7 @@ void AddL2Torches() BOOL TorchLocOK(int xp, int yp) { - if (dFlags[xp][yp] & DFLAG_POPULATED) + if (dFlags[xp][yp] & BFLAG_POPULATED) return FALSE; return nTrapTable[dPiece[xp][yp]] != FALSE; diff --git a/Source/player.cpp b/Source/player.cpp index 8e6f0aa14..eb6e7d9bd 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -998,11 +998,11 @@ BOOL PlrDirOK(int pnum, int dir) isOk = TRUE; if (dir == DIR_E) { - isOk = !SolidLoc(px, py + 1) && !(dFlags[px][py + 1] & DFLAG_PLAYER); + isOk = !SolidLoc(px, py + 1) && !(dFlags[px][py + 1] & BFLAG_PLAYERLR); } if (isOk && dir == DIR_W) { - isOk = !SolidLoc(px + 1, py) && !(dFlags[px + 1][py] & DFLAG_PLAYER); + isOk = !SolidLoc(px + 1, py) && !(dFlags[px + 1][py] & BFLAG_PLAYERLR); } return isOk; @@ -1364,7 +1364,7 @@ void StartWalk3(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int dPlayer[px][py] = -1 - pnum; plr[pnum]._pVar4 = x; plr[pnum]._pVar5 = y; - dFlags[x][y] |= DFLAG_PLAYER; + dFlags[x][y] |= BFLAG_PLAYERLR; plr[pnum]._pxoff = xoff; plr[pnum]._pyoff = yoff; @@ -1544,8 +1544,8 @@ void FixPlrWalkTags(int pnum) } if (dx >= 0 && dx < MAXDUNX - 1 && dy >= 0 && dy < MAXDUNY - 1) { - dFlags[dx + 1][dy] &= ~DFLAG_PLAYER; - dFlags[dx][dy + 1] &= ~DFLAG_PLAYER; + dFlags[dx + 1][dy] &= ~BFLAG_PLAYERLR; + dFlags[dx][dy + 1] &= ~BFLAG_PLAYERLR; } } @@ -1560,8 +1560,8 @@ void RemovePlrFromMap(int pnum) for (y = 1; y < MAXDUNY; y++) for (x = 1; x < MAXDUNX; x++) if (dPlayer[x][y - 1] == pn || dPlayer[x - 1][y] == pn) - if (dFlags[x][y] & DFLAG_PLAYER) - dFlags[x][y] &= ~DFLAG_PLAYER; + if (dFlags[x][y] & BFLAG_PLAYERLR) + dFlags[x][y] &= ~BFLAG_PLAYERLR; for (y = 0; y < MAXDUNY; y++) for (x = 0; x < MAXDUNX; x++) @@ -1692,7 +1692,7 @@ void StartPlayerKill(int pnum, int earflag) if (plr[pnum].plrlevel == currlevel) { FixPlayerLocation(pnum, plr[pnum]._pdir); RemovePlrFromMap(pnum); - dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; + dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= BFLAG_DEAD_PLAYER; SetPlayerOld(pnum); if (pnum == myplr) { @@ -2182,7 +2182,7 @@ BOOL PM_DoWalk3(int pnum) if (plr[pnum]._pVar8 == vel) { dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = 0; - dFlags[plr[pnum]._pVar4][plr[pnum]._pVar5] &= ~DFLAG_PLAYER; + dFlags[plr[pnum]._pVar4][plr[pnum]._pVar5] &= ~BFLAG_PLAYERLR; plr[pnum].WorldX = plr[pnum]._pVar1; plr[pnum].WorldY = plr[pnum]._pVar2; dPlayer[plr[pnum]._pVar1][plr[pnum]._pVar2] = pnum + 1; @@ -2933,7 +2933,7 @@ BOOL PM_DoDeath(int pnum) plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen; plr[pnum]._pAnimDelay = 10000; - dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; + dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= BFLAG_DEAD_PLAYER; } if (plr[pnum]._pVar8 < 100) { diff --git a/Source/portal.cpp b/Source/portal.cpp index f89333c80..620b229f9 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -102,7 +102,7 @@ void RemovePortalMissile(int id) for (i = 0; i < nummissiles; i++) { mi = missileactive[i]; if (missile[mi]._mitype == MIS_TOWN && missile[mi]._misource == id) { - dFlags[missile[mi]._mix][missile[mi]._miy] &= ~DFLAG_MISSILE; + dFlags[missile[mi]._mix][missile[mi]._miy] &= ~BFLAG_MISSILE; dMissile[missile[mi]._mix][missile[mi]._miy] = 0; if (portal[id].level) diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index d4c5e71fb..80d886657 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -200,7 +200,7 @@ void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL else DrawPlrProc = DrawPlayer; - dFlags[x][y] &= ~DFLAG_DEAD_PLAYER; + dFlags[x][y] &= ~BFLAG_DEAD_PLAYER; for (i = 0; i < MAX_PLRS; i++) { p = &plr[i]; @@ -216,7 +216,7 @@ void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL // app_fatal("Drawing dead player %d \"%s\": facing %d, frame %d of %d", i, p->_pName, p->_pdir, nCel, pFrameTable[0]); break; } - dFlags[x][y] |= DFLAG_DEAD_PLAYER; + dFlags[x][y] |= BFLAG_DEAD_PLAYER; px = sx + p->_pxoff - p->_pAnimWidth2; py = sy + p->_pyoff; DrawPlrProc(i, x, y, px, py, p->_pAnimData, p->_pAnimFrame, p->_pAnimWidth, CelSkip, CelCap); @@ -229,7 +229,7 @@ void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel int l; DWORD *pFrameTable; - if (dFlags[x][y] & DFLAG_LIT || plr[myplr]._pInfraFlag || !setlevel && !currlevel) { + if (dFlags[x][y] & BFLAG_LIT || plr[myplr]._pInfraFlag || !setlevel && !currlevel) { if (!pCelBuff) { // app_fatal("Drawing player %d \"%s\": NULL Cel Buffer", pnum, plr[pnum]._pName); return; @@ -264,7 +264,7 @@ void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, int nCel misfiledata[MFILE_MANASHLD].mAnimWidth[0], CelSkip, CelCap); - } else if (!(dFlags[x][y] & DFLAG_LIT) || plr[myplr]._pInfraFlag && light_table_index > 8) { + } else if (!(dFlags[x][y] & BFLAG_LIT) || plr[myplr]._pInfraFlag && light_table_index > 8) { Cl2DecodeFrm3(px, py, pCelBuff, nCel, nWidth, CelSkip, CelCap, 1); if (plr[pnum].pManaShield) Cl2DecodeFrm3( @@ -302,7 +302,7 @@ void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i int l; DWORD *pFrameTable; - if (dFlags[x][y] & DFLAG_LIT || plr[myplr]._pInfraFlag) { + if (dFlags[x][y] & BFLAG_LIT || plr[myplr]._pInfraFlag) { if (!pCelBuff) { // app_fatal("Drawing player %d \"%s\" clipped: NULL Cel Buffer", pnum, plr[pnum]._pName); return; @@ -337,7 +337,7 @@ void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i misfiledata[MFILE_MANASHLD].mAnimWidth[0], CelSkip, CelCap); - } else if (!(dFlags[x][y] & DFLAG_LIT) || plr[myplr]._pInfraFlag && light_table_index > 8) { + } else if (!(dFlags[x][y] & BFLAG_LIT) || plr[myplr]._pInfraFlag && light_table_index > 8) { Cl2DecodeFrm5(px, py, pCelBuff, nCel, nWidth, CelSkip, CelCap, 1); if (plr[pnum].pManaShield) Cl2DecodeFrm5( @@ -704,10 +704,10 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, negPlr = dPlayer[sx][sy - 1]; negMon = dMonster[sx][sy - 1]; - if(visiondebug && bFlag & DFLAG_LIT) { + if(visiondebug && bFlag & BFLAG_LIT) { Cel2DecodeHdrOnly(pBuff, (BYTE *)pSquareCel, 1, 64, 0, 8); } - if(MissilePreFlag && bFlag & DFLAG_MISSILE) { + if(MissilePreFlag && bFlag & BFLAG_MISSILE) { DrawClippedMissile(sx, sy, dx, dy, 0, 8, 1); } if(light_table_index < lightmax) { @@ -766,7 +766,7 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, } } } - if(bFlag & DFLAG_PLAYER) { + if(bFlag & BFLAG_PLAYERLR) { p = -(negPlr + 1); if((DWORD)p < MAX_PLRS) { pPlayer = &plr[p]; @@ -783,7 +783,7 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, // app_fatal("draw player clipped: tried to draw illegal player %d", p); } } - if(bFlag & DFLAG_MONSTER && (bFlag & DFLAG_LIT || plr[myplr]._pInfraFlag) && negMon < 0) { + if(bFlag & BFLAG_MONSTLR && (bFlag & BFLAG_LIT || plr[myplr]._pInfraFlag) && negMon < 0) { draw_monster_num = -(negMon + 1); if((DWORD)draw_monster_num < MAXMONSTERS) { pMonster = &monster[draw_monster_num]; @@ -806,7 +806,7 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, // app_fatal("Draw Monster Clipped: tried to draw illegal monster %d", draw_monster_num); } } - if(bFlag & DFLAG_DEAD_PLAYER) { + if(bFlag & BFLAG_DEAD_PLAYER) { DrawDeadPlayer(sx, sy, dx, dy, 0, 8, 1); } if(bPlr > 0) { @@ -826,7 +826,7 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, // app_fatal("draw player clipped: tried to draw illegal player %d", p); } } - if(nMon > 0 && (bFlag & DFLAG_LIT || plr[myplr]._pInfraFlag)) { + if(nMon > 0 && (bFlag & BFLAG_LIT || plr[myplr]._pInfraFlag)) { draw_monster_num = nMon - 1; if((DWORD)draw_monster_num < MAXMONSTERS) { pMonster = &monster[draw_monster_num]; @@ -849,7 +849,7 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, // app_fatal("Draw Monster Clipped: tried to draw illegal monster %d", draw_monster_num); } } - if(bFlag & DFLAG_MISSILE) { + if(bFlag & BFLAG_MISSILE) { DrawClippedMissile(sx, sy, dx, dy, 0, 8, 0); } if(bObj != 0 && light_table_index < lightmax) { @@ -928,7 +928,7 @@ void DrawClippedMonster(int x, int y, int mx, int my, int m, int CelSkip, int Ce return; } - if (!(dFlags[x][y] & DFLAG_LIT)) { + if (!(dFlags[x][y] & BFLAG_LIT)) { Cl2DecodeFrm5(mx, my, monster[m]._mAnimData, monster[m]._mAnimFrame, monster[m].MType->width, CelSkip, CelCap, 1); } else { trans = 0; @@ -1168,10 +1168,10 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks negPlr = dPlayer[sx][sy - 1]; negMon = dMonster[sx][sy - 1]; - if(visiondebug && bFlag & DFLAG_LIT) { + if(visiondebug && bFlag & BFLAG_LIT) { Cel2DecodeHdrOnly(pBuff, (BYTE *)pSquareCel, 1, 64, CelSkip, 8); } - if(MissilePreFlag && bFlag & DFLAG_MISSILE) { + if(MissilePreFlag && bFlag & BFLAG_MISSILE) { DrawClippedMissile(sx, sy, dx, dy, CelSkip, 8, 1); } if(light_table_index < lightmax) { @@ -1230,7 +1230,7 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks } } } - if(bFlag & DFLAG_PLAYER) { + if(bFlag & BFLAG_PLAYERLR) { p = -(negPlr + 1); if((DWORD)p < MAX_PLRS) { pPlayer = &plr[p]; @@ -1247,7 +1247,7 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks // app_fatal("draw player clipped: tried to draw illegal player %d", p); } } - if(bFlag & DFLAG_MONSTER && (bFlag & DFLAG_LIT || plr[myplr]._pInfraFlag) && negMon < 0) { + if(bFlag & BFLAG_MONSTLR && (bFlag & BFLAG_LIT || plr[myplr]._pInfraFlag) && negMon < 0) { draw_monster_num = -(negMon + 1); if((DWORD)draw_monster_num < MAXMONSTERS) { pMonster = &monster[draw_monster_num]; @@ -1270,7 +1270,7 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks // app_fatal("Draw Monster Clipped: tried to draw illegal monster %d", draw_monster_num); } } - if(bFlag & DFLAG_DEAD_PLAYER) { + if(bFlag & BFLAG_DEAD_PLAYER) { DrawDeadPlayer(sx, sy, dx, dy, CelSkip, 8, 1); } if(bPlr > 0) { @@ -1290,7 +1290,7 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks // app_fatal("draw player clipped: tried to draw illegal player %d", p); } } - if(nMon > 0 && (bFlag & DFLAG_LIT || plr[myplr]._pInfraFlag)) { + if(nMon > 0 && (bFlag & BFLAG_LIT || plr[myplr]._pInfraFlag)) { draw_monster_num = nMon - 1; if((DWORD)draw_monster_num < MAXMONSTERS) { pMonster = &monster[draw_monster_num]; @@ -1313,7 +1313,7 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks // app_fatal("Draw Monster Clipped: tried to draw illegal monster %d", draw_monster_num); } } - if(bFlag & DFLAG_MISSILE) { + if(bFlag & BFLAG_MISSILE) { DrawClippedMissile(sx, sy, dx, dy, CelSkip, 8, 0); } if(bObj != 0 && light_table_index < lightmax) { @@ -1806,7 +1806,7 @@ void DrawMonster(int x, int y, int mx, int my, int m, int CelSkip, int CelCap) return; } - if (!(dFlags[x][y] & DFLAG_LIT)) { + if (!(dFlags[x][y] & BFLAG_LIT)) { Cl2DecodeFrm3(mx, my, monster[m]._mAnimData, monster[m]._mAnimFrame, monster[m].MType->width, CelSkip, CelCap, 1); } else { trans = 0; diff --git a/Source/themes.cpp b/Source/themes.cpp index 9f30017da..6ded1cde0 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -359,7 +359,7 @@ BOOL CheckThemeRoom(int tv) for (i = 0; i < MAXDUNX; i++) { if (dTransVal[i][j] != tv) continue; - if (dFlags[i][j] & DFLAG_POPULATED) + if (dFlags[i][j] & BFLAG_POPULATED) return FALSE; tarea++; @@ -462,7 +462,7 @@ void HoldThemeRooms() for (y = 0; y < MAXDUNY; y++) { for (x = 0; x < MAXDUNX; x++) { if (dTransVal[x][y] == (char)themes[i].ttval) { - dFlags[x][y] |= DFLAG_POPULATED; + dFlags[x][y] |= BFLAG_POPULATED; } } } diff --git a/Source/town.cpp b/Source/town.cpp index ebfe3afd2..3e46d0a61 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -403,7 +403,7 @@ void town_draw_clipped_town(BYTE *pBuff, int x, int y, int sx, int sy, BOOL some } Cel2DrawHdrOnly(px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, 0, 8); } - if (dFlags[x][y] & DFLAG_MONSTER) { + if (dFlags[x][y] & BFLAG_MONSTLR) { mi = -(dMonster[x][y - 1] + 1); px = sx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) { @@ -419,7 +419,7 @@ void town_draw_clipped_town(BYTE *pBuff, int x, int y, int sx, int sy, BOOL some } Cel2DrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, 8); } - if (dFlags[x][y] & DFLAG_PLAYER) { + if (dFlags[x][y] & BFLAG_PLAYERLR) { bv = -(dPlayer[x][y - 1] + 1); px = sx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; py = sy + plr[bv]._pyoff; @@ -431,7 +431,7 @@ void town_draw_clipped_town(BYTE *pBuff, int x, int y, int sx, int sy, BOOL some town_draw_clipped_e_flag(pBuff - 64, x - 1, y + 1, sx - 64, sy); } } - if (dFlags[x][y] & DFLAG_DEAD_PLAYER) { + if (dFlags[x][y] & BFLAG_DEAD_PLAYER) { DrawDeadPlayer(x, y, sx, sy, 0, 8, 1); } if (dPlayer[x][y] > 0) { @@ -446,7 +446,7 @@ void town_draw_clipped_town(BYTE *pBuff, int x, int y, int sx, int sy, BOOL some town_draw_clipped_e_flag(pBuff - 64, x - 1, y + 1, sx - 64, sy); } } - if (dFlags[x][y] & DFLAG_MISSILE) { + if (dFlags[x][y] & BFLAG_MISSILE) { DrawClippedMissile(x, y, sx, sy, 0, 8, 0); } if(dArch[x][y] != 0) { @@ -585,7 +585,7 @@ void town_draw_clipped_town_2(BYTE *pBuff, int x, int y, int a4, int a5, int sx, } Cel2DrawHdrOnly(px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, a5, 8); } - if (dFlags[x][y] & DFLAG_MONSTER) { + if (dFlags[x][y] & BFLAG_MONSTLR) { mi = -(dMonster[x][y - 1] + 1); px = sx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) { @@ -601,7 +601,7 @@ void town_draw_clipped_town_2(BYTE *pBuff, int x, int y, int a4, int a5, int sx, } Cel2DrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, a5, 8); } - if (dFlags[x][y] & DFLAG_PLAYER) { + if (dFlags[x][y] & BFLAG_PLAYERLR) { bv = -(dPlayer[x][y - 1] + 1); px = sx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; py = sy + plr[bv]._pyoff; @@ -613,7 +613,7 @@ void town_draw_clipped_town_2(BYTE *pBuff, int x, int y, int a4, int a5, int sx, town_draw_clipped_e_flag_2(pBuff - 64, x - 1, y + 1, a4, a5, sx - 64, sy); } } - if (dFlags[x][y] & DFLAG_DEAD_PLAYER) { + if (dFlags[x][y] & BFLAG_DEAD_PLAYER) { DrawDeadPlayer(x, y, sx, sy, a5, 8, 1); } if (dPlayer[x][y] > 0) { @@ -628,7 +628,7 @@ void town_draw_clipped_town_2(BYTE *pBuff, int x, int y, int a4, int a5, int sx, town_draw_clipped_e_flag_2(pBuff - 64, x - 1, y + 1, a4, a5, sx - 64, sy); } } - if (dFlags[x][y] & DFLAG_MISSILE) { + if (dFlags[x][y] & BFLAG_MISSILE) { DrawClippedMissile(x, y, sx, sy, a5, 8, 0); } if(dArch[x][y] != 0) { @@ -775,7 +775,7 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int /// ASSERT: assert(item[bv]._iAnimData); CelDrawHdrOnly(px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, 0, dir); } - if (dFlags[x][y] & DFLAG_MONSTER) { + if (dFlags[x][y] & BFLAG_MONSTLR) { mi = -(dMonster[x][y - 1] + 1); px = sx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) { @@ -793,7 +793,7 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int /// ASSERT: assert(towner[mi]._tAnimData); CelDrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); } - if (dFlags[x][y] & DFLAG_PLAYER) { + if (dFlags[x][y] & BFLAG_PLAYERLR) { bv = -(dPlayer[x][y - 1] + 1); px = sx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; py = sy + plr[bv]._pyoff; @@ -806,7 +806,7 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int town_draw_e_flag(pBuff - 64, x - 1, y + 1, a4, dir, sx - 64, sy); } } - if (dFlags[x][y] & DFLAG_DEAD_PLAYER) { + if (dFlags[x][y] & BFLAG_DEAD_PLAYER) { DrawDeadPlayer(x, y, sx, sy, 0, dir, 0); } if (dPlayer[x][y] > 0) { @@ -822,7 +822,7 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int town_draw_e_flag(pBuff - 64, x - 1, y + 1, a4, dir, sx - 64, sy); } } - if (dFlags[x][y] & DFLAG_MISSILE) { + if (dFlags[x][y] & BFLAG_MISSILE) { DrawMissile(x, y, sx, sy, 0, dir, 0); } if(dArch[x][y] != 0) { diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 090862aea..c8dcd14c3 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -593,7 +593,7 @@ void Freeupstairs() for (yy = 0; yy < MAXTRIGGERS; yy++) { for (xx = 0; xx < MAXTRIGGERS; xx++) { - dFlags[tx - 2 + xx][ty - 2 + yy] |= DFLAG_POPULATED; + dFlags[tx - 2 + xx][ty - 2 + yy] |= BFLAG_POPULATED; } } } diff --git a/enums.h b/enums.h index e45c9d23c..428f26127 100644 --- a/enums.h +++ b/enums.h @@ -1840,14 +1840,14 @@ typedef enum dungeon_type { } dungeon_type; typedef enum dflag { - DFLAG_MISSILE = 0x01, - DFLAG_VISIBLE = 0x02, - DFLAG_DEAD_PLAYER = 0x04, - DFLAG_POPULATED = 0x08, - DFLAG_MONSTER = 0x10, - DFLAG_PLAYER = 0x20, - DFLAG_LIT = 0x40, - DFLAG_EXPLORED = 0x80, + BFLAG_MISSILE = 0x01, + BFLAG_VISIBLE = 0x02, + BFLAG_DEAD_PLAYER = 0x04, + BFLAG_POPULATED = 0x08, + BFLAG_MONSTLR = 0x10, + BFLAG_PLAYERLR = 0x20, + BFLAG_LIT = 0x40, + BFLAG_EXPLORED = 0x80, } dflag; typedef enum dungeon_message { From d218b5e3ae505881e47bea1e52ba397b6ac3bac4 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Tue, 28 May 2019 07:12:50 +0300 Subject: [PATCH 7/9] Clean up DrawTalkPan. --- Source/control.cpp | 120 ++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 68 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 98f8041ca..238389143 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -2431,79 +2431,63 @@ void control_set_gold_curs(int pnum) void DrawTalkPan() { - int v0; // esi - signed int v1; // edi - signed int v2; // esi - char *v3; // eax - int v4; // esi - int v5; // esi - int v6; // ebx - int v7; // eax - int a4; // [esp+4h] [ebp-Ch] - char *a1; // [esp+8h] [ebp-8h] - int v10; // [esp+Ch] [ebp-4h] - - v0 = 0; - if (talkflag) { - DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, 239, 516); - v1 = 293; - do { - DrawPanelBox((v0 >> 1) + 175, sgbPlrTalkTbl + v0 + 25, v1, 1, (v0 >> 1) + 239, v0 + 521); - ++v0; - --v1; - } while (v1 > 283); - DrawPanelBox(185, sgbPlrTalkTbl + 35, 274, 30, 249, 531); - DrawPanelBox(180, sgbPlrTalkTbl + 65, 284, 5, 244, 561); - v2 = 0; - do { - DrawPanelBox(180, sgbPlrTalkTbl + v2 + 70, v2 + 284, 1, 244, v2 + 566); - ++v2; - } while (v2 < 10); - DrawPanelBox(170, sgbPlrTalkTbl + 80, 310, 55, 234, 576); - v3 = sgszTalkMsg; - v4 = 0; - do { - v3 = control_print_talk_msg(v3, 0, v4, &a4, 0); - if (!v3) - goto LABEL_10; - v4 += 13; - } while (v4 < 39); - *v3 = 0; - LABEL_10: - CelDecDatOnly(gpBuffer + a4, pCelBuff, frame, 12); - v5 = 0; - a1 = plr[0]._pName; - v10 = 0; - frame = (frame & 7) + 1; - while (v10 == myplr) { - LABEL_21: - a1 += 21720; - ++v10; - if ((signed int)a1 >= (signed int)&plr[4]._pName) - return; - } - if (whisper[v10]) { - v6 = 3; - if (!talkbtndown[v5]) { - LABEL_18: - if (*(a1 - 291)) - control_print_talk_msg(a1, 46, 18 * v5 + 60, &a4, v6); - ++v5; - goto LABEL_21; + int i, off, talk_btn, color, nCel, x; + char *msg; + + off = 0; + if (!talkflag) + return; + + DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, 239, 516); + for (i = 293; i > 283; off++, i--) { + DrawPanelBox((off >> 1) + 175, sgbPlrTalkTbl + off + 25, i, 1, (off >> 1) + 239, off + 521); + } + DrawPanelBox(185, sgbPlrTalkTbl + 35, 274, 30, 249, 531); + DrawPanelBox(180, sgbPlrTalkTbl + 65, 284, 5, 244, 561); + for (i = 0; i < 10; i++) { + DrawPanelBox(180, sgbPlrTalkTbl + i + 70, i + 284, 1, 244, i + 566); + } + DrawPanelBox(170, sgbPlrTalkTbl + 80, 310, 55, 234, 576); + msg = sgszTalkMsg; + for (i = 0; i < 39; i += 13) { + msg = control_print_talk_msg(msg, 0, i, &x, 0); + if (!msg) + break; + } + if (msg) + *msg = '\0'; + CelDecDatOnly(gpBuffer + x, pCelBuff, frame, 12); + talk_btn = 0; + frame = (frame & 7) + 1; + for (i = 0; i < 4; i++) { + if (i == myplr) + continue; + if (whisper[i]) { + color = COL_GOLD; + if (talkbtndown[talk_btn]) { + if (talk_btn != 0) + nCel = 4; + else + nCel = 3; + CelDecodeOnly(236, 596 + 18 * talk_btn, pTalkBtns, nCel, 61); } - v7 = (v5 != 0) + 3; } else { - v7 = (v5 != 0) + 1; - v6 = 2; - if (talkbtndown[v5]) - v7 = (v5 != 0) + 5; + color = COL_RED; + if (talk_btn != 0) + nCel = 2; + else + nCel = 1; + if (talkbtndown[talk_btn]) + nCel += 4; + CelDecodeOnly(236, 596 + 18 * talk_btn, pTalkBtns, nCel, 61); } - CelDecodeOnly(236, 18 * v5 + 596, pTalkBtns, v7, 61); - goto LABEL_18; + if (plr[i].plractive) { + control_print_talk_msg(plr[i]._pName, 46, 60 + talk_btn * 18, &x, color); + } + + talk_btn++; } } -// 4B8840: using guessed type int sgbPlrTalkTbl; -// 4B8960: using guessed type int talkflag; char *control_print_talk_msg(char *msg, int x, int y, int *a4, int color) { From e404c62473c7ed796f73e6ff69c33f2174cb6c3a Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Thu, 30 May 2019 01:30:41 -0500 Subject: [PATCH 8/9] multi_begin_timeout --- Source/multi.cpp | 101 ++++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 41 deletions(-) diff --git a/Source/multi.cpp b/Source/multi.cpp index f9b29a81d..068fc53b2 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -363,54 +363,73 @@ void multi_mon_seeds() void multi_begin_timeout() { - unsigned char bGroupPlayers; // bl - signed int v1; // eax - signed int nLowestActive; // esi - signed int nLowestPlayer; // edi - signed int v4; // eax - int v5; // edx - unsigned char v6; // [esp+Fh] [ebp-1h] + int i, nTicks, nState, nLowestActive, nLowestPlayer; + BYTE bGroupPlayers, bGroupCount; - bGroupPlayers = 0; + if(!sgbTimeout) { + return; + } #ifdef _DEBUG - if (sgbTimeout && !debug_mode_key_i) -#else - if (sgbTimeout) + if(debug_mode_key_i) { + return; + } #endif - { - v1 = GetTickCount() - sglTimeoutStart; - if (v1 <= 20000) { - if (v1 >= 10000) { - v6 = 0; - nLowestActive = -1; - nLowestPlayer = -1; - v4 = 0; - do { - v5 = player_state[v4]; - if (v5 & 0x10000) { - if (nLowestPlayer == -1) - nLowestPlayer = v4; - if (v5 & 0x40000) { - ++bGroupPlayers; - if (nLowestActive == -1) - nLowestActive = v4; - } else { - ++v6; - } - } - ++v4; - } while (v4 < MAX_PLRS); - if (bGroupPlayers >= v6 && (bGroupPlayers != v6 || nLowestPlayer == nLowestActive)) { - if (nLowestActive == myplr) - multi_check_drop_player(); - } else { - gbGameDestroyed = TRUE; + + nTicks = GetTickCount() - sglTimeoutStart; + if(nTicks > 20000) { + gbRunGame = FALSE; + return; + } + if(nTicks < 10000) { + return; + } + + nLowestActive = -1; + nLowestPlayer = -1; + bGroupPlayers = 0; + bGroupCount = 0; + for(i = 0; i < MAX_PLRS; i++) { + nState = player_state[i]; + if(nState & 0x10000) { + if(nLowestPlayer == -1) { + nLowestPlayer = i; + } + if(nState & 0x40000) { + bGroupPlayers++; + if(nLowestActive == -1) { + nLowestActive = i; } + } else { + bGroupCount++; } - } else { - gbRunGame = FALSE; } } + + /// ASSERT: assert(bGroupPlayers); + /// ASSERT: assert(nLowestActive != -1); + /// ASSERT: assert(nLowestPlayer != -1); + +#ifdef _DEBUG + dumphist( + "(%d) grp:%d ngrp:%d lowp:%d lowa:%d", + myplr, + bGroupPlayers, + bGroupCount, + nLowestPlayer, + nLowestActive); +#endif + + if(bGroupPlayers < bGroupCount) { + gbGameDestroyed = TRUE; + } else if(bGroupPlayers == bGroupCount) { + if(nLowestPlayer != nLowestActive) { + gbGameDestroyed = TRUE; + } else if(nLowestActive == myplr) { + multi_check_drop_player(); + } + } else if(nLowestActive == myplr) { + multi_check_drop_player(); + } } // 67862D: using guessed type char gbGameDestroyed; // 678644: using guessed type int sglTimeoutStart; From 13ff40e3ff751486cf5f0fc19493503b2d60e6cc Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Thu, 30 May 2019 06:48:43 +0300 Subject: [PATCH 9/9] Clean up multi_recv_packet. --- Source/multi.cpp | 47 +++++++++++++++++++++-------------------------- Source/multi.h | 2 +- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/Source/multi.cpp b/Source/multi.cpp index 068fc53b2..cfda2587e 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -154,35 +154,30 @@ void NetSendHiPri(BYTE *pbMsg, BYTE bLen) } // 679760: using guessed type int gdwNormalMsgSize; -unsigned char *multi_recv_packet(TBuffer *packet, unsigned char *a2, int *a3) -{ - TBuffer *v3; // esi - unsigned char *result; // eax - BYTE *v5; // ebx - size_t v6; // edi - char *v7; // ebx - unsigned char *v8; // [esp+4h] [ebp-4h] - - v3 = packet; - result = a2; - v8 = a2; - if (packet->dwNextWriteOffset) { - v5 = packet->bData; - while (*v5) { - v6 = *v5; - if (v6 > *a3) +BYTE *multi_recv_packet(TBuffer *packet, BYTE *body, int *size) +{ + BYTE *src_ptr; + size_t chunk_size; + + if (packet->dwNextWriteOffset != 0) { + src_ptr = packet->bData; + while (TRUE) { + if (*src_ptr == 0) break; - v7 = (char *)(v5 + 1); - memcpy(v8, v7, v6); - v8 += v6; - v5 = (BYTE *)&v7[v6]; - *a3 -= v6; + chunk_size = *src_ptr; + if (chunk_size > *size) + break; + src_ptr++; + memcpy(body, src_ptr, chunk_size); + body += chunk_size; + src_ptr += chunk_size; + *size -= chunk_size; } - memcpy(v3->bData, v5, (size_t)&v3->bData[v3->dwNextWriteOffset - (_DWORD)v5 + 1]); /* memcpy_0 */ - v3->dwNextWriteOffset += (char *)v3 - (char *)v5 + 4; - result = v8; + memcpy(packet->bData, src_ptr, (packet->bData - src_ptr) + packet->dwNextWriteOffset + 1); + packet->dwNextWriteOffset += (packet->bData - src_ptr); + return body; } - return result; + return body; } void multi_send_msg_packet(int pmask, BYTE *a2, BYTE len) diff --git a/Source/multi.h b/Source/multi.h index 3fbb1d8b7..5851c0488 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -24,7 +24,7 @@ void multi_copy_packet(TBuffer *buf, void *packet, BYTE size); void multi_send_packet(void *packet, BYTE dwSize); void NetRecvPlrData(TPkt *pkt); void NetSendHiPri(BYTE *pbMsg, BYTE bLen); -unsigned char *multi_recv_packet(TBuffer *packet, unsigned char *a2, int *a3); +BYTE *multi_recv_packet(TBuffer *packet, BYTE *body, int *size); void multi_send_msg_packet(int pmask, BYTE *a2, BYTE len); void multi_msg_countdown(); void multi_parse_turn(int pnum, int turn);