From 1ea67db9e684aad21d75ce919928e7b009b82a46 Mon Sep 17 00:00:00 2001 From: qndel Date: Mon, 9 Sep 2019 00:42:57 +0200 Subject: [PATCH 01/26] path_next_node cleanup --- Source/path.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/path.cpp b/Source/path.cpp index 516e1ed02..c1c949710 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -288,7 +288,9 @@ void path_next_node(PATHNODE *pPath) int f; next = path_2_nodes; - if (path_2_nodes->NextNode) { + if (!path_2_nodes->NextNode) { + path_2_nodes->NextNode = pPath; + } else { current = path_2_nodes; next = path_2_nodes->NextNode; f = pPath->f; @@ -298,8 +300,6 @@ void path_next_node(PATHNODE *pPath) } pPath->NextNode = next; current->NextNode = pPath; - } else { - path_2_nodes->NextNode = pPath; } } From f6ae3e748928f2e5349be9924c6be6f4b814fa5b Mon Sep 17 00:00:00 2001 From: qndel Date: Tue, 10 Sep 2019 23:19:36 +0200 Subject: [PATCH 02/26] M_GetKnockback cleanup (#1579) --- Source/monster.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index c684add59..807f9aa52 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1488,8 +1488,11 @@ void M_GetKnockback(int i) monster[i]._myoff = 0; monster[i]._mx = monster[i]._moldx; monster[i]._my = monster[i]._moldy; - monster[i]._mfutx = monster[i]._moldx; - monster[i]._mfuty = monster[i]._moldy; + monster[i]._mfutx = monster[i]._mx; + monster[i]._mfuty = monster[i]._my; + // BUGFIX useless assignment + monster[i]._moldx = monster[i]._mx; + monster[i]._moldy = monster[i]._my; M_CheckEFlag(i); M_ClearSquares(i); dMonster[monster[i]._mx][monster[i]._my] = i + 1; From 4605c6096f31460d37ebe1a76af04ace58d78546 Mon Sep 17 00:00:00 2001 From: qndel Date: Thu, 12 Sep 2019 08:47:19 +0200 Subject: [PATCH 03/26] control_up_down cleanup --- Source/control.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 541f2e817..56c151897 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -2658,15 +2658,11 @@ void control_up_down(int v) { int i; - i = 0; - while (1) { + for (i = 0; i < 8; i++) { sgbTalkSavePos = (v + sgbTalkSavePos) & 7; - if (sgszTalkSave[sgbTalkSavePos][0]) - break; - i++; - if (i >= 8) { + if (sgszTalkSave[sgbTalkSavePos][0]) { + strcpy(sgszTalkMsg, sgszTalkSave[sgbTalkSavePos]); return; } } - strcpy(sgszTalkMsg, sgszTalkSave[sgbTalkSavePos]); } From 522f8f07c62348c15886e0bbed8649009699a64e Mon Sep 17 00:00:00 2001 From: qndel Date: Thu, 12 Sep 2019 11:03:53 +0200 Subject: [PATCH 04/26] DrawTalkPan cleanup --- Source/control.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 56c151897..3758e8ef7 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -2408,11 +2408,11 @@ void DrawTalkPan() int i, off, talk_btn, color, nCel, x; char *msg; - off = 0; if (!talkflag) return; DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, 239, 516); + off = 0; for (i = 293; i > 283; off++, i--) { DrawPanelBox((off >> 1) + 175, sgbPlrTalkTbl + off + 25, i, 1, (off >> 1) + 239, off + 521); } @@ -2431,8 +2431,8 @@ void DrawTalkPan() if (msg) *msg = '\0'; CelDecDatOnly(gpBuffer + x, pSPentSpn2Cels, frame, 12); - talk_btn = 0; frame = (frame & 7) + 1; + talk_btn = 0; for (i = 0; i < 4; i++) { if (i == myplr) continue; From c26ec70434edea223341eb10cfc0535efa886f1e Mon Sep 17 00:00:00 2001 From: qndel Date: Thu, 12 Sep 2019 11:34:47 +0200 Subject: [PATCH 05/26] VerifyGoldSeeds cleanup --- Source/pack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/pack.cpp b/Source/pack.cpp index af1f7d072..948a94244 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -111,7 +111,7 @@ void VerifyGoldSeeds(PlayerStruct *pPlayer) int i, j; for (i = 0; i < pPlayer->_pNumInv; i++) { - if (pPlayer->InvList[i].IDidx == IDI_GOLD && pPlayer->_pNumInv > 0) { + if (pPlayer->InvList[i].IDidx == IDI_GOLD) { for (j = 0; j < pPlayer->_pNumInv; j++) { if (i != j) { if (pPlayer->InvList[j].IDidx == IDI_GOLD && pPlayer->InvList[i]._iSeed == pPlayer->InvList[j]._iSeed) { From b7a4d32e9129cab88e05427adf13a6990208222a Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 14 Sep 2019 22:55:40 +0200 Subject: [PATCH 06/26] 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 07/26] 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 08/26] 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 09/26] 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 10/26] 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 11/26] 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 12/26] 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 13/26] 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 14/26] 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 15/26] 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 16/26] 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 17/26] 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 18/26] 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 19/26] 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 20/26] 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; } From 56f04e19192e4852670cc5acc29a70487618b02e Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 17 Sep 2019 04:40:41 +0200 Subject: [PATCH 21/26] Update dthread.cpp --- Source/dthread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/dthread.cpp b/Source/dthread.cpp index 396ce655c..2c268c25b 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -21,7 +21,7 @@ void dthread_remove_player(int pnum) #endif for (pkt = sgpInfoHead; pkt; pkt = pkt->pNext) { if (pkt->dwSpaceLeft == pnum) - pkt->dwSpaceLeft = 4; + pkt->dwSpaceLeft = MAX_PLRS; } #ifdef __cplusplus sgMemCrit.Leave(); @@ -106,7 +106,7 @@ unsigned int __stdcall dthread_handler(void *) #endif if (pkt) { - if (pkt->dwSpaceLeft != 4) + if (pkt->dwSpaceLeft != MAX_PLRS) multi_send_zero_packet(pkt->dwSpaceLeft, pkt->data[0], &pkt->data[8], *(DWORD *)&pkt->data[4]); dwMilliseconds = 1000 * *(DWORD *)&pkt->data[4] / gdwDeltaBytesSec; From 6a1ab27a1acd3f56af1f0993a5e38ced4b3534dd Mon Sep 17 00:00:00 2001 From: qndel Date: Tue, 17 Sep 2019 13:28:58 +0200 Subject: [PATCH 22/26] gmenu_clear_buffer cleanup --- Source/gmenu.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 9b3e7f3ab..d37a2943c 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -200,7 +200,8 @@ void gmenu_clear_buffer(int x, int y, int width, int height) { BYTE *i; - for (i = gpBuffer + PitchTbl[y] + x; height; height--) { + i = gpBuffer + PitchTbl[y] + x; + while (height--) { memset(i, 205, width); i -= BUFFER_WIDTH; } From 12435a9317c264d2fa86848c6b984bf66f02908c Mon Sep 17 00:00:00 2001 From: qndel Date: Tue, 17 Sep 2019 16:43:57 +0200 Subject: [PATCH 23/26] SetSpell cleanup --- Source/control.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/control.cpp b/Source/control.cpp index 3758e8ef7..b12b1bb30 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -504,9 +504,9 @@ void SetSpell() spselflag = 0; if (pSpell != -1) { ClearPanel(); - drawpanflag = 255; plr[myplr]._pRSpell = pSpell; plr[myplr]._pRSplType = pSplType; + drawpanflag = 255; } } From 13c957a445d8c252812eb5ee5711561d06754e77 Mon Sep 17 00:00:00 2001 From: qndel Date: Tue, 17 Sep 2019 18:17:03 +0200 Subject: [PATCH 24/26] Freeupstairs cleanup --- Source/trigs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/trigs.cpp b/Source/trigs.cpp index c2e258c47..4597282c3 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -590,15 +590,15 @@ BOOL ForceL4Trig() void Freeupstairs() { - int i, yy, xx, tx, ty; + int i, tx, ty, yy, xx; for (i = 0; i < numtrigs; i++) { tx = trigs[i]._tx; ty = trigs[i]._ty; - for (yy = 0; yy < MAXTRIGGERS; yy++) { - for (xx = 0; xx < MAXTRIGGERS; xx++) { - dFlags[tx - 2 + xx][ty - 2 + yy] |= BFLAG_POPULATED; + for (yy = -2; yy <= 2; yy++) { + for (xx = -2; xx <= 2; xx++) { + dFlags[tx + xx][ty + yy] |= BFLAG_POPULATED; } } } From c629eb1e60b8830171477c4e1a3d78645f05cb80 Mon Sep 17 00:00:00 2001 From: qndel Date: Wed, 18 Sep 2019 00:51:49 +0200 Subject: [PATCH 25/26] codec_decode cleanup (#1661) --- Source/codec.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/codec.cpp b/Source/codec.cpp index 748fa2925..157c23141 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -34,20 +34,21 @@ int codec_decode(BYTE *pbSrcDst, DWORD size, char *pszPassword) memset(buf, 0, sizeof(buf)); sig = (CodecSignature *)pbSrcDst; if (sig->error > 0) { - size = 0; - SHA1Clear(); - } else { - SHA1Result(0, dst); - if (sig->checksum != *(DWORD *)dst) { - memset(dst, 0, sizeof(dst)); - size = 0; - SHA1Clear(); - } else { - size += sig->last_chunk_size - 64; - SHA1Clear(); - } + goto error; + } + + SHA1Result(0, dst); + if (sig->checksum != *(DWORD *)dst) { + memset(dst, 0, sizeof(dst)); + goto error; } + + size += sig->last_chunk_size - 64; + SHA1Clear(); return size; +error: + SHA1Clear(); + return 0; } void codec_init_key(int unused, char *pszPassword) From a593f3a1d2a6cce3c5a77499b482c353776b404d Mon Sep 17 00:00:00 2001 From: qndel Date: Tue, 17 Sep 2019 20:57:02 +0200 Subject: [PATCH 26/26] 6 functions cleanup --- Source/engine.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/engine.cpp b/Source/engine.cpp index a7173b2f3..35ae01520 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -164,9 +164,9 @@ void CelDecDatOnly(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth) */ void CelDrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { - int nDataStart, nDataSize, nDataCap; BYTE *pRLEBytes; DWORD *pFrameTable; + int nDataStart, nDataSize, nDataCap; /// ASSERT: assert(gpBuffer); if (!gpBuffer) @@ -205,9 +205,9 @@ void CelDrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Ce */ void CelDecodeHdrOnly(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { - int nDataStart, nDataSize, nDataCap; BYTE *pRLEBytes; DWORD *pFrameTable; + int nDataStart, nDataSize, nDataCap; /// ASSERT: assert(pCelBuff != NULL); if (!pCelBuff) @@ -924,9 +924,9 @@ void Cel2DecDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) */ void Cel2DrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { - int nDataStart, nDataSize, nDataCap; BYTE *pRLEBytes; DWORD *pFrameTable; + int nDataStart, nDataSize, nDataCap; /// ASSERT: assert(gpBuffer); if (!gpBuffer) @@ -965,9 +965,9 @@ void Cel2DrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C */ void Cel2DecodeHdrOnly(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { - int nDataStart, nDataSize, nDataCap; BYTE *pRLEBytes; DWORD *pFrameTable; + int nDataStart, nDataSize, nDataCap; /// ASSERT: assert(pCelBuff != NULL); if (!pCelBuff) @@ -2480,9 +2480,9 @@ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel) */ void Cl2DecodeFrm1(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { - int nDataStart, nDataSize; BYTE *pRLEBytes; DWORD *pFrameTable; + int nDataStart, nDataSize; /// ASSERT: assert(gpBuffer != NULL); if (!gpBuffer) @@ -3112,9 +3112,9 @@ void Cl2DecodeLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int */ void Cl2DecodeFrm4(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap) { - int nDataStart, nDataSize; BYTE *pRLEBytes; DWORD *pFrameTable; + int nDataStart, nDataSize; /// ASSERT: assert(gpBuffer != NULL); if (!gpBuffer)