From 8cddb57d0817db963d12084760fc4b2d72c695ce Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sat, 31 Aug 2019 00:53:29 -0500 Subject: [PATCH 1/9] Fix returning in gmenu_lmouse --- Source/gmenu.cpp | 77 +++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 43 deletions(-) diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 0b7a5165e..9b3e7f3ab 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -311,7 +311,6 @@ BOOLEAN gmenu_valid_mouse_pos(int *plOffset) BOOL gmenu_left_mouse(BOOL isDown) { - BOOL result; TMenuItem *pItem; DWORD i, w; int dummy; @@ -319,53 +318,45 @@ BOOL gmenu_left_mouse(BOOL isDown) if (!isDown) { if (mouseNavigation) { mouseNavigation = FALSE; - result = TRUE; + return TRUE; } else { - result = FALSE; + return FALSE; } + } + if (!sgpCurrentMenu) { + return FALSE; + } + if (MouseY >= PANEL_TOP) { + return FALSE; + } + if (MouseY - 117 < 0) { + return TRUE; + } + i = (MouseY - 117) / 45; + if (i >= sgCurrentMenuIdx) { + return TRUE; + } + pItem = &sgpCurrentMenu[i]; + if (!(sgpCurrentMenu[i].dwFlags & GMENU_ENABLED)) { + return TRUE; + } + w = gmenu_get_lfont(pItem); + if (MouseX < SCREEN_WIDTH / 2 - w / 2) { + return TRUE; + } + if (MouseX > SCREEN_WIDTH / 2 + w / 2) { + return TRUE; + } + sgpCurrItem = pItem; + PlaySFX(IS_TITLEMOV); + if (pItem->dwFlags & GMENU_SLIDER) { + mouseNavigation = gmenu_valid_mouse_pos(&dummy); + gmenu_on_mouse_move(); } else { - - if (!sgpCurrentMenu) { - return FALSE; - } - if (MouseY >= PANEL_TOP) { - return FALSE; - } - if (MouseY - 117 >= 0) { - i = (MouseY - 117) / 45; - if (i < sgCurrentMenuIdx) { - pItem = &sgpCurrentMenu[i]; - if ((sgpCurrentMenu[i].dwFlags & GMENU_ENABLED) != 0) { - w = gmenu_get_lfont(pItem); - if (MouseX >= SCREEN_WIDTH / 2 - w / 2) { - if (MouseX <= SCREEN_WIDTH / 2 + w / 2) { - sgpCurrItem = pItem; - PlaySFX(IS_TITLEMOV); - if (pItem->dwFlags & GMENU_SLIDER) { - mouseNavigation = gmenu_valid_mouse_pos(&dummy); - gmenu_on_mouse_move(); - } else { - sgpCurrItem->fnMenu(TRUE); - } - result = TRUE; - } else { - result = TRUE; - } - } else { - result = TRUE; - } - } else { - result = TRUE; - } - } else { - result = TRUE; - } - } else { - result = TRUE; - } + sgpCurrItem->fnMenu(TRUE); } - return result; + return TRUE; } void gmenu_enable(TMenuItem *pMenuItem, BOOL enable) From d4ae8e56065dc3f13dba569ba6cf7741d57c2fce Mon Sep 17 00:00:00 2001 From: qndel Date: Sat, 31 Aug 2019 08:29:29 +0200 Subject: [PATCH 2/9] Clean up CreatePlrItems --- Source/items.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index 0f970c9b7..60c8bf49b 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -856,8 +856,9 @@ void CreatePlrItems(int p) int i; ItemStruct *pi = plr[p].InvBody; - for (i = 0; i < NUM_INVLOC; i++) { - pi[i]._itype = ITYPE_NONE; + for (i = NUM_INVLOC; i != 0; i--) { + pi->_itype = ITYPE_NONE; + pi++; } // converting this to a for loop creates a `rep stosd` instruction, @@ -865,15 +866,17 @@ void CreatePlrItems(int p) memset(&plr[p].InvGrid, 0, sizeof(plr[p].InvGrid)); pi = plr[p].InvList; - for (i = 0; i < NUM_INV_GRID_ELEM; i++) { - pi[i]._itype = ITYPE_NONE; + for (i = NUM_INV_GRID_ELEM; i != 0; i--) { + pi->_itype = ITYPE_NONE; + pi++; } plr[p]._pNumInv = 0; pi = plr[p].SpdList; - for (i = 0; i < MAXBELTITEMS; i++) { - pi[i]._itype = ITYPE_NONE; + for (i = MAXBELTITEMS; i != 0; i--) { + pi->_itype = ITYPE_NONE; + pi++; } switch (plr[p]._pClass) { From 6cf1da4045f10f5a572a3b6be940e0e1e7110f61 Mon Sep 17 00:00:00 2001 From: qndel Date: Fri, 30 Aug 2019 21:33:58 +0200 Subject: [PATCH 3/9] Apply enums to _mFlags --- Source/missiles.cpp | 4 ++-- Source/scrollrt.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 21ff280a4..f7602fbe0 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -991,9 +991,9 @@ void CheckMissileCol(int i, int mindam, int maxdam, BOOL shift, int mx, int my, missile[i]._miHitFlag = 1; } } else { - if (monster[missile[i]._misource]._mFlags & 0x10 + if (monster[missile[i]._misource]._mFlags & MFLAG_TARGETS_MONSTER && dMonster[mx][my] > 0 - && monster[dMonster[mx][my] - 1]._mFlags & 0x20 + && monster[dMonster[mx][my] - 1]._mFlags & MFLAG_GOLEM && MonsterTrapHit(dMonster[mx][my] - 1, mindam, maxdam, missile[i]._midist, missile[i]._mitype, shift)) { if (!nodel) missile[i]._mirange = 0; diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 253c23f3e..2baf2cdf3 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -787,7 +787,7 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, draw_monster_num = -(negMon + 1); if ((DWORD)draw_monster_num < MAXMONSTERS) { pMonster = &monster[draw_monster_num]; - if (!(pMonster->_mFlags & 1)) { + if (!(pMonster->_mFlags & MFLAG_HIDDEN)) { if (pMonster->MType != NULL) { px = dx + pMonster->_mxoff - pMonster->MType->width2; py = dy + pMonster->_myoff; @@ -830,7 +830,7 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, draw_monster_num = nMon - 1; if ((DWORD)draw_monster_num < MAXMONSTERS) { pMonster = &monster[draw_monster_num]; - if (!(pMonster->_mFlags & 1)) { + if (!(pMonster->_mFlags & MFLAG_HIDDEN)) { if (pMonster->MType != NULL) { px = dx + pMonster->_mxoff - pMonster->MType->width2; py = dy + pMonster->_myoff; @@ -1253,7 +1253,7 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks draw_monster_num = -(negMon + 1); if ((DWORD)draw_monster_num < MAXMONSTERS) { pMonster = &monster[draw_monster_num]; - if (!(pMonster->_mFlags & 1)) { + if (!(pMonster->_mFlags & MFLAG_HIDDEN)) { if (pMonster->MType != NULL) { px = dx + pMonster->_mxoff - pMonster->MType->width2; py = dy + pMonster->_myoff; @@ -1296,7 +1296,7 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks draw_monster_num = nMon - 1; if ((DWORD)draw_monster_num < MAXMONSTERS) { pMonster = &monster[draw_monster_num]; - if (!(pMonster->_mFlags & 1)) { + if (!(pMonster->_mFlags & MFLAG_HIDDEN)) { if (pMonster->MType != NULL) { px = dx + pMonster->_mxoff - pMonster->MType->width2; py = dy + pMonster->_myoff; @@ -1680,7 +1680,7 @@ void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, int CelCa draw_monster_num = -(negMon + 1); if ((DWORD)draw_monster_num < MAXMONSTERS) { pMonster = &monster[draw_monster_num]; - if (!(pMonster->_mFlags & 1)) { + if (!(pMonster->_mFlags & MFLAG_HIDDEN)) { if (pMonster->MType != NULL) { px = dx + pMonster->_mxoff - pMonster->MType->width2; py = dy + pMonster->_myoff; @@ -1723,7 +1723,7 @@ void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, int CelCa draw_monster_num = nMon - 1; if ((DWORD)draw_monster_num < MAXMONSTERS) { pMonster = &monster[draw_monster_num]; - if (!(pMonster->_mFlags & 1)) { + if (!(pMonster->_mFlags & MFLAG_HIDDEN)) { if (pMonster->MType != NULL) { px = dx + pMonster->_mxoff - pMonster->MType->width2; py = dy + pMonster->_myoff; From 99a200f44c800c13c5b4f85df2789bda426451ef Mon Sep 17 00:00:00 2001 From: jimmy-cell Date: Sat, 31 Aug 2019 18:27:50 +0300 Subject: [PATCH 4/9] bin exact AddBoneSpirit --- Source/missiles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index f7602fbe0..27acc20ae 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -2373,9 +2373,9 @@ void AddBoneSpirit(int mi, int sx, int sy, int dx, int dy, int midir, char miene missile[mi]._mlid = AddLight(sx, sy, 8); if (!mienemy) { UseMana(id, SPL_BONESPIRIT); - drawhpflag = TRUE; plr[id]._pHitPoints -= 384; plr[id]._pHPBase -= 384; + drawhpflag = TRUE; if (plr[id]._pHitPoints <= 0) SyncPlrKill(id, 0); } From a0575d335f1a8456ce805bb6d868edc8e1bbd86b Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 1 Sep 2019 01:47:20 +0200 Subject: [PATCH 5/9] random bin exact in vanilla/hellfire --- Source/engine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/engine.cpp b/Source/engine.cpp index 9a4c4de8a..a7173b2f3 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -2337,9 +2337,9 @@ int random(BYTE idx, int v) { if (v <= 0) return 0; - if (v >= 0xFFFF) - return GetRndSeed() % v; - return (GetRndSeed() >> 16) % v; + if (v < 0xFFFF) + return (GetRndSeed() >> 16) % v; + return GetRndSeed() % v; } void engine_debug_trap(BOOL show_cursor) From e24cbb242326fda063c343db7d21c4d58c0b232d Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 30 Aug 2019 03:33:58 +0200 Subject: [PATCH 6/9] Clean up init_disable_screensaver --- Source/automap.cpp | 2 +- Source/control.cpp | 2 +- Source/drlg_l1.cpp | 6 ++---- Source/init.cpp | 32 +++++++++++++++++++------------- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index f2446d3c5..432b8cc5f 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -577,7 +577,7 @@ void SetAutomapView(int x, int y) return; } - automapview[xx][yy] = 1; + automapview[xx][yy] = TRUE; maptype = GetAutomapType(xx, yy, FALSE); solid = maptype & 0x4000; diff --git a/Source/control.cpp b/Source/control.cpp index a1277ca16..541f2e817 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -2638,7 +2638,7 @@ void control_press_enter() } if (i >= 8) { strcpy(sgszTalkSave[sgbNextTalkSave], sgszTalkMsg); - sgbNextTalkSave = sgbNextTalkSave + 1; + sgbNextTalkSave++; sgbNextTalkSave &= 7; } else { talk_save = sgbNextTalkSave - 1; diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 014fdc5eb..6f200496a 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -615,10 +615,8 @@ void DRLG_L1Shadows() dungeon[x - 1][y - 1] = SPATS[i].nv1; if (SPATS[i].nv2 && !L5dflags[x][y - 1]) dungeon[x][y - 1] = SPATS[i].nv2; - if (SPATS[i].nv3) { - if (!L5dflags[x - 1][y]) - dungeon[x - 1][y] = SPATS[i].nv3; - } + if (SPATS[i].nv3 && !L5dflags[x - 1][y]) + dungeon[x - 1][y] = SPATS[i].nv3; } } } diff --git a/Source/init.cpp b/Source/init.cpp index 221ee9743..a4691033e 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -113,24 +113,30 @@ void init_disable_screensaver(BOOLEAN disable) char Data[16]; DWORD Type, cbData; HKEY phkResult; + LRESULT success; // BUGFIX: this is probably the worst possible way to do this. Alternatives: ExtEscape() with SETPOWERMANAGEMENT, // SystemParametersInfo() with SPI_SETSCREENSAVEACTIVE/SPI_SETPOWEROFFACTIVE/SPI_SETLOWPOWERACTIVE - if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ | KEY_WRITE, (PHKEY)&phkResult)) { - if (disable) { - cbData = 16; - if (!RegQueryValueEx(phkResult, "ScreenSaveActive", 0, &Type, (LPBYTE)Data, &cbData)) - screensaver_enabled_prev = Data[0] != '0'; - enabled = FALSE; - } else { - enabled = screensaver_enabled_prev; - } - Data[1] = 0; - Data[0] = enabled ? '1' : '0'; - RegSetValueEx(phkResult, "ScreenSaveActive", 0, REG_SZ, (const BYTE *)Data, 2); - RegCloseKey(phkResult); + success = RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ | KEY_WRITE, (PHKEY)&phkResult); + if (success != ERROR_SUCCESS) { + return; + } + + if (disable) { + cbData = 16; + success = RegQueryValueEx(phkResult, "ScreenSaveActive", 0, &Type, (LPBYTE)Data, &cbData); + if (success == ERROR_SUCCESS) + screensaver_enabled_prev = Data[0] != '0'; + enabled = FALSE; + } else { + enabled = screensaver_enabled_prev; } + + Data[1] = 0; + Data[0] = enabled ? '1' : '0'; + RegSetValueEx(phkResult, "ScreenSaveActive", 0, REG_SZ, (const BYTE *)Data, 2); + RegCloseKey(phkResult); } void init_create_window(int nCmdShow) From a3f4124fae1a68518addb1176ebe2326e4174881 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 2 Sep 2019 08:17:20 +0200 Subject: [PATCH 7/9] Remove generated VC6 files --- MakefileVC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MakefileVC b/MakefileVC index 9c2998d88..0c768814a 100644 --- a/MakefileVC +++ b/MakefileVC @@ -85,6 +85,6 @@ diablo.res: Diablo.rc $(RC) /i $(VC6_INC_DIR) /l 0x409 /fo $@ $< clean: - @$(RM) -v $(OBJS) + @$(RM) -v $(OBJS) vc60.idb vc60.pdb Diablo.pdb Diablo.pch .PHONY: clean all From d2362172fad2faf1e07ef36d164d8fa0c3f8acb7 Mon Sep 17 00:00:00 2001 From: qndel Date: Mon, 2 Sep 2019 22:15:59 +0200 Subject: [PATCH 8/9] [hellfire] DRLG_L4 bin exact --- Source/drlg_l4.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 91b1ebef2..aadfa212e 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -492,7 +492,7 @@ void CreateL4Dungeon(DWORD rseed, int entry) void DRLG_L4(int entry) { - int i, j, spi, spj; + int i, j, spi, spj, ar; BOOL doneflag; do { @@ -501,8 +501,11 @@ void DRLG_L4(int entry) InitL4Dungeon(); L4firstRoom(); L4FixRim(); - } while (GetArea() < 173); - uShape(); + ar = GetArea(); + if (ar >= 173) { + uShape(); + } + } while (ar < 173); L4makeDungeon(); L4makeDmt(); L4tileFix(); From 9daea5be8a85745f69dc54795562630071596725 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 3 Sep 2019 00:12:09 +0200 Subject: [PATCH 9/9] Back port clean ups from Hellfire --- Source/drlg_l1.cpp | 10 +- Source/drlg_l3.cpp | 247 +++++++++++++++++++++++---------------------- Source/palette.cpp | 4 +- Source/player.cpp | 19 +++- Source/player.h | 6 +- defs.h | 2 +- enums.h | 194 +++++++++++++++++------------------ 7 files changed, 253 insertions(+), 229 deletions(-) diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 6f200496a..bb3ad1813 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -120,10 +120,14 @@ void DRLG_Init_Globals() memset(dItem, 0, sizeof(dItem)); memset(dMissile, 0, sizeof(dMissile)); memset(dArch, 0, sizeof(dArch)); - if (!lightflag) - c = (light4flag) ? 3 : 15; - else + if (!lightflag) { + if (light4flag) + c = 3; + else + c = 15; + } else { c = 0; + } memset(dLight, c, sizeof(dLight)); } diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 60fd6acce..12cd04e3d 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -147,10 +147,10 @@ BOOL DRLG_L3Anvil() int sx, sy, sw, sh, xx, yy, ii, trys; BOOL found; - sx = random(0, 29); - sy = random(0, 29); - sw = 11; - sh = 11; + sw = L3ANVIL[0]; + sh = L3ANVIL[1]; + sx = random(0, DMAXX - sw); + sy = random(0, DMAXY - sh); found = FALSE; trys = 0; @@ -171,10 +171,10 @@ BOOL DRLG_L3Anvil() } if (!found) { sx++; - if (sx == 29) { + if (sx == DMAXX - sw) { sx = 0; sy++; - if (sy == 29) { + if (sy == DMAXY - sh) { sy = 0; } } @@ -184,7 +184,7 @@ BOOL DRLG_L3Anvil() return TRUE; } - ii = 123; + ii = sw * sh + 2; for (yy = 0; yy < sh; yy++) { for (xx = 0; xx < sw; xx++) { if (L3ANVIL[ii] != 0) { @@ -646,7 +646,7 @@ void DRLG_L3FillSingles() void DRLG_L3FillStraights() { - int i, j, xc, xs, yc, ys, k; + int i, j, xc, xs, yc, ys, k, rv; for (j = 0; j < DMAXY - 1; j++) { xs = 0; @@ -659,7 +659,8 @@ void DRLG_L3FillStraights() } else { if (xs > 3 && random(0, 2) != 0) { for (k = xc; k < i; k++) { - dungeon[k][j] = random(0, 2); + rv = random(0, 2); + dungeon[k][j] = rv; } } xs = 0; @@ -677,7 +678,8 @@ void DRLG_L3FillStraights() } else { if (xs > 3 && random(0, 2) != 0) { for (k = xc; k < i; k++) { - dungeon[k][j + 1] = random(0, 2); + rv = random(0, 2); + dungeon[k][j + 1] = rv; } } xs = 0; @@ -695,7 +697,8 @@ void DRLG_L3FillStraights() } else { if (ys > 3 && random(0, 2) != 0) { for (k = yc; k < j; k++) { - dungeon[i][k] = random(0, 2); + rv = random(0, 2); + dungeon[i][k] = rv; } } ys = 0; @@ -713,7 +716,8 @@ void DRLG_L3FillStraights() } else { if (ys > 3 && random(0, 2) != 0) { for (k = yc; k < j; k++) { - dungeon[i + 1][k] = random(0, 2); + rv = random(0, 2); + dungeon[i + 1][k] = rv; } } ys = 0; @@ -751,20 +755,22 @@ int DRLG_L3GetFloorArea() void DRLG_L3MakeMegas() { - int i, j, v; + int i, j, v, rv; - for (j = 0; j < DMAXY-1; j++) { - for (i = 0; i < DMAXX-1; i++) { + for (j = 0; j < DMAXY - 1; j++) { + for (i = 0; i < DMAXX - 1; i++) { v = dungeon[i + 1][j + 1] + 2 * dungeon[i][j + 1] + 4 * dungeon[i + 1][j] + 8 * dungeon[i][j]; if (v == 6) { - if (random(0, 2) == 0) { + rv = random(0, 2); + if (rv == 0) { v = 12; } else { v = 5; } } if (v == 9) { - if (random(0, 2) == 0) { + rv = random(0, 2); + if (rv == 0) { v = 13; } else { v = 14; @@ -772,10 +778,10 @@ void DRLG_L3MakeMegas() } dungeon[i][j] = L3ConvTbl[v]; } - dungeon[DMAXX-1][j] = 8; + dungeon[DMAXX - 1][j] = 8; } for (i = 0; i < DMAXX; i++) { - dungeon[i][DMAXY-1] = 8; + dungeon[i][DMAXY - 1] = 8; } } @@ -1188,7 +1194,7 @@ void DRLG_L3PoolFix() { int dunx, duny; - for (duny = 0; duny < DMAXY; duny++) { // BUGFIX: Change '0' to '1' and 'DMAXY' to 'DMAXY - 1' + for (duny = 0; duny < DMAXY; duny++) { // BUGFIX: Change '0' to '1' and 'DMAXY' to 'DMAXY - 1' for (dunx = 0; dunx < DMAXX; dunx++) { // BUGFIX: Change '0' to '1' and 'DMAXX' to 'DMAXX - 1' if (dungeon[dunx][duny] == 8) { if (dungeon[dunx - 1][duny - 1] >= 25 && dungeon[dunx - 1][duny - 1] <= 41 @@ -1346,7 +1352,7 @@ void DRLG_L3Wood() int i, j, x, y, xx, yy, rt, rp, x1, y1, x2, y2; BOOL skip; - for (j = 0; j < DMAXY - 1; j++) { // BUGFIX: Change '0' to '1' + for (j = 0; j < DMAXY - 1; j++) { // BUGFIX: Change '0' to '1' for (i = 0; i < DMAXX - 1; i++) { // BUGFIX: Change '0' to '1' if (dungeon[i][j] == 10 && random(0, 2) != 0) { x = i; @@ -1416,112 +1422,111 @@ void DRLG_L3Wood() } } - for (j = 0; j < DMAXY; j++) { // BUGFIX: Change '0' to '1' + for (j = 0; j < DMAXY; j++) { // BUGFIX: Change '0' to '1' for (i = 0; i < DMAXX; i++) { // BUGFIX: Change '0' to '1' - if (dungeon[i][j] != 7 || random(0, 1) != 0 || !SkipThemeRoom(i, j)) { - continue; - } - rt = random(0, 2); - if (rt == 0) { - y1 = j; - while (WoodVertU(i, y1)) { - y1--; - } - y1++; - y2 = j; - while (WoodVertD(i, y2)) { - y2++; - } - y2--; - skip = TRUE; - if (dungeon[i][y1] == 7) { - skip = FALSE; - } - if (dungeon[i][y2] == 7) { - skip = FALSE; - } - if (y2 - y1 > 1 && skip) { - rp = random(0, y2 - y1 - 1) + y1 + 1; - for (y = y1; y <= y2; y++) { - if (y == rp) { - continue; - } - if (dungeon[i][y] == 7) { - if (random(0, 2) != 0) { - dungeon[i][y] = 135; - } else { - dungeon[i][y] = 137; + if (dungeon[i][j] == 7 && random(0, 1) == 0 && SkipThemeRoom(i, j)) { + rt = random(0, 2); + if (rt == 0) { + y1 = j; + while (WoodVertU(i, y1)) { + y1--; + } + y1++; + y2 = j; + while (WoodVertD(i, y2)) { + y2++; + } + y2--; + skip = TRUE; + if (dungeon[i][y1] == 7) { + skip = FALSE; + } + if (dungeon[i][y2] == 7) { + skip = FALSE; + } + if (y2 - y1 > 1 && skip) { + rp = random(0, y2 - y1 - 1) + y1 + 1; + for (y = y1; y <= y2; y++) { + if (y == rp) { + continue; + } + if (dungeon[i][y] == 7) { + if (random(0, 2) != 0) { + dungeon[i][y] = 135; + } else { + dungeon[i][y] = 137; + } + } + if (dungeon[i][y] == 10) { + dungeon[i][y] = 131; + } + if (dungeon[i][y] == 126) { + dungeon[i][y] = 133; + } + if (dungeon[i][y] == 129) { + dungeon[i][y] = 133; + } + if (dungeon[i][y] == 2) { + dungeon[i][y] = 139; + } + if (dungeon[i][y] == 134) { + dungeon[i][y] = 138; + } + if (dungeon[i][y] == 136) { + dungeon[i][y] = 138; } - } - if (dungeon[i][y] == 10) { - dungeon[i][y] = 131; - } - if (dungeon[i][y] == 126) { - dungeon[i][y] = 133; - } - if (dungeon[i][y] == 129) { - dungeon[i][y] = 133; - } - if (dungeon[i][y] == 2) { - dungeon[i][y] = 139; - } - if (dungeon[i][y] == 134) { - dungeon[i][y] = 138; - } - if (dungeon[i][y] == 136) { - dungeon[i][y] = 138; } } } - } - if (rt == 1) { - x1 = i; - while (WoodHorizL(x1, j)) { - x1--; - } - x1++; - x2 = i; - while (WoodHorizR(x2, j)) { - x2++; - } - x2--; - skip = TRUE; - if (dungeon[x1][j] == 7) { - skip = FALSE; - } - if (dungeon[x2][j] == 7) { - skip = FALSE; - } - if (x2 - x1 > 1 && skip) { - rp = random(0, x2 - x1 - 1) + x1 + 1; - for (x = x1; x <= x2; x++) { - if (x == rp) { - continue; - } - if (dungeon[x][j] == 7) { - if (random(0, 2) != 0) { - dungeon[x][j] = 134; - } else { - dungeon[x][j] = 136; + if (rt == 1) { + x1 = i; + while (WoodHorizL(x1, j)) { + x1--; + } + x1++; + x2 = i; + while (WoodHorizR(x2, j)) { + x2++; + } + x2--; + skip = TRUE; + if (dungeon[x1][j] == 7) { + skip = FALSE; + } + if (dungeon[x2][j] == 7) { + skip = FALSE; + } + if (x2 - x1 > 1 && skip) { + rp = random(0, x2 - x1 - 1) + x1 + 1; + for (x = x1; x <= x2; x++) { + if (x == rp) { + continue; + } + if (dungeon[x][j] == 7) { + if (random(0, 2) != 0) { + dungeon[x][j] = 134; + } else { + dungeon[x][j] = 136; + } + } + if (dungeon[x][j] == 9) { + dungeon[x][j] = 130; + } + if (dungeon[x][j] == 121) { + dungeon[x][j] = 132; + } + if (dungeon[x][j] == 124) { + dungeon[x][j] = 132; + } + if (dungeon[x][j] == 4) { + dungeon[x][j] = 140; + } + if (dungeon[x][j] == 135) { + dungeon[x][j] = 138; + } + if (dungeon[x][j] == 137) { + dungeon[x][j] = 138; } - } - if (dungeon[x][j] == 9) { - dungeon[x][j] = 130; - } - if (dungeon[x][j] == 121) { - dungeon[x][j] = 132; - } - if (dungeon[x][j] == 124) { - dungeon[x][j] = 132; - } - if (dungeon[x][j] == 4) { - dungeon[x][j] = 140; - } - if (dungeon[x][j] == 135) { - dungeon[x][j] = 138; - } - if (dungeon[x][j] == 137) { - dungeon[x][j] = 138; } } } diff --git a/Source/palette.cpp b/Source/palette.cpp index de1e9a453..f4b21fd75 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -112,12 +112,14 @@ void LoadPalette(char *pszFileName) void LoadRndLvlPal(int l) { + int rv; char szFileName[MAX_PATH]; if (l == DTYPE_TOWN) { LoadPalette("Levels\\TownData\\Town.pal"); } else { - sprintf(szFileName, "Levels\\L%iData\\L%i_%i.PAL", l, l, random(0, 4) + 1); + rv = random(0, 4) + 1; + sprintf(szFileName, "Levels\\L%iData\\L%i_%i.PAL", l, l, rv); LoadPalette(szFileName); } } diff --git a/Source/player.cpp b/Source/player.cpp index a10701e04..ab14c0153 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -19,7 +19,12 @@ int plr_dframe_size; const char ArmourChar[4] = { 'L', 'M', 'H', 0 }; const char WepChar[10] = { 'N', 'U', 'S', 'D', 'B', 'A', 'M', 'H', 'T', 0 }; -const char CharChar[4] = { 'W', 'R', 'S', 0 }; +const char CharChar[] = { + 'W', + 'R', + 'S', + 0 +}; /* data */ @@ -46,7 +51,11 @@ int MagicTbl[3] = { 10, 15, 35 }; int DexterityTbl[3] = { 20, 30, 15 }; int VitalityTbl[3] = { 25, 20, 20 }; int ToBlkTbl[3] = { 30, 20, 10 }; -char *ClassStrTblOld[3] = { "Warrior", "Rogue", "Sorceror" }; // unused +char *ClassStrTblOld[] = { + "Warrior", + "Rogue", + "Sorceror", +}; int MaxStats[3][4] = { { 250, 50, 60, 100 }, { 55, 70, 250, 80 }, @@ -105,7 +114,11 @@ int ExpLvlsTbl[MAXCHARLEVEL] = { 1310707109, 1583495809 }; -char *ClassStrTbl[3] = { "Warrior", "Rogue", "Sorceror" }; +char *ClassStrTbl[] = { + "Warrior", + "Rogue", + "Sorceror", +}; BYTE fix[9] = { 0, 0, 3, 3, 3, 6, 6, 6, 8 }; /* PM_ChangeLightOff local type */ void SetPlayerGPtrs(BYTE *pData, BYTE **pAnim) diff --git a/Source/player.h b/Source/player.h index 964171fa5..193de42da 100644 --- a/Source/player.h +++ b/Source/player.h @@ -113,7 +113,7 @@ void PlayDungMsgs(); extern const char ArmourChar[4]; extern const char WepChar[10]; -extern const char CharChar[4]; +extern const char CharChar[]; /* data */ @@ -129,10 +129,10 @@ extern int MagicTbl[3]; extern int DexterityTbl[3]; extern int VitalityTbl[3]; extern int ToBlkTbl[3]; -extern char *ClassStrTblOld[3]; +extern char *ClassStrTblOld[]; extern int MaxStats[3][4]; extern int ExpLvlsTbl[MAXCHARLEVEL]; -extern char *ClassStrTbl[3]; +extern char *ClassStrTbl[]; extern BYTE fix[9]; #endif /* __PLAYER_H__ */ diff --git a/defs.h b/defs.h index fc2a2bffe..b7623b95d 100644 --- a/defs.h +++ b/defs.h @@ -168,7 +168,7 @@ typedef void (*_PVFV)(void); #endif // To apply to certain functions which have local variables aligned by 1 for unknown yet reason -#ifdef _MSC_VER +#if (_MSC_VER == 1200) #define ALIGN_BY_1 __declspec(align(1)) #else #define ALIGN_BY_1 diff --git a/enums.h b/enums.h index 7e0a8413f..240ff2154 100644 --- a/enums.h +++ b/enums.h @@ -2162,103 +2162,103 @@ typedef enum spell_id { } spell_id; typedef enum _cmd_id { - CMD_STAND = 0, - CMD_WALKXY = 1, - CMD_ACK_PLRINFO = 2, - CMD_ADDSTR = 3, - CMD_ADDMAG = 4, - CMD_ADDDEX = 5, - CMD_ADDVIT = 6, - CMD_SBSPELL = 7, - CMD_GETITEM = 8, - CMD_AGETITEM = 9, - CMD_PUTITEM = 10, - CMD_RESPAWNITEM = 11, - CMD_ATTACKXY = 12, - CMD_RATTACKXY = 13, - CMD_SPELLXY = 14, - CMD_TSPELLXY = 15, - CMD_OPOBJXY = 16, - CMD_DISARMXY = 17, - CMD_ATTACKID = 18, - CMD_ATTACKPID = 19, - CMD_RATTACKID = 20, - CMD_RATTACKPID = 21, - CMD_SPELLID = 22, - CMD_SPELLPID = 23, - CMD_TSPELLID = 24, - CMD_TSPELLPID = 25, - CMD_RESURRECT = 26, - CMD_OPOBJT = 27, - CMD_KNOCKBACK = 28, - CMD_TALKXY = 29, - CMD_NEWLVL = 30, - CMD_WARP = 31, - CMD_CHEAT_EXPERIENCE = 32, - CMD_CHEAT_SPELL_LEVEL = 33, - CMD_DEBUG = 34, - CMD_SYNCDATA = 35, - CMD_MONSTDEATH = 36, - CMD_MONSTDAMAGE = 37, - CMD_PLRDEAD = 38, - CMD_REQUESTGITEM = 39, - CMD_REQUESTAGITEM = 40, - CMD_GOTOGETITEM = 41, - CMD_GOTOAGETITEM = 42, - CMD_OPENDOOR = 43, - CMD_CLOSEDOOR = 44, - CMD_OPERATEOBJ = 45, - CMD_PLROPOBJ = 46, - CMD_BREAKOBJ = 47, - CMD_CHANGEPLRITEMS = 48, - CMD_DELPLRITEMS = 49, - CMD_PLRDAMAGE = 50, - CMD_PLRLEVEL = 51, - CMD_DROPITEM = 52, - CMD_PLAYER_JOINLEVEL = 53, - CMD_SEND_PLRINFO = 54, - CMD_SATTACKXY = 55, - CMD_ACTIVATEPORTAL = 56, - CMD_DEACTIVATEPORTAL = 57, - CMD_DLEVEL_0 = 58, - CMD_DLEVEL_1 = 59, - CMD_DLEVEL_2 = 60, - CMD_DLEVEL_3 = 61, - CMD_DLEVEL_4 = 62, - CMD_DLEVEL_5 = 63, - CMD_DLEVEL_6 = 64, - CMD_DLEVEL_7 = 65, - CMD_DLEVEL_8 = 66, - CMD_DLEVEL_9 = 67, - CMD_DLEVEL_10 = 68, - CMD_DLEVEL_11 = 69, - CMD_DLEVEL_12 = 70, - CMD_DLEVEL_13 = 71, - CMD_DLEVEL_14 = 72, - CMD_DLEVEL_15 = 73, - CMD_DLEVEL_16 = 74, - CMD_DLEVEL_JUNK = 75, - CMD_DLEVEL_END = 76, - CMD_HEALOTHER = 77, - CMD_STRING = 78, - CMD_SETSTR = 79, - CMD_SETMAG = 80, - CMD_SETDEX = 81, - CMD_SETVIT = 82, - CMD_RETOWN = 83, - CMD_SPELLXYD = 84, - CMD_ITEMEXTRA = 85, - CMD_SYNCPUTITEM = 86, - CMD_KILLGOLEM = 87, - CMD_SYNCQUEST = 88, - CMD_ENDSHIELD = 89, - CMD_AWAKEGOLEM = 90, - CMD_NOVA = 91, - CMD_SETSHIELD = 92, - CMD_REMSHIELD = 93, - FAKE_CMD_SETID = 94, - FAKE_CMD_DROPID = 95, - NUM_CMDS = 96, + CMD_STAND, + CMD_WALKXY, + CMD_ACK_PLRINFO, + CMD_ADDSTR, + CMD_ADDMAG, + CMD_ADDDEX, + CMD_ADDVIT, + CMD_SBSPELL, + CMD_GETITEM, + CMD_AGETITEM, + CMD_PUTITEM, + CMD_RESPAWNITEM, + CMD_ATTACKXY, + CMD_RATTACKXY, + CMD_SPELLXY, + CMD_TSPELLXY, + CMD_OPOBJXY, + CMD_DISARMXY, + CMD_ATTACKID, + CMD_ATTACKPID, + CMD_RATTACKID, + CMD_RATTACKPID, + CMD_SPELLID, + CMD_SPELLPID, + CMD_TSPELLID, + CMD_TSPELLPID, + CMD_RESURRECT, + CMD_OPOBJT, + CMD_KNOCKBACK, + CMD_TALKXY, + CMD_NEWLVL, + CMD_WARP, + CMD_CHEAT_EXPERIENCE, + CMD_CHEAT_SPELL_LEVEL, + CMD_DEBUG, + CMD_SYNCDATA, + CMD_MONSTDEATH, + CMD_MONSTDAMAGE, + CMD_PLRDEAD, + CMD_REQUESTGITEM, + CMD_REQUESTAGITEM, + CMD_GOTOGETITEM, + CMD_GOTOAGETITEM, + CMD_OPENDOOR, + CMD_CLOSEDOOR, + CMD_OPERATEOBJ, + CMD_PLROPOBJ, + CMD_BREAKOBJ, + CMD_CHANGEPLRITEMS, + CMD_DELPLRITEMS, + CMD_PLRDAMAGE, + CMD_PLRLEVEL, + CMD_DROPITEM, + CMD_PLAYER_JOINLEVEL, + CMD_SEND_PLRINFO, + CMD_SATTACKXY, + CMD_ACTIVATEPORTAL, + CMD_DEACTIVATEPORTAL, + CMD_DLEVEL_0, + CMD_DLEVEL_1, + CMD_DLEVEL_2, + CMD_DLEVEL_3, + CMD_DLEVEL_4, + CMD_DLEVEL_5, + CMD_DLEVEL_6, + CMD_DLEVEL_7, + CMD_DLEVEL_8, + CMD_DLEVEL_9, + CMD_DLEVEL_10, + CMD_DLEVEL_11, + CMD_DLEVEL_12, + CMD_DLEVEL_13, + CMD_DLEVEL_14, + CMD_DLEVEL_15, + CMD_DLEVEL_16, + CMD_DLEVEL_JUNK, + CMD_DLEVEL_END, + CMD_HEALOTHER, + CMD_STRING, + CMD_SETSTR, + CMD_SETMAG, + CMD_SETDEX, + CMD_SETVIT, + CMD_RETOWN, + CMD_SPELLXYD, + CMD_ITEMEXTRA, + CMD_SYNCPUTITEM, + CMD_KILLGOLEM, + CMD_SYNCQUEST, + CMD_ENDSHIELD, + CMD_AWAKEGOLEM, + CMD_NOVA, + CMD_SETSHIELD, + CMD_REMSHIELD, + FAKE_CMD_SETID, + FAKE_CMD_DROPID, + NUM_CMDS, } _cmd_id; typedef enum _talker_id {