diff --git a/.travis.yml b/.travis.yml index 1bec6b994..7dc3a4f22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: cpp os: - linux - osx - + osx_image: xcode10.3 notifications: diff --git a/Source/automap.cpp b/Source/automap.cpp index 22b791995..d2ec2247f 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -531,10 +531,12 @@ WORD GetAutomapType(int x, int y, BOOL view) } rv = automaptype[(BYTE)dungeon[x][y]]; - if (rv == 7 - && GetAutomapType(x - 1, y, FALSE) & (MAPFLAG_HORZARCH << 8) - && GetAutomapType(x, y - 1, FALSE) & (MAPFLAG_VERTARCH << 8)) { - rv = 1; + if (rv == 7) { + if ((GetAutomapType(x - 1, y, FALSE) >> 8) & MAPFLAG_HORZARCH) { + if ((GetAutomapType(x, y - 1, FALSE) >> 8) & MAPFLAG_VERTARCH) { + rv = 1; + } + } } return rv; } diff --git a/Source/capture.cpp b/Source/capture.cpp index 7f5fadfa2..b0583f534 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -77,8 +77,7 @@ static BOOL CapturePix(HANDLE hFile, WORD width, WORD height, WORD stride, BYTE BYTE *pBuffer, *pBufferEnd; pBuffer = (BYTE *)DiabloAllocPtr(2 * width); - while (height != 0) { - height--; + while (height--) { pBufferEnd = CaptureEnc(pixels, pBuffer, width); pixels += stride; writeSize = pBufferEnd - pBuffer; @@ -158,9 +157,9 @@ void CaptureScreen() success = CaptureHdr(hObject, SCREEN_WIDTH, SCREEN_HEIGHT); if (success) { success = CapturePix(hObject, SCREEN_WIDTH, SCREEN_HEIGHT, BUFFER_WIDTH, &gpBuffer[SCREENXY(0, 0)]); - if (success) { - success = CapturePal(hObject, palette); - } + } + if (success) { + success = CapturePal(hObject, palette); } unlock_buf(2); CloseHandle(hObject); diff --git a/Source/control.cpp b/Source/control.cpp index 616a08424..81c797160 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -139,10 +139,43 @@ const BYTE gbFontTransTbl[256] = { /* data */ char SpellITbl[MAX_SPELLS] = { - 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 28, 13, 12, 18, 16, 14, 18, 19, 11, 20, - 15, 21, 23, 24, 25, 22, 26, 29, 37, 38, - 39, 42, 41, 40, 10, 36, 30 + 1, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 28, + 13, + 12, + 18, + 16, + 14, + 18, + 19, + 11, + 20, + 15, + 21, + 23, + 24, + 25, + 22, + 26, + 29, + 37, + 38, + 39, + 42, + 41, + 40, + 10, + 36, + 30, }; int PanBtnPos[8][5] = { { PANEL_LEFT + 9, PANEL_TOP + 9, 71, 19, 1 }, // char button diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 184bc4030..7ac04e506 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -170,7 +170,7 @@ void CheckRportal() void CheckCursMove() { - int i, sx, sy, mx, my, tx, ty, px, py, xx, yy, mi; + int i, sx, sy, fx, fy, mx, my, tx, ty, px, py, xx, yy, mi; char bv; BOOL flipflag, flipx, flipy; @@ -201,9 +201,14 @@ void CheckCursMove() sx -= ScrollInfo._sxoff; sy -= ScrollInfo._syoff; + fx = plr[myplr]._pVar6 >> 8; + fy = plr[myplr]._pVar7 >> 8; + fx -= (plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8; + fy -= (plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8; + if (ScrollInfo._sdir != 0) { - sx += ((plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8) - (plr[myplr]._pVar6 >> 8); - sy += ((plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8) - (plr[myplr]._pVar7 >> 8); + sx -= fx; + sy -= fy; } if (sx < 0) { diff --git a/Source/debug.cpp b/Source/debug.cpp index ae843bb30..1ed3720e7 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -116,7 +116,7 @@ void StoresCheat() numpremium = 0; - for (i = 0; i < 6; i++) + for (i = 0; i < SMITH_PREMIUM_ITEMS; i++) premiumitem[i]._itype = -1; SpawnPremium(30); diff --git a/Source/doom.cpp b/Source/doom.cpp index 8bb9d080a..03d7fe2ec 100644 --- a/Source/doom.cpp +++ b/Source/doom.cpp @@ -37,7 +37,7 @@ int doom_get_frame_from_time() void doom_alloc_cel() { - pDoomCel = DiabloAllocPtr(229376); + pDoomCel = DiabloAllocPtr(0x38000); } void doom_cleanup() diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 5fc1ac565..cfa0eb0c0 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -263,13 +263,11 @@ static void DRLG_L1Shadows() static int DRLG_PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int noquad, int ldir) { - int xx, yy, sx, sy; - int ii, i, t, found; - int numt; + int sx, sy, sw, sh, xx, yy, i, ii, numt, found, t; BOOL abort; - int sw = miniset[0]; - int sh = miniset[1]; + sw = miniset[0]; + sh = miniset[1]; if (tmax - tmin == 0) numt = 1; @@ -900,7 +898,7 @@ static void L5makeDungeon() static void L5makeDmt() { - int i, j, dmtx, dmty; + int i, j, idx, val, dmtx, dmty; for (j = 0; j < DMAXY; j++) { for (i = 0; i < DMAXX; i++) { @@ -910,11 +908,12 @@ static void L5makeDmt() for (j = 0, dmty = 1; dmty <= 77; j++, dmty += 2) { for (i = 0, dmtx = 1; dmtx <= 77; i++, dmtx += 2) { - int val = L5dungeon[dmtx + 1][dmty + 1]; - val = 2 * val + L5dungeon[dmtx][dmty + 1]; - val = 2 * val + L5dungeon[dmtx + 1][dmty]; - val = 2 * val + L5dungeon[dmtx][dmty]; - dungeon[i][j] = L5ConvTbl[val]; + val = 8 * L5dungeon[dmtx + 1][dmty + 1] + + 4 * L5dungeon[dmtx][dmty + 1] + + 2 * L5dungeon[dmtx + 1][dmty] + + L5dungeon[dmtx][dmty]; + idx = L5ConvTbl[val]; + dungeon[i][j] = idx; } } } diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 9e39fd6cd..9097dce61 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -384,15 +384,16 @@ void DRLG_L4SetSPRoom(int rx1, int ry1) static void L4makeDmt() { - int i, j, val, dmtx, dmty; + int i, j, idx, val, dmtx, dmty; for (j = 0, dmty = 1; dmty <= 77; j++, dmty += 2) { for (i = 0, dmtx = 1; dmtx <= 77; i++, dmtx += 2) { - val = L4dungeon[dmtx + 1][dmty + 1]; - val = 2 * val + L4dungeon[dmtx][dmty + 1]; - val = 2 * val + L4dungeon[dmtx + 1][dmty]; - val = 2 * val + L4dungeon[dmtx][dmty]; - dungeon[i][j] = L4ConvTbl[val]; + val = 8 * L4dungeon[dmtx + 1][dmty + 1] + + 4 * L4dungeon[dmtx][dmty + 1] + + 2 * L4dungeon[dmtx + 1][dmty] + + L4dungeon[dmtx][dmty]; + idx = L4ConvTbl[val]; + dungeon[i][j] = idx; } } } @@ -1314,7 +1315,7 @@ static void L4roomGen(int x, int y, int w, int h, int dir) static void L4firstRoom() { - int x, y, w, h, rndx, rndy, xmin, xmax, ymin, ymax; + int x, y, w, h, rndx, rndy, xmin, xmax, ymin, ymax, tx, ty; if (currlevel != 16) { if (currlevel == quests[QTYPE_WARLRD]._qlevel && quests[QTYPE_WARLRD]._qactive) { @@ -1337,7 +1338,8 @@ static void L4firstRoom() xmax = 19 - w; rndx = random_(0, xmax - xmin + 1) + xmin; if (rndx + w > 19) { - x = 19 - w + 1; + tx = w + rndx - 19; + x = rndx - tx + 1; } else { x = rndx; } @@ -1345,7 +1347,8 @@ static void L4firstRoom() ymax = 19 - h; rndy = random_(0, ymax - ymin + 1) + ymin; if (rndy + h > 19) { - y = 19 - h + 1; + ty = h + rndy - 19; + y = rndy - ty + 1; } else { y = rndy; } @@ -1374,17 +1377,16 @@ void L4SaveQuads() { int i, j, x, y; - y = 0; + x = l4holdx; + y = l4holdy; + for (j = 0; j < 14; j++) { - x = 0; for (i = 0; i < 14; i++) { - dflags[i + l4holdx][j + l4holdy] = 1; - dflags[DMAXX - 1 - x - l4holdx][j + l4holdy] = 1; - dflags[i + l4holdx][DMAXY - 1 - y - l4holdy] = 1; - dflags[DMAXX - 1 - x - l4holdx][DMAXY - 1 - y - l4holdy] = 1; - x++; + dflags[i + x][j + y] = 1; + dflags[DMAXX - 1 - i - x][j + y] = 1; + dflags[i + x][DMAXY - 1 - j - y] = 1; + dflags[DMAXX - 1 - i - x][DMAXY - 1 - j - y] = 1; } - y++; } } diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index cb9bc137f..efb8a0ccb 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -174,7 +174,7 @@ void gmenu_draw() void gmenu_draw_menu_item(TMenuItem *pItem, int y) { - DWORD x, w, nSteps, step, pos, t; + DWORD w, x, nSteps, step, pos, t; t = y - 2; w = gmenu_get_lfont(pItem); if (pItem->dwFlags & GMENU_SLIDER) { diff --git a/Source/init.cpp b/Source/init.cpp index 9e381bcce..aba2d7076 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -155,7 +155,7 @@ void init_create_window(int nCmdShow) wcex.hIcon = LoadIcon(ghInst, MAKEINTRESOURCE(IDI_ICON1)); wcex.hCursor = LoadCursor(0, IDC_ARROW); wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wcex.lpszMenuName = "DIABLO"; + wcex.lpszMenuName = GAME_NAME; wcex.lpszClassName = "DIABLO"; wcex.hIconSm = (HICON)LoadImage(ghInst, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); if (!RegisterClassEx(&wcex)) @@ -168,7 +168,7 @@ void init_create_window(int nCmdShow) nHeight = SCREEN_HEIGHT; else nHeight = GetSystemMetrics(SM_CYSCREEN); - hWnd = CreateWindowEx(0, "DIABLO", "DIABLO", WS_POPUP, 0, 0, nWidth, nHeight, NULL, NULL, ghInst, NULL); + hWnd = CreateWindowEx(0, "DIABLO", GAME_NAME, WS_POPUP, 0, 0, nWidth, nHeight, NULL, NULL, ghInst, NULL); if (!hWnd) app_fatal("Unable to create main window"); ShowWindow(hWnd, SW_SHOWNORMAL); // nCmdShow used only in beta: ShowWindow(hWnd, nCmdShow) diff --git a/Source/inv.cpp b/Source/inv.cpp index 03ffc4458..0b06f20cf 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -171,6 +171,7 @@ void DrawInv() { BOOL invtest[NUM_INV_GRID_ELEM]; int frame, frame_width, colour, screen_x, screen_y, i, j, ii; + BYTE *pBuff; CelDraw(RIGHT_PANEL_X, 351 + SCREEN_Y, pInvCels, 1, 320); @@ -301,11 +302,10 @@ void DrawInv() light_table_index = 0; cel_transparency_active = 1; - CelClippedBlitLightTrans( - frame_width == INV_SLOT_SIZE_PX - ? &gpBuffer[SCREENXY(RIGHT_PANEL_X + 197, SCREEN_Y)] - : &gpBuffer[SCREENXY(RIGHT_PANEL_X + 183, SCREEN_Y)], - pCursCels, frame, frame_width, 0, 8); + pBuff = frame_width == INV_SLOT_SIZE_PX + ? &gpBuffer[SCREENXY(RIGHT_PANEL_X + 197, SCREEN_Y)] + : &gpBuffer[SCREENXY(RIGHT_PANEL_X + 183, SCREEN_Y)]; + CelClippedBlitLightTrans(pBuff, pCursCels, frame, frame_width, 0, 8); cel_transparency_active = 0; } @@ -362,6 +362,7 @@ void DrawInv() } for (i = 0; i < NUM_INV_GRID_ELEM; i++) { + invtest[i] = FALSE; if (plr[myplr].InvGrid[i] != 0) { InvDrawSlotBack( InvRect[i + SLOTXY_INV_FIRST].X + SCREEN_X, @@ -439,10 +440,11 @@ void DrawInvBelt() CelBlitOutline(colour, InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, pCursCels, frame, frame_width, 0, 8); } - if (plr[myplr].SpdList[i]._iStatFlag) + if (plr[myplr].SpdList[i]._iStatFlag) { CelClippedDraw(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, pCursCels, frame, frame_width, 0, 8); - else + } else { CelDrawLightRed(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X, InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1, pCursCels, frame, frame_width, 0, 8, 1); + } if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable && plr[myplr].SpdList[i]._iStatFlag @@ -473,10 +475,10 @@ BOOL AutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag) xx = 0; } for (i = 0; i < sx && done; i++) { - if (xx < 10) { - done = plr[pnum].InvGrid[xx + yy] == 0; - } else { + if (xx >= 10) { done = FALSE; + } else { + done = plr[pnum].InvGrid[xx + yy] == 0; } xx++; } @@ -528,10 +530,10 @@ BOOL SpecialAutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag) xx = 0; } for (i = 0; i < sx && done; i++) { - if (xx < 10) { - done = plr[pnum].InvGrid[xx + yy] == 0; - } else { + if (xx >= 10) { done = FALSE; + } else { + done = plr[pnum].InvGrid[xx + yy] == 0; } xx++; } @@ -1116,7 +1118,7 @@ void CheckInvCut(int pnum, int mx, int my) int r; BOOL done; char ii; - int iv, i, j, offs; + int iv, i, j, offs, ig; if (plr[pnum]._pmode > PM_WALK3) { return; @@ -1129,7 +1131,6 @@ void CheckInvCut(int pnum, int mx, int my) done = FALSE; - // TODO: this loop is compiled differently (via InvRect pointers) for (r = 0; (DWORD)r < NUM_XY_SLOTS && !done; r++) { // check which inventory rectangle the mouse is in, if any if (mx >= InvRect[r].X @@ -1209,7 +1210,8 @@ void CheckInvCut(int pnum, int mx, int my) } if (r >= SLOTXY_INV_FIRST && r <= SLOTXY_INV_LAST) { - ii = plr[pnum].InvGrid[r - SLOTXY_INV_FIRST]; + ig = r - SLOTXY_INV_FIRST; + ii = plr[pnum].InvGrid[ig]; if (ii) { iv = ii; if (ii <= 0) { @@ -1273,10 +1275,10 @@ void inv_update_rem_item(int pnum, BYTE iv) plr[pnum].InvBody[iv]._itype = ITYPE_NONE; } - if (plr[pnum]._pmode == PM_DEATH) { - CalcPlrInv(pnum, FALSE); - } else { + if (plr[pnum]._pmode != PM_DEATH) { CalcPlrInv(pnum, TRUE); + } else { + CalcPlrInv(pnum, FALSE); } } @@ -1727,7 +1729,9 @@ BOOL CanPut(int x, int y) return FALSE; } - if (!currlevel && (dMonster[x][y] || dMonster[x + 1][y + 1])) + if (currlevel == 0 && dMonster[x][y] != 0) + return FALSE; + if (currlevel == 0 && dMonster[x + 1][y + 1] != 0) return FALSE; return TRUE; @@ -1775,6 +1779,7 @@ int InvPutItem(int pnum, int x, int y) int d, ii; int i, j, l; int xx, yy; + int xp, yp; if (numitems >= 127) return -1; @@ -1803,13 +1808,13 @@ int InvPutItem(int pnum, int x, int y) done = FALSE; for (l = 1; l < 50 && !done; l++) { for (j = -l; j <= l && !done; j++) { - yy = j + plr[pnum].WorldY; + yp = j + plr[pnum].WorldY; for (i = -l; i <= l && !done; i++) { - xx = i + plr[pnum].WorldX; - if (CanPut(xx, yy)) { + xp = i + plr[pnum].WorldX; + if (CanPut(xp, yp)) { done = TRUE; - x = xx; - y = yy; + x = xp; + y = yp; } } } @@ -1843,6 +1848,7 @@ int SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, in int d, ii; int i, j, l; int xx, yy; + int xp, yp; if (numitems >= 127) return -1; @@ -1871,13 +1877,13 @@ int SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, in done = FALSE; for (l = 1; l < 50 && !done; l++) { for (j = -l; j <= l && !done; j++) { - yy = j + plr[pnum].WorldY; + yp = j + plr[pnum].WorldY; for (i = -l; i <= l && !done; i++) { - xx = i + plr[pnum].WorldX; - if (CanPut(xx, yy)) { + xp = i + plr[pnum].WorldX; + if (CanPut(xp, yp)) { done = TRUE; - x = xx; - y = yy; + x = xp; + y = yp; } } } @@ -2110,8 +2116,8 @@ BOOL UseInvItem(int pnum, int cii) if (cii <= 46) { c = cii - 7; - speedlist = FALSE; Item = &plr[pnum].InvList[c]; + speedlist = FALSE; } else { if (talkflag) return TRUE; @@ -2181,6 +2187,7 @@ BOOL UseInvItem(int pnum, int cii) if (Item->_iMiscId == IMISC_SCROLLT && currlevel == 0 && !spelldata[Item->_iSpell].sTownSpell) { return TRUE; } + idata = ItemCAnimTbl[Item->_iCurs]; if (Item->_iMiscId == IMISC_BOOK) PlaySFX(IS_RBOOK); @@ -2191,7 +2198,10 @@ BOOL UseInvItem(int pnum, int cii) if (speedlist) { RemoveSpdBarItem(pnum, c); - } else if (plr[pnum].InvList[c]._iMiscId != IMISC_MAPOFDOOM) { + return TRUE; + } else { + if (plr[pnum].InvList[c]._iMiscId == IMISC_MAPOFDOOM) + return TRUE; RemoveInvItem(pnum, c); } diff --git a/Source/itemdat.cpp b/Source/itemdat.cpp index d13316e94..394764418 100644 --- a/Source/itemdat.cpp +++ b/Source/itemdat.cpp @@ -1,6 +1,6 @@ #include "diablo.h" -ItemDataStruct AllItemsList[157] = { +ItemDataStruct AllItemsList[] = { // clang-format off // iRnd, iClass, iLoc, iCurs, itype, iItemId, iName, iSName, iMinMLvl, iDurability, iMinDam, iMaxDam, iMinAC, iMaxAC, iMinStr, iMinMag, iMinDex, iFlags, iMiscId, iSpell, iUsable, iValue, iMaxValue { IDROP_REGULAR, ICLASS_GOLD, ILOC_UNEQUIPABLE, ICURS_GOLD, 11, UITYPE_NONE, "Gold", NULL, 1, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_NONE, SPL_NULL, TRUE, 0, 0 }, @@ -159,11 +159,11 @@ ItemDataStruct AllItemsList[157] = { { IDROP_REGULAR, ICLASS_MISC, ILOC_RING, ICURS_RING, 12, UITYPE_RING, "Ring", "Ring", 15, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_RING, SPL_NULL, FALSE, 1000, 1000 }, { IDROP_REGULAR, ICLASS_MISC, ILOC_AMULET, ICURS_AMULET, 13, UITYPE_AMULET, "Amulet", "Amulet", 8, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_AMULET, SPL_NULL, FALSE, 1200, 1200 }, { IDROP_REGULAR, ICLASS_MISC, ILOC_AMULET, ICURS_AMULET, 13, UITYPE_AMULET, "Amulet", "Amulet", 16, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_AMULET, SPL_NULL, FALSE, 1200, 1200 }, - { IDROP_NEVER, ICLASS_NONE, ILOC_INVALID, ICURS_POTION_OF_FULL_MANA, 0, UITYPE_NONE, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_NONE, SPL_NULL, FALSE, 0, 0 } + { IDROP_NEVER, ICLASS_NONE, ILOC_INVALID, ICURS_POTION_OF_FULL_MANA, 0, UITYPE_NONE, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_NONE, SPL_NULL, FALSE, 0, 0 }, // clang-format on }; -const PLStruct PL_Prefix[84] = { +const PLStruct PL_Prefix[] = { // clang-format off // PLName, PLPower, PLParam1, PLParam2, PLMinLvl, PLIType, PLGOE, PLDouble, PLOk, PLMinVal, PLMaxVal, PLMultVal { "Tin", IPL_TOHIT_CURSE, 6, 10, 3, PLT_WEAP | PLT_BOW | PLT_MISC, 0, TRUE, FALSE, 0, 0, -3 }, @@ -249,11 +249,11 @@ const PLStruct PL_Prefix[84] = { { "Bountiful", IPL_CHARGES, 3, 3, 9, PLT_STAFF , 0, FALSE, TRUE, 3000, 3000, 3 }, { "Flaming", IPL_FIREDAM, 1, 10, 7, PLT_WEAP | PLT_STAFF , 0, FALSE, TRUE, 5000, 5000, 2 }, { "Lightning", IPL_LIGHTDAM, 2, 20, 18, PLT_WEAP | PLT_STAFF , 0, FALSE, TRUE, 10000, 10000, 2 }, - { "", IPL_INVALID, 0, 0, 0, 0 , 0, FALSE, FALSE, 0, 0, 0 } + { "", IPL_INVALID, 0, 0, 0, 0 , 0, FALSE, FALSE, 0, 0, 0 }, // clang-format on }; -const PLStruct PL_Suffix[96] = { +const PLStruct PL_Suffix[] = { // clang-format off // PLName, PLPower, PLParam1, PLParam2, PLMinLvl, PLIType, PLGOE, PLDouble, PLOk, PLMinVal, PLMaxVal, PLMultVal { "quality", IPL_DAMMOD, 1, 2, 2, PLT_WEAP | PLT_BOW , 0, FALSE, TRUE, 100, 200, 2 }, @@ -351,11 +351,11 @@ const PLStruct PL_Suffix[96] = { { "stability", IPL_FASTRECOVER, 2, 2, 10, PLT_ARMO | PLT_MISC, 0, FALSE, TRUE, 4000, 4000, 4 }, { "harmony", IPL_FASTRECOVER, 3, 3, 20, PLT_ARMO | PLT_MISC, 0, FALSE, TRUE, 8000, 8000, 8 }, { "blocking", IPL_FASTBLOCK, 1, 1, 5, PLT_SHLD , 0, FALSE, TRUE, 4000, 4000, 4 }, - { "", IPL_INVALID, 0, 0, 0, 0 , 0, FALSE, FALSE, 0, 0, 0 } + { "", IPL_INVALID, 0, 0, 0, 0 , 0, FALSE, FALSE, 0, 0, 0 }, // clang-format on }; -const UItemStruct UniqueItemList[91] = { +const UItemStruct UniqueItemList[] = { // clang-format off // UIName, UIItemId, UIMinLvl, UINumPL, UIValue, UIPower1, UIParam1, UIParam2, UIPower2, UIParam3, UIParam4, UIPower3, UIParam5, UIParam6, UIPower4, UIParam7, UIParam8, UIPower5, UIParam9, UIParam10, UIPower6, UIParam11, UIParam12 { "The Butcher's Cleaver", UITYPE_CLEAVER, 1, 3, 3650, IPL_STR, 10, 10, IPL_SETDAM, 4, 24, IPL_SETDUR, 10, 10, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 }, @@ -448,6 +448,6 @@ const UItemStruct UniqueItemList[91] = { { "The Bleeder", UITYPE_RING, 2, 4, 8500, IPL_MAGICRES, 20, 20, IPL_MANA, 30, 30, IPL_LIFE_CURSE, 10, 10, IPL_INVCURS, 8, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 }, { "Constricting Ring", UITYPE_RING, 5, 3, 62000, IPL_ALLRES, 75, 75, IPL_DRAINLIFE, 0, 0, IPL_INVCURS, 14, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 }, { "Ring of Engagement", UITYPE_RING, 11, 5, 12476, IPL_GETHIT, 1, 2, IPL_THORNS, 1, 3, IPL_SETAC, 5, 5, IPL_TARGAC, 4, 12, IPL_INVCURS, 13, 0, IPL_TOHIT, 0, 0 }, - { "", UITYPE_INVALID, 0, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 } + { "", UITYPE_INVALID, 0, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0, IPL_TOHIT, 0, 0 }, // clang-format on }; diff --git a/Source/itemdat.h b/Source/itemdat.h index 00f178608..e84ce0c9f 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -2,9 +2,9 @@ #ifndef __ITEMDAT_H__ #define __ITEMDAT_H__ -extern ItemDataStruct AllItemsList[157]; -extern const PLStruct PL_Prefix[84]; -extern const PLStruct PL_Suffix[96]; -extern const UItemStruct UniqueItemList[91]; +extern ItemDataStruct AllItemsList[]; +extern const PLStruct PL_Prefix[]; +extern const PLStruct PL_Suffix[]; +extern const UItemStruct UniqueItemList[]; #endif /* __ITEMDAT_H__ */ diff --git a/Source/items.cpp b/Source/items.cpp index d9d4a443c..cbbd04faa 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1126,6 +1126,8 @@ void GetBookSpell(int i, int lvl) if (gbMaxPlayers == 1) { if (s == SPL_RESURRECT) s = SPL_TELEKINESIS; + } + if (gbMaxPlayers == 1) { if (s == SPL_HEALOTHER) s = SPL_FLARE; } @@ -1309,7 +1311,7 @@ void GetItemAttrs(int i, int idata, int lvl) item[i]._iPrePower = -1; item[i]._iSufPower = -1; - if (AllItemsList[idata].iMiscId == IMISC_BOOK) + if (item[i]._iMiscId == IMISC_BOOK) GetBookSpell(i, lvl); if (item[i]._itype == ITYPE_GOLD) { @@ -1319,7 +1321,6 @@ void GetItemAttrs(int i, int idata, int lvl) rndv = 5 * (currlevel + 16) + random_(21, 10 * (currlevel + 16)); if (gnDifficulty == DIFF_HELL) rndv = 5 * (currlevel + 32) + random_(21, 10 * (currlevel + 32)); - if (leveltype == DTYPE_HELL) rndv += rndv >> 3; if (rndv > GOLD_MAX_LIMIT) @@ -2049,14 +2050,17 @@ void SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood, if (item[ii]._iMiscId != IMISC_UNIQUE) { iblvl = -1; - if (random_(32, 100) > 10 && random_(33, 100) > lvl || (iblvl = lvl, lvl == -1)) { - - if (item[ii]._iMiscId != IMISC_STAFF || (iblvl = lvl, lvl == -1)) { - if (item[ii]._iMiscId != IMISC_RING || (iblvl = lvl, lvl == -1)) { - if (item[ii]._iMiscId == IMISC_AMULET) - iblvl = lvl; - } - } + if (random_(32, 100) <= 10 || random_(33, 100) <= lvl) { + iblvl = lvl; + } + if (iblvl == -1 && item[ii]._iMiscId == IMISC_STAFF) { + iblvl = lvl; + } + if (iblvl == -1 && item[ii]._iMiscId == IMISC_RING) { + iblvl = lvl; + } + if (iblvl == -1 && item[ii]._iMiscId == IMISC_AMULET) { + iblvl = lvl; } if (onlygood) iblvl = lvl; @@ -2339,9 +2343,9 @@ void SpawnQuestItem(int itemid, int x, int y, int randarea, int selflag) SetupItem(i); item[i]._iPostDraw = TRUE; if (selflag) { - item[i]._iAnimFlag = FALSE; item[i]._iSelFlag = selflag; item[i]._iAnimFrame = item[i]._iAnimLen; + item[i]._iAnimFlag = FALSE; } numitems++; } @@ -3393,20 +3397,20 @@ void SpawnSmith(int lvl) { int i, iCnt, idata; - iCnt = random_(50, 10) + 10; + iCnt = random_(50, SMITH_ITEMS - 10) + 10; for (i = 0; i < iCnt; i++) { do { item[0]._iSeed = GetRndSeed(); SetRndSeed(item[0]._iSeed); idata = RndSmithItem(lvl) - 1; GetItemAttrs(0, idata, lvl); - } while (item[0]._iIvalue > 140000); + } while (item[0]._iIvalue > SMITH_MAX_VALUE); smithitem[i] = item[0]; smithitem[i]._iCreateInfo = lvl | 0x400; smithitem[i]._iIdentified = TRUE; smithitem[i]._iStatFlag = StoreStatOk(&smithitem[i]); } - for (i = iCnt; i < 20; i++) + for (i = iCnt; i < SMITH_ITEMS; i++) smithitem[i]._itype = ITYPE_NONE; SortSmith(); @@ -3472,7 +3476,7 @@ void SpawnOnePremium(int i, int plvl) itype = RndPremiumItem(plvl >> 2, plvl) - 1; GetItemAttrs(0, itype, plvl); GetItemBonus(0, itype, plvl >> 1, plvl, 1); - } while (item[0]._iIvalue > 140000); + } while (item[0]._iIvalue > SMITH_MAX_PREMIUM_VALUE); premiumitem[i] = item[0]; premiumitem[i]._iCreateInfo = plvl | 0x800; premiumitem[i]._iIdentified = TRUE; @@ -3484,12 +3488,12 @@ void SpawnPremium(int lvl) { int i; - if (numpremium < 6) { - for (i = 0; i < 6; i++) { + if (numpremium < SMITH_PREMIUM_ITEMS) { + for (i = 0; i < SMITH_PREMIUM_ITEMS; i++) { if (premiumitem[i]._itype == ITYPE_NONE) SpawnOnePremium(i, premiumlevel + premiumlvladd[i]); } - numpremium = 6; + numpremium = SMITH_PREMIUM_ITEMS; } while (premiumlevel < lvl) { premiumlevel++; @@ -3822,8 +3826,8 @@ void RecreatePremiumItem(int ii, int idx, int plvl, int iseed) GetItemAttrs(ii, itype, plvl); GetItemBonus(ii, itype, plvl >> 1, plvl, 1); - item[ii]._iCreateInfo = plvl | 0x800; item[ii]._iSeed = iseed; + item[ii]._iCreateInfo = plvl | 0x800; item[ii]._iIdentified = TRUE; } @@ -3835,9 +3839,8 @@ void RecreateBoyItem(int ii, int idx, int lvl, int iseed) itype = RndBoyItem(lvl) - 1; GetItemAttrs(ii, itype, lvl); GetItemBonus(ii, itype, lvl, 2 * lvl, 1); - - item[ii]._iCreateInfo = lvl | 0x1000; item[ii]._iSeed = iseed; + item[ii]._iCreateInfo = lvl | 0x1000; item[ii]._iIdentified = TRUE; } @@ -3849,9 +3852,9 @@ void RecreateWitchItem(int ii, int idx, int lvl, int iseed) GetItemAttrs(ii, idx, lvl); } else { SetRndSeed(iseed); - iblvl = -1; itype = RndWitchItem(lvl) - 1; GetItemAttrs(ii, itype, lvl); + iblvl = -1; if (random_(51, 100) <= 5) iblvl = 2 * lvl; if (iblvl == -1 && item[ii]._iMiscId == IMISC_STAFF) @@ -3860,8 +3863,8 @@ void RecreateWitchItem(int ii, int idx, int lvl, int iseed) GetItemBonus(ii, itype, iblvl >> 1, iblvl, 1); } - item[ii]._iCreateInfo = lvl | 0x2000; item[ii]._iSeed = iseed; + item[ii]._iCreateInfo = lvl | 0x2000; item[ii]._iIdentified = TRUE; } @@ -3900,12 +3903,12 @@ void RecalcStoreStats() { int i; - for (i = 0; i < 20; i++) { + for (i = 0; i < SMITH_ITEMS; i++) { if (smithitem[i]._itype != ITYPE_NONE) { smithitem[i]._iStatFlag = StoreStatOk(&smithitem[i]); } } - for (i = 0; i < 6; i++) { + for (i = 0; i < SMITH_PREMIUM_ITEMS; i++) { if (premiumitem[i]._itype != ITYPE_NONE) { premiumitem[i]._iStatFlag = StoreStatOk(&premiumitem[i]); } @@ -3948,7 +3951,7 @@ void CreateSpellBook(int x, int y, int ispell, BOOL sendmsg, BOOL delta) itemavail[0] = itemavail[MAXITEMS - numitems - 1]; itemactive[numitems] = ii; while (!done) { - SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, 1, FALSE, delta); + SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, TRUE, FALSE, delta); if (item[ii]._iMiscId == IMISC_BOOK && item[ii]._iSpell == ispell) done = TRUE; } @@ -3973,7 +3976,7 @@ void CreateMagicArmor(int x, int y, int imisc, int icurs, BOOL sendmsg, BOOL del itemactive[numitems] = ii; idx = RndTypeItems(imisc, IMISC_NONE); while (!done) { - SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, 1, FALSE, delta); + SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, TRUE, FALSE, delta); if (item[ii]._iCurs == icurs) done = TRUE; else @@ -4000,7 +4003,7 @@ void CreateMagicWeapon(int x, int y, int imisc, int icurs, BOOL sendmsg, BOOL de itemactive[numitems] = ii; idx = RndTypeItems(imisc, IMISC_NONE); while (!done) { - SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, 1, FALSE, delta); + SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, TRUE, FALSE, delta); if (item[ii]._iCurs == icurs) done = TRUE; else diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 1e593e0df..b8cb69a27 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -152,7 +152,7 @@ void LoadGame(BOOL firstflag) numpremium = WLoad(); premiumlevel = WLoad(); - for (i = 0; i < 6; i++) + for (i = 0; i < SMITH_PREMIUM_ITEMS; i++) LoadPremium(i); automapflag = OLoad(); @@ -401,7 +401,7 @@ void SaveGame() WSave(numpremium); WSave(premiumlevel); - for (i = 0; i < 6; i++) + for (i = 0; i < SMITH_PREMIUM_ITEMS; i++) SavePremium(i); OSave(automapflag); diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index 317620e97..7302c26fb 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -16,7 +16,7 @@ void mainmenu_refresh_music() menu_music_track_id++; if (menu_music_track_id == NUM_MUSIC) menu_music_track_id = TMUSIC_TOWN; - } while (!menu_music_track_id || menu_music_track_id == TMUSIC_L1); + } while (menu_music_track_id == TMUSIC_TOWN || menu_music_track_id == TMUSIC_L1); #endif } diff --git a/Source/misdat.cpp b/Source/misdat.cpp index 5c5184981..bdc425f73 100644 --- a/Source/misdat.cpp +++ b/Source/misdat.cpp @@ -1,6 +1,6 @@ #include "diablo.h" -MissileData missiledata[68] = { +MissileData missiledata[] = { // clang-format off // mName, mAddProc, mProc, mDraw, mType, mResist, mFileNum, miSFX, mlSFX; { MIS_ARROW, &AddArrow, &MI_Arrow, TRUE, 0, 0, MFILE_ARROWS, -1, -1 }, @@ -70,11 +70,11 @@ MissileData missiledata[68] = { { MIS_WEAPEXP, &AddWeapexp, &MI_Weapexp, TRUE, 2, 0, MFILE_NONE, -1, -1 }, { MIS_RPORTAL, &AddRportal, &MI_Rportal, TRUE, 2, 0, MFILE_RPORTAL, LS_SENTINEL, LS_ELEMENTL }, { MIS_BOOM2, &AddBoom, &MI_Boom, TRUE, 2, 0, MFILE_FIREPLAR, -1, -1 }, - { MIS_DIABAPOCA, &AddDiabApoca, &MI_Dummy, FALSE, 2, 0, MFILE_NONE, -1, -1 } + { MIS_DIABAPOCA, &AddDiabApoca, &MI_Dummy, FALSE, 2, 0, MFILE_NONE, -1, -1 }, // clang-format on }; -MisFileData misfiledata[47] = { +MisFileData misfiledata[] = { // clang-format off // mAnimName, mAnimFAmt, mName, mFlags, mAnimData[16], mAnimDelay[16], mAnimLen[16], mAnimWidth[16], mAnimWidth2[16] { MFILE_ARROWS, 1, "Arrows", 2, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, @@ -123,6 +123,6 @@ MisFileData misfiledata[47] = { { MFILE_SCBSEXPC, 1, "Scbsexpc", 1, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, { MFILE_SCUBMISD, 1, "Scubmisd", 1, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, { MFILE_SCBSEXPD, 1, "Scbsexpd", 1, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, - { MFILE_NONE, 0, "", 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } + { MFILE_NONE, 0, "", 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, // clang-format on }; diff --git a/Source/misdat.h b/Source/misdat.h index d64cc993d..d32f8173c 100644 --- a/Source/misdat.h +++ b/Source/misdat.h @@ -2,7 +2,7 @@ #ifndef __MISDAT_H__ #define __MISDAT_H__ -extern MissileData missiledata[68]; -extern MisFileData misfiledata[47]; +extern MissileData missiledata[]; +extern MisFileData misfiledata[]; #endif /* __MISDAT_H__ */ diff --git a/Source/missiles.cpp b/Source/missiles.cpp index baacc9916..853222bf1 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -1284,10 +1284,11 @@ void AddRndTeleport(int mi, int sx, int sy, int dx, int dy, int midir, char mien if (random_(58, 2) == 1) r2 = -r2; - } while (nSolidTable[dPiece[r1 + sx][sy + r2]] || dObject[r1 + sx][sy + r2] || dMonster[r1 + sx][sy + r2]); + pn = dPiece[r1 + sx][sy + r2]; + } while (nSolidTable[pn] || dObject[r1 + sx][sy + r2] || dMonster[r1 + sx][sy + r2]); - missile[mi]._miVar1 = 0; missile[mi]._mirange = 2; + missile[mi]._miVar1 = 0; if (!setlevel || setlvlnum != SL_VILEBETRAYER) { missile[mi]._mix = sx + r1; missile[mi]._miy = sy + r2; @@ -3123,12 +3124,12 @@ void MI_Manashield(int i) plr[id]._pMana -= diff; plr[id]._pManaBase -= diff; } else { - missile[i]._miDelFlag = TRUE; plr[id]._pHitPoints = plr[id]._pMana + missile[i]._miVar1 - diff; plr[id]._pHPBase = plr[id]._pMana + missile[i]._miVar2 - diff; plr[id]._pMana = 0; plr[id]._pManaBase = plr[id]._pMaxManaBase - plr[id]._pMaxMana; missile[i]._mirange = 0; + missile[i]._miDelFlag = TRUE; if (plr[id]._pHitPoints < 0) SetPlayerHitPoints(id, 0); if (!(plr[id]._pHitPoints >> 6) && id == myplr) { diff --git a/Source/monstdat.cpp b/Source/monstdat.cpp index a5588b21b..2a71b3dfb 100644 --- a/Source/monstdat.cpp +++ b/Source/monstdat.cpp @@ -1,6 +1,6 @@ #include "diablo.h" -MonsterData monsterdata[112] = { +MonsterData monsterdata[] = { // clang-format off // width, mImage, GraphicType, has_special, sndfile, snd_special, has_trans, TransFile, Frames[6], Rate[6], mName, mMinDLvl, mMaxDLvl, mLevel, mMinHP, mMaxHP, mAi, mFlags, mInt, mHit, mAFNum, mMinDamage, mMaxDamage, mHit2, mAFNum2, mMinDamage2, mMaxDamage2, mArmorClass, mMonstClass, mMagicRes , mMagicRes2 , mTreasure, mSelFlag, mExp { 128, 799, "Monsters\\Zombie\\Zombie%c.CL2", FALSE, "Monsters\\Zombie\\Zombie%c%i.WAV", FALSE, FALSE, NULL, { 11, 24, 12, 6, 16, 0 }, { 4, 0, 0, 0, 0, 0 }, "Zombie", 1, 3, 1, 4, 7, AI_ZOMBIE, 0 , 0, 10, 8, 2, 5, 0, 0, 0, 0, 5, MC_UNDEAD, IMUNE_MAGIC | IMUNE_NULL_40, IMUNE_MAGIC | IMUNE_NULL_40, 0, 3, 54 }, @@ -114,7 +114,7 @@ MonsterData monsterdata[112] = { { 128, 2000, "Monsters\\Mage\\Mage%c.CL2", TRUE, "Monsters\\Mage\\Mage%c%i.WAV", FALSE, TRUE, "Monsters\\Mage\\Cnselbk.TRN", { 12, 1, 20, 8, 28, 20 }, { 0, 0, 0, 0, 0, 0 }, "Advocate", 30, 30, 30, 145, 145, AI_COUNSLR, MFLAG_CAN_OPEN_DOOR, 3, 120, 8, 15, 25, 0, 0, 0, 0, 0, MC_DEMON, IMUNE_MAGIC | RESIST_FIRE | IMUNE_LIGHTNING | IMUNE_NULL_40, IMUNE_MAGIC | IMUNE_FIRE | IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 7, 4968 }, { 96, 386, "Monsters\\Golem\\Golem%c.CL2", TRUE, "Monsters\\Golem\\Golm%c%i.WAV", FALSE, FALSE, NULL, { 0, 16, 12, 0, 12, 20 }, { 0, 0, 0, 0, 0, 0 }, "Golem", 0, 0, 12, 1, 1, AI_GOLUM, MFLAG_CAN_OPEN_DOOR, 0, 0, 7, 1, 1, 0, 0, 0, 0, 1, MC_DEMON, 0 , 0 , 0, 0, 0 }, { 160, 2000, "Monsters\\Diablo\\Diablo%c.CL2", TRUE, "Monsters\\Diablo\\Diablo%c%i.WAV", TRUE, FALSE, NULL, { 16, 6, 16, 6, 16, 16 }, { 0, 0, 0, 0, 0, 0 }, "The Dark Lord", 50, 50, 30, 1666, 1666, AI_DIABLO, MFLAG_KNOCKBACK | MFLAG_SEARCH | MFLAG_CAN_OPEN_DOOR, 3, 220, 4, 30, 60, 0, 11, 0, 0, 70, MC_DEMON, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 7, 31666 }, - { 128, 1060, "Monsters\\DarkMage\\Dmage%c.CL2", TRUE, "Monsters\\DarkMage\\Dmag%c%i.WAV", FALSE, FALSE, NULL, { 6, 1, 21, 6, 23, 18 }, { 0, 0, 0, 0, 0, 0 }, "The Arch-Litch Malignus", 30, 30, 30, 160, 160, AI_COUNSLR, MFLAG_CAN_OPEN_DOOR, 3, 120, 8, 20, 40, 0, 0, 0, 0, 70, MC_DEMON, RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, IMUNE_MAGIC | IMUNE_FIRE | IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 7, 4968 } + { 128, 1060, "Monsters\\DarkMage\\Dmage%c.CL2", TRUE, "Monsters\\DarkMage\\Dmag%c%i.WAV", FALSE, FALSE, NULL, { 6, 1, 21, 6, 23, 18 }, { 0, 0, 0, 0, 0, 0 }, "The Arch-Litch Malignus", 30, 30, 30, 160, 160, AI_COUNSLR, MFLAG_CAN_OPEN_DOOR, 3, 120, 8, 20, 40, 0, 0, 0, 0, 70, MC_DEMON, RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, IMUNE_MAGIC | IMUNE_FIRE | IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 7, 4968 }, // clang-format on }; @@ -139,22 +139,122 @@ char MonstConvTbl[128] = { * 1 = Avalible in retail and shareware * 2 = avalible in retail only */ -BYTE MonstAvailTbl[112] = { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, - 2, 2, 2, 0, 2, 2, 2, 2, 1, 1, - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, - 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, - 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, - 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, - 0, 0 +BYTE MonstAvailTbl[] = { + 1, // Zombie + 1, // Ghoul + 1, // Rotting Carcass + 1, // Black Death + 1, // Fallen One + 1, // Carver + 1, // Devil Kin + 1, // Dark One + 1, // Skeleton + 1, // Corpse Axe + 1, // Burning Dead + 1, // Horror + 1, // Fallen One + 1, // Carver + 1, // Devil Kin + 1, // Dark One + 1, // Scavenger + 1, // Plague Eater + 1, // Shadow Beast + 1, // Bone Gasher + 1, // Skeleton + 1, // Corpse Bow + 1, // Burning Dead + 1, // Horror + 1, // Skeleton Captain + 1, // Corpse Captain + 1, // Burning Dead Captain + 1, // Horror Captain + 0, // Invisible Lord + 2, // Hidden + 2, // Stalker + 2, // Unseen + 2, // Illusion Weaver + 0, // Lord Sayter + 2, // Flesh Clan + 2, // Stone Clan + 2, // Fire Clan + 2, // Night Clan + 1, // Fiend + 1, // Blink + 1, // Gloom + 1, // Familiar + 2, // Flesh Clan + 2, // Stone Clan + 2, // Fire Clan + 2, // Night Clan + 2, // Acid Beast + 2, // Poison Spitter + 2, // Pit Beast + 2, // Lava Maw + 0, // Skeleton King + 0, // The Butcher + 2, // Overlord + 2, // Mud Man + 2, // Toad Demon + 2, // Flayed One + 0, // Wyrm + 0, // Cave Slug + 0, // Devil Wyrm + 0, // Devourer + 2, // Magma Demon + 2, // Blood Stone + 2, // Hell Stone + 2, // Lava Lord + 2, // Horned Demon + 2, // Mud Runner + 2, // Frost Charger + 2, // Obsidian Lord + 0, // Bone Demon (oldboned in Hellfire) + 0, // Red Death + 0, // Litch Demon + 0, // Undead Balrog + 0, // Incinerator + 0, // Flame Lord + 0, // Doom Fire + 0, // Hell Burner + 2, // Red Storm + 2, // Storm Rider + 2, // Storm Lord + 2, // Maelstorm + 2, // Devil Kin Brute + 2, // Winged-Demon + 2, // Gargoyle + 2, // Blood Claw + 2, // Death Wing + 2, // Slayer + 2, // Guardian + 2, // Vortex Lord + 2, // Balrog + 2, // Cave Viper + 2, // Fire Drake + 2, // Gold Viper + 2, // Azure Drake + 2, // Black Knight + 2, // Doom Guard + 2, // Steel Lord + 2, // Blood Knight + 0, // Unraveler + 0, // Hollow One + 0, // Pain Master + 0, // Reality Weaver + 2, // Succubus + 2, // Snow Witch + 2, // Hell Spawn + 2, // Soul Burner + 2, // Counselor + 2, // Magistrate + 2, // Cabalist + 2, // Advocate + 0, // Golem + 0, // The Dark Lord + 0, // The Arch-Litch Malignus }; -UniqMonstStruct UniqMonst[98] = { +UniqMonstStruct UniqMonst[] = { // clang-format off // mtype, mName, mTrnName, mlevel, mmaxhp, mAi, mint, mMinDamage, mMaxDamage, mMagicRes, mUnqAttr, mUnqVar1, mUnqVar2, mtalkmsg { MT_NGOATMC, "Gharbad the Weak", "BSDB", 4, 120, AI_GARBUD, 3, 8, 16, IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, QUEST_GARBUD1 }, @@ -254,6 +354,6 @@ UniqMonstStruct UniqMonst[98] = { { MT_SOLBRNR, "Fleshdancer", "GENERAL", 16, 999, AI_SUCC, 3, 30, 50, IMUNE_MAGIC | RESIST_FIRE | IMUNE_NULL_40, 0, 0, 0, 0 }, { MT_OBLORD, "Grimspike", "GENERAL", 19, 534, AI_SNEAK, 1, 25, 40, IMUNE_MAGIC | RESIST_FIRE | IMUNE_NULL_40, 3, 0, 0, 0 }, { MT_STORML, "Doomlock", "GENERAL", 28, 534, AI_SNEAK, 1, 35, 55, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 3, 0, 0, 0 }, - { -1, NULL, NULL, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0 } + { -1, NULL, NULL, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0 }, // clang-format on }; diff --git a/Source/monstdat.h b/Source/monstdat.h index 6922cb4db..9d0312692 100644 --- a/Source/monstdat.h +++ b/Source/monstdat.h @@ -2,9 +2,9 @@ #ifndef __MONSTDAT_H__ #define __MONSTDAT_H__ -extern MonsterData monsterdata[112]; +extern MonsterData monsterdata[]; extern char MonstConvTbl[128]; -extern BYTE MonstAvailTbl[112]; -extern UniqMonstStruct UniqMonst[98]; +extern BYTE MonstAvailTbl[]; +extern UniqMonstStruct UniqMonst[]; #endif /* __MONSTDAT_H__ */ diff --git a/Source/monster.cpp b/Source/monster.cpp index 323d07c07..69a7d7357 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -11,8 +11,7 @@ int nummonsters; BOOLEAN sgbSaveSoundOn; MonsterStruct monster[MAXMONSTERS]; int totalmonsters; -CMonster Monsters[16]; -// int END_Monsters_17; +CMonster Monsters[MAX_LVLMTYPES]; int monstimgtot; int uniquetrans; int nummtypes; @@ -93,7 +92,7 @@ void (*AiProc[])(int i) = { &MAI_Lazurus, &MAI_Lazhelp, &MAI_Lachdanan, - &MAI_Warlord + &MAI_Warlord, }; void InitMonsterTRN(int monst, BOOL special) @@ -233,7 +232,7 @@ void GetLevelMTypes() } nt = 0; - for (i = 0; i < 111; i++) { + for (i = 0; i < NUM_MTYPES; i++) { minl = 15 * monsterdata[i].mMinDLvl / 30 + 1; maxl = 15 * monsterdata[i].mMaxDLvl / 30 + 1; @@ -922,7 +921,7 @@ void InitMonsters() int numplacemonsters; int mtype; int numscattypes; - int scattertypes[111]; + int scattertypes[NUM_MTYPES]; numscattypes = 0; if (gbMaxPlayers != 1) @@ -932,11 +931,11 @@ void InitMonsters() AddMonster(1, 0, 0, 0, FALSE); AddMonster(1, 0, 0, 0, FALSE); AddMonster(1, 0, 0, 0, FALSE); + } #ifndef SPAWN - if (!setlevel && currlevel == 16) - LoadDiabMonsts(); + if (!setlevel && currlevel == 16) + LoadDiabMonsts(); #endif - } nt = numtrigs; if (currlevel == 15) nt = 1; @@ -1864,7 +1863,8 @@ void M_ChangeLightOffset(int monst) _myoff = 1; } - ChangeLightOff(monster[monst].mlid, _mxoff, _myoff * (ly >> 3)); + _myoff *= (ly >> 3); + ChangeLightOff(monster[monst].mlid, _mxoff, _myoff); } BOOL M_DoStand(int i) @@ -2620,8 +2620,8 @@ BOOL M_DoDeath(int i) else AddDead(monster[i]._mx, monster[i]._my, monster[i]._udeadval, (direction)monster[i]._mdir); - monster[i]._mDelFlag = TRUE; dMonster[monster[i]._mx][monster[i]._my] = 0; + monster[i]._mDelFlag = TRUE; M_UpdateLeader(i); } @@ -3020,8 +3020,9 @@ void MAI_Snake(int i) int pnum; int tmp; - if ((DWORD)i >= MAXMONSTERS) + if ((DWORD)i >= MAXMONSTERS) { app_fatal("MAI_Snake: Invalid monster %d", i); + } char pattern[6] = { 1, 1, 0, -1, -1, 0 }; Monst = monster + i; pnum = Monst->_menemy; @@ -3037,8 +3038,8 @@ void MAI_Snake(int i) if (abs(mx) < 3 && abs(my) < 3 && LineClearF1(PosOkMonst, i, Monst->_mx, Monst->_my, fx, fy) && Monst->_mVar1 != MM_CHARGE) { if (AddMissile(Monst->_mx, Monst->_my, fx, fy, md, MIS_RHINO, pnum, i, 0, 0) != -1) { PlayEffect(i, 0); + dMonster[Monst->_mx][Monst->_my] = -(i + 1); Monst->_mmode = MM_CHARGE; - dMonster[Monst->_mx][Monst->_my] = -1 - i; } } else if (Monst->_mVar1 == MM_DELAY || random_(106, 100) >= 35 - 2 * Monst->_mint) { if (md + pattern[Monst->_mgoalvar1] < 0) { @@ -4525,17 +4526,19 @@ void ProcessMonsters() Monst->_mAISeed = GetRndSeed(); } if (!(monster[mi]._mFlags & MFLAG_NOHEAL) && Monst->_mhitpoints < Monst->_mmaxhp && Monst->_mhitpoints >> 6 > 0) { - if (Monst->mLevel <= 1) { - Monst->_mhitpoints += Monst->mLevel; - } else { + if (Monst->mLevel > 1) { Monst->_mhitpoints += Monst->mLevel >> 1; + } else { + Monst->_mhitpoints += Monst->mLevel; } } mx = Monst->_mx; my = Monst->_my; #ifndef SPAWN - if (dFlags[mx][my] & BFLAG_VISIBLE && Monst->_msquelch == 0 && Monst->MType->mtype == MT_CLEAVER) { - PlaySFX(USFX_CLEAVER); + if (dFlags[mx][my] & BFLAG_VISIBLE && Monst->_msquelch == 0) { + if (Monst->MType->mtype == MT_CLEAVER) { + PlaySFX(USFX_CLEAVER); + } } #endif if (Monst->_mFlags & MFLAG_TARGETS_MONSTER) { diff --git a/Source/monster.h b/Source/monster.h index 8848b87ee..45d884df7 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -8,8 +8,7 @@ extern int monstactive[MAXMONSTERS]; extern int nummonsters; extern MonsterStruct monster[MAXMONSTERS]; extern int totalmonsters; -extern CMonster Monsters[16]; -// int END_Monsters_17; +extern CMonster Monsters[MAX_LVLMTYPES]; extern int monstimgtot; extern int uniquetrans; extern int nummtypes; diff --git a/Source/msg.cpp b/Source/msg.cpp index d381816bb..bac871d2e 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1695,8 +1695,9 @@ DWORD On_RESPAWNITEM(TCmd *pCmd, int pnum) if (gbBufferMsgs == 1) msg_send_packet(pnum, p, sizeof(*p)); else { - if (currlevel == plr[pnum].plrlevel && pnum != myplr) + if (currlevel == plr[pnum].plrlevel && pnum != myplr) { SyncPutItem(pnum, p->x, p->y, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff); + } PutItemRecord(p->dwSeed, p->wCI, p->wIndx); delta_put_item(p, p->x, p->y, plr[pnum].plrlevel); } diff --git a/Source/objects.cpp b/Source/objects.cpp index 4b927ae97..e2b608e56 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -454,7 +454,10 @@ BOOL TorchLocOK(int xp, int yp) if (dFlags[xp][yp] & BFLAG_POPULATED) return FALSE; - return nTrapTable[dPiece[xp][yp]] != FALSE; + if (nTrapTable[dPiece[xp][yp]] != FALSE) + return TRUE; + else + return FALSE; } void AddObjTraps() @@ -2633,8 +2636,8 @@ void OperateMushPatch(int pnum, int i) if (object[i]._oSelFlag != 0) { if (!deltaload) PlaySfxLoc(IS_CHEST, object[i]._ox, object[i]._oy); - object[i]._oAnimFrame++; object[i]._oSelFlag = 0; + object[i]._oAnimFrame++; if (!deltaload) { GetSuperItemLoc(object[i]._ox, object[i]._oy, x, y); SpawnQuestItem(IDI_MUSHROOM, x, y, 0, 0); diff --git a/Source/path.cpp b/Source/path.cpp index c1c949710..9988ca720 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -60,27 +60,27 @@ int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, while ((next_node = GetNextPath())) { // reached the end, success! if (next_node->x == dx && next_node->y == dy) - break; + { + current = next_node; + path_length = 0; + while (current->Parent) { + if (path_length >= 25) + break; + pnode_vals[path_length++] = path_directions[3 * (current->y - current->Parent->y) - current->Parent->x + 4 + current->x]; + current = current->Parent; + } + if (path_length != 25) { + for (i = 0; i < path_length; i++) + path[i] = pnode_vals[path_length - i - 1]; + return i; + } + return 0; + } // ran out of nodes, abort! if (!path_get_path(PosOk, PosOkArg, next_node, dx, dy)) return 0; } // frontier is empty, no path! - if (!next_node) - return 0; - current = next_node; - path_length = 0; - while (current->Parent) { - if (path_length >= 25) - break; - pnode_vals[path_length++] = path_directions[3 * (current->y - current->Parent->y) - current->Parent->x + 4 + current->x]; - current = current->Parent; - } - if (path_length != 25) { - for (i = 0; i < path_length; i++) - path[i] = pnode_vals[path_length - i - 1]; - return i; - } return 0; } diff --git a/Source/quests.cpp b/Source/quests.cpp index f27ecf456..21d1e3f23 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -32,7 +32,7 @@ QuestData questlist[MAXQUESTS] = { { 3, 3, DTYPE_CATHEDRAL, QTYPE_KING, 100, 1, 1, QUEST_KING2, "The Curse of King Leoric" }, { 2, -1, DTYPE_CAVES, QTYPE_PW, 100, 4, 0, QUEST_POISON3, "Poisoned Water Supply" }, { 6, -1, DTYPE_CATACOMBS, QTYPE_BONE, 100, 2, 0, QUEST_BONER, "The Chamber of Bone" }, - { 15, 15, DTYPE_CATHEDRAL, QTYPE_VB, 100, 5, 1, QUEST_VILE1, "Archbishop Lazarus" } + { 15, 15, DTYPE_CATHEDRAL, QTYPE_VB, 100, 5, 1, QUEST_VILE1, "Archbishop Lazarus" }, // clang-format on }; char questxoff[7] = { 0, -1, 0, -1, -2, -1, -2 }; @@ -66,10 +66,10 @@ void InitQuests() } } - initiatedQuests = 0; questlog = FALSE; ALLQUESTS = 1; WaterDone = 0; + initiatedQuests = 0; for (z = 0; z < MAXQUESTS; z++) { if (gbMaxPlayers <= 1 || questlist[z]._qflags & 1) { @@ -89,11 +89,11 @@ void InitQuests() quests[z]._qlog = 0; } - quests[z]._qtx = 0; quests[z]._qslvl = questlist[z]._qslvl; + quests[z]._qtx = 0; + quests[z]._qty = 0; quests[z]._qidx = z; quests[z]._qlvltype = questlist[z]._qlvlt; - quests[z]._qty = 0; quests[z]._qvar2 = 0; quests[z]._qmsg = questlist[z]._qdmsg; } diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index c99c90924..0f2e76719 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -81,9 +81,14 @@ static void scrollrt_draw_cursor_back_buffer() /// ASSERT: assert(gpBuffer); src = sgSaveBack; dst = &gpBuffer[SCREENXY(sgdwCursX, sgdwCursY)]; + i = sgdwCursHgt; - for (i = sgdwCursHgt; i != 0; i--, src += sgdwCursWdt, dst += BUFFER_WIDTH) { - memcpy(dst, src, sgdwCursWdt); + if (sgdwCursHgt != 0) { + while (i--) { + memcpy(dst, src, sgdwCursWdt); + src += sgdwCursWdt; + dst += BUFFER_WIDTH; + } } sgdwCursXOld = sgdwCursX; diff --git a/Source/spelldat.cpp b/Source/spelldat.cpp index fc929b682..84a02cce7 100644 --- a/Source/spelldat.cpp +++ b/Source/spelldat.cpp @@ -3,7 +3,7 @@ SpellData spelldata[MAX_SPELLS] = { // clang-format off // sName, sManaCost, sType, sNameText, sSkillText, sBookLvl, sStaffLvl, sTargeted, sTownSpell, sMinInt, sSFX, sMissiles[3], sManaAdj, sMinMana, sStaffMin, sStaffMax, sBookCost, sStaffCost - { 0, 0, 0, NULL, NULL, 0, 0, FALSE, FALSE, 0, 0, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, + { SPL_NULL, 0, 0, NULL, NULL, 0, 0, FALSE, FALSE, 0, 0, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, { SPL_FIREBOLT, 6, STYPE_FIRE, "Firebolt", "Firebolt", 1, 1, TRUE, FALSE, 15, IS_CAST2, { MIS_FIREBOLT, 0, 0 }, 1, 3, 40, 80, 1000, 50 }, { SPL_HEAL, 5, STYPE_MAGIC, "Healing", NULL, 1, 1, FALSE, TRUE, 17, IS_CAST8, { MIS_HEAL, 0, 0 }, 3, 1, 20, 40, 1000, 50 }, { SPL_LIGHTNING, 10, STYPE_LIGHTNING, "Lightning", NULL, 4, 3, TRUE, FALSE, 20, IS_CAST4, { MIS_LIGHTCTRL, 0, 0 }, 1, 6, 20, 60, 3000, 150 }, @@ -39,6 +39,6 @@ SpellData spelldata[MAX_SPELLS] = { { SPL_TELEKINESIS, 15, STYPE_MAGIC, "Telekinesis", NULL, 2, 2, FALSE, FALSE, 33, IS_CAST2, { MIS_TELEKINESIS, 0, 0 }, 2, 8, 20, 40, 2500, 200 }, { SPL_HEALOTHER, 5, STYPE_MAGIC, "Heal Other", NULL, 1, 1, FALSE, TRUE, 17, IS_CAST8, { MIS_HEALOTHER, 0, 0 }, 3, 1, 20, 40, 1000, 50 }, { SPL_FLARE, 25, STYPE_MAGIC, "Blood Star", NULL, 14, 13, FALSE, FALSE, 70, IS_CAST2, { MIS_FLARE, 0, 0 }, 2, 14, 20, 60, 27500, 1800 }, - { SPL_BONESPIRIT, 24, STYPE_MAGIC, "Bone Spirit", NULL, 9, 7, FALSE, FALSE, 34, IS_CAST2, { MIS_BONESPIRIT, 0, 0 }, 1, 12, 20, 60, 11500, 800 } + { SPL_BONESPIRIT, 24, STYPE_MAGIC, "Bone Spirit", NULL, 9, 7, FALSE, FALSE, 34, IS_CAST2, { MIS_BONESPIRIT, 0, 0 }, 1, 12, 20, 60, 11500, 800 }, // clang-format on }; diff --git a/Source/spells.cpp b/Source/spells.cpp index 106e17ef4..f95ce8f87 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -224,9 +224,9 @@ void DoResurrect(int pnum, int rid) } SetPlayerHitPoints(rid, hp); - plr[rid]._pMana = 0; plr[rid]._pHPBase = plr[rid]._pHitPoints + (plr[rid]._pMaxHPBase - plr[rid]._pMaxHP); - plr[rid]._pManaBase = plr[rid]._pMaxManaBase - plr[rid]._pMaxMana; + plr[rid]._pMana = 0; + plr[rid]._pManaBase = plr[rid]._pMana + (plr[rid]._pMaxManaBase - plr[rid]._pMaxMana); CalcPlrInv(rid, TRUE); diff --git a/Source/stores.cpp b/Source/stores.cpp index ff82c5c44..42cc13115 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -5,7 +5,7 @@ int storenumh; int stextlhold; ItemStruct boyitem; int stextshold; -ItemStruct premiumitem[6]; +ItemStruct premiumitem[SMITH_PREMIUM_ITEMS]; BYTE *pSTextBoxCels; int premiumlevel; int talker; @@ -29,7 +29,7 @@ int gossipend; BYTE *pSPentSpn2Cels; int stextsval; int boylevel; -ItemStruct smithitem[20]; +ItemStruct smithitem[SMITH_ITEMS]; int stextdown; char stextscrlubtn; char stextflag; @@ -1889,8 +1889,8 @@ void SmithBuyItem() plr[myplr].HoldItem._iIdentified = FALSE; StoreAutoPlace(); idx = stextvhold + ((stextlhold - stextup) >> 2); - if (idx == 19) { - smithitem[19]._itype = ITYPE_NONE; + if (idx == SMITH_ITEMS - 1) { + smithitem[SMITH_ITEMS - 1]._itype = ITYPE_NONE; } else { for (; smithitem[idx + 1]._itype != ITYPE_NONE; idx++) { smithitem[idx] = smithitem[idx + 1]; diff --git a/Source/stores.h b/Source/stores.h index 5fcac1297..90e6ab0e6 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -7,7 +7,7 @@ extern int storenumh; extern int stextlhold; extern ItemStruct boyitem; extern int stextshold; -extern ItemStruct premiumitem[6]; +extern ItemStruct premiumitem[SMITH_PREMIUM_ITEMS]; extern BYTE *pSTextBoxCels; extern int premiumlevel; extern int talker; @@ -31,7 +31,7 @@ extern int gossipend; extern BYTE *pSPentSpn2Cels; extern int stextsval; extern int boylevel; -extern ItemStruct smithitem[20]; +extern ItemStruct smithitem[SMITH_ITEMS]; extern int stextdown; extern char stextscrlubtn; extern char stextflag; diff --git a/Source/towners.cpp b/Source/towners.cpp index 97b375366..e39be8e2a 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -10,7 +10,7 @@ BYTE *pCowCels; TownerStruct towner[16]; #ifndef SPAWN -const int snSFX[3][3] = { +const int snSFX[3][NUM_CLASSES] = { { PS_WARR52, PS_ROGUE52, PS_MAGE52 }, { PS_WARR49, PS_ROGUE49, PS_MAGE49 }, { PS_WARR50, PS_ROGUE50, PS_MAGE50 } diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 4597282c3..9c7d27305 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -487,7 +487,9 @@ BOOL ForceL3Trig() } for (i = 0; L3DownList[i] != -1; i++) { - if (dPiece[cursmx][cursmy] == L3DownList[i] || dPiece[cursmx + 1][cursmy] == L3DownList[i] || dPiece[cursmx + 2][cursmy] == L3DownList[i]) { + if (dPiece[cursmx][cursmy] == L3DownList[i] + || dPiece[cursmx + 1][cursmy] == L3DownList[i] + || dPiece[cursmx + 2][cursmy] == L3DownList[i]) { sprintf(infostr, "Down to level %i", currlevel + 1); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { diff --git a/comparer-config/diablo.toml b/comparer-config/diablo.toml index 7973f29c4..12dfa5f2d 100644 --- a/comparer-config/diablo.toml +++ b/comparer-config/diablo.toml @@ -2181,6 +2181,7 @@ size = 0x80 name = "gamemenu_gamma" addr = 0x418C30 size = 0x2A + [[func]] name = "gamemenu_slider_gamma" addr = 0x418C5A diff --git a/defs.h b/defs.h index 5a0e555f5..d043f6edd 100644 --- a/defs.h +++ b/defs.h @@ -1,5 +1,7 @@ // some global definitions, found in debug release +#define GAME_NAME "DIABLO" + #define DMAXX 40 #define DMAXY 40 @@ -50,6 +52,10 @@ // todo: enums #define NUMLEVELS 17 +#define SMITH_ITEMS 20 +#define SMITH_PREMIUM_ITEMS 6 +#define SMITH_MAX_VALUE 140000 +#define SMITH_MAX_PREMIUM_VALUE 140000 // from diablo 2 beta #define MAXEXP 2000000000 diff --git a/enums.h b/enums.h index e9f1539e3..f54f3f791 100644 --- a/enums.h +++ b/enums.h @@ -124,6 +124,7 @@ typedef enum item_effect_type { IPL_THORNS = 0x2D, IPL_NOMANA = 0x2E, IPL_NOHEALPLR = 0x2F, + IPL_FIREBALL = 0x32, /* only used in hellfire */ IPL_ABSHALFTRAP = 0x34, IPL_KNOCKBACK = 0x35, IPL_NOHEALMON = 0x36, @@ -1255,55 +1256,55 @@ typedef enum missile_id { } missile_id; typedef enum missile_graphic_id { - MFILE_ARROWS = 0x0, - MFILE_FIREBA = 0x1, - MFILE_GUARD = 0x2, - MFILE_LGHNING = 0x3, - MFILE_FIREWAL = 0x4, - MFILE_MAGBLOS = 0x5, - MFILE_PORTAL = 0x6, - MFILE_BLUEXFR = 0x7, - MFILE_BLUEXBK = 0x8, - MFILE_MANASHLD = 0x9, - MFILE_BLOOD = 0xA, - MFILE_BONE = 0xB, - MFILE_METLHIT = 0xC, - MFILE_FARROW = 0xD, - MFILE_DOOM = 0xE, - MFILE_0F = 0xF, - MFILE_BLODBUR = 0x10, - MFILE_NEWEXP = 0x11, - MFILE_SHATTER1 = 0x12, - MFILE_BIGEXP = 0x13, - MFILE_INFERNO = 0x14, - MFILE_THINLGHT = 0x15, - MFILE_FLARE = 0x16, - MFILE_FLAREEXP = 0x17, - MFILE_MAGBALL = 0x18, - MFILE_KRULL = 0x19, - MFILE_MINILTNG = 0x1A, - MFILE_HOLY = 0x1B, - MFILE_HOLYEXPL = 0x1C, - MFILE_LARROW = 0x1D, - MFILE_FIRARWEX = 0x1E, - MFILE_ACIDBF = 0x1F, - MFILE_ACIDSPLA = 0x20, - MFILE_ACIDPUD = 0x21, - MFILE_ETHRSHLD = 0x22, - MFILE_FIRERUN = 0x23, - MFILE_RESSUR1 = 0x24, - MFILE_SKLBALL = 0x25, - MFILE_RPORTAL = 0x26, - MFILE_FIREPLAR = 0x27, - MFILE_SCUBMISB = 0x28, - MFILE_SCBSEXPB = 0x29, - MFILE_SCUBMISC = 0x2A, - MFILE_SCBSEXPC = 0x2B, - MFILE_SCUBMISD = 0x2C, - MFILE_SCBSEXPD = 0x2D, - MFILE_NULL = 0x2E, - MFILE_INVALID = 0x2F, - MFILE_NONE = 0xFF, + MFILE_ARROWS, + MFILE_FIREBA, + MFILE_GUARD, + MFILE_LGHNING, + MFILE_FIREWAL, + MFILE_MAGBLOS, + MFILE_PORTAL, + MFILE_BLUEXFR, + MFILE_BLUEXBK, + MFILE_MANASHLD, + MFILE_BLOOD, + MFILE_BONE, + MFILE_METLHIT, + MFILE_FARROW, + MFILE_DOOM, + MFILE_0F, + MFILE_BLODBUR, + MFILE_NEWEXP, + MFILE_SHATTER1, + MFILE_BIGEXP, + MFILE_INFERNO, + MFILE_THINLGHT, + MFILE_FLARE, + MFILE_FLAREEXP, + MFILE_MAGBALL, + MFILE_KRULL, + MFILE_MINILTNG, + MFILE_HOLY, + MFILE_HOLYEXPL, + MFILE_LARROW, + MFILE_FIRARWEX, + MFILE_ACIDBF, + MFILE_ACIDSPLA, + MFILE_ACIDPUD, + MFILE_ETHRSHLD, + MFILE_FIRERUN, + MFILE_RESSUR1, + MFILE_SKLBALL, + MFILE_RPORTAL, + MFILE_FIREPLAR, + MFILE_SCUBMISB, + MFILE_SCBSEXPB, + MFILE_SCUBMISC, + MFILE_SCBSEXPC, + MFILE_SCUBMISD, + MFILE_SCBSEXPD, + MFILE_NULL, + MFILE_INVALID, + MFILE_NONE = 0xFF, } missile_graphic_id; typedef enum _mai_id { @@ -1475,8 +1476,7 @@ typedef enum _monster_id { MT_ADVOCATE = 0x6C, MT_GOLEM = 0x6D, MT_DIABLO = 0x6E, - MT_DARKMAGE = 0x6F, - NUM_MTYPES + NUM_MTYPES, } _monster_id; // this enum contains indexes from UniqMonst array for special unique monsters (usually quest related) @@ -2492,43 +2492,43 @@ typedef enum item_type { } item_type; typedef enum _item_indexes { - IDI_GOLD = 0x0, - IDI_WARRIOR = 0x1, - IDI_WARRSHLD = 0x2, - IDI_WARRCLUB = 0x3, - IDI_ROGUE = 0x4, - IDI_SORCEROR = 0x5, - IDI_CLEAVER = 0x6, - IDI_FIRSTQUEST = 0x6, - IDI_SKCROWN = 0x7, - IDI_INFRARING = 0x8, - IDI_ROCK = 0x9, - IDI_OPTAMULET = 0xA, - IDI_TRING = 0xB, - IDI_BANNER = 0xC, - IDI_HARCREST = 0xD, - IDI_STEELVEIL = 0xE, - IDI_GLDNELIX = 0xF, - IDI_ANVIL = 0x10, - IDI_MUSHROOM = 0x11, - IDI_BRAIN = 0x12, - IDI_FUNGALTM = 0x13, - IDI_SPECELIX = 0x14, - IDI_BLDSTONE = 0x15, - IDI_LASTQUEST = 0x16, - IDI_MAPOFDOOM = 0x16, - IDI_EAR = 0x17, - IDI_HEAL = 0x18, - IDI_MANA = 0x19, - IDI_IDENTIFY = 0x1A, - IDI_PORTAL = 0x1B, - IDI_ARMOFVAL = 0x1C, - IDI_FULLHEAL = 0x1D, - IDI_FULLMANA = 0x1E, - IDI_GRISWOLD = 0x1F, - IDI_LGTFORGE = 0x20, - IDI_LAZSTAFF = 0x21, - IDI_RESURRECT = 0x22, + IDI_GOLD, + IDI_WARRIOR, + IDI_WARRSHLD, + IDI_WARRCLUB, + IDI_ROGUE, + IDI_SORCEROR, + IDI_CLEAVER, + IDI_FIRSTQUEST = IDI_CLEAVER, + IDI_SKCROWN, + IDI_INFRARING, + IDI_ROCK, + IDI_OPTAMULET, + IDI_TRING, + IDI_BANNER, + IDI_HARCREST, + IDI_STEELVEIL, + IDI_GLDNELIX, + IDI_ANVIL, + IDI_MUSHROOM, + IDI_BRAIN, + IDI_FUNGALTM, + IDI_SPECELIX, + IDI_BLDSTONE, + IDI_MAPOFDOOM, + IDI_LASTQUEST = IDI_MAPOFDOOM, + IDI_EAR, + IDI_HEAL, + IDI_MANA, + IDI_IDENTIFY, + IDI_PORTAL, + IDI_ARMOFVAL, + IDI_FULLHEAL, + IDI_FULLMANA, + IDI_GRISWOLD, + IDI_LGTFORGE, + IDI_LAZSTAFF, + IDI_RESURRECT, } _item_indexes; typedef enum _setlevels { @@ -2703,7 +2703,7 @@ typedef enum _ui_classes { UI_WARRIOR = 0x0, UI_ROGUE = 0x1, UI_SORCERER = 0x2, - UI_NUM_CLASSES = 0x3, + UI_NUM_CLASSES, } _ui_classes; typedef enum _walk_path { diff --git a/structs.h b/structs.h index cac5e4d94..34227e647 100644 --- a/structs.h +++ b/structs.h @@ -1066,7 +1066,7 @@ typedef struct TownerStruct { int _tbtcnt; int _tSelFlag; int _tMsgSaid; - TNQ qsts[16]; + TNQ qsts[MAXQUESTS]; int _tSeed; int _tVar1; int _tVar2;