From b7a4d32e9129cab88e05427adf13a6990208222a Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 14 Sep 2019 22:55:40 +0200 Subject: [PATCH 01/15] Use sizeof(TMegaPkt) --- Source/msg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/msg.cpp b/Source/msg.cpp index a47dc771b..a8d427f11 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -53,7 +53,7 @@ TMegaPkt *msg_get_next_packet() { TMegaPkt *result; - sgpCurrPkt = (TMegaPkt *)DiabloAllocPtr(32008); + sgpCurrPkt = (TMegaPkt *)DiabloAllocPtr(sizeof(TMegaPkt)); sgpCurrPkt->pNext = NULL; sgpCurrPkt->dwSpaceLeft = 32000; From d269ef5045ae6fa8b1ea705cb2372a956c9b8f52 Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 15 Sep 2019 11:26:41 +0200 Subject: [PATCH 02/15] InitThemes cleanup --- Source/themes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/themes.cpp b/Source/themes.cpp index 02629f53d..b3f04db77 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -393,7 +393,6 @@ void InitThemes() zharlib = -1; numthemes = 0; - bCrossFlag = FALSE; armorFlag = TRUE; bFountainFlag = TRUE; cauldronFlag = TRUE; @@ -401,6 +400,7 @@ void InitThemes() pFountainFlag = TRUE; tFountainFlag = TRUE; treasureFlag = TRUE; + bCrossFlag = FALSE; weaponFlag = TRUE; if (currlevel == 16) From 72883c06217bfa66980ef9649d5fa8ae49bb702a Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 15 Sep 2019 12:11:54 +0200 Subject: [PATCH 03/15] SetReturnLvlPos cleanup --- Source/quests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/quests.cpp b/Source/quests.cpp index 5506159b0..0608948e0 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -551,26 +551,26 @@ void SetReturnLvlPos() case SL_SKELKING: ReturnLvlX = quests[QTYPE_KING]._qtx + 1; ReturnLvlY = quests[QTYPE_KING]._qty; - ReturnLvlT = DTYPE_CATHEDRAL; ReturnLvl = quests[QTYPE_KING]._qlevel; + ReturnLvlT = DTYPE_CATHEDRAL; break; case SL_BONECHAMB: ReturnLvlX = quests[QTYPE_BONE]._qtx + 1; ReturnLvlY = quests[QTYPE_BONE]._qty; - ReturnLvlT = DTYPE_CATACOMBS; ReturnLvl = quests[QTYPE_BONE]._qlevel; + ReturnLvlT = DTYPE_CATACOMBS; break; case SL_POISONWATER: ReturnLvlX = quests[QTYPE_PW]._qtx; ReturnLvlY = quests[QTYPE_PW]._qty + 1; - ReturnLvlT = DTYPE_CATHEDRAL; ReturnLvl = quests[QTYPE_PW]._qlevel; + ReturnLvlT = DTYPE_CATHEDRAL; break; case SL_VILEBETRAYER: ReturnLvlX = quests[QTYPE_VB]._qtx + 1; ReturnLvlY = quests[QTYPE_VB]._qty - 1; - ReturnLvlT = DTYPE_HELL; ReturnLvl = quests[QTYPE_VB]._qlevel; + ReturnLvlT = DTYPE_HELL; break; } } From eab02de82fd1cd9dbe8b8149899f2b2ce9be5463 Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 15 Sep 2019 12:48:41 +0200 Subject: [PATCH 04/15] ResyncQuests cleanup --- Source/quests.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/quests.cpp b/Source/quests.cpp index 5506159b0..eb56ad569 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -659,17 +659,17 @@ void ResyncQuests() } } if (currlevel == quests[QTYPE_BLKM]._qlevel) { - if (quests[QTYPE_BLKM]._qactive == 1) { - if (!quests[QTYPE_BLKM]._qvar1) { - SpawnQuestItem(IDI_FUNGALTM, 0, 0, 5, 1); - quests[QTYPE_BLKM]._qvar1 = QS_TOMESPAWNED; - } - } else if (quests[QTYPE_BLKM]._qactive == 2) { - if (quests[QTYPE_BLKM]._qvar1 >= QS_MUSHGIVEN) { - Qtalklist[TOWN_WITCH]._qblkm = -1; - Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3; - } else if (quests[QTYPE_BLKM]._qvar1 >= QS_BRAINGIVEN) { - Qtalklist[TOWN_HEALER]._qblkm = -1; + if (quests[QTYPE_BLKM]._qactive == 1 && !quests[QTYPE_BLKM]._qvar1) { + SpawnQuestItem(IDI_FUNGALTM, 0, 0, 5, 1); + quests[QTYPE_BLKM]._qvar1 = QS_TOMESPAWNED; + } else { + if (quests[QTYPE_BLKM]._qactive == 2) { + if (quests[QTYPE_BLKM]._qvar1 >= QS_MUSHGIVEN) { + Qtalklist[TOWN_WITCH]._qblkm = -1; + Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3; + } else if (quests[QTYPE_BLKM]._qvar1 >= QS_BRAINGIVEN) { + Qtalklist[TOWN_HEALER]._qblkm = -1; + } } } } From 3668c20fe3b41d8f05b3631e2d8972879b4b8322 Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 15 Sep 2019 13:47:16 +0200 Subject: [PATCH 05/15] NewTownerAnim cleanup --- Source/towners.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/towners.cpp b/Source/towners.cpp index 3e04b429e..469444d4f 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -153,10 +153,10 @@ void SetTownerGPtrs(BYTE *pData, BYTE **pAnim) void NewTownerAnim(int tnum, BYTE *pAnim, int numFrames, int Delay) { - towner[tnum]._tAnimCnt = 0; - towner[tnum]._tAnimLen = numFrames; towner[tnum]._tAnimData = pAnim; + towner[tnum]._tAnimLen = numFrames; towner[tnum]._tAnimFrame = 1; + towner[tnum]._tAnimCnt = 0; towner[tnum]._tAnimDelay = Delay; } From 5fb15255a81bab3bb9e531e83f0c0323242cb6a4 Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 15 Sep 2019 13:33:55 +0200 Subject: [PATCH 06/15] Apply enums to quests --- Source/drlg_l2.cpp | 4 ++-- Source/drlg_l4.cpp | 4 ++-- Source/town.cpp | 2 +- Source/towners.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index a89c72d71..91340a2d3 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -555,13 +555,13 @@ void LoadPreL2Dungeon(char *sFileName, int vx, int vy) void CreateL2Dungeon(DWORD rseed, int entry) { if (gbMaxPlayers == 1) { - if (currlevel == 7 && !quests[8]._qactive) { + if (currlevel == 7 && !quests[QTYPE_BLIND]._qactive) { currlevel = 6; CreateL2Dungeon(glSeedTbl[6], 4); currlevel = 7; } if (currlevel == 8) { - if (!quests[8]._qactive) { + if (!quests[QTYPE_BLIND]._qactive) { currlevel = 6; CreateL2Dungeon(glSeedTbl[6], 4); currlevel = 8; diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index aadfa212e..566d3d82b 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1754,8 +1754,8 @@ BOOL DRLG_L4PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, int cy } if (currlevel == 15) { - quests[15]._qtx = sx + 1; - quests[15]._qty = sy + 1; + quests[QTYPE_VB]._qtx = sx + 1; + quests[QTYPE_VB]._qty = sy + 1; } if (setview == TRUE) { ViewX = 2 * sx + 21; diff --git a/Source/town.cpp b/Source/town.cpp index 1ca9f3dab..41cf40097 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -1471,7 +1471,7 @@ void T_Pass3() } #endif - if (quests[13]._qactive != 3 && quests[13]._qactive) { + if (quests[QTYPE_PW]._qactive != 3 && quests[QTYPE_PW]._qactive) { T_FillTile(P3Tiles, 60, 70, 342); } else { T_FillTile(P3Tiles, 60, 70, 71); diff --git a/Source/towners.cpp b/Source/towners.cpp index 469444d4f..7a6e4fc2d 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -445,7 +445,7 @@ void TownDead() tidx = GetActiveTowner(TOWN_DEADGUY); TownCtrlMsg(tidx); if (!qtextflag) { - if ((quests[6]._qactive != 2 || quests[6]._qlog) && quests[6]._qactive != 1) { + if ((quests[QTYPE_BUTCH]._qactive != 2 || quests[QTYPE_BUTCH]._qlog) && quests[QTYPE_BUTCH]._qactive != 1) { towner[tidx]._tAnimDelay = 1000; towner[tidx]._tAnimFrame = 1; strcpy(towner[tidx]._tName, "Slain Townsman"); From a05071551a6c959aabb27680c874dd660e5d9eca Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 15 Sep 2019 21:14:56 +0200 Subject: [PATCH 07/15] CalcPlrItemMin cleanup --- Source/items.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/items.cpp b/Source/items.cpp index 94d8cdaa0..db4c667bd 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -695,8 +695,9 @@ void CalcPlrItemMin(int pnum) p = &plr[pnum]; pi = p->InvList; + i = p->_pNumInv; - for (i = p->_pNumInv; i; i--) { + while (i--) { pi->_iStatFlag = ItemMinStats(p, pi); pi++; } From a5de88ab3991532874aff548fcf117b32b0138e8 Mon Sep 17 00:00:00 2001 From: qndel Date: Mon, 16 Sep 2019 01:08:30 +0200 Subject: [PATCH 08/15] SortWitch cleanup --- Source/items.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index db4c667bd..35ea5711f 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3560,12 +3560,10 @@ void SortWitch() sorted = FALSE; while (j > 3 && !sorted) { sorted = TRUE; - if (j > 3) { - for (k = 3; k < j; k++) { - if (witchitem[k].IDidx > witchitem[k + 1].IDidx) { - BubbleSwapItem(&witchitem[k], &witchitem[k + 1]); - sorted = FALSE; - } + for (k = 3; k < j; k++) { + if (witchitem[k].IDidx > witchitem[k + 1].IDidx) { + BubbleSwapItem(&witchitem[k], &witchitem[k + 1]); + sorted = FALSE; } } j--; From b47af60b6f28ac912017dee26fe4d2cd95b57ccb Mon Sep 17 00:00:00 2001 From: qndel Date: Mon, 16 Sep 2019 01:11:21 +0200 Subject: [PATCH 09/15] SortHealer cleanup --- Source/items.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index db4c667bd..eb8368eec 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3746,12 +3746,10 @@ void SortHealer() sorted = FALSE; while (j > 2 && !sorted) { sorted = TRUE; - if (j > 2) { - for (k = 2; k < j; k++) { - if (healitem[k].IDidx > healitem[k + 1].IDidx) { - BubbleSwapItem(&healitem[k], &healitem[k + 1]); - sorted = FALSE; - } + for (k = 2; k < j; k++) { + if (healitem[k].IDidx > healitem[k + 1].IDidx) { + BubbleSwapItem(&healitem[k], &healitem[k + 1]); + sorted = FALSE; } } j--; From 33b371166238a39ff85668f8ebc6defef4149a6e Mon Sep 17 00:00:00 2001 From: qndel Date: Mon, 16 Sep 2019 01:37:03 +0200 Subject: [PATCH 10/15] SortSmith cleanup --- Source/items.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index db4c667bd..6eabd2a97 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3379,12 +3379,10 @@ void SortSmith() sorted = FALSE; while (j > 0 && !sorted) { sorted = TRUE; - if (j > 0) { - for (k = 0; k < j; k++) { - if (smithitem[k].IDidx > smithitem[k + 1].IDidx) { - BubbleSwapItem(&smithitem[k], &smithitem[k + 1]); - sorted = FALSE; - } + for (k = 0; k < j; k++) { + if (smithitem[k].IDidx > smithitem[k + 1].IDidx) { + BubbleSwapItem(&smithitem[k], &smithitem[k + 1]); + sorted = FALSE; } } j--; From a47a797468037966515bbed8e05b6e8c2750305e Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 15 Sep 2019 21:38:10 +0200 Subject: [PATCH 11/15] RecreateEar cleanup --- Source/items.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/items.cpp b/Source/items.cpp index cc2582a93..61e3d1086 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -2299,8 +2299,8 @@ void RecreateEar(int ii, WORD ic, int iseed, int Id, int dur, int mdur, int ch, tempstr[16] = '\0'; sprintf(item[ii]._iName, "Ear of %s", tempstr); item[ii]._iCurs = ((ivalue >> 6) & 3) + 19; - item[ii]._iCreateInfo = ic; item[ii]._ivalue = ivalue & 0x3F; + item[ii]._iCreateInfo = ic; item[ii]._iSeed = iseed; } From 2f6a428f4bca8ced40fb42b2fafb460e35063afa Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 15 Sep 2019 22:14:37 +0200 Subject: [PATCH 12/15] ProcessItems cleanup --- Source/items.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/items.cpp b/Source/items.cpp index 61e3d1086..737d2bea1 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -2452,8 +2452,8 @@ void ProcessItems() PlaySfxLoc(ItemDropSnds[ItemCAnimTbl[item[ii]._iCurs]], item[ii]._ix, item[ii]._iy); if (item[ii]._iAnimFrame >= item[ii]._iAnimLen) { - item[ii]._iAnimFlag = FALSE; item[ii]._iAnimFrame = item[ii]._iAnimLen; + item[ii]._iAnimFlag = FALSE; item[ii]._iSelFlag = 1; } } From afa1306e9120510cb664bbddc4eaf7f799568dce Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 15 Sep 2019 22:04:17 +0200 Subject: [PATCH 13/15] GetUniqueItem cleanup --- Source/items.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/items.cpp b/Source/items.cpp index 737d2bea1..63dccebe1 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1994,9 +1994,9 @@ void GetUniqueItem(int i, int uid) if (item[i]._iMiscId == IMISC_UNIQUE) item[i]._iSeed = uid; - item[i]._iCreateInfo |= 0x0200; item[i]._iUid = uid; item[i]._iMagical = ITEM_QUALITY_UNIQUE; + item[i]._iCreateInfo |= 0x0200; } void SpawnUnique(int uid, int x, int y) From 8741ddc6c271124d2491e08ea444e30d177fbefa Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 15 Sep 2019 21:47:43 +0200 Subject: [PATCH 14/15] SetupItem cleanup --- Source/items.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index 63dccebe1..0f643f1c3 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1785,27 +1785,25 @@ void GetItemBonus(int i, int idata, int minlvl, int maxlvl, int onlygood) void SetupItem(int i) { - int it, il; + int it; it = ItemCAnimTbl[item[i]._iCurs]; + item[i]._iAnimData = itemanims[it]; + item[i]._iAnimLen = ItemAnimLs[it]; item[i]._iAnimWidth = 96; item[i]._iAnimWidth2 = 16; - item[i]._iAnimData = itemanims[it]; - il = ItemAnimLs[it]; - item[i]._iAnimLen = il; item[i]._iIdentified = FALSE; item[i]._iPostDraw = FALSE; if (!plr[myplr].pLvlLoad) { - item[i]._iSelFlag = 0; - il = 1; + item[i]._iAnimFrame = 1; item[i]._iAnimFlag = TRUE; + item[i]._iSelFlag = 0; } else { + item[i]._iAnimFrame = item[i]._iAnimLen; item[i]._iAnimFlag = FALSE; item[i]._iSelFlag = 1; } - - item[i]._iAnimFrame = il; } int RndItem(int m) From 1c9801986c559417b7889708b2ce9cc2e27d9ba9 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 15 Sep 2019 23:00:28 +0200 Subject: [PATCH 15/15] Fix S_StartTalk --- Source/stores.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index 83a4c5e25..6c6a56f76 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -1372,7 +1372,7 @@ void S_StartTalk() #else sn = 0; for (i = 0; i < 16; i++) { - if (quests[i]._qlevel == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) + if (quests[i]._qactive == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) sn++; } @@ -1387,7 +1387,7 @@ void S_StartTalk() sn2 = sn - 2; for (i = 0; i < 16; i++) { - if (quests[i]._qlevel == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) { + if (quests[i]._qactive == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) { AddSText(0, sn, 1, questlist[i]._qlstr, COL_WHITE, 1); sn += la; }