From bfe47597452f8dd237f50a8246e9f22cf04105f1 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Fri, 1 Nov 2019 12:59:46 +0100 Subject: [PATCH 1/4] Loading screen (#1836) --- Source/interfac.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 8e3f3a93d..0e540ab30 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -36,11 +36,11 @@ void DrawCutscene() DWORD i; lock_buf(1); - CelDraw(SCREEN_X, 480 + SCREEN_Y - 1, (BYTE *)sgpBackCel, 1, 640); + CelDraw(PANEL_X, 480 + SCREEN_Y - 1, (BYTE *)sgpBackCel, 1, 640); for (i = 0; i < sgdwProgress; i++) { DrawProgress( - BarPos[progress_id][0] + i + SCREEN_X, + BarPos[progress_id][0] + i + PANEL_X, BarPos[progress_id][1] + SCREEN_Y, progress_id); } From 3bd28cc0c12303925dffce8842f6334f1520f3cf Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sun, 3 Nov 2019 07:36:03 -0600 Subject: [PATCH 2/4] Fix function order [spells+pack.cpp] --- Source/pack.cpp | 110 +++++++++++++++++++++++----------------------- Source/pack.h | 2 - Source/spells.cpp | 92 +++++++++++++++++++------------------- Source/spells.h | 1 - 4 files changed, 101 insertions(+), 104 deletions(-) diff --git a/Source/pack.cpp b/Source/pack.cpp index 1a88d40cf..912123765 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -1,6 +1,36 @@ #include "diablo.h" #include "../3rdParty/Storm/Source/storm.h" +static void PackItem(PkItemStruct *id, ItemStruct *is) +{ + if (is->_itype == -1) { + id->idx = 0xFFFF; + } else { + id->idx = is->IDidx; + if (is->IDidx == IDI_EAR) { + id->iCreateInfo = is->_iName[8] | (is->_iName[7] << 8); + id->iSeed = is->_iName[12] | ((is->_iName[11] | ((is->_iName[10] | (is->_iName[9] << 8)) << 8)) << 8); + id->bId = is->_iName[13]; + id->bDur = is->_iName[14]; + id->bMDur = is->_iName[15]; + id->bCh = is->_iName[16]; + id->bMCh = is->_iName[17]; + id->wValue = is->_ivalue | (is->_iName[18] << 8) | ((is->_iCurs - 19) << 6); + id->dwBuff = is->_iName[22] | ((is->_iName[21] | ((is->_iName[20] | (is->_iName[19] << 8)) << 8)) << 8); + } else { + id->iSeed = is->_iSeed; + id->iCreateInfo = is->_iCreateInfo; + id->bId = is->_iIdentified + 2 * is->_iMagical; + id->bDur = is->_iDurability; + id->bMDur = is->_iMaxDur; + id->bCh = is->_iCharges; + id->bMCh = is->_iMaxCharges; + if (!is->IDidx) + id->wValue = is->_ivalue; + } + } +} + void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield) { PlayerStruct *pPlayer; @@ -76,33 +106,35 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield) pPack->pManaShield = FALSE; } -void PackItem(PkItemStruct *id, ItemStruct *is) +// Note: last slot of item[MAXITEMS+1] used as temporary buffer +// find real name reference below, possibly [sizeof(item[])/sizeof(ItemStruct)] +static void UnPackItem(PkItemStruct *is, ItemStruct *id) { - if (is->_itype == -1) { - id->idx = 0xFFFF; + if (is->idx == 0xFFFF) { + id->_itype = -1; } else { - id->idx = is->IDidx; - if (is->IDidx == IDI_EAR) { - id->iCreateInfo = is->_iName[8] | (is->_iName[7] << 8); - id->iSeed = is->_iName[12] | ((is->_iName[11] | ((is->_iName[10] | (is->_iName[9] << 8)) << 8)) << 8); - id->bId = is->_iName[13]; - id->bDur = is->_iName[14]; - id->bMDur = is->_iName[15]; - id->bCh = is->_iName[16]; - id->bMCh = is->_iName[17]; - id->wValue = is->_ivalue | (is->_iName[18] << 8) | ((is->_iCurs - 19) << 6); - id->dwBuff = is->_iName[22] | ((is->_iName[21] | ((is->_iName[20] | (is->_iName[19] << 8)) << 8)) << 8); + if (is->idx == IDI_EAR) { + RecreateEar( + MAXITEMS, + is->iCreateInfo, + is->iSeed, + is->bId, + is->bDur, + is->bMDur, + is->bCh, + is->bMCh, + is->wValue, + is->dwBuff); } else { - id->iSeed = is->_iSeed; - id->iCreateInfo = is->_iCreateInfo; - id->bId = is->_iIdentified + 2 * is->_iMagical; - id->bDur = is->_iDurability; - id->bMDur = is->_iMaxDur; - id->bCh = is->_iCharges; - id->bMCh = is->_iMaxCharges; - if (!is->IDidx) - id->wValue = is->_ivalue; + RecreateItem(MAXITEMS, is->idx, is->iCreateInfo, is->iSeed, is->wValue); + item[MAXITEMS]._iMagical = is->bId >> 1; + item[MAXITEMS]._iIdentified = is->bId & 1; + item[MAXITEMS]._iDurability = is->bDur; + item[MAXITEMS]._iMaxDur = is->bMDur; + item[MAXITEMS]._iCharges = is->bCh; + item[MAXITEMS]._iMaxCharges = is->bMCh; } + *id = item[MAXITEMS]; } } @@ -216,35 +248,3 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, BOOL killok) pPlayer->pBattleNet = pPack->pBattleNet; pPlayer->pManaShield = pPack->pManaShield; } - -// Note: last slot of item[MAXITEMS+1] used as temporary buffer -// find real name reference below, possibly [sizeof(item[])/sizeof(ItemStruct)] -void UnPackItem(PkItemStruct *is, ItemStruct *id) -{ - if (is->idx == 0xFFFF) { - id->_itype = -1; - } else { - if (is->idx == IDI_EAR) { - RecreateEar( - MAXITEMS, - is->iCreateInfo, - is->iSeed, - is->bId, - is->bDur, - is->bMDur, - is->bCh, - is->bMCh, - is->wValue, - is->dwBuff); - } else { - RecreateItem(MAXITEMS, is->idx, is->iCreateInfo, is->iSeed, is->wValue); - item[MAXITEMS]._iMagical = is->bId >> 1; - item[MAXITEMS]._iIdentified = is->bId & 1; - item[MAXITEMS]._iDurability = is->bDur; - item[MAXITEMS]._iMaxDur = is->bMDur; - item[MAXITEMS]._iCharges = is->bCh; - item[MAXITEMS]._iMaxCharges = is->bMCh; - } - *id = item[MAXITEMS]; - } -} diff --git a/Source/pack.h b/Source/pack.h index 7fd3c4355..5b7b6f6f1 100644 --- a/Source/pack.h +++ b/Source/pack.h @@ -3,10 +3,8 @@ #define __PACK_H__ void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield); -void PackItem(PkItemStruct *id, ItemStruct *is); void VerifyGoldSeeds(PlayerStruct *pPlayer); void UnPackPlayer(PkPlayerStruct *pPack, int pnum, BOOL killok); -void UnPackItem(PkItemStruct *is, ItemStruct *id); /* rdata */ diff --git a/Source/spells.cpp b/Source/spells.cpp index 3cf248f58..106e17ef4 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -143,6 +143,52 @@ void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int caster, int } } +static void PlacePlayer(int pnum) +{ + int nx, ny, max, min, x, y; + DWORD i; + BOOL done; + + if (plr[pnum].plrlevel == currlevel) { + for (i = 0; i < 8; i++) { + nx = plr[pnum].WorldX + plrxoff2[i]; + ny = plr[pnum].WorldY + plryoff2[i]; + + if (PosOkPlayer(pnum, nx, ny)) { + break; + } + } + + if (!PosOkPlayer(pnum, nx, ny)) { + done = FALSE; + + for (max = 1, min = -1; min > -50 && !done; max++, min--) { + for (y = min; y <= max && !done; y++) { + ny = plr[pnum].WorldY + y; + + for (x = min; x <= max && !done; x++) { + nx = plr[pnum].WorldX + x; + + if (PosOkPlayer(pnum, nx, ny)) { + done = TRUE; + } + } + } + } + } + + plr[pnum].WorldX = nx; + plr[pnum].WorldY = ny; + + dPlayer[nx][ny] = pnum + 1; + + if (pnum == myplr) { + ViewX = nx; + ViewY = ny; + } + } +} + /** * @param pnum player index * @param rid target player index @@ -192,52 +238,6 @@ void DoResurrect(int pnum, int rid) } } -void PlacePlayer(int pnum) -{ - int nx, ny, max, min, x, y; - DWORD i; - BOOL done; - - if (plr[pnum].plrlevel == currlevel) { - for (i = 0; i < 8; i++) { - nx = plr[pnum].WorldX + plrxoff2[i]; - ny = plr[pnum].WorldY + plryoff2[i]; - - if (PosOkPlayer(pnum, nx, ny)) { - break; - } - } - - if (!PosOkPlayer(pnum, nx, ny)) { - done = FALSE; - - for (max = 1, min = -1; min > -50 && !done; max++, min--) { - for (y = min; y <= max && !done; y++) { - ny = plr[pnum].WorldY + y; - - for (x = min; x <= max && !done; x++) { - nx = plr[pnum].WorldX + x; - - if (PosOkPlayer(pnum, nx, ny)) { - done = TRUE; - } - } - } - } - } - - plr[pnum].WorldX = nx; - plr[pnum].WorldY = ny; - - dPlayer[nx][ny] = pnum + 1; - - if (pnum == myplr) { - ViewX = nx; - ViewY = ny; - } - } -} - void DoHealOther(int pnum, int rid) { int i, j, hp; diff --git a/Source/spells.h b/Source/spells.h index f8887d47e..9eb299e4f 100644 --- a/Source/spells.h +++ b/Source/spells.h @@ -7,7 +7,6 @@ void UseMana(int id, int sn); BOOL CheckSpell(int id, int sn, char st, BOOL manaonly); void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int caster, int spllvl); void DoResurrect(int pnum, int rid); -void PlacePlayer(int pnum); void DoHealOther(int pnum, int rid); #endif /* __SPELLS_H__ */ From 3638381b48665fe2a917221b8ba4d75119d5197d Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 3 Nov 2019 16:05:52 +0100 Subject: [PATCH 3/4] SetCursor CURSOR_NONE --- Source/diablo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 34bbae365..d84f81ae6 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -178,7 +178,7 @@ void run_game_loop(unsigned int uMsg) pfile_flush_W(); PaletteFadeOut(8); - SetCursor_(0); + SetCursor_(CURSOR_NONE); ClearScreenBuffer(); force_redraw = 255; scrollrt_draw_game_screen(TRUE); From a4a302c4edbb110adaf63c78488b3f1ee6958262 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Mon, 4 Nov 2019 20:21:35 +0000 Subject: [PATCH 4/4] Fix OOB in lighting.cpp --- Source/lighting.cpp | 12 ++++++------ Source/lighting.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/lighting.cpp b/Source/lighting.cpp index ef1035d77..073e2a47d 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -9,7 +9,7 @@ BOOL dovision; int numvision; char lightmax; BOOL dolighting; -BYTE lightblock[8][8][16][16]; +BYTE lightblock[64][16][16]; int visionid; BYTE *pLightTbl; BOOL lightflag; @@ -556,7 +556,7 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) mult = xoff + 8 * yoff; for (y = 0; y < min_y; y++) { for (x = 1; x < max_x; x++) { - radius_block = lightblock[0][mult][y][x]; + radius_block = lightblock[mult][y][x]; if (radius_block < 128) { temp_x = nXPos + x; temp_y = nYPos + y; @@ -573,7 +573,7 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) mult = xoff + 8 * yoff; for (y = 0; y < max_y; y++) { for (x = 1; x < max_x; x++) { - radius_block = lightblock[0][mult][y + block_y][x + block_x]; + radius_block = lightblock[mult][y + block_y][x + block_x]; if (radius_block < 128) { temp_x = nXPos + y; temp_y = nYPos - x; @@ -590,7 +590,7 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) mult = xoff + 8 * yoff; for (y = 0; y < max_y; y++) { for (x = 1; x < min_x; x++) { - radius_block = lightblock[0][mult][y + block_y][x + block_x]; + radius_block = lightblock[mult][y + block_y][x + block_x]; if (radius_block < 128) { temp_x = nXPos - x; temp_y = nYPos - y; @@ -607,7 +607,7 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) mult = xoff + 8 * yoff; for (y = 0; y < min_y; y++) { for (x = 1; x < min_x; x++) { - radius_block = lightblock[0][mult][y + block_y][x + block_x]; + radius_block = lightblock[mult][y + block_y][x + block_x]; if (radius_block < 128) { temp_x = nXPos - y; temp_y = nYPos + x; @@ -958,7 +958,7 @@ void MakeLightTable() } else { fa = 0.5; } - lightblock[i][j][k][l] = fs + fa; + lightblock[i * 8 + j][k][l] = fs + fa; } } } diff --git a/Source/lighting.h b/Source/lighting.h index b755bd6d5..5b5934232 100644 --- a/Source/lighting.h +++ b/Source/lighting.h @@ -11,7 +11,7 @@ extern BOOL dovision; extern int numvision; extern char lightmax; extern BOOL dolighting; -extern BYTE lightblock[8][8][16][16]; +extern BYTE lightblock[64][16][16]; extern int visionid; extern BYTE *pLightTbl; extern BOOL lightflag;