From 29b9c99e5a79ebc5e98d7ddd57d46f2b21a98f15 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 14 Jan 2020 17:30:13 +0100 Subject: [PATCH 01/38] added some more values from enums (#1955) --- Source/control.cpp | 2 +- Source/cursor.cpp | 2 +- Source/items.cpp | 2 +- Source/items.h | 10 +++++----- Source/missiles.cpp | 2 +- Source/monster.cpp | 2 +- Source/objects.cpp | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 1290ccbd..e7de4a6c 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -561,7 +561,7 @@ void DrawSpellList() void SetSpell() { spselflag = 0; - if (pSpell != -1) { + if (pSpell != SPL_INVALID) { ClearPanel(); plr[myplr]._pRSpell = pSpell; plr[myplr]._pRSplType = pSplType; diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 7ac04e50..9e590080 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -206,7 +206,7 @@ void CheckCursMove() fx -= (plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8; fy -= (plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8; - if (ScrollInfo._sdir != 0) { + if (ScrollInfo._sdir != SDIR_NONE) { sx -= fx; sy -= fy; } diff --git a/Source/items.cpp b/Source/items.cpp index ffc156f7..715e95e7 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -189,7 +189,7 @@ void InitItemGFX() int i; char arglist[64]; - for (i = 0; i < 35; i++) { + for (i = 0; i < ITEMTYPES; i++) { sprintf(arglist, "Items\\%s.CEL", ItemDropNames[i]); itemanims[i] = LoadFileInMem(arglist, NULL); } diff --git a/Source/items.h b/Source/items.h index 35114397..4440b0e8 100644 --- a/Source/items.h +++ b/Source/items.h @@ -9,7 +9,7 @@ extern ItemStruct curruitem; extern ItemGetRecordStruct itemrecord[MAXITEMS]; extern ItemStruct item[MAXITEMS + 1]; extern BOOL itemhold[3][3]; -extern BYTE *itemanims[35]; +extern BYTE *itemanims[ITEMTYPES]; extern BOOL UniqueItemFlag[128]; extern int numitems; extern int gnNumGetRecords; @@ -129,10 +129,10 @@ void PutItemRecord(int nSeed, WORD wCI, int nIndex); /* data */ extern BYTE ItemCAnimTbl[169]; -extern char *ItemDropNames[35]; -extern BYTE ItemAnimLs[35]; -extern int ItemDropSnds[35]; -extern int ItemInvSnds[35]; +extern char *ItemDropNames[ITEMTYPES]; +extern BYTE ItemAnimLs[ITEMTYPES]; +extern int ItemDropSnds[ITEMTYPES]; +extern int ItemInvSnds[ITEMTYPES]; extern int idoppely; extern int premiumlvladd[6]; diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 36b24193..3bfba6fb 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -962,7 +962,7 @@ void CheckMissileCol(int i, int mindam, int maxdam, BOOL shift, int mx, int my, } } else { if (dMonster[mx][my] < 0 - && monster[-(dMonster[mx][my] + 1)]._mmode == 15 + && monster[-(dMonster[mx][my] + 1)]._mmode == MM_STONE && MonsterMHit( missile[i]._misource, -(dMonster[mx][my] + 1), diff --git a/Source/monster.cpp b/Source/monster.cpp index cc4e8864..7a786262 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4056,7 +4056,7 @@ void MAI_Rhino(int i) Monst->_mgoalvar1 = 0; Monst->_mgoalvar2 = random_(133, 2); } - Monst->_mgoal = 4; + Monst->_mgoal = MGOAL_MOVE; if (abs(mx) > abs(my)) { dist = abs(mx); } else { diff --git a/Source/objects.cpp b/Source/objects.cpp index 4262843a..1e1f6536 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1063,7 +1063,7 @@ void AddFlameTrap(int i) void AddFlameLvr(int i) { object[i]._oVar1 = trapid; - object[i]._oVar2 = 49; + object[i]._oVar2 = MIS_FLAMEC; } void AddTrap(int i, int ot) From df2e6b2bb9df2e079e0b5962a2c11c0dc4790da9 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 14 Jan 2020 18:21:45 +0100 Subject: [PATCH 02/38] affix_item_type enum --- Source/items.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index 715e95e7..edbed6d6 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -302,7 +302,7 @@ void CalcPlrItemVals(int p, BOOL Loadgfx) int btohit = 0; // bonus chance to hit int bac = 0; // bonus accuracy - int iflgs = 0; // item_special_effect flags + int iflgs = ISPL_NONE; // item_special_effect flags int sadd = 0; // added strength int madd = 0; // added magic @@ -1211,7 +1211,7 @@ void GetStaffSpell(int i, int lvl, BOOL onlygood) char istr[64]; if (!random_(17, 4)) { - GetItemPower(i, lvl >> 1, lvl, 256, onlygood); + GetItemPower(i, lvl >> 1, lvl, PLT_STAFF, onlygood); } else { l = lvl >> 1; if (l == 0) @@ -1761,26 +1761,26 @@ void GetItemBonus(int i, int idata, int minlvl, int maxlvl, BOOL onlygood) case ITYPE_SWORD: case ITYPE_AXE: case ITYPE_MACE: - GetItemPower(i, minlvl, maxlvl, 0x1000, onlygood); + GetItemPower(i, minlvl, maxlvl, PLT_WEAP, onlygood); break; case ITYPE_BOW: - GetItemPower(i, minlvl, maxlvl, 0x10, onlygood); + GetItemPower(i, minlvl, maxlvl, PLT_BOW, onlygood); break; case ITYPE_SHIELD: - GetItemPower(i, minlvl, maxlvl, 0x10000, onlygood); + GetItemPower(i, minlvl, maxlvl, PLT_SHLD, onlygood); break; case ITYPE_LARMOR: case ITYPE_HELM: case ITYPE_MARMOR: case ITYPE_HARMOR: - GetItemPower(i, minlvl, maxlvl, 0x100000, onlygood); + GetItemPower(i, minlvl, maxlvl, PLT_ARMO, onlygood); break; case ITYPE_STAFF: GetStaffSpell(i, maxlvl, onlygood); break; case ITYPE_RING: case ITYPE_AMULET: - GetItemPower(i, minlvl, maxlvl, 1, onlygood); + GetItemPower(i, minlvl, maxlvl, PLT_MISC, onlygood); break; } } From 1657af4b083333f0352078bf30cb27489840f71c Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Tue, 14 Jan 2020 14:10:06 -0600 Subject: [PATCH 03/38] Missing blood boil+FreeMissGFX --- Source/misdat.cpp | 2 +- Source/missiles.cpp | 37 +++++++++++++++++++++---------------- Source/missiles.h | 1 + 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Source/misdat.cpp b/Source/misdat.cpp index bdc425f7..142b975c 100644 --- a/Source/misdat.cpp +++ b/Source/misdat.cpp @@ -46,7 +46,7 @@ MissileData missiledata[] = { { MIS_IDENTIFY, &AddIdentify, &MI_Dummy, FALSE, 1, 0, MFILE_NONE, -1, -1 }, { MIS_WAVE, &AddWave, &MI_Wave, TRUE, 1, MISR_FIRE, MFILE_FIREWAL, LS_FLAMWAVE, -1 }, { MIS_NOVA, &AddNova, &MI_Nova, TRUE, 1, MISR_LIGHTNING, MFILE_LGHNING, LS_NOVA, -1 }, - { MIS_BLODBOIL, &miss_null_1F, &MI_Blodboil, TRUE, 1, 0, MFILE_NONE, -1, LS_BLODBOIL }, + { MIS_BLODBOIL, &AddBlodboil, &MI_Blodboil, TRUE, 1, 0, MFILE_NONE, -1, LS_BLODBOIL }, { MIS_APOCA, &AddApoca, &MI_Apoca, TRUE, 1, MISR_MAGIC, MFILE_NEWEXP, LS_APOC, -1 }, { MIS_REPAIR, &AddRepair, &MI_Dummy, FALSE, 2, 0, MFILE_NONE, -1, -1 }, { MIS_RECHARGE, &AddRecharge, &MI_Dummy, FALSE, 2, 0, MFILE_NONE, -1, -1 }, diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 3bfba6fb..12b05316 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -1123,12 +1123,13 @@ void InitMissileGFX() void FreeMissileGFX(int mi) { int i; - DWORD *pFrameTable; + DWORD *p; if (misfiledata[mi].mFlags & MFLAG_ALLOW_SPECIAL) { if (misfiledata[mi].mAnimData[0]) { - pFrameTable = (DWORD *)misfiledata[mi].mAnimData[0]; - mem_free_dbg(&pFrameTable[-misfiledata[mi].mAnimFAmt]); // TODO find a cleaner way to access the offeset + p = (DWORD *)misfiledata[mi].mAnimData[0]; + p -= misfiledata[mi].mAnimFAmt; + MemFreeDbg(p); misfiledata[mi].mAnimData[0] = NULL; } return; @@ -1136,9 +1137,7 @@ void FreeMissileGFX(int mi) for (i = 0; i < misfiledata[mi].mAnimFAmt; i++) { if (misfiledata[mi].mAnimData[i]) { - pFrameTable = (DWORD *)misfiledata[mi].mAnimData[i]; - misfiledata[mi].mAnimData[i] = NULL; - mem_free_dbg(pFrameTable); + MemFreeDbg(misfiledata[mi].mAnimData[i]); } } } @@ -2175,6 +2174,11 @@ void AddNova(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, in missile[mi]._mirange = 1; } +void AddBlodboil(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) +{ + missile[mi]._miDelFlag = 1; +} + void AddRepair(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) { missile[mi]._miDelFlag = TRUE; @@ -3459,17 +3463,18 @@ void MI_Stone(int i) } if (monster[m]._mmode != MM_STONE) { missile[i]._miDelFlag = TRUE; - } else { - if (!missile[i]._mirange) { - missile[i]._miDelFlag = TRUE; - if (monster[m]._mhitpoints > 0) - monster[m]._mmode = missile[i]._miVar1; - else - AddDead(monster[m]._mx, monster[m]._my, stonendx, (direction)monster[m]._mdir); - } - if (missile[i]._miAnimType == MFILE_SHATTER1) - PutMissile(i); + return; } + + if (!missile[i]._mirange) { + missile[i]._miDelFlag = TRUE; + if (monster[m]._mhitpoints > 0) + monster[m]._mmode = missile[i]._miVar1; + else + AddDead(monster[m]._mx, monster[m]._my, stonendx, (direction)monster[m]._mdir); + } + if (missile[i]._miAnimType == MFILE_SHATTER1) + PutMissile(i); } void MI_Boom(int i) diff --git a/Source/missiles.h b/Source/missiles.h index b7e502c2..64e45c1a 100644 --- a/Source/missiles.h +++ b/Source/missiles.h @@ -81,6 +81,7 @@ void AddFirewallC(int mi, int sx, int sy, int dx, int dy, int midir, char mienem void AddInfra(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); void AddWave(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); void AddNova(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); +void AddBlodboil(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); void AddRepair(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); void AddRecharge(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); void AddDisarm(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); From 3008439bc7300b2c592fee996d5a4268567e3a8b Mon Sep 17 00:00:00 2001 From: qndel Date: Wed, 15 Jan 2020 13:29:08 +0100 Subject: [PATCH 04/38] enums and stuff --- DiabloUI/diabloui.cpp | 2 +- Source/control.cpp | 16 ++++++++-------- Source/control.h | 2 +- Source/debug.cpp | 4 ++-- Source/diablo.cpp | 18 +++++++++--------- Source/gendung.cpp | 4 ++-- Source/gmenu.cpp | 8 ++++---- Source/help.cpp | 6 +++--- Source/help.h | 2 +- Source/inv.cpp | 12 ++++++------ Source/items.cpp | 10 +++++----- Source/logging.cpp | 2 +- Source/missiles.cpp | 4 ++-- Source/mpqapi.cpp | 6 +++--- Source/nthread.cpp | 2 +- Source/objects.cpp | 8 ++++---- Source/stores.cpp | 2 +- Source/themes.cpp | 2 +- 18 files changed, 55 insertions(+), 55 deletions(-) diff --git a/DiabloUI/diabloui.cpp b/DiabloUI/diabloui.cpp index b8e2b2f7..2f663500 100644 --- a/DiabloUI/diabloui.cpp +++ b/DiabloUI/diabloui.cpp @@ -138,7 +138,7 @@ BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) } else { local_DelUiPalette(); } - return 1; + return TRUE; } // ref: 0x10005CEA diff --git a/Source/control.cpp b/Source/control.cpp index e7de4a6c..094dd1f2 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -54,7 +54,7 @@ int initialDropGoldValue; BYTE *pSpellCels; BOOL panbtndown; BYTE *pTalkPanel; -int spselflag; +BOOL spselflag; const BYTE fontframe[128] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -560,7 +560,7 @@ void DrawSpellList() void SetSpell() { - spselflag = 0; + spselflag = FALSE; if (pSpell != SPL_INVALID) { ClearPanel(); plr[myplr]._pRSpell = pSpell; @@ -1262,7 +1262,7 @@ void InitControlPan() drawhpflag = TRUE; drawmanaflag = TRUE; chrflag = FALSE; - spselflag = 0; + spselflag = FALSE; pSpellBkCel = LoadFileInMem("Data\\SpellBk.CEL", NULL); pSBkBtnCel = LoadFileInMem("Data\\SpellBkB.CEL", NULL); pSBkIconCels = LoadFileInMem("Data\\SpellI2.CEL", NULL); @@ -1324,7 +1324,7 @@ void DoSpeedBook() unsigned __int64 spells, spell; int xo, yo, X, Y, i, j; - spselflag = 1; + spselflag = TRUE; xo = PANEL_X + 12 + 56 * 10; yo = PANEL_Y - 17; X = PANEL_LEFT + 12 + 56 * 10 + 56 / 2; @@ -2495,15 +2495,15 @@ void control_remove_gold(int pnum, int gold_index) { int gi; - if (gold_index <= 46) { - gi = gold_index - 7; + if (gold_index <= INVITEM_INV_LAST) { + gi = gold_index - INVITEM_INV_FIRST; plr[pnum].InvList[gi]._ivalue -= dropGoldValue; if (plr[pnum].InvList[gi]._ivalue > 0) SetGoldCurs(pnum, gi); else RemoveInvItem(pnum, gi); } else { - gi = gold_index - 47; + gi = gold_index - INVITEM_BELT_FIRST; plr[pnum].SpdList[gi]._ivalue -= dropGoldValue; if (plr[pnum].SpdList[gi]._ivalue > 0) SetSpdbarGoldCurs(pnum, gi); @@ -2513,7 +2513,7 @@ void control_remove_gold(int pnum, int gold_index) SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); GetGoldSeed(pnum, &plr[pnum].HoldItem); plr[pnum].HoldItem._ivalue = dropGoldValue; - plr[pnum].HoldItem._iStatFlag = 1; + plr[pnum].HoldItem._iStatFlag = TRUE; control_set_gold_curs(pnum); plr[pnum]._pGold = CalculateGold(pnum); dropGoldValue = 0; diff --git a/Source/control.h b/Source/control.h index b4ef27a1..9b8b781b 100644 --- a/Source/control.h +++ b/Source/control.h @@ -51,7 +51,7 @@ extern int initialDropGoldValue; extern BYTE *pSpellCels; extern BOOL panbtndown; extern BYTE *pTalkPanel; -extern int spselflag; +extern BOOL spselflag; void DrawSpellCel(int xp, int yp, BYTE *Trans, int nCel, int w); void SetSpellTrans(char t); diff --git a/Source/debug.cpp b/Source/debug.cpp index 1ed3720e..5af78a27 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -241,11 +241,11 @@ void PrintDebugMonster(int m) sprintf(dstr, "Mode = %i, Var1 = %i", monster[m]._mmode, monster[m]._mVar1); NetSendCmdString(1 << myplr, dstr); - bActive = 0; + bActive = FALSE; for (i = 0; i < nummonsters; i++) { if (monstactive[i] == m) - bActive = 1; + bActive = TRUE; } sprintf(dstr, "Active List = %i, Squelch = %i", bActive, monster[m]._msquelch); diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 25e93800..3c5d2645 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -597,12 +597,12 @@ BOOL PressEscKey() rv = TRUE; } if (helpflag) { - helpflag = 0; + helpflag = FALSE; rv = TRUE; } if (qtextflag) { - qtextflag = 0; + qtextflag = FALSE; sfx_stop(); rv = TRUE; } else if (stextflag) { @@ -623,7 +623,7 @@ BOOL PressEscKey() rv = TRUE; } if (spselflag) { - spselflag = 0; + spselflag = FALSE; rv = TRUE; } @@ -1063,17 +1063,17 @@ void PressKey(int vkey) } } else if (vkey == VK_F1) { if (helpflag) { - helpflag = 0; + helpflag = FALSE; } else if (stextflag) { ClearPanel(); AddPanelString("No help available", TRUE); /// BUGFIX: message isn't displayed AddPanelString("while in stores", TRUE); track_repeat_walk(FALSE); } else { - invflag = 0; + invflag = FALSE; chrflag = FALSE; sbookflag = FALSE; - spselflag = 0; + spselflag = FALSE; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = FALSE; sfx_stop(); @@ -1191,11 +1191,11 @@ void PressKey(int vkey) if (!invflag && chrflag && MouseX > 160 && MouseY < PANEL_TOP) { SetCursorPos(MouseX - 160, MouseY); } - helpflag = 0; + helpflag = FALSE; invflag = FALSE; chrflag = FALSE; sbookflag = FALSE; - spselflag = 0; + spselflag = FALSE; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = FALSE; sfx_stop(); @@ -1307,7 +1307,7 @@ void PressChar(int vkey) if (!spselflag) { DoSpeedBook(); } else { - spselflag = 0; + spselflag = FALSE; } track_repeat_walk(FALSE); } diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 294b80fe..06a85a05 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -943,10 +943,10 @@ BOOL SkipThemeRoom(int x, int y) for (i = 0; i < themeCount; i++) { if (x >= themeLoc[i].x - 2 && x <= themeLoc[i].x + themeLoc[i].width + 2 && y >= themeLoc[i].y - 2 && y <= themeLoc[i].y + themeLoc[i].height + 2) - return 0; + return FALSE; } - return 1; + return TRUE; } void InitLevels() diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index efb8a0cc..c25c6c71 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -228,7 +228,7 @@ int gmenu_get_lfont(TMenuItem *pItem) BOOL gmenu_presskeys(int vkey) { if (!sgpCurrentMenu) - return 0; + return FALSE; switch (vkey) { case VK_RETURN: if ((sgpCurrItem->dwFlags & GMENU_ENABLED) != 0) { @@ -301,14 +301,14 @@ BOOLEAN gmenu_valid_mouse_pos(int *plOffset) *plOffset = 282; if (MouseX < 282 + PANEL_LEFT) { *plOffset = 0; - return 0; + return FALSE; } if (MouseX > 538 + PANEL_LEFT) { *plOffset = 256; - return 0; + return FALSE; } *plOffset = MouseX - 282 - PANEL_LEFT; - return 1; + return TRUE; } BOOL gmenu_left_mouse(BOOL isDown) diff --git a/Source/help.cpp b/Source/help.cpp index 960c572e..8996ac2e 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -2,7 +2,7 @@ int help_select_line; int dword_634494; -int helpflag; +BOOL helpflag; int displayinghelp[22]; /* check, does nothing? */ int HelpTop; @@ -437,7 +437,7 @@ const char gszHelpText[] = { void InitHelp() { - helpflag = 0; + helpflag = FALSE; dword_634494 = 0; displayinghelp[0] = 0; } @@ -554,7 +554,7 @@ void DrawHelpLine(int always_0, int help_line_nr, char *text, char color) void DisplayHelp() { help_select_line = 0; - helpflag = 1; + helpflag = TRUE; HelpTop = 5000; } diff --git a/Source/help.h b/Source/help.h index a96c5fb5..cb536b9b 100644 --- a/Source/help.h +++ b/Source/help.h @@ -4,7 +4,7 @@ extern int help_select_line; extern int dword_634494; -extern int helpflag; +extern BOOL helpflag; extern int displayinghelp[22]; extern int HelpTop; diff --git a/Source/inv.cpp b/Source/inv.cpp index c10c8e5f..003e8cfe 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -2111,23 +2111,23 @@ BOOL UseInvItem(int pnum, int cii) return TRUE; if (stextflag) return TRUE; - if (cii <= 5) + if (cii <= INVITEM_HAND_RIGHT) return FALSE; - if (cii <= 46) { - c = cii - 7; + if (cii <= INVITEM_INV_LAST) { + c = cii - INVITEM_INV_FIRST; Item = &plr[pnum].InvList[c]; speedlist = FALSE; } else { if (talkflag) return TRUE; - c = cii - 47; + c = cii - INVITEM_BELT_FIRST; Item = &plr[pnum].SpdList[c]; speedlist = TRUE; } switch (Item->IDidx) { - case 17: + case IDI_MUSHROOM: sfxdelay = 10; #ifndef SPAWN if (plr[pnum]._pClass == PC_WARRIOR) { @@ -2139,7 +2139,7 @@ BOOL UseInvItem(int pnum, int cii) } #endif return TRUE; - case 19: + case IDI_FUNGALTM: PlaySFX(IS_IBOOK); sfxdelay = 10; if (plr[pnum]._pClass == PC_WARRIOR) { diff --git a/Source/items.cpp b/Source/items.cpp index edbed6d6..048dff47 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -255,14 +255,14 @@ void InitItems() GetItemAttrs(0, IDI_GOLD, 1); golditem = item[0]; - golditem._iStatFlag = 1; + golditem._iStatFlag = TRUE; numitems = 0; for (i = 0; i < MAXITEMS; i++) { item[i]._itype = ITYPE_MISC; item[i]._ix = 0; item[i]._iy = 0; - item[i]._iAnimFlag = 0; + item[i]._iAnimFlag = FALSE; item[i]._iSelFlag = 0; item[i]._iIdentified = FALSE; item[i]._iPostDraw = FALSE; @@ -3598,15 +3598,15 @@ void SpawnWitch(int lvl) GetItemAttrs(0, IDI_MANA, 1); witchitem[0] = item[0]; witchitem[0]._iCreateInfo = lvl; - witchitem[0]._iStatFlag = 1; + witchitem[0]._iStatFlag = TRUE; GetItemAttrs(0, IDI_FULLMANA, 1); witchitem[1] = item[0]; witchitem[1]._iCreateInfo = lvl; - witchitem[1]._iStatFlag = 1; + witchitem[1]._iStatFlag = TRUE; GetItemAttrs(0, IDI_PORTAL, 1); witchitem[2] = item[0]; witchitem[2]._iCreateInfo = lvl; - witchitem[2]._iStatFlag = 1; + witchitem[2]._iStatFlag = TRUE; iCnt = random_(51, 8) + 10; for (i = 3; i < iCnt; i++) { diff --git a/Source/logging.cpp b/Source/logging.cpp index 15231eba..05d4d688 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -11,7 +11,7 @@ DWORD nNumberOfBytesToWrite; /* data */ -BOOL log_not_created = 1; +BOOL log_not_created = TRUE; HANDLE log_file = INVALID_HANDLE_VALUE; void __cdecl log_flush(BOOL force_close) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 12b05316..375cd0bd 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -610,10 +610,10 @@ BOOL MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist, int t, BOOLE return ret; #ifdef _DEBUG if (hit >= hper && !debug_mode_key_inverted_v && !debug_mode_dollar_sign) - return 0; + return FALSE; #else if (hit >= hper) - return 0; + return FALSE; #endif if (t == MIS_BONESPIRIT) { dam = monster[m]._mhitpoints / 3 >> 6; diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 6820e8c2..25435212 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -202,7 +202,7 @@ _BLOCKENTRY *mpqapi_new_block(int *block_index) blockEntry++; if (i >= 2048) { app_fatal("Out of free block entries"); - return 0; + return NULL; } } if (block_index) @@ -593,9 +593,9 @@ BOOL WriteMPQHeader() fhdr.blockcount = 2048; if (SetFilePointer(sghArchive, 0, NULL, FILE_BEGIN) == -1) - return 0; + return FALSE; if (!WriteFile(sghArchive, &fhdr, sizeof(fhdr), &NumberOfBytesWritten, 0)) - return 0; + return FALSE; return NumberOfBytesWritten == 104; } diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 53cacc3e..ebbc4f62 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -91,7 +91,7 @@ BOOL nthread_recv_turns(BOOL *pfSendAsync) sgbTicsOutOfSync = FALSE; sgbSyncCountdown = 1; sgbPacketCountdown = 1; - return 0; + return FALSE; } else { if (!sgbTicsOutOfSync) { sgbTicsOutOfSync = TRUE; diff --git a/Source/objects.cpp b/Source/objects.cpp index 1e1f6536..adffaaf2 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -3191,14 +3191,14 @@ void OperateShrine(int pnum, int i, int sType) || plr[pnum].InvList[j]._iMiscId == IMISC_MANA) { SetPlrHandItem(&plr[pnum].HoldItem, ItemMiscIdIdx(IMISC_REJUV)); GetPlrHandSeed(&plr[pnum].HoldItem); - plr[pnum].HoldItem._iStatFlag = 1; + plr[pnum].HoldItem._iStatFlag = TRUE; plr[pnum].InvList[j] = plr[pnum].HoldItem; } if (plr[pnum].InvList[j]._iMiscId == IMISC_FULLHEAL || plr[pnum].InvList[j]._iMiscId == IMISC_FULLMANA) { SetPlrHandItem(&plr[pnum].HoldItem, ItemMiscIdIdx(IMISC_FULLREJUV)); GetPlrHandSeed(&plr[pnum].HoldItem); - plr[pnum].HoldItem._iStatFlag = 1; + plr[pnum].HoldItem._iStatFlag = TRUE; plr[pnum].InvList[j] = plr[pnum].HoldItem; } } @@ -3209,14 +3209,14 @@ void OperateShrine(int pnum, int i, int sType) || plr[pnum].SpdList[j]._iMiscId == IMISC_MANA) { SetPlrHandItem(&plr[pnum].HoldItem, ItemMiscIdIdx(IMISC_REJUV)); GetPlrHandSeed(&plr[pnum].HoldItem); - plr[pnum].HoldItem._iStatFlag = 1; + plr[pnum].HoldItem._iStatFlag = TRUE; plr[pnum].SpdList[j] = plr[pnum].HoldItem; } if (plr[pnum].SpdList[j]._iMiscId == IMISC_FULLHEAL || plr[pnum].SpdList[j]._iMiscId == IMISC_FULLMANA) { SetPlrHandItem(&plr[pnum].HoldItem, ItemMiscIdIdx(IMISC_FULLREJUV)); GetPlrHandSeed(&plr[pnum].HoldItem); - plr[pnum].HoldItem._iStatFlag = 1; + plr[pnum].HoldItem._iStatFlag = TRUE; plr[pnum].SpdList[j] = plr[pnum].HoldItem; } } diff --git a/Source/stores.cpp b/Source/stores.cpp index 938497b1..a73da94d 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -2007,7 +2007,7 @@ BOOL StoreGoldFit(int idx) SetCursor_(CURSOR_HAND); if (numsqrs >= sz) - return 1; + return TRUE; for (i = 0; i < 40; i++) { if (!plr[myplr].InvGrid[i]) diff --git a/Source/themes.cpp b/Source/themes.cpp index a745edd0..508e85c1 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -65,7 +65,7 @@ BOOL TFit_Shrine(int i) && dObject[xp + 1][yp - 1] == 0) { found = 1; } - if (!found + if (found == 0 && nTrapTable[dPiece[xp - 1][yp]] && !nSolidTable[dPiece[xp][yp - 1]] && !nSolidTable[dPiece[xp][yp + 1]] From f57af2fa7d12b794e46e3d80d7d5211150e0c862 Mon Sep 17 00:00:00 2001 From: qndel Date: Fri, 17 Jan 2020 17:34:20 +0100 Subject: [PATCH 05/38] tMsgSaid type change --- Source/towners.cpp | 2 +- structs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/towners.cpp b/Source/towners.cpp index da56af30..65abc2ed 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -166,7 +166,7 @@ void InitTownerInfo(int i, int w, int sel, int t, int x, int y, int ao, int tp) towner[i]._tSelFlag = sel; towner[i]._tAnimWidth = w; towner[i]._tAnimWidth2 = (w - 64) >> 1; - towner[i]._tMsgSaid = 0; + towner[i]._tMsgSaid = FALSE; towner[i]._ttype = t; towner[i]._tx = x; towner[i]._ty = y; diff --git a/structs.h b/structs.h index 00a82282..408f2889 100644 --- a/structs.h +++ b/structs.h @@ -1065,7 +1065,7 @@ typedef struct TownerStruct { int _teflag; int _tbtcnt; int _tSelFlag; - int _tMsgSaid; + BOOL _tMsgSaid; TNQ qsts[MAXQUESTS]; int _tSeed; int _tVar1; From 6605e1de5ec648cf5f9e1cdfb7ba0a999d21bf3a Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 15 Jan 2020 18:00:54 -0600 Subject: [PATCH 06/38] Fix variable 'gbSelectProvider' --- Source/diablo.cpp | 4 ++-- Source/multi.cpp | 8 ++++---- Source/multi.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 3c5d2645..6f80ba93 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -86,7 +86,7 @@ BOOL StartGame(BOOL bNewGame, BOOL bSinglePlayer) BOOL fExitProgram; unsigned int uMsg; - gbGameUninitialized = TRUE; + gbSelectProvider = TRUE; do { fExitProgram = FALSE; @@ -97,7 +97,7 @@ BOOL StartGame(BOOL bNewGame, BOOL bSinglePlayer) break; } - gbGameUninitialized = FALSE; + gbSelectProvider = FALSE; if (bNewGame || !gbValidSaveFile) { InitLevels(); diff --git a/Source/multi.cpp b/Source/multi.cpp index 051b63d1..1d2f8532 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -18,7 +18,7 @@ BYTE gbActivePlayers; BOOLEAN gbGameDestroyed; BOOLEAN sgbSendDeltaTbl[MAX_PLRS]; _gamedata sgGameInitInfo; -BOOLEAN gbGameUninitialized; +BOOLEAN gbSelectProvider; int sglTimeoutStart; int sgdwPlayerLeftReasonTbl[MAX_PLRS]; TBuffer sgLoPriBuf; @@ -754,7 +754,7 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram) if (sgbPlayerTurnBitTbl[myplr] == 0 || msg_wait_resync()) break; NetClose(); - gbGameUninitialized = FALSE; + gbSelectProvider = FALSE; } gnDifficulty = sgGameInitInfo.bDiff; SetRndSeed(sgGameInitInfo.dwSeed); @@ -859,7 +859,7 @@ BOOL multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, for (first = TRUE;; first = FALSE) { type = 0x00; - if (gbGameUninitialized) { + if (gbSelectProvider) { if (!UiSelectProvider(0, client_info, user_info, ui_info, &fileinfo, &type) && (!first || SErrGetLastError() != STORM_ERROR_REQUIRES_UPGRADE || !multi_upgrade(pfExitProgram))) { return FALSE; @@ -872,7 +872,7 @@ BOOL multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, if (UiSelectGame(1, client_info, user_info, ui_info, &fileinfo, &playerId)) break; - gbGameUninitialized = TRUE; + gbSelectProvider = TRUE; } if ((DWORD)playerId >= MAX_PLRS) { diff --git a/Source/multi.h b/Source/multi.h index f02eea78..08c10260 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -9,7 +9,7 @@ extern PkPlayerStruct netplr[MAX_PLRS]; extern BOOL gbShouldValidatePackage; extern BYTE gbActivePlayers; extern BOOLEAN gbGameDestroyed; -extern BOOLEAN gbGameUninitialized; +extern BOOLEAN gbSelectProvider; extern BYTE gbMaxPlayers; extern char szPlayerName[128]; extern BYTE gbDeltaSender; From 621477945901c33e92fcb97fd9c1f5914ae45307 Mon Sep 17 00:00:00 2001 From: qndel Date: Sun, 19 Jan 2020 14:23:15 +0100 Subject: [PATCH 07/38] DrawZoom cleanup --- Source/scrollrt.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 37e06ad9..ff6b5928 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -2206,8 +2206,6 @@ static void DrawZoom(int x, int y) blocks = 3; switch (ScrollInfo._sdir) { - case SDIR_NONE: - break; case SDIR_NE: chunks++; case SDIR_N: From bc2ab2289c98f677ce2ecacea6efd4ef3b506fc7 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 20 Jan 2020 16:38:45 +0100 Subject: [PATCH 08/38] Apply enum MFILE_NONE Thanks to @ MaxDesiatov --- Source/missiles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 375cd0bd..ccad5622 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -2447,7 +2447,7 @@ int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micas missile[mi]._mispllvl = spllvl; missile[mi]._mimfnum = midir; - if (missile[mi]._miAnimType == 255 || misfiledata[missile[mi]._miAnimType].mAnimFAmt < 8) + if (missile[mi]._miAnimType == MFILE_NONE || misfiledata[missile[mi]._miAnimType].mAnimFAmt < 8) SetMissDir(mi, 0); else SetMissDir(mi, midir); From e724668be50ec1069b0d871bade80739ca561884 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 20 Jan 2020 16:56:13 +0100 Subject: [PATCH 09/38] Apply enum MFILE_FIREWAL --- Source/missiles.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index ccad5622..af914421 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -945,7 +945,7 @@ void CheckMissileCol(int i, int mindam, int maxdam, BOOL shift, int mx, int my, { int oi; - if (missile[i]._miAnimType != 4 && missile[i]._misource != -1) { + if (missile[i]._miAnimType != MFILE_FIREWAL && missile[i]._misource != -1) { if (!missile[i]._micaster) { if (dMonster[mx][my] > 0) { if (MonsterMHit( @@ -1016,7 +1016,7 @@ void CheckMissileCol(int i, int mindam, int maxdam, BOOL shift, int mx, int my, } } else { if (dMonster[mx][my] > 0) { - if (missile[i]._miAnimType == 4) { + if (missile[i]._miAnimType == MFILE_FIREWAL) { if (MonsterMHit( missile[i]._misource, dMonster[mx][my] - 1, From 3770c8551dc3f8d9820ab9929737b3619611a3c6 Mon Sep 17 00:00:00 2001 From: qndel Date: Mon, 27 Jan 2020 10:52:00 +0100 Subject: [PATCH 10/38] max walkpath (#1996) --- Source/path.cpp | 6 +++--- Source/path.h | 2 +- Source/player.cpp | 4 ++-- defs.h | 2 ++ structs.h | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/path.cpp b/Source/path.cpp index 9988ca72..796ddb28 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -9,7 +9,7 @@ int gdwCurNodes; /* for reconstructing the path after the A* search is done. The longest * possible path is actually 24 steps, even though we can fit 25 */ -int pnode_vals[25]; +int pnode_vals[MAX_PATH_LENGTH]; // a linked list of all visited nodes PATHNODE *pnode_ptr; // a stack for recursively searching nodes @@ -64,12 +64,12 @@ int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, current = next_node; path_length = 0; while (current->Parent) { - if (path_length >= 25) + if (path_length >= MAX_PATH_LENGTH) 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) { + if (path_length != MAX_PATH_LENGTH) { for (i = 0; i < path_length; i++) path[i] = pnode_vals[path_length - i - 1]; return i; diff --git a/Source/path.h b/Source/path.h index 04d30e27..ff333084 100644 --- a/Source/path.h +++ b/Source/path.h @@ -5,7 +5,7 @@ extern PATHNODE path_nodes[MAXPATHNODES]; extern int gdwCurPathStep; extern int gdwCurNodes; -extern int pnode_vals[25]; +extern int pnode_vals[MAX_PATH_LENGTH]; extern PATHNODE *pnode_ptr; extern PATHNODE *pnode_tblptr[MAXPATHNODES]; extern PATHNODE *path_2_nodes; diff --git a/Source/player.cpp b/Source/player.cpp index 19825ac3..b3609686 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3072,11 +3072,11 @@ void CheckNewPath(int pnum) break; } - for (i = 1; i < 25; i++) { + for (i = 1; i < MAX_PATH_LENGTH; i++) { plr[pnum].walkpath[i - 1] = plr[pnum].walkpath[i]; } - plr[pnum].walkpath[24] = WALK_NONE; + plr[pnum].walkpath[MAX_PATH_LENGTH-1] = WALK_NONE; if (plr[pnum]._pmode == PM_STAND) { StartStand(pnum, plr[pnum]._pdir); diff --git a/defs.h b/defs.h index d043f6ed..20c09ac7 100644 --- a/defs.h +++ b/defs.h @@ -68,6 +68,8 @@ #define MAXPATHNODES 300 +#define MAX_PATH_LENGTH 25 + // 256 kilobytes + 3 bytes (demo leftover) for file magic (262147) // final game uses 4-byte magic instead of 3 #define FILEBUFF ((256*1024)+3) diff --git a/structs.h b/structs.h index 408f2889..e100ab47 100644 --- a/structs.h +++ b/structs.h @@ -171,7 +171,7 @@ typedef struct ItemStruct { typedef struct PlayerStruct { int _pmode; - char walkpath[25]; + char walkpath[MAX_PATH_LENGTH]; BOOLEAN plractive; int destAction; int destParam1; From c2587d9786649f62ae9e9d7438da536acf032213 Mon Sep 17 00:00:00 2001 From: qndel Date: Tue, 28 Jan 2020 17:33:34 +0100 Subject: [PATCH 11/38] use enums (#1997) --- Source/control.cpp | 4 ++-- Source/debug.cpp | 6 +++--- Source/diablo.cpp | 16 ++++++++-------- Source/inv.cpp | 2 +- Source/objects.cpp | 4 ++-- Source/pack.cpp | 6 +++--- Source/stores.cpp | 4 ++-- Source/sync.cpp | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 094dd1f2..8f548ead 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1492,14 +1492,14 @@ void CheckPanelInfo() AddPanelString(tempstr, TRUE); s = 0; for (i = 0; i < plr[myplr]._pNumInv; i++) { - if (plr[myplr].InvList[i]._itype != -1 + if (plr[myplr].InvList[i]._itype != ITYPE_NONE && (plr[myplr].InvList[i]._iMiscId == IMISC_SCROLL || plr[myplr].InvList[i]._iMiscId == IMISC_SCROLLT) && plr[myplr].InvList[i]._iSpell == v) { s++; } } for (i = 0; i < MAXBELTITEMS; i++) { - if (plr[myplr].SpdList[i]._itype != -1 + if (plr[myplr].SpdList[i]._itype != ITYPE_NONE && (plr[myplr].SpdList[i]._iMiscId == IMISC_SCROLL || plr[myplr].SpdList[i]._iMiscId == IMISC_SCROLLT) && plr[myplr].SpdList[i]._iSpell == v) { s++; diff --git a/Source/debug.cpp b/Source/debug.cpp index 5af78a27..a260b25b 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -117,12 +117,12 @@ void StoresCheat() numpremium = 0; for (i = 0; i < SMITH_PREMIUM_ITEMS; i++) - premiumitem[i]._itype = -1; + premiumitem[i]._itype = ITYPE_NONE; SpawnPremium(30); for (i = 0; i < 20; i++) - witchitem[i]._itype = -1; + witchitem[i]._itype = ITYPE_NONE; SpawnWitch(30); } @@ -140,7 +140,7 @@ void TakeGoldCheat() for (i = 0; i < MAXBELTITEMS; i++) { if (plr[myplr].SpdList[i]._itype == ITYPE_GOLD) - plr[myplr].SpdList[i]._itype = -1; + plr[myplr].SpdList[i]._itype = ITYPE_NONE; } plr[myplr]._pGold = 0; diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 6f80ba93..5c11df0b 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1339,43 +1339,43 @@ void PressChar(int vkey) return; case '!': case '1': - if (plr[myplr].SpdList[0]._itype != -1 && plr[myplr].SpdList[0]._itype != 11) { + if (plr[myplr].SpdList[0]._itype != ITYPE_NONE && plr[myplr].SpdList[0]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST); } return; case '@': case '2': - if (plr[myplr].SpdList[1]._itype != -1 && plr[myplr].SpdList[1]._itype != 11) { + if (plr[myplr].SpdList[1]._itype != ITYPE_NONE && plr[myplr].SpdList[1]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 1); } return; case '#': case '3': - if (plr[myplr].SpdList[2]._itype != -1 && plr[myplr].SpdList[2]._itype != 11) { + if (plr[myplr].SpdList[2]._itype != ITYPE_NONE && plr[myplr].SpdList[2]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 2); } return; case '$': case '4': - if (plr[myplr].SpdList[3]._itype != -1 && plr[myplr].SpdList[3]._itype != 11) { + if (plr[myplr].SpdList[3]._itype != ITYPE_NONE && plr[myplr].SpdList[3]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 3); } return; case '%': case '5': - if (plr[myplr].SpdList[4]._itype != -1 && plr[myplr].SpdList[4]._itype != 11) { + if (plr[myplr].SpdList[4]._itype != ITYPE_NONE && plr[myplr].SpdList[4]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 4); } return; case '^': case '6': - if (plr[myplr].SpdList[5]._itype != -1 && plr[myplr].SpdList[5]._itype != 11) { + if (plr[myplr].SpdList[5]._itype != ITYPE_NONE && plr[myplr].SpdList[5]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 5); } return; case '&': case '7': - if (plr[myplr].SpdList[6]._itype != -1 && plr[myplr].SpdList[6]._itype != 11) { + if (plr[myplr].SpdList[6]._itype != ITYPE_NONE && plr[myplr].SpdList[6]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 6); } return; @@ -1387,7 +1387,7 @@ void PressChar(int vkey) return; } #endif - if (plr[myplr].SpdList[7]._itype != -1 && plr[myplr].SpdList[7]._itype != 11) { + if (plr[myplr].SpdList[7]._itype != ITYPE_NONE && plr[myplr].SpdList[7]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 7); } return; diff --git a/Source/inv.cpp b/Source/inv.cpp index 003e8cfe..224c2ba4 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1073,7 +1073,7 @@ void CheckInvPaste(int pnum, int mx, int my) plr[pnum].SpdList[ii] = plr[pnum].HoldItem; } else { cn = SwapItem(&plr[pnum].SpdList[ii], &plr[pnum].HoldItem); - if (plr[pnum].HoldItem._itype == 11) + if (plr[pnum].HoldItem._itype == ITYPE_GOLD) plr[pnum]._pGold = CalculateGold(pnum); } drawsbarflag = TRUE; diff --git a/Source/objects.cpp b/Source/objects.cpp index adffaaf2..497e8195 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2941,8 +2941,8 @@ void OperateShrine(int pnum, int i, int sType) } if (cnt == 0) break; - r = random_(0, 7); - if (plr[pnum].InvBody[r]._itype == -1 || plr[pnum].InvBody[r]._iMaxDur == DUR_INDESTRUCTIBLE || plr[pnum].InvBody[r]._iMaxDur == 0) + r = random_(0, NUM_INVLOC); + if (plr[pnum].InvBody[r]._itype == ITYPE_NONE || plr[pnum].InvBody[r]._iMaxDur == DUR_INDESTRUCTIBLE || plr[pnum].InvBody[r]._iMaxDur == 0) continue; plr[pnum].InvBody[r]._iDurability -= 20; diff --git a/Source/pack.cpp b/Source/pack.cpp index 5d15f5d5..920121c3 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -3,7 +3,7 @@ static void PackItem(PkItemStruct *id, ItemStruct *is) { - if (is->_itype == -1) { + if (is->_itype == ITYPE_NONE) { id->idx = 0xFFFF; } else { id->idx = is->IDidx; @@ -111,7 +111,7 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield) static void UnPackItem(PkItemStruct *is, ItemStruct *id) { if (is->idx == 0xFFFF) { - id->_itype = -1; + id->_itype = ITYPE_NONE; } else { if (is->idx == IDI_EAR) { RecreateEar( @@ -237,7 +237,7 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, BOOL killok) if (pnum == myplr) { for (i = 0; i < 20; i++) - witchitem[i]._itype = -1; + witchitem[i]._itype = ITYPE_NONE; } CalcPlrInv(pnum, FALSE); diff --git a/Source/stores.cpp b/Source/stores.cpp index a73da94d..04bfcdde 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -489,7 +489,7 @@ void PrintStoreItem(ItemStruct *x, int l, char iclr) } else { strcat(sstr, "Indestructible, "); } - if (!x->_itype) + if (x->_itype == ITYPE_MISC) sstr[0] = '\0'; str = x->_iMinStr; dex = x->_iMinDex; @@ -552,7 +552,7 @@ void S_ScrollSPBuy(int idx) } for (l = 5; l < 20 && idx < 6; l += 4) { - if (premiumitem[idx]._itype != -1) { + if (premiumitem[idx]._itype != ITYPE_NONE) { iclr = COL_WHITE; if (premiumitem[idx]._iMagical) iclr = COL_BLUE; diff --git a/Source/sync.cpp b/Source/sync.cpp index 5d071030..d817471d 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -170,7 +170,7 @@ void SyncPlrInv(TSyncHeader *pHdr) /// ASSERT: assert((DWORD) sgnSyncPInv < NUM_INVLOC); pItem = &plr[myplr].InvBody[sgnSyncPInv]; - if (pItem->_itype != -1) { + if (pItem->_itype != ITYPE_NONE) { pHdr->bPInvLoc = sgnSyncPInv; pHdr->wPInvIndx = pItem->IDidx; pHdr->wPInvCI = pItem->_iCreateInfo; From a6a89bca3a722d42a017f069f1587946089c8861 Mon Sep 17 00:00:00 2001 From: qndel Date: Fri, 31 Jan 2020 18:59:35 +0100 Subject: [PATCH 12/38] apply TRUE/FALSE --- Source/diablo.cpp | 2 +- Source/engine.cpp | 2 +- Source/interfac.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 5c11df0b..15752095 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1882,7 +1882,7 @@ void timeout_cursor(BOOL bTimeout) SetCursor_(CURSOR_HOURGLASS); force_redraw = 255; } - scrollrt_draw_game_screen(1); + scrollrt_draw_game_screen(TRUE); } else if (sgnTimeoutCurs) { SetCursor_(sgnTimeoutCurs); sgnTimeoutCurs = 0; diff --git a/Source/engine.cpp b/Source/engine.cpp index d71fa31f..5f45e523 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -3816,7 +3816,7 @@ void PlayInGameMovie(char *pszMovie) play_movie(pszMovie, FALSE); ClearScreenBuffer(); force_redraw = 255; - scrollrt_draw_game_screen(1); + scrollrt_draw_game_screen(TRUE); PaletteFadeIn(8); force_redraw = 255; } diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 0e540ab3..277d3627 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -47,7 +47,7 @@ void DrawCutscene() unlock_buf(1); force_redraw = 255; - scrollrt_draw_game_screen(0); + scrollrt_draw_game_screen(FALSE); } void DrawProgress(int screen_x, int screen_y, int progress_id) From a1321539fb43b11b7cf72e6b47b65b6b559d735e Mon Sep 17 00:00:00 2001 From: qndel Date: Fri, 31 Jan 2020 22:53:42 +0100 Subject: [PATCH 13/38] enums --- Source/diablo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 15752095..f9357e9c 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -959,7 +959,7 @@ void RightMouseDown() if (pcurs == 1) { if (pcursinvitem == -1 || !UseInvItem(myplr, pcursinvitem)) CheckPlrSpell(); - } else if (pcurs > 1 && pcurs < 12) { + } else if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) { SetCursor_(CURSOR_HAND); } } From 09c41c666fd2a1700c74adf812f714bebc389092 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 1 Feb 2020 00:08:36 +0100 Subject: [PATCH 14/38] Update monster.cpp --- Source/monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 7a786262..b1d966a4 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1644,7 +1644,7 @@ void MonstStartKill(int i, int pnum, BOOL sendmsg) SetRndSeed(monster[i]._mRndSeed); if (QuestStatus(QTYPE_GARB) && monster[i].mName == UniqMonst[UMT_GARBUD].mName) { CreateTypeItem(monster[i]._mx + 1, monster[i]._my + 1, TRUE, ITYPE_MACE, IMISC_NONE, TRUE, FALSE); - } else if (i > 3) { + } else if (i > MAX_PLRS - 1) { // Golems should not spawn items SpawnItem(i, monster[i]._mx, monster[i]._my, sendmsg); } if (monster[i].MType->mtype == MT_DIABLO) From 20621a0642fa15d8ffc44cce50bdd61472b863fe Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 14 Feb 2020 13:12:54 +0100 Subject: [PATCH 15/38] add all.h and use in place of diablo.h (#2005) Now diablo.h is treated in the same way as all other header files of Source, as it only contains the declarations of global variables and functions of diablo.cpp. Besides consistency, this also enables mods to include diablo.h just like any other header file without having to include every header file (and without having to include C++ specific aspects of the now all.h). --- Source/all.h | 86 +++++++++++++++++++++++++++++++++++++++++++++ Source/appfat.cpp | 2 +- Source/automap.cpp | 2 +- Source/capture.cpp | 2 +- Source/codec.cpp | 2 +- Source/control.cpp | 2 +- Source/cursor.cpp | 2 +- Source/dead.cpp | 2 +- Source/debug.cpp | 2 +- Source/diablo.cpp | 2 +- Source/diablo.h | 81 ------------------------------------------ Source/doom.cpp | 2 +- Source/drlg_l1.cpp | 2 +- Source/drlg_l2.cpp | 2 +- Source/drlg_l3.cpp | 2 +- Source/drlg_l4.cpp | 2 +- Source/dthread.cpp | 2 +- Source/dx.cpp | 2 +- Source/effects.cpp | 2 +- Source/encrypt.cpp | 2 +- Source/engine.cpp | 2 +- Source/error.cpp | 2 +- Source/fault.cpp | 2 +- Source/gamemenu.cpp | 2 +- Source/gendung.cpp | 2 +- Source/gmenu.cpp | 2 +- Source/help.cpp | 2 +- Source/init.cpp | 2 +- Source/interfac.cpp | 2 +- Source/inv.cpp | 2 +- Source/itemdat.cpp | 2 +- Source/items.cpp | 2 +- Source/lighting.cpp | 2 +- Source/loadsave.cpp | 2 +- Source/logging.cpp | 2 +- Source/mainmenu.cpp | 2 +- Source/minitext.cpp | 2 +- Source/misdat.cpp | 2 +- Source/missiles.cpp | 2 +- Source/monstdat.cpp | 2 +- Source/monster.cpp | 2 +- Source/movie.cpp | 2 +- Source/mpqapi.cpp | 2 +- Source/msg.cpp | 2 +- Source/msgcmd.cpp | 2 +- Source/multi.cpp | 2 +- Source/nthread.cpp | 2 +- Source/objdat.cpp | 2 +- Source/objects.cpp | 2 +- Source/pack.cpp | 2 +- Source/palette.cpp | 2 +- Source/path.cpp | 2 +- Source/pfile.cpp | 2 +- Source/player.cpp | 2 +- Source/plrmsg.cpp | 2 +- Source/portal.cpp | 2 +- Source/quests.cpp | 2 +- Source/render.cpp | 2 +- Source/restrict.cpp | 2 +- Source/scrollrt.cpp | 2 +- Source/setmaps.cpp | 2 +- Source/sha.cpp | 2 +- Source/sound.cpp | 2 +- Source/spelldat.cpp | 2 +- Source/spells.cpp | 2 +- Source/stores.cpp | 2 +- Source/sync.cpp | 2 +- Source/textdat.cpp | 2 +- Source/themes.cpp | 2 +- Source/tmsg.cpp | 2 +- Source/town.cpp | 2 +- Source/towners.cpp | 2 +- Source/track.cpp | 2 +- Source/trigs.cpp | 2 +- Source/wave.cpp | 2 +- 75 files changed, 159 insertions(+), 154 deletions(-) create mode 100644 Source/all.h diff --git a/Source/all.h b/Source/all.h new file mode 100644 index 00000000..4a19fbbf --- /dev/null +++ b/Source/all.h @@ -0,0 +1,86 @@ +#ifndef __ALL_H__ +#define __ALL_H__ + +#include "../types.h" + +#ifdef __cplusplus +extern "C" { +#endif +#include "appfat.h" +#include "automap.h" +#include "capture.h" +#include "codec.h" +#include "control.h" +#include "cursor.h" +#include "dead.h" +#include "debug.h" +#include "diablo.h" +#include "doom.h" +#include "drlg_l1.h" +#include "drlg_l2.h" +#include "drlg_l3.h" +#include "drlg_l4.h" +#include "dthread.h" +#include "dx.h" +#include "effects.h" +#include "encrypt.h" +#include "engine.h" +#include "error.h" +#include "fault.h" +#include "gamemenu.h" +#include "gendung.h" +#include "gmenu.h" +#include "help.h" +#include "init.h" +#include "interfac.h" +#include "inv.h" +#include "itemdat.h" +#include "items.h" +#include "lighting.h" +#include "loadsave.h" +#include "logging.h" +#include "mainmenu.h" +#include "minitext.h" +#include "misdat.h" +#include "missiles.h" +#include "monstdat.h" +#include "monster.h" +#include "movie.h" +#include "mpqapi.h" +#include "msg.h" +#include "msgcmd.h" +#include "multi.h" +#include "nthread.h" +#include "objdat.h" +#include "objects.h" +#include "pack.h" +#include "palette.h" +#include "path.h" +#include "pfile.h" +#include "player.h" +#include "plrmsg.h" +#include "portal.h" +#include "quests.h" +#include "restrict.h" +#include "scrollrt.h" +#include "setmaps.h" +#include "sha.h" +#include "sound.h" +#include "spelldat.h" +#include "spells.h" +#include "stores.h" +#include "sync.h" +#include "textdat.h" // check file name +#include "themes.h" +#include "tmsg.h" +#include "town.h" +#include "towners.h" +#include "track.h" +#include "trigs.h" +#include "wave.h" +#include "render.h" // linked last, likely .s/.asm +#ifdef __cplusplus +} +#endif + +#endif /* __ALL_H__ */ diff --git a/Source/appfat.cpp b/Source/appfat.cpp index 41154a07..51be3e1d 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" char sz_error_buf[256]; diff --git a/Source/automap.cpp b/Source/automap.cpp index 7f1726c3..57867d61 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" // BUGFIX: only the first 256 elements are ever read WORD automaptype[512]; diff --git a/Source/capture.cpp b/Source/capture.cpp index b0583f53..ce3a07bf 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" static BOOL CaptureHdr(HANDLE hFile, short width, short height) { diff --git a/Source/codec.cpp b/Source/codec.cpp index 157c2314..835cf447 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" struct CodecSignature { DWORD checksum; diff --git a/Source/control.cpp b/Source/control.cpp index 8f548ead..881197b3 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" BYTE sgbNextTalkSave; BYTE sgbTalkSavePos; diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 9e590080..d463c15a 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int cursH; int icursH28; diff --git a/Source/dead.cpp b/Source/dead.cpp index eb4f8727..00e87d27 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" // unused, this was probably for blood boil/burn int spurtndx; diff --git a/Source/debug.cpp b/Source/debug.cpp index a260b25b..f01542c6 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #ifdef _DEBUG BOOL update_seed_check = FALSE; diff --git a/Source/diablo.cpp b/Source/diablo.cpp index f9357e9c..9bff14ef 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/diablo.h b/Source/diablo.h index 84de4553..8127673e 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -2,87 +2,6 @@ #ifndef __DIABLO_H__ #define __DIABLO_H__ -#include "../types.h" - -#ifdef __cplusplus -extern "C" { -#endif -#include "appfat.h" -#include "automap.h" -#include "capture.h" -#include "codec.h" -#include "control.h" -#include "cursor.h" -#include "dead.h" -#include "debug.h" -#include "doom.h" -#include "drlg_l1.h" -#include "drlg_l2.h" -#include "drlg_l3.h" -#include "drlg_l4.h" -#include "dthread.h" -#include "dx.h" -#include "effects.h" -#include "encrypt.h" -#include "engine.h" -#include "error.h" -#include "fault.h" -#include "gamemenu.h" -#include "gendung.h" -#include "gmenu.h" -#include "help.h" -#include "init.h" -#include "interfac.h" -#include "inv.h" -#include "itemdat.h" -#include "items.h" -#include "lighting.h" -#include "loadsave.h" -#include "logging.h" -#include "mainmenu.h" -#include "minitext.h" -#include "misdat.h" -#include "missiles.h" -#include "monstdat.h" -#include "monster.h" -#include "movie.h" -#include "mpqapi.h" -#include "msg.h" -#include "msgcmd.h" -#include "multi.h" -#include "nthread.h" -#include "objdat.h" -#include "objects.h" -#include "pack.h" -#include "palette.h" -#include "path.h" -#include "pfile.h" -#include "player.h" -#include "plrmsg.h" -#include "portal.h" -#include "quests.h" -#include "restrict.h" -#include "scrollrt.h" -#include "setmaps.h" -#include "sha.h" -#include "sound.h" -#include "spelldat.h" -#include "spells.h" -#include "stores.h" -#include "sync.h" -#include "textdat.h" // check file name -#include "themes.h" -#include "tmsg.h" -#include "town.h" -#include "towners.h" -#include "track.h" -#include "trigs.h" -#include "wave.h" -#include "render.h" // linked last, likely .s/.asm -#ifdef __cplusplus -} -#endif - extern HWND ghMainWnd; extern int glMid1Seed[NUMLEVELS]; extern int glMid2Seed[NUMLEVELS]; diff --git a/Source/doom.cpp b/Source/doom.cpp index 03d7fe2e..b336849e 100644 --- a/Source/doom.cpp +++ b/Source/doom.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int doom_quest_time; int doom_stars_drawn; diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index cfa0eb0c..64391da7 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" BYTE L5dungeon[80][80]; BYTE L5dflags[DMAXX][DMAXY]; diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index f7f7ad19..b66ccab9 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -1,5 +1,5 @@ #ifndef SPAWN -#include "diablo.h" +#include "all.h" int nSx1; int nSx2; diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 5c0a8526..43a1a67e 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1,5 +1,5 @@ #ifndef SPAWN -#include "diablo.h" +#include "all.h" BOOLEAN lavapool; int abyssx; diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 9097dce6..9cf009bf 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int diabquad1x; int diabquad1y; diff --git a/Source/dthread.cpp b/Source/dthread.cpp index 2c268c25..b17457cf 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #ifdef __cplusplus diff --git a/Source/dx.cpp b/Source/dx.cpp index 149541f1..99c5dc33 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" BYTE *sgpBackBuf; diff --git a/Source/effects.cpp b/Source/effects.cpp index 3bb4207d..0afb731a 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" int sfxdelay; diff --git a/Source/encrypt.cpp b/Source/encrypt.cpp index a1d28721..50abc783 100644 --- a/Source/encrypt.cpp +++ b/Source/encrypt.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/PKWare/pkware.h" DWORD hashtable[1280]; diff --git a/Source/engine.cpp b/Source/engine.cpp index 5f45e523..2278ccdb 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #ifdef USE_ASM diff --git a/Source/error.cpp b/Source/error.cpp index 557198b6..6a87b9c8 100644 --- a/Source/error.cpp +++ b/Source/error.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" char msgtable[MAX_SEND_STR_LEN]; char msgdelay; diff --git a/Source/fault.cpp b/Source/fault.cpp index 72326f63..64d2f5d8 100644 --- a/Source/fault.cpp +++ b/Source/fault.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter; diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index 0445a70a..09124e8d 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" TMenuItem sgSingleMenu[6] = { // clang-format off diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 06a85a05..e9c0cde3 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" WORD level_frame_types[MAXTILES]; int themeCount; diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index c25c6c71..3c4d4fe1 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" BYTE *optbar_cel; BOOLEAN mouseNavigation; diff --git a/Source/help.cpp b/Source/help.cpp index 8996ac2e..0922e1a5 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int help_select_line; int dword_634494; diff --git a/Source/init.cpp b/Source/init.cpp index 9bbd57ce..d57d9138 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 277d3627..e3b3ebd1 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" void *sgpBackCel; diff --git a/Source/inv.cpp b/Source/inv.cpp index 224c2ba4..371fd41f 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" BOOL invflag; BYTE *pInvCels; diff --git a/Source/itemdat.cpp b/Source/itemdat.cpp index 39476441..887ab8b7 100644 --- a/Source/itemdat.cpp +++ b/Source/itemdat.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" ItemDataStruct AllItemsList[] = { // clang-format off diff --git a/Source/items.cpp b/Source/items.cpp index 048dff47..22ee22a3 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int itemactive[MAXITEMS]; BOOL uitemflag; diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 21ca4a3a..5343d3c6 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" LightListStruct VisionList[MAXVISION]; BYTE lightactive[MAXLIGHTS]; diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index cc31275f..cbbf4ebc 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" BYTE *tbuff; diff --git a/Source/logging.cpp b/Source/logging.cpp index 05d4d688..c0ea8a7c 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #ifdef __cplusplus diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index 039ad6e8..1c66f703 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/minitext.cpp b/Source/minitext.cpp index 0a250b00..4ef780a1 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int qtexty; char *qtextptr; diff --git a/Source/misdat.cpp b/Source/misdat.cpp index 142b975c..6449e655 100644 --- a/Source/misdat.cpp +++ b/Source/misdat.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" MissileData missiledata[] = { // clang-format off diff --git a/Source/missiles.cpp b/Source/missiles.cpp index af914421..96910d80 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int missileactive[MAXMISSILES]; int missileavail[MAXMISSILES]; diff --git a/Source/monstdat.cpp b/Source/monstdat.cpp index a4e029e0..c9bed996 100644 --- a/Source/monstdat.cpp +++ b/Source/monstdat.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" MonsterData monsterdata[] = { // clang-format off diff --git a/Source/monster.cpp b/Source/monster.cpp index b1d966a4..924ba107 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" // Tracks which missile files are already loaded diff --git a/Source/movie.cpp b/Source/movie.cpp index e8d819fc..40c513c3 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" BYTE movie_playing; diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 25435212..985eb25b 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" DWORD sgdwMpqOffset; diff --git a/Source/msg.cpp b/Source/msg.cpp index 693abe1f..7d2a27e6 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/msgcmd.cpp b/Source/msgcmd.cpp index 5122c2c1..26bd5bbb 100644 --- a/Source/msgcmd.cpp +++ b/Source/msgcmd.cpp @@ -2,7 +2,7 @@ #include // for offsetof #include // for typeid -#include "diablo.h" +#include "all.h" #include "list.h" #define COMMAND_LEN 128 diff --git a/Source/multi.cpp b/Source/multi.cpp index 1d2f8532..75da357f 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/nthread.cpp b/Source/nthread.cpp index ebbc4f62..4911067a 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" BYTE sgbNetUpdateRate; diff --git a/Source/objdat.cpp b/Source/objdat.cpp index d21bb893..e61f9c4f 100644 --- a/Source/objdat.cpp +++ b/Source/objdat.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int ObjTypeConv[113] = { 0, diff --git a/Source/objects.cpp b/Source/objects.cpp index 497e8195..07b3a32e 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int trapid; int trapdir; diff --git a/Source/pack.cpp b/Source/pack.cpp index 920121c3..2ebe3946 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" static void PackItem(PkItemStruct *id, ItemStruct *is) diff --git a/Source/palette.cpp b/Source/palette.cpp index 93cadc93..65d35665 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" PALETTEENTRY logical_palette[256]; diff --git a/Source/path.cpp b/Source/path.cpp index 796ddb28..d0dd05d7 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" // preallocated nodes, search is terminated after 300 nodes are visited PATHNODE path_nodes[MAXPATHNODES]; diff --git a/Source/pfile.cpp b/Source/pfile.cpp index e3f964c0..9fea06a5 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/player.cpp b/Source/player.cpp index b3609686..9186d2c8 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" int plr_lframe_size; diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index 09c6fe84..185739f3 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" static BYTE plr_msg_slot; _plrmsg plr_msgs[PMSG_COUNT]; diff --git a/Source/portal.cpp b/Source/portal.cpp index edf94618..038c33d8 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" PortalStruct portal[MAXPORTAL]; int portalindex; diff --git a/Source/quests.cpp b/Source/quests.cpp index 21d1e3f2..5517d745 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int qtopline; BOOL questlog; diff --git a/Source/render.cpp b/Source/render.cpp index bf740a63..c4ff1e4d 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "_asm.cpp" int WorldBoolFlag = 0; diff --git a/Source/restrict.cpp b/Source/restrict.cpp index 643c54c5..0522480c 100644 --- a/Source/restrict.cpp +++ b/Source/restrict.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" BOOL SystemSupported() { diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index ff6b5928..4bd01159 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" int light_table_index; diff --git a/Source/setmaps.cpp b/Source/setmaps.cpp index 273eea86..51b0a345 100644 --- a/Source/setmaps.cpp +++ b/Source/setmaps.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" // BUGFIX: constant data should be const BYTE SkelKingTrans1[8] = { diff --git a/Source/sha.cpp b/Source/sha.cpp index 2e851435..14ac7133 100644 --- a/Source/sha.cpp +++ b/Source/sha.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" SHA1Context sgSHA1[3]; diff --git a/Source/sound.cpp b/Source/sound.cpp index 19fabfaf..b7de83ae 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" LPDIRECTSOUNDBUFFER DSBs[8]; diff --git a/Source/spelldat.cpp b/Source/spelldat.cpp index 84a02cce..8337d598 100644 --- a/Source/spelldat.cpp +++ b/Source/spelldat.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" SpellData spelldata[MAX_SPELLS] = { // clang-format off diff --git a/Source/spells.cpp b/Source/spells.cpp index f95ce8f8..5cb38763 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int GetManaAmount(int id, int sn) { diff --git a/Source/stores.cpp b/Source/stores.cpp index 04bfcdde..ab9990e2 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int stextup; int storenumh; diff --git a/Source/sync.cpp b/Source/sync.cpp index d817471d..636c8afc 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" WORD sync_word_6AA708[MAXMONSTERS]; int sgnMonsters; diff --git a/Source/textdat.cpp b/Source/textdat.cpp index 2484a0c7..b3432759 100644 --- a/Source/textdat.cpp +++ b/Source/textdat.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" /* todo: move text out of struct */ diff --git a/Source/themes.cpp b/Source/themes.cpp index 508e85c1..4c9a8ddd 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int numthemes; BOOL armorFlag; diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index 634d1b21..27783f1e 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" static TMsg *sgpTimedMsgHead; diff --git a/Source/town.cpp b/Source/town.cpp index 6d804f63..3289caaf 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" /** * Used under building to avoid HOM and outside of level diff --git a/Source/towners.cpp b/Source/towners.cpp index 65abc2ed..09782e23 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" BOOL storeflag; int sgnCowMsg; diff --git a/Source/track.cpp b/Source/track.cpp index 86f3d5f1..11552f0d 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" static BYTE sgbIsScrolling; diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 1265404f..04447c0b 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" BOOL townwarps[3]; BOOL trigflag; diff --git a/Source/wave.cpp b/Source/wave.cpp index d7f753a4..fa8bd799 100644 --- a/Source/wave.cpp +++ b/Source/wave.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" BOOL WCloseFile(HANDLE file) From f1616060e52325796b52c87931ecc6b79ab72545 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 15 Feb 2020 04:26:51 +0100 Subject: [PATCH 16/38] Document CL2 render functions --- Source/control.cpp | 12 ++--- Source/engine.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++++ Source/lighting.cpp | 56 ++++++++++++---------- Source/scrollrt.cpp | 86 +++++++++++++++++----------------- 4 files changed, 193 insertions(+), 73 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 881197b3..5a1747fe 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -216,8 +216,8 @@ int SpellPages[6][7] = { /** * Draw spell cell onto the back buffer. - * @param xp Backbuffer coordinate - * @param yp Backbuffer coordinate + * @param xp Back buffer coordinate + * @param yp Back buffer coordinate * @param Trans Pointer to the cel buffer. * @param nCel Index of the cel frame to draw. 0 based. * @param w Width of the frame. @@ -614,8 +614,8 @@ void ToggleSpell(int slot) } /** - * @brief Print letter to the backbuffer - * @param nOffset Backbuffer offset + * @brief Print letter to the back buffer + * @param nOffset Back buffer offset * @param nCel Number of letter in Windows-1252 * @param col text_color color value */ @@ -1006,8 +1006,8 @@ void DrawPanelBox(int x, int y, int w, int h, int sx, int sy) * @param pCelBuff Buffer of the empty flask cel. * @param min Top of the flask cel section to draw. * @param max Bottom of the flask cel section to draw. - * @param sx X Backbuffer coordinate - * @param sy Y Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate */ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int sx, int sy) { diff --git a/Source/engine.cpp b/Source/engine.cpp index 2278ccdb..e45e487c 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -16,7 +16,14 @@ static CCritSect sgMemCrit; int SeedCount; BOOL gbNotInView; // valid - if x/y are in bounds +/** + * Specifies the increment used in the Borland C/C++ pseudo-random. + */ const int RndInc = 1; + +/** + * Specifies the multiplier used in the Borland C/C++ pseudo-random number generator algorithm. + */ const int RndMult = 0x015A4E35; __FINLINE BYTE *CelGetFrame(BYTE *pCelBuff, int nCel, int *nDataSize) @@ -2467,6 +2474,9 @@ DWORD LoadFileWithMem(const char *pszName, void *p) /** * @brief Apply the color swaps to a CL2 sprite + * @param p CL2 buffer + * @param ttbl Palette translation table + * @param nCel Frame number in CL2 file */ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel) { @@ -2508,6 +2518,12 @@ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel) } /** + * @brief Blit CL2 sprite, to the back buffer at the given coordianates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -2548,6 +2564,13 @@ void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, nWidth); } +/** + * @brief Blit CL2 sprite to the given buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth Width of sprite + */ void Cl2Blit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { #ifdef USE_ASM @@ -2690,6 +2713,13 @@ void Cl2Blit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) } /** + * @brief Blit a solid colder shape one pix larger then the given sprite shape, to the back buffer at the given coordianates + * @param col Color index from current palette + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -2731,6 +2761,14 @@ void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid col); } +/** + * @brief Blit a solid colder shape one pix larger then the given sprite shape, to the given buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth Width of sprite + * @param col Color index from current palette + */ void Cl2BlitOutline(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col) { #ifdef USE_ASM @@ -2894,8 +2932,15 @@ void Cl2BlitOutline(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, } /** + * @brief Blit CL2 sprite, and apply a given lighting, to the back buffer at the given coordianates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 + * @param light Light shade to use */ void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) { @@ -2945,6 +2990,14 @@ void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C &pLightTbl[idx]); } +/** + * @brief Blit CL2 sprite, and apply lighting, to the given buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth Width of sprite + * @param pTable Light color table + */ void Cl2BlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) { #ifdef USE_ASM @@ -3096,6 +3149,12 @@ void Cl2BlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, B } /** + * @brief Blit CL2 sprite, and apply lighting, to the back buffer at the given coordinates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -3140,6 +3199,12 @@ void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelS } /** + * @brief Blit CL2 sprite to the back buffer, while checking bounds, at the given coordianates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -3180,6 +3245,13 @@ void Cl2DrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSk nWidth); } +/** + * @brief Blit CL2 sprite to pDecodeTo while checking bounds + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth Width of sprite + */ void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { #ifdef USE_ASM @@ -3335,6 +3407,13 @@ void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) } /** + * @brief Blit a solid colder shape one pix larger then the given sprite shape, to the back buffer at the given coordianates, while checking bounds + * @param col Color index from current palette + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -3378,6 +3457,14 @@ void Cl2DrawOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int gpBufEnd += BUFFER_WIDTH; } +/** + * @brief Blit a solid colder shape one pix larger then the given sprite shape, to the given buffer, while checking bounds + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth Width of sprite + * @param col Color index from current palette + */ void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col) { #ifdef USE_ASM @@ -3552,8 +3639,15 @@ void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi } /** + * @brief Blit CL2 sprite, and apply a given lighting, to the back buffer at the given coordianates, while checking bounds + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 + * @param light light shade to use */ void Cl2DrawLightTblSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) { @@ -3603,6 +3697,14 @@ void Cl2DrawLightTblSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i &pLightTbl[idx]); } +/** + * @brief Blit CL2 sprite, and apply light, to pDecodeTo while checking bounds + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth With of CL2 sprite + * @param pTable Light color table + */ void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) { #ifdef USE_ASM @@ -3767,6 +3869,12 @@ void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt } /** + * @brief Blit CL2 sprite, and apply lighting, to the back buffer at the given coordinates, while checking bounds + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -3810,6 +3918,10 @@ void Cl2DrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cl2BlitSafe(pDecodeTo, pRLEBytes, nSize, nWidth); } +/** + * @brief Fade to black and play a video + * @param pszMovie file path of movie + */ void PlayInGameMovie(char *pszMovie) { PaletteFadeOut(8); diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 5343d3c6..51b8edaa 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -14,28 +14,29 @@ int visionid; BYTE *pLightTbl; BOOL lightflag; -// CrawlTable specifies X- and Y-coordinate deltas from a missile target -// coordinate. -// -// n=4 -// -// y -// ^ -// | 1 -// | 3#4 -// | 2 -// +-----> x -// -// n=16 -// -// y -// ^ -// | 314 -// | B7 8C -// | F # G -// | D9 AE -// | 526 -// +-------> x +/** + * CrawlTable specifies X- and Y-coordinate deltas from a missile target coordinate. + * + * n=4 + * + * y + * ^ + * | 1 + * | 3#4 + * | 2 + * +-----> x + * + * n=16 + * + * y + * ^ + * | 314 + * | B7 8C + * | F # G + * | D9 AE + * | 526 + * +-------> x + */ char CrawlTable[2749] = { 1, 0, 0, @@ -400,8 +401,9 @@ char CrawlTable[2749] = { -18, -1, 18, -1, -18, 0, 18, 0 }; -// pCrawlTable maps from circle radius to the X- and Y-coordinate deltas from -// the center of a circle. +/** + * pCrawlTable maps from circle radius to the X- and Y-coordinate deltas from the center of a circle. + */ char *pCrawlTable[19] = { CrawlTable, CrawlTable + 3, @@ -423,6 +425,9 @@ char *pCrawlTable[19] = { CrawlTable + 2187, CrawlTable + 2460 }; +/** + * vCrawlTable specifies the X- Y-coordinate offsets of lighting visions. + */ BYTE vCrawlTable[23][30] = { { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0 }, { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1 }, @@ -470,6 +475,9 @@ BYTE byte_49463C[18][18] = /* unused */ { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 } }; +/** + * RadiusAdj maps from vCrawlTable index to lighting vision radius adjustment. + */ BYTE RadiusAdj[23] = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0 }; void RotateRadius(int *x, int *y, int *dx, int *dy, int *lx, int *ly, int *bx, int *by) diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 4bd01159..92c5d8e4 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -67,7 +67,7 @@ void ClearCursor() // CODE_FIX: this was supposed to be in cursor.cpp } /** - * @brief Remove the cursor from the backbuffer + * @brief Remove the cursor from the back buffer */ static void scrollrt_draw_cursor_back_buffer() { @@ -99,7 +99,7 @@ static void scrollrt_draw_cursor_back_buffer() } /** - * @brief Draw the cursor on the backbuffer + * @brief Draw the cursor on the back buffer */ static void scrollrt_draw_cursor_item() { @@ -179,8 +179,8 @@ static void scrollrt_draw_cursor_item() * @brief Render a missile sprite * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw * @param pre Is the sprite in the background @@ -250,8 +250,8 @@ void DrawMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL pre * @brief Render a missile sprite, check for overdraw on lower screen * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw * @param pre Is the sprite in the background @@ -321,8 +321,8 @@ void DrawClippedMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, B * @brief Render a monster sprite * @param x dPiece coordinate * @param y dPiece coordinate - * @param mx Backbuffer coordinate - * @param my Backbuffer coordinate + * @param mx Back buffer coordinate + * @param my Back buffer coordinate * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw */ @@ -383,8 +383,8 @@ static void DrawMonster(int x, int y, int mx, int my, int m, int CelSkip, int Ce * @brief Render a monster sprite, check for overdraw on lower screen * @param x dPiece coordinate * @param y dPiece coordinate - * @param mx Backbuffer coordinate - * @param my Backbuffer coordinate + * @param mx Back buffer coordinate + * @param my Back buffer coordinate * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw */ @@ -446,8 +446,8 @@ static void DrawClippedMonster(int x, int y, int mx, int my, int m, int CelSkip, * @param pnum Player id * @param x dPiece coordinate * @param y dPiece coordinate - * @param px Backbuffer coordinate - * @param py Backbuffer coordinate + * @param px Back buffer coordinate + * @param py Back buffer coordinate * @param pCelBuff sprite buffer * @param nCel frame * @param nWidth width @@ -532,8 +532,8 @@ static void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i * @param pnum Player id * @param x dPiece coordinate * @param y dPiece coordinate - * @param px Backbuffer coordinate - * @param py Backbuffer coordinate + * @param px Back buffer coordinate + * @param py Back buffer coordinate * @param pCelBuff sprite buffer * @param nCel frame * @param nWidth width @@ -617,8 +617,8 @@ static void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCel * @brief Render a monster sprite * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw * @param clipped check for overdraw on lower screen @@ -663,8 +663,8 @@ void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL * @brief Render an object sprite * @param x dPiece coordinate * @param y dPiece coordinate - * @param ox Backbuffer coordinate - * @param oy Backbuffer coordinate + * @param ox Back buffer coordinate + * @param oy Back buffer coordinate * @param pre Is the sprite in the background * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw @@ -726,8 +726,8 @@ static void DrawObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int * @brief Render an object sprite, check for overdraw on lower screen * @param x dPiece coordinate * @param y dPiece coordinate - * @param ox Backbuffer coordinate - * @param oy Backbuffer coordinate + * @param ox Back buffer coordinate + * @param oy Back buffer coordinate * @param pre Is the sprite in the background * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw @@ -791,8 +791,8 @@ static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, i * @param pBuff Pointer to output buffer at location sx,sy * @param y dPiece coordinate * @param x dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate */ static void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy) { @@ -847,8 +847,8 @@ static void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int * @param pBuff where to render to with sx,sy already applied * @param sx dPiece coordinate * @param sy dPiece coordinate - * @param dx Backbuffer coordinate - * @param dy Backbuffer coordinate + * @param dx Back buffer coordinate + * @param dy Back buffer coordinate * @param eflag Should the sorting workaround be applied */ static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag) @@ -1069,8 +1069,8 @@ static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, i * @brief Render a row of tile * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param chunks tile width of row * @param eflag is it an even (0) or odd (1) row */ @@ -1233,8 +1233,8 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int row * @param x dPiece coordinate * @param row The current row being rendered * @param CelSkip chunks of cell to skip - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate */ static void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int row, int CelSkip, int sx, int sy) { @@ -1312,8 +1312,8 @@ static void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int row, i * @param sy dPiece coordinate * @param row The current row being rendered * @param CelSkip chunks of cell to skip - * @param dx Backbuffer coordinate - * @param dy Backbuffer coordinate + * @param dx Back buffer coordinate + * @param dy Back buffer coordinate * @param eflag Should the sorting workaround be applied */ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int row, int CelSkip, int dx, int dy, int eflag) @@ -1534,8 +1534,8 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int row * @brief Render a row of tile, checking for overdrawing on lower part of screen * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param chunks tile width of row * @param row current row being rendered * @param eflag is it an even (0) or odd (1) row @@ -1651,8 +1651,8 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int row, int CelC * @param x dPiece coordinate * @param row The current row being rendered * @param CelCap chunks of cell to skip - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate */ static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int row, int CelCap, int sx, int sy) { @@ -1710,8 +1710,8 @@ static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int row, int CelCap, * @param sy dPiece coordinate * @param row The current row being rendered * @param CelCap chunks of cell to skip - * @param dx Backbuffer coordinate - * @param dy Backbuffer coordinate + * @param dx Back buffer coordinate + * @param dy Back buffer coordinate * @param eflag Should the sorting workaround be applied */ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int row, int CelCap, int dx, int dy, int eflag) @@ -1922,8 +1922,8 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int row, int CelC * @brief Render a row of tile, checking for overdrawing on upper part of screen * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param chunks tile width of row * @param row current row being rendered * @param eflag is it an even (0) or odd (1) row @@ -2569,11 +2569,11 @@ static void DrawFPS() #endif /** - * @brief Update part of the screen from the backbuffer - * @param dwX Backbuffer coordinate - * @param dwY Backbuffer coordinate - * @param dwWdt Backbuffer coordinate - * @param dwHgt Backbuffer coordinate + * @brief Update part of the screen from the back buffer + * @param dwX Back buffer coordinate + * @param dwY Back buffer coordinate + * @param dwWdt Back buffer coordinate + * @param dwHgt Back buffer coordinate */ static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt) { From a29d64b923f5fdc9266ebe4bffb817743d2b71a7 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 15 Feb 2020 18:40:58 +0100 Subject: [PATCH 17/38] Document engine.cpp functions --- Source/engine.cpp | 241 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 219 insertions(+), 22 deletions(-) diff --git a/Source/engine.cpp b/Source/engine.cpp index e45e487c..5836aafa 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -26,6 +26,12 @@ const int RndInc = 1; */ const int RndMult = 0x015A4E35; +/** + * @brief Find the start of a CEL frame + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nDataSize Will be set to frame size + */ __FINLINE BYTE *CelGetFrame(BYTE *pCelBuff, int nCel, int *nDataSize) { DWORD *pFrameTable; @@ -38,6 +44,12 @@ __FINLINE BYTE *CelGetFrame(BYTE *pCelBuff, int nCel, int *nDataSize) return pCelBuff + nCellStart; } +/** + * @brief Calculate the size of a CEL frame + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @return Size of CEL in bytes + */ __FINLINE int CelGetFrameSize(BYTE *pCelBuff, int nCel) { DWORD *pFrameTable; @@ -47,6 +59,13 @@ __FINLINE int CelGetFrameSize(BYTE *pCelBuff, int nCel) return SwapLE32(pFrameTable[nCel + 1]) - SwapLE32(pFrameTable[nCel]); } +/** + * @brief Blit CEL sprite to the given buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite + */ void CelBlit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { int w; @@ -146,6 +165,14 @@ void CelBlit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) #endif } +/** + * @brief Blit CEL sprite to the back buffer at the given coordinates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite + */ void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { int nDataSize; @@ -162,6 +189,13 @@ void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) CelBlit(&gpBuffer[sx + PitchTbl[sy]], pRLEBytes, nDataSize, nWidth); } +/** + * @brief Blit a given CEL frame to the given buffer + * @param pBuff Target buffer + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite + */ void CelBlitFrame(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth) { int nDataSize; @@ -179,6 +213,12 @@ void CelBlitFrame(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth) } /** + * @brief Same as CelDraw but with the option to skip parts of the top and bottom of the sprite + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -220,6 +260,11 @@ void CelClippedDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Ce } /** + * @brief Same as CelBlit but with the option to skip parts of the top and bottom of the sprite + * @param pBuff Target buffer + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -256,6 +301,13 @@ void CelClippedBlit(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSk CelBlit(pBuff, pRLEBytes + nDataStart, nDataSize, nWidth); } +/** + * @brief Blit CEL sprite, and apply lighting, to the given buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite + */ void CelBlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { int w; @@ -409,6 +461,13 @@ void CelBlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) #endif } +/** + * @brief Blit CEL sprite, and apply lighting, to the given buffer, with transparancy applied + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite + */ void CelBlitLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { int w; @@ -596,6 +655,14 @@ void CelBlitLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWid #endif } +/** + * @brief Blit CEL sprite, and apply lighting, to the back buffer at the given coordinates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite + */ void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { int nDataSize; @@ -618,6 +685,12 @@ void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) } /** + * @brief Same as CelDrawLight but with the option to skip parts of the top and bottom of the sprite + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -661,6 +734,11 @@ void CelClippedDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i } /** + * @brief Same as CelBlitLightTrans but with the option to skip parts of the top and bottom of the sprite + * @param pBuff Target buffer + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -705,8 +783,15 @@ void CelClippedBlitLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, } /** + * @brief Blit CEL sprite, and apply lighting, to the back buffer at the given coordinates, translated to a red hue + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 + * @param light Light shade to use */ void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) { @@ -823,6 +908,10 @@ void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C /** * @brief Same as CelBlit but checks for drawing outside the buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite */ void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { @@ -938,6 +1027,12 @@ void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) } /** + * @brief Same as CelClippedDraw but checks for drawing outside the buffer + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -979,6 +1074,11 @@ void CelClippedDrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, in } /** + * @brief Same as CelClippedBlit but checks for drawing outside the buffer + * @param pBuff Target buffer + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -1017,6 +1117,10 @@ void CelClippedBlitSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int C /** * @brief Same as CelBlitLight but checks for drawing outside the buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite */ void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { @@ -1188,6 +1292,10 @@ void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt /** * @brief Same as CelBlitLightTrans but checks for drawing outside the buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite */ void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { @@ -1391,6 +1499,12 @@ void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int } /** + * @brief Same as CelDrawLight but checks for drawing outside the buffer + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of cel * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -1434,6 +1548,11 @@ void CelDrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int } /** + * @brief Same as CelClippedBlitLightTrans but checks for drawing outside the buffer + * @param pBuff Target buffer + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of cel * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -1476,8 +1595,14 @@ void CelClippedBlitLightTransSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWi /** * @brief Same as CelDrawLightRed but checks for drawing outside the buffer + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of cel * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 + * @param light Light shade to use */ void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) { @@ -1607,7 +1732,7 @@ void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i * @param y Cordinate in pBuff buffer * @param wdt Width of pBuff * @param pCelBuff Cel data - * @param nCel Frame of cel + * @param nCel CEL frame number * @param nWidth Width of cel */ void CelBlitWidth(BYTE *pBuff, int x, int y, int wdt, BYTE *pCelBuff, int nCel, int nWidth) @@ -1725,6 +1850,13 @@ void CelBlitWidth(BYTE *pBuff, int x, int y, int wdt, BYTE *pCelBuff, int nCel, } /** + * @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the back buffer at the given coordianates + * @param col Color index from current palette + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CEL buffer + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -1867,6 +1999,12 @@ void CelBlitOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid /** * @brief Same as CelBlitOutline but checks for drawing outside the buffer + * @param col Color index from current palette + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CEL buffer + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -2049,6 +2187,12 @@ void CelBlitOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int #endif } +/** + * @brief Set the value of a single pixel in the back buffer, checks bounds + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param col Color index from current palette + */ void ENG_set_pixel(int sx, int sy, BYTE col) { BYTE *dst; @@ -2075,6 +2219,11 @@ void ENG_set_pixel(int sx, int sy, BYTE col) #endif } +/** + * @brief Set the value of a single pixel in the back buffer to that of gbPixelCol, checks bounds + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + */ void engine_draw_pixel(int sx, int sy) { BYTE *dst; @@ -2106,18 +2255,6 @@ void engine_draw_pixel(int sx, int sy) #endif } -// Exact copy from https://github.com/erich666/GraphicsGems/blob/dad26f941e12c8bf1f96ea21c1c04cd2206ae7c9/gems/DoubleLine.c -// Except: -// * not in view checks -// * global variable instead of reverse flag -// * condition for pixels_left < 0 removed - -/* -Symmetric Double Step Line Algorithm -by Brian Wyvill -from "Graphics Gems", Academic Press, 1990 -*/ - #define GG_SWAP(A, B) \ { \ (A) ^= (B); \ @@ -2126,6 +2263,24 @@ from "Graphics Gems", Academic Press, 1990 } #define GG_ABSOLUTE(I, J, K) (((I) - (J)) * ((K) = (((I) - (J)) < 0 ? -1 : 1))) +/** + * Symmetric Double Step Line Algorithm + * by Brian Wyvill + * from "Graphics Gems", Academic Press, 1990 + * + * Exact copy from https://github.com/erich666/GraphicsGems/blob/dad26f941e12c8bf1f96ea21c1c04cd2206ae7c9/gems/DoubleLine.c + * Except: + * - not in view checks + * - global variable instead of reverse flag + * - condition for pixels_left < 0 removed + * + * @brief Draw a line on the back buffer + * @param x0 Back buffer coordinate + * @param y0 Back buffer coordinate + * @param x1 Back buffer coordinate + * @param y1 Back buffer coordinate + * @param col Color index from current palette + */ void DrawLine(int x0, int y0, int x1, int y1, BYTE col) { int dx, dy, incr1, incr2, D, x, y, xend, c, pixels_left; @@ -2315,6 +2470,14 @@ void DrawLine(int x0, int y0, int x1, int y1, BYTE col) } } +/** + * @brief Calculate the best fit direction between two points + * @param x1 Tile coordinate + * @param y1 Tile coordinate + * @param x2 Tile coordinate + * @param y2 Tile coordinate + * @return A value from the direction enum + */ int GetDirection(int x1, int y1, int x2, int y2) { int mx, my; @@ -2356,6 +2519,10 @@ int GetDirection(int x1, int y1, int x2, int y2) return md; } +/** + * @brief Set the RNG seed + * @param s RNG seed + */ void SetRndSeed(int s) { SeedCount = 0; @@ -2363,6 +2530,10 @@ void SetRndSeed(int s) orgseed = s; } +/** + * @brief Get the current RNG seed + * @return RNG seed + */ int GetRndSeed() { SeedCount++; @@ -2370,6 +2541,12 @@ int GetRndSeed() return abs(sglGameSeed); } +/** + * @brief Main RNG function + * @param idx Unused + * @param v The upper limit for the return value + * @return A random number from 0 to (v-1) + */ int random_(BYTE idx, int v) { if (v <= 0) @@ -2394,6 +2571,10 @@ void engine_debug_trap(BOOL show_cursor) */ } +/** + * @brief Multithreaded safe malloc + * @param dwBytes Byte size to allocate + */ BYTE *DiabloAllocPtr(DWORD dwBytes) { BYTE *buf; @@ -2413,6 +2594,10 @@ BYTE *DiabloAllocPtr(DWORD dwBytes) return buf; } +/** + * @brief Multithreaded safe memfree + * @param p Memory pointer to free + */ void mem_free_dbg(void *p) { if (p) { @@ -2426,6 +2611,12 @@ void mem_free_dbg(void *p) } } +/** + * @brief Load a file in to a buffer + * @param pszName Path of file + * @param pdwFileLen Will be set to file size if non-NULL + * @return Buffer with content of file + */ BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen) { HANDLE file; @@ -2449,6 +2640,12 @@ BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen) return buf; } +/** + * @brief Load a file in to the given buffer + * @param pszName Path of file + * @param p Target buffer + * @return Size of file + */ DWORD LoadFileWithMem(const char *pszName, void *p) { DWORD dwFileLen; @@ -2713,7 +2910,7 @@ void Cl2Blit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) } /** - * @brief Blit a solid colder shape one pix larger then the given sprite shape, to the back buffer at the given coordianates + * @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the back buffer at the given coordianates * @param col Color index from current palette * @param sx Back buffer coordinate * @param sy Back buffer coordinate @@ -2762,7 +2959,7 @@ void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid } /** - * @brief Blit a solid colder shape one pix larger then the given sprite shape, to the given buffer + * @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the given buffer * @param pDecodeTo The output buffer * @param pRLEBytes CL2 pixel stream (run-length encoded) * @param nDataSize Size of CL2 in bytes @@ -3199,7 +3396,7 @@ void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelS } /** - * @brief Blit CL2 sprite to the back buffer, while checking bounds, at the given coordianates + * @brief Same as Cl2Draw but checks for drawing outside the buffer * @param sx Back buffer coordinate * @param sy Back buffer coordinate * @param pCelBuff CL2 buffer @@ -3246,7 +3443,7 @@ void Cl2DrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSk } /** - * @brief Blit CL2 sprite to pDecodeTo while checking bounds + * @brief Same as Cl2Blit but checks for drawing outside the buffer * @param pDecodeTo The output buffer * @param pRLEBytes CL2 pixel stream (run-length encoded) * @param nDataSize Size of CL2 in bytes @@ -3407,7 +3604,7 @@ void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) } /** - * @brief Blit a solid colder shape one pix larger then the given sprite shape, to the back buffer at the given coordianates, while checking bounds + * @brief Same as Cl2DrawOutline but checks for drawing outside the buffer * @param col Color index from current palette * @param sx Back buffer coordinate * @param sy Back buffer coordinate @@ -3458,7 +3655,7 @@ void Cl2DrawOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int } /** - * @brief Blit a solid colder shape one pix larger then the given sprite shape, to the given buffer, while checking bounds + * @brief Same as Cl2BlitOutline but checks for drawing outside the buffer * @param pDecodeTo The output buffer * @param pRLEBytes CL2 pixel stream (run-length encoded) * @param nDataSize Size of CL2 in bytes @@ -3639,7 +3836,7 @@ void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi } /** - * @brief Blit CL2 sprite, and apply a given lighting, to the back buffer at the given coordianates, while checking bounds + * @brief Same as Cl2DrawLightTbl but checks for drawing outside the buffer * @param sx Back buffer coordinate * @param sy Back buffer coordinate * @param pCelBuff CL2 buffer @@ -3698,7 +3895,7 @@ void Cl2DrawLightTblSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i } /** - * @brief Blit CL2 sprite, and apply light, to pDecodeTo while checking bounds + * @brief Same as Cl2BlitLight but checks for drawing outside the buffer * @param pDecodeTo The output buffer * @param pRLEBytes CL2 pixel stream (run-length encoded) * @param nDataSize Size of CL2 in bytes @@ -3869,7 +4066,7 @@ void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt } /** - * @brief Blit CL2 sprite, and apply lighting, to the back buffer at the given coordinates, while checking bounds + * @brief Same as Cl2DrawLight but checks for drawing outside the buffer * @param sx Back buffer coordinate * @param sy Back buffer coordinate * @param pCelBuff CL2 buffer From e7e51abd135e64f639e774999b1851ee176d3970 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 16 Feb 2020 03:39:04 +0100 Subject: [PATCH 18/38] Document remaning functions in render related files --- Source/engine.cpp | 4 ++++ Source/render.cpp | 32 ++++++++++++++++++++++++++++++++ Source/scrollrt.cpp | 32 ++++++++++++++++++++++++++++++++ Source/town.cpp | 3 +++ 4 files changed, 71 insertions(+) diff --git a/Source/engine.cpp b/Source/engine.cpp index 5836aafa..13a86bfc 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -2556,6 +2556,10 @@ int random_(BYTE idx, int v) return GetRndSeed() % v; } +/** + * @brief Unallocate all remaining pointers + * @param show_cursor unused + */ void engine_debug_trap(BOOL show_cursor) { /* diff --git a/Source/render.cpp b/Source/render.cpp index c4ff1e4d..39a22cb3 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -114,6 +114,11 @@ int WorldTbl17_2[17] = { 0, 32, 60, 88, 112, 136, 156, 176, 192, 208, 220, 232, #ifdef USE_ASM #include "_render.cpp" #else +/** + * While blitting this function will check for the upper bound of the buffer + * @brief Blit upper part of transparent world CELs + * @param pBuff Output buffer + */ void drawTopArchesUpperScreen(BYTE *pBuff) { BYTE *dst, *src; @@ -1137,6 +1142,12 @@ void drawTopArchesUpperScreen(BYTE *pBuff) } } +/** + * While blitting this function will check for the upper bound of the buffer + * @brief Blit lower part of transparent world CELs + * @param pBuff Output buffer + * @param pMask Transparancy pattern + */ void drawBottomArchesUpperScreen(BYTE *pBuff, DWORD *pMask) { BYTE *dst, *src; @@ -1769,6 +1780,11 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, DWORD *pMask) } } +/** + * While blitting this function will check for the upper bound of the buffer + * @brief Blit current world CEL to the given buffer + * @param pBuff Output buffer + */ void drawUpperScreen(BYTE *pBuff) { BYTE *dst, *src; @@ -2386,6 +2402,11 @@ void drawUpperScreen(BYTE *pBuff) } } +/** + * While blitting this function will check for the lower bound of the buffer + * @brief Blit upper part of transparent world CELs + * @param pBuff Output buffer + */ void drawTopArchesLowerScreen(BYTE *pBuff) { BYTE *dst, *src; @@ -3622,6 +3643,12 @@ LABEL_11: } } +/** + * While blitting this function will check for the lower bound of the buffer + * @brief Blit lower part of transparent world CELs + * @param pBuff Output buffer + * @param pMask Transparancy pattern + */ void drawBottomArchesLowerScreen(BYTE *pBuff, DWORD *pMask) { BYTE *dst, *src; @@ -4414,6 +4441,11 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, DWORD *pMask) } } +/** + * While blitting this function will check for the lower bound of the buffer + * @brief Blit current world CEL to the given buffer + * @param pBuff Output buffer + */ void drawLowerScreen(BYTE *pBuff) { BYTE *dst, *src; diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 92c5d8e4..b2508db1 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1,23 +1,51 @@ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" +/** + * Specifies the current light entry. + */ int light_table_index; int PitchTbl[1024]; DWORD sgdwCursWdtOld; DWORD sgdwCursX; DWORD sgdwCursY; +/** + * Lower bound of back buffer. + */ BYTE *gpBufEnd; DWORD sgdwCursHgt; + +/** + * Specifies the current MIN block of the level CEL file, as used during rendering of the level tiles. + * + * frameNum := block & 0x0FFF + * frameType := block & 0x7000 >> 12 + */ DWORD level_cel_block; DWORD sgdwCursXOld; DWORD sgdwCursYOld; +/** + * Specifies the type of arches to render. + */ char arch_draw_type; +/** + * Describes the surface being rendered. + */ DDSURFACEDESC DDS_desc; +/** + * Specifies whether transparency is active for the current CEL file being decoded. + */ int cel_transparency_active; +/** + * Specifies the current dungeon piece ID of the level, as used during rendering of the level tiles. + */ int level_piece_id; DWORD sgdwCursWdt; void (*DrawPlrProc)(int, int, int, int, int, BYTE *, int, int, int, int); BYTE sgSaveBack[8192]; +/** + * Specifies the monster_num to render. + */ int draw_monster_num; DWORD sgdwCursHgtOld; @@ -2800,6 +2828,10 @@ static void DrawMain(int dwHgt, BOOL draw_desc, BOOL draw_hp, BOOL draw_mana, BO #endif } +/** + * @brief Redraw screen + * @param draw_cursor + */ void scrollrt_draw_game_screen(BOOL draw_cursor) { int hgt; diff --git a/Source/town.cpp b/Source/town.cpp index 3289caaf..dc7904d5 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -1396,6 +1396,9 @@ void T_DrawView(int StartX, int StartY) DrawManaFlask(); } +/** + * @brief Build tile columns + */ void SetTownMicros() { int i, x, y, lv; From ab453a5bb03f8eb6e14fbcafaea7b02d6c0ec594 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 16 Feb 2020 04:59:51 +0100 Subject: [PATCH 19/38] Correct some documentation --- Source/scrollrt.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index b2508db1..1fcd527a 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -88,6 +88,9 @@ char *szPlrModeAssert[12] = { "quitting" }; +/** + * @brief Clear cursor state + */ void ClearCursor() // CODE_FIX: this was supposed to be in cursor.cpp { sgdwCursWdt = 0; @@ -204,7 +207,7 @@ static void scrollrt_draw_cursor_item() } /** - * @brief Render a missile sprite + * @brief Render a missile sprites for a given tile * @param x dPiece coordinate * @param y dPiece coordinate * @param sx Back buffer coordinate @@ -470,7 +473,7 @@ static void DrawClippedMonster(int x, int y, int mx, int my, int m, int CelSkip, } /** - * @brief Render a monster sprite + * @brief Render a player sprite * @param pnum Player id * @param x dPiece coordinate * @param y dPiece coordinate @@ -642,7 +645,7 @@ static void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCel } /** - * @brief Render a monster sprite + * @brief Render a player sprite * @param x dPiece coordinate * @param y dPiece coordinate * @param sx Back buffer coordinate From d51eee6916fadb78f2d33376a22612eeeebb1a57 Mon Sep 17 00:00:00 2001 From: qndel Date: Mon, 17 Feb 2020 20:49:32 +0100 Subject: [PATCH 20/38] CheckPanelInfo cleanup --- Source/control.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 5a1747fe..51c25ff2 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1435,15 +1435,14 @@ void DoAutoMap() */ void CheckPanelInfo() { - int i, c, v, s; + int i, c, v, s, xend, yend; panelflag = FALSE; ClearPanel(); for (i = 0; i < numpanbtns; i++) { - if (MouseX >= PanBtnPos[i][0] - && MouseX <= PanBtnPos[i][0] + PanBtnPos[i][2] - && MouseY >= PanBtnPos[i][1] - && MouseY <= PanBtnPos[i][1] + PanBtnPos[i][3]) { + xend = PanBtnPos[i][0] + PanBtnPos[i][2]; + yend = PanBtnPos[i][1] + PanBtnPos[i][3]; + if (MouseX >= PanBtnPos[i][0] && MouseX <= xend && MouseY >= PanBtnPos[i][1] && MouseY <= yend) { if (i != 7) { strcpy(infostr, PanBtnStr[i]); } else { From 34caded4ded2a50916a4c39545df43fc23ce6902 Mon Sep 17 00:00:00 2001 From: qndel Date: Sat, 22 Feb 2020 00:19:58 +0100 Subject: [PATCH 21/38] fix hotkeys --- Source/diablo.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 9bff14ef..e3643960 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1112,31 +1112,31 @@ void PressKey(int vkey) #endif else if (vkey == VK_F5) { if (spselflag) { - ToggleSpell(0); + SetSpeedSpell(0); return; } - SetSpeedSpell(0); + ToggleSpell(0); return; } else if (vkey == VK_F6) { if (spselflag) { - ToggleSpell(1); + SetSpeedSpell(1); return; } - SetSpeedSpell(1); + ToggleSpell(1); return; } else if (vkey == VK_F7) { if (spselflag) { - ToggleSpell(2); + SetSpeedSpell(2); return; } - SetSpeedSpell(2); + ToggleSpell(2); return; } else if (vkey == VK_F8) { if (spselflag) { - ToggleSpell(3); + SetSpeedSpell(3); return; } - SetSpeedSpell(3); + ToggleSpell(3); return; } else if (vkey == VK_F9) { diablo_hotkey_msg(0); From 81ff8e6287ba5515558e3266e961495c6da52a77 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Fri, 28 Feb 2020 16:35:57 -0600 Subject: [PATCH 22/38] Metallic hydrogen neural array --- Source/automap.cpp | 302 ++++++++++++++++++------------------ Source/automap.h | 16 +- Source/control.cpp | 28 ++-- Source/control.h | 8 +- Source/diablo.cpp | 16 +- Source/error.cpp | 2 +- Source/gamemenu.cpp | 26 ++-- Source/gamemenu.h | 8 +- Source/gmenu.cpp | 12 +- Source/gmenu.h | 6 +- Source/help.cpp | 2 +- Source/inv.cpp | 2 +- Source/items.cpp | 2 +- Source/player.cpp | 2 +- Source/plrmsg.cpp | 2 +- Source/quests.cpp | 2 +- Source/scrollrt.cpp | 4 +- Source/stores.cpp | 4 +- comparer-config/diablo.toml | 28 ++-- comparer-config/spawn.toml | 28 ++-- 20 files changed, 250 insertions(+), 250 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index 57867d61..5a2df7ab 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -2,19 +2,19 @@ // BUGFIX: only the first 256 elements are ever read WORD automaptype[512]; -static int MapX; -static int MapY; +static int AutoMapX; +static int AutoMapY; BOOL automapflag; -char AmShiftTab[32]; // [31]? +char AmShiftTab[31]; BOOLEAN automapview[DMAXX][DMAXY]; int AutoMapScale; int AutoMapXOfs; int AutoMapYOfs; -int AutoMapPosBits; -int AutoMapXPos; -int AutoMapYPos; -int AMPlayerX; -int AMPlayerY; +int AmLine64; +int AmLine32; +int AmLine16; +int AmLine8; +int AmLine4; // color used to draw the player's arrow #define COLOR_PLAYER (PAL8_ORANGE + 1) @@ -31,18 +31,18 @@ int AMPlayerY; #define MAPFLAG_HORZARCH 0x08 #define MAPFLAG_VERTGRATE 0x10 #define MAPFLAG_HORZGRATE 0x20 -#define MAPFLAG_SQUARE 0x40 +#define MAPFLAG_DIRT 0x40 #define MAPFLAG_STAIRS 0x80 void InitAutomapOnce() { automapflag = FALSE; AutoMapScale = 50; - AutoMapPosBits = 32; - AutoMapXPos = 16; - AutoMapYPos = 8; - AMPlayerX = 4; - AMPlayerY = 2; + AmLine64 = 32; + AmLine32 = 16; + AmLine16 = 8; + AmLine8 = 4; + AmLine4 = 2; } void InitAutomap() @@ -138,11 +138,11 @@ void AutomapZoomIn() { if (AutoMapScale < 200) { AutoMapScale += 5; - AutoMapPosBits = (AutoMapScale << 6) / 100; - AutoMapXPos = AutoMapPosBits >> 1; - AutoMapYPos = AutoMapXPos >> 1; - AMPlayerX = AutoMapYPos >> 1; - AMPlayerY = AMPlayerX >> 1; + AmLine64 = (AutoMapScale << 6) / 100; + AmLine32 = AmLine64 >> 1; + AmLine16 = AmLine32 >> 1; + AmLine8 = AmLine16 >> 1; + AmLine4 = AmLine8 >> 1; } } @@ -150,11 +150,11 @@ void AutomapZoomOut() { if (AutoMapScale > 50) { AutoMapScale -= 5; - AutoMapPosBits = (AutoMapScale << 6) / 100; - AutoMapXPos = AutoMapPosBits >> 1; - AutoMapYPos = AutoMapXPos >> 1; - AMPlayerX = AutoMapYPos >> 1; - AMPlayerY = AMPlayerX >> 1; + AmLine64 = (AutoMapScale << 6) / 100; + AmLine32 = AmLine64 >> 1; + AmLine16 = AmLine32 >> 1; + AmLine8 = AmLine16 >> 1; + AmLine4 = AmLine8 >> 1; } } @@ -166,46 +166,46 @@ void DrawAutomap() int mapx, mapy; if (leveltype == DTYPE_TOWN) { - DrawAutomapGame(); + DrawAutomapText(); return; } gpBufEnd = &gpBuffer[(PANEL_Y)*BUFFER_WIDTH]; - MapX = (ViewX - 16) >> 1; - while (MapX + AutoMapXOfs < 0) + AutoMapX = (ViewX - 16) >> 1; + while (AutoMapX + AutoMapXOfs < 0) AutoMapXOfs++; - while (MapX + AutoMapXOfs >= DMAXX) + while (AutoMapX + AutoMapXOfs >= DMAXX) AutoMapXOfs--; - MapX += AutoMapXOfs; + AutoMapX += AutoMapXOfs; - MapY = (ViewY - 16) >> 1; - while (MapY + AutoMapYOfs < 0) + AutoMapY = (ViewY - 16) >> 1; + while (AutoMapY + AutoMapYOfs < 0) AutoMapYOfs++; - while (MapY + AutoMapYOfs >= DMAXY) + while (AutoMapY + AutoMapYOfs >= DMAXY) AutoMapYOfs--; - MapY += AutoMapYOfs; + AutoMapY += AutoMapYOfs; cells = AmShiftTab[(AutoMapScale - 50) / 5]; if (ScrollInfo._sxoff + ScrollInfo._syoff) cells++; - mapx = MapX - cells; - mapy = MapY - 1; + mapx = AutoMapX - cells; + mapy = AutoMapY - 1; if (cells & 1) { - sx = 384 - AutoMapPosBits * ((cells - 1) >> 1); - sy = 336 - AutoMapXPos * ((cells + 1) >> 1); + sx = 384 - AmLine64 * ((cells - 1) >> 1); + sy = 336 - AmLine32 * ((cells + 1) >> 1); } else { - sx = 384 - AutoMapPosBits * (cells >> 1) + AutoMapXPos; - sy = 336 - AutoMapXPos * (cells >> 1) - AutoMapYPos; + sx = 384 - AmLine64 * (cells >> 1) + AmLine32; + sy = 336 - AmLine32 * (cells >> 1) - AmLine16; } if (ViewX & 1) { - sx -= AutoMapYPos; - sy -= AMPlayerX; + sx -= AmLine16; + sy -= AmLine8; } if (ViewY & 1) { - sx += AutoMapYPos; - sy -= AMPlayerX; + sx += AmLine16; + sy -= AmLine8; } sx += AutoMapScale * ScrollInfo._sxoff / 100 >> 1; @@ -224,26 +224,26 @@ void DrawAutomap() for (j = 0; j < cells; j++) { WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); if (maptype) - DrawAutomapType(x, sy, maptype); - x += AutoMapPosBits; + DrawAutomapTile(x, sy, maptype); + x += AmLine64; } mapy++; - x = sx - AutoMapXPos; - y = sy + AutoMapYPos; + x = sx - AmLine32; + y = sy + AmLine16; for (j = 0; j <= cells; j++) { WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); if (maptype) - DrawAutomapType(x, y, maptype); - x += AutoMapPosBits; + DrawAutomapTile(x, y, maptype); + x += AmLine64; } mapx++; - sy += AutoMapXPos; + sy += AmLine32; } DrawAutomapPlr(); - DrawAutomapGame(); + DrawAutomapText(); } -void DrawAutomapType(int sx, int sy, WORD automap_type) +void DrawAutomapTile(int sx, int sy, WORD automap_type) { BOOL do_vert; BOOL do_horz; @@ -253,30 +253,30 @@ void DrawAutomapType(int sx, int sy, WORD automap_type) BYTE flags = automap_type >> 8; - if (flags & MAPFLAG_SQUARE) { + if (flags & MAPFLAG_DIRT) { ENG_set_pixel(sx, sy, COLOR_DIM); - ENG_set_pixel(sx - AMPlayerX, sy - AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx - AMPlayerX, sy + AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx + AMPlayerX, sy - AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx + AMPlayerX, sy + AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx - AutoMapYPos, sy, COLOR_DIM); - ENG_set_pixel(sx + AutoMapYPos, sy, COLOR_DIM); - ENG_set_pixel(sx, sy - AMPlayerX, COLOR_DIM); - ENG_set_pixel(sx, sy + AMPlayerX, COLOR_DIM); - ENG_set_pixel(sx + AMPlayerX - AutoMapXPos, sy + AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx - AMPlayerX + AutoMapXPos, sy + AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx - AutoMapYPos, sy + AMPlayerX, COLOR_DIM); - ENG_set_pixel(sx + AutoMapYPos, sy + AMPlayerX, COLOR_DIM); - ENG_set_pixel(sx - AMPlayerX, sy + AutoMapYPos - AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx + AMPlayerX, sy + AutoMapYPos - AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx, sy + AutoMapYPos, COLOR_DIM); + ENG_set_pixel(sx - AmLine8, sy - AmLine4, COLOR_DIM); + ENG_set_pixel(sx - AmLine8, sy + AmLine4, COLOR_DIM); + ENG_set_pixel(sx + AmLine8, sy - AmLine4, COLOR_DIM); + ENG_set_pixel(sx + AmLine8, sy + AmLine4, COLOR_DIM); + ENG_set_pixel(sx - AmLine16, sy, COLOR_DIM); + ENG_set_pixel(sx + AmLine16, sy, COLOR_DIM); + ENG_set_pixel(sx, sy - AmLine8, COLOR_DIM); + ENG_set_pixel(sx, sy + AmLine8, COLOR_DIM); + ENG_set_pixel(sx + AmLine8 - AmLine32, sy + AmLine4, COLOR_DIM); + ENG_set_pixel(sx - AmLine8 + AmLine32, sy + AmLine4, COLOR_DIM); + ENG_set_pixel(sx - AmLine16, sy + AmLine8, COLOR_DIM); + ENG_set_pixel(sx + AmLine16, sy + AmLine8, COLOR_DIM); + ENG_set_pixel(sx - AmLine8, sy + AmLine16 - AmLine4, COLOR_DIM); + ENG_set_pixel(sx + AmLine8, sy + AmLine16 - AmLine4, COLOR_DIM); + ENG_set_pixel(sx, sy + AmLine16, COLOR_DIM); } if (flags & MAPFLAG_STAIRS) { - DrawLine(sx - AMPlayerX, sy - AMPlayerX - AMPlayerY, sx + AMPlayerX + AutoMapYPos, sy + AMPlayerY, COLOR_BRIGHT); - DrawLine(sx - AutoMapYPos, sy - AMPlayerX, sx + AutoMapYPos, sy + AMPlayerX, COLOR_BRIGHT); - DrawLine(sx - AutoMapYPos - AMPlayerX, sy - AMPlayerY, sx + AMPlayerX, sy + AMPlayerX + AMPlayerY, COLOR_BRIGHT); - DrawLine(sx - AutoMapXPos, sy, sx, sy + AutoMapYPos, COLOR_BRIGHT); + DrawLine(sx - AmLine8, sy - AmLine8 - AmLine4, sx + AmLine8 + AmLine16, sy + AmLine4, COLOR_BRIGHT); + DrawLine(sx - AmLine16, sy - AmLine8, sx + AmLine16, sy + AmLine8, COLOR_BRIGHT); + DrawLine(sx - AmLine16 - AmLine8, sy - AmLine4, sx + AmLine8, sy + AmLine8 + AmLine4, COLOR_BRIGHT); + DrawLine(sx - AmLine32, sy, sx, sy + AmLine16, COLOR_BRIGHT); } do_vert = FALSE; @@ -285,10 +285,10 @@ void DrawAutomapType(int sx, int sy, WORD automap_type) do_cave_vert = FALSE; switch (automap_type & MAPFLAG_TYPE) { case 1: // stand-alone column or other unpassable object - x1 = sx - AutoMapYPos; - y1 = sy - AutoMapYPos; - x2 = x1 + AutoMapXPos; - y2 = sy - AMPlayerX; + x1 = sx - AmLine16; + y1 = sy - AmLine16; + x2 = x1 + AmLine32; + y2 = sy - AmLine8; DrawLine(sx, y1, x1, y2, COLOR_DIM); DrawLine(sx, y1, x2, y2, COLOR_DIM); DrawLine(sx, sy, x1, y2, COLOR_DIM); @@ -328,27 +328,27 @@ void DrawAutomapType(int sx, int sy, WORD automap_type) if (do_vert) { // right-facing obstacle if (flags & MAPFLAG_VERTDOOR) { // two wall segments with a door in the middle - x1 = sx - AutoMapXPos; - x2 = sx - AutoMapYPos; - y1 = sy - AutoMapYPos; - y2 = sy - AMPlayerX; + x1 = sx - AmLine32; + x2 = sx - AmLine16; + y1 = sy - AmLine16; + y2 = sy - AmLine8; - DrawLine(sx, y1, sx - AMPlayerX, y1 + AMPlayerY, COLOR_DIM); - DrawLine(x1, sy, x1 + AMPlayerX, sy - AMPlayerY, COLOR_DIM); + DrawLine(sx, y1, sx - AmLine8, y1 + AmLine4, COLOR_DIM); + DrawLine(x1, sy, x1 + AmLine8, sy - AmLine4, COLOR_DIM); DrawLine(x2, y1, x1, y2, COLOR_BRIGHT); DrawLine(x2, y1, sx, y2, COLOR_BRIGHT); DrawLine(x2, sy, x1, y2, COLOR_BRIGHT); DrawLine(x2, sy, sx, y2, COLOR_BRIGHT); } if (flags & MAPFLAG_VERTGRATE) { // right-facing half-wall - DrawLine(sx - AutoMapYPos, sy - AMPlayerX, sx - AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx - AmLine16, sy - AmLine8, sx - AmLine32, sy, COLOR_DIM); flags |= MAPFLAG_VERTARCH; } if (flags & MAPFLAG_VERTARCH) { // window or passable column - x1 = sx - AutoMapYPos; - y1 = sy - AutoMapYPos; - x2 = x1 + AutoMapXPos; - y2 = sy - AMPlayerX; + x1 = sx - AmLine16; + y1 = sy - AmLine16; + x2 = x1 + AmLine32; + y2 = sy - AmLine8; DrawLine(sx, y1, x1, y2, COLOR_DIM); DrawLine(sx, y1, x2, y2, COLOR_DIM); @@ -356,32 +356,32 @@ void DrawAutomapType(int sx, int sy, WORD automap_type) DrawLine(sx, sy, x2, y2, COLOR_DIM); } if (!(flags & (MAPFLAG_VERTDOOR | MAPFLAG_VERTGRATE | MAPFLAG_VERTARCH))) - DrawLine(sx, sy - AutoMapYPos, sx - AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx, sy - AmLine16, sx - AmLine32, sy, COLOR_DIM); } if (do_horz) { // left-facing obstacle if (flags & MAPFLAG_HORZDOOR) { - x1 = sx + AutoMapYPos; - x2 = sx + AutoMapXPos; - y1 = sy - AutoMapYPos; - y2 = sy - AMPlayerX; + x1 = sx + AmLine16; + x2 = sx + AmLine32; + y1 = sy - AmLine16; + y2 = sy - AmLine8; - DrawLine(sx, y1, sx + AMPlayerX, y1 + AMPlayerY, COLOR_DIM); - DrawLine(x2, sy, x2 - AMPlayerX, sy - AMPlayerY, COLOR_DIM); + DrawLine(sx, y1, sx + AmLine8, y1 + AmLine4, COLOR_DIM); + DrawLine(x2, sy, x2 - AmLine8, sy - AmLine4, COLOR_DIM); DrawLine(x1, y1, sx, y2, COLOR_BRIGHT); DrawLine(x1, y1, x2, y2, COLOR_BRIGHT); DrawLine(x1, sy, sx, y2, COLOR_BRIGHT); DrawLine(x1, sy, x2, y2, COLOR_BRIGHT); } if (flags & MAPFLAG_HORZGRATE) { - DrawLine(sx + AutoMapYPos, sy - AMPlayerX, sx + AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx + AmLine16, sy - AmLine8, sx + AmLine32, sy, COLOR_DIM); flags |= MAPFLAG_HORZARCH; } if (flags & MAPFLAG_HORZARCH) { - x1 = sx - AutoMapYPos; - y1 = sy - AutoMapYPos; - x2 = x1 + AutoMapXPos; - y2 = sy - AMPlayerX; + x1 = sx - AmLine16; + y1 = sy - AmLine16; + x2 = x1 + AmLine32; + y2 = sy - AmLine8; DrawLine(sx, y1, x1, y2, COLOR_DIM); DrawLine(sx, y1, x2, y2, COLOR_DIM); @@ -389,42 +389,42 @@ void DrawAutomapType(int sx, int sy, WORD automap_type) DrawLine(sx, sy, x2, y2, COLOR_DIM); } if (!(flags & (MAPFLAG_HORZDOOR | MAPFLAG_HORZGRATE | MAPFLAG_HORZARCH))) - DrawLine(sx, sy - AutoMapYPos, sx + AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx, sy - AmLine16, sx + AmLine32, sy, COLOR_DIM); } // for caves the horz/vert flags are switched if (do_cave_horz) { if (flags & MAPFLAG_VERTDOOR) { - x1 = sx - AutoMapXPos; - x2 = sx - AutoMapYPos; - y1 = sy + AutoMapYPos; - y2 = sy + AMPlayerX; + x1 = sx - AmLine32; + x2 = sx - AmLine16; + y1 = sy + AmLine16; + y2 = sy + AmLine8; - DrawLine(sx, y1, sx - AMPlayerX, y1 - AMPlayerY, COLOR_DIM); - DrawLine(x1, sy, x1 + AMPlayerX, sy + AMPlayerY, COLOR_DIM); + DrawLine(sx, y1, sx - AmLine8, y1 - AmLine4, COLOR_DIM); + DrawLine(x1, sy, x1 + AmLine8, sy + AmLine4, COLOR_DIM); DrawLine(x2, y1, x1, y2, COLOR_BRIGHT); DrawLine(x2, y1, sx, y2, COLOR_BRIGHT); DrawLine(x2, sy, x1, y2, COLOR_BRIGHT); DrawLine(x2, sy, sx, y2, COLOR_BRIGHT); } else - DrawLine(sx, sy + AutoMapYPos, sx - AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx, sy + AmLine16, sx - AmLine32, sy, COLOR_DIM); } if (do_cave_vert) { if (flags & MAPFLAG_HORZDOOR) { - x1 = sx + AutoMapYPos; - x2 = sx + AutoMapXPos; - y1 = sy + AutoMapYPos; - y2 = sy + AMPlayerX; + x1 = sx + AmLine16; + x2 = sx + AmLine32; + y1 = sy + AmLine16; + y2 = sy + AmLine8; - DrawLine(sx, y1, sx + AMPlayerX, y1 - AMPlayerY, COLOR_DIM); - DrawLine(x2, sy, x2 - AMPlayerX, sy + AMPlayerY, COLOR_DIM); + DrawLine(sx, y1, sx + AmLine8, y1 - AmLine4, COLOR_DIM); + DrawLine(x2, sy, x2 - AmLine8, sy + AmLine4, COLOR_DIM); DrawLine(x1, y1, sx, y2, COLOR_BRIGHT); DrawLine(x1, y1, x2, y2, COLOR_BRIGHT); DrawLine(x1, sy, sx, y2, COLOR_BRIGHT); DrawLine(x1, sy, x2, y2, COLOR_BRIGHT); } else - DrawLine(sx, sy + AutoMapYPos, sx + AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx, sy + AmLine16, sx + AmLine32, sy, COLOR_DIM); } } @@ -447,55 +447,55 @@ void DrawAutomapPlr() px = x - 2 * AutoMapXOfs - ViewX; py = y - 2 * AutoMapYOfs - ViewY; - x = (plr[myplr]._pxoff * AutoMapScale / 100 >> 1) + (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AutoMapYPos + 384; - y = (plr[myplr]._pyoff * AutoMapScale / 100 >> 1) + (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AMPlayerX + 336; + x = (plr[myplr]._pxoff * AutoMapScale / 100 >> 1) + (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AmLine16 + 384; + y = (plr[myplr]._pyoff * AutoMapScale / 100 >> 1) + (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AmLine8 + 336; if (invflag || sbookflag) x -= 160; if (chrflag || questlog) x += 160; - y -= AMPlayerX; + y -= AmLine8; switch (plr[myplr]._pdir) { case DIR_N: - DrawLine(x, y, x, y - AutoMapYPos, COLOR_PLAYER); - DrawLine(x, y - AutoMapYPos, x - AMPlayerY, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x, y - AutoMapYPos, x + AMPlayerY, y - AMPlayerX, COLOR_PLAYER); + DrawLine(x, y, x, y - AmLine16, COLOR_PLAYER); + DrawLine(x, y - AmLine16, x - AmLine4, y - AmLine8, COLOR_PLAYER); + DrawLine(x, y - AmLine16, x + AmLine4, y - AmLine8, COLOR_PLAYER); break; case DIR_NE: - DrawLine(x, y, x + AutoMapYPos, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y - AMPlayerX, x + AMPlayerX, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y - AMPlayerX, x + AMPlayerX + AMPlayerY, y, COLOR_PLAYER); + DrawLine(x, y, x + AmLine16, y - AmLine8, COLOR_PLAYER); + DrawLine(x + AmLine16, y - AmLine8, x + AmLine8, y - AmLine8, COLOR_PLAYER); + DrawLine(x + AmLine16, y - AmLine8, x + AmLine8 + AmLine4, y, COLOR_PLAYER); break; case DIR_E: - DrawLine(x, y, x + AutoMapYPos, y, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y, x + AMPlayerX, y - AMPlayerY, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y, x + AMPlayerX, y + AMPlayerY, COLOR_PLAYER); + DrawLine(x, y, x + AmLine16, y, COLOR_PLAYER); + DrawLine(x + AmLine16, y, x + AmLine8, y - AmLine4, COLOR_PLAYER); + DrawLine(x + AmLine16, y, x + AmLine8, y + AmLine4, COLOR_PLAYER); break; case DIR_SE: - DrawLine(x, y, x + AutoMapYPos, y + AMPlayerX, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y + AMPlayerX, x + AMPlayerX + AMPlayerY, y, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y + AMPlayerX, x + AMPlayerX, y + AMPlayerX, COLOR_PLAYER); + DrawLine(x, y, x + AmLine16, y + AmLine8, COLOR_PLAYER); + DrawLine(x + AmLine16, y + AmLine8, x + AmLine8 + AmLine4, y, COLOR_PLAYER); + DrawLine(x + AmLine16, y + AmLine8, x + AmLine8, y + AmLine8, COLOR_PLAYER); break; case DIR_S: - DrawLine(x, y, x, y + AutoMapYPos, COLOR_PLAYER); - DrawLine(x, y + AutoMapYPos, x + AMPlayerY, y + AMPlayerX, COLOR_PLAYER); - DrawLine(x, y + AutoMapYPos, x - AMPlayerY, y + AMPlayerX, COLOR_PLAYER); + DrawLine(x, y, x, y + AmLine16, COLOR_PLAYER); + DrawLine(x, y + AmLine16, x + AmLine4, y + AmLine8, COLOR_PLAYER); + DrawLine(x, y + AmLine16, x - AmLine4, y + AmLine8, COLOR_PLAYER); break; case DIR_SW: - DrawLine(x, y, x - AutoMapYPos, y + AMPlayerX, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y + AMPlayerX, x - AMPlayerY - AMPlayerX, y, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y + AMPlayerX, x - AMPlayerX, y + AMPlayerX, COLOR_PLAYER); + DrawLine(x, y, x - AmLine16, y + AmLine8, COLOR_PLAYER); + DrawLine(x - AmLine16, y + AmLine8, x - AmLine4 - AmLine8, y, COLOR_PLAYER); + DrawLine(x - AmLine16, y + AmLine8, x - AmLine8, y + AmLine8, COLOR_PLAYER); break; case DIR_W: - DrawLine(x, y, x - AutoMapYPos, y, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y, x - AMPlayerX, y - AMPlayerY, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y, x - AMPlayerX, y + AMPlayerY, COLOR_PLAYER); + DrawLine(x, y, x - AmLine16, y, COLOR_PLAYER); + DrawLine(x - AmLine16, y, x - AmLine8, y - AmLine4, COLOR_PLAYER); + DrawLine(x - AmLine16, y, x - AmLine8, y + AmLine4, COLOR_PLAYER); break; case DIR_NW: - DrawLine(x, y, x - AutoMapYPos, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y - AMPlayerX, x - AMPlayerX, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y - AMPlayerX, x - AMPlayerY - AMPlayerX, y, COLOR_PLAYER); + DrawLine(x, y, x - AmLine16, y - AmLine8, COLOR_PLAYER); + DrawLine(x - AmLine16, y - AmLine8, x - AmLine8, y - AmLine8, COLOR_PLAYER); + DrawLine(x - AmLine16, y - AmLine8, x - AmLine4 - AmLine8, y, COLOR_PLAYER); break; } } @@ -505,18 +505,18 @@ WORD GetAutomapType(int x, int y, BOOL view) WORD rv; if (view && x == -1 && y >= 0 && y < DMAXY && automapview[0][y]) { - if (GetAutomapType(0, y, FALSE) & (MAPFLAG_SQUARE << 8)) { + if (GetAutomapType(0, y, FALSE) & (MAPFLAG_DIRT << 8)) { return 0; } else { - return MAPFLAG_SQUARE << 8; + return MAPFLAG_DIRT << 8; } } if (view && y == -1 && x >= 0 && x < DMAXY && automapview[x][0]) { - if (GetAutomapType(x, 0, FALSE) & (MAPFLAG_SQUARE << 8)) { + if (GetAutomapType(x, 0, FALSE) & (MAPFLAG_DIRT << 8)) { return 0; } else { - return MAPFLAG_SQUARE << 8; + return MAPFLAG_DIRT << 8; } } @@ -541,7 +541,7 @@ WORD GetAutomapType(int x, int y, BOOL view) return rv; } -void DrawAutomapGame() +void DrawAutomapText() { char desc[256]; int nextline = 20; @@ -640,9 +640,9 @@ void AutomapZoomReset() { AutoMapXOfs = 0; AutoMapYOfs = 0; - AutoMapPosBits = (AutoMapScale << 6) / 100; - AutoMapXPos = AutoMapPosBits >> 1; - AutoMapYPos = AutoMapXPos >> 1; - AMPlayerX = AutoMapYPos >> 1; - AMPlayerY = AMPlayerX >> 1; + AmLine64 = (AutoMapScale << 6) / 100; + AmLine32 = AmLine64 >> 1; + AmLine16 = AmLine32 >> 1; + AmLine8 = AmLine16 >> 1; + AmLine4 = AmLine8 >> 1; } diff --git a/Source/automap.h b/Source/automap.h index 1793005b..a947c467 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -4,16 +4,16 @@ extern WORD automaptype[512]; extern BOOL automapflag; -extern char AmShiftTab[32]; +extern char AmShiftTab[31]; extern BOOLEAN automapview[DMAXX][DMAXY]; extern int AutoMapScale; extern int AutoMapXOfs; extern int AutoMapYOfs; -extern int AutoMapPosBits; -extern int AutoMapXPos; -extern int AutoMapYPos; -extern int AMPlayerX; -extern int AMPlayerY; +extern int AmLine64; +extern int AmLine32; +extern int AmLine16; +extern int AmLine8; +extern int AmLine4; void InitAutomapOnce(); void InitAutomap(); @@ -25,10 +25,10 @@ void AutomapRight(); void AutomapZoomIn(); void AutomapZoomOut(); void DrawAutomap(); -void DrawAutomapType(int screen_x, int screen_y, WORD automap_type); +void DrawAutomapTile(int screen_x, int screen_y, WORD automap_type); void DrawAutomapPlr(); WORD GetAutomapType(int x, int y, BOOL view); -void DrawAutomapGame(); +void DrawAutomapText(); void SetAutomapView(int x, int y); void AutomapZoomReset(); diff --git a/Source/control.cpp b/Source/control.cpp index 51c25ff2..589efcfb 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -619,7 +619,7 @@ void ToggleSpell(int slot) * @param nCel Number of letter in Windows-1252 * @param col text_color color value */ -void CPrintString(int nOffset, int nCel, char col) +void PrintChar(int nOffset, int nCel, char col) { /// ASSERT: assert(gpBuffer); @@ -1286,7 +1286,7 @@ void InitControlPan() nGoldFrame = 1; } -void ClearCtrlPan() +void DrawCtrlPan() { DrawPanelBox(0, sgbPlrTalkTbl + 16, PANEL_WIDTH, PANEL_HEIGHT, PANEL_X, PANEL_Y); DrawInfoBox(); @@ -1296,7 +1296,7 @@ void ClearCtrlPan() * Draws the control panel buttons in their current state. If the button is in the default * state draw it from the panel cel(extract its sub-rect). Else draw it from the buttons cel. */ -void DrawCtrlPan() +void DrawCtrlBtns() { int i; @@ -1706,10 +1706,10 @@ void DrawInfoBox() } } if (infostr[0] || pnumlines) - control_draw_info_str(); + PrintInfo(); } -void control_draw_info_str() +void PrintInfo() { int yo, lo, i; @@ -1717,18 +1717,18 @@ void control_draw_info_str() yo = 0; lo = 1; if (infostr[0]) { - control_print_info_str(0, infostr, TRUE, pnumlines); + CPrintString(0, infostr, TRUE, pnumlines); yo = 1; lo = 0; } for (i = 0; i < pnumlines; i++) { - control_print_info_str(i + yo, panelstr[i], pstrjust[i], pnumlines - lo); + CPrintString(i + yo, panelstr[i], pstrjust[i], pnumlines - lo); } } } -void control_print_info_str(int y, char *str, BOOL center, int lines) +void CPrintString(int y, char *str, BOOL center, int lines) { BYTE c; char *tmp; @@ -1753,7 +1753,7 @@ void control_print_info_str(int y, char *str, BOOL center, int lines) lineOffset += fontkern[c] + 2; if (c) { if (lineOffset < 288) { - CPrintString(lineStart, c, infoclr); + PrintChar(lineStart, c, infoclr); } } lineStart += fontkern[c] + 2; @@ -1769,7 +1769,7 @@ void PrintGameStr(int x, int y, char *str, int color) c = gbFontTransTbl[(BYTE)*str++]; c = fontframe[c]; if (c) - CPrintString(off, c, color); + PrintChar(off, c, color); off += fontkern[c] + 1; } } @@ -2006,7 +2006,7 @@ void ADD_PlrStringXY(int x, int y, int width, char *pszStr, char col) line += fontkern[c] + 1; if (c) { if (line < widthOffset) - CPrintString(nOffset, c, col); + PrintChar(nOffset, c, col); } nOffset += fontkern[c] + 1; } @@ -2045,7 +2045,7 @@ void MY_PlrStringXY(int x, int y, int endX, char *pszStr, char col, int base) line += fontkern[c] + base; if (c) { if (line < widthOffset) - CPrintString(nOffset, c, col); + PrintChar(nOffset, c, col); } nOffset += fontkern[c] + base; } @@ -2386,7 +2386,7 @@ void PrintSBookStr(int x, int y, BOOL cjustflag, char *pszStr, char col) line += fontkern[c] + 1; if (c) { if (line <= 222) - CPrintString(width, c, col); + PrintChar(width, c, col); } width += fontkern[c] + 1; } @@ -2606,7 +2606,7 @@ char *control_print_talk_msg(char *msg, int x, int y, int *nOffset, int color) return msg; msg++; if (c) { - CPrintString(*nOffset, c, color); + PrintChar(*nOffset, c, color); } *nOffset += fontkern[c] + 1; } diff --git a/Source/control.h b/Source/control.h index 9b8b781b..1e64e1fa 100644 --- a/Source/control.h +++ b/Source/control.h @@ -60,7 +60,7 @@ void DrawSpellList(); void SetSpell(); void SetSpeedSpell(int slot); void ToggleSpell(int slot); -void CPrintString(int nOffset, int nCel, char col); +void PrintChar(int nOffset, int nCel, char col); void AddPanelString(char *str, BOOL just); void ClearPanel(); void DrawPanelBox(int x, int y, int w, int h, int sx, int sy); @@ -73,8 +73,8 @@ void DrawManaFlask(); void control_update_life_mana(); void UpdateManaFlask(); void InitControlPan(); -void ClearCtrlPan(); void DrawCtrlPan(); +void DrawCtrlBtns(); void DoSpeedBook(); void DoPanBtn(); void control_set_button_down(int btn_id); @@ -85,8 +85,8 @@ void CheckBtnUp(); void FreeControlPan(); BOOL control_WriteStringToBuffer(BYTE *str); void DrawInfoBox(); -void control_draw_info_str(); -void control_print_info_str(int y, char *str, BOOL center, int lines); +void PrintInfo(); +void CPrintString(int y, char *str, BOOL center, int lines); void PrintGameStr(int x, int y, char *str, int color); void DrawChr(); void ADD_PlrStringXY(int x, int y, int width, char *pszStr, char col); diff --git a/Source/diablo.cpp b/Source/diablo.cpp index e3643960..8b97a5d8 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -787,7 +787,7 @@ BOOL LeftMouseDown(int wParam) } else if (stextflag) { CheckStoreBtn(); } else if (MouseY < PANEL_TOP) { - if (!gmenu_exception() && !TryIconCurs()) { + if (!gmenu_is_active() && !TryIconCurs()) { if (questlog && MouseX > 32 && MouseX < 288 && MouseY > 32 && MouseY < 308) { QuestlogESC(); } else if (qtextflag) { @@ -813,7 +813,7 @@ BOOL LeftMouseDown(int wParam) } } } else { - if (!talkflag && !dropGoldFlag && !gmenu_exception()) + if (!talkflag && !dropGoldFlag && !gmenu_is_active()) CheckInvScrn(); DoPanBtn(); if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) @@ -946,7 +946,7 @@ void LeftMouseUp() void RightMouseDown() { - if (!gmenu_exception() && sgnTimeoutCurs == CURSOR_NONE && PauseMode != 2 && !plr[myplr]._pInvincible) { + if (!gmenu_is_active() && sgnTimeoutCurs == CURSOR_NONE && PauseMode != 2 && !plr[myplr]._pInvincible) { if (doomflag) { doom_close(); } else if (!stextflag) { @@ -969,7 +969,7 @@ void RightMouseDown() BOOL PressSysKey(int wParam) { - if (gmenu_exception() || wParam != VK_F10) + if (gmenu_is_active() || wParam != VK_F10) return FALSE; diablo_hotkey_msg(1); return TRUE; @@ -1037,7 +1037,7 @@ void PressKey(int vkey) if (vkey == VK_ESCAPE) { if (!PressEscKey()) { track_repeat_walk(FALSE); - gamemenu_previous(); + gamemenu_on(); } return; } @@ -1225,7 +1225,7 @@ void diablo_pause_game() /* NOTE: `return` must be used instead of `break` to be bin exact as C++ */ void PressChar(int vkey) { - if (gmenu_exception() || control_talk_last_key(vkey) || sgnTimeoutCurs != 0 || deathflag) { + if (gmenu_is_active() || control_talk_last_key(vkey) || sgnTimeoutCurs != 0 || deathflag) { return; } if ((char)vkey == 'p' || (char)vkey == 'P') { @@ -1831,12 +1831,12 @@ void game_logic() if (PauseMode == 1) { PauseMode = 2; } - if (gbMaxPlayers == 1 && gmenu_exception()) { + if (gbMaxPlayers == 1 && gmenu_is_active()) { force_redraw |= 1; return; } - if (!gmenu_exception() && sgnTimeoutCurs == 0) { + if (!gmenu_is_active() && sgnTimeoutCurs == 0) { CheckCursMove(); track_process(); } diff --git a/Source/error.cpp b/Source/error.cpp index 6a87b9c8..1d96d370 100644 --- a/Source/error.cpp +++ b/Source/error.cpp @@ -127,7 +127,7 @@ void DrawDiabloMsg() for (i = 0; i < len; i++) { c = fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]; if (c != '\0') { - CPrintString(off, c, COL_GOLD); + PrintChar(off, c, COL_GOLD); } off += fontkern[c] + 1; } diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index 09124e8d..7cf3db3c 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -28,7 +28,7 @@ TMenuItem sgOptionsMenu[6] = { { GMENU_ENABLED | GMENU_SLIDER, NULL, &gamemenu_sound_volume }, { GMENU_ENABLED | GMENU_SLIDER, "Gamma", &gamemenu_gamma }, { GMENU_ENABLED , NULL, &gamemenu_color_cycling }, - { GMENU_ENABLED , "Previous Menu", &j_gamemenu_previous }, + { GMENU_ENABLED , "Previous Menu", &gamemenu_previous }, { GMENU_ENABLED , NULL, NULL } // clang-format on }; @@ -36,23 +36,23 @@ char *music_toggle_names[] = { "Music", "Music Disabled" }; char *sound_toggle_names[] = { "Sound", "Sound Disabled" }; char *color_cycling_toggle_names[] = { "Color Cycling Off", "Color Cycling On" }; -void gamemenu_previous() +void gamemenu_on() { void (*proc)(TMenuItem *); TMenuItem *item; if (gbMaxPlayers == 1) { - proc = gamemenu_enable_single; + proc = gamemenu_update_single; item = sgSingleMenu; } else { - proc = gamemenu_enable_multi; + proc = gamemenu_update_multi; item = sgMultiMenu; } - gmenu_call_proc(item, proc); + gmenu_set_items(item, proc); PressEscKey(); } -void gamemenu_enable_single(TMenuItem *pMenuItems) +void gamemenu_update_single(TMenuItem *pMenuItems) { BOOL enable; @@ -65,27 +65,27 @@ void gamemenu_enable_single(TMenuItem *pMenuItems) gmenu_enable(sgSingleMenu, enable); } -void gamemenu_enable_multi(TMenuItem *pMenuItems) +void gamemenu_update_multi(TMenuItem *pMenuItems) { gmenu_enable(&sgMultiMenu[2], deathflag); } void gamemenu_off() { - gmenu_call_proc(0, NULL); + gmenu_set_items(0, NULL); } void gamemenu_handle_previous() { - if (gmenu_exception()) + if (gmenu_is_active()) gamemenu_off(); else - gamemenu_previous(); + gamemenu_on(); } -void j_gamemenu_previous(BOOL bActivate) +void gamemenu_previous(BOOL bActivate) { - gamemenu_previous(); + gamemenu_on(); } void gamemenu_new_game(BOOL bActivate) @@ -166,7 +166,7 @@ void gamemenu_options(BOOL bActivate) gamemenu_get_sound(); gamemenu_get_gamma(); gamemenu_get_color_cycling(); - gmenu_call_proc(sgOptionsMenu, NULL); + gmenu_set_items(sgOptionsMenu, NULL); } void gamemenu_get_music() diff --git a/Source/gamemenu.h b/Source/gamemenu.h index 96daa542..634e17cf 100644 --- a/Source/gamemenu.h +++ b/Source/gamemenu.h @@ -2,12 +2,12 @@ #ifndef __GAMEMENU_H__ #define __GAMEMENU_H__ -void gamemenu_previous(); -void gamemenu_enable_single(TMenuItem *pMenuItems); -void gamemenu_enable_multi(TMenuItem *pMenuItems); +void gamemenu_on(); +void gamemenu_update_single(TMenuItem *pMenuItems); +void gamemenu_update_multi(TMenuItem *pMenuItems); void gamemenu_off(); void gamemenu_handle_previous(); -void j_gamemenu_previous(BOOL bActivate); +void gamemenu_previous(BOOL bActivate); void gamemenu_new_game(BOOL bActivate); void gamemenu_quit_game(BOOL bActivate); void gamemenu_load_game(BOOL bActivate); diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 3c4d4fe1..d78cd99f 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -84,12 +84,12 @@ void gmenu_init_menu() optbar_cel = LoadFileInMem("Data\\optbar.CEL", NULL); } -BOOL gmenu_exception() +BOOL gmenu_is_active() { return sgpCurrentMenu != 0; } -void gmenu_call_proc(TMenuItem *pItem, void (*gmFunc)(TMenuItem *)) +void gmenu_set_items(TMenuItem *pItem, void (*gmFunc)(TMenuItem *)) { int i; @@ -238,7 +238,7 @@ BOOL gmenu_presskeys(int vkey) break; case VK_ESCAPE: PlaySFX(IS_TITLEMOV); - gmenu_call_proc(0, 0); + gmenu_set_items(0, 0); break; case VK_SPACE: return FALSE; @@ -285,7 +285,7 @@ BOOL gmenu_on_mouse_move() if (!mouseNavigation) return FALSE; - gmenu_valid_mouse_pos(&step); + gmenu_get_mouse_slider(&step); nSteps = (int)(sgpCurrItem->dwFlags & 0xFFF000) >> 12; step *= nSteps; step /= 256; @@ -296,7 +296,7 @@ BOOL gmenu_on_mouse_move() return TRUE; } -BOOLEAN gmenu_valid_mouse_pos(int *plOffset) +BOOLEAN gmenu_get_mouse_slider(int *plOffset) { *plOffset = 282; if (MouseX < 282 + PANEL_LEFT) { @@ -353,7 +353,7 @@ BOOL gmenu_left_mouse(BOOL isDown) sgpCurrItem = pItem; PlaySFX(IS_TITLEMOV); if (pItem->dwFlags & GMENU_SLIDER) { - mouseNavigation = gmenu_valid_mouse_pos(&dummy); + mouseNavigation = gmenu_get_mouse_slider(&dummy); gmenu_on_mouse_move(); } else { sgpCurrItem->fnMenu(TRUE); diff --git a/Source/gmenu.h b/Source/gmenu.h index 997aaffe..b884a9a9 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -17,8 +17,8 @@ void gmenu_draw_pause(); void gmenu_print_text(int x, int y, char *pszStr); void FreeGMenu(); void gmenu_init_menu(); -BOOL gmenu_exception(); -void gmenu_call_proc(TMenuItem *pItem, void (*gmFunc)(TMenuItem *)); +BOOL gmenu_is_active(); +void gmenu_set_items(TMenuItem *pItem, void (*gmFunc)(TMenuItem *)); void gmenu_up_down(BOOL isDown); void gmenu_draw(); void gmenu_draw_menu_item(TMenuItem *pItem, int y); @@ -27,7 +27,7 @@ int gmenu_get_lfont(TMenuItem *pItem); BOOL gmenu_presskeys(int vkey); void gmenu_left_right(BOOL isRight); BOOL gmenu_on_mouse_move(); -BOOLEAN gmenu_valid_mouse_pos(int *plOffset); +BOOLEAN gmenu_get_mouse_slider(int *plOffset); BOOL gmenu_left_mouse(BOOL isDown); void gmenu_enable(TMenuItem *pMenuItem, BOOL enable); void gmenu_slider_set(TMenuItem *pItem, int min, int max, int gamma); diff --git a/Source/help.cpp b/Source/help.cpp index 0922e1a5..69b166bf 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -545,7 +545,7 @@ void DrawHelpLine(int always_0, int help_line_nr, char *text, char color) width += fontkern[c] + 1; if (c) { if (width <= 577) - CPrintString(off, c, color); + PrintChar(off, c, color); } off += fontkern[c] + 1; } diff --git a/Source/inv.cpp b/Source/inv.cpp index 371fd41f..b867a154 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -451,7 +451,7 @@ void DrawInvBelt() && plr[myplr].SpdList[i]._itype != ITYPE_GOLD) { fi = i + 49; ff = fontframe[gbFontTransTbl[fi]]; - CPrintString(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X + PitchTbl[InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1] - fontkern[ff] + 28, ff, 0); + PrintChar(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X + PitchTbl[InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1] - fontkern[ff] + 28, ff, 0); } } } diff --git a/Source/items.cpp b/Source/items.cpp index 22ee22a3..230da042 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -2942,7 +2942,7 @@ void PrintUString(int x, int y, BOOL cjustflag, char *str, int col) c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; k += fontkern[c] + 1; if (c && k <= 257) { - CPrintString(off, c, col); + PrintChar(off, c, col); } off += fontkern[c] + 1; } diff --git a/Source/player.cpp b/Source/player.cpp index 9186d2c8..bef128d7 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -2968,7 +2968,7 @@ BOOL PM_DoDeath(int pnum) if (deathdelay == 1) { deathflag = TRUE; if (gbMaxPlayers == 1) { - gamemenu_previous(); + gamemenu_on(); } } } diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index 185739f3..c5b85113 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -133,7 +133,7 @@ void PrintPlrMsg(DWORD x, DWORD y, DWORD width, const char *str, BYTE col) c = gbFontTransTbl[(BYTE)*str++]; c = fontframe[c]; if (c) - CPrintString(screen, c, col); + PrintChar(screen, c, col); screen += fontkern[c] + 1; } diff --git a/Source/quests.cpp b/Source/quests.cpp index 5517d745..20169885 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -720,7 +720,7 @@ void PrintQLString(int x, int y, BOOL cjustflag, char *str, int col) c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; k += fontkern[c] + 1; if (c && k <= 257) { - CPrintString(off, c, col); + PrintChar(off, c, col); } off += fontkern[c] + 1; } diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 1fcd527a..7a92d335 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -2898,7 +2898,7 @@ void DrawAndBlit() T_DrawView(ViewX, ViewY); } if (ctrlPan) { - ClearCtrlPan(); + DrawCtrlPan(); } if (drawhpflag) { UpdateLifeFlask(); @@ -2907,7 +2907,7 @@ void DrawAndBlit() UpdateManaFlask(); } if (drawbtnflag) { - DrawCtrlPan(); + DrawCtrlBtns(); } if (drawsbarflag) { DrawInvBelt(); diff --git a/Source/stores.cpp b/Source/stores.cpp index ab9990e2..61d3dd7d 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -173,7 +173,7 @@ void PrintSString(int x, int y, BOOL cjustflag, char *str, char col, int val) c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; k += fontkern[c] + 1; if (c && k <= yy) { - CPrintString(off, c, col); + PrintChar(off, c, col); } off += fontkern[c] + 1; } @@ -184,7 +184,7 @@ void PrintSString(int x, int y, BOOL cjustflag, char *str, char col, int val) c = fontframe[gbFontTransTbl[(BYTE)valstr[i]]]; off -= fontkern[c] + 1; if (c) { - CPrintString(off, c, col); + PrintChar(off, c, col); } } } diff --git a/comparer-config/diablo.toml b/comparer-config/diablo.toml index bff95c25..0ea60516 100644 --- a/comparer-config/diablo.toml +++ b/comparer-config/diablo.toml @@ -153,7 +153,7 @@ addr = 0x401FBD size = 0x276 [[func]] -name = "DrawAutomapType" +name = "DrawAutomapTile" addr = 0x402233 size = 0x745 @@ -168,7 +168,7 @@ addr = 0x402D83 size = 0xC7 [[func]] -name = "DrawAutomapGame" +name = "DrawAutomapText" addr = 0x402E4A size = 0xDD @@ -273,7 +273,7 @@ addr = 0x404017 size = 0xC3 [[func]] -name = "CPrintString" +name = "PrintChar" addr = 0x4040DA size = 0x13E @@ -333,12 +333,12 @@ addr = 0x404616 size = 0x31E [[func]] -name = "ClearCtrlPan" +name = "DrawCtrlPan" addr = 0x404934 size = 0x25 [[func]] -name = "DrawCtrlPan" +name = "DrawCtrlBtns" addr = 0x404959 size = 0xB1 @@ -393,12 +393,12 @@ addr = 0x4052C8 size = 0x289 [[func]] -name = "control_draw_info_str" +name = "PrintInfo" addr = 0x405551 size = 0x6B [[func]] -name = "control_print_info_str" +name = "CPrintString" addr = 0x4055BC size = 0xC5 @@ -2078,17 +2078,17 @@ addr = 0x418860 size = 0x6 [[func]] -name = "gamemenu_previous" +name = "gamemenu_on" addr = 0x418866 size = 0x29 [[func]] -name = "gamemenu_enable_single" +name = "gamemenu_update_single" addr = 0x41888F size = 0x39 [[func]] -name = "gamemenu_enable_multi" +name = "gamemenu_update_multi" addr = 0x4188C8 size = 0x10 @@ -2103,7 +2103,7 @@ addr = 0x4188E1 size = 0x13 [[func]] -name = "j_gamemenu_previous" +name = "gamemenu_previous" addr = 0x4188F4 size = 0x5 @@ -2323,12 +2323,12 @@ addr = 0x419F70 size = 0x78 [[func]] -name = "gmenu_exception" +name = "gmenu_is_active" addr = 0x419FE8 size = 0xC [[func]] -name = "gmenu_call_proc" +name = "gmenu_set_items" addr = 0x419FF4 size = 0x5A @@ -2373,7 +2373,7 @@ addr = 0x41A37A size = 0x58 [[func]] -name = "gmenu_valid_mouse_pos" +name = "gmenu_get_mouse_slider" addr = 0x41A3D2 size = 0x2F diff --git a/comparer-config/spawn.toml b/comparer-config/spawn.toml index 08d16891..7d0685ef 100644 --- a/comparer-config/spawn.toml +++ b/comparer-config/spawn.toml @@ -153,7 +153,7 @@ addr = 0x401FBD size = 0x276 [[func]] -name = "DrawAutomapType" +name = "DrawAutomapTile" addr = 0x402233 size = 0x745 @@ -168,7 +168,7 @@ addr = 0x402D83 size = 0xC7 [[func]] -name = "DrawAutomapGame" +name = "DrawAutomapText" addr = 0x402E4A size = 0xDD @@ -273,7 +273,7 @@ addr = 0x404017 size = 0xC3 [[func]] -name = "CPrintString" +name = "PrintChar" addr = 0x4040DA size = 0x13E @@ -333,12 +333,12 @@ addr = 0x404616 size = 0x2FC [[func]] -name = "ClearCtrlPan" +name = "DrawCtrlPan" addr = 0x404912 size = 0x25 [[func]] -name = "DrawCtrlPan" +name = "DrawCtrlBtns" addr = 0x404937 size = 0xB1 @@ -393,12 +393,12 @@ addr = 0x4052A6 size = 0x289 [[func]] -name = "control_draw_info_str" +name = "PrintInfo" addr = 0x40552F size = 0x6B [[func]] -name = "control_print_info_str" +name = "CPrintString" addr = 0x40559A size = 0xC5 @@ -1548,17 +1548,17 @@ addr = 0x4106D0 size = 0x6 [[func]] -name = "gamemenu_previous" +name = "gamemenu_on" addr = 0x4106D6 size = 0x29 [[func]] -name = "gamemenu_enable_single" +name = "gamemenu_update_single" addr = 0x4106FF size = 0x39 [[func]] -name = "gamemenu_enable_multi" +name = "gamemenu_update_multi" addr = 0x410738 size = 0x10 @@ -1573,7 +1573,7 @@ addr = 0x410751 size = 0x13 [[func]] -name = "j_gamemenu_previous" +name = "gamemenu_previous" addr = 0x410764 size = 0x5 @@ -1763,12 +1763,12 @@ addr = 0x4115EC size = 0x78 [[func]] -name = "gmenu_exception" +name = "gmenu_is_active" addr = 0x411664 size = 0xC [[func]] -name = "gmenu_call_proc" +name = "gmenu_set_items" addr = 0x411670 size = 0x5A @@ -1813,7 +1813,7 @@ addr = 0x4119F6 size = 0x58 [[func]] -name = "gmenu_valid_mouse_pos" +name = "gmenu_get_mouse_slider" addr = 0x411A4E size = 0x2F From f8831ba3b0d8afd832a7feda54e0553345841e92 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 29 Feb 2020 17:56:18 +0100 Subject: [PATCH 23/38] Fix Travis Mac builds because of an outdated brew --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 7dc3a4f2..7c149b61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ addons: homebrew: packages: - mingw-w64 + update: true env: - MAKE_BUILD=make From 21b62274b91029ee7eaec6bc6ef9e77de95e932e Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 29 Feb 2020 18:31:49 +0100 Subject: [PATCH 24/38] Document .SOL value tables --- Source/gendung.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Source/gendung.cpp b/Source/gendung.cpp index e9c0cde3..9061e1f9 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -2,6 +2,9 @@ WORD level_frame_types[MAXTILES]; int themeCount; +/** + * List of transparent dPieces + */ BOOLEAN nTransTable[2049]; //int dword_52D204; int dMonster[MAXDUNX][MAXDUNY]; @@ -23,6 +26,9 @@ int tile_defs[MAXTILES]; BYTE *pMegaTiles; BYTE *pLevelPieces; int gnDifficulty; +/** + * List of transparancy masks to use for dPieces + */ char block_lvid[2049]; //char byte_5B78EB; char dTransVal[MAXDUNX][MAXDUNY]; @@ -30,6 +36,9 @@ BOOLEAN nTrapTable[2049]; BYTE leveltype; BYTE currlevel; BOOLEAN TransList[256]; +/** + * List of path blocking dPieces + */ BOOLEAN nSolidTable[2049]; int level_frame_count[MAXTILES]; ScrollStruct ScrollInfo; @@ -42,12 +51,18 @@ int dword_5C2FFC; int scr_pix_width; int scr_pix_height; char dArch[MAXDUNX][MAXDUNY]; +/** + * List of light blocking dPieces + */ BOOLEAN nBlockTable[2049]; BYTE *pSpecialCels; char dFlags[MAXDUNX][MAXDUNY]; char dItem[MAXDUNX][MAXDUNY]; BYTE setlvlnum; int level_frame_sizes[MAXTILES]; +/** + * List of missile blocking dPieces + */ BOOLEAN nMissileTable[2049]; BYTE *pSetPiece; char setlvltype; From 3c276a3cd3423f117df9e50ca3456e285706db7c Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 1 Mar 2020 01:29:19 +0100 Subject: [PATCH 25/38] Add documentation - Add file documentation to about 1/4 of the files in Source - Copy over a lot of the documentation from the sanctuary/notes repo - Standardise all the existing documentation - Create a configuration for Doxygen - Add more documentation (engine.cpp is now fully documented) --- .gitignore | 1 + Source/all.h | 5 ++ Source/appfat.cpp | 19 +++++ Source/appfat.h | 6 +- Source/automap.cpp | 13 +++- Source/automap.h | 6 +- Source/capture.cpp | 12 +++ Source/capture.h | 6 +- Source/codec.cpp | 5 ++ Source/codec.h | 6 +- Source/control.cpp | 11 ++- Source/control.h | 6 +- Source/cursor.cpp | 9 ++- Source/cursor.h | 6 +- Source/dead.cpp | 7 +- Source/dead.h | 6 +- Source/debug.cpp | 5 ++ Source/debug.h | 6 +- Source/diablo.cpp | 20 ++++- Source/diablo.h | 12 ++- Source/doom.cpp | 5 ++ Source/doom.h | 6 +- Source/drlg_l1.cpp | 5 ++ Source/drlg_l1.h | 6 +- Source/drlg_l2.cpp | 5 ++ Source/drlg_l2.h | 6 +- Source/drlg_l3.cpp | 5 ++ Source/drlg_l3.h | 6 +- Source/drlg_l4.cpp | 5 ++ Source/drlg_l4.h | 6 +- Source/dthread.cpp | 5 ++ Source/dthread.h | 6 +- Source/dx.cpp | 5 ++ Source/dx.h | 6 +- Source/effects.cpp | 14 +++- Source/effects.h | 6 +- Source/encrypt.cpp | 5 ++ Source/encrypt.h | 6 +- Source/engine.cpp | 16 ++++ Source/engine.h | 24 +++++- Source/error.cpp | 6 ++ Source/error.h | 6 +- Source/fault.cpp | 5 ++ Source/fault.h | 6 +- Source/gamemenu.cpp | 5 ++ Source/gamemenu.h | 6 +- Source/gmenu.cpp | 7 ++ Source/gmenu.h | 6 +- Source/interfac.cpp | 2 + Source/lighting.cpp | 59 +++++++-------- Source/lighting.h | 6 +- Source/list.h | 30 ++++---- Source/logging.cpp | 2 + Source/mainmenu.cpp | 1 + Source/misdat.cpp | 2 + Source/missiles.cpp | 2 + Source/monster.cpp | 9 ++- Source/monster.h | 8 +- Source/movie.cpp | 2 + Source/mpqapi.cpp | 2 + Source/nthread.cpp | 5 ++ Source/nthread.h | 6 +- Source/objects.cpp | 2 +- Source/pack.cpp | 10 ++- Source/path.cpp | 25 +++--- Source/path.h | 6 +- Source/pfile.cpp | 1 + Source/player.cpp | 2 +- Source/plrmsg.cpp | 1 + Source/portal.cpp | 4 + Source/render.cpp | 2 +- Source/setmaps.cpp | 1 + Source/spelldat.cpp | 1 + Source/stores.cpp | 1 + Source/textdat.cpp | 3 +- Source/themes.cpp | 180 +++++++++++++++++++++++++------------------- Source/themes.h | 6 +- Source/towners.cpp | 3 +- defs.h | 6 +- doxygen.config | 34 +++++++++ 80 files changed, 602 insertions(+), 184 deletions(-) create mode 100644 doxygen.config diff --git a/.gitignore b/.gitignore index d14076ae..97e810c1 100644 --- a/.gitignore +++ b/.gitignore @@ -373,3 +373,4 @@ ASALocalRun/ *.pubxml.user # End of https://www.gitignore.io/api/visualstudio +/docs/html/ diff --git a/Source/all.h b/Source/all.h index 4a19fbbf..75e22931 100644 --- a/Source/all.h +++ b/Source/all.h @@ -1,3 +1,8 @@ +/** + * @file all.h + * + * Include all aplication headers. + */ #ifndef __ALL_H__ #define __ALL_H__ diff --git a/Source/appfat.cpp b/Source/appfat.cpp index 51be3e1d..69222e70 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -1,8 +1,15 @@ +/** + * @file appfat.cpp + * + * Implementation of error dialogs. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" char sz_error_buf[256]; +/** Set to true when a fatal error is encountered and the application should shut down. */ BOOL terminating; +/** Thread id of the last callee to FreeDlg(). */ int cleanup_thread_id; // delete overloads the delete operator. @@ -80,6 +87,12 @@ char *GetErrorStr(DWORD error_code) return sz_error_buf; } +/** + * @brief Generate a textual message for DirectDraw error codes + * @param hError DirectDraw error code + * @param pszBuffer Buffer for the error message + * @param dwMaxChars Length of pszBuffer + */ void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) { const char *szError; @@ -390,6 +403,12 @@ void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) strncpy(pszBuffer, szError, dwMaxChars); } +/** + * @brief Generate a textual message for DirectSound error codes + * @param hError DirectSound error code + * @param pszBuffer Buffer for the error message + * @param dwMaxChars Length of pszBuffer + */ void TraceErrorDS(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) { const char *szError; diff --git a/Source/appfat.h b/Source/appfat.h index 97c49825..ea335f09 100644 --- a/Source/appfat.h +++ b/Source/appfat.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file appfat.h + * + * Interface of error dialogs. + */ #ifndef __APPFAT_H__ #define __APPFAT_H__ diff --git a/Source/automap.cpp b/Source/automap.cpp index 5a2df7ab..6f64b069 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -1,3 +1,8 @@ +/** + * @file automap.cpp + * + * Implementation of the ingame map overlay. + */ #include "all.h" // BUGFIX: only the first 256 elements are ever read @@ -16,15 +21,15 @@ int AmLine16; int AmLine8; int AmLine4; -// color used to draw the player's arrow +/** color used to draw the player's arrow */ #define COLOR_PLAYER (PAL8_ORANGE + 1) -// color for bright map lines (doors, stairs etc.) +/** color for bright map lines (doors, stairs etc.) */ #define COLOR_BRIGHT PAL8_YELLOW -// color for dim map lines/dots +/** color for dim map lines/dots */ #define COLOR_DIM (PAL16_YELLOW + 8) #define MAPFLAG_TYPE 0x000F -// these are in the second byte +/** these are in the second byte */ #define MAPFLAG_VERTDOOR 0x01 #define MAPFLAG_HORZDOOR 0x02 #define MAPFLAG_VERTARCH 0x04 diff --git a/Source/automap.h b/Source/automap.h index a947c467..22ccfaa7 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file automap.h + * + * Interface of the ingame map overlay. + */ #ifndef __AUTOMAP_H__ #define __AUTOMAP_H__ diff --git a/Source/capture.cpp b/Source/capture.cpp index ce3a07bf..552b43e2 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -1,5 +1,17 @@ +/** + * @file capture.cpp + * + * Implementation of the screenshot function. + */ #include "all.h" +/** + * @brief Write the PCX-file header + * @param hFile File handler for the PCX file. + * @param width Image width + * @param height Image height + * @return True on success + */ static BOOL CaptureHdr(HANDLE hFile, short width, short height) { DWORD lpNumBytes; diff --git a/Source/capture.h b/Source/capture.h index c1e86c10..9a54e2d1 100644 --- a/Source/capture.h +++ b/Source/capture.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file capture.h + * + * Interface of the screenshot function. + */ #ifndef __CAPTURE_H__ #define __CAPTURE_H__ diff --git a/Source/codec.cpp b/Source/codec.cpp index 835cf447..1e9402b7 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -1,3 +1,8 @@ +/** + * @file codec.cpp + * + * Implementation of save game encryption algorithm. + */ #include "all.h" struct CodecSignature { diff --git a/Source/codec.h b/Source/codec.h index 0cae2784..00c11cea 100644 --- a/Source/codec.h +++ b/Source/codec.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file codec.h + * + * Interface of save game encryption algorithm. + */ #ifndef __CODEC_H__ #define __CODEC_H__ diff --git a/Source/control.cpp b/Source/control.cpp index 589efcfb..d612b2b3 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1,3 +1,8 @@ +/** + * @file control.cpp + * + * Implementation of the character and main control panels + */ #include "all.h" BYTE sgbNextTalkSave; @@ -18,7 +23,8 @@ BOOL drawmanaflag; BOOL chrbtnactive; char sgszTalkMsg[MAX_SEND_STR_LEN]; BYTE *pPanelText; -int nGoldFrame; /** current frame # for the pentagram caret in gold input */ +/** current frame # for the pentagram caret in gold input */ +int nGoldFrame; BYTE *pLifeBuff; BYTE *pBtmBuff; BYTE *pTalkBtns; @@ -36,7 +42,8 @@ char tempstr[256]; BOOLEAN whisper[MAX_PLRS]; int sbooktab; int pSplType; -int frame; /** current frame # for the pentagram caret in chat input */ +/** current frame # for the pentagram caret in chat input */ +int frame; int initialDropGoldIndex; BOOL talkflag; BYTE *pSBkIconCels; diff --git a/Source/control.h b/Source/control.h index 1e64e1fa..0fa12609 100644 --- a/Source/control.h +++ b/Source/control.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file control.h + * + * Interface of the character and main control panels + */ #ifndef __CONTROL_H__ #define __CONTROL_H__ diff --git a/Source/cursor.cpp b/Source/cursor.cpp index d463c15a..8fa3aa31 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -1,3 +1,8 @@ +/** + * @file cursor.cpp + * + * Implementation of cursor tracking functionality. + */ #include "all.h" int cursH; @@ -8,7 +13,7 @@ int icursW28; BYTE *pCursCels; int icursH; -// inv_item value +/** inv_item value */ char pcursinvitem; int icursW; char pcursitem; @@ -20,6 +25,7 @@ int pcurstemp; int pcurs; /* rdata */ +/** Maps from objcurs.cel frame number to frame width. */ const int InvItemWidth[180] = { // Cursors 0, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 23, @@ -43,6 +49,7 @@ const int InvItemWidth[180] = { 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28 }; +/** Maps from objcurs.cel frame number to frame height. */ const int InvItemHeight[180] = { // Cursors 0, 29, 32, 32, 32, 32, 32, 32, 32, 32, 32, 35, diff --git a/Source/cursor.h b/Source/cursor.h index 5fbb4241..42b1df21 100644 --- a/Source/cursor.h +++ b/Source/cursor.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file cursor.h + * + * Interface of cursor tracking functionality. + */ #ifndef __CURSOR_H__ #define __CURSOR_H__ diff --git a/Source/dead.cpp b/Source/dead.cpp index 00e87d27..ba72cd0a 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -1,6 +1,11 @@ +/** + * @file dead.cpp + * + * Implementation of functions for placing dead monsters. + */ #include "all.h" -// unused, this was probably for blood boil/burn +/** unused, this was probably for blood boil/burn */ int spurtndx; DeadStruct dead[MAXDEAD]; int stonendx; diff --git a/Source/dead.h b/Source/dead.h index bc16374d..f9e992a2 100644 --- a/Source/dead.h +++ b/Source/dead.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file dead.h + * + * Interface of functions for placing dead monsters. + */ #ifndef __DEAD_H__ #define __DEAD_H__ diff --git a/Source/debug.cpp b/Source/debug.cpp index f01542c6..24d004d0 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -1,3 +1,8 @@ +/** + * @file debug.cpp + * + * Implementation of debug functions. + */ #include "all.h" #ifdef _DEBUG diff --git a/Source/debug.h b/Source/debug.h index d3dacf70..439fc9c8 100644 --- a/Source/debug.h +++ b/Source/debug.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file debug.h + * + * Interface of debug functions. + */ #ifndef __DEBUG_H__ #define __DEBUG_H__ diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 8b97a5d8..c764276d 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1,3 +1,8 @@ +/** + * @file diablo.cpp + * + * Implementation of the main game initialization functions. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" @@ -22,11 +27,13 @@ int DebugMonsters[10]; BOOLEAN cineflag; int force_redraw; BOOL visiondebug; -BOOL scrollflag; /* unused */ +/** unused */ +BOOL scrollflag; BOOL light4flag; BOOL leveldebug; BOOL monstdebug; -BOOL trigdebug; /* unused */ +/** unused */ +BOOL trigdebug; int setseed; int debugmonsttypes; int PauseMode; @@ -56,12 +63,14 @@ int framerate; int framestart; #endif BOOL FriendlyMode = TRUE; +/** Default quick messages */ char *spszMsgTbl[4] = { "I need help! Come Here!", "Follow me.", "Here's something for you.", "Now you DIE!" }; +/** INI files variable names for quick message keys */ char *spszMsgHotKeyTbl[4] = { "F9", "F10", "F11", "F12" }; void FreeGameMem() @@ -236,6 +245,13 @@ BOOL diablo_get_not_running() return GetLastError() != ERROR_ALREADY_EXISTS; } +/** + * @brief Main entry point, check env, initialize systesm, play intros, start main menu, shut down + * @param hInstance A handle to the current instance of the application. + * @param hPrevInstance Always null + * @param lpCmdLine The command line for the application + * @param nCmdShow Initial window state + */ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HINSTANCE hInst; diff --git a/Source/diablo.h b/Source/diablo.h index 8127673e..1e3f5002 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file diablo.h + * + * Interface of the main game initialization functions. + */ #ifndef __DIABLO_H__ #define __DIABLO_H__ @@ -22,11 +26,13 @@ extern int DebugMonsters[10]; extern BOOLEAN cineflag; extern int force_redraw; extern BOOL visiondebug; -extern BOOL scrollflag; /* unused */ +/** unused */ +extern BOOL scrollflag; extern BOOL light4flag; extern BOOL leveldebug; extern BOOL monstdebug; -extern BOOL trigdebug; /* unused */ +/** unused */ +extern BOOL trigdebug; extern int setseed; extern int debugmonsttypes; extern int PauseMode; diff --git a/Source/doom.cpp b/Source/doom.cpp index b336849e..b419c702 100644 --- a/Source/doom.cpp +++ b/Source/doom.cpp @@ -1,3 +1,8 @@ +/** + * @file doom.cpp + * + * Implementation of the map of the stars quest. + */ #include "all.h" int doom_quest_time; diff --git a/Source/doom.h b/Source/doom.h index 31635fe0..b72b2c33 100644 --- a/Source/doom.h +++ b/Source/doom.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file doom.h + * + * Interface of the map of the stars quest. + */ #ifndef __DOOM_H__ #define __DOOM_H__ diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 64391da7..9aa56141 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -1,3 +1,8 @@ +/** + * @file drlg_l1.cpp + * + * Implementation of the cathedral level generation algorithms. + */ #include "all.h" BYTE L5dungeon[80][80]; diff --git a/Source/drlg_l1.h b/Source/drlg_l1.h index e9e354d5..2b0ff6c5 100644 --- a/Source/drlg_l1.h +++ b/Source/drlg_l1.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file drlg_l1.h + * + * Interface of the cathedral level generation algorithms. + */ #ifndef __DRLG_L1_H__ #define __DRLG_L1_H__ diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index b66ccab9..fc3ea922 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -1,3 +1,8 @@ +/** + * @file drlg_l2.cpp + * + * Implementation of the catacombs level generation algorithms. + */ #ifndef SPAWN #include "all.h" diff --git a/Source/drlg_l2.h b/Source/drlg_l2.h index 35beda6b..8b9e8690 100644 --- a/Source/drlg_l2.h +++ b/Source/drlg_l2.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file drlg_l2.h + * + * Interface of the catacombs level generation algorithms. + */ #ifndef __DRLG_L2_H__ #define __DRLG_L2_H__ diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 43a1a67e..3679c2e4 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1,3 +1,8 @@ +/** + * @file drlg_l3.cpp + * + * Implementation of the caves level generation algorithms. + */ #ifndef SPAWN #include "all.h" diff --git a/Source/drlg_l3.h b/Source/drlg_l3.h index 9170d7f9..a3067300 100644 --- a/Source/drlg_l3.h +++ b/Source/drlg_l3.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file drlg_l3.h + * + * Interface of the caves level generation algorithms. + */ #ifndef __DRLG_L3_H__ #define __DRLG_L3_H__ diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 9cf009bf..f97a0be4 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1,3 +1,8 @@ +/** + * @file drlg_l4.cpp + * + * Implementation of the hell level generation algorithms. + */ #include "all.h" int diabquad1x; diff --git a/Source/drlg_l4.h b/Source/drlg_l4.h index 6559545b..cf64e917 100644 --- a/Source/drlg_l4.h +++ b/Source/drlg_l4.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file drlg_l4.h + * + * Interface of the hell level generation algorithms. + */ #ifndef __DRLG_L4_H__ #define __DRLG_L4_H__ diff --git a/Source/dthread.cpp b/Source/dthread.cpp index b17457cf..6e3e9a0b 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -1,3 +1,8 @@ +/** + * @file dthread.cpp + * + * Implementation of functions for updating game state from network commands. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" diff --git a/Source/dthread.h b/Source/dthread.h index 4ad5d3fb..7a9e86c9 100644 --- a/Source/dthread.h +++ b/Source/dthread.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file dthread.h + * + * Interface of functions for updating game state from network commands. + */ #ifndef __DTHREAD_H__ #define __DTHREAD_H__ diff --git a/Source/dx.cpp b/Source/dx.cpp index 99c5dc33..2ead8b68 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -1,3 +1,8 @@ +/** + * @file dx.cpp + * + * Implementation of functions setting up the graphics pipeline. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" diff --git a/Source/dx.h b/Source/dx.h index 39c0fbef..1a13e3b1 100644 --- a/Source/dx.h +++ b/Source/dx.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file dx.h + * + * Interface of functions setting up the graphics pipeline. + */ #ifndef __DX_H__ #define __DX_H__ diff --git a/Source/effects.cpp b/Source/effects.cpp index 0afb731a..cfa3d203 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1,3 +1,8 @@ +/** + * @file effects.cpp + * + * Implementation of functions for loading and playing sounds. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" @@ -6,10 +11,17 @@ int sfxdnum; HANDLE sfx_stream; TSFX *sfx_data_cur; +/** + * Monster sound type prefix + * a: Attack + * h: Hit + * d: Death + * s: Special + */ const char MonstSndChar[] = { 'a', 'h', 'd', 's' }; /* data */ - +/** List of all sounds, except monsters and music */ TSFX sgSFX[] = { // clang-format off // bFlags, pszName, pSnd diff --git a/Source/effects.h b/Source/effects.h index 8ed845e6..5aa3ddbc 100644 --- a/Source/effects.h +++ b/Source/effects.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file effects.h + * + * Interface of functions for loading and playing sounds. + */ #ifndef __EFFECTS_H__ #define __EFFECTS_H__ diff --git a/Source/encrypt.cpp b/Source/encrypt.cpp index 50abc783..dd4d0a4a 100644 --- a/Source/encrypt.cpp +++ b/Source/encrypt.cpp @@ -1,3 +1,8 @@ +/** + * @file encrypt.cpp + * + * Implementation of functions for compression and decompressing MPQ data. + */ #include "all.h" #include "../3rdParty/PKWare/pkware.h" diff --git a/Source/encrypt.h b/Source/encrypt.h index 0d76b0f8..552bed22 100644 --- a/Source/encrypt.h +++ b/Source/encrypt.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file encrypt.h + * + * Interface of functions for compression and decompressing MPQ data. + */ #ifndef __ENCRYPT_H__ #define __ENCRYPT_H__ diff --git a/Source/engine.cpp b/Source/engine.cpp index 13a86bfc..fb460826 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -1,3 +1,15 @@ +/** + * @file engine.cpp + * + * Implementation of basic engine helper functions: + * - Sprite blitting + * - Drawing + * - Angle calculation + * - RNG + * - Memory allocation + * - File loading + * - Video playback + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" @@ -8,7 +20,9 @@ char gbPixelCol; // automap pixel color 8-bit (palette entry) BOOL gbRotateMap; // flip - if y < x int orgseed; +/** Width of sprite being blitted */ int sgnWidth; +/** Current game seed */ int sglGameSeed; #ifdef __cplusplus static CCritSect sgMemCrit; @@ -2255,12 +2269,14 @@ void engine_draw_pixel(int sx, int sy) #endif } +/** Macro used in DrawLine() */ #define GG_SWAP(A, B) \ { \ (A) ^= (B); \ (B) ^= (A); \ (A) ^= (B); \ } +/** Macro used in DrawLine() */ #define GG_ABSOLUTE(I, J, K) (((I) - (J)) * ((K) = (((I) - (J)) < 0 ? -1 : 1))) /** diff --git a/Source/engine.h b/Source/engine.h index 26075080..9027445b 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -1,15 +1,31 @@ -//HEADER_GOES_HERE +/** + * @file engine.h + * + * of basic engine helper functions: + * - Sprite blitting + * - Drawing + * - Angle calculation + * - RNG + * - Memory allocation + * - File loading + * - Video playback + */ #ifndef __ENGINE_H__ #define __ENGINE_H__ //offset 0 //pCelBuff->pFrameTable[0] -extern char gbPixelCol; // automap pixel color 8-bit (palette entry) -extern BOOL gbRotateMap; // flip - if y < x +/** automap pixel color 8-bit (palette entry) */ +extern char gbPixelCol; +/** flip - if y < x */ +extern BOOL gbRotateMap; +/** Seed value before the most recent call to SetRndSeed() */ extern int orgseed; +/** Track number of calls to GetRndSeed() since last call to SetRndSeed() */ extern int SeedCount; -extern BOOL gbNotInView; // valid - if x/y are in bounds +/** valid - if x/y are in bounds */ +extern BOOL gbNotInView; __FINLINE BYTE *CelGetFrame(BYTE *pCelBuff, int nCel, int *nDataSize); diff --git a/Source/error.cpp b/Source/error.cpp index 1d96d370..2df97ac3 100644 --- a/Source/error.cpp +++ b/Source/error.cpp @@ -1,3 +1,8 @@ +/** + * @file error.cpp + * + * Implementation of in-game message functions. + */ #include "all.h" char msgtable[MAX_SEND_STR_LEN]; @@ -5,6 +10,7 @@ char msgdelay; char msgflag; char msgcnt; +/** Maps from error_id to error message. */ char *MsgStrings[44] = { "", "No automap available in town", diff --git a/Source/error.h b/Source/error.h index 4191582a..046307b8 100644 --- a/Source/error.h +++ b/Source/error.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file error.h + * + * Interface of in-game message functions. + */ #ifndef __ERROR_H__ #define __ERROR_H__ diff --git a/Source/fault.cpp b/Source/fault.cpp index 64d2f5d8..43e14f5e 100644 --- a/Source/fault.cpp +++ b/Source/fault.cpp @@ -1,3 +1,8 @@ +/** + * @file fault.cpp + * + * Implementation of exception logging functionality. + */ #include "all.h" LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter; diff --git a/Source/fault.h b/Source/fault.h index 0dc743cb..4ed85ea1 100644 --- a/Source/fault.h +++ b/Source/fault.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file fault.h + * + * Interface of exception logging functionality. + */ #ifndef __FAULT_H__ #define __FAULT_H__ diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index 7cf3db3c..2e385b0b 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -1,3 +1,8 @@ +/** + * @file gamemenu.cpp + * + * Implementation of the ingame menu functions. + */ #include "all.h" TMenuItem sgSingleMenu[6] = { diff --git a/Source/gamemenu.h b/Source/gamemenu.h index 634e17cf..a6ad2f1c 100644 --- a/Source/gamemenu.h +++ b/Source/gamemenu.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file gamemenu.h + * + * Interface of the ingame menu functions. + */ #ifndef __GAMEMENU_H__ #define __GAMEMENU_H__ diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index d78cd99f..c13c7676 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -1,3 +1,8 @@ +/** + * @file gmenu.cpp + * + * Implementation of the ingame navigation and interaction. + */ #include "all.h" BYTE *optbar_cel; @@ -13,6 +18,7 @@ BYTE *option_cel; BYTE *sgpLogo; int sgCurrentMenuIdx; +/** Maps from font index to bigtgold.cel frame number. */ const BYTE lfontframe[127] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -28,6 +34,7 @@ const BYTE lfontframe[127] = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 20, 0, 21, 0 }; +/* Maps from bigtgold.cel frame number to character width. */ const BYTE lfontkern[56] = { 18, 33, 21, 26, 28, 19, 19, 26, 25, 11, 12, 25, 19, 34, 28, 32, 20, 32, 28, 20, diff --git a/Source/gmenu.h b/Source/gmenu.h index b884a9a9..1d0490d3 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file gmenu.h + * + * Interface of the ingame navigation and interaction. + */ #ifndef __GMENU_H__ #define __GMENU_H__ diff --git a/Source/interfac.cpp b/Source/interfac.cpp index e3b3ebd1..be837929 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -5,7 +5,9 @@ void *sgpBackCel; int sgdwProgress; int progress_id; +/** The colour used for the progress bar as an index into the palette. */ const BYTE BarColor[3] = { 138, 43, 254 }; +/** The screen position of the top left corner of the progress bar. */ const int BarPos[3][2] = { { 53, 37 }, { 53, 421 }, { 53, 37 } }; void interface_msg_pump() diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 51b8edaa..adde0a7f 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -1,3 +1,8 @@ +/** + * @file lighting.cpp + * + * Implementation of light and vision. + */ #include "all.h" LightListStruct VisionList[MAXVISION]; @@ -401,9 +406,7 @@ char CrawlTable[2749] = { -18, -1, 18, -1, -18, 0, 18, 0 }; -/** - * pCrawlTable maps from circle radius to the X- and Y-coordinate deltas from the center of a circle. - */ +/** pCrawlTable maps from circle radius to the X- and Y-coordinate deltas from the center of a circle. */ char *pCrawlTable[19] = { CrawlTable, CrawlTable + 3, @@ -425,9 +428,7 @@ char *pCrawlTable[19] = { CrawlTable + 2187, CrawlTable + 2460 }; -/** - * vCrawlTable specifies the X- Y-coordinate offsets of lighting visions. - */ +/** vCrawlTable specifies the X- Y-coordinate offsets of lighting visions. */ BYTE vCrawlTable[23][30] = { { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0 }, { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1 }, @@ -453,31 +454,29 @@ BYTE vCrawlTable[23][30] = { { 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15 }, { 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15 } }; -BYTE byte_49463C[18][18] = /* unused */ - { - { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 } - }; +/** unused */ +BYTE byte_49463C[18][18] = { + { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 } +}; -/** - * RadiusAdj maps from vCrawlTable index to lighting vision radius adjustment. - */ +/** RadiusAdj maps from vCrawlTable index to lighting vision radius adjustment. */ BYTE RadiusAdj[23] = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0 }; void RotateRadius(int *x, int *y, int *dx, int *dy, int *lx, int *ly, int *bx, int *by) diff --git a/Source/lighting.h b/Source/lighting.h index 5b593423..ac4b1278 100644 --- a/Source/lighting.h +++ b/Source/lighting.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file lighting.h + * + * Interface of light and vision. + */ #ifndef __LIGHTING_H__ #define __LIGHTING_H__ diff --git a/Source/list.h b/Source/list.h index 154f9bec..7a2c35fc 100644 --- a/Source/list.h +++ b/Source/list.h @@ -1,4 +1,6 @@ -/* Intrusive double-linked list implementation, +/** + * @file list.h + * Intrusive double-linked list implementation, * based on https://github.com/webcoyote/coho/blob/master/Base/List.h */ @@ -7,22 +9,22 @@ #define OBJECT_NAME(obj) (((const char *)&typeid(obj)) + 8) /****************************************************************************** -* -* List definition macros -* -***/ + * + * List definition macros + * + ***/ -// Define a field within a structure that will be used to link it into a list +/** Define a field within a structure that will be used to link it into a list */ #define LIST_LINK(T) TLink template class TLink; /****************************************************************************** -* -* TList -* -***/ + * + * TList + * + ***/ //============================================================================= template @@ -159,10 +161,10 @@ void TList::UnlinkAll() } /****************************************************************************** -* -* TLink -* -***/ + * + * TLink + * + ***/ //============================================================================= template diff --git a/Source/logging.cpp b/Source/logging.cpp index c0ea8a7c..cffa639e 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -11,7 +11,9 @@ DWORD nNumberOfBytesToWrite; /* data */ +/** Has the log file not yet been created. */ BOOL log_not_created = TRUE; +/** Handle to the log file. */ HANDLE log_file = INVALID_HANDLE_VALUE; void __cdecl log_flush(BOOL force_close) diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index 1c66f703..d9eec335 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -6,6 +6,7 @@ char gszHero[16]; /* data */ +/** The active music track id for the main menu. */ int menu_music_track_id = TMUSIC_INTRO; void mainmenu_refresh_music() diff --git a/Source/misdat.cpp b/Source/misdat.cpp index 6449e655..49cc1034 100644 --- a/Source/misdat.cpp +++ b/Source/misdat.cpp @@ -1,5 +1,6 @@ #include "all.h" +/** Data related to each missile ID. */ MissileData missiledata[] = { // clang-format off // mName, mAddProc, mProc, mDraw, mType, mResist, mFileNum, miSFX, mlSFX; @@ -74,6 +75,7 @@ MissileData missiledata[] = { // clang-format on }; +/** Data related to each missile graphic ID. */ MisFileData misfiledata[] = { // clang-format off // mAnimName, mAnimFAmt, mName, mFlags, mAnimData[16], mAnimDelay[16], mAnimLen[16], mAnimWidth[16], mAnimWidth2[16] diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 96910d80..517b2ac2 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -9,7 +9,9 @@ ChainStruct chain[MAXMISSILES]; BOOL MissilePreFlag; int numchains; +/** Maps from direction to X-offset. */ int XDirAdd[8] = { 1, 0, -1, -1, -1, 0, 1, 1 }; +/** Maps from direction to Y-offset. */ int YDirAdd[8] = { 1, 1, 1, 0, -1, -1, -1, 0 }; void GetDamageAmt(int i, int *mind, int *maxd) diff --git a/Source/monster.cpp b/Source/monster.cpp index 924ba107..cf1e1ac9 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1,7 +1,12 @@ +/** + * @file monster.cpp + * + * Implementation of monster functionality, AI, actions, spawning, loading, etc. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" -// Tracks which missile files are already loaded +/** Tracks which missile files are already loaded */ int MissileFileFlag; // BUGFIX: replace monstkills[MAXMONSTERS] with monstkills[NUM_MTYPES]. @@ -54,7 +59,7 @@ int opposite[8] = { 4, 5, 6, 7, 0, 1, 2, 3 }; int offset_x[8] = { 1, 0, -1, -1, -1, 0, 1, 1 }; int offset_y[8] = { 1, 1, 1, 0, -1, -1, -1, 0 }; -/* unused */ +/** unused */ int rnd5[4] = { 5, 10, 15, 20 }; int rnd10[4] = { 10, 15, 20, 30 }; int rnd20[4] = { 20, 30, 40, 50 }; diff --git a/Source/monster.h b/Source/monster.h index 45d884df..881e4cab 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file monster.h + * + * Interface of monster functionality, AI, actions, spawning, loading, etc. + */ #ifndef __MONSTER_H__ #define __MONSTER_H__ @@ -174,7 +178,7 @@ extern int opposite[8]; extern int offset_x[8]; extern int offset_y[8]; -/* unused */ +/** unused */ extern int rnd5[4]; extern int rnd10[4]; extern int rnd20[4]; diff --git a/Source/movie.cpp b/Source/movie.cpp index 40c513c3..75fb4791 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -1,7 +1,9 @@ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" +/** Should the movie continue playing. */ BYTE movie_playing; +/** Should the movie play in a loop. */ BOOL loop_movie; void play_movie(char *pszMovie, BOOL user_can_close) diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 985eb25b..2bdcbfc6 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -4,8 +4,10 @@ DWORD sgdwMpqOffset; char mpq_buf[4096]; _HASHENTRY *sgpHashTbl; +/** Has the savegame-file been modified in memory. */ BOOL save_archive_modified; _BLOCKENTRY *sgpBlockTbl; +/** Is the savegame-file currently open. */ BOOLEAN save_archive_open; //note: 32872 = 32768 + 104 (sizeof(_FILEHEADER)) diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 4911067a..ec5d75bd 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -1,3 +1,8 @@ +/** + * @file nthread.cpp + * + * Implementation of functions for managing game ticks. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" diff --git a/Source/nthread.h b/Source/nthread.h index 84263e95..98b50121 100644 --- a/Source/nthread.h +++ b/Source/nthread.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file nthread.h + * + * Interface of functions for managing game ticks. + */ #ifndef __NTHREAD_H__ #define __NTHREAD_H__ diff --git a/Source/objects.cpp b/Source/objects.cpp index 07b3a32e..5f3c8126 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -52,7 +52,7 @@ char shrinemax[NUM_SHRINETYPE] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 }; -// 0 - sp+mp, 1 - sp only, 2 - mp only +/** 0 - sp+mp, 1 - sp only, 2 - mp only */ BYTE shrineavail[NUM_SHRINETYPE] = { 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, diff --git a/Source/pack.cpp b/Source/pack.cpp index 2ebe3946..931a1c0c 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -106,8 +106,14 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield) pPack->pManaShield = FALSE; } -// Note: last slot of item[MAXITEMS+1] used as temporary buffer -// find real name reference below, possibly [sizeof(item[])/sizeof(ItemStruct)] +/** + * Expand a PkItemStruct in to a ItemStruct + * + * Note: last slot of item[MAXITEMS+1] used as temporary buffer + * find real name reference below, possibly [sizeof(item[])/sizeof(ItemStruct)] + * @param is The source packed item + * @param id The distination item + */ static void UnPackItem(PkItemStruct *is, ItemStruct *id) { if (is->idx == 0xFFFF) { diff --git a/Source/path.cpp b/Source/path.cpp index d0dd05d7..0dda4826 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -1,30 +1,37 @@ +/** + * @file path.cpp + * + * Implementation of the path finding algorithms. + */ #include "all.h" -// preallocated nodes, search is terminated after 300 nodes are visited +/** Notes visisted by the path finding algorithm. */ PATHNODE path_nodes[MAXPATHNODES]; -// size of the pnode_tblptr stack +/** size of the pnode_tblptr stack */ int gdwCurPathStep; -// the number of in-use nodes in path_nodes +/** the number of in-use nodes in path_nodes */ int gdwCurNodes; -/* for reconstructing the path after the A* search is done. The longest +/** + * for reconstructing the path after the A* search is done. The longest * possible path is actually 24 steps, even though we can fit 25 */ int pnode_vals[MAX_PATH_LENGTH]; -// a linked list of all visited nodes +/** A linked list of all visited nodes */ PATHNODE *pnode_ptr; -// a stack for recursively searching nodes +/** A stack for recursively searching nodes */ PATHNODE *pnode_tblptr[MAXPATHNODES]; -// a linked list of the A* frontier, sorted by distance +/** A linked list of the A* frontier, sorted by distance */ PATHNODE *path_2_nodes; PATHNODE path_unusednodes[MAXPATHNODES]; -// for iterating over the 8 possible movement directions +/** For iterating over the 8 possible movement directions */ const char pathxdir[8] = { -1, -1, 1, 1, -1, 0, 1, 0 }; const char pathydir[8] = { -1, 1, -1, 1, 0, -1, 0, 1 }; /* data */ -/* each step direction is assigned a number like this: +/** + * each step direction is assigned a number like this: * dx * -1 0 1 * +----- diff --git a/Source/path.h b/Source/path.h index ff333084..83191d34 100644 --- a/Source/path.h +++ b/Source/path.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file path.h + * + * Interface of the path finding algorithms. + */ #ifndef __PATH_H__ #define __PATH_H__ diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 9fea06a5..d6ac5fa0 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -10,6 +10,7 @@ #define PASSWORD_MULTI "szqnlsk1" #endif +/** List of character names for the character selection screen. */ static char hero_names[MAX_CHARACTERS][PLR_NAME_LEN]; BOOL gbValidSaveFile; diff --git a/Source/player.cpp b/Source/player.cpp index bef128d7..c4913c3f 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -42,7 +42,7 @@ int PWVel[3][3] = { { 2048, 1024, 512 }, { 2048, 1024, 512 } }; -// Total number of frames in walk animation. +/** Total number of frames in walk animation. */ int AnimLenFromClass[3] = { 8, 8, 8 }; diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index c5b85113..d745df86 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -3,6 +3,7 @@ static BYTE plr_msg_slot; _plrmsg plr_msgs[PMSG_COUNT]; +/** Maps from player_num to text colour, as used in chat messages. */ const char text_color_from_player_num[MAX_PLRS + 1] = { COL_WHITE, COL_WHITE, COL_WHITE, COL_WHITE, COL_GOLD }; void plrmsg_delay(BOOL delay) diff --git a/Source/portal.cpp b/Source/portal.cpp index 038c33d8..88df7ac7 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -1,9 +1,13 @@ #include "all.h" +/** In-game state of portals. */ PortalStruct portal[MAXPORTAL]; +/** Current portal number (a portal array index). */ int portalindex; +/** X-coordinate of each players portal in town. */ int WarpDropX[MAXPORTAL] = { 57, 59, 61, 63 }; +/** Y-coordinate of each players portal in town. */ int WarpDropY[MAXPORTAL] = { 40, 40, 40, 40 }; void InitPortals() diff --git a/Source/render.cpp b/Source/render.cpp index 39a22cb3..7d1327f9 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -84,7 +84,7 @@ int WorldTbl3x16[48] = { 60, 60, 60 }; -// slope/angle tables, left and right +/** slope/angle tables, left and right */ int WorldTbl17_1[17] = { 0, 4, 8, 16, 24, 36, 48, 64, 80, 100, 120, 144, 168, 196, 224, 256, 288 }; int WorldTbl17_2[17] = { 0, 32, 60, 88, 112, 136, 156, 176, 192, 208, 220, 232, 240, 248, 252, 256, 288 }; diff --git a/Source/setmaps.cpp b/Source/setmaps.cpp index 51b0a345..3a0b8735 100644 --- a/Source/setmaps.cpp +++ b/Source/setmaps.cpp @@ -54,6 +54,7 @@ BYTE SkelChamTrans3[36] = { 50, 43, 59, 51 }; +/** Maps from quest level to quest level names. */ char *quest_level_names[] = { "", "Skeleton King's Lair", diff --git a/Source/spelldat.cpp b/Source/spelldat.cpp index 8337d598..ce198eaf 100644 --- a/Source/spelldat.cpp +++ b/Source/spelldat.cpp @@ -1,5 +1,6 @@ #include "all.h" +/** Data related to each spell ID. */ 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 diff --git a/Source/stores.cpp b/Source/stores.cpp index 61d3dd7d..5bb86f53 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -60,6 +60,7 @@ int SStringY[24] = { 264, 276 }; +/** Maps from towner IDs to NPC names. */ char *talkname[9] = { "Griswold", "Pepin", diff --git a/Source/textdat.cpp b/Source/textdat.cpp index b3432759..dbf7898a 100644 --- a/Source/textdat.cpp +++ b/Source/textdat.cpp @@ -784,4 +784,5 @@ const TextDataStruct alltext[] = { { "Thank goodness you've returned!\nMuch has changed since you lived here, my friend. All was peaceful until the dark riders came and destroyed our village. Many were cut down where they stood, and those who took up arms were slain or dragged away to become slaves - or worse. The church at the edge of town has been desecrated and is being used for dark rituals. The screams that echo in the night are inhuman, but some of our townsfolk may yet survive. Follow the path that lies between my tavern and the blacksmith shop to find the church and save who you can. \n \nPerhaps I can tell you more if we speak again. Good luck.|", 1, 5, TSFX_TAVERN0 } }; -const DWORD gdwAllTextEntries = 259; /* unused */ +/** unused */ +const DWORD gdwAllTextEntries = 259; diff --git a/Source/themes.cpp b/Source/themes.cpp index 4c9a8ddd..4ebbf3b5 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -1,3 +1,8 @@ +/** + * @file themes.cpp + * + * Implementation of the theme room placing algorithms. + */ #include "all.h" int numthemes; @@ -451,7 +456,9 @@ void InitThemes() } } -// HoldThemeRooms marks theme rooms as populated. +/** + * @brief HoldThemeRooms marks theme rooms as populated. + */ void HoldThemeRooms() { int i, x, y; @@ -475,11 +482,12 @@ void HoldThemeRooms() } } -// PlaceThemeMonsts places theme monsters with the specified frequency. -// -// Parameters: -// - t: theme number (index into themes array). -// - f: frequency (1/f likelihood of adding monster). +/** + * PlaceThemeMonsts places theme monsters with the specified frequency. + * + * @param t theme number (index into themes array). + * @param f frequency (1/f likelihood of adding monster). + */ void PlaceThemeMonsts(int t, int f) { int xp, yp; @@ -505,10 +513,11 @@ void PlaceThemeMonsts(int t, int f) } } -// Theme_Barrel initializes the barrel theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Barrel initializes the barrel theme. + * + * @param t theme number (index into themes array). + */ void Theme_Barrel(int t) { int xp, yp, r; @@ -532,10 +541,11 @@ void Theme_Barrel(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_Shrine initializes the shrine theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Shrine initializes the shrine theme. + * + * @param t theme number (index into themes array). + */ void Theme_Shrine(int t) { char monstrnd[4] = { 6, 6, 3, 9 }; @@ -553,10 +563,11 @@ void Theme_Shrine(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_MonstPit initializes the monster pit theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_MonstPit initializes the monster pit theme. + * + * @param t theme number (index into themes array). + */ void Theme_MonstPit(int t) { int r; @@ -589,10 +600,11 @@ void Theme_MonstPit(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_SkelRoom initializes the skeleton room theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_SkelRoom initializes the skeleton room theme. + * + * @param t theme number (index into themes array). + */ void Theme_SkelRoom(int t) { int xp, yp, i; @@ -658,10 +670,11 @@ void Theme_SkelRoom(int t) } } -// Theme_Treasure initializes the treasure theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Treasure initializes the treasure theme. + * + * @param t theme number (index into themes array). + */ void Theme_Treasure(int t) { int xp, yp; @@ -695,10 +708,11 @@ void Theme_Treasure(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_Library initializes the library theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Library initializes the library theme. + * + * @param t theme number (index into themes array). + */ void Theme_Library(int t) { int xp, yp, oi; @@ -740,10 +754,11 @@ void Theme_Library(int t) } } -// Theme_Torture initializes the torture theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Torture initializes the torture theme. + * + * @param t theme number (index into themes array). + */ void Theme_Torture(int t) { int xp, yp; @@ -764,10 +779,10 @@ void Theme_Torture(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_BloodFountain initializes the blood fountain theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_BloodFountain initializes the blood fountain theme. + * @param t Theme number (index into themes array). + */ void Theme_BloodFountain(int t) { char monstrnd[4] = { 6, 8, 3, 9 }; @@ -777,10 +792,11 @@ void Theme_BloodFountain(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_Decap initializes the decapitated theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Decap initializes the decapitated theme. + * + * @param t theme number (index into themes array). + */ void Theme_Decap(int t) { int xp, yp; @@ -801,10 +817,11 @@ void Theme_Decap(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_PurifyingFountain initializes the purifying fountain theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_PurifyingFountain initializes the purifying fountain theme. + * + * @param t theme number (index into themes array). + */ void Theme_PurifyingFountain(int t) { char monstrnd[4] = { 6, 7, 3, 9 }; @@ -814,10 +831,11 @@ void Theme_PurifyingFountain(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_ArmorStand initializes the armor stand theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_ArmorStand initializes the armor stand theme. + * + * @param t theme number (index into themes array). + */ void Theme_ArmorStand(int t) { int xp, yp; @@ -843,10 +861,11 @@ void Theme_ArmorStand(int t) armorFlag = FALSE; } -// Theme_GoatShrine initializes the goat shrine theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_GoatShrine initializes the goat shrine theme. + * + * @param t theme number (index into themes array). + */ void Theme_GoatShrine(int t) { int xx, yy; @@ -862,10 +881,11 @@ void Theme_GoatShrine(int t) } } -// Theme_Cauldron initializes the cauldron theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Cauldron initializes the cauldron theme. + * + * @param t theme number (index into themes array). + */ void Theme_Cauldron(int t) { char monstrnd[4] = { 6, 7, 3, 9 }; @@ -875,10 +895,11 @@ void Theme_Cauldron(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_MurkyFountain initializes the murky fountain theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_MurkyFountain initializes the murky fountain theme. + * + * @param t theme number (index into themes array). + */ void Theme_MurkyFountain(int t) { char monstrnd[4] = { 6, 7, 3, 9 }; @@ -888,10 +909,11 @@ void Theme_MurkyFountain(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_TearFountain initializes the tear fountain theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_TearFountain initializes the tear fountain theme. + * + * @param t theme number (index into themes array). + */ void Theme_TearFountain(int t) { char monstrnd[4] = { 6, 7, 3, 9 }; @@ -901,10 +923,11 @@ void Theme_TearFountain(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_BrnCross initializes the burning cross theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_BrnCross initializes the burning cross theme. + * + * @param t theme number (index into themes array). + */ void Theme_BrnCross(int t) { int xp, yp; @@ -926,10 +949,11 @@ void Theme_BrnCross(int t) bCrossFlag = TRUE; } -// Theme_WeaponRack initializes the weapon rack theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_WeaponRack initializes the weapon rack theme. + * + * @param t theme number (index into themes array). + */ void Theme_WeaponRack(int t) { int xp, yp; @@ -955,7 +979,9 @@ void Theme_WeaponRack(int t) weaponFlag = FALSE; } -// UpdateL4Trans sets each value of the transparency map to 1. +/** + * UpdateL4Trans sets each value of the transparency map to 1. + */ void UpdateL4Trans() { int i, j; @@ -969,7 +995,9 @@ void UpdateL4Trans() } } -// CreateThemeRooms adds thematic elements to rooms. +/** + * CreateThemeRooms adds thematic elements to rooms. + */ void CreateThemeRooms() { int i; diff --git a/Source/themes.h b/Source/themes.h index 5ee91827..35c4cb08 100644 --- a/Source/themes.h +++ b/Source/themes.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file themes.h + * + * Interface of the theme room placing algorithms. + */ #ifndef __THEMES_H__ #define __THEMES_H__ diff --git a/Source/towners.cpp b/Source/towners.cpp index 09782e23..103271ef 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -4,7 +4,8 @@ BOOL storeflag; int sgnCowMsg; int numtowners; DWORD sgdwCowClicks; -BOOL bannerflag; // unused 0x6AAC28 +/** unused 0x6AAC28 */ +BOOL bannerflag; BOOL boyloadflag; BYTE *pCowCels; TownerStruct towner[16]; diff --git a/defs.h b/defs.h index 20c09ac7..505eb4bf 100644 --- a/defs.h +++ b/defs.h @@ -1,4 +1,8 @@ -// some global definitions, found in debug release +/** + * @file defs.h + * + * Global definitions and Macros. + */ #define GAME_NAME "DIABLO" diff --git a/doxygen.config b/doxygen.config new file mode 100644 index 00000000..47dd195f --- /dev/null +++ b/doxygen.config @@ -0,0 +1,34 @@ +PROJECT_NAME = "Devilution" +PROJECT_BRIEF = "Diablo devolved - magic behind the 1996 computer game" +OUTPUT_DIRECTORY = docs +INPUT = ./ ./Source +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.c \ + *.cpp \ + *.h \ + *.inc +GENERATE_LATEX = NO + +# Call graphces alows logical navigation of the docs +CALL_GRAPH = YES +CALLER_GRAPH = YES + +# all.h includes everything and everything inclues it so the graph is usless past depth 1 +MAX_DOT_GRAPH_DEPTH = 1 + +SOURCE_BROWSER = YES +EXTRACT_STATIC = YES +JAVADOC_AUTOBRIEF = YES +OPTIMIZE_OUTPUT_FOR_C = YES + +HTML_COLORSTYLE_HUE = 0 +HTML_COLORSTYLE_SAT = 125 +HTML_COLORSTYLE_GAMMA = 200 +HTML_DYNAMIC_SECTIONS = YES + +DOT_IMAGE_FORMAT = svg +INTERACTIVE_SVG = YES + +# Not all files are documented yet +EXTRACT_ALL = YES + From d6f70c56cebd53b1526a4fe181b72879f38b7846 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 1 Mar 2020 22:46:44 +0100 Subject: [PATCH 26/38] Format files --- Source/all.h | 182 ++++++++++++++++++++++----------------------- Source/control.cpp | 2 + Source/objdat.cpp | 2 +- Source/path.cpp | 3 +- Source/player.cpp | 2 +- resource.h | 2 +- structs.h | 40 +++++----- 7 files changed, 117 insertions(+), 116 deletions(-) diff --git a/Source/all.h b/Source/all.h index 75e22931..24693dba 100644 --- a/Source/all.h +++ b/Source/all.h @@ -1,91 +1,91 @@ -/** - * @file all.h - * - * Include all aplication headers. - */ -#ifndef __ALL_H__ -#define __ALL_H__ - -#include "../types.h" - -#ifdef __cplusplus -extern "C" { -#endif -#include "appfat.h" -#include "automap.h" -#include "capture.h" -#include "codec.h" -#include "control.h" -#include "cursor.h" -#include "dead.h" -#include "debug.h" -#include "diablo.h" -#include "doom.h" -#include "drlg_l1.h" -#include "drlg_l2.h" -#include "drlg_l3.h" -#include "drlg_l4.h" -#include "dthread.h" -#include "dx.h" -#include "effects.h" -#include "encrypt.h" -#include "engine.h" -#include "error.h" -#include "fault.h" -#include "gamemenu.h" -#include "gendung.h" -#include "gmenu.h" -#include "help.h" -#include "init.h" -#include "interfac.h" -#include "inv.h" -#include "itemdat.h" -#include "items.h" -#include "lighting.h" -#include "loadsave.h" -#include "logging.h" -#include "mainmenu.h" -#include "minitext.h" -#include "misdat.h" -#include "missiles.h" -#include "monstdat.h" -#include "monster.h" -#include "movie.h" -#include "mpqapi.h" -#include "msg.h" -#include "msgcmd.h" -#include "multi.h" -#include "nthread.h" -#include "objdat.h" -#include "objects.h" -#include "pack.h" -#include "palette.h" -#include "path.h" -#include "pfile.h" -#include "player.h" -#include "plrmsg.h" -#include "portal.h" -#include "quests.h" -#include "restrict.h" -#include "scrollrt.h" -#include "setmaps.h" -#include "sha.h" -#include "sound.h" -#include "spelldat.h" -#include "spells.h" -#include "stores.h" -#include "sync.h" -#include "textdat.h" // check file name -#include "themes.h" -#include "tmsg.h" -#include "town.h" -#include "towners.h" -#include "track.h" -#include "trigs.h" -#include "wave.h" -#include "render.h" // linked last, likely .s/.asm -#ifdef __cplusplus -} -#endif - -#endif /* __ALL_H__ */ +/** + * @file all.h + * + * Include all aplication headers. + */ +#ifndef __ALL_H__ +#define __ALL_H__ + +#include "../types.h" + +#ifdef __cplusplus +extern "C" { +#endif +#include "appfat.h" +#include "automap.h" +#include "capture.h" +#include "codec.h" +#include "control.h" +#include "cursor.h" +#include "dead.h" +#include "debug.h" +#include "diablo.h" +#include "doom.h" +#include "drlg_l1.h" +#include "drlg_l2.h" +#include "drlg_l3.h" +#include "drlg_l4.h" +#include "dthread.h" +#include "dx.h" +#include "effects.h" +#include "encrypt.h" +#include "engine.h" +#include "error.h" +#include "fault.h" +#include "gamemenu.h" +#include "gendung.h" +#include "gmenu.h" +#include "help.h" +#include "init.h" +#include "interfac.h" +#include "inv.h" +#include "itemdat.h" +#include "items.h" +#include "lighting.h" +#include "loadsave.h" +#include "logging.h" +#include "mainmenu.h" +#include "minitext.h" +#include "misdat.h" +#include "missiles.h" +#include "monstdat.h" +#include "monster.h" +#include "movie.h" +#include "mpqapi.h" +#include "msg.h" +#include "msgcmd.h" +#include "multi.h" +#include "nthread.h" +#include "objdat.h" +#include "objects.h" +#include "pack.h" +#include "palette.h" +#include "path.h" +#include "pfile.h" +#include "player.h" +#include "plrmsg.h" +#include "portal.h" +#include "quests.h" +#include "restrict.h" +#include "scrollrt.h" +#include "setmaps.h" +#include "sha.h" +#include "sound.h" +#include "spelldat.h" +#include "spells.h" +#include "stores.h" +#include "sync.h" +#include "textdat.h" // check file name +#include "themes.h" +#include "tmsg.h" +#include "town.h" +#include "towners.h" +#include "track.h" +#include "trigs.h" +#include "wave.h" +#include "render.h" // linked last, likely .s/.asm +#ifdef __cplusplus +} +#endif + +#endif /* __ALL_H__ */ diff --git a/Source/control.cpp b/Source/control.cpp index d612b2b3..01fce584 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -185,6 +185,7 @@ char SpellITbl[MAX_SPELLS] = { 30, }; int PanBtnPos[8][5] = { + // clang-format off { PANEL_LEFT + 9, PANEL_TOP + 9, 71, 19, 1 }, // char button { PANEL_LEFT + 9, PANEL_TOP + 35, 71, 19, 0 }, // quests button { PANEL_LEFT + 9, PANEL_TOP + 75, 71, 19, 1 }, // map button @@ -193,6 +194,7 @@ int PanBtnPos[8][5] = { { PANEL_LEFT + 560, PANEL_TOP + 35, 71, 19, 0 }, // spells button { PANEL_LEFT + 87, PANEL_TOP + 91, 33, 32, 1 }, // chat button { PANEL_LEFT + 527, PANEL_TOP + 91, 33, 32, 1 }, // friendly fire button + // clang-format on }; char *PanBtnHotKey[8] = { "'c'", "'q'", "Tab", "Esc", "'i'", "'b'", "Enter", NULL }; char *PanBtnStr[8] = { diff --git a/Source/objdat.cpp b/Source/objdat.cpp index e61f9c4f..070be9f6 100644 --- a/Source/objdat.cpp +++ b/Source/objdat.cpp @@ -1,4 +1,4 @@ -#include "all.h" +#include "all.h" int ObjTypeConv[113] = { 0, diff --git a/Source/path.cpp b/Source/path.cpp index 0dda4826..39906fe5 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -66,8 +66,7 @@ int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, // A* search until we find (dx,dy) or fail while ((next_node = GetNextPath())) { // reached the end, success! - if (next_node->x == dx && next_node->y == dy) - { + if (next_node->x == dx && next_node->y == dy) { current = next_node; path_length = 0; while (current->Parent) { diff --git a/Source/player.cpp b/Source/player.cpp index c4913c3f..c324b3a6 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3076,7 +3076,7 @@ void CheckNewPath(int pnum) plr[pnum].walkpath[i - 1] = plr[pnum].walkpath[i]; } - plr[pnum].walkpath[MAX_PATH_LENGTH-1] = WALK_NONE; + plr[pnum].walkpath[MAX_PATH_LENGTH - 1] = WALK_NONE; if (plr[pnum]._pmode == PM_STAND) { StartStand(pnum, plr[pnum]._pdir); diff --git a/resource.h b/resource.h index bcfe205a..c04cac6c 100644 --- a/resource.h +++ b/resource.h @@ -16,7 +16,7 @@ #define IDD_DIALOG11 114 // READONLY // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 103 diff --git a/structs.h b/structs.h index e100ab47..0a04b459 100644 --- a/structs.h +++ b/structs.h @@ -102,7 +102,7 @@ typedef struct ItemStruct { int _iAnimFrame; int _iAnimWidth; int _iAnimWidth2; // width 2? - BOOL _iDelFlag; // set when item is flagged for deletion, deprecated in 1.02 + BOOL _iDelFlag; // set when item is flagged for deletion, deprecated in 1.02 char _iSelFlag; BOOL _iPostDraw; BOOL _iIdentified; @@ -370,8 +370,8 @@ typedef struct TextDataStruct { typedef struct MissileData { unsigned char mName; - void(* mAddProc)(int, int, int, int, int, int, char, int, int); - void(* mProc)(int); + void (*mAddProc)(int, int, int, int, int, int, char, int, int); + void (*mProc)(int); BOOL mDraw; unsigned char mType; unsigned char mResist; @@ -1002,7 +1002,7 @@ typedef struct QuestData { typedef struct TMenuItem { DWORD dwFlags; char *pszStr; - void(* fnMenu)(BOOL); /* fix, should have one arg */ + void (*fnMenu)(BOOL); /* fix, should have one arg */ } TMenuItem; // TPDEF PTR FCN VOID TMenuUpdateFcn @@ -1314,21 +1314,21 @@ typedef struct _SNETUIDATA { int size; int uiflags; HWND parentwindow; - void(* artcallback)(); - void(* authcallback)(); - void(* createcallback)(); - void(* drawdesccallback)(); - void(* selectedcallback)(); - void(* messageboxcallback)(); - void(* soundcallback)(); - void(* statuscallback)(); - void(* getdatacallback)(); - void(* categorycallback)(); - void(* categorylistcallback)(); - void(* newaccountcallback)(); - void(* profilecallback)(); + void (*artcallback)(); + void (*authcallback)(); + void (*createcallback)(); + void (*drawdesccallback)(); + void (*selectedcallback)(); + void (*messageboxcallback)(); + void (*soundcallback)(); + void (*statuscallback)(); + void (*getdatacallback)(); + void (*categorycallback)(); + void (*categorylistcallback)(); + void (*newaccountcallback)(); + void (*profilecallback)(); const char **profilefields; - void(* profilebitmapcallback)(); + void (*profilebitmapcallback)(); int(__stdcall *selectnamecallback)( const struct _SNETPROGRAMDATA *, const struct _SNETPLAYERDATA *, @@ -1338,8 +1338,8 @@ typedef struct _SNETUIDATA { char *, DWORD, /* character name will be copied here */ char *, DWORD, /* character "description" will be copied here (used to advertise games) */ BOOL * /* new character? - unsure about this */ - ); - void(* changenamecallback)(); + ); + void (*changenamecallback)(); } _SNETUIDATA; typedef struct _SNETVERSIONDATA { From 68a8f07d2bf95a60d97e52177a84fe8cf641ac62 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sun, 1 Mar 2020 23:33:28 +0100 Subject: [PATCH 27/38] Document BUG in SetupAllItems when recreating unique items. --- Source/items.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index 230da042..8b64bffc 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -2078,8 +2078,13 @@ void SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood, if (item[ii]._iMagical != ITEM_QUALITY_UNIQUE) ItemRndDur(ii); } else { - if (item[ii]._iLoc != ILOC_UNEQUIPABLE) - GetUniqueItem(ii, iseed); + if (item[ii]._iLoc != ILOC_UNEQUIPABLE) { + //uid = CheckUnique(ii, iblvl, uper, recreate); + //if (uid != UITYPE_INVALID) { + // GetUniqueItem(ii, uid); + //} + GetUniqueItem(ii, iseed); // BUG: the second argument to GetUniqueItem should be uid. + } } SetupItem(ii); } From 0383f9abcdad3997012bbf4f5f73a31a8edcf093 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 2 Mar 2020 01:18:06 +0100 Subject: [PATCH 28/38] Add documentation to more files --- Source/automap.cpp | 2 +- Source/automap.h | 2 +- Source/gamemenu.cpp | 2 +- Source/gamemenu.h | 2 +- Source/gendung.cpp | 5 +++++ Source/gendung.h | 6 +++++- Source/gmenu.cpp | 2 +- Source/gmenu.h | 2 +- Source/help.cpp | 5 +++++ Source/help.h | 6 +++++- Source/init.cpp | 5 +++++ Source/init.h | 6 +++++- Source/interfac.cpp | 5 +++++ Source/interfac.h | 6 +++++- Source/inv.cpp | 5 +++++ Source/inv.h | 6 +++++- Source/itemdat.cpp | 5 +++++ Source/itemdat.h | 6 +++++- Source/items.cpp | 5 +++++ Source/items.h | 6 +++++- Source/loadsave.cpp | 5 +++++ Source/loadsave.h | 6 +++++- Source/logging.cpp | 5 +++++ Source/logging.h | 6 +++++- Source/mainmenu.cpp | 5 +++++ Source/mainmenu.h | 6 +++++- Source/minitext.cpp | 5 +++++ Source/minitext.h | 6 +++++- Source/misdat.cpp | 5 +++++ Source/misdat.h | 6 +++++- Source/missiles.cpp | 5 +++++ Source/missiles.h | 6 +++++- Source/monstdat.cpp | 5 +++++ Source/monstdat.h | 6 +++++- Source/movie.cpp | 5 +++++ Source/movie.h | 6 +++++- Source/mpqapi.cpp | 5 +++++ Source/mpqapi.h | 6 +++++- Source/msg.cpp | 5 +++++ Source/msg.h | 6 +++++- Source/msgcmd.cpp | 7 +++++++ Source/msgcmd.h | 8 +++++++- Source/multi.cpp | 5 +++++ Source/multi.h | 6 +++++- Source/player.cpp | 4 ++-- doxygen.config | 31 ++++++++++++++++--------------- enums.h | 6 ++++++ resource.h | 11 +++++++---- structs.h | 6 ++++++ types.h | 7 +++++-- 50 files changed, 242 insertions(+), 48 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index 6f64b069..d94d87bb 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -1,7 +1,7 @@ /** * @file automap.cpp * - * Implementation of the ingame map overlay. + * Implementation of the in-game map overlay. */ #include "all.h" diff --git a/Source/automap.h b/Source/automap.h index 22ccfaa7..219b0e74 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -1,7 +1,7 @@ /** * @file automap.h * - * Interface of the ingame map overlay. + * Interface of the in-game map overlay. */ #ifndef __AUTOMAP_H__ #define __AUTOMAP_H__ diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index 2e385b0b..16a14434 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -1,7 +1,7 @@ /** * @file gamemenu.cpp * - * Implementation of the ingame menu functions. + * Implementation of the in-game menu functions. */ #include "all.h" diff --git a/Source/gamemenu.h b/Source/gamemenu.h index a6ad2f1c..55ca4c40 100644 --- a/Source/gamemenu.h +++ b/Source/gamemenu.h @@ -1,7 +1,7 @@ /** * @file gamemenu.h * - * Interface of the ingame menu functions. + * Interface of the in-game menu functions. */ #ifndef __GAMEMENU_H__ #define __GAMEMENU_H__ diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 9061e1f9..2f321f70 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -1,3 +1,8 @@ +/** + * @file gendung.cpp + * + * Implementation of general dungeon generation code. + */ #include "all.h" WORD level_frame_types[MAXTILES]; diff --git a/Source/gendung.h b/Source/gendung.h index b423c2ab..a32db1f5 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file gendung.h + * + * Interface of general dungeon generation code. + */ #ifndef __GENDUNG_H__ #define __GENDUNG_H__ diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index c13c7676..3ba56654 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -1,7 +1,7 @@ /** * @file gmenu.cpp * - * Implementation of the ingame navigation and interaction. + * Implementation of the in-game navigation and interaction. */ #include "all.h" diff --git a/Source/gmenu.h b/Source/gmenu.h index 1d0490d3..8cdb3878 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -1,7 +1,7 @@ /** * @file gmenu.h * - * Interface of the ingame navigation and interaction. + * Interface of the in-game navigation and interaction. */ #ifndef __GMENU_H__ #define __GMENU_H__ diff --git a/Source/help.cpp b/Source/help.cpp index 69b166bf..60f5ca4e 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -1,3 +1,8 @@ +/** + * @file help.cpp + * + * Implementation of the in-game help text. + */ #include "all.h" int help_select_line; diff --git a/Source/help.h b/Source/help.h index cb536b9b..52fb3bf3 100644 --- a/Source/help.h +++ b/Source/help.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file help.h + * + * Interface of the in-game help text. + */ #ifndef __HELP_H__ #define __HELP_H__ diff --git a/Source/init.cpp b/Source/init.cpp index d57d9138..338374fb 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -1,3 +1,8 @@ +/** + * @file init.cpp + * + * Implementation of routines for initializing the environment, disable screen saver, load MPQ. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/init.h b/Source/init.h index 76809088..6867b23b 100644 --- a/Source/init.h +++ b/Source/init.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file init.h + * + * Interface of routines for initializing the environment, disable screen saver, load MPQ. + */ #ifndef __INIT_H__ #define __INIT_H__ diff --git a/Source/interfac.cpp b/Source/interfac.cpp index be837929..c5be1d43 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -1,3 +1,8 @@ +/** + * @file interfac.cpp + * + * Implementation of load screens. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" diff --git a/Source/interfac.h b/Source/interfac.h index 5049b2b1..a88a864e 100644 --- a/Source/interfac.h +++ b/Source/interfac.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file interfac.h + * + * Interface of load screens. + */ #ifndef __INTERFAC_H__ #define __INTERFAC_H__ diff --git a/Source/inv.cpp b/Source/inv.cpp index b867a154..a385832a 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1,3 +1,8 @@ +/** + * @file inv.cpp + * + * Implementation of player inventory. + */ #include "all.h" BOOL invflag; diff --git a/Source/inv.h b/Source/inv.h index 0ef9c39c..f236172c 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file inv.h + * + * Interface of player inventory. + */ #ifndef __INV_H__ #define __INV_H__ diff --git a/Source/itemdat.cpp b/Source/itemdat.cpp index 887ab8b7..ee9c1433 100644 --- a/Source/itemdat.cpp +++ b/Source/itemdat.cpp @@ -1,3 +1,8 @@ +/** + * @file itemdat.cpp + * + * Implementation of all item data. + */ #include "all.h" ItemDataStruct AllItemsList[] = { diff --git a/Source/itemdat.h b/Source/itemdat.h index e84ce0c9..7d038985 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file itemdat.h + * + * Interface of all item data. + */ #ifndef __ITEMDAT_H__ #define __ITEMDAT_H__ diff --git a/Source/items.cpp b/Source/items.cpp index 230da042..da10da3d 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1,3 +1,8 @@ +/** + * @file items.cpp + * + * Implementation of item functionality. + */ #include "all.h" int itemactive[MAXITEMS]; diff --git a/Source/items.h b/Source/items.h index 4440b0e8..729761e9 100644 --- a/Source/items.h +++ b/Source/items.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file items.h + * + * Interface of item functionality. + */ #ifndef __ITEMS_H__ #define __ITEMS_H__ diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index cbbf4ebc..a3dde56c 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -1,3 +1,8 @@ +/** + * @file loadsave.cpp + * + * Implementation of save game functionality. + */ #include "all.h" BYTE *tbuff; diff --git a/Source/loadsave.h b/Source/loadsave.h index 71309f5f..376d4af3 100644 --- a/Source/loadsave.h +++ b/Source/loadsave.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file loadsave.h + * + * Interface of save game functionality. + */ #ifndef __LOADSAVE_H__ #define __LOADSAVE_H__ diff --git a/Source/logging.cpp b/Source/logging.cpp index cffa639e..a3fb3043 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -1,3 +1,8 @@ +/** + * @file logging.cpp + * + * Implementation of logging functionality. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" diff --git a/Source/logging.h b/Source/logging.h index 13b0ec7c..b88d8e42 100644 --- a/Source/logging.h +++ b/Source/logging.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file logging.h + * + * Interface of logging functionality. + */ #ifndef __LOGGING_H__ #define __LOGGING_H__ diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index d9eec335..57b2f6a5 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -1,3 +1,8 @@ +/** + * @file mainmenu.cpp + * + * Implementation of functions for interacting with the main menu. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/mainmenu.h b/Source/mainmenu.h index c2bc0dd6..dc0ddb34 100644 --- a/Source/mainmenu.h +++ b/Source/mainmenu.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file mainmenu.h + * + * Interface of functions for interacting with the main menu. + */ #ifndef __MAINMENU_H__ #define __MAINMENU_H__ diff --git a/Source/minitext.cpp b/Source/minitext.cpp index 4ef780a1..c89d3125 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -1,3 +1,8 @@ +/** + * @file minitext.cpp + * + * Implementation of scrolling dialog text. + */ #include "all.h" int qtexty; diff --git a/Source/minitext.h b/Source/minitext.h index 3be2aeea..568e51b6 100644 --- a/Source/minitext.h +++ b/Source/minitext.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file minitext.h + * + * Interface of scrolling dialog text. + */ #ifndef __MINITEXT_H__ #define __MINITEXT_H__ diff --git a/Source/misdat.cpp b/Source/misdat.cpp index 49cc1034..7f222ae5 100644 --- a/Source/misdat.cpp +++ b/Source/misdat.cpp @@ -1,3 +1,8 @@ +/** + * @file misdat.cpp + * + * Implementation of data related to missiles. + */ #include "all.h" /** Data related to each missile ID. */ diff --git a/Source/misdat.h b/Source/misdat.h index d32f8173..bab38abd 100644 --- a/Source/misdat.h +++ b/Source/misdat.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file misdat.h + * + * Interface of data related to missiles. + */ #ifndef __MISDAT_H__ #define __MISDAT_H__ diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 517b2ac2..410ca94c 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -1,3 +1,8 @@ +/** + * @file missiles.cpp + * + * Implementation of missile functionality. + */ #include "all.h" int missileactive[MAXMISSILES]; diff --git a/Source/missiles.h b/Source/missiles.h index 64e45c1a..ddd67ec9 100644 --- a/Source/missiles.h +++ b/Source/missiles.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file missiles.h + * + * Interface of missile functionality. + */ #ifndef __MISSILES_H__ #define __MISSILES_H__ diff --git a/Source/monstdat.cpp b/Source/monstdat.cpp index c9bed996..cfb50b5c 100644 --- a/Source/monstdat.cpp +++ b/Source/monstdat.cpp @@ -1,3 +1,8 @@ +/** + * @file monstdat.cpp + * + * Implementation of all monster data. + */ #include "all.h" MonsterData monsterdata[] = { diff --git a/Source/monstdat.h b/Source/monstdat.h index 9d031269..2a4e845c 100644 --- a/Source/monstdat.h +++ b/Source/monstdat.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file monstdat.h + * + * Interface of all monster data. + */ #ifndef __MONSTDAT_H__ #define __MONSTDAT_H__ diff --git a/Source/movie.cpp b/Source/movie.cpp index 75fb4791..d9058671 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -1,3 +1,8 @@ +/** + * @file movie.cpp + * + * Implementation of video playback. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" diff --git a/Source/movie.h b/Source/movie.h index 03fcab32..f61ba789 100644 --- a/Source/movie.h +++ b/Source/movie.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file movie.h + * + * Interface of video playback. + */ #ifndef __MOVIE_H__ #define __MOVIE_H__ diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 2bdcbfc6..6c88bff4 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -1,3 +1,8 @@ +/** + * @file mpqapi.cpp + * + * Implementation of functions for creating and editing MPQ files. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" diff --git a/Source/mpqapi.h b/Source/mpqapi.h index 9afe8fe9..ff6e6112 100644 --- a/Source/mpqapi.h +++ b/Source/mpqapi.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file mpqapi.h + * + * Interface of functions for creating and editing MPQ files. + */ #ifndef __MPQAPI_H__ #define __MPQAPI_H__ diff --git a/Source/msg.cpp b/Source/msg.cpp index 7d2a27e6..c9415318 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1,3 +1,8 @@ +/** + * @file msg.cpp + * + * Implementation of function for sending and reciving network messages. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/msg.h b/Source/msg.h index 3b2123f4..81d58176 100644 --- a/Source/msg.h +++ b/Source/msg.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file msg.h + * + * Interface of function for sending and reciving network messages. + */ #ifndef __MSG_H__ #define __MSG_H__ diff --git a/Source/msgcmd.cpp b/Source/msgcmd.cpp index 26bd5bbb..6cba271a 100644 --- a/Source/msgcmd.cpp +++ b/Source/msgcmd.cpp @@ -1,3 +1,10 @@ +/** + * @file msgcmd.cpp + * + * Functions for sending commands to Battle.net. + * + * See http://classic.battle.net/info/commands.shtml for a list of commands. + */ #include // for placement new #include // for offsetof #include // for typeid diff --git a/Source/msgcmd.h b/Source/msgcmd.h index be57db0f..db3b451e 100644 --- a/Source/msgcmd.h +++ b/Source/msgcmd.h @@ -1,4 +1,10 @@ -//HEADER_GOES_HERE +/** + * @file msgcmd.h + * + * Interface for sending commands to Battle.net. + * + * See http://classic.battle.net/info/commands.shtml for a list of commands. + */ #ifndef __MSGCMD_H__ #define __MSGCMD_H__ diff --git a/Source/multi.cpp b/Source/multi.cpp index 75da357f..d03d8b06 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -1,3 +1,8 @@ +/** + * @file multi.cpp + * + * Implementation of functions for keeping multiplaye games in sync. + */ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/multi.h b/Source/multi.h index 08c10260..73cae280 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file multi.h + * + * Interface of functions for keeping multiplaye games in sync. + */ #ifndef __MULTI_H__ #define __MULTI_H__ diff --git a/Source/player.cpp b/Source/player.cpp index c324b3a6..befb421b 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -267,7 +267,7 @@ void InitPlrGFXMem(int pnum) if (GetPlrGFXSize("ST") > GetPlrGFXSize("AS")) { plr_sframe_size = GetPlrGFXSize("ST"); //TOWN } else { - plr_sframe_size = GetPlrGFXSize("AS"); //DUNGION + plr_sframe_size = GetPlrGFXSize("AS"); //DUNGEON } } plr[pnum]._pNData = DiabloAllocPtr(plr_sframe_size); @@ -277,7 +277,7 @@ void InitPlrGFXMem(int pnum) if (GetPlrGFXSize("WL") > GetPlrGFXSize("AW")) { plr_wframe_size = GetPlrGFXSize("WL"); //TOWN } else { - plr_wframe_size = GetPlrGFXSize("AW"); //DUNGION + plr_wframe_size = GetPlrGFXSize("AW"); //DUNGEON } } plr[pnum]._pWData = DiabloAllocPtr(plr_wframe_size); diff --git a/doxygen.config b/doxygen.config index 47dd195f..6e90f746 100644 --- a/doxygen.config +++ b/doxygen.config @@ -1,13 +1,27 @@ PROJECT_NAME = "Devilution" PROJECT_BRIEF = "Diablo devolved - magic behind the 1996 computer game" +USE_MDFILE_AS_MAINPAGE = README.md OUTPUT_DIRECTORY = docs -INPUT = ./ ./Source +INPUT = ./ ./Source ./docs INPUT_ENCODING = UTF-8 FILE_PATTERNS = *.c \ *.cpp \ *.h \ - *.inc + *.inc \ + *.md + GENERATE_LATEX = NO +WARNINGS = YES +SOURCE_BROWSER = YES +EXTRACT_STATIC = YES +JAVADOC_AUTOBRIEF = YES +OPTIMIZE_OUTPUT_FOR_C = YES +SEPARATE_MEMBER_PAGES = YES +DOT_IMAGE_FORMAT = svg +INTERACTIVE_SVG = YES +HTML_COLORSTYLE_HUE = 0 +HTML_COLORSTYLE_SAT = 125 +HTML_COLORSTYLE_GAMMA = 200 # Call graphces alows logical navigation of the docs CALL_GRAPH = YES @@ -16,19 +30,6 @@ CALLER_GRAPH = YES # all.h includes everything and everything inclues it so the graph is usless past depth 1 MAX_DOT_GRAPH_DEPTH = 1 -SOURCE_BROWSER = YES -EXTRACT_STATIC = YES -JAVADOC_AUTOBRIEF = YES -OPTIMIZE_OUTPUT_FOR_C = YES - -HTML_COLORSTYLE_HUE = 0 -HTML_COLORSTYLE_SAT = 125 -HTML_COLORSTYLE_GAMMA = 200 -HTML_DYNAMIC_SECTIONS = YES - -DOT_IMAGE_FORMAT = svg -INTERACTIVE_SVG = YES - # Not all files are documented yet EXTRACT_ALL = YES diff --git a/enums.h b/enums.h index f54f3f79..257cb532 100644 --- a/enums.h +++ b/enums.h @@ -1,3 +1,9 @@ +/** + * @file enums.h + * + * Various global enumerators. + */ + typedef enum item_quality { ITEM_QUALITY_NORMAL = 0, ITEM_QUALITY_MAGIC = 1, diff --git a/resource.h b/resource.h index c04cac6c..962c2838 100644 --- a/resource.h +++ b/resource.h @@ -1,7 +1,10 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by Diablo.rc -// +/** + * @file resource.h + * + * Microsoft Developer Studio generated include file. + * Used by Diablo.rc + */ + #define IDI_ICON1 101 #define IDD_DIALOG1 104 // DX #define IDD_DIALOG2 105 // NOMEMORY diff --git a/structs.h b/structs.h index 0a04b459..e80eccfd 100644 --- a/structs.h +++ b/structs.h @@ -1,3 +1,9 @@ +/** + * @file structs.h + * + * Various global structures. + */ + ////////////////////////////////////////////////// // control ////////////////////////////////////////////////// diff --git a/types.h b/types.h index 5b51454d..6553268d 100644 --- a/types.h +++ b/types.h @@ -1,5 +1,8 @@ -// temporary file - +/** + * @file types.h + * + * Include OS headers and set compiler state. + */ #ifndef _TYPES_H #define _TYPES_H From 3130ae35932c1e92a22d935aa0c090990fd450ae Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sun, 8 Mar 2020 14:50:34 +0100 Subject: [PATCH 29/38] codec: fix build error of codec.cpp when compiling as C Prior to this commit, the following error was encountered when compiling as C using Clang: Source/codec.cpp:20:2: error: must use 'struct' tag to refer to type 'CodecSignature' CodecSignature *sig; ^ struct --- Source/codec.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/codec.cpp b/Source/codec.cpp index 1e9402b7..04f81d0f 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -5,12 +5,12 @@ */ #include "all.h" -struct CodecSignature { +typedef struct CodecSignature { DWORD checksum; BYTE error; BYTE last_chunk_size; WORD unused; -}; +} CodecSignature; int codec_decode(BYTE *pbSrcDst, DWORD size, char *pszPassword) { From f6e6b4b56fbe87a13ff323f3c52cb3a3c66ac4cc Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sun, 8 Mar 2020 17:56:06 +0100 Subject: [PATCH 30/38] dthread: use INFINITE enum for second argument to WaitForSingleObject --- Source/dthread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/dthread.cpp b/Source/dthread.cpp index 6e3e9a0b..e283d19c 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -93,7 +93,7 @@ unsigned int __stdcall dthread_handler(void *) DWORD dwMilliseconds; while (dthread_running) { - if (!sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, 0xFFFFFFFF) == -1) { + if (!sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, INFINITE) == -1) { error_buf = TraceLastError(); app_fatal("dthread4:\n%s", error_buf); } @@ -140,7 +140,7 @@ void dthread_cleanup() dthread_running = FALSE; SetEvent(sghWorkToDoEvent); if (sghThread != INVALID_HANDLE_VALUE && glpDThreadId != GetCurrentThreadId()) { - if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) { + if (WaitForSingleObject(sghThread, INFINITE) == -1) { error_buf = TraceLastError(); app_fatal("dthread3:\n(%s)", error_buf); } From dce389599eda23db61994a95fc0f71d367fd278e Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sun, 8 Mar 2020 17:51:57 +0100 Subject: [PATCH 31/38] dthread: add parameter name to dthread_handler This fixes a build error in dthread_handler when compiling as C. Source/dthread.cpp:92:46: error: parameter name omitted unsigned int __stdcall dthread_handler(void *) ^ --- Source/dthread.cpp | 2 +- Source/dthread.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/dthread.cpp b/Source/dthread.cpp index 6e3e9a0b..d1d49f57 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -86,7 +86,7 @@ void dthread_start() } } -unsigned int __stdcall dthread_handler(void *) +unsigned int __stdcall dthread_handler(void *data) { char *error_buf; TMegaPkt *pkt; diff --git a/Source/dthread.h b/Source/dthread.h index 7a9e86c9..f4dc99c6 100644 --- a/Source/dthread.h +++ b/Source/dthread.h @@ -12,7 +12,7 @@ extern BOOLEAN dthread_running; void dthread_remove_player(int pnum); void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen); void dthread_start(); -unsigned int __stdcall dthread_handler(void *); +unsigned int __stdcall dthread_handler(void *data); void dthread_cleanup(); /* data */ From 038666db182b5b5a012c795bbad977b7d817c199 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Mon, 9 Mar 2020 00:24:52 +0100 Subject: [PATCH 32/38] nthread: add parameter name to nthread_handler Fixes the following error when compiling as C with Clang: Source/dthread.cpp:92:46: error: parameter name omitted unsigned int __stdcall dthread_handler(void *) ^ Related to #2017. --- Source/nthread.cpp | 2 +- Source/nthread.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/nthread.cpp b/Source/nthread.cpp index ec5d75bd..ad7d43b2 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -173,7 +173,7 @@ void nthread_start(BOOL set_turn_upper_bit) } } -unsigned int __stdcall nthread_handler(void *) +unsigned int __stdcall nthread_handler(void *data) { int delta; BOOL received; diff --git a/Source/nthread.h b/Source/nthread.h index 98b50121..bcd4a187 100644 --- a/Source/nthread.h +++ b/Source/nthread.h @@ -24,7 +24,7 @@ DWORD nthread_send_and_recv_turn(DWORD cur_turn, int turn_delta); BOOL nthread_recv_turns(BOOL *pfSendAsync); void nthread_set_turn_upper_bit(); void nthread_start(BOOL set_turn_upper_bit); -unsigned int __stdcall nthread_handler(void *); +unsigned int __stdcall nthread_handler(void *data); void nthread_cleanup(); void nthread_ignore_mutex(BOOL bStart); BOOL nthread_has_500ms_passed(BOOL unused); From 71565b9c028d5e58c4c41fd04102c648dfa1dd57 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 11 Mar 2020 21:27:40 -0500 Subject: [PATCH 33/38] Several updates [enums+names] (#2002) * Several updates * Correct msg_get_next_packet * Update enums.h Co-Authored-By: Robin Eklind Co-authored-by: Robin Eklind --- Source/diablo.cpp | 4 +- Source/drlg_l1.cpp | 14 +- Source/drlg_l2.cpp | 16 +- Source/drlg_l3.cpp | 6 +- Source/drlg_l4.cpp | 22 +- Source/inv.cpp | 24 +- Source/items.cpp | 16 +- Source/monstdat.cpp | 16 +- Source/monster.cpp | 148 +++++----- Source/msg.cpp | 10 +- Source/msg.h | 6 +- Source/multi.cpp | 2 +- Source/objects.cpp | 114 ++++---- Source/player.cpp | 6 +- Source/quests.cpp | 274 +++++++++--------- Source/setmaps.cpp | 18 +- Source/stores.cpp | 44 +-- Source/themes.cpp | 4 +- Source/town.cpp | 2 +- Source/towners.cpp | 270 ++++++++--------- Source/trigs.cpp | 10 +- comparer-config/diablo.toml | 4 +- comparer-config/spawn.toml | 4 +- enums.h | 562 ++++++++++++++++++------------------ 24 files changed, 800 insertions(+), 796 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index c764276d..ade09cc6 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -139,7 +139,7 @@ void run_game_loop(unsigned int uMsg) /// ASSERT: assert(ghMainWnd); saveProc = SetWindowProc(GM_Game); control_update_life_mana(); - msg_process_net_packets(); + run_delta_info(); gbRunGame = TRUE; gbProcessPlayers = TRUE; gbRunGameResult = TRUE; @@ -1815,7 +1815,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir) ; #ifndef SPAWN - if (setlevel && setlvlnum == SL_SKELKING && quests[QTYPE_KING]._qactive == 2) + if (setlevel && setlvlnum == SL_SKELKING && quests[Q_SKELKING]._qactive == QUEST_ACTIVE) PlaySFX(USFX_SKING1); #endif } diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 9aa56141..07f11519 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -355,8 +355,8 @@ static int DRLG_PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, in DRLG_MRectTrans(sx, sy + 2, sx + 5, sy + 4); TransVal = t; - quests[QTYPE_PW]._qtx = 2 * sx + 21; - quests[QTYPE_PW]._qty = 2 * sy + 22; + quests[Q_PWATER]._qtx = 2 * sx + 21; + quests[Q_PWATER]._qty = 2 * sy + 22; } if (setview == TRUE) { @@ -487,15 +487,15 @@ static void DRLG_L1Pass3() static void DRLG_LoadL1SP() { L5setloadflag = FALSE; - if (QuestStatus(QTYPE_BUTCH)) { + if (QuestStatus(Q_BUTCHER)) { L5pSetPiece = LoadFileInMem("Levels\\L1Data\\rnd6.DUN", NULL); L5setloadflag = TRUE; } - if (QuestStatus(QTYPE_KING) && gbMaxPlayers == 1) { + if (QuestStatus(Q_SKELKING) && gbMaxPlayers == 1) { L5pSetPiece = LoadFileInMem("Levels\\L1Data\\SKngDO.DUN", NULL); L5setloadflag = TRUE; } - if (QuestStatus(QTYPE_BOL)) { + if (QuestStatus(Q_LTBANNER)) { L5pSetPiece = LoadFileInMem("Levels\\L1Data\\Banner2.DUN", NULL); L5setloadflag = TRUE; } @@ -1658,7 +1658,7 @@ static void DRLG_L5(int entry) doneflag = TRUE; - if (QuestStatus(QTYPE_PW)) { + if (QuestStatus(Q_PWATER)) { if (entry == 0) { if (DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, 1, -1, 0) < 0) doneflag = FALSE; @@ -1668,7 +1668,7 @@ static void DRLG_L5(int entry) ViewY--; } } - if (QuestStatus(QTYPE_BOL)) { + if (QuestStatus(Q_LTBANNER)) { if (entry == 0) { if (DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, 1, -1, 0) < 0) doneflag = FALSE; diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index fc3ea922..a3721d55 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -470,13 +470,13 @@ static void DRLG_LoadL2SP() { setloadflag = FALSE; - if (QuestStatus(QTYPE_BLIND)) { + if (QuestStatus(Q_BLIND)) { pSetPiece = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", NULL); setloadflag = TRUE; - } else if (QuestStatus(QTYPE_BLOOD)) { + } else if (QuestStatus(Q_BLOOD)) { pSetPiece = LoadFileInMem("Levels\\L2Data\\Blood1.DUN", NULL); setloadflag = TRUE; - } else if (QuestStatus(QTYPE_BONE)) { + } else if (QuestStatus(Q_SCHAMB)) { pSetPiece = LoadFileInMem("Levels\\L2Data\\Bonestr2.DUN", NULL); setloadflag = TRUE; } @@ -1383,21 +1383,21 @@ static BOOL CreateDungeon() switch (currlevel) { case 5: - if (quests[QTYPE_BLOOD]._qactive) { + if (quests[Q_BLOOD]._qactive) { ForceHW = TRUE; ForceH = 20; ForceW = 14; } break; case 6: - if (quests[QTYPE_BONE]._qactive) { + if (quests[Q_SCHAMB]._qactive) { ForceHW = TRUE; ForceW = 10; ForceH = 10; } break; case 7: - if (quests[QTYPE_BLIND]._qactive) { + if (quests[Q_BLIND]._qactive) { ForceHW = TRUE; ForceW = 15; ForceH = 15; @@ -2123,13 +2123,13 @@ void LoadPreL2Dungeon(char *sFileName, int vx, int vy) void CreateL2Dungeon(DWORD rseed, int entry) { if (gbMaxPlayers == 1) { - if (currlevel == 7 && !quests[QTYPE_BLIND]._qactive) { + if (currlevel == 7 && !quests[Q_BLIND]._qactive) { currlevel = 6; CreateL2Dungeon(glSeedTbl[6], 4); currlevel = 7; } if (currlevel == 8) { - if (!quests[QTYPE_BLIND]._qactive) { + if (!quests[Q_BLIND]._qactive) { currlevel = 6; CreateL2Dungeon(glSeedTbl[6], 4); currlevel = 8; diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 3679c2e4..d5049f5e 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1508,7 +1508,7 @@ static void DRLG_L3(int entry) DRLG_L3CreateBlock(x2, y1, 2, 1); DRLG_L3CreateBlock(x1, y2, 2, 2); DRLG_L3CreateBlock(x1, y1, 2, 3); - if (QuestStatus(QTYPE_ANVIL)) { + if (QuestStatus(Q_ANVIL)) { x1 = random_(0, 10) + 10; y1 = random_(0, 10) + 10; x2 = x1 + 12; @@ -1554,7 +1554,7 @@ static void DRLG_L3(int entry) } } } - if (!genok && QuestStatus(QTYPE_ANVIL)) { + if (!genok && QuestStatus(Q_ANVIL)) { genok = DRLG_L3Anvil(); } } while (genok == TRUE); @@ -1573,7 +1573,7 @@ static void DRLG_L3(int entry) FixL3HallofHeroes(); DRLG_L3River(); - if (QuestStatus(QTYPE_ANVIL)) { + if (QuestStatus(Q_ANVIL)) { dungeon[setpc_x + 7][setpc_y + 5] = 7; dungeon[setpc_x + 8][setpc_y + 5] = 7; dungeon[setpc_x + 9][setpc_y + 5] = 7; diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index f97a0be4..8a0f6a5f 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -344,7 +344,7 @@ static void InitL4Dungeon() void DRLG_LoadL4SP() { setloadflag = FALSE; - if (QuestStatus(QTYPE_WARLRD)) { + if (QuestStatus(Q_WARLORD)) { pSetPiece = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", NULL); setloadflag = TRUE; } @@ -1323,11 +1323,11 @@ static void L4firstRoom() 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) { + if (currlevel == quests[Q_WARLORD]._qlevel && quests[Q_WARLORD]._qactive) { /// ASSERT: assert(gbMaxPlayers == 1); w = 11; h = 11; - } else if (currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { + } else if (currlevel == quests[Q_BETRAYER]._qlevel && gbMaxPlayers != 1) { w = 11; h = 11; } else { @@ -1362,7 +1362,7 @@ static void L4firstRoom() l4holdx = x; l4holdy = y; } - if (QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { + if (QuestStatus(Q_WARLORD) || currlevel == quests[Q_BETRAYER]._qlevel && gbMaxPlayers != 1) { SP4x1 = x + 1; SP4y1 = y + 1; SP4x2 = SP4x1 + w; @@ -1530,8 +1530,8 @@ static BOOL DRLG_L4PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, } if (currlevel == 15) { - quests[QTYPE_VB]._qtx = sx + 1; - quests[QTYPE_VB]._qty = sy + 1; + quests[Q_BETRAYER]._qtx = sx + 1; + quests[Q_BETRAYER]._qty = sy + 1; } if (setview == TRUE) { ViewX = 2 * sx + 21; @@ -1747,7 +1747,7 @@ static void DRLG_L4(int entry) if (currlevel == 16) { L4SaveQuads(); } - if (QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { + if (QuestStatus(Q_WARLORD) || currlevel == quests[Q_BETRAYER]._qlevel && gbMaxPlayers != 1) { for (spi = SP4x1; spi < SP4x2; spi++) { for (spj = SP4y1; spj < SP4y2; spj++) { dflags[spi][spj] = 1; @@ -1763,7 +1763,7 @@ static void DRLG_L4(int entry) if (currlevel == 16) { DRLG_LoadDiabQuads(TRUE); } - if (QuestStatus(QTYPE_WARLRD)) { + if (QuestStatus(Q_WARLORD)) { if (entry == 0) { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); if (doneflag && currlevel == 13) { @@ -1817,7 +1817,7 @@ static void DRLG_L4(int entry) if (entry == 0) { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); if (doneflag) { - if (gbMaxPlayers == 1 && quests[QTYPE_MOD]._qactive != 2) { + if (gbMaxPlayers == 1 && quests[Q_DIABLO]._qactive != QUEST_ACTIVE) { doneflag = DRLG_L4PlaceMiniSet(L4PENTA, 1, 1, -1, -1, 0, 1); } else { doneflag = DRLG_L4PlaceMiniSet(L4PENTA2, 1, 1, -1, -1, 0, 1); @@ -1827,7 +1827,7 @@ static void DRLG_L4(int entry) } else { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); if (doneflag) { - if (gbMaxPlayers == 1 && quests[QTYPE_MOD]._qactive != 2) { + if (gbMaxPlayers == 1 && quests[Q_DIABLO]._qactive != QUEST_ACTIVE) { doneflag = DRLG_L4PlaceMiniSet(L4PENTA, 1, 1, -1, -1, 1, 1); } else { doneflag = DRLG_L4PlaceMiniSet(L4PENTA2, 1, 1, -1, -1, 1, 1); @@ -1849,7 +1849,7 @@ static void DRLG_L4(int entry) DRLG_L4Subs(); DRLG_Init_Globals(); - if (QuestStatus(QTYPE_WARLRD)) { + if (QuestStatus(Q_WARLORD)) { for (j = 0; j < DMAXY; j++) { for (i = 0; i < DMAXX; i++) { pdungeon[i][j] = dungeon[i][j]; diff --git a/Source/inv.cpp b/Source/inv.cpp index a385832a..023e0ea2 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1406,8 +1406,8 @@ void CheckBookLevel(int pnum) void CheckQuestItem(int pnum) { if (plr[pnum].HoldItem.IDidx == IDI_OPTAMULET) - quests[QTYPE_BLIND]._qactive = 3; - if (plr[pnum].HoldItem.IDidx == IDI_MUSHROOM && quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qvar1 == QS_MUSHSPAWNED) { + quests[Q_BLIND]._qactive = QUEST_DONE; + if (plr[pnum].HoldItem.IDidx == IDI_MUSHROOM && quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE && quests[Q_MUSHROOM]._qvar1 == QS_MUSHSPAWNED) { #ifndef SPAWN sfxdelay = 10; if (plr[pnum]._pClass == PC_WARRIOR) { // BUGFIX: Voice for this quest might be wrong in MP @@ -1418,15 +1418,15 @@ void CheckQuestItem(int pnum) sfxdnum = PS_MAGE95; } #endif - quests[QTYPE_BLKM]._qvar1 = QS_MUSHPICKED; + quests[Q_MUSHROOM]._qvar1 = QS_MUSHPICKED; } if (plr[pnum].HoldItem.IDidx == IDI_ANVIL) { - if (quests[QTYPE_ANVIL]._qactive == 1) { - quests[QTYPE_ANVIL]._qactive = 2; - quests[QTYPE_ANVIL]._qvar1 = 1; + if (quests[Q_ANVIL]._qactive == QUEST_INIT) { + quests[Q_ANVIL]._qactive = QUEST_ACTIVE; + quests[Q_ANVIL]._qvar1 = 1; } #ifndef SPAWN - if (quests[QTYPE_ANVIL]._qlog == 1) { + if (quests[Q_ANVIL]._qlog == 1) { sfxdelay = 10; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR89; @@ -1451,12 +1451,12 @@ void CheckQuestItem(int pnum) } #endif if (plr[pnum].HoldItem.IDidx == IDI_ROCK) { - if (quests[QTYPE_INFRA]._qactive == 1) { - quests[QTYPE_INFRA]._qactive = 2; - quests[QTYPE_INFRA]._qvar1 = 1; + if (quests[Q_ROCK]._qactive == QUEST_INIT) { + quests[Q_ROCK]._qactive = QUEST_ACTIVE; + quests[Q_ROCK]._qvar1 = 1; } #ifndef SPAWN - if (quests[QTYPE_INFRA]._qlog == 1) { + if (quests[Q_ROCK]._qlog == 1) { sfxdelay = 10; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR87; @@ -1469,7 +1469,7 @@ void CheckQuestItem(int pnum) #endif } if (plr[pnum].HoldItem.IDidx == IDI_ARMOFVAL) { - quests[QTYPE_BLOOD]._qactive = 3; + quests[Q_BLOOD]._qactive = QUEST_DONE; #ifndef SPAWN sfxdelay = 20; if (plr[myplr]._pClass == PC_WARRIOR) { diff --git a/Source/items.cpp b/Source/items.cpp index 2232a904..c339265e 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -280,9 +280,9 @@ void InitItems() if (!setlevel) { s = GetRndSeed(); /* unused */ - if (QuestStatus(QTYPE_INFRA)) + if (QuestStatus(Q_ROCK)) SpawnRock(); - if (QuestStatus(QTYPE_ANVIL)) + if (QuestStatus(Q_ANVIL)) SpawnQuestItem(IDI_ANVIL, 2 * setpc_x + 27, 2 * setpc_y + 27, 0, 1); if (currlevel > 0 && currlevel < 16) AddInitItems(); @@ -1875,7 +1875,7 @@ int RndUItem(int m) okflag = FALSE; if (AllItemsList[i].itype == ITYPE_GOLD) okflag = FALSE; - if (AllItemsList[i].itype == ITYPE_0E) + if (AllItemsList[i].itype == ITYPE_MEAT) okflag = FALSE; if (AllItemsList[i].iMiscId == IMISC_BOOK) okflag = TRUE; @@ -2105,7 +2105,7 @@ void SpawnItem(int m, int x, int y, BOOL sendmsg) return; } onlygood = 1; - } else if (quests[QTYPE_BLKM]._qactive != 2 || quests[QTYPE_BLKM]._qvar1 != QS_MUSHGIVEN) { + } else if (quests[Q_MUSHROOM]._qactive != QUEST_ACTIVE || quests[Q_MUSHROOM]._qvar1 != QS_MUSHGIVEN) { idx = RndItem(m); if (!idx) return; @@ -2118,7 +2118,7 @@ void SpawnItem(int m, int x, int y, BOOL sendmsg) } } else { idx = IDI_BRAIN; - quests[QTYPE_BLKM]._qvar1 = QS_BRAINSPAWNED; + quests[Q_MUSHROOM]._qvar1 = QS_BRAINSPAWNED; } if (numitems < MAXITEMS) { @@ -3159,7 +3159,7 @@ void UseItem(int p, int Mid, int spl) switch (Mid) { case IMISC_HEAL: - case IMISC_HEAL_1C: + case IMISC_MEAT: j = plr[p]._pMaxHP >> 8; l = ((j >> 1) + random_(39, j)) << 6; if (plr[p]._pClass == PC_WARRIOR) @@ -3339,7 +3339,7 @@ BOOL SmithItemOk(int i) rv = FALSE; if (AllItemsList[i].itype == ITYPE_GOLD) rv = FALSE; - if (AllItemsList[i].itype == ITYPE_0E) + if (AllItemsList[i].itype == ITYPE_MEAT) rv = FALSE; if (AllItemsList[i].itype == ITYPE_STAFF) rv = FALSE; @@ -3435,7 +3435,7 @@ BOOL PremiumItemOk(int i) rv = FALSE; if (AllItemsList[i].itype == ITYPE_GOLD) rv = FALSE; - if (AllItemsList[i].itype == ITYPE_0E) + if (AllItemsList[i].itype == ITYPE_MEAT) rv = FALSE; if (AllItemsList[i].itype == ITYPE_STAFF) rv = FALSE; diff --git a/Source/monstdat.cpp b/Source/monstdat.cpp index cfb50b5c..7db551da 100644 --- a/Source/monstdat.cpp +++ b/Source/monstdat.cpp @@ -262,15 +262,15 @@ BYTE MonstAvailTbl[] = { 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 }, + { MT_NGOATMC, "Gharbad the Weak", "BSDB", 4, 120, AI_GARBUD, 3, 8, 16, IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, TEXT_GARBUD1 }, { MT_SKING, "Skeleton King", "GENRL", 0, 240, AI_SKELKING, 3, 6, 16, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 1, 0, 0, 0 }, - { MT_COUNSLR, "Zhar the Mad", "GENERAL", 8, 360, AI_ZHAR, 3, 16, 40, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING , 0, 0, 0, QUEST_ZHAR1 }, - { MT_BFALLSP, "Snotspill", "BNG", 4, 220, AI_SNOTSPIL, 3, 10, 18, RESIST_LIGHTNING , 0, 0, 0, QUEST_BANNER10 }, - { MT_ADVOCATE, "Arch-Bishop Lazarus", "GENERAL", 0, 600, AI_LAZURUS, 3, 30, 50, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, QUEST_VILE13 }, - { MT_HLSPWN, "Red Vex", "REDV", 0, 400, AI_LAZHELP, 3, 30, 50, IMUNE_MAGIC | RESIST_FIRE | IMUNE_NULL_40, 0, 0, 0, QUEST_VILE13 }, - { MT_HLSPWN, "BlackJade", "BLKJD", 0, 400, AI_LAZHELP, 3, 30, 50, IMUNE_MAGIC | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, QUEST_VILE13 }, - { MT_RBLACK, "Lachdanan", "BHKA", 14, 500, AI_LACHDAN, 3, 0, 0, 0 , 0, 0, 0, QUEST_VEIL9 }, - { MT_BTBLACK, "Warlord of Blood", "GENERAL", 13, 850, AI_WARLORD, 3, 35, 50, IMUNE_MAGIC | IMUNE_FIRE | IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, QUEST_WARLRD9 }, + { MT_COUNSLR, "Zhar the Mad", "GENERAL", 8, 360, AI_ZHAR, 3, 16, 40, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING , 0, 0, 0, TEXT_ZHAR1 }, + { MT_BFALLSP, "Snotspill", "BNG", 4, 220, AI_SNOTSPIL, 3, 10, 18, RESIST_LIGHTNING , 0, 0, 0, TEXT_BANNER10 }, + { MT_ADVOCATE, "Arch-Bishop Lazarus", "GENERAL", 0, 600, AI_LAZURUS, 3, 30, 50, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, TEXT_VILE13 }, + { MT_HLSPWN, "Red Vex", "REDV", 0, 400, AI_LAZHELP, 3, 30, 50, IMUNE_MAGIC | RESIST_FIRE | IMUNE_NULL_40, 0, 0, 0, TEXT_VILE13 }, + { MT_HLSPWN, "BlackJade", "BLKJD", 0, 400, AI_LAZHELP, 3, 30, 50, IMUNE_MAGIC | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, TEXT_VILE13 }, + { MT_RBLACK, "Lachdanan", "BHKA", 14, 500, AI_LACHDAN, 3, 0, 0, 0 , 0, 0, 0, TEXT_VEIL9 }, + { MT_BTBLACK, "Warlord of Blood", "GENERAL", 13, 850, AI_WARLORD, 3, 35, 50, IMUNE_MAGIC | IMUNE_FIRE | IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, TEXT_WARLRD9 }, { MT_CLEAVER, "The Butcher", "GENRL", 0, 220, AI_CLEAVER, 3, 6, 12, RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, 0 }, { MT_TSKELAX, "Bonehead Keenaxe", "BHKA", 2, 91, AI_SKELSD, 2, 4, 10, IMUNE_MAGIC | IMUNE_NULL_40, 7, 100, 0, 0 }, { MT_RFALLSD, "Bladeskin the Slasher", "BSTS", 2, 51, AI_FALLEN, 0, 6, 18, RESIST_FIRE , 11, 45, 0, 0 }, diff --git a/Source/monster.cpp b/Source/monster.cpp index cf1e1ac9..42503a00 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -203,20 +203,20 @@ void GetLevelMTypes() } if (!setlevel) { - if (QuestStatus(QTYPE_BUTCH)) + if (QuestStatus(Q_BUTCHER)) AddMonsterType(MT_CLEAVER, 2); - if (QuestStatus(QTYPE_GARB)) + if (QuestStatus(Q_GARBUD)) AddMonsterType(UniqMonst[UMT_GARBUD].mtype, 4); - if (QuestStatus(QTYPE_ZHAR)) + if (QuestStatus(Q_ZHAR)) AddMonsterType(UniqMonst[UMT_ZHAR].mtype, 4); - if (QuestStatus(QTYPE_BOL)) + if (QuestStatus(Q_LTBANNER)) AddMonsterType(UniqMonst[UMT_SNOTSPIL].mtype, 4); - if (QuestStatus(QTYPE_VEIL)) + if (QuestStatus(Q_VEIL)) AddMonsterType(UniqMonst[UMT_LACHDAN].mtype, 4); - if (QuestStatus(QTYPE_WARLRD)) + if (QuestStatus(Q_WARLORD)) AddMonsterType(UniqMonst[UMT_WARLORD].mtype, 4); - if (gbMaxPlayers != 1 && currlevel == quests[QTYPE_KING]._qlevel) { + if (gbMaxPlayers != 1 && currlevel == quests[Q_SKELKING]._qlevel) { AddMonsterType(MT_SKING, 4); @@ -698,7 +698,7 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize) Monst->mtalkmsg = 0; } - if (Monst->_mAi != AI_LAZURUS || quests[QTYPE_VB]._qvar1 <= 3) { + if (Monst->_mAi != AI_LAZURUS || quests[Q_BETRAYER]._qvar1 <= 3) { if (Monst->mtalkmsg) { Monst->_mgoal = MGOAL_INQUIRING; } @@ -762,11 +762,11 @@ void PlaceQuestMonsters() BYTE *setp; if (!setlevel) { - if (QuestStatus(QTYPE_BUTCH)) { + if (QuestStatus(Q_BUTCHER)) { PlaceUniqueMonst(UMT_BUTCHER, 0, 0); } - if (currlevel == quests[QTYPE_KING]._qlevel && gbMaxPlayers != 1) { + if (currlevel == quests[Q_SKELKING]._qlevel && gbMaxPlayers != 1) { skeltype = 0; for (skeltype = 0; skeltype < nummtypes; skeltype++) { @@ -778,40 +778,40 @@ void PlaceQuestMonsters() PlaceUniqueMonst(UMT_SKELKING, skeltype, 30); } - if (QuestStatus(QTYPE_BOL)) { + if (QuestStatus(Q_LTBANNER)) { setp = LoadFileInMem("Levels\\L1Data\\Banner1.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } - if (QuestStatus(QTYPE_BLOOD)) { + if (QuestStatus(Q_BLOOD)) { setp = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } - if (QuestStatus(QTYPE_BLIND)) { + if (QuestStatus(Q_BLIND)) { setp = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } - if (QuestStatus(QTYPE_ANVIL)) { + if (QuestStatus(Q_ANVIL)) { setp = LoadFileInMem("Levels\\L3Data\\Anvil.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x + 2, 2 * setpc_y + 2); mem_free_dbg(setp); } - if (QuestStatus(QTYPE_WARLRD)) { + if (QuestStatus(Q_WARLORD)) { setp = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); AddMonsterType(UniqMonst[UMT_WARLORD].mtype, 1); } - if (QuestStatus(QTYPE_VEIL)) { + if (QuestStatus(Q_VEIL)) { AddMonsterType(UniqMonst[UMT_LACHDAN].mtype, 1); } - if (QuestStatus(QTYPE_ZHAR) && zharlib == -1) { - quests[QTYPE_ZHAR]._qactive = 0; + if (QuestStatus(Q_ZHAR) && zharlib == -1) { + quests[Q_ZHAR]._qactive = QUEST_NOTAVAIL; } - if (currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { + if (currlevel == quests[Q_BETRAYER]._qlevel && gbMaxPlayers != 1) { AddMonsterType(UniqMonst[UMT_LAZURUS].mtype, 4); AddMonsterType(UniqMonst[UMT_RED_VEX].mtype, 4); PlaceUniqueMonst(UMT_LAZURUS, 0, 0); @@ -1009,15 +1009,15 @@ void PlaceUniques() done = (Monsters[mt].mtype == UniqMonst[u].mtype); } mt--; - if (u == UMT_GARBUD && quests[QTYPE_GARB]._qactive == 0) + if (u == UMT_GARBUD && quests[Q_GARBUD]._qactive == QUEST_NOTAVAIL) done = FALSE; - if (u == UMT_ZHAR && quests[QTYPE_ZHAR]._qactive == 0) + if (u == UMT_ZHAR && quests[Q_ZHAR]._qactive == QUEST_NOTAVAIL) done = FALSE; - if (u == UMT_SNOTSPIL && quests[QTYPE_BOL]._qactive == 0) + if (u == UMT_SNOTSPIL && quests[Q_LTBANNER]._qactive == QUEST_NOTAVAIL) done = FALSE; - if (u == UMT_LACHDAN && quests[QTYPE_VEIL]._qactive == 0) + if (u == UMT_LACHDAN && quests[Q_VEIL]._qactive == QUEST_NOTAVAIL) done = FALSE; - if (u == UMT_WARLORD && quests[QTYPE_WARLRD]._qactive == 0) + if (u == UMT_WARLORD && quests[Q_WARLORD]._qactive == QUEST_NOTAVAIL) done = FALSE; if (done) PlaceUniqueMonst(u, mt, 8); @@ -1541,9 +1541,9 @@ void M_DiabloDeath(int i, BOOL sendmsg) #ifndef SPAWN PlaySFX(USFX_DIABLOD); #endif - quests[QTYPE_MOD]._qactive = 3; + quests[Q_DIABLO]._qactive = QUEST_DONE; if (sendmsg) - NetSendCmdQuest(TRUE, QTYPE_MOD); + NetSendCmdQuest(TRUE, Q_DIABLO); gbProcessPlayers = FALSE; sgbSaveSoundOn = gbSoundOn; for (j = 0; j < nummonsters; j++) { @@ -1647,7 +1647,7 @@ void MonstStartKill(int i, int pnum, BOOL sendmsg) monstkills[monster[i].MType->mtype]++; monster[i]._mhitpoints = 0; SetRndSeed(monster[i]._mRndSeed); - if (QuestStatus(QTYPE_GARB) && monster[i].mName == UniqMonst[UMT_GARBUD].mName) { + if (QuestStatus(Q_GARBUD) && monster[i].mName == UniqMonst[UMT_GARBUD].mName) { CreateTypeItem(monster[i]._mx + 1, monster[i]._my + 1, TRUE, ITYPE_MACE, IMISC_NONE, TRUE, FALSE); } else if (i > MAX_PLRS - 1) { // Golems should not spawn items SpawnItem(i, monster[i]._mx, monster[i]._my, sendmsg); @@ -2388,55 +2388,55 @@ int M_DoTalk(int i) return FALSE; InitQTextMsg(Monst->mtalkmsg); if (Monst->mName == UniqMonst[UMT_GARBUD].mName) { - if (Monst->mtalkmsg == QUEST_GARBUD1) - quests[QTYPE_GARB]._qactive = 2; - quests[QTYPE_GARB]._qlog = TRUE; - if (Monst->mtalkmsg == QUEST_GARBUD2 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { + if (Monst->mtalkmsg == TEXT_GARBUD1) + quests[Q_GARBUD]._qactive = QUEST_ACTIVE; + quests[Q_GARBUD]._qlog = TRUE; + if (Monst->mtalkmsg == TEXT_GARBUD2 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { SpawnItem(i, Monst->_mx + 1, Monst->_my + 1, TRUE); Monst->_mFlags |= MFLAG_QUEST_COMPLETE; } } if (Monst->mName == UniqMonst[UMT_ZHAR].mName - && Monst->mtalkmsg == QUEST_ZHAR1 + && Monst->mtalkmsg == TEXT_ZHAR1 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { - quests[QTYPE_ZHAR]._qactive = 2; - quests[QTYPE_ZHAR]._qlog = TRUE; + quests[Q_ZHAR]._qactive = QUEST_ACTIVE; + quests[Q_ZHAR]._qlog = TRUE; CreateTypeItem(Monst->_mx + 1, Monst->_my + 1, FALSE, ITYPE_MISC, IMISC_BOOK, TRUE, FALSE); Monst->_mFlags |= MFLAG_QUEST_COMPLETE; } if (Monst->mName == UniqMonst[UMT_SNOTSPIL].mName) { - if (Monst->mtalkmsg == QUEST_BANNER10 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { + if (Monst->mtalkmsg == TEXT_BANNER10 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { ObjChangeMap(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 2, (setpc_h >> 1) + setpc_y - 2); tren = TransVal; TransVal = 9; DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 4, setpc_y + (setpc_h >> 1)); TransVal = tren; - quests[QTYPE_BOL]._qvar1 = 2; - if (quests[QTYPE_BOL]._qactive == 1) - quests[QTYPE_BOL]._qactive = 2; + quests[Q_LTBANNER]._qvar1 = 2; + if (quests[Q_LTBANNER]._qactive == QUEST_INIT) + quests[Q_LTBANNER]._qactive = QUEST_ACTIVE; Monst->_mFlags |= MFLAG_QUEST_COMPLETE; } - if (quests[QTYPE_BOL]._qvar1 < 2) { + if (quests[Q_LTBANNER]._qvar1 < 2) { sprintf(tempstr, "SS Talk = %i, Flags = %i", Monst->mtalkmsg, Monst->_mFlags); app_fatal(tempstr); } } if (Monst->mName == UniqMonst[UMT_LACHDAN].mName) { - if (Monst->mtalkmsg == QUEST_VEIL9) { - quests[QTYPE_VEIL]._qactive = 2; - quests[QTYPE_VEIL]._qlog = TRUE; + if (Monst->mtalkmsg == TEXT_VEIL9) { + quests[Q_VEIL]._qactive = QUEST_ACTIVE; + quests[Q_VEIL]._qlog = TRUE; } - if (Monst->mtalkmsg == QUEST_VEIL11 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { + if (Monst->mtalkmsg == TEXT_VEIL11 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { SpawnUnique(UITEM_STEELVEIL, Monst->_mx + 1, Monst->_my + 1); Monst->_mFlags |= MFLAG_QUEST_COMPLETE; } } if (Monst->mName == UniqMonst[UMT_WARLORD].mName) - quests[QTYPE_WARLRD]._qvar1 = 2; + quests[Q_WARLORD]._qvar1 = 2; if (Monst->mName == UniqMonst[UMT_LAZURUS].mName && gbMaxPlayers != 1) { Monst->_msquelch = UCHAR_MAX; Monst->mtalkmsg = 0; - quests[QTYPE_VB]._qvar1 = 6; + quests[Q_BETRAYER]._qvar1 = 6; Monst->_mgoal = MGOAL_NORMAL; } return FALSE; @@ -4196,8 +4196,8 @@ void MAI_Garbud(int i) _my = Monst->_my; md = M_GetDir(i); - if (Monst->mtalkmsg < QUEST_GARBUD4 - && Monst->mtalkmsg > QUEST_DOOM10 + if (Monst->mtalkmsg < TEXT_GARBUD4 + && Monst->mtalkmsg > TEXT_DOOM10 && !(dFlags[_mx][_my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { Monst->_mgoal = MGOAL_INQUIRING; @@ -4206,7 +4206,7 @@ void MAI_Garbud(int i) if (dFlags[_mx][_my] & BFLAG_VISIBLE) { #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_GARBUD4) { + if (Monst->mtalkmsg == TEXT_GARBUD4) { if (!effect_is_playing(USFX_GARBUD4) && Monst->_mgoal == MGOAL_TALKING) { Monst->_mgoal = MGOAL_NORMAL; Monst->_msquelch = UCHAR_MAX; @@ -4241,8 +4241,8 @@ void MAI_Zhar(int i) mx = Monst->_mx; my = Monst->_my; md = M_GetDir(i); - if (Monst->mtalkmsg == QUEST_ZHAR1 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { - Monst->mtalkmsg = QUEST_ZHAR2; + if (Monst->mtalkmsg == TEXT_ZHAR1 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { + Monst->mtalkmsg = TEXT_ZHAR2; Monst->_mgoal = MGOAL_INQUIRING; } @@ -4254,7 +4254,7 @@ void MAI_Zhar(int i) else abs(_my); #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_ZHAR2) { + if (Monst->mtalkmsg == TEXT_ZHAR2) { if (!effect_is_playing(USFX_ZHAR2) && Monst->_mgoal == MGOAL_TALKING) { Monst->_msquelch = UCHAR_MAX; Monst->mtalkmsg = 0; @@ -4290,22 +4290,22 @@ void MAI_SnotSpil(int i) my = Monst->_my; md = M_GetDir(i); - if (Monst->mtalkmsg == QUEST_BANNER10 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { - Monst->mtalkmsg = QUEST_BANNER11; + if (Monst->mtalkmsg == TEXT_BANNER10 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { + Monst->mtalkmsg = TEXT_BANNER11; Monst->_mgoal = MGOAL_INQUIRING; } - if (Monst->mtalkmsg == QUEST_BANNER11 && quests[QTYPE_BOL]._qvar1 == 3) { + if (Monst->mtalkmsg == TEXT_BANNER11 && quests[Q_LTBANNER]._qvar1 == 3) { Monst->mtalkmsg = 0; Monst->_mgoal = MGOAL_NORMAL; } if (dFlags[mx][my] & BFLAG_VISIBLE) { #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_BANNER12) { + if (Monst->mtalkmsg == TEXT_BANNER12) { if (!effect_is_playing(USFX_SNOT3) && Monst->_mgoal == MGOAL_TALKING) { ObjChangeMap(setpc_x, setpc_y, setpc_x + setpc_w + 1, setpc_y + setpc_h + 1); - quests[QTYPE_BOL]._qvar1 = 3; + quests[Q_LTBANNER]._qvar1 = 3; RedoPlayerVision(); Monst->_msquelch = UCHAR_MAX; Monst->mtalkmsg = 0; @@ -4313,7 +4313,7 @@ void MAI_SnotSpil(int i) } } #endif - if (quests[QTYPE_BOL]._qvar1 == 3) { + if (quests[Q_LTBANNER]._qvar1 == 3) { if (Monst->_mgoal == MGOAL_NORMAL || Monst->_mgoal == MGOAL_SHOOT) MAI_Fallen(i); } @@ -4343,25 +4343,25 @@ void MAI_Lazurus(int i) md = M_GetDir(i); if (dFlags[mx][my] & BFLAG_VISIBLE) { if (gbMaxPlayers == 1) { - if (Monst->mtalkmsg == QUEST_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && plr[myplr].WorldX == QUEST_VILE13 && plr[myplr].WorldY == 46) { + if (Monst->mtalkmsg == TEXT_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && plr[myplr].WorldX == TEXT_VILE13 && plr[myplr].WorldY == 46) { PlayInGameMovie("gendata\\fprst3.smk"); Monst->_mmode = MM_TALK; - quests[QTYPE_VB]._qvar1 = 5; + quests[Q_BETRAYER]._qvar1 = 5; } #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_VILE13 && !effect_is_playing(USFX_LAZ1) && Monst->_mgoal == MGOAL_TALKING) { + if (Monst->mtalkmsg == TEXT_VILE13 && !effect_is_playing(USFX_LAZ1) && Monst->_mgoal == MGOAL_TALKING) { ObjChangeMapResync(1, 18, 20, 24); RedoPlayerVision(); Monst->_msquelch = UCHAR_MAX; Monst->mtalkmsg = 0; - quests[QTYPE_VB]._qvar1 = 6; + quests[Q_BETRAYER]._qvar1 = 6; Monst->_mgoal = MGOAL_NORMAL; } #endif } - if (gbMaxPlayers != 1 && Monst->mtalkmsg == QUEST_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && quests[QTYPE_VB]._qvar1 <= 3) { + if (gbMaxPlayers != 1 && Monst->mtalkmsg == TEXT_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && quests[Q_BETRAYER]._qvar1 <= 3) { Monst->_mmode = MM_TALK; } } @@ -4395,7 +4395,7 @@ void MAI_Lazhelp(int i) if (dFlags[_mx][_my] & BFLAG_VISIBLE) { if (gbMaxPlayers == 1) { - if (quests[QTYPE_VB]._qvar1 <= 5) { + if (quests[Q_BETRAYER]._qvar1 <= 5) { Monst->_mgoal = MGOAL_INQUIRING; } else { Monst->mtalkmsg = 0; @@ -4428,16 +4428,16 @@ void MAI_Lachdanan(int i) _my = Monst->_my; md = M_GetDir(i); #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_VEIL9 && !(dFlags[_mx][_my] & BFLAG_VISIBLE) && monster[i]._mgoal == MGOAL_TALKING) { - Monst->mtalkmsg = QUEST_VEIL10; + if (Monst->mtalkmsg == TEXT_VEIL9 && !(dFlags[_mx][_my] & BFLAG_VISIBLE) && monster[i]._mgoal == MGOAL_TALKING) { + Monst->mtalkmsg = TEXT_VEIL10; monster[i]._mgoal = MGOAL_INQUIRING; } if (dFlags[_mx][_my] & BFLAG_VISIBLE) { - if (Monst->mtalkmsg == QUEST_VEIL11) { + if (Monst->mtalkmsg == TEXT_VEIL11) { if (!effect_is_playing(USFX_LACH3) && Monst->_mgoal == MGOAL_TALKING) { Monst->mtalkmsg = 0; - quests[QTYPE_VEIL]._qactive = 3; + quests[Q_VEIL]._qactive = QUEST_DONE; M_StartKill(i, -1); } } @@ -4467,10 +4467,10 @@ void MAI_Warlord(int i) my = Monst->_my; md = M_GetDir(i); if (dFlags[mx][my] & BFLAG_VISIBLE) { - if (Monst->mtalkmsg == QUEST_WARLRD9 && Monst->_mgoal == MGOAL_INQUIRING) + if (Monst->mtalkmsg == TEXT_WARLRD9 && Monst->_mgoal == MGOAL_INQUIRING) Monst->_mmode = MM_TALK; #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_WARLRD9 && !effect_is_playing(USFX_WARLRD1) && Monst->_mgoal == MGOAL_TALKING) { + if (Monst->mtalkmsg == TEXT_WARLRD9 && !effect_is_playing(USFX_WARLRD1) && Monst->_mgoal == MGOAL_TALKING) { Monst->_msquelch = UCHAR_MAX; Monst->mtalkmsg = 0; Monst->_mgoal = MGOAL_NORMAL; @@ -5441,16 +5441,16 @@ void TalktoMonster(int i) pnum = Monst->_menemy; Monst->_mmode = MM_TALK; if (Monst->_mAi == AI_SNOTSPIL || Monst->_mAi == AI_LACHDAN) { - if (QuestStatus(QTYPE_BOL) && quests[QTYPE_BOL]._qvar1 == 2 && PlrHasItem(pnum, IDI_BANNER, itm)) { + if (QuestStatus(Q_LTBANNER) && quests[Q_LTBANNER]._qvar1 == 2 && PlrHasItem(pnum, IDI_BANNER, itm)) { RemoveInvItem(pnum, itm); - quests[QTYPE_BOL]._qactive = 3; - Monst->mtalkmsg = QUEST_BANNER12; + quests[Q_LTBANNER]._qactive = QUEST_DONE; + Monst->mtalkmsg = TEXT_BANNER12; Monst->_mgoal = MGOAL_INQUIRING; } - if (QuestStatus(QTYPE_VEIL) && Monst->mtalkmsg >= QUEST_VEIL9) { + if (QuestStatus(Q_VEIL) && Monst->mtalkmsg >= TEXT_VEIL9) { if (PlrHasItem(pnum, IDI_GLDNELIX, itm)) { RemoveInvItem(pnum, itm); - Monst->mtalkmsg = QUEST_VEIL11; + Monst->mtalkmsg = TEXT_VEIL11; Monst->_mgoal = MGOAL_INQUIRING; } } diff --git a/Source/msg.cpp b/Source/msg.cpp index c9415318..3b95bc1c 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -54,7 +54,7 @@ void msg_send_packet(int pnum, const void *packet, DWORD dwSize) sgpCurrPkt->dwSpaceLeft -= dwSize; } -TMegaPkt *msg_get_next_packet() +void msg_get_next_packet() { TMegaPkt *result; @@ -67,8 +67,6 @@ TMegaPkt *msg_get_next_packet() result = result->pNext; } result->pNext = sgpCurrPkt; - - return result; } BOOL msg_wait_resync() @@ -145,7 +143,7 @@ int msg_wait_for_turns() return 100 * sgbDeltaChunks / 21; } -void msg_process_net_packets() +void run_delta_info() { if (gbMaxPlayers != 1) { gbBufferMsgs = 2; @@ -973,7 +971,7 @@ void NetSendCmdString(int pmask, const char *pszStr) multi_send_msg_packet(pmask, (BYTE *)&cmd.bCmd, dwStrLen + 2); } -void RemovePlrPortal(int pnum) +void delta_close_portal(int pnum) { memset(&sgJunk.portal[pnum], 0xFF, sizeof(sgJunk.portal[pnum])); sgbDeltaChanged = TRUE; @@ -2429,7 +2427,7 @@ DWORD On_DEACTIVATEPORTAL(TCmd *pCmd, int pnum) if (PortalOnLevel(pnum)) RemovePortalMissile(pnum); DeactivatePortal(pnum); - RemovePlrPortal(pnum); + delta_close_portal(pnum); } return sizeof(*pCmd); diff --git a/Source/msg.h b/Source/msg.h index 81d58176..611933ab 100644 --- a/Source/msg.h +++ b/Source/msg.h @@ -12,11 +12,11 @@ extern int pkt_counter; void msg_send_drop_pkt(int pnum, int reason); void msg_send_packet(int pnum, const void *packet, DWORD dwSize); -TMegaPkt *msg_get_next_packet(); +void msg_get_next_packet(); BOOL msg_wait_resync(); void msg_free_packets(); int msg_wait_for_turns(); -void msg_process_net_packets(); +void run_delta_info(); void msg_pre_packet(); void DeltaExportData(int pnum); BYTE *DeltaExportItem(BYTE *dst, TCmdPItem *src); @@ -55,7 +55,7 @@ void NetSendCmdDelItem(BOOL bHiPri, BYTE bLoc); void NetSendCmdDItem(BOOL bHiPri, int ii); void NetSendCmdDamage(BOOL bHiPri, BYTE bPlr, DWORD dwDam); void NetSendCmdString(int pmask, const char *pszStr); -void RemovePlrPortal(int pnum); +void delta_close_portal(int pnum); DWORD ParseCmd(int pnum, TCmd *pCmd); DWORD On_DLEVEL(int pnum, TCmd *pCmd); void DeltaImportData(BYTE cmd, DWORD recv_offset); diff --git a/Source/multi.cpp b/Source/multi.cpp index d03d8b06..a5752229 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -277,7 +277,7 @@ void multi_player_left_msg(int pnum, int left) RemovePlrFromMap(pnum); RemovePortalMissile(pnum); DeactivatePortal(pnum); - RemovePlrPortal(pnum); + delta_close_portal(pnum); RemovePlrMissiles(pnum); if (left) { pszFmt = "Player '%s' just left the game"; diff --git a/Source/objects.cpp b/Source/objects.cpp index 5f3c8126..c9e094eb 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -70,9 +70,9 @@ char *StoryBookName[9] = { "The Black King" }; int StoryText[3][3] = { - { QUEST_BOOK11, QUEST_BOOK12, QUEST_BOOK13 }, - { QUEST_BOOK21, QUEST_BOOK22, QUEST_BOOK23 }, - { QUEST_BOOK31, QUEST_BOOK32, QUEST_BOOK33 } + { TEXT_BOOK11, TEXT_BOOK12, TEXT_BOOK13 }, + { TEXT_BOOK21, TEXT_BOOK22, TEXT_BOOK23 }, + { TEXT_BOOK31, TEXT_BOOK32, TEXT_BOOK33 } }; void InitObjectGFX() @@ -276,8 +276,8 @@ void AddCandles() { int tx, ty; - tx = quests[QTYPE_PW]._qtx; - ty = quests[QTYPE_PW]._qty; + tx = quests[Q_PWATER]._qtx; + ty = quests[Q_PWATER]._qty; AddObject(OBJ_STORYCANDLE, tx - 2, ty + 1); AddObject(OBJ_STORYCANDLE, tx + 3, ty + 1); AddObject(OBJ_STORYCANDLE, tx - 1, ty + 2); @@ -307,11 +307,11 @@ void AddBookLever(int lx1, int ly1, int lx2, int ly2, int x1, int y1, int x2, in return; } - if (QuestStatus(QTYPE_BLIND)) + if (QuestStatus(Q_BLIND)) AddObject(OBJ_BLINDBOOK, xp, yp); - if (QuestStatus(QTYPE_WARLRD)) + if (QuestStatus(Q_WARLORD)) AddObject(OBJ_STEELTOME, xp, yp); - if (QuestStatus(QTYPE_BLOOD)) { + if (QuestStatus(Q_BLOOD)) { xp = 2 * setpc_x + 25; yp = 2 * setpc_y + 40; AddObject(OBJ_BLOODBOOK, xp, yp); @@ -751,7 +751,7 @@ void InitObjects() GetRndSeed(); if (currlevel == 9 && gbMaxPlayers == 1) AddSlainHero(); - if (currlevel == quests[QTYPE_BLKM]._qlevel && quests[QTYPE_BLKM]._qactive == 1) + if (currlevel == quests[Q_MUSHROOM]._qlevel && quests[Q_MUSHROOM]._qactive == QUEST_INIT) AddMushPatch(); if (currlevel == 4) AddStoryBooks(); @@ -760,46 +760,46 @@ void InitObjects() if (currlevel == 12) AddStoryBooks(); if (leveltype == DTYPE_CATHEDRAL) { - if (QuestStatus(QTYPE_BUTCH)) + if (QuestStatus(Q_BUTCHER)) AddTortures(); - if (QuestStatus(QTYPE_PW)) + if (QuestStatus(Q_PWATER)) AddCandles(); - if (QuestStatus(QTYPE_BOL)) + if (QuestStatus(Q_LTBANNER)) AddObject(OBJ_SIGNCHEST, 2 * setpc_x + 26, 2 * setpc_y + 19); InitRndLocBigObj(10, 15, OBJ_SARC); AddL1Objs(0, 0, MAXDUNX, MAXDUNY); InitRndBarrels(); } if (leveltype == DTYPE_CATACOMBS) { - if (QuestStatus(QTYPE_INFRA)) + if (QuestStatus(Q_ROCK)) InitRndLocObj5x5(1, 1, OBJ_STAND); - if (QuestStatus(QTYPE_BONE)) + if (QuestStatus(Q_SCHAMB)) InitRndLocObj5x5(1, 1, OBJ_BOOK2R); AddL2Objs(0, 0, MAXDUNX, MAXDUNY); AddL2Torches(); - if (QuestStatus(QTYPE_BLIND)) { + if (QuestStatus(Q_BLIND)) { if (plr[myplr]._pClass == PC_WARRIOR) { - sp_id = QUEST_BLINDING; + sp_id = TEXT_BLINDING; } else if (plr[myplr]._pClass == PC_ROGUE) { - sp_id = QUEST_RBLINDING; + sp_id = TEXT_RBLINDING; } else if (plr[myplr]._pClass == PC_SORCERER) { - sp_id = QUEST_MBLINDING; + sp_id = TEXT_MBLINDING; } - quests[QTYPE_BLIND]._qmsg = sp_id; + quests[Q_BLIND]._qmsg = sp_id; AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1, sp_id); mem = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", NULL); LoadMapObjs(mem, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(mem); } - if (QuestStatus(QTYPE_BLOOD)) { + if (QuestStatus(Q_BLOOD)) { if (plr[myplr]._pClass == PC_WARRIOR) { - sp_id = QUEST_BLOODY; + sp_id = TEXT_BLOODY; } else if (plr[myplr]._pClass == PC_ROGUE) { - sp_id = QUEST_RBLOODY; + sp_id = TEXT_RBLOODY; } else if (plr[myplr]._pClass == PC_SORCERER) { - sp_id = QUEST_MBLOODY; + sp_id = TEXT_MBLOODY; } - quests[QTYPE_BLOOD]._qmsg = sp_id; + quests[Q_BLOOD]._qmsg = sp_id; AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7, sp_id); AddObject(OBJ_PEDISTAL, 2 * setpc_x + 25, 2 * setpc_y + 32); } @@ -810,21 +810,21 @@ void InitObjects() InitRndBarrels(); } if (leveltype == DTYPE_HELL) { - if (QuestStatus(QTYPE_WARLRD)) { + if (QuestStatus(Q_WARLORD)) { if (plr[myplr]._pClass == PC_WARRIOR) { - sp_id = QUEST_BLOODWAR; + sp_id = TEXT_BLOODWAR; } else if (plr[myplr]._pClass == PC_ROGUE) { - sp_id = QUEST_RBLOODWAR; + sp_id = TEXT_RBLOODWAR; } else if (plr[myplr]._pClass == PC_SORCERER) { - sp_id = QUEST_MBLOODWAR; + sp_id = TEXT_MBLOODWAR; } - quests[QTYPE_WARLRD]._qmsg = sp_id; + quests[Q_WARLORD]._qmsg = sp_id; AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y, setpc_x + setpc_w, setpc_y + setpc_h, sp_id); mem = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", NULL); LoadMapObjs(mem, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(mem); } - if (QuestStatus(QTYPE_VB) && gbMaxPlayers == 1) + if (QuestStatus(Q_BETRAYER) && gbMaxPlayers == 1) AddLazStand(); InitRndBarrels(); AddL4Goodies(); @@ -1519,8 +1519,8 @@ void Obj_Circle(int i) if (ox == 35 && oy == 36 && object[i]._oVar5 == 3) { object[i]._oVar6 = 4; ObjChangeMapResync(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); - if (quests[QTYPE_VB]._qactive == 2) - quests[QTYPE_VB]._qvar1 = 4; + if (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE) + quests[Q_BETRAYER]._qvar1 = 4; AddMissile(plr[myplr].WorldX, plr[myplr].WorldY, 35, 46, plr[myplr]._pdir, MIS_RNDTELEPORT, 0, myplr, 0, 0); track_repeat_walk(FALSE); sgbMouseDown = 0; @@ -2469,7 +2469,7 @@ void OperateBook(int pnum, int i) plr[myplr]._pMemSpells |= ((__int64)1 << (SPL_GUARDIAN - 1)); if (plr[pnum]._pSplLvl[SPL_GUARDIAN] < 15) plr[myplr]._pSplLvl[SPL_GUARDIAN]++; - quests[QTYPE_BONE]._qactive = 3; + quests[Q_SCHAMB]._qactive = QUEST_DONE; if (!deltaload) PlaySfxLoc(IS_QUESTDN, object[i]._ox, object[i]._oy); InitDiabloMsg(EMSG_BONECHAMB); @@ -2503,24 +2503,24 @@ void OperateBookLever(int pnum, int i) x = 2 * setpc_x + 16; y = 2 * setpc_y + 16; if (object[i]._oSelFlag != 0 && !qtextflag) { - if (object[i]._otype == OBJ_BLINDBOOK && !quests[QTYPE_BLIND]._qvar1) { - quests[QTYPE_BLIND]._qactive = 2; - quests[QTYPE_BLIND]._qlog = 1; - quests[QTYPE_BLIND]._qvar1 = 1; + if (object[i]._otype == OBJ_BLINDBOOK && !quests[Q_BLIND]._qvar1) { + quests[Q_BLIND]._qactive = QUEST_ACTIVE; + quests[Q_BLIND]._qlog = 1; + quests[Q_BLIND]._qvar1 = 1; } - if (object[i]._otype == OBJ_BLOODBOOK && !quests[QTYPE_BLOOD]._qvar1) { - quests[QTYPE_BLOOD]._qactive = 2; - quests[QTYPE_BLOOD]._qlog = 1; - quests[QTYPE_BLOOD]._qvar1 = 1; + if (object[i]._otype == OBJ_BLOODBOOK && !quests[Q_BLOOD]._qvar1) { + quests[Q_BLOOD]._qactive = QUEST_ACTIVE; + quests[Q_BLOOD]._qlog = 1; + quests[Q_BLOOD]._qvar1 = 1; SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 19, 2 * setpc_y + 26, 0, 1); SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 31, 2 * setpc_y + 26, 0, 1); SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 25, 2 * setpc_y + 33, 0, 1); } object[i]._otype = object[i]._otype; - if (object[i]._otype == OBJ_STEELTOME && !quests[QTYPE_WARLRD]._qvar1) { - quests[QTYPE_WARLRD]._qactive = 2; - quests[QTYPE_WARLRD]._qlog = 1; - quests[QTYPE_WARLRD]._qvar1 = 1; + if (object[i]._otype == OBJ_STEELTOME && !quests[Q_WARLORD]._qvar1) { + quests[Q_WARLORD]._qactive = QUEST_ACTIVE; + quests[Q_WARLORD]._qlog = 1; + quests[Q_WARLORD]._qvar1 = 1; } if (object[i]._oAnimFrame != object[i]._oVar6) { if (object[i]._otype != OBJ_BLOODBOOK) @@ -2551,18 +2551,18 @@ void OperateSChambBk(int pnum, int i) SyncObjectAnim(objectactive[j]); } object[i]._oAnimFrame = object[i]._oVar6; - if (quests[QTYPE_BONE]._qactive == 1) { - quests[QTYPE_BONE]._qactive = 2; - quests[QTYPE_BONE]._qlog = 1; + if (quests[Q_SCHAMB]._qactive == QUEST_INIT) { + quests[Q_SCHAMB]._qactive = QUEST_ACTIVE; + quests[Q_SCHAMB]._qlog = 1; } if (plr[myplr]._pClass == PC_WARRIOR) { - textdef = QUEST_BONER; + textdef = TEXT_BONER; } else if (plr[myplr]._pClass == PC_ROGUE) { - textdef = QUEST_RBONER; + textdef = TEXT_RBONER; } else if (plr[myplr]._pClass == PC_SORCERER) { - textdef = QUEST_MBONER; + textdef = TEXT_MBONER; } - quests[QTYPE_BONE]._qmsg = textdef; + quests[Q_SCHAMB]._qmsg = textdef; InitQTextMsg(textdef); } } @@ -2617,7 +2617,7 @@ void OperateMushPatch(int pnum, int i) { int x, y; - if (quests[QTYPE_BLKM]._qactive != 2 || quests[QTYPE_BLKM]._qvar1 < QS_TOMEGIVEN) { + if (quests[Q_MUSHROOM]._qactive != QUEST_ACTIVE || quests[Q_MUSHROOM]._qvar1 < QS_TOMEGIVEN) { if (!deltaload && pnum == myplr) { if (plr[myplr]._pClass == PC_WARRIOR) { PlaySFX(PS_WARR13); @@ -2638,7 +2638,7 @@ void OperateMushPatch(int pnum, int i) if (!deltaload) { GetSuperItemLoc(object[i]._ox, object[i]._oy, x, y); SpawnQuestItem(IDI_MUSHROOM, x, y, 0, 0); - quests[QTYPE_BLKM]._qvar1 = QS_MUSHSPAWNED; + quests[Q_MUSHROOM]._qvar1 = QS_MUSHSPAWNED; } } } @@ -2648,7 +2648,7 @@ void OperateInnSignChest(int pnum, int i) { int x, y; - if (quests[QTYPE_BOL]._qvar1 != 2) { + if (quests[Q_LTBANNER]._qvar1 != 2) { if (!deltaload && pnum == myplr) { if (plr[myplr]._pClass == PC_WARRIOR) { PlaySFX(PS_WARR24); @@ -3486,11 +3486,11 @@ void OperateBookCase(int pnum, int i, BOOL sendmsg) if (!deltaload) { SetRndSeed(object[i]._oRndSeed); CreateTypeItem(object[i]._ox, object[i]._oy, FALSE, ITYPE_MISC, IMISC_BOOK, sendmsg, FALSE); - if (QuestStatus(QTYPE_ZHAR) + if (QuestStatus(Q_ZHAR) && monster[MAX_PLRS].mName == UniqMonst[UMT_ZHAR].mName && monster[MAX_PLRS]._msquelch == UCHAR_MAX && monster[MAX_PLRS]._mhitpoints) { - monster[MAX_PLRS].mtalkmsg = QUEST_ZHAR2; + monster[MAX_PLRS].mtalkmsg = TEXT_ZHAR2; M_StartStand(0, monster[MAX_PLRS]._mdir); monster[MAX_PLRS]._mgoal = MGOAL_SHOOT; monster[MAX_PLRS]._mmode = MM_TALK; diff --git a/Source/player.cpp b/Source/player.cpp index befb421b..01e1bc63 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3025,7 +3025,7 @@ void CheckNewPath(int pnum) if (x < 2 && y < 2) { ClrPlrPath(pnum); - if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + if (monster[i].mtalkmsg && monster[i].mtalkmsg != TEXT_VILE14) { TalktoMonster(i); } else { StartAttack(pnum, d); @@ -3102,7 +3102,7 @@ void CheckNewPath(int pnum) y = abs(plr[pnum].WorldY - monster[i]._mfuty); if (x <= 1 && y <= 1) { d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + if (monster[i].mtalkmsg && monster[i].mtalkmsg != TEXT_VILE14) { TalktoMonster(i); } else { StartAttack(pnum, d); @@ -3125,7 +3125,7 @@ void CheckNewPath(int pnum) case ACTION_RATTACKMON: i = plr[pnum].destParam1; d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + if (monster[i].mtalkmsg && monster[i].mtalkmsg != TEXT_VILE14) { TalktoMonster(i); } else { StartRangeAttack(pnum, d, monster[i]._mfutx, monster[i]._mfuty); diff --git a/Source/quests.cpp b/Source/quests.cpp index 20169885..c0fc49c0 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -17,22 +17,22 @@ int ReturnLvl; QuestData questlist[MAXQUESTS] = { // clang-format off // _qdlvl, _qdmultlvl, _qlvlt, _qdtype, _qdrnd, _qslvl, _qflags, _qdmsg, _qlstr - { 5, -1, DTYPE_NONE, QTYPE_INFRA, 100, 0, 0, QUEST_INFRA5, "The Magic Rock" }, - { 9, -1, DTYPE_NONE, QTYPE_BLKM, 100, 0, 0, QUEST_MUSH8, "Black Mushroom" }, - { 4, -1, DTYPE_NONE, QTYPE_GARB, 100, 0, 0, QUEST_GARBUD1, "Gharbad The Weak" }, - { 8, -1, DTYPE_NONE, QTYPE_ZHAR, 100, 0, 0, QUEST_ZHAR1, "Zhar the Mad" }, - { 14, -1, DTYPE_NONE, QTYPE_VEIL, 100, 0, 0, QUEST_VEIL9, "Lachdanan" }, - { 15, -1, DTYPE_NONE, QTYPE_MOD, 100, 0, 1, QUEST_VILE3, "Diablo" }, - { 2, 2, DTYPE_NONE, QTYPE_BUTCH, 100, 0, 1, QUEST_BUTCH9, "The Butcher" }, - { 4, -1, DTYPE_NONE, QTYPE_BOL, 100, 0, 0, QUEST_BANNER2, "Ogden's Sign" }, - { 7, -1, DTYPE_NONE, QTYPE_BLIND, 100, 0, 0, QUEST_BLINDING, "Halls of the Blind" }, - { 5, -1, DTYPE_NONE, QTYPE_BLOOD, 100, 0, 0, QUEST_BLOODY, "Valor" }, - { 10, -1, DTYPE_NONE, QTYPE_ANVIL, 100, 0, 0, QUEST_ANVIL5, "Anvil of Fury" }, - { 13, -1, DTYPE_NONE, QTYPE_WARLRD, 100, 0, 0, QUEST_BLOODWAR, "Warlord of Blood" }, - { 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" }, + { 5, -1, DTYPE_NONE, Q_ROCK, 100, 0, 0, TEXT_INFRA5, "The Magic Rock" }, + { 9, -1, DTYPE_NONE, Q_MUSHROOM, 100, 0, 0, TEXT_MUSH8, "Black Mushroom" }, + { 4, -1, DTYPE_NONE, Q_GARBUD, 100, 0, 0, TEXT_GARBUD1, "Gharbad The Weak" }, + { 8, -1, DTYPE_NONE, Q_ZHAR, 100, 0, 0, TEXT_ZHAR1, "Zhar the Mad" }, + { 14, -1, DTYPE_NONE, Q_VEIL, 100, 0, 0, TEXT_VEIL9, "Lachdanan" }, + { 15, -1, DTYPE_NONE, Q_DIABLO, 100, 0, 1, TEXT_VILE3, "Diablo" }, + { 2, 2, DTYPE_NONE, Q_BUTCHER, 100, 0, 1, TEXT_BUTCH9, "The Butcher" }, + { 4, -1, DTYPE_NONE, Q_LTBANNER, 100, 0, 0, TEXT_BANNER2, "Ogden's Sign" }, + { 7, -1, DTYPE_NONE, Q_BLIND, 100, 0, 0, TEXT_BLINDING, "Halls of the Blind" }, + { 5, -1, DTYPE_NONE, Q_BLOOD, 100, 0, 0, TEXT_BLOODY, "Valor" }, + { 10, -1, DTYPE_NONE, Q_ANVIL, 100, 0, 0, TEXT_ANVIL5, "Anvil of Fury" }, + { 13, -1, DTYPE_NONE, Q_WARLORD, 100, 0, 0, TEXT_BLOODWAR, "Warlord of Blood" }, + { 3, 3, DTYPE_CATHEDRAL, Q_SKELKING, 100, 1, 1, TEXT_KING2, "The Curse of King Leoric" }, + { 2, -1, DTYPE_CAVES, Q_PWATER, 100, 4, 0, TEXT_POISON3, "Poisoned Water Supply" }, + { 6, -1, DTYPE_CATACOMBS, Q_SCHAMB, 100, 2, 0, TEXT_BONER, "The Chamber of Bone" }, + { 15, 15, DTYPE_CATHEDRAL, Q_BETRAYER, 100, 5, 1, TEXT_VILE1, "Archbishop Lazarus" }, // clang-format on }; char questxoff[7] = { 0, -1, 0, -1, -2, -1, -2 }; @@ -44,10 +44,10 @@ char *questtrigstr[5] = { "A Dark Passage", "Unholy Altar" }; -int QuestGroup1[3] = { QTYPE_BUTCH, QTYPE_BOL, QTYPE_GARB }; -int QuestGroup2[3] = { QTYPE_BLIND, QTYPE_INFRA, QTYPE_BLOOD }; -int QuestGroup3[3] = { QTYPE_BLKM, QTYPE_ZHAR, QTYPE_ANVIL }; -int QuestGroup4[2] = { QTYPE_VEIL, QTYPE_WARLRD }; +int QuestGroup1[3] = { Q_BUTCHER, Q_LTBANNER, Q_GARBUD }; +int QuestGroup2[3] = { Q_BLIND, Q_ROCK, Q_BLOOD }; +int QuestGroup3[3] = { Q_MUSHROOM, Q_ZHAR, Q_ANVIL }; +int QuestGroup4[2] = { Q_VEIL, Q_WARLORD }; void InitQuests() { @@ -56,12 +56,12 @@ void InitQuests() if (gbMaxPlayers == 1) { for (i = 0; i < MAXQUESTS; i++) { - quests[i]._qactive = 0; + quests[i]._qactive = QUEST_NOTAVAIL; } } else { for (i = 0; i < MAXQUESTS; i++) { if (!(questlist[i]._qflags & 1)) { - quests[i]._qactive = 0; + quests[i]._qactive = QUEST_NOTAVAIL; } } } @@ -77,13 +77,13 @@ void InitQuests() if (gbMaxPlayers > 1) { quests[z]._qlevel = questlist[z]._qdmultlvl; if (!delta_quest_inited(initiatedQuests)) { - quests[z]._qactive = 1; + quests[z]._qactive = QUEST_INIT; quests[z]._qvar1 = 0; quests[z]._qlog = 0; } initiatedQuests++; } else { - quests[z]._qactive = 1; + quests[z]._qactive = QUEST_INIT; quests[z]._qlevel = questlist[z]._qdlvl; quests[z]._qvar1 = 0; quests[z]._qlog = 0; @@ -102,33 +102,33 @@ void InitQuests() if (gbMaxPlayers == 1) { SetRndSeed(glSeedTbl[15]); if (random_(0, 2)) - quests[QTYPE_PW]._qactive = 0; + quests[Q_PWATER]._qactive = QUEST_NOTAVAIL; else - quests[QTYPE_KING]._qactive = 0; + quests[Q_SKELKING]._qactive = QUEST_NOTAVAIL; - quests[QuestGroup1[random_(0, sizeof(QuestGroup1) / sizeof(int))]]._qactive = 0; - quests[QuestGroup2[random_(0, sizeof(QuestGroup2) / sizeof(int))]]._qactive = 0; - quests[QuestGroup3[random_(0, sizeof(QuestGroup3) / sizeof(int))]]._qactive = 0; - quests[QuestGroup4[random_(0, sizeof(QuestGroup4) / sizeof(int))]]._qactive = 0; + quests[QuestGroup1[random_(0, sizeof(QuestGroup1) / sizeof(int))]]._qactive = QUEST_NOTAVAIL; + quests[QuestGroup2[random_(0, sizeof(QuestGroup2) / sizeof(int))]]._qactive = QUEST_NOTAVAIL; + quests[QuestGroup3[random_(0, sizeof(QuestGroup3) / sizeof(int))]]._qactive = QUEST_NOTAVAIL; + quests[QuestGroup4[random_(0, sizeof(QuestGroup4) / sizeof(int))]]._qactive = QUEST_NOTAVAIL; } #ifdef _DEBUG if (questdebug != -1) - quests[questdebug]._qactive = 2; + quests[questdebug]._qactive = QUEST_ACTIVE; #endif #ifdef SPAWN for (z = 0; z < MAXQUESTS; z++) { - quests[z]._qactive = 0; + quests[z]._qactive = QUEST_NOTAVAIL; } #endif - if (!quests[QTYPE_KING]._qactive) - quests[QTYPE_KING]._qvar2 = 2; - if (!quests[QTYPE_INFRA]._qactive) - quests[QTYPE_INFRA]._qvar2 = 2; - quests[QTYPE_BOL]._qvar1 = 1; + if (!quests[Q_SKELKING]._qactive) + quests[Q_SKELKING]._qvar2 = 2; + if (!quests[Q_ROCK]._qactive) + quests[Q_ROCK]._qvar2 = 2; + quests[Q_LTBANNER]._qvar1 = 1; if (gbMaxPlayers != 1) - quests[QTYPE_VB]._qvar1 = 2; + quests[Q_BETRAYER]._qvar1 = 2; } void CheckQuests() @@ -136,49 +136,49 @@ void CheckQuests() #ifndef SPAWN int i, rportx, rporty; - if (QuestStatus(QTYPE_VB) && gbMaxPlayers != 1 && quests[QTYPE_VB]._qvar1 == 2) { + if (QuestStatus(Q_BETRAYER) && gbMaxPlayers != 1 && quests[Q_BETRAYER]._qvar1 == 2) { AddObject(OBJ_ALTBOY, 2 * setpc_x + 20, 2 * setpc_y + 22); - quests[QTYPE_VB]._qvar1 = 3; - NetSendCmdQuest(TRUE, QTYPE_VB); + quests[Q_BETRAYER]._qvar1 = 3; + NetSendCmdQuest(TRUE, Q_BETRAYER); } if (gbMaxPlayers != 1) { return; } - if (currlevel == quests[QTYPE_VB]._qlevel + if (currlevel == quests[Q_BETRAYER]._qlevel && !setlevel - && quests[QTYPE_VB]._qvar1 >= 2 - && (quests[QTYPE_VB]._qactive == 2 || quests[QTYPE_VB]._qactive == 3) - && (quests[QTYPE_VB]._qvar2 == 0 || quests[QTYPE_VB]._qvar2 == 2)) { - quests[QTYPE_VB]._qtx = 2 * quests[QTYPE_VB]._qtx + 16; - quests[QTYPE_VB]._qty = 2 * quests[QTYPE_VB]._qty + 16; - rportx = quests[QTYPE_VB]._qtx; - rporty = quests[QTYPE_VB]._qty; + && quests[Q_BETRAYER]._qvar1 >= 2 + && (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE || quests[Q_BETRAYER]._qactive == QUEST_DONE) + && (quests[Q_BETRAYER]._qvar2 == 0 || quests[Q_BETRAYER]._qvar2 == 2)) { + quests[Q_BETRAYER]._qtx = 2 * quests[Q_BETRAYER]._qtx + 16; + quests[Q_BETRAYER]._qty = 2 * quests[Q_BETRAYER]._qty + 16; + rportx = quests[Q_BETRAYER]._qtx; + rporty = quests[Q_BETRAYER]._qty; AddMissile(rportx, rporty, rportx, rporty, 0, MIS_RPORTAL, 0, myplr, 0, 0); - quests[QTYPE_VB]._qvar2 = 1; - if (quests[QTYPE_VB]._qactive == 2) { - quests[QTYPE_VB]._qvar1 = 3; + quests[Q_BETRAYER]._qvar2 = 1; + if (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE) { + quests[Q_BETRAYER]._qvar1 = 3; } } - if (quests[QTYPE_VB]._qactive == 3 + if (quests[Q_BETRAYER]._qactive == QUEST_DONE && setlevel && setlvlnum == SL_VILEBETRAYER - && quests[QTYPE_VB]._qvar2 == 4) { + && quests[Q_BETRAYER]._qvar2 == 4) { rportx = 35; rporty = 32; AddMissile(rportx, rporty, rportx, rporty, 0, MIS_RPORTAL, 0, myplr, 0, 0); - quests[QTYPE_VB]._qvar2 = 3; + quests[Q_BETRAYER]._qvar2 = 3; } if (setlevel) { - if (setlvlnum == quests[QTYPE_PW]._qslvl - && quests[QTYPE_PW]._qactive != 1 - && leveltype == quests[QTYPE_PW]._qlvltype + if (setlvlnum == quests[Q_PWATER]._qslvl + && quests[Q_PWATER]._qactive != QUEST_INIT + && leveltype == quests[Q_PWATER]._qlvltype && nummonsters == 4 - && quests[QTYPE_PW]._qactive != 3) { - quests[QTYPE_PW]._qactive = 3; + && quests[Q_PWATER]._qactive != QUEST_DONE) { + quests[Q_PWATER]._qactive = QUEST_DONE; PlaySfxLoc(IS_QUESTDN, plr[myplr].WorldX, plr[myplr].WorldY); LoadPalette("Levels\\L3Data\\L3pwater.pal"); WaterDone = 32; @@ -191,7 +191,7 @@ void CheckQuests() for (i = 0; i < MAXQUESTS; i++) { if (currlevel == quests[i]._qlevel && quests[i]._qslvl != 0 - && quests[i]._qactive != 0 + && quests[i]._qactive != QUEST_NOTAVAIL && plr[myplr].WorldX == quests[i]._qtx && plr[myplr].WorldY == quests[i]._qty) { if (quests[i]._qlvltype != 255) { @@ -215,7 +215,7 @@ BOOL ForceQuests() for (i = 0; i < MAXQUESTS; i++) { - if (i != QTYPE_VB && currlevel == quests[i]._qlevel && quests[i]._qslvl != 0) { + if (i != Q_BETRAYER && currlevel == quests[i]._qlevel && quests[i]._qslvl != 0) { ql = quests[quests[i]._qidx]._qslvl - 1; qx = quests[i]._qtx; qy = quests[i]._qty; @@ -254,7 +254,7 @@ void CheckQuestKill(int m, BOOL sendmsg) int i, j; if (monster[m].MType->mtype == MT_SKING) { - quests[QTYPE_KING]._qactive = 3; + quests[Q_SKELKING]._qactive = QUEST_DONE; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR82; @@ -264,10 +264,10 @@ void CheckQuestKill(int m, BOOL sendmsg) sfxdnum = PS_MAGE82; } if (sendmsg) - NetSendCmdQuest(TRUE, QTYPE_KING); + NetSendCmdQuest(TRUE, Q_SKELKING); } else if (monster[m].MType->mtype == MT_CLEAVER) { - quests[QTYPE_BUTCH]._qactive = 3; + quests[Q_BUTCHER]._qactive = QUEST_DONE; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR80; @@ -277,9 +277,9 @@ void CheckQuestKill(int m, BOOL sendmsg) sfxdnum = PS_MAGE80; } if (sendmsg) - NetSendCmdQuest(TRUE, QTYPE_BUTCH); + NetSendCmdQuest(TRUE, Q_BUTCHER); } else if (monster[m].mName == UniqMonst[UMT_GARBUD].mName) { //"Gharbad the Weak" - quests[QTYPE_GARB]._qactive = 3; + quests[Q_GARBUD]._qactive = QUEST_DONE; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR61; @@ -289,7 +289,7 @@ void CheckQuestKill(int m, BOOL sendmsg) sfxdnum = PS_MAGE61; } } else if (monster[m].mName == UniqMonst[UMT_ZHAR].mName) { //"Zhar the Mad" - quests[QTYPE_ZHAR]._qactive = 3; + quests[Q_ZHAR]._qactive = QUEST_DONE; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR62; @@ -299,10 +299,10 @@ void CheckQuestKill(int m, BOOL sendmsg) sfxdnum = PS_MAGE62; } } else if (monster[m].mName == UniqMonst[UMT_LAZURUS].mName && gbMaxPlayers != 1) { //"Arch-Bishop Lazarus" - quests[QTYPE_VB]._qactive = 3; - quests[QTYPE_VB]._qvar1 = 7; + quests[Q_BETRAYER]._qactive = QUEST_DONE; + quests[Q_BETRAYER]._qvar1 = 7; sfxdelay = 30; - quests[QTYPE_MOD]._qactive = 2; + quests[Q_DIABLO]._qactive = QUEST_ACTIVE; for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { @@ -322,16 +322,16 @@ void CheckQuestKill(int m, BOOL sendmsg) sfxdnum = PS_MAGE83; } if (sendmsg) { - NetSendCmdQuest(TRUE, QTYPE_VB); - NetSendCmdQuest(TRUE, QTYPE_MOD); + NetSendCmdQuest(TRUE, Q_BETRAYER); + NetSendCmdQuest(TRUE, Q_DIABLO); } } else if (monster[m].mName == UniqMonst[UMT_LAZURUS].mName && gbMaxPlayers == 1) { //"Arch-Bishop Lazarus" - quests[QTYPE_VB]._qactive = 3; + quests[Q_BETRAYER]._qactive = QUEST_DONE; sfxdelay = 30; InitVPTriggers(); - quests[QTYPE_VB]._qvar1 = 7; - quests[QTYPE_VB]._qvar2 = 4; - quests[QTYPE_MOD]._qactive = 2; + quests[Q_BETRAYER]._qvar1 = 7; + quests[Q_BETRAYER]._qvar2 = 4; + quests[Q_DIABLO]._qactive = QUEST_ACTIVE; AddMissile(35, 32, 35, 32, 0, MIS_RPORTAL, 0, myplr, 0, 0); if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR83; @@ -341,7 +341,7 @@ void CheckQuestKill(int m, BOOL sendmsg) sfxdnum = PS_MAGE83; } } else if (monster[m].mName == UniqMonst[UMT_WARLORD].mName) { //"Warlord of Blood" - quests[QTYPE_WARLRD]._qactive = 3; + quests[Q_WARLORD]._qactive = QUEST_DONE; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR94; @@ -519,25 +519,25 @@ void DRLG_CheckQuests(int x, int y) for (i = 0; i < MAXQUESTS; i++) { if (QuestStatus(i)) { switch (quests[i]._qtype) { - case QTYPE_BUTCH: + case Q_BUTCHER: DrawButcher(); break; - case QTYPE_BOL: + case Q_LTBANNER: DrawLTBanner(x, y); break; - case QTYPE_BLIND: + case Q_BLIND: DrawBlind(x, y); break; - case QTYPE_BLOOD: + case Q_BLOOD: DrawBlood(x, y); break; - case QTYPE_WARLRD: + case Q_WARLORD: DrawWarLord(x, y); break; - case QTYPE_KING: + case Q_SKELKING: DrawSkelKing(i, x, y); break; - case QTYPE_BONE: + case Q_SCHAMB: DrawSChamber(i, x, y); break; } @@ -549,27 +549,27 @@ void SetReturnLvlPos() { switch (setlvlnum) { case SL_SKELKING: - ReturnLvlX = quests[QTYPE_KING]._qtx + 1; - ReturnLvlY = quests[QTYPE_KING]._qty; - ReturnLvl = quests[QTYPE_KING]._qlevel; + ReturnLvlX = quests[Q_SKELKING]._qtx + 1; + ReturnLvlY = quests[Q_SKELKING]._qty; + ReturnLvl = quests[Q_SKELKING]._qlevel; ReturnLvlT = DTYPE_CATHEDRAL; break; case SL_BONECHAMB: - ReturnLvlX = quests[QTYPE_BONE]._qtx + 1; - ReturnLvlY = quests[QTYPE_BONE]._qty; - ReturnLvl = quests[QTYPE_BONE]._qlevel; + ReturnLvlX = quests[Q_SCHAMB]._qtx + 1; + ReturnLvlY = quests[Q_SCHAMB]._qty; + ReturnLvl = quests[Q_SCHAMB]._qlevel; ReturnLvlT = DTYPE_CATACOMBS; break; case SL_POISONWATER: - ReturnLvlX = quests[QTYPE_PW]._qtx; - ReturnLvlY = quests[QTYPE_PW]._qty + 1; - ReturnLvl = quests[QTYPE_PW]._qlevel; + ReturnLvlX = quests[Q_PWATER]._qtx; + ReturnLvlY = quests[Q_PWATER]._qty + 1; + ReturnLvl = quests[Q_PWATER]._qlevel; ReturnLvlT = DTYPE_CATHEDRAL; break; case SL_VILEBETRAYER: - ReturnLvlX = quests[QTYPE_VB]._qtx + 1; - ReturnLvlY = quests[QTYPE_VB]._qty - 1; - ReturnLvl = quests[QTYPE_VB]._qlevel; + ReturnLvlX = quests[Q_BETRAYER]._qtx + 1; + ReturnLvlY = quests[Q_BETRAYER]._qty - 1; + ReturnLvl = quests[Q_BETRAYER]._qlevel; ReturnLvlT = DTYPE_HELL; break; } @@ -577,8 +577,8 @@ void SetReturnLvlPos() void GetReturnLvlPos() { - if (quests[QTYPE_VB]._qactive == 3) - quests[QTYPE_VB]._qvar2 = 2; + if (quests[Q_BETRAYER]._qactive == QUEST_DONE) + quests[Q_BETRAYER]._qvar2 = 2; ViewX = ReturnLvlX; ViewY = ReturnLvlY; currlevel = ReturnLvl; @@ -588,23 +588,23 @@ void GetReturnLvlPos() void ResyncMPQuests() { #ifndef SPAWN - if (quests[QTYPE_KING]._qactive == 1 - && currlevel >= quests[QTYPE_KING]._qlevel - 1 - && currlevel <= quests[QTYPE_KING]._qlevel + 1) { - quests[QTYPE_KING]._qactive = 2; - NetSendCmdQuest(TRUE, QTYPE_KING); + if (quests[Q_SKELKING]._qactive == QUEST_INIT + && currlevel >= quests[Q_SKELKING]._qlevel - 1 + && currlevel <= quests[Q_SKELKING]._qlevel + 1) { + quests[Q_SKELKING]._qactive = QUEST_ACTIVE; + NetSendCmdQuest(TRUE, Q_SKELKING); } - if (quests[QTYPE_BUTCH]._qactive == 1 - && currlevel >= quests[QTYPE_BUTCH]._qlevel - 1 - && currlevel <= quests[QTYPE_BUTCH]._qlevel + 1) { - quests[QTYPE_BUTCH]._qactive = 2; - NetSendCmdQuest(TRUE, QTYPE_BUTCH); + if (quests[Q_BUTCHER]._qactive == QUEST_INIT + && currlevel >= quests[Q_BUTCHER]._qlevel - 1 + && currlevel <= quests[Q_BUTCHER]._qlevel + 1) { + quests[Q_BUTCHER]._qactive = QUEST_ACTIVE; + NetSendCmdQuest(TRUE, Q_BUTCHER); } - if (quests[QTYPE_VB]._qactive == 1 && currlevel == quests[QTYPE_VB]._qlevel - 1) { - quests[QTYPE_VB]._qactive = 2; - NetSendCmdQuest(TRUE, QTYPE_VB); + if (quests[Q_BETRAYER]._qactive == QUEST_INIT && currlevel == quests[Q_BETRAYER]._qlevel - 1) { + quests[Q_BETRAYER]._qactive = QUEST_ACTIVE; + NetSendCmdQuest(TRUE, Q_BETRAYER); } - if (QuestStatus(QTYPE_VB)) + if (QuestStatus(Q_BETRAYER)) AddObject(OBJ_ALTBOY, 2 * setpc_x + 20, 2 * setpc_y + 22); #endif } @@ -614,9 +614,9 @@ void ResyncQuests() #ifndef SPAWN int i, tren, x, y; - if (setlevel && setlvlnum == quests[QTYPE_PW]._qslvl && quests[QTYPE_PW]._qactive != 1 && leveltype == quests[QTYPE_PW]._qlvltype) { + if (setlevel && setlvlnum == quests[Q_PWATER]._qslvl && quests[Q_PWATER]._qactive != QUEST_INIT && leveltype == quests[Q_PWATER]._qlvltype) { - if (quests[QTYPE_PW]._qactive == 3) + if (quests[Q_PWATER]._qactive == QUEST_DONE) LoadPalette("Levels\\L3Data\\L3pwater.pal"); else LoadPalette("Levels\\L3Data\\L3pfoul.pal"); @@ -625,14 +625,14 @@ void ResyncQuests() palette_update_quest_palette(i); } - if (QuestStatus(QTYPE_BOL)) { - if (quests[QTYPE_BOL]._qvar1 == 1) + if (QuestStatus(Q_LTBANNER)) { + if (quests[Q_LTBANNER]._qvar1 == 1) ObjChangeMapResync( setpc_w + setpc_x - 2, setpc_h + setpc_y - 2, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1); - if (quests[QTYPE_BOL]._qvar1 == 2) { + if (quests[Q_LTBANNER]._qvar1 == 2) { ObjChangeMapResync( setpc_w + setpc_x - 2, setpc_h + setpc_y - 2, @@ -646,7 +646,7 @@ void ResyncQuests() DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 4, setpc_y + (setpc_h >> 1)); TransVal = tren; } - if (quests[QTYPE_BOL]._qvar1 == 3) { + if (quests[Q_LTBANNER]._qvar1 == 3) { x = setpc_x; y = setpc_y; ObjChangeMapResync(x, y, x + setpc_w + 1, y + setpc_h + 1); @@ -658,40 +658,40 @@ void ResyncQuests() TransVal = tren; } } - if (currlevel == quests[QTYPE_BLKM]._qlevel) { - if (quests[QTYPE_BLKM]._qactive == 1 && !quests[QTYPE_BLKM]._qvar1) { + if (currlevel == quests[Q_MUSHROOM]._qlevel) { + if (quests[Q_MUSHROOM]._qactive == QUEST_INIT && !quests[Q_MUSHROOM]._qvar1) { SpawnQuestItem(IDI_FUNGALTM, 0, 0, 5, 1); - quests[QTYPE_BLKM]._qvar1 = QS_TOMESPAWNED; + quests[Q_MUSHROOM]._qvar1 = QS_TOMESPAWNED; } else { - if (quests[QTYPE_BLKM]._qactive == 2) { - if (quests[QTYPE_BLKM]._qvar1 >= QS_MUSHGIVEN) { + if (quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) { + if (quests[Q_MUSHROOM]._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 = TEXT_MUSH3; + } else if (quests[Q_MUSHROOM]._qvar1 >= QS_BRAINGIVEN) { Qtalklist[TOWN_HEALER]._qblkm = -1; } } } } - if (currlevel == quests[QTYPE_VEIL]._qlevel + 1 && quests[QTYPE_VEIL]._qactive == 2 && !quests[QTYPE_VEIL]._qvar1) { - quests[QTYPE_VEIL]._qvar1 = 1; + if (currlevel == quests[Q_VEIL]._qlevel + 1 && quests[Q_VEIL]._qactive == QUEST_ACTIVE && !quests[Q_VEIL]._qvar1) { + quests[Q_VEIL]._qvar1 = 1; SpawnQuestItem(IDI_GLDNELIX, 0, 0, 5, 1); } if (setlevel && setlvlnum == SL_VILEBETRAYER) { - if (quests[QTYPE_VB]._qvar1 >= 4) + if (quests[Q_BETRAYER]._qvar1 >= 4) ObjChangeMapResync(1, 11, 20, 18); - if (quests[QTYPE_VB]._qvar1 >= 6) + if (quests[Q_BETRAYER]._qvar1 >= 6) ObjChangeMapResync(1, 18, 20, 24); - if (quests[QTYPE_VB]._qvar1 >= 7) + if (quests[Q_BETRAYER]._qvar1 >= 7) InitVPTriggers(); for (i = 0; i < nobjects; i++) SyncObjectAnim(objectactive[i]); } - if (currlevel == quests[QTYPE_VB]._qlevel + if (currlevel == quests[Q_BETRAYER]._qlevel && !setlevel - && (quests[QTYPE_VB]._qvar2 == 1 || quests[QTYPE_VB]._qvar2 >= 3) - && (quests[QTYPE_VB]._qactive == 2 || quests[QTYPE_VB]._qactive == 3)) { - quests[QTYPE_VB]._qvar2 = 2; + && (quests[Q_BETRAYER]._qvar2 == 1 || quests[Q_BETRAYER]._qvar2 >= 3) + && (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE || quests[Q_BETRAYER]._qactive == QUEST_DONE)) { + quests[Q_BETRAYER]._qvar2 = 2; } #endif } @@ -750,7 +750,7 @@ void StartQuestlog() numqlines = 0; for (i = 0; i < MAXQUESTS; i++) { - if (quests[i]._qactive == 2 && quests[i]._qlog) { + if (quests[i]._qactive == QUEST_ACTIVE && quests[i]._qlog) { qlist[numqlines] = i; numqlines++; } @@ -825,7 +825,7 @@ void QuestlogESC() void SetMultiQuest(int q, int s, int l, int v1) { #ifndef SPAWN - if (quests[q]._qactive != 3) { + if (quests[q]._qactive != QUEST_DONE) { if (s > quests[q]._qactive) quests[q]._qactive = s; quests[q]._qlog |= l; diff --git a/Source/setmaps.cpp b/Source/setmaps.cpp index 3a0b8735..286d6cd0 100644 --- a/Source/setmaps.cpp +++ b/Source/setmaps.cpp @@ -133,9 +133,9 @@ void LoadSetMap() { switch (setlvlnum) { case SL_SKELKING: - if (quests[QTYPE_KING]._qactive == 1) { - quests[QTYPE_KING]._qactive = 2; - quests[QTYPE_KING]._qvar1 = 1; + if (quests[Q_SKELKING]._qactive == QUEST_INIT) { + quests[Q_SKELKING]._qactive = QUEST_ACTIVE; + quests[Q_SKELKING]._qvar1 = 1; } LoadPreL1Dungeon("Levels\\L1Data\\SklKng1.DUN", 83, 45); LoadL1Dungeon("Levels\\L1Data\\SklKng2.DUN", 83, 45); @@ -167,18 +167,18 @@ void LoadSetMap() DRLG_SetMapTrans("Levels\\L1Data\\Lv1MazeA.DUN"); break; case SL_POISONWATER: - if (quests[QTYPE_PW]._qactive == 1) - quests[QTYPE_PW]._qactive = 2; + if (quests[Q_PWATER]._qactive == QUEST_INIT) + quests[Q_PWATER]._qactive = QUEST_ACTIVE; LoadPreL3Dungeon("Levels\\L3Data\\Foulwatr.DUN", 19, 50); LoadL3Dungeon("Levels\\L3Data\\Foulwatr.DUN", 20, 50); LoadPalette("Levels\\L3Data\\L3pfoul.pal"); InitPWaterTriggers(); break; case SL_VILEBETRAYER: - if (quests[QTYPE_VB]._qactive == 3) { - quests[QTYPE_VB]._qvar2 = 4; - } else if (quests[QTYPE_VB]._qactive == 2) { - quests[QTYPE_VB]._qvar2 = 3; + if (quests[Q_BETRAYER]._qactive == QUEST_DONE) { + quests[Q_BETRAYER]._qvar2 = 4; + } else if (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE) { + quests[Q_BETRAYER]._qvar2 = 3; } LoadPreL1Dungeon("Levels\\L1Data\\Vile1.DUN", 35, 36); LoadL1Dungeon("Levels\\L1Data\\Vile2.DUN", 35, 36); diff --git a/Source/stores.cpp b/Source/stores.cpp index 5bb86f53..fa02dbee 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -615,7 +615,7 @@ BOOL SmithSellOk(int i) return FALSE; if (plr[myplr].InvList[i]._itype == ITYPE_GOLD) return FALSE; - if (plr[myplr].InvList[i]._itype == ITYPE_0E) + if (plr[myplr].InvList[i]._itype == ITYPE_MEAT) return FALSE; if (plr[myplr].InvList[i]._itype == ITYPE_STAFF) return FALSE; @@ -723,7 +723,7 @@ BOOL SmithRepairOk(int i) return FALSE; if (plr[myplr].InvList[i]._itype == ITYPE_GOLD) return FALSE; - if (plr[myplr].InvList[i]._itype == ITYPE_0E) + if (plr[myplr].InvList[i]._itype == ITYPE_MEAT) return FALSE; if (plr[myplr].InvList[i]._iDurability == plr[myplr].InvList[i]._iMaxDur) return FALSE; @@ -1379,7 +1379,7 @@ void S_StartTalk() #else sn = 0; for (i = 0; i < MAXQUESTS; i++) { - if (quests[i]._qactive == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) + if (quests[i]._qactive == QUEST_ACTIVE && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) sn++; } @@ -1394,7 +1394,7 @@ void S_StartTalk() sn2 = sn - 2; for (i = 0; i < MAXQUESTS; i++) { - if (quests[i]._qactive == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) { + if (quests[i]._qactive == QUEST_ACTIVE && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) { AddSText(0, sn, 1, questlist[i]._qlstr, COL_WHITE, 1); sn += la; } @@ -1773,8 +1773,8 @@ void S_SmithEnter() talker = 0; stextlhold = 10; stextshold = STORE_SMITH; - gossipstart = QUEST_GRISWOLD2; - gossipend = QUEST_GRISWOLD13; + gossipstart = TEXT_GRISWOLD2; + gossipend = TEXT_GRISWOLD13; StartStore(STORE_GOSSIP); break; case 12: @@ -2167,8 +2167,8 @@ void S_WitchEnter() stextlhold = 12; talker = 6; stextshold = STORE_WITCH; - gossipstart = QUEST_ADRIA2; - gossipend = QUEST_ADRIA13; + gossipstart = TEXT_ADRIA2; + gossipend = TEXT_ADRIA13; StartStore(STORE_GOSSIP); return; case 14: @@ -2321,8 +2321,8 @@ void S_BoyEnter() talker = 8; stextshold = STORE_BOY; stextlhold = stextsel; - gossipstart = QUEST_WIRT2; - gossipend = QUEST_WIRT12; + gossipstart = TEXT_WIRT2; + gossipend = TEXT_WIRT12; StartStore(STORE_GOSSIP); } else { stextflag = STORE_NONE; @@ -2491,8 +2491,8 @@ void S_HealerEnter() stextlhold = 12; talker = 1; stextshold = STORE_HEALER; - gossipstart = QUEST_PEPIN2; - gossipend = QUEST_PEPIN11; + gossipstart = TEXT_PEPIN2; + gossipend = TEXT_PEPIN11; StartStore(STORE_GOSSIP); break; case 14: @@ -2550,8 +2550,8 @@ void S_StoryEnter() stextlhold = 12; talker = 4; stextshold = STORE_STORY; - gossipstart = QUEST_STORY2; - gossipend = QUEST_STORY11; + gossipstart = TEXT_STORY2; + gossipend = TEXT_STORY11; StartStore(STORE_GOSSIP); break; case 14: @@ -2595,7 +2595,7 @@ void S_TalkEnter() sn = 0; for (i = 0; i < MAXQUESTS; i++) { - if (quests[i]._qactive == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) + if (quests[i]._qactive == QUEST_ACTIVE && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) sn++; } if (sn > 6) { @@ -2614,7 +2614,7 @@ void S_TalkEnter() } for (i = 0; i < MAXQUESTS; i++) { - if (quests[i]._qactive == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) { + if (quests[i]._qactive == QUEST_ACTIVE && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) { if (sn == stextsel) { InitQTextMsg(((DWORD *)&Qtalklist[talker])[i]); } @@ -2630,8 +2630,8 @@ void S_TavernEnter() stextlhold = 12; talker = 3; stextshold = STORE_TAVERN; - gossipstart = QUEST_OGDEN2; - gossipend = QUEST_OGDEN10; + gossipstart = TEXT_OGDEN2; + gossipend = TEXT_OGDEN10; StartStore(STORE_GOSSIP); break; case 18: @@ -2647,8 +2647,8 @@ void S_BarmaidEnter() stextlhold = 12; talker = 7; stextshold = STORE_BARMAID; - gossipstart = QUEST_GILLIAN2; - gossipend = QUEST_GILLIAN10; + gossipstart = TEXT_GILLIAN2; + gossipend = TEXT_GILLIAN10; StartStore(STORE_GOSSIP); break; case 18: @@ -2664,8 +2664,8 @@ void S_DrunkEnter() stextlhold = 12; talker = 5; stextshold = STORE_DRUNK; - gossipstart = QUEST_FARNHAM2; - gossipend = QUEST_FARNHAM13; + gossipstart = TEXT_FARNHAM2; + gossipend = TEXT_FARNHAM13; StartStore(STORE_GOSSIP); break; case 18: diff --git a/Source/themes.cpp b/Source/themes.cpp index 4ebbf3b5..541e6355 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -431,7 +431,7 @@ void InitThemes() if (leveltype == DTYPE_CATACOMBS || leveltype == DTYPE_CAVES || leveltype == DTYPE_HELL) { for (i = 0; i < themeCount; i++) themes[i].ttype = THEME_NONE; - if (QuestStatus(QTYPE_ZHAR)) { + if (QuestStatus(Q_ZHAR)) { for (j = 0; j < themeCount; j++) { themes[j].ttval = themeLoc[j].ttval; if (SpecialThemeFit(j, THEME_LIBRARY)) { @@ -744,7 +744,7 @@ void Theme_Library(int t) } } - if (QuestStatus(QTYPE_ZHAR)) { + if (QuestStatus(Q_ZHAR)) { if (t == zharlib) { return; } diff --git a/Source/town.cpp b/Source/town.cpp index dc7904d5..148650e9 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -1623,7 +1623,7 @@ void T_Pass3() } #endif - if (quests[QTYPE_PW]._qactive != 3 && quests[QTYPE_PW]._qactive) { + if (quests[Q_PWATER]._qactive != QUEST_DONE && quests[Q_PWATER]._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 103271ef..6b8d6dd8 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -94,17 +94,17 @@ int cowoffy[8] = { -1, -1, -1, 0, -1, -1, -1, 0 }; QuestTalkData Qtalklist[11] = { // clang-format off // _qinfra, _qblkm, _qgarb, _qzhar, _qveil, _qmod, _qbutch, _qbol, _qblind, _qblood, _qanvil, _qwarlrd, _qking, _qpw, _qbone, _qvb - { QUEST_INFRA6, QUEST_MUSH6, -1, -1, QUEST_VEIL5, -1, QUEST_BUTCH5, QUEST_BANNER6, QUEST_BLIND5, QUEST_BLOOD5, QUEST_ANVIL6, QUEST_WARLRD5, QUEST_KING7, QUEST_POISON7, QUEST_BONE5, QUEST_VILE9 }, - { QUEST_INFRA3, -1, -1, -1, QUEST_VEIL3, -1, QUEST_BUTCH3, QUEST_BANNER4, QUEST_BLIND3, QUEST_BLOOD3, QUEST_ANVIL3, QUEST_WARLRD3, QUEST_KING5, QUEST_POISON4, QUEST_BONE3, QUEST_VILE7 }, + { TEXT_INFRA6, TEXT_MUSH6, -1, -1, TEXT_VEIL5, -1, TEXT_BUTCH5, TEXT_BANNER6, TEXT_BLIND5, TEXT_BLOOD5, TEXT_ANVIL6, TEXT_WARLRD5, TEXT_KING7, TEXT_POISON7, TEXT_BONE5, TEXT_VILE9 }, + { TEXT_INFRA3, -1, -1, -1, TEXT_VEIL3, -1, TEXT_BUTCH3, TEXT_BANNER4, TEXT_BLIND3, TEXT_BLOOD3, TEXT_ANVIL3, TEXT_WARLRD3, TEXT_KING5, TEXT_POISON4, TEXT_BONE3, TEXT_VILE7 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_INFRA2, QUEST_MUSH2, -1, -1, QUEST_VEIL2, -1, QUEST_BUTCH2, -1, QUEST_BLIND2, QUEST_BLOOD2, QUEST_ANVIL2, QUEST_WARLRD2, QUEST_KING3, QUEST_POISON2, QUEST_BONE2, QUEST_VILE4 }, - { QUEST_INFRA1, QUEST_MUSH1, -1, -1, QUEST_VEIL1, QUEST_VILE3, QUEST_BUTCH1, QUEST_BANNER1, QUEST_BLIND1, QUEST_BLOOD1, QUEST_ANVIL1, QUEST_WARLRD1, QUEST_KING1, QUEST_POISON1, QUEST_BONE1, QUEST_VILE2 }, - { QUEST_INFRA8, QUEST_MUSH7, -1, -1, QUEST_VEIL6, -1, QUEST_BUTCH6, QUEST_BANNER7, QUEST_BLIND6, QUEST_BLOOD6, QUEST_ANVIL8, QUEST_WARLRD6, QUEST_KING8, QUEST_POISON8, QUEST_BONE6, QUEST_VILE10 }, - { QUEST_INFRA9, QUEST_MUSH9, -1, -1, QUEST_VEIL7, -1, QUEST_BUTCH7, QUEST_BANNER8, QUEST_BLIND7, QUEST_BLOOD7, QUEST_ANVIL9, QUEST_WARLRD7, QUEST_KING9, QUEST_POISON9, QUEST_BONE7, QUEST_VILE11 }, - { QUEST_INFRA4, QUEST_MUSH5, -1, -1, QUEST_VEIL4, -1, QUEST_BUTCH4, QUEST_BANNER5, QUEST_BLIND4, QUEST_BLOOD4, QUEST_ANVIL4, QUEST_WARLRD4, QUEST_KING6, QUEST_POISON6, QUEST_BONE4, QUEST_VILE8 }, - { QUEST_INFRA10, QUEST_MUSH13, -1, -1, QUEST_VEIL8, -1, QUEST_BUTCH8, QUEST_BANNER9, QUEST_BLIND8, QUEST_BLOOD8, QUEST_ANVIL10,QUEST_WARLRD8, QUEST_KING10, QUEST_POISON10, QUEST_BONE8, QUEST_VILE12 }, + { TEXT_INFRA2, TEXT_MUSH2, -1, -1, TEXT_VEIL2, -1, TEXT_BUTCH2, -1, TEXT_BLIND2, TEXT_BLOOD2, TEXT_ANVIL2, TEXT_WARLRD2, TEXT_KING3, TEXT_POISON2, TEXT_BONE2, TEXT_VILE4 }, + { TEXT_INFRA1, TEXT_MUSH1, -1, -1, TEXT_VEIL1, TEXT_VILE3, TEXT_BUTCH1, TEXT_BANNER1, TEXT_BLIND1, TEXT_BLOOD1, TEXT_ANVIL1, TEXT_WARLRD1, TEXT_KING1, TEXT_POISON1, TEXT_BONE1, TEXT_VILE2 }, + { TEXT_INFRA8, TEXT_MUSH7, -1, -1, TEXT_VEIL6, -1, TEXT_BUTCH6, TEXT_BANNER7, TEXT_BLIND6, TEXT_BLOOD6, TEXT_ANVIL8, TEXT_WARLRD6, TEXT_KING8, TEXT_POISON8, TEXT_BONE6, TEXT_VILE10 }, + { TEXT_INFRA9, TEXT_MUSH9, -1, -1, TEXT_VEIL7, -1, TEXT_BUTCH7, TEXT_BANNER8, TEXT_BLIND7, TEXT_BLOOD7, TEXT_ANVIL9, TEXT_WARLRD7, TEXT_KING9, TEXT_POISON9, TEXT_BONE7, TEXT_VILE11 }, + { TEXT_INFRA4, TEXT_MUSH5, -1, -1, TEXT_VEIL4, -1, TEXT_BUTCH4, TEXT_BANNER5, TEXT_BLIND4, TEXT_BLOOD4, TEXT_ANVIL4, TEXT_WARLRD4, TEXT_KING6, TEXT_POISON6, TEXT_BONE4, TEXT_VILE8 }, + { TEXT_INFRA10, TEXT_MUSH13, -1, -1, TEXT_VEIL8, -1, TEXT_BUTCH8, TEXT_BANNER9, TEXT_BLIND8, TEXT_BLOOD8, TEXT_ANVIL10,TEXT_WARLRD8, TEXT_KING10, TEXT_POISON10, TEXT_BONE8, TEXT_VILE12 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1 } + { TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1 } // clang-format on }; int CowPlaying = -1; @@ -379,7 +379,7 @@ void InitTowners() boyloadflag = FALSE; InitSmith(); InitHealer(); - if (quests[QTYPE_BUTCH]._qactive && quests[QTYPE_BUTCH]._qactive != 3) + if (quests[Q_BUTCHER]._qactive && quests[Q_BUTCHER]._qactive != QUEST_DONE) InitTownDead(); InitBarOwner(); InitTeller(); @@ -446,7 +446,7 @@ void TownDead() tidx = GetActiveTowner(TOWN_DEADGUY); TownCtrlMsg(tidx); if (!qtextflag) { - if ((quests[QTYPE_BUTCH]._qactive != 2 || quests[QTYPE_BUTCH]._qlog) && quests[QTYPE_BUTCH]._qactive != 1) { + if ((quests[Q_BUTCHER]._qactive != QUEST_ACTIVE || quests[Q_BUTCHER]._qlog) && quests[Q_BUTCHER]._qactive != QUEST_INIT) { towner[tidx]._tAnimDelay = 1000; towner[tidx]._tAnimFrame = 1; strcpy(towner[tidx]._tName, "Slain Townsman"); @@ -454,7 +454,7 @@ void TownDead() return; } } - if (quests[QTYPE_BUTCH]._qactive != 1) + if (quests[Q_BUTCHER]._qactive != QUEST_INIT) towner[tidx]._tAnimCnt = 0; } @@ -625,68 +625,68 @@ void TalkToTowner(int p, int t) if (!plr[p]._pLvlVisited[0] && !towner[t]._tMsgSaid) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_INTRO); + InitQTextMsg(TEXT_INTRO); towner[t]._tMsgSaid = TRUE; } - if ((plr[p]._pLvlVisited[2] || plr[p]._pLvlVisited[4]) && quests[QTYPE_KING]._qactive != 0) { - if (quests[QTYPE_KING]._qvar2 == 0 && !towner[t]._tMsgSaid) { - quests[QTYPE_KING]._qvar2 = 1; - quests[QTYPE_KING]._qlog = TRUE; - if (quests[QTYPE_KING]._qactive == 1) { - quests[QTYPE_KING]._qactive = 2; - quests[QTYPE_KING]._qvar1 = 1; + if ((plr[p]._pLvlVisited[2] || plr[p]._pLvlVisited[4]) && quests[Q_SKELKING]._qactive != QUEST_NOTAVAIL) { + if (quests[Q_SKELKING]._qvar2 == 0 && !towner[t]._tMsgSaid) { + quests[Q_SKELKING]._qvar2 = 1; + quests[Q_SKELKING]._qlog = TRUE; + if (quests[Q_SKELKING]._qactive == QUEST_INIT) { + quests[Q_SKELKING]._qactive = QUEST_ACTIVE; + quests[Q_SKELKING]._qvar1 = 1; } towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_KING2); + InitQTextMsg(TEXT_KING2); towner[t]._tMsgSaid = TRUE; - NetSendCmdQuest(TRUE, QTYPE_KING); + NetSendCmdQuest(TRUE, Q_SKELKING); } - if (quests[QTYPE_KING]._qactive == 3 && quests[QTYPE_KING]._qvar2 == 1 && !towner[t]._tMsgSaid) { - quests[QTYPE_KING]._qvar2 = 2; - quests[QTYPE_KING]._qvar1 = 2; + if (quests[Q_SKELKING]._qactive == QUEST_DONE && quests[Q_SKELKING]._qvar2 == 1 && !towner[t]._tMsgSaid) { + quests[Q_SKELKING]._qvar2 = 2; + quests[Q_SKELKING]._qvar1 = 2; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_KING4); + InitQTextMsg(TEXT_KING4); towner[t]._tMsgSaid = TRUE; - NetSendCmdQuest(TRUE, QTYPE_KING); + NetSendCmdQuest(TRUE, Q_SKELKING); } } - if (gbMaxPlayers == 1 && plr[p]._pLvlVisited[3] && quests[QTYPE_BOL]._qactive != 0) { - if ((quests[QTYPE_BOL]._qactive == 1 || quests[QTYPE_BOL]._qactive == 2) && quests[QTYPE_BOL]._qvar2 == 0 && !towner[t]._tMsgSaid) { - quests[QTYPE_BOL]._qvar2 = 1; - if (quests[QTYPE_BOL]._qactive == 1) { - quests[QTYPE_BOL]._qvar1 = 1; - quests[QTYPE_BOL]._qactive = 2; + if (gbMaxPlayers == 1 && plr[p]._pLvlVisited[3] && quests[Q_LTBANNER]._qactive != QUEST_NOTAVAIL) { + if ((quests[Q_LTBANNER]._qactive == QUEST_INIT || quests[Q_LTBANNER]._qactive == QUEST_ACTIVE) && quests[Q_LTBANNER]._qvar2 == 0 && !towner[t]._tMsgSaid) { + quests[Q_LTBANNER]._qvar2 = 1; + if (quests[Q_LTBANNER]._qactive == QUEST_INIT) { + quests[Q_LTBANNER]._qvar1 = 1; + quests[Q_LTBANNER]._qactive = QUEST_ACTIVE; } - quests[QTYPE_BOL]._qlog = TRUE; + quests[Q_LTBANNER]._qlog = TRUE; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_BANNER2); + InitQTextMsg(TEXT_BANNER2); towner[t]._tMsgSaid = TRUE; } - if (quests[QTYPE_BOL]._qvar2 == 1 && PlrHasItem(p, IDI_BANNER, i) != NULL && !towner[t]._tMsgSaid) { - quests[QTYPE_BOL]._qactive = 3; - quests[QTYPE_BOL]._qvar1 = 3; + if (quests[Q_LTBANNER]._qvar2 == 1 && PlrHasItem(p, IDI_BANNER, i) != NULL && !towner[t]._tMsgSaid) { + quests[Q_LTBANNER]._qactive = QUEST_DONE; + quests[Q_LTBANNER]._qvar1 = 3; RemoveInvItem(p, i); CreateItem(UITEM_HARCREST, towner[t]._tx, towner[t]._ty + 1); towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_BANNER3); + InitQTextMsg(TEXT_BANNER3); towner[t]._tMsgSaid = TRUE; } } if (!qtextflag) { - TownerTalk(QUEST_OGDEN1, t); + TownerTalk(TEXT_OGDEN1, t); if (storeflag) { StartStore(STORE_TAVERN); } } } else if (t == GetActiveTowner(TOWN_DEADGUY)) { - if (quests[QTYPE_BUTCH]._qactive == 2 && quests[QTYPE_BUTCH]._qvar1 == 1) { + if (quests[Q_BUTCHER]._qactive == QUEST_ACTIVE && quests[Q_BUTCHER]._qvar1 == 1) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - quests[QTYPE_BUTCH]._qvar1 = 1; + quests[Q_BUTCHER]._qvar1 = 1; #ifndef SPAWN if (plr[p]._pClass == PC_WARRIOR && !effect_is_playing(PS_WARR8)) { PlaySFX(PS_WARR8); @@ -697,113 +697,113 @@ void TalkToTowner(int p, int t) } #endif towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_BUTCH]._qactive == 3 && quests[QTYPE_BUTCH]._qvar1 == 1) { - quests[QTYPE_BUTCH]._qvar1 = 1; + } else if (quests[Q_BUTCHER]._qactive == QUEST_DONE && quests[Q_BUTCHER]._qvar1 == 1) { + quests[Q_BUTCHER]._qvar1 = 1; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_BUTCH]._qactive == 1 || quests[QTYPE_BUTCH]._qactive == 2 && quests[QTYPE_BUTCH]._qvar1 == 0) { - quests[QTYPE_BUTCH]._qactive = 2; - quests[QTYPE_BUTCH]._qlog = TRUE; - quests[QTYPE_BUTCH]._qmsg = QUEST_BUTCH9; - quests[QTYPE_BUTCH]._qvar1 = 1; + } else if (quests[Q_BUTCHER]._qactive == QUEST_INIT || quests[Q_BUTCHER]._qactive == QUEST_ACTIVE && quests[Q_BUTCHER]._qvar1 == 0) { + quests[Q_BUTCHER]._qactive = QUEST_ACTIVE; + quests[Q_BUTCHER]._qlog = TRUE; + quests[Q_BUTCHER]._qmsg = TEXT_BUTCH9; + quests[Q_BUTCHER]._qvar1 = 1; towner[t]._tbtcnt = 50; towner[t]._tVar1 = p; towner[t]._tVar2 = 3; - InitQTextMsg(QUEST_BUTCH9); + InitQTextMsg(TEXT_BUTCH9); towner[t]._tMsgSaid = TRUE; - NetSendCmdQuest(TRUE, QTYPE_BUTCH); + NetSendCmdQuest(TRUE, Q_BUTCHER); } } else if (t == GetActiveTowner(TOWN_SMITH)) { if (gbMaxPlayers == 1) { - if (plr[p]._pLvlVisited[4] && quests[QTYPE_INFRA]._qactive != 0) { - if (quests[QTYPE_INFRA]._qvar2 == 0) { - quests[QTYPE_INFRA]._qvar2 = 1; - quests[QTYPE_INFRA]._qlog = TRUE; - if (quests[QTYPE_INFRA]._qactive == 1) { - quests[QTYPE_INFRA]._qactive = 2; - quests[QTYPE_INFRA]._qvar1 = 1; + if (plr[p]._pLvlVisited[4] && quests[Q_ROCK]._qactive != QUEST_NOTAVAIL) { + if (quests[Q_ROCK]._qvar2 == 0) { + quests[Q_ROCK]._qvar2 = 1; + quests[Q_ROCK]._qlog = TRUE; + if (quests[Q_ROCK]._qactive == QUEST_INIT) { + quests[Q_ROCK]._qactive = QUEST_ACTIVE; + quests[Q_ROCK]._qvar1 = 1; } towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_INFRA5); + InitQTextMsg(TEXT_INFRA5); towner[t]._tMsgSaid = TRUE; } - if (quests[QTYPE_INFRA]._qvar2 == 1 && PlrHasItem(p, IDI_ROCK, i) != NULL && !towner[t]._tMsgSaid) { - quests[QTYPE_INFRA]._qactive = 3; - quests[QTYPE_INFRA]._qvar2 = 2; - quests[QTYPE_INFRA]._qvar1 = 2; + if (quests[Q_ROCK]._qvar2 == 1 && PlrHasItem(p, IDI_ROCK, i) != NULL && !towner[t]._tMsgSaid) { + quests[Q_ROCK]._qactive = QUEST_DONE; + quests[Q_ROCK]._qvar2 = 2; + quests[Q_ROCK]._qvar1 = 2; RemoveInvItem(p, i); CreateItem(UITEM_INFRARING, towner[t]._tx, towner[t]._ty + 1); towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_INFRA7); + InitQTextMsg(TEXT_INFRA7); towner[t]._tMsgSaid = TRUE; } } - if (plr[p]._pLvlVisited[9] && quests[QTYPE_ANVIL]._qactive != 0) { - if ((quests[QTYPE_ANVIL]._qactive == 1 || quests[QTYPE_ANVIL]._qactive == 2) && quests[QTYPE_ANVIL]._qvar2 == 0 && !towner[t]._tMsgSaid) { - if (quests[QTYPE_INFRA]._qvar2 == 2 || quests[QTYPE_INFRA]._qactive == 2 && quests[QTYPE_INFRA]._qvar2 == 1) { - quests[QTYPE_ANVIL]._qvar2 = 1; - quests[QTYPE_ANVIL]._qlog = TRUE; - if (quests[QTYPE_ANVIL]._qactive == 1) { - quests[QTYPE_ANVIL]._qactive = 2; - quests[QTYPE_ANVIL]._qvar1 = 1; + if (plr[p]._pLvlVisited[9] && quests[Q_ANVIL]._qactive != QUEST_NOTAVAIL) { + if ((quests[Q_ANVIL]._qactive == QUEST_INIT || quests[Q_ANVIL]._qactive == QUEST_ACTIVE) && quests[Q_ANVIL]._qvar2 == 0 && !towner[t]._tMsgSaid) { + if (quests[Q_ROCK]._qvar2 == 2 || quests[Q_ROCK]._qactive == QUEST_ACTIVE && quests[Q_ROCK]._qvar2 == 1) { + quests[Q_ANVIL]._qvar2 = 1; + quests[Q_ANVIL]._qlog = TRUE; + if (quests[Q_ANVIL]._qactive == QUEST_INIT) { + quests[Q_ANVIL]._qactive = QUEST_ACTIVE; + quests[Q_ANVIL]._qvar1 = 1; } towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_ANVIL5); + InitQTextMsg(TEXT_ANVIL5); towner[t]._tMsgSaid = TRUE; } } - if (quests[QTYPE_ANVIL]._qvar2 == 1 && PlrHasItem(p, IDI_ANVIL, i) != NULL) { + if (quests[Q_ANVIL]._qvar2 == 1 && PlrHasItem(p, IDI_ANVIL, i) != NULL) { if (!towner[t]._tMsgSaid) { - quests[QTYPE_ANVIL]._qactive = 3; - quests[QTYPE_ANVIL]._qvar2 = 2; - quests[QTYPE_ANVIL]._qvar1 = 2; + quests[Q_ANVIL]._qactive = QUEST_DONE; + quests[Q_ANVIL]._qvar2 = 2; + quests[Q_ANVIL]._qvar1 = 2; RemoveInvItem(p, i); CreateItem(UITEM_GRISWOLD, towner[t]._tx, towner[t]._ty + 1); towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_ANVIL7); + InitQTextMsg(TEXT_ANVIL7); towner[t]._tMsgSaid = TRUE; } } } } if (!qtextflag) { - TownerTalk(QUEST_GRISWOLD1, t); + TownerTalk(TEXT_GRISWOLD1, t); if (storeflag) { StartStore(STORE_SMITH); } } } else if (t == GetActiveTowner(TOWN_WITCH)) { - if (quests[QTYPE_BLKM]._qactive == 1 && PlrHasItem(p, IDI_FUNGALTM, i) != NULL) { + if (quests[Q_MUSHROOM]._qactive == QUEST_INIT && PlrHasItem(p, IDI_FUNGALTM, i) != NULL) { RemoveInvItem(p, i); - quests[QTYPE_BLKM]._qactive = 2; - quests[QTYPE_BLKM]._qlog = TRUE; - quests[QTYPE_BLKM]._qvar1 = 2; + quests[Q_MUSHROOM]._qactive = QUEST_ACTIVE; + quests[Q_MUSHROOM]._qlog = TRUE; + quests[Q_MUSHROOM]._qvar1 = 2; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_MUSH8); + InitQTextMsg(TEXT_MUSH8); towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_BLKM]._qactive == 2) { - if (quests[QTYPE_BLKM]._qvar1 >= 2 && quests[QTYPE_BLKM]._qvar1 <= 4) { + } else if (quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) { + if (quests[Q_MUSHROOM]._qvar1 >= 2 && quests[Q_MUSHROOM]._qvar1 <= 4) { if (PlrHasItem(p, IDI_MUSHROOM, i) != NULL) { RemoveInvItem(p, i); - quests[QTYPE_BLKM]._qvar1 = 5; - Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3; + quests[Q_MUSHROOM]._qvar1 = 5; + Qtalklist[TOWN_HEALER]._qblkm = TEXT_MUSH3; Qtalklist[TOWN_WITCH]._qblkm = -1; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - quests[QTYPE_BLKM]._qmsg = QUEST_MUSH10; - InitQTextMsg(QUEST_MUSH10); + quests[Q_MUSHROOM]._qmsg = TEXT_MUSH10; + InitQTextMsg(TEXT_MUSH10); towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_BLKM]._qmsg != QUEST_MUSH9) { + } else if (quests[Q_MUSHROOM]._qmsg != TEXT_MUSH9) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - quests[QTYPE_BLKM]._qmsg = QUEST_MUSH9; - InitQTextMsg(QUEST_MUSH9); + quests[Q_MUSHROOM]._qmsg = TEXT_MUSH9; + InitQTextMsg(TEXT_MUSH9); towner[t]._tMsgSaid = TRUE; } } else { @@ -811,35 +811,35 @@ void TalkToTowner(int p, int t) if (Item != NULL) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_MUSH12); - quests[QTYPE_BLKM]._qactive = 3; + InitQTextMsg(TEXT_MUSH12); + quests[Q_MUSHROOM]._qactive = QUEST_DONE; towner[t]._tMsgSaid = TRUE; AllItemsList[Item->IDidx].iUsable = TRUE; - } else if (PlrHasItem(p, IDI_BRAIN, i) != NULL && quests[QTYPE_BLKM]._qvar2 != QUEST_MUSH11) { + } else if (PlrHasItem(p, IDI_BRAIN, i) != NULL && quests[Q_MUSHROOM]._qvar2 != TEXT_MUSH11) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - quests[QTYPE_BLKM]._qvar2 = QUEST_MUSH11; - InitQTextMsg(QUEST_MUSH11); + quests[Q_MUSHROOM]._qvar2 = TEXT_MUSH11; + InitQTextMsg(TEXT_MUSH11); towner[t]._tMsgSaid = TRUE; } } } if (!qtextflag) { - TownerTalk(QUEST_ADRIA1, t); + TownerTalk(TEXT_ADRIA1, t); if (storeflag) { StartStore(STORE_WITCH); } } } else if (t == GetActiveTowner(TOWN_BMAID)) { if (!qtextflag) { - TownerTalk(QUEST_GILLIAN1, t); + TownerTalk(TEXT_GILLIAN1, t); if (storeflag) { StartStore(STORE_BARMAID); } } } else if (t == GetActiveTowner(TOWN_DRUNK)) { if (!qtextflag) { - TownerTalk(QUEST_FARNHAM1, t); + TownerTalk(TEXT_FARNHAM1, t); if (storeflag) { StartStore(STORE_DRUNK); } @@ -847,86 +847,86 @@ void TalkToTowner(int p, int t) } else if (t == GetActiveTowner(TOWN_HEALER)) { if (gbMaxPlayers == 1) { if (plr[p]._pLvlVisited[1] && !towner[t]._tMsgSaid) { - if (quests[QTYPE_PW]._qactive == 1) { - quests[QTYPE_PW]._qactive = 2; - quests[QTYPE_PW]._qlog = TRUE; - quests[QTYPE_PW]._qmsg = QUEST_POISON3; - quests[QTYPE_PW]._qvar1 = 1; + if (quests[Q_PWATER]._qactive == QUEST_INIT) { + quests[Q_PWATER]._qactive = QUEST_ACTIVE; + quests[Q_PWATER]._qlog = TRUE; + quests[Q_PWATER]._qmsg = TEXT_POISON3; + quests[Q_PWATER]._qvar1 = 1; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_POISON3); + InitQTextMsg(TEXT_POISON3); towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_PW]._qactive == 3 && quests[QTYPE_PW]._qvar1 != 2) { - quests[QTYPE_PW]._qvar1 = 2; + } else if (quests[Q_PWATER]._qactive == QUEST_DONE && quests[Q_PWATER]._qvar1 != 2) { + quests[Q_PWATER]._qvar1 = 2; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_POISON5); + InitQTextMsg(TEXT_POISON5); CreateItem(UITEM_TRING, towner[t]._tx, towner[t]._ty + 1); towner[t]._tMsgSaid = TRUE; } } - if (quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qmsg == QUEST_MUSH10 && PlrHasItem(p, IDI_BRAIN, i) != NULL) { + if (quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE && quests[Q_MUSHROOM]._qmsg == TEXT_MUSH10 && PlrHasItem(p, IDI_BRAIN, i) != NULL) { RemoveInvItem(p, i); SpawnQuestItem(IDI_SPECELIX, towner[t]._tx, towner[t]._ty + 1, 0, 0); - InitQTextMsg(QUEST_MUSH4); - quests[QTYPE_BLKM]._qvar1 = 7; + InitQTextMsg(TEXT_MUSH4); + quests[Q_MUSHROOM]._qvar1 = 7; Qtalklist[TOWN_HEALER]._qblkm = -1; } } if (!qtextflag) { - TownerTalk(QUEST_PEPIN1, t); + TownerTalk(TEXT_PEPIN1, t); if (storeflag) { StartStore(STORE_HEALER); } } } else if (t == GetActiveTowner(TOWN_PEGBOY)) { if (!qtextflag) { - TownerTalk(QUEST_WIRT1, t); + TownerTalk(TEXT_WIRT1, t); if (storeflag) { StartStore(STORE_BOY); } } } else if (t == GetActiveTowner(TOWN_STORY)) { if (gbMaxPlayers == 1) { - if (quests[QTYPE_VB]._qactive == 1 && PlrHasItem(p, IDI_LAZSTAFF, i) != NULL) { + if (quests[Q_BETRAYER]._qactive == QUEST_INIT && PlrHasItem(p, IDI_LAZSTAFF, i) != NULL) { RemoveInvItem(p, i); - quests[QTYPE_VB]._qvar1 = 2; + quests[Q_BETRAYER]._qvar1 = 2; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_VILE1); - quests[QTYPE_VB]._qactive = 2; - quests[QTYPE_VB]._qlog = TRUE; + InitQTextMsg(TEXT_VILE1); + quests[Q_BETRAYER]._qactive = QUEST_ACTIVE; + quests[Q_BETRAYER]._qlog = TRUE; towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_VB]._qactive == 3 && quests[QTYPE_VB]._qvar1 == 7) { - quests[QTYPE_VB]._qvar1 = 8; + } else if (quests[Q_BETRAYER]._qactive == QUEST_DONE && quests[Q_BETRAYER]._qvar1 == 7) { + quests[Q_BETRAYER]._qvar1 = 8; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_VILE3); - quests[QTYPE_MOD]._qlog = TRUE; + InitQTextMsg(TEXT_VILE3); + quests[Q_DIABLO]._qlog = TRUE; towner[t]._tMsgSaid = TRUE; } } if (gbMaxPlayers != 1) { - if (quests[QTYPE_VB]._qactive == 2 && !quests[QTYPE_VB]._qlog) { + if (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE && !quests[Q_BETRAYER]._qlog) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_VILE1); + InitQTextMsg(TEXT_VILE1); towner[t]._tMsgSaid = TRUE; - quests[QTYPE_VB]._qlog = TRUE; - NetSendCmdQuest(TRUE, QTYPE_VB); - } else if (quests[QTYPE_VB]._qactive == 3 && quests[QTYPE_VB]._qvar1 == 7) { - quests[QTYPE_VB]._qvar1 = 8; + quests[Q_BETRAYER]._qlog = TRUE; + NetSendCmdQuest(TRUE, Q_BETRAYER); + } else if (quests[Q_BETRAYER]._qactive == QUEST_DONE && quests[Q_BETRAYER]._qvar1 == 7) { + quests[Q_BETRAYER]._qvar1 = 8; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_VILE3); + InitQTextMsg(TEXT_VILE3); towner[t]._tMsgSaid = TRUE; - NetSendCmdQuest(TRUE, QTYPE_VB); - quests[QTYPE_MOD]._qlog = TRUE; - NetSendCmdQuest(TRUE, QTYPE_MOD); + NetSendCmdQuest(TRUE, Q_BETRAYER); + quests[Q_DIABLO]._qlog = TRUE; + NetSendCmdQuest(TRUE, Q_DIABLO); } } if (!qtextflag) { - TownerTalk(QUEST_STORY1, t); + TownerTalk(TEXT_STORY1, t); if (storeflag) { StartStore(STORE_STORY); } diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 04447c0b..c005a371 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -189,7 +189,7 @@ void InitL2Triggers() numtrigs = 0; for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { - if (dPiece[i][j] == 267 && (i != quests[QTYPE_BONE]._qtx || j != quests[QTYPE_BONE]._qty)) { + if (dPiece[i][j] == 267 && (i != quests[Q_SCHAMB]._qtx || j != quests[Q_SCHAMB]._qty)) { trigs[numtrigs]._tx = i; trigs[numtrigs]._ty = j; trigs[numtrigs]._tmsg = WM_DIABPREVLVL; @@ -280,7 +280,7 @@ void InitL4Triggers() for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { - if (dPiece[i][j] == 370 && quests[QTYPE_VB]._qactive == 3) { + if (dPiece[i][j] == 370 && quests[Q_BETRAYER]._qactive == QUEST_DONE) { trigs[numtrigs]._tx = i; trigs[numtrigs]._ty = j; trigs[numtrigs]._tmsg = WM_DIABNEXTLVL; @@ -612,7 +612,7 @@ BOOL ForceSKingTrig() for (i = 0; L1UpList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L1UpList[i]) { - sprintf(infostr, "Back to Level %i", quests[QTYPE_KING]._qlevel); + sprintf(infostr, "Back to Level %i", quests[Q_SKELKING]._qlevel); cursmx = trigs[0]._tx; cursmy = trigs[0]._ty; @@ -629,7 +629,7 @@ BOOL ForceSChambTrig() for (i = 0; L2DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L2DownList[i]) { - sprintf(infostr, "Back to Level %i", quests[QTYPE_BONE]._qlevel); + sprintf(infostr, "Back to Level %i", quests[Q_SCHAMB]._qlevel); cursmx = trigs[0]._tx; cursmy = trigs[0]._ty; @@ -646,7 +646,7 @@ BOOL ForcePWaterTrig() for (i = 0; L3DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L3DownList[i]) { - sprintf(infostr, "Back to Level %i", quests[QTYPE_PW]._qlevel); + sprintf(infostr, "Back to Level %i", quests[Q_PWATER]._qlevel); cursmx = trigs[0]._tx; cursmy = trigs[0]._ty; diff --git a/comparer-config/diablo.toml b/comparer-config/diablo.toml index 0ea60516..5a3b9c37 100644 --- a/comparer-config/diablo.toml +++ b/comparer-config/diablo.toml @@ -5243,7 +5243,7 @@ addr = 0x43BD19 size = 0xD2 [[func]] -name = "msg_process_net_packets" +name = "run_delta_info" addr = 0x43BDEB size = 0x22 @@ -5438,7 +5438,7 @@ addr = 0x43D064 size = 0x39 [[func]] -name = "RemovePlrPortal" +name = "delta_close_portal" addr = 0x43D09D size = 0x1F diff --git a/comparer-config/spawn.toml b/comparer-config/spawn.toml index 7d0685ef..ae5877e2 100644 --- a/comparer-config/spawn.toml +++ b/comparer-config/spawn.toml @@ -4653,7 +4653,7 @@ addr = 0x432327 size = 0xD2 [[func]] -name = "msg_process_net_packets" +name = "run_delta_info" addr = 0x4323F9 size = 0x22 @@ -4848,7 +4848,7 @@ addr = 0x433672 size = 0x39 [[func]] -name = "RemovePlrPortal" +name = "delta_close_portal" addr = 0x4336AB size = 0x1F diff --git a/enums.h b/enums.h index 257cb532..0ecfd684 100644 --- a/enums.h +++ b/enums.h @@ -1544,265 +1544,265 @@ typedef enum missile_resistance { } missile_resistance; typedef enum _speech_id { - QUEST_KING1 = 0x0, - QUEST_KING2 = 0x1, - QUEST_KING3 = 0x2, - QUEST_KING4 = 0x3, - QUEST_KING5 = 0x4, - QUEST_KING6 = 0x5, - QUEST_KING7 = 0x6, - QUEST_KING8 = 0x7, - QUEST_KING9 = 0x8, - QUEST_KING10 = 0x9, - QUEST_KING11 = 0xA, - QUEST_BANNER1 = 0xB, - QUEST_BANNER2 = 0xC, - QUEST_BANNER3 = 0xD, - QUEST_BANNER4 = 0xE, - QUEST_BANNER5 = 0xF, - QUEST_BANNER6 = 0x10, - QUEST_BANNER7 = 0x11, - QUEST_BANNER8 = 0x12, - QUEST_BANNER9 = 0x13, - QUEST_BANNER10 = 0x14, - QUEST_BANNER11 = 0x15, - QUEST_BANNER12 = 0x16, - QUEST_VILE1 = 0x17, - QUEST_VILE2 = 0x18, - QUEST_VILE3 = 0x19, - QUEST_VILE4 = 0x1A, - QUEST_VILE5 = 0x1B, - QUEST_VILE6 = 0x1C, - QUEST_VILE7 = 0x1D, - QUEST_VILE8 = 0x1E, - QUEST_VILE9 = 0x1F, - QUEST_VILE10 = 0x20, - QUEST_VILE11 = 0x21, - QUEST_VILE12 = 0x22, - QUEST_VILE13 = 0x23, - QUEST_VILE14 = 0x24, - QUEST_POISON1 = 0x25, - QUEST_POISON2 = 0x26, - QUEST_POISON3 = 0x27, - QUEST_POISON4 = 0x28, - QUEST_POISON5 = 0x29, - QUEST_POISON6 = 0x2A, - QUEST_POISON7 = 0x2B, - QUEST_POISON8 = 0x2C, - QUEST_POISON9 = 0x2D, - QUEST_POISON10 = 0x2E, - QUEST_BONE1 = 0x2F, - QUEST_BONE2 = 0x30, - QUEST_BONE3 = 0x31, - QUEST_BONE4 = 0x32, - QUEST_BONE5 = 0x33, - QUEST_BONE6 = 0x34, - QUEST_BONE7 = 0x35, - QUEST_BONE8 = 0x36, - QUEST_BUTCH1 = 0x37, - QUEST_BUTCH2 = 0x38, - QUEST_BUTCH3 = 0x39, - QUEST_BUTCH4 = 0x3A, - QUEST_BUTCH5 = 0x3B, - QUEST_BUTCH6 = 0x3C, - QUEST_BUTCH7 = 0x3D, - QUEST_BUTCH8 = 0x3E, - QUEST_BUTCH9 = 0x3F, - QUEST_BUTCH10 = 0x40, - QUEST_BLIND1 = 0x41, - QUEST_BLIND2 = 0x42, - QUEST_BLIND3 = 0x43, - QUEST_BLIND4 = 0x44, - QUEST_BLIND5 = 0x45, - QUEST_BLIND6 = 0x46, - QUEST_BLIND7 = 0x47, - QUEST_BLIND8 = 0x48, - QUEST_VEIL1 = 0x49, - QUEST_VEIL2 = 0x4A, - QUEST_VEIL3 = 0x4B, - QUEST_VEIL4 = 0x4C, - QUEST_VEIL5 = 0x4D, - QUEST_VEIL6 = 0x4E, - QUEST_VEIL7 = 0x4F, - QUEST_VEIL8 = 0x50, - QUEST_VEIL9 = 0x51, - QUEST_VEIL10 = 0x52, - QUEST_VEIL11 = 0x53, - QUEST_ANVIL1 = 0x54, - QUEST_ANVIL2 = 0x55, - QUEST_ANVIL3 = 0x56, - QUEST_ANVIL4 = 0x57, - QUEST_ANVIL5 = 0x58, - QUEST_ANVIL6 = 0x59, - QUEST_ANVIL7 = 0x5A, - QUEST_ANVIL8 = 0x5B, - QUEST_ANVIL9 = 0x5C, - QUEST_ANVIL10 = 0x5D, - QUEST_BLOOD1 = 0x5E, - QUEST_BLOOD2 = 0x5F, - QUEST_BLOOD3 = 0x60, - QUEST_BLOOD4 = 0x61, - QUEST_BLOOD5 = 0x62, - QUEST_BLOOD6 = 0x63, - QUEST_BLOOD7 = 0x64, - QUEST_BLOOD8 = 0x65, - QUEST_WARLRD1 = 0x66, - QUEST_WARLRD2 = 0x67, - QUEST_WARLRD3 = 0x68, - QUEST_WARLRD4 = 0x69, - QUEST_WARLRD5 = 0x6A, - QUEST_WARLRD6 = 0x6B, - QUEST_WARLRD7 = 0x6C, - QUEST_WARLRD8 = 0x6D, - QUEST_WARLRD9 = 0x6E, - QUEST_INFRA1 = 0x6F, - QUEST_INFRA2 = 0x70, - QUEST_INFRA3 = 0x71, - QUEST_INFRA4 = 0x72, - QUEST_INFRA5 = 0x73, - QUEST_INFRA6 = 0x74, - QUEST_INFRA7 = 0x75, - QUEST_INFRA8 = 0x76, - QUEST_INFRA9 = 0x77, - QUEST_INFRA10 = 0x78, - QUEST_MUSH1 = 0x79, - QUEST_MUSH2 = 0x7A, - QUEST_MUSH3 = 0x7B, - QUEST_MUSH4 = 0x7C, - QUEST_MUSH5 = 0x7D, - QUEST_MUSH6 = 0x7E, - QUEST_MUSH7 = 0x7F, - QUEST_MUSH8 = 0x80, - QUEST_MUSH9 = 0x81, - QUEST_MUSH10 = 0x82, - QUEST_MUSH11 = 0x83, - QUEST_MUSH12 = 0x84, - QUEST_MUSH13 = 0x85, - QUEST_DOOM1 = 0x86, - QUEST_DOOM2 = 0x87, - QUEST_DOOM3 = 0x88, - QUEST_DOOM4 = 0x89, - QUEST_DOOM5 = 0x8A, - QUEST_DOOM6 = 0x8B, - QUEST_DOOM7 = 0x8C, - QUEST_DOOM8 = 0x8D, - QUEST_DOOM9 = 0x8E, - QUEST_DOOM10 = 0x8F, - QUEST_GARBUD1 = 0x90, - QUEST_GARBUD2 = 0x91, - QUEST_GARBUD3 = 0x92, - QUEST_GARBUD4 = 0x93, - QUEST_ZHAR1 = 0x94, - QUEST_ZHAR2 = 0x95, - QUEST_STORY1 = 0x96, - QUEST_STORY2 = 0x97, - QUEST_STORY3 = 0x98, - QUEST_STORY4 = 0x99, - QUEST_STORY5 = 0x9A, - QUEST_STORY6 = 0x9B, - QUEST_STORY7 = 0x9C, - QUEST_STORY9 = 0x9D, - QUEST_STORY10 = 0x9E, - QUEST_STORY11 = 0x9F, - QUEST_OGDEN1 = 0xA0, - QUEST_OGDEN2 = 0xA1, - QUEST_OGDEN3 = 0xA2, - QUEST_OGDEN4 = 0xA3, - QUEST_OGDEN5 = 0xA4, - QUEST_OGDEN6 = 0xA5, - QUEST_OGDEN8 = 0xA6, - QUEST_OGDEN9 = 0xA7, - QUEST_OGDEN10 = 0xA8, - QUEST_PEPIN1 = 0xA9, - QUEST_PEPIN2 = 0xAA, - QUEST_PEPIN3 = 0xAB, - QUEST_PEPIN4 = 0xAC, - QUEST_PEPIN5 = 0xAD, - QUEST_PEPIN6 = 0xAE, - QUEST_PEPIN7 = 0xAF, - QUEST_PEPIN9 = 0xB0, - QUEST_PEPIN10 = 0xB1, - QUEST_PEPIN11 = 0xB2, - QUEST_GILLIAN1 = 0xB3, - QUEST_GILLIAN2 = 0xB4, - QUEST_GILLIAN3 = 0xB5, - QUEST_GILLIAN4 = 0xB6, - QUEST_GILLIAN5 = 0xB7, - QUEST_GILLIAN6 = 0xB8, - QUEST_GILLIAN7 = 0xB9, - QUEST_GILLIAN9 = 0xBA, - QUEST_GILLIAN10 = 0xBB, - QUEST_GRISWOLD1 = 0xBC, - QUEST_GRISWOLD2 = 0xBD, - QUEST_GRISWOLD3 = 0xBE, - QUEST_GRISWOLD4 = 0xBF, - QUEST_GRISWOLD5 = 0xC0, - QUEST_GRISWOLD6 = 0xC1, - QUEST_GRISWOLD7 = 0xC2, - QUEST_GRISWOLD8 = 0xC3, - QUEST_GRISWOLD9 = 0xC4, - QUEST_GRISWOLD10 = 0xC5, - QUEST_GRISWOLD12 = 0xC6, - QUEST_GRISWOLD13 = 0xC7, - QUEST_FARNHAM1 = 0xC8, - QUEST_FARNHAM2 = 0xC9, - QUEST_FARNHAM3 = 0xCA, - QUEST_FARNHAM4 = 0xCB, - QUEST_FARNHAM5 = 0xCC, - QUEST_FARNHAM6 = 0xCD, - QUEST_FARNHAM8 = 0xCE, - QUEST_FARNHAM9 = 0xCF, - QUEST_FARNHAM10 = 0xD0, - QUEST_FARNHAM11 = 0xD1, - QUEST_FARNHAM12 = 0xD2, - QUEST_FARNHAM13 = 0xD3, - QUEST_ADRIA1 = 0xD4, - QUEST_ADRIA2 = 0xD5, - QUEST_ADRIA3 = 0xD6, - QUEST_ADRIA4 = 0xD7, - QUEST_ADRIA5 = 0xD8, - QUEST_ADRIA6 = 0xD9, - QUEST_ADRIA7 = 0xDA, - QUEST_ADRIA8 = 0xDB, - QUEST_ADRIA9 = 0xDC, - QUEST_ADRIA10 = 0xDD, - QUEST_ADRIA12 = 0xDE, - QUEST_ADRIA13 = 0xDF, - QUEST_WIRT1 = 0xE0, - QUEST_WIRT2 = 0xE1, - QUEST_WIRT3 = 0xE2, - QUEST_WIRT4 = 0xE3, - QUEST_WIRT5 = 0xE4, - QUEST_WIRT6 = 0xE5, - QUEST_WIRT7 = 0xE6, - QUEST_WIRT8 = 0xE7, - QUEST_WIRT9 = 0xE8, - QUEST_WIRT11 = 0xE9, - QUEST_WIRT12 = 0xEA, - QUEST_BONER = 0xEB, - QUEST_BLOODY = 0xEC, - QUEST_BLINDING = 0xED, - QUEST_BLOODWAR = 0xEE, - QUEST_MBONER = 0xEF, - QUEST_MBLOODY = 0xF0, - QUEST_MBLINDING = 0xF1, - QUEST_MBLOODWAR = 0xF2, - QUEST_RBONER = 0xF3, - QUEST_RBLOODY = 0xF4, - QUEST_RBLINDING = 0xF5, - QUEST_RBLOODWAR = 0xF6, - QUEST_COW1 = 0xF7, - QUEST_COW2 = 0xF8, - QUEST_BOOK11 = 0xF9, - QUEST_BOOK12 = 0xFA, - QUEST_BOOK13 = 0xFB, - QUEST_BOOK21 = 0xFC, - QUEST_BOOK22 = 0xFD, - QUEST_BOOK23 = 0xFE, - QUEST_BOOK31 = 0xFF, - QUEST_BOOK32 = 0x100, - QUEST_BOOK33 = 0x101, - QUEST_INTRO = 0x102 + TEXT_KING1 = 0x0, + TEXT_KING2 = 0x1, + TEXT_KING3 = 0x2, + TEXT_KING4 = 0x3, + TEXT_KING5 = 0x4, + TEXT_KING6 = 0x5, + TEXT_KING7 = 0x6, + TEXT_KING8 = 0x7, + TEXT_KING9 = 0x8, + TEXT_KING10 = 0x9, + TEXT_KING11 = 0xA, + TEXT_BANNER1 = 0xB, + TEXT_BANNER2 = 0xC, + TEXT_BANNER3 = 0xD, + TEXT_BANNER4 = 0xE, + TEXT_BANNER5 = 0xF, + TEXT_BANNER6 = 0x10, + TEXT_BANNER7 = 0x11, + TEXT_BANNER8 = 0x12, + TEXT_BANNER9 = 0x13, + TEXT_BANNER10 = 0x14, + TEXT_BANNER11 = 0x15, + TEXT_BANNER12 = 0x16, + TEXT_VILE1 = 0x17, + TEXT_VILE2 = 0x18, + TEXT_VILE3 = 0x19, + TEXT_VILE4 = 0x1A, + TEXT_VILE5 = 0x1B, + TEXT_VILE6 = 0x1C, + TEXT_VILE7 = 0x1D, + TEXT_VILE8 = 0x1E, + TEXT_VILE9 = 0x1F, + TEXT_VILE10 = 0x20, + TEXT_VILE11 = 0x21, + TEXT_VILE12 = 0x22, + TEXT_VILE13 = 0x23, + TEXT_VILE14 = 0x24, + TEXT_POISON1 = 0x25, + TEXT_POISON2 = 0x26, + TEXT_POISON3 = 0x27, + TEXT_POISON4 = 0x28, + TEXT_POISON5 = 0x29, + TEXT_POISON6 = 0x2A, + TEXT_POISON7 = 0x2B, + TEXT_POISON8 = 0x2C, + TEXT_POISON9 = 0x2D, + TEXT_POISON10 = 0x2E, + TEXT_BONE1 = 0x2F, + TEXT_BONE2 = 0x30, + TEXT_BONE3 = 0x31, + TEXT_BONE4 = 0x32, + TEXT_BONE5 = 0x33, + TEXT_BONE6 = 0x34, + TEXT_BONE7 = 0x35, + TEXT_BONE8 = 0x36, + TEXT_BUTCH1 = 0x37, + TEXT_BUTCH2 = 0x38, + TEXT_BUTCH3 = 0x39, + TEXT_BUTCH4 = 0x3A, + TEXT_BUTCH5 = 0x3B, + TEXT_BUTCH6 = 0x3C, + TEXT_BUTCH7 = 0x3D, + TEXT_BUTCH8 = 0x3E, + TEXT_BUTCH9 = 0x3F, + TEXT_BUTCH10 = 0x40, + TEXT_BLIND1 = 0x41, + TEXT_BLIND2 = 0x42, + TEXT_BLIND3 = 0x43, + TEXT_BLIND4 = 0x44, + TEXT_BLIND5 = 0x45, + TEXT_BLIND6 = 0x46, + TEXT_BLIND7 = 0x47, + TEXT_BLIND8 = 0x48, + TEXT_VEIL1 = 0x49, + TEXT_VEIL2 = 0x4A, + TEXT_VEIL3 = 0x4B, + TEXT_VEIL4 = 0x4C, + TEXT_VEIL5 = 0x4D, + TEXT_VEIL6 = 0x4E, + TEXT_VEIL7 = 0x4F, + TEXT_VEIL8 = 0x50, + TEXT_VEIL9 = 0x51, + TEXT_VEIL10 = 0x52, + TEXT_VEIL11 = 0x53, + TEXT_ANVIL1 = 0x54, + TEXT_ANVIL2 = 0x55, + TEXT_ANVIL3 = 0x56, + TEXT_ANVIL4 = 0x57, + TEXT_ANVIL5 = 0x58, + TEXT_ANVIL6 = 0x59, + TEXT_ANVIL7 = 0x5A, + TEXT_ANVIL8 = 0x5B, + TEXT_ANVIL9 = 0x5C, + TEXT_ANVIL10 = 0x5D, + TEXT_BLOOD1 = 0x5E, + TEXT_BLOOD2 = 0x5F, + TEXT_BLOOD3 = 0x60, + TEXT_BLOOD4 = 0x61, + TEXT_BLOOD5 = 0x62, + TEXT_BLOOD6 = 0x63, + TEXT_BLOOD7 = 0x64, + TEXT_BLOOD8 = 0x65, + TEXT_WARLRD1 = 0x66, + TEXT_WARLRD2 = 0x67, + TEXT_WARLRD3 = 0x68, + TEXT_WARLRD4 = 0x69, + TEXT_WARLRD5 = 0x6A, + TEXT_WARLRD6 = 0x6B, + TEXT_WARLRD7 = 0x6C, + TEXT_WARLRD8 = 0x6D, + TEXT_WARLRD9 = 0x6E, + TEXT_INFRA1 = 0x6F, + TEXT_INFRA2 = 0x70, + TEXT_INFRA3 = 0x71, + TEXT_INFRA4 = 0x72, + TEXT_INFRA5 = 0x73, + TEXT_INFRA6 = 0x74, + TEXT_INFRA7 = 0x75, + TEXT_INFRA8 = 0x76, + TEXT_INFRA9 = 0x77, + TEXT_INFRA10 = 0x78, + TEXT_MUSH1 = 0x79, + TEXT_MUSH2 = 0x7A, + TEXT_MUSH3 = 0x7B, + TEXT_MUSH4 = 0x7C, + TEXT_MUSH5 = 0x7D, + TEXT_MUSH6 = 0x7E, + TEXT_MUSH7 = 0x7F, + TEXT_MUSH8 = 0x80, + TEXT_MUSH9 = 0x81, + TEXT_MUSH10 = 0x82, + TEXT_MUSH11 = 0x83, + TEXT_MUSH12 = 0x84, + TEXT_MUSH13 = 0x85, + TEXT_DOOM1 = 0x86, + TEXT_DOOM2 = 0x87, + TEXT_DOOM3 = 0x88, + TEXT_DOOM4 = 0x89, + TEXT_DOOM5 = 0x8A, + TEXT_DOOM6 = 0x8B, + TEXT_DOOM7 = 0x8C, + TEXT_DOOM8 = 0x8D, + TEXT_DOOM9 = 0x8E, + TEXT_DOOM10 = 0x8F, + TEXT_GARBUD1 = 0x90, + TEXT_GARBUD2 = 0x91, + TEXT_GARBUD3 = 0x92, + TEXT_GARBUD4 = 0x93, + TEXT_ZHAR1 = 0x94, + TEXT_ZHAR2 = 0x95, + TEXT_STORY1 = 0x96, + TEXT_STORY2 = 0x97, + TEXT_STORY3 = 0x98, + TEXT_STORY4 = 0x99, + TEXT_STORY5 = 0x9A, + TEXT_STORY6 = 0x9B, + TEXT_STORY7 = 0x9C, + TEXT_STORY9 = 0x9D, + TEXT_STORY10 = 0x9E, + TEXT_STORY11 = 0x9F, + TEXT_OGDEN1 = 0xA0, + TEXT_OGDEN2 = 0xA1, + TEXT_OGDEN3 = 0xA2, + TEXT_OGDEN4 = 0xA3, + TEXT_OGDEN5 = 0xA4, + TEXT_OGDEN6 = 0xA5, + TEXT_OGDEN8 = 0xA6, + TEXT_OGDEN9 = 0xA7, + TEXT_OGDEN10 = 0xA8, + TEXT_PEPIN1 = 0xA9, + TEXT_PEPIN2 = 0xAA, + TEXT_PEPIN3 = 0xAB, + TEXT_PEPIN4 = 0xAC, + TEXT_PEPIN5 = 0xAD, + TEXT_PEPIN6 = 0xAE, + TEXT_PEPIN7 = 0xAF, + TEXT_PEPIN9 = 0xB0, + TEXT_PEPIN10 = 0xB1, + TEXT_PEPIN11 = 0xB2, + TEXT_GILLIAN1 = 0xB3, + TEXT_GILLIAN2 = 0xB4, + TEXT_GILLIAN3 = 0xB5, + TEXT_GILLIAN4 = 0xB6, + TEXT_GILLIAN5 = 0xB7, + TEXT_GILLIAN6 = 0xB8, + TEXT_GILLIAN7 = 0xB9, + TEXT_GILLIAN9 = 0xBA, + TEXT_GILLIAN10 = 0xBB, + TEXT_GRISWOLD1 = 0xBC, + TEXT_GRISWOLD2 = 0xBD, + TEXT_GRISWOLD3 = 0xBE, + TEXT_GRISWOLD4 = 0xBF, + TEXT_GRISWOLD5 = 0xC0, + TEXT_GRISWOLD6 = 0xC1, + TEXT_GRISWOLD7 = 0xC2, + TEXT_GRISWOLD8 = 0xC3, + TEXT_GRISWOLD9 = 0xC4, + TEXT_GRISWOLD10 = 0xC5, + TEXT_GRISWOLD12 = 0xC6, + TEXT_GRISWOLD13 = 0xC7, + TEXT_FARNHAM1 = 0xC8, + TEXT_FARNHAM2 = 0xC9, + TEXT_FARNHAM3 = 0xCA, + TEXT_FARNHAM4 = 0xCB, + TEXT_FARNHAM5 = 0xCC, + TEXT_FARNHAM6 = 0xCD, + TEXT_FARNHAM8 = 0xCE, + TEXT_FARNHAM9 = 0xCF, + TEXT_FARNHAM10 = 0xD0, + TEXT_FARNHAM11 = 0xD1, + TEXT_FARNHAM12 = 0xD2, + TEXT_FARNHAM13 = 0xD3, + TEXT_ADRIA1 = 0xD4, + TEXT_ADRIA2 = 0xD5, + TEXT_ADRIA3 = 0xD6, + TEXT_ADRIA4 = 0xD7, + TEXT_ADRIA5 = 0xD8, + TEXT_ADRIA6 = 0xD9, + TEXT_ADRIA7 = 0xDA, + TEXT_ADRIA8 = 0xDB, + TEXT_ADRIA9 = 0xDC, + TEXT_ADRIA10 = 0xDD, + TEXT_ADRIA12 = 0xDE, + TEXT_ADRIA13 = 0xDF, + TEXT_WIRT1 = 0xE0, + TEXT_WIRT2 = 0xE1, + TEXT_WIRT3 = 0xE2, + TEXT_WIRT4 = 0xE3, + TEXT_WIRT5 = 0xE4, + TEXT_WIRT6 = 0xE5, + TEXT_WIRT7 = 0xE6, + TEXT_WIRT8 = 0xE7, + TEXT_WIRT9 = 0xE8, + TEXT_WIRT11 = 0xE9, + TEXT_WIRT12 = 0xEA, + TEXT_BONER = 0xEB, + TEXT_BLOODY = 0xEC, + TEXT_BLINDING = 0xED, + TEXT_BLOODWAR = 0xEE, + TEXT_MBONER = 0xEF, + TEXT_MBLOODY = 0xF0, + TEXT_MBLINDING = 0xF1, + TEXT_MBLOODWAR = 0xF2, + TEXT_RBONER = 0xF3, + TEXT_RBLOODY = 0xF4, + TEXT_RBLINDING = 0xF5, + TEXT_RBLOODWAR = 0xF6, + TEXT_COW1 = 0xF7, + TEXT_COW2 = 0xF8, + TEXT_BOOK11 = 0xF9, + TEXT_BOOK12 = 0xFA, + TEXT_BOOK13 = 0xFB, + TEXT_BOOK21 = 0xFC, + TEXT_BOOK22 = 0xFD, + TEXT_BOOK23 = 0xFE, + TEXT_BOOK31 = 0xFF, + TEXT_BOOK32 = 0x100, + TEXT_BOOK33 = 0x101, + TEXT_INTRO = 0x102 } _speech_id; typedef enum object_graphic_id { @@ -2458,7 +2458,7 @@ typedef enum item_misc_id { IMISC_RING = 0x19, IMISC_AMULET = 0x1A, IMISC_UNIQUE = 0x1B, - IMISC_HEAL_1C = 0x1C, + IMISC_MEAT = 0x1C, /* from demo/PSX */ IMISC_OILFIRST = 0x1D, IMISC_OILOF = 0x1E, /* oils are beta or hellfire only */ IMISC_OILACC = 0x1F, @@ -2493,7 +2493,7 @@ typedef enum item_type { ITYPE_GOLD = 0xB, ITYPE_RING = 0xC, ITYPE_AMULET = 0xD, - ITYPE_0E = 0xE, + ITYPE_MEAT = 0xE, /* used in demo, might be generic for 'food' */ ITYPE_NONE = -1, } item_type; @@ -2547,25 +2547,31 @@ typedef enum _setlevels { } _setlevels; typedef enum quest_id { - QTYPE_INFRA = 0x0, - QTYPE_BLKM = 0x1, - QTYPE_GARB = 0x2, - QTYPE_ZHAR = 0x3, - QTYPE_VEIL = 0x4, - QTYPE_MOD = 0x5, - QTYPE_BUTCH = 0x6, - QTYPE_BOL = 0x7, - QTYPE_BLIND = 0x8, - QTYPE_BLOOD = 0x9, - QTYPE_ANVIL = 0xA, - QTYPE_WARLRD = 0xB, - QTYPE_KING = 0xC, - QTYPE_PW = 0xD, - QTYPE_BONE = 0xE, - QTYPE_VB = 0xF, - QTYPE_INVALID = -1, + Q_ROCK = 0x0, + Q_MUSHROOM = 0x1, + Q_GARBUD = 0x2, + Q_ZHAR = 0x3, + Q_VEIL = 0x4, + Q_DIABLO = 0x5, + Q_BUTCHER = 0x6, + Q_LTBANNER = 0x7, + Q_BLIND = 0x8, + Q_BLOOD = 0x9, + Q_ANVIL = 0xA, + Q_WARLORD = 0xB, + Q_SKELKING = 0xC, + Q_PWATER = 0xD, + Q_SCHAMB = 0xE, + Q_BETRAYER = 0xF } quest_id; +typedef enum quest_state { + QUEST_NOTAVAIL = 0, + QUEST_INIT = 1, + QUEST_ACTIVE = 2, + QUEST_DONE = 3 +} quest_state; + typedef enum quest_mush_state { QS_INIT = 0, QS_TOMESPAWNED = 1, From e7bd82b44af56fac34bb9c06468179981157c7ec Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 14 Feb 2020 03:58:40 +0100 Subject: [PATCH 34/38] A handful of param names and consts --- DiabloUI/_temp_funcs.h | 8 ++++---- DiabloUI/connect.cpp | 10 +++++----- DiabloUI/diabloui.h | 8 ++++---- DiabloUI/mainmenu.cpp | 4 ++-- Source/nthread.cpp | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/DiabloUI/_temp_funcs.h b/DiabloUI/_temp_funcs.h index a7c7a62a..17e057d2 100644 --- a/DiabloUI/_temp_funcs.h +++ b/DiabloUI/_temp_funcs.h @@ -76,7 +76,7 @@ void __cdecl Connect_cpp_init(); BOOL __stdcall UiGetDataCallback(int game_type, int data_code, void *a3, int a4, int a5); BOOL __stdcall UiSoundCallback(int a1, int type, int a3); BOOL __stdcall UiAuthCallback(int a1, char *a2, char *a3, char a4, char *a5, LPSTR lpBuffer, int cchBufferMax); -BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8); +BOOL __stdcall UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8); BOOL __stdcall UiCategoryCallback(int a1, int a2, int a3, int a4, int a5, DWORD *a6, DWORD *a7); int __fastcall Connect_GetRankFromLevel(char *str); BOOL __fastcall Connect_DiffFromString(char *str, _gamedata *gamedata, int a3, int a4); @@ -84,8 +84,8 @@ void __fastcall Connect_SetDiffString(_gamedata *gamedata, const char *str1, cha BOOL __fastcall Connect_GetHeroInfoConc(const char *a1, _uiheroinfo *pInfo); void __fastcall Connect_MakeDescString(_uiheroinfo *a1, char *name, size_t size); void __stdcall UiCreateGameCriteria(_uiheroinfo *pInfo, char *str); -BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, int mode, char *desc); -void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, int type); +BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc); +void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type); void __fastcall Connect_CopyPlrDescStrings(char *str1, int size1, char *str2, int size2); BOOL __stdcall UiCopyProtError(int *pdwResult); @@ -283,7 +283,7 @@ void __fastcall local_SetDiabloCursor(HWND hWnd); void __cdecl j_MainMenu_cpp_init(); void __cdecl MainMenu_cpp_init(); -BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int a4); +BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int attractTimeOut); LRESULT __stdcall MainMenu_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); void __fastcall MainMenu_KillAndFreeMenu(HWND hWnd); void __fastcall MainMenu_SetMenuTimer(HWND hWnd); diff --git a/DiabloUI/connect.cpp b/DiabloUI/connect.cpp index 1eb03e4a..58600228 100644 --- a/DiabloUI/connect.cpp +++ b/DiabloUI/connect.cpp @@ -450,7 +450,7 @@ BOOL __stdcall UiAuthCallback(int a1, char *a2, char *a3, char a4, char *a5, LPS } // ref: 0x10003710 -BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8) +BOOL __stdcall UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8) { HDC *v8; // ebx HDC v9; // esi @@ -525,7 +525,7 @@ BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, cha GetCurrentPositionEx(v17, (LPPOINT)&a8a[7]); SetTextAlign(v8[6], 0); connect_color_text = 1; - UiDrawDescCallback(arg0, 2u, (LPCSTR)a8, a4, 0, 1u, 0, a8a); + UiDrawDescCallback(game_type, 2u, (LPCSTR)a8, a4, 0, 1u, 0, a8a); connect_color_text = 0; if (a7) { SetTextAlign(v8[6], 1u); @@ -599,7 +599,7 @@ BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, cha goto LABEL_45; } if (a5 & 8) { - v25 = (arg0 != 'BNET') - 1; + v25 = (game_type != 'BNET') - 1; v25 = v25 & 0xFD; v24 = v25 + 4; goto LABEL_46; @@ -847,7 +847,7 @@ void __stdcall UiCreateGameCriteria(_uiheroinfo *pInfo, char *str) } // ref: 0x10003FD6 -BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, int mode, char *desc) +BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc) { connect_charname = (char *)mode; Connect_MakeDescString(info, desc, 0x80u); @@ -855,7 +855,7 @@ BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, int mode, char *desc } // ref: 0x10003FF7 -void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, int type) +void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type) { connect_charname = (char *)type; SStrCopy(connect_plrinfostr, infostr, 128); diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index 923a2639..4e93c744 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -35,7 +35,7 @@ BOOL __fastcall UiValidPlayerName(char *name); /* check __stdcall */ BOOL __stdcall UiSelHeroMultDialog(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(__stdcall *fnremove)(_uiheroinfo *), BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, BOOL *hero_is_created, char *name); BOOL __stdcall UiSelHeroSingDialog(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(__stdcall *fnremove)(_uiheroinfo *), BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, char *name, int *difficulty); BOOL __stdcall UiCreditsDialog(int a1); -BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int a4); +BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int attractTimeOut); BOOL __stdcall UiProgressDialog(HWND window, char *msg, int enable, int(*fnfunc)(), int rate); const char **__stdcall UiProfileGetString(); void __cdecl UiProfileCallback(); @@ -45,13 +45,13 @@ BOOL __stdcall UiGetDataCallback(int game_type, int data_code, void *a3, int a4, BOOL __stdcall UiAuthCallback(int a1, char *a2, char *a3, char a4, char *a5, LPSTR lpBuffer, int cchBufferMax); BOOL __stdcall UiSoundCallback(int a1, int type, int a3); void __stdcall UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, UINT uType); -BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8); +BOOL __stdcall UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8); BOOL __stdcall UiCreateGameCallback(int a1, int a2, int a3, int a4, int a5, int a6); BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp); int __stdcall UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *a6); int __stdcall UiSelectProvider(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *type); -BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, int mode, char *desc); -void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, int type); +BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc); +void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type); void __stdcall UiCreateGameCriteria(_uiheroinfo *pInfo, char *str); BOOL __stdcall UiGetDefaultStats(int pclass, _uidefaultstats *pStats); BOOL __stdcall UiBetaDisclaimer(int a1); diff --git a/DiabloUI/mainmenu.cpp b/DiabloUI/mainmenu.cpp index fa3a2f45..64d32021 100644 --- a/DiabloUI/mainmenu.cpp +++ b/DiabloUI/mainmenu.cpp @@ -7,12 +7,12 @@ void __cdecl MainMenu_cpp_init() // 1002A0D4: using guessed type int mainmenu_cpp_float; // ref: 0x1000816F -BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int a4) +BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int attractTimeOut) { int v4; // eax int v5; // esi - menu_item_timer = a4; + menu_item_timer = attractTimeOut; TitleSnd_SetSoundFunction(fnSound); artfont_LoadAllFonts(); menu_version_str[0] = 0; diff --git a/Source/nthread.cpp b/Source/nthread.cpp index ad7d43b2..43aa04c5 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -216,7 +216,7 @@ void nthread_cleanup() if (!sgbThreadIsRunning) sgMemCrit.Leave(); #endif - if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) { + if (WaitForSingleObject(sghThread, INFINITE) == -1) { app_fatal("nthread3:\n(%s)", TraceLastError()); } CloseHandle(sghThread); From c632e2d1d077ce48f6cf930a4ce48765af45f854 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 11 Mar 2020 22:32:53 -0500 Subject: [PATCH 35/38] Names and bug fixes (#1974) --- Source/control.cpp | 2 +- Source/control.h | 2 +- Source/drlg_l1.cpp | 4 +-- Source/drlg_l2.cpp | 20 ++++++------ Source/gendung.cpp | 26 ++++++++-------- Source/gendung.h | 10 +++--- Source/items.cpp | 2 +- Source/monster.cpp | 4 +-- Source/msg.cpp | 2 +- Source/msg.h | 2 +- Source/multi.cpp | 2 +- Source/objects.cpp | 62 ++++++++++++++++++------------------ Source/player.cpp | 6 ++-- Source/scrollrt.cpp | 22 ++++++------- Source/town.cpp | 76 ++++++++++++++++++++++----------------------- 15 files changed, 121 insertions(+), 121 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 01fce584..30f4ebf9 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -51,7 +51,7 @@ BOOL sbookflag; BOOL chrflag; BOOL drawbtnflag; BYTE *pSpellBkCel; -char infostr[MAX_PATH]; +char infostr[256]; int numpanbtns; BYTE *pStatusPanel; char panelstr[4][64]; diff --git a/Source/control.h b/Source/control.h index 0fa12609..7acced9b 100644 --- a/Source/control.h +++ b/Source/control.h @@ -45,7 +45,7 @@ extern BOOL sbookflag; extern BOOL chrflag; extern BOOL drawbtnflag; extern BYTE *pSpellBkCel; -extern char infostr[MAX_PATH]; +extern char infostr[256]; extern int numpanbtns; extern BYTE *pStatusPanel; extern char panelstr[4][64]; diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 07f11519..655b4061 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -517,7 +517,7 @@ void DRLG_Init_Globals() memset(dObject, 0, sizeof(dObject)); memset(dItem, 0, sizeof(dItem)); memset(dMissile, 0, sizeof(dMissile)); - memset(dArch, 0, sizeof(dArch)); + memset(dSpecial, 0, sizeof(dSpecial)); if (!lightflag) { if (light4flag) c = 3; @@ -566,7 +566,7 @@ static void DRLG_InitL1Vals() } else { continue; } - dArch[i][j] = pc; + dSpecial[i][j] = pc; } } } diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index a3721d55..6ca20629 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -1965,17 +1965,17 @@ static void DRLG_InitL2Vals() } else { continue; } - dArch[i][j] = pc; + dSpecial[i][j] = pc; } } for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { if (dPiece[i][j] == 132) { - dArch[i][j + 1] = 2; - dArch[i][j + 2] = 1; + dSpecial[i][j + 1] = 2; + dSpecial[i][j + 2] = 1; } else if (dPiece[i][j] == 135 || dPiece[i][j] == 139) { - dArch[i + 1][j] = 3; - dArch[i + 2][j] = 4; + dSpecial[i + 1][j] = 3; + dSpecial[i + 2][j] = 4; } } } @@ -2049,17 +2049,17 @@ void LoadL2Dungeon(char *sFileName, int vx, int vy) if (dPiece[i][j] == 17) { pc = 6; } - dArch[i][j] = pc; + dSpecial[i][j] = pc; } } for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { if (dPiece[i][j] == 132) { - dArch[i][j + 1] = 2; - dArch[i][j + 2] = 1; + dSpecial[i][j + 1] = 2; + dSpecial[i][j + 2] = 1; } else if (dPiece[i][j] == 135 || dPiece[i][j] == 139) { - dArch[i + 1][j] = 3; - dArch[i + 2][j] = 4; + dSpecial[i + 1][j] = 3; + dSpecial[i + 2][j] = 4; } } } diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 2f321f70..3133dc17 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -51,11 +51,11 @@ BYTE *pDungeonCels; int SpeedFrameTbl[128][16]; THEME_LOC themeLoc[MAXTHEMES]; char dPlayer[MAXDUNX][MAXDUNY]; -int dword_5C2FF8; -int dword_5C2FFC; -int scr_pix_width; -int scr_pix_height; -char dArch[MAXDUNX][MAXDUNY]; +int ViewBX; +int ViewBY; +int ViewDX; +int ViewDY; +char dSpecial[MAXDUNX][MAXDUNY]; /** * List of light blocking dPieces */ @@ -560,15 +560,15 @@ void SetDungeonMicros() SetSpeedCels(); if (zoomflag) { - scr_pix_width = SCREEN_WIDTH; - scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; + ViewDX = SCREEN_WIDTH; + ViewDY = VIEWPORT_HEIGHT; + ViewBX = SCREEN_WIDTH / 64; + ViewBY = VIEWPORT_HEIGHT / 32; } else { - scr_pix_width = ZOOM_WIDTH; - scr_pix_height = ZOOM_HEIGHT; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = ZOOM_HEIGHT / 32; + ViewDX = ZOOM_WIDTH; + ViewDY = ZOOM_HEIGHT; + ViewBX = ZOOM_WIDTH / 64; + ViewBY = ZOOM_HEIGHT / 32; } } diff --git a/Source/gendung.h b/Source/gendung.h index a32db1f5..3de61872 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -43,11 +43,11 @@ extern BYTE *pDungeonCels; extern int SpeedFrameTbl[128][16]; extern THEME_LOC themeLoc[MAXTHEMES]; extern char dPlayer[MAXDUNX][MAXDUNY]; -extern int dword_5C2FF8; -extern int dword_5C2FFC; -extern int scr_pix_width; -extern int scr_pix_height; -extern char dArch[MAXDUNX][MAXDUNY]; +extern int ViewBX; +extern int ViewBY; +extern int ViewDX; +extern int ViewDY; +extern char dSpecial[MAXDUNX][MAXDUNY]; extern BOOLEAN nBlockTable[2049]; extern BYTE *pSpecialCels; extern char dFlags[MAXDUNX][MAXDUNY]; diff --git a/Source/items.cpp b/Source/items.cpp index c339265e..b83a139d 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1963,7 +1963,7 @@ int CheckUnique(int i, int lvl, int uper, BOOL recreate) if (!numu) return -1; - random_(29, 10); + random_(29, 10); /// BUGFIX: unused, last unique in array always gets chosen idata = 0; while (numu > 0) { if (uok[idata]) diff --git a/Source/monster.cpp b/Source/monster.cpp index 42503a00..d3c4527e 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -857,7 +857,7 @@ void PlaceGroup(int mtype, int num, int leaderf, int leader) } j = 0; - for (try2 = 0; j < num && try2 < 100; xp += offset_x[random_(94, 8)], yp += offset_x[random_(94, 8)]) { + for (try2 = 0; j < num && try2 < 100; xp += offset_x[random_(94, 8)], yp += offset_x[random_(94, 8)]) { /// BUGFIX: `yp += offset_y` if (!MonstPlace(xp, yp) || (dTransVal[xp][yp] != dTransVal[x1][y1]) || (leaderf & 2) && ((abs(xp - x1) >= 4) || (abs(yp - y1) >= 4))) { @@ -1222,7 +1222,7 @@ void M_CheckEFlag(int i) return; } - if (f | dArch[x][y]) + if (f | dSpecial[x][y]) monster[i]._meflag = TRUE; else { monster[i]._meflag = FALSE; diff --git a/Source/msg.cpp b/Source/msg.cpp index 3b95bc1c..77c1e4ab 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -22,7 +22,7 @@ static BOOLEAN sgbDeltaChanged; static BYTE sgbDeltaChunks; BOOL deltaload; BYTE gbBufferMsgs; -int pkt_counter; +int dwRecCount; void msg_send_drop_pkt(int pnum, int reason) { diff --git a/Source/msg.h b/Source/msg.h index 611933ab..7013723e 100644 --- a/Source/msg.h +++ b/Source/msg.h @@ -8,7 +8,7 @@ extern BOOL deltaload; extern BYTE gbBufferMsgs; -extern int pkt_counter; +extern int dwRecCount; void msg_send_drop_pkt(int pnum, int reason); void msg_send_packet(int pnum, const void *packet, DWORD dwSize); diff --git a/Source/multi.cpp b/Source/multi.cpp index a5752229..6de6af8f 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -454,7 +454,7 @@ void multi_process_network_packets() multi_clear_left_tbl(); multi_process_tmsgs(); while (SNetReceiveMessage((int *)&dwID, &data, (int *)&dwMsgSize)) { - pkt_counter++; + dwRecCount++; multi_clear_left_tbl(); pkt = (TPktHdr *)data; if (dwMsgSize < sizeof(TPktHdr)) diff --git a/Source/objects.cpp b/Source/objects.cpp index c9e094eb..2e9f3e46 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1903,35 +1903,35 @@ void ObjL1Special(int x1, int y1, int x2, int y2) for (i = y1; i <= y2; ++i) { for (j = x1; j <= x2; ++j) { - dArch[j][i] = 0; + dSpecial[j][i] = 0; if (dPiece[j][i] == 12) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 11) - dArch[j][i] = 2; + dSpecial[j][i] = 2; if (dPiece[j][i] == 71) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 259) - dArch[j][i] = 5; + dSpecial[j][i] = 5; if (dPiece[j][i] == 249) - dArch[j][i] = 2; + dSpecial[j][i] = 2; if (dPiece[j][i] == 325) - dArch[j][i] = 2; + dSpecial[j][i] = 2; if (dPiece[j][i] == 321) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 255) - dArch[j][i] = 4; + dSpecial[j][i] = 4; if (dPiece[j][i] == 211) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 344) - dArch[j][i] = 2; + dSpecial[j][i] = 2; if (dPiece[j][i] == 341) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 331) - dArch[j][i] = 2; + dSpecial[j][i] = 2; if (dPiece[j][i] == 418) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 421) - dArch[j][i] = 2; + dSpecial[j][i] = 2; } } } @@ -1942,32 +1942,32 @@ void ObjL2Special(int x1, int y1, int x2, int y2) for (j = y1; j <= y2; j++) { for (i = x1; i <= x2; i++) { - dArch[i][j] = 0; + dSpecial[i][j] = 0; if (dPiece[i][j] == 541) - dArch[i][j] = 5; + dSpecial[i][j] = 5; if (dPiece[i][j] == 178) - dArch[i][j] = 5; + dSpecial[i][j] = 5; if (dPiece[i][j] == 551) - dArch[i][j] = 5; + dSpecial[i][j] = 5; if (dPiece[i][j] == 542) - dArch[i][j] = 6; + dSpecial[i][j] = 6; if (dPiece[i][j] == 553) - dArch[i][j] = 6; + dSpecial[i][j] = 6; if (dPiece[i][j] == 13) - dArch[i][j] = 5; + dSpecial[i][j] = 5; if (dPiece[i][j] == 17) - dArch[i][j] = 6; + dSpecial[i][j] = 6; } } for (j = y1; j <= y2; j++) { for (i = x1; i <= x2; i++) { if (dPiece[i][j] == 132) { - dArch[i][j + 1] = 2; - dArch[i][j + 2] = 1; + dSpecial[i][j + 1] = 2; + dSpecial[i][j + 2] = 1; } if (dPiece[i][j] == 135 || dPiece[i][j] == 139) { - dArch[i + 1][j] = 3; - dArch[i + 2][j] = 4; + dSpecial[i + 1][j] = 3; + dSpecial[i + 2][j] = 4; } } } @@ -2043,7 +2043,7 @@ void OperateL1RDoor(int pnum, int oi, BOOL sendflag) if (!deltaload) PlaySfxLoc(IS_DOOROPEN, object[oi]._ox, object[oi]._oy); ObjSetMicro(xp, yp, 395); - dArch[xp][yp] = 8; + dSpecial[xp][yp] = 8; objects_set_door_piece(xp, yp - 1); object[oi]._oAnimFrame += 2; object[oi]._oPreFlag = TRUE; @@ -2099,7 +2099,7 @@ void OperateL1LDoor(int pnum, int oi, BOOL sendflag) ObjSetMicro(xp, yp, 408); else ObjSetMicro(xp, yp, 393); - dArch[xp][yp] = 7; + dSpecial[xp][yp] = 7; objects_set_door_piece(xp - 1, yp); object[oi]._oAnimFrame += 2; object[oi]._oPreFlag = TRUE; @@ -4191,12 +4191,12 @@ void SyncL1Doors(int i) ObjSetMicro(x, y, 408); else ObjSetMicro(x, y, 393); - dArch[x][y] = 7; + dSpecial[x][y] = 7; objects_set_door_piece(x - 1, y); y--; } else { ObjSetMicro(x, y, 395); - dArch[x][y] = 8; + dSpecial[x][y] = 8; objects_set_door_piece(x, y - 1); x--; } diff --git a/Source/player.cpp b/Source/player.cpp index 01e1bc63..1fe8283a 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -966,7 +966,7 @@ void CheckEFlag(int pnum, BOOL flag) bitflags |= pieces->mt[i]; } - if (bitflags | nSolidTable[dPiece[x][y]] | dArch[x][y]) { + if (bitflags | nSolidTable[dPiece[x][y]] | dSpecial[x][y]) { plr[pnum]._peflag = 1; } else { plr[pnum]._peflag = 0; @@ -985,7 +985,7 @@ void CheckEFlag(int pnum, BOOL flag) bitflags |= pieces->mt[i]; } - if (bitflags | dArch[x][y]) { + if (bitflags | dSpecial[x][y]) { return; } @@ -998,7 +998,7 @@ void CheckEFlag(int pnum, BOOL flag) bitflags |= pieces->mt[i]; } - if (bitflags | dArch[x][y]) { + if (bitflags | dSpecial[x][y]) { plr[pnum]._peflag = 2; } } diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 7a92d335..d56272dd 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -900,7 +900,7 @@ static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, i bObj = dObject[sx][sy]; bItem = dItem[sx][sy]; bPlr = dPlayer[sx][sy]; - bArch = dArch[sx][sy]; + bArch = dSpecial[sx][sy]; bMap = dTransVal[sx][sy]; nMon = dMonster[sx][sy]; @@ -1365,7 +1365,7 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int row bObj = dObject[sx][sy]; bItem = dItem[sx][sy]; bPlr = dPlayer[sx][sy]; - bArch = dArch[sx][sy]; + bArch = dSpecial[sx][sy]; bMap = dTransVal[sx][sy]; nMon = dMonster[sx][sy]; @@ -1763,7 +1763,7 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int row, int CelC bObj = dObject[sx][sy]; bItem = dItem[sx][sy]; bPlr = dPlayer[sx][sy]; - bArch = dArch[sx][sy]; + bArch = dSpecial[sx][sy]; bMap = dTransVal[sx][sy]; nMon = dMonster[sx][sy]; @@ -2116,10 +2116,10 @@ static void DrawGame(int x, int y) { int i, sx, sy, chunks, blocks; - scr_pix_width = SCREEN_WIDTH; - scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; + ViewDX = SCREEN_WIDTH; + ViewDY = VIEWPORT_HEIGHT; + ViewBX = SCREEN_WIDTH / 64; + ViewBY = VIEWPORT_HEIGHT / 32; sx = ScrollInfo._sxoff + SCREEN_X; sy = ScrollInfo._syoff + SCREEN_Y + 15; @@ -2224,10 +2224,10 @@ static void DrawZoom(int x, int y) int i, sx, sy, chunks, blocks; int wdt, nSrcOff, nDstOff; - scr_pix_width = ZOOM_WIDTH; - scr_pix_height = ZOOM_HEIGHT - 32; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = (ZOOM_HEIGHT - 32) / 32; + ViewDX = ZOOM_WIDTH; + ViewDY = ZOOM_HEIGHT - 32; + ViewBX = ZOOM_WIDTH / 64; + ViewBY = (ZOOM_HEIGHT - 32) / 32; sx = ScrollInfo._sxoff + SCREEN_X; sy = ScrollInfo._syoff + SCREEN_Y - 17; diff --git a/Source/town.cpp b/Source/town.cpp index 148650e9..18c25a1c 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -488,8 +488,8 @@ void town_draw_clipped_town(BYTE *pBuff, int sx, int sy, int dx, int dy, int efl if (dFlags[sx][sy] & BFLAG_MISSILE) { DrawClippedMissile(sx, sy, dx, dy, 0, 8, 0); } - if (dArch[sx][sy] != 0) { - town_special_lower(pBuff, dArch[sx][sy]); + if (dSpecial[sx][sy] != 0) { + town_special_lower(pBuff, dSpecial[sx][sy]); } } @@ -702,8 +702,8 @@ void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int row, int CelSkip, if (dFlags[sx][sy] & BFLAG_MISSILE) { DrawClippedMissile(sx, sy, dx, dy, CelSkip, 8, 0); } - if (dArch[sx][sy] != 0) { - town_special_lower(&pBuff[PitchTbl[16 * CelSkip]], dArch[sx][sy]); + if (dSpecial[sx][sy] != 0) { + town_special_lower(&pBuff[PitchTbl[16 * CelSkip]], dSpecial[sx][sy]); } } @@ -929,8 +929,8 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int row, int CelCap, int sx, if (dFlags[x][y] & BFLAG_MISSILE) { DrawMissile(x, y, sx, sy, 0, CelCap, FALSE); } - if (dArch[x][y] != 0) { - town_special_upper(pBuff, dArch[x][y]); + if (dSpecial[x][y] != 0) { + town_special_upper(pBuff, dSpecial[x][y]); } } @@ -1049,10 +1049,10 @@ void T_DrawGame(int x, int y) { int i, sx, sy, chunks, blocks; - scr_pix_width = SCREEN_WIDTH; - scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; + ViewDX = SCREEN_WIDTH; + ViewDY = VIEWPORT_HEIGHT; + ViewBX = SCREEN_WIDTH / 64; + ViewBY = VIEWPORT_HEIGHT / 32; sx = ScrollInfo._sxoff + 64; sy = ScrollInfo._syoff + 175; @@ -1168,10 +1168,10 @@ void T_DrawZoom(int x, int y) int i, sx, sy, chunks, blocks; int wdt, nSrcOff, nDstOff; - scr_pix_width = ZOOM_WIDTH; - scr_pix_height = 192; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = 192 / 32; + ViewDX = ZOOM_WIDTH; + ViewDY = 192; + ViewBX = ZOOM_WIDTH / 64; + ViewBY = 192 / 32; sx = ScrollInfo._sxoff + 64; sy = ScrollInfo._syoff + 143; @@ -1424,15 +1424,15 @@ void SetTownMicros() } if (zoomflag) { - scr_pix_width = SCREEN_WIDTH; - scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; + ViewDX = SCREEN_WIDTH; + ViewDY = VIEWPORT_HEIGHT; + ViewBX = SCREEN_WIDTH / 64; + ViewBY = VIEWPORT_HEIGHT / 32; } else { - scr_pix_width = ZOOM_WIDTH; - scr_pix_height = ZOOM_HEIGHT; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = ZOOM_HEIGHT / 32; + ViewDX = ZOOM_WIDTH; + ViewDY = ZOOM_HEIGHT; + ViewBX = ZOOM_WIDTH / 64; + ViewBY = ZOOM_HEIGHT / 32; } } @@ -1673,40 +1673,40 @@ void CreateTown(int entry) memset(dMonster, 0, sizeof(dMonster)); memset(dObject, 0, sizeof(dObject)); memset(dItem, 0, sizeof(dItem)); - memset(dArch, 0, sizeof(dArch)); + memset(dSpecial, 0, sizeof(dSpecial)); for (y = 0; y < MAXDUNY; y++) { for (x = 0; x < MAXDUNX; x++) { if (dPiece[x][y] == 360) { - dArch[x][y] = 1; + dSpecial[x][y] = 1; } else if (dPiece[x][y] == 358) { - dArch[x][y] = 2; + dSpecial[x][y] = 2; } else if (dPiece[x][y] == 129) { - dArch[x][y] = 6; + dSpecial[x][y] = 6; } else if (dPiece[x][y] == 130) { - dArch[x][y] = 7; + dSpecial[x][y] = 7; } else if (dPiece[x][y] == 128) { - dArch[x][y] = 8; + dSpecial[x][y] = 8; } else if (dPiece[x][y] == 117) { - dArch[x][y] = 9; + dSpecial[x][y] = 9; } else if (dPiece[x][y] == 157) { - dArch[x][y] = 10; + dSpecial[x][y] = 10; } else if (dPiece[x][y] == 158) { - dArch[x][y] = 11; + dSpecial[x][y] = 11; } else if (dPiece[x][y] == 156) { - dArch[x][y] = 12; + dSpecial[x][y] = 12; } else if (dPiece[x][y] == 162) { - dArch[x][y] = 13; + dSpecial[x][y] = 13; } else if (dPiece[x][y] == 160) { - dArch[x][y] = 14; + dSpecial[x][y] = 14; } else if (dPiece[x][y] == 214) { - dArch[x][y] = 15; + dSpecial[x][y] = 15; } else if (dPiece[x][y] == 212) { - dArch[x][y] = 16; + dSpecial[x][y] = 16; } else if (dPiece[x][y] == 217) { - dArch[x][y] = 17; + dSpecial[x][y] = 17; } else if (dPiece[x][y] == 216) { - dArch[x][y] = 18; + dSpecial[x][y] = 18; } } } From f89204e7ddc81d1ca6ab5e64a8b91e09cf4e323a Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Tue, 24 Mar 2020 00:22:36 -0500 Subject: [PATCH 36/38] Fix function/var names (effects/sound) --- Source/diablo.cpp | 16 ++++++------ Source/effects.cpp | 52 ++++++++++++++++++------------------- Source/effects.h | 16 ++++++------ Source/gamemenu.cpp | 4 +-- Source/interfac.cpp | 2 +- Source/movie.cpp | 2 +- Source/player.cpp | 2 +- Source/sound.cpp | 34 ++++++++++++------------ Source/sound.h | 4 +-- Source/stores.cpp | 10 +++---- Source/stores.h | 2 +- Source/towners.cpp | 2 +- comparer-config/diablo.toml | 20 +++++++------- comparer-config/spawn.toml | 20 +++++++------- 14 files changed, 93 insertions(+), 93 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index ade09cc6..7a167b4b 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -86,7 +86,7 @@ void FreeGameMem() FreeMissiles(); FreeMonsters(); FreeObjectGFX(); - FreeEffects(); + FreeMonsterSnd(); FreeTownerGFX(); } @@ -286,7 +286,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi diablo_init_screen(); diablo_parse_flags(lpCmdLine); init_create_window(nCmdShow); - sound_init(); + ui_sound_init(); UiInitialize(); #ifdef SPAWN UiSetSpawned(TRUE); @@ -619,7 +619,7 @@ BOOL PressEscKey() if (qtextflag) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); rv = TRUE; } else if (stextflag) { STextESC(); @@ -772,7 +772,7 @@ LRESULT CALLBACK GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) pfile_write_hero(); nthread_ignore_mutex(TRUE); PaletteFadeOut(8); - FreeMonsterSnd(); + sound_stop(); music_stop(); track_repeat_walk(FALSE); sgbMouseDown = 0; @@ -808,7 +808,7 @@ BOOL LeftMouseDown(int wParam) QuestlogESC(); } else if (qtextflag) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); } else if (chrflag && MouseX < 320) { CheckChrBtns(); } else if (invflag && MouseX > RIGHT_PANEL) { @@ -1092,7 +1092,7 @@ void PressKey(int vkey) spselflag = FALSE; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); } questlog = FALSE; automapflag = FALSE; @@ -1214,7 +1214,7 @@ void PressKey(int vkey) spselflag = FALSE; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); } questlog = FALSE; automapflag = FALSE; @@ -1231,7 +1231,7 @@ void diablo_pause_game() PauseMode = 0; } else { PauseMode = 2; - FreeMonsterSnd(); + sound_stop(); track_repeat_walk(FALSE); } force_redraw = 255; diff --git a/Source/effects.cpp b/Source/effects.cpp index cfa3d203..d8c0b09b 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -8,8 +8,8 @@ int sfxdelay; int sfxdnum; -HANDLE sfx_stream; -TSFX *sfx_data_cur; +HANDLE sghStream; +TSFX *sgpStreamSFX; /** * Monster sound type prefix @@ -919,18 +919,18 @@ BOOL effect_is_playing(int nSFX) return snd_playing(sfx->pSnd); if (sfx->bFlags & SFX_STREAM) - return sfx == sfx_data_cur; + return sfx == sgpStreamSFX; return FALSE; } -void sfx_stop() +void stream_stop() { - if (sfx_stream) { - SFileDdaEnd(sfx_stream); - SFileCloseFile(sfx_stream); - sfx_stream = NULL; - sfx_data_cur = NULL; + if (sghStream) { + SFileDdaEnd(sghStream); + SFileCloseFile(sghStream); + sghStream = NULL; + sgpStreamSFX = NULL; } } @@ -961,7 +961,7 @@ void InitMonsterSND(int monst) } } -void FreeEffects() +void FreeMonsterSnd() { int mtype, i, j, k; char *file; @@ -1080,7 +1080,7 @@ void stream_play(TSFX *pSFX, int lVolume, int lPan) /// ASSERT: assert(pSFX); /// ASSERT: assert(pSFX->bFlags & sfx_STREAM); - sfx_stop(); + stream_stop(); lVolume += sound_get_or_set_sound_volume(1); if (lVolume >= VOLUME_MIN) { if (lVolume > VOLUME_MAX) @@ -1088,17 +1088,17 @@ void stream_play(TSFX *pSFX, int lVolume, int lPan) #ifdef _DEBUG SFileEnableDirectAccess(FALSE); #endif - success = SFileOpenFile(pSFX->pszName, &sfx_stream); + success = SFileOpenFile(pSFX->pszName, &sghStream); #ifdef _DEBUG SFileEnableDirectAccess(TRUE); #endif if (!success) { - sfx_stream = 0; + sghStream = 0; } else { - if (!SFileDdaBeginEx(sfx_stream, 0x40000, 0, 0, lVolume, lPan, 0)) - sfx_stop(); + if (!SFileDdaBeginEx(sghStream, 0x40000, 0, 0, lVolume, lPan, 0)) + stream_stop(); else - sfx_data_cur = pSFX; + sgpStreamSFX = pSFX; } } } @@ -1155,13 +1155,13 @@ void PlaySfxLoc(int psfx, int x, int y) PlaySFX_priv(&sgSFX[psfx], TRUE, x, y); } -void FreeMonsterSnd() +void sound_stop() { int i, j, k; snd_update(TRUE); + stream_stop(); sfx_stop(); - sound_stop(); for (i = 0; i < nummtypes; i++) { for (j = 0; j < 4; j++) { @@ -1172,7 +1172,7 @@ void FreeMonsterSnd() } } -void sound_stop() +void sfx_stop() { int i; TSFX *snd; @@ -1192,15 +1192,15 @@ void sound_update() } snd_update(FALSE); - effects_update(); + stream_update(); } -void effects_update() +void stream_update() { DWORD current, end; - if (sfx_stream != NULL && SFileDdaGetPos(sfx_stream, ¤t, &end) && current >= end) { - sfx_stop(); + if (sghStream != NULL && SFileDdaGetPos(sghStream, ¤t, &end) && current >= end) { + stream_stop(); } } @@ -1208,7 +1208,7 @@ void effects_cleanup_sfx() { DWORD i; - FreeMonsterSnd(); + sound_stop(); for (i = 0; i < sizeof(sgSFX) / sizeof(TSFX); i++) { if (sgSFX[i].pSnd) { @@ -1218,7 +1218,7 @@ void effects_cleanup_sfx() } } -void stream_update() +void sound_init() { BYTE mask = 0; if (gbMaxPlayers > 1) { @@ -1269,7 +1269,7 @@ void priv_sound_init(BYTE bLoadMask) } } -void sound_init() +void ui_sound_init() { priv_sound_init(SFX_UI); } diff --git a/Source/effects.h b/Source/effects.h index 5aa3ddbc..46aeb95d 100644 --- a/Source/effects.h +++ b/Source/effects.h @@ -8,13 +8,13 @@ extern int sfxdelay; extern int sfxdnum; -extern HANDLE sfx_stream; -extern TSFX *sfx_data_cur; +extern HANDLE sghStream; +extern TSFX *sgpStreamSFX; BOOL effect_is_playing(int nSFX); -void sfx_stop(); +void stream_stop(); void InitMonsterSND(int monst); -void FreeEffects(); +void FreeMonsterSnd(); void PlayEffect(int i, int mode); BOOL calc_snd_position(int x, int y, int *plVolume, int *plPan); void PlaySFX(int psfx); @@ -22,14 +22,14 @@ void PlaySFX_priv(TSFX *pSFX, BOOL loc, int x, int y); void stream_play(TSFX *pSFX, int lVolume, int lPan); int RndSFX(int psfx); void PlaySfxLoc(int psfx, int x, int y); -void FreeMonsterSnd(); void sound_stop(); +void sfx_stop(); void sound_update(); -void effects_update(); -void effects_cleanup_sfx(); void stream_update(); -void priv_sound_init(BYTE bLoadMask); +void effects_cleanup_sfx(); void sound_init(); +void priv_sound_init(BYTE bLoadMask); +void ui_sound_init(); void __stdcall effects_play_sound(char *snd_file); /* rdata */ diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index 16a14434..1545fa20 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -262,7 +262,7 @@ void gamemenu_sound_volume(BOOL bActivate) if (bActivate) { if (gbSoundOn) { gbSoundOn = FALSE; - FreeMonsterSnd(); + sound_stop(); sound_get_or_set_sound_volume(VOLUME_MIN); } else { gbSoundOn = TRUE; @@ -274,7 +274,7 @@ void gamemenu_sound_volume(BOOL bActivate) if (volume == VOLUME_MIN) { if (gbSoundOn) { gbSoundOn = FALSE; - FreeMonsterSnd(); + sound_stop(); } } else if (!gbSoundOn) { gbSoundOn = TRUE; diff --git a/Source/interfac.cpp b/Source/interfac.cpp index c5be1d43..8c987f12 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -87,7 +87,7 @@ void ShowProgress(unsigned int uMsg) DrawCutscene(); PaletteFadeIn(8); IncProgress(); - stream_update(); + sound_init(); IncProgress(); switch (uMsg) { diff --git a/Source/movie.cpp b/Source/movie.cpp index d9058671..1e3f8129 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -25,7 +25,7 @@ void play_movie(char *pszMovie, BOOL user_can_close) UpdateWindow(ghMainWnd); movie_playing = TRUE; sound_disable_music(TRUE); - sfx_stop(); + stream_stop(); effects_play_sound("Sfx\\Misc\\blank.wav"); SVidPlayBegin(pszMovie, 0, 0, 0, 0, loop_movie ? 0x100C0808 : 0x10280808, &video_stream); diff --git a/Source/player.cpp b/Source/player.cpp index 1fe8283a..c89c5f19 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -1988,7 +1988,7 @@ void InitLevelChange(int pnum) RemovePlrMissiles(pnum); if (pnum == myplr && qtextflag) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); } RemovePlrFromMap(pnum); diff --git a/Source/sound.cpp b/Source/sound.cpp index b7de83ae..3f8fb33f 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -7,7 +7,7 @@ BOOLEAN gbSndInited; int sglMusicVolume; int sglSoundVolume; HMODULE hDsound_dll; -HANDLE sgpMusicTrack; +HANDLE sghMusic; LPDIRECTSOUNDBUFFER sglpDSB; /* data */ @@ -306,10 +306,10 @@ void sound_file_cleanup(TSnd *sound_file) void snd_init(HWND hWnd) { int error_code; - sound_load_volume("Sound Volume", &sglSoundVolume); + snd_get_volume("Sound Volume", &sglSoundVolume); gbSoundOn = sglSoundVolume > VOLUME_MIN; - sound_load_volume("Music Volume", &sglMusicVolume); + snd_get_volume("Music Volume", &sglMusicVolume); gbMusicOn = sglMusicVolume > VOLUME_MIN; error_code = sound_DirectSoundCreate(NULL, &sglpDS, NULL); @@ -329,7 +329,7 @@ void snd_init(HWND hWnd) gbSndInited = sglpDS != NULL; } -void sound_load_volume(char *value_name, int *value) +void snd_get_volume(char *value_name, int *value) { int v = *value; if (!SRegLoadValue("Diablo", value_name, 0, &v)) { @@ -433,22 +433,22 @@ void sound_cleanup() if (gbSndInited) { gbSndInited = FALSE; - sound_store_volume("Sound Volume", sglSoundVolume); - sound_store_volume("Music Volume", sglMusicVolume); + snd_set_volume("Sound Volume", sglSoundVolume); + snd_set_volume("Music Volume", sglMusicVolume); } } -void sound_store_volume(char *key, int value) +void snd_set_volume(char *key, int value) { SRegSaveValue("Diablo", key, 0, value); } void music_stop() { - if (sgpMusicTrack) { - SFileDdaEnd(sgpMusicTrack); - SFileCloseFile(sgpMusicTrack); - sgpMusicTrack = NULL; + if (sghMusic) { + SFileDdaEnd(sghMusic); + SFileCloseFile(sghMusic); + sghMusic = NULL; sgnMusicTrack = NUM_MUSIC; } } @@ -463,15 +463,15 @@ void music_start(int nTrack) #ifdef _DEBUG SFileEnableDirectAccess(FALSE); #endif - success = SFileOpenFile(sgszMusicTracks[nTrack], &sgpMusicTrack); + success = SFileOpenFile(sgszMusicTracks[nTrack], &sghMusic); #ifdef _DEBUG SFileEnableDirectAccess(TRUE); #endif - sound_create_primary_buffer(sgpMusicTrack); + sound_create_primary_buffer(sghMusic); if (!success) { - sgpMusicTrack = NULL; + sghMusic = NULL; } else { - SFileDdaBeginEx(sgpMusicTrack, 0x40000, 0x40000, 0, sglMusicVolume, 0, 0); + SFileDdaBeginEx(sghMusic, 0x40000, 0x40000, 0, sglMusicVolume, 0, 0); sgnMusicTrack = nTrack; } } @@ -493,8 +493,8 @@ int sound_get_or_set_music_volume(int volume) sglMusicVolume = volume; - if (sgpMusicTrack) - SFileDdaSetVolume(sgpMusicTrack, volume, 0); + if (sghMusic) + SFileDdaSetVolume(sghMusic, volume, 0); return sglMusicVolume; } diff --git a/Source/sound.h b/Source/sound.h index f584f4e7..bd14be41 100644 --- a/Source/sound.h +++ b/Source/sound.h @@ -16,11 +16,11 @@ TSnd *sound_file_load(char *path); void sound_CreateSoundBuffer(TSnd *sound_file); void sound_file_cleanup(TSnd *sound_file); void snd_init(HWND hWnd); -void sound_load_volume(char *value_name, int *value); +void snd_get_volume(char *value_name, int *value); void sound_create_primary_buffer(HANDLE music_track); HRESULT sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter); void sound_cleanup(); -void sound_store_volume(char *key, int value); +void snd_set_volume(char *key, int value); void music_stop(); void music_start(int nTrack); void sound_disable_music(BOOL disable); diff --git a/Source/stores.cpp b/Source/stores.cpp index fa02dbee..5dfe2d8b 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -242,7 +242,7 @@ void DrawSLine(int y) #endif } -void DrawSArrows(int y1, int y2) +void DrawSSlider(int y1, int y2) { int yd1, yd2, yd3; @@ -1583,7 +1583,7 @@ void DrawSText() } if (stextscrl) - DrawSArrows(4, 20); + DrawSSlider(4, 20); InStoreFlag = (InStoreFlag & 7) + 1; } @@ -1593,7 +1593,7 @@ void STextESC() if (qtextflag) { qtextflag = FALSE; if (leveltype == DTYPE_TOWN) - sfx_stop(); + stream_stop(); } else { switch (stextflag) { case STORE_SMITH: @@ -2679,7 +2679,7 @@ void STextEnter() if (qtextflag) { qtextflag = FALSE; if (leveltype == DTYPE_TOWN) - sfx_stop(); + stream_stop(); } else { PlaySFX(IS_TITLSLCT); switch (stextflag) { @@ -2763,7 +2763,7 @@ void CheckStoreBtn() if (qtextflag) { qtextflag = FALSE; if (leveltype == DTYPE_TOWN) - sfx_stop(); + stream_stop(); } else if (stextsel != -1 && MouseY >= 32 && MouseY <= 320) { if (!stextsize) { if (MouseX < 344 + PANEL_LEFT || MouseX > 616 + PANEL_LEFT) diff --git a/Source/stores.h b/Source/stores.h index 90e6ab0e..88c11ddf 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -42,7 +42,7 @@ void FreeStoreMem(); void DrawSTextBack(); void PrintSString(int x, int y, BOOL cjustflag, char *str, char col, int val); void DrawSLine(int y); -void DrawSArrows(int y1, int y2); +void DrawSSlider(int y1, int y2); void DrawSTextHelp(); void ClearSText(int s, int e); void AddSLine(int y); diff --git a/Source/towners.cpp b/Source/towners.cpp index 6b8d6dd8..b8f502ee 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -418,7 +418,7 @@ void TownCtrlMsg(int i) towner[i]._tbtcnt = 0; if (!towner[i]._tbtcnt) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); } } } diff --git a/comparer-config/diablo.toml b/comparer-config/diablo.toml index 5a3b9c37..41c12fd3 100644 --- a/comparer-config/diablo.toml +++ b/comparer-config/diablo.toml @@ -1628,7 +1628,7 @@ addr = 0x4158B9 size = 0x29 [[func]] -name = "sfx_stop" +name = "stream_stop" addr = 0x4158E2 size = 0x29 @@ -1638,7 +1638,7 @@ addr = 0x41590B size = 0xD0 [[func]] -name = "FreeEffects" +name = "FreeMonsterSnd" addr = 0x4159DB size = 0x6A @@ -1678,12 +1678,12 @@ addr = 0x415D01 size = 0x38 [[func]] -name = "FreeMonsterSnd" +name = "sound_stop" addr = 0x415D39 size = 0x61 [[func]] -name = "sound_stop" +name = "sfx_stop" addr = 0x415D9A size = 0x20 @@ -1693,7 +1693,7 @@ addr = 0x415DBA size = 0x16 [[func]] -name = "effects_update" +name = "stream_update" addr = 0x415DD0 size = 0x2F @@ -1703,7 +1703,7 @@ addr = 0x415DFF size = 0x2B [[func]] -name = "stream_update" +name = "sound_init" addr = 0x415E2A size = 0x4D @@ -1713,7 +1713,7 @@ addr = 0x415E77 size = 0x61 [[func]] -name = "sound_init" +name = "ui_sound_init" addr = 0x415ED8 size = 0x7 @@ -8153,7 +8153,7 @@ addr = 0x45708B size = 0xA0 [[func]] -name = "sound_load_volume" +name = "snd_get_volume" addr = 0x45712B size = 0x51 @@ -8173,7 +8173,7 @@ addr = 0x4572FF size = 0x59 [[func]] -name = "sound_store_volume" +name = "snd_set_volume" addr = 0x457358 size = 0xF @@ -8268,7 +8268,7 @@ addr = 0x457DE2 size = 0x80 [[func]] -name = "DrawSArrows" +name = "DrawSSlider" addr = 0x457E62 size = 0xF0 diff --git a/comparer-config/spawn.toml b/comparer-config/spawn.toml index ae5877e2..5a6fd8cb 100644 --- a/comparer-config/spawn.toml +++ b/comparer-config/spawn.toml @@ -1098,7 +1098,7 @@ addr = 0x40D741 size = 0x29 [[func]] -name = "sfx_stop" +name = "stream_stop" addr = 0x40D76A size = 0x29 @@ -1108,7 +1108,7 @@ addr = 0x40D793 size = 0xD0 [[func]] -name = "FreeEffects" +name = "FreeMonsterSnd" addr = 0x40D863 size = 0x6A @@ -1148,12 +1148,12 @@ addr = 0x40DB71 size = 0x38 [[func]] -name = "FreeMonsterSnd" +name = "sound_stop" addr = 0x40DBA9 size = 0x61 [[func]] -name = "sound_stop" +name = "sfx_stop" addr = 0x40DC0A size = 0x20 @@ -1163,7 +1163,7 @@ addr = 0x40DC2A size = 0x16 [[func]] -name = "effects_update" +name = "stream_update" addr = 0x40DC40 size = 0x2F @@ -1173,7 +1173,7 @@ addr = 0x40DC6F size = 0x2B [[func]] -name = "stream_update" +name = "sound_init" addr = 0x40DC9A size = 0x4D @@ -1183,7 +1183,7 @@ addr = 0x40DCE7 size = 0x61 [[func]] -name = "sound_init" +name = "ui_sound_init" addr = 0x40DD48 size = 0x7 @@ -7528,7 +7528,7 @@ addr = 0x44C454 size = 0xA0 [[func]] -name = "sound_load_volume" +name = "snd_get_volume" addr = 0x44C4F4 size = 0x51 @@ -7548,7 +7548,7 @@ addr = 0x44C6C8 size = 0x59 [[func]] -name = "sound_store_volume" +name = "snd_set_volume" addr = 0x44C721 size = 0xF @@ -7643,7 +7643,7 @@ addr = 0x44D1AB size = 0x80 [[func]] -name = "DrawSArrows" +name = "DrawSSlider" addr = 0x44D22B size = 0xF0 From 312168d4c1ae948f4296d8c1f1c4b22975d3be92 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 29 Mar 2020 20:45:57 +0200 Subject: [PATCH 37/38] Reformat the .clang-format files These files are YAML, changes to a more idiomatic YAML syntax --- .clang-format | 20 +++++++++----------- Source/.clang-format | 18 ++++++++---------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.clang-format b/.clang-format index 11c49919..ea436110 100644 --- a/.clang-format +++ b/.clang-format @@ -1,11 +1,9 @@ -{ - BasedOnStyle: webkit, - AlignTrailingComments: true, - AllowShortBlocksOnASingleLine: true, - AllowShortFunctionsOnASingleLine: None, - PointerAlignment: Right, - AlignConsecutiveAssignments: true, - TabWidth: 4, - UseTab: ForIndentation, - SortIncludes: false, -} +BasedOnStyle: webkit +AlignTrailingComments: true +AllowShortBlocksOnASingleLine: true +AllowShortFunctionsOnASingleLine: None +PointerAlignment: Right +AlignConsecutiveAssignments: true +TabWidth: 4 +UseTab: ForIndentation +SortIncludes: false diff --git a/Source/.clang-format b/Source/.clang-format index 7074a477..0d8567a2 100644 --- a/Source/.clang-format +++ b/Source/.clang-format @@ -1,10 +1,8 @@ -{ - BasedOnStyle: webkit, - AlignTrailingComments: true, - AllowShortBlocksOnASingleLine: true, - AllowShortFunctionsOnASingleLine: None, - PointerAlignment: Right, - TabWidth: 4, - UseTab: ForIndentation, - SortIncludes: false, -} +BasedOnStyle: webkit +AlignTrailingComments: true +AllowShortBlocksOnASingleLine: true +AllowShortFunctionsOnASingleLine: None +PointerAlignment: Right +TabWidth: 4 +UseTab: ForIndentation +SortIncludes: false From 187a021b304ffb1bac01579d8c46ac8f4aae075d Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 30 Mar 2020 11:31:36 +0200 Subject: [PATCH 38/38] More documentation from sanctuary/notes (#2026) --- Source/automap.cpp | 8 +++++++- Source/control.cpp | 41 ++++++++++++++++++++++++++++++----------- Source/diablo.cpp | 9 ++++++++- Source/effects.cpp | 2 ++ Source/gamemenu.cpp | 5 +++++ Source/gmenu.cpp | 3 ++- Source/inv.cpp | 18 +++++++++++++++++- Source/itemdat.cpp | 4 ++++ Source/minitext.cpp | 9 ++++++++- Source/multi.cpp | 8 ++++++++ Source/objdat.cpp | 6 ++++-- Source/scrollrt.h | 2 +- Source/textdat.cpp | 1 + 13 files changed, 97 insertions(+), 19 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index d94d87bb..f4c6286e 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -5,13 +5,19 @@ */ #include "all.h" -// BUGFIX: only the first 256 elements are ever read +/** + * Maps from tile_id to automap type. + * BUGFIX: only the first 256 elements are ever read + */ WORD automaptype[512]; static int AutoMapX; static int AutoMapY; +/** Specifies whether the automap is enabled. */ BOOL automapflag; char AmShiftTab[31]; +/** Tracks the explored areas of the map. */ BOOLEAN automapview[DMAXX][DMAXY]; +/** Specifies the scale of the automap. */ int AutoMapScale; int AutoMapXOfs; int AutoMapYOfs; diff --git a/Source/control.cpp b/Source/control.cpp index 30f4ebf9..176bf0da 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -63,6 +63,7 @@ BOOL panbtndown; BYTE *pTalkPanel; BOOL spselflag; +/** Maps from font index to smaltext.cel frame number. */ const BYTE fontframe[128] = { 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, @@ -73,6 +74,12 @@ const BYTE fontframe[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 40, 66, 41, 67, 0 }; + +/** + * Maps from smaltext.cel frame number to character width. Note, the + * character width may be distinct from the frame width, which is 13 for every + * smaltext.cel frame. + */ const BYTE fontkern[68] = { 8, 10, 7, 9, 8, 7, 6, 8, 8, 3, 3, 8, 6, 11, 9, 10, 6, 9, 9, 6, @@ -83,36 +90,36 @@ const BYTE fontkern[68] = { 4, 4, 9, 6, 6, 12, 3, 7 }; /** - * Line height for info box when displaying 1, 2, 3, 4 and 5 lines respectivly + * Line start position for info box text when displaying 1, 2, 3, 4 and 5 lines respectivly */ const int lineOffsets[5][5] = { { SCREENXY(177, 434), - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32 + 180, + SCREENXY(-64, -128), + SCREENXY(-64, -128), + SCREENXY(-64, -128), + SCREENXY(116, -128), }, { SCREENXY(177, 422), SCREENXY(177, 446), - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32, + SCREENXY(-64, -128), + SCREENXY(-64, -128), + SCREENXY(-64, -128), }, { SCREENXY(177, 416), SCREENXY(177, 434), SCREENXY(177, 452), - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32, + SCREENXY(-64, -128), + SCREENXY(-64, -128), }, { SCREENXY(177, 412), SCREENXY(177, 427), SCREENXY(177, 441), SCREENXY(177, 456), - BUFFER_WIDTH * 32, + SCREENXY(-64, -128), }, { SCREENXY(177, 410), @@ -122,6 +129,12 @@ const int lineOffsets[5][5] = { SCREENXY(177, 457), } }; + +/** + * Maps ASCII character code to font index, as used by the + * small, medium and large sized fonts; which corresponds to smaltext.cel, + * medtexts.cel and bigtgold.cel respectively. + */ const BYTE gbFontTransTbl[256] = { // clang-format off '\0', 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, @@ -145,6 +158,7 @@ const BYTE gbFontTransTbl[256] = { /* data */ +/** Maps from spell_id to spelicon.cel frame number. */ char SpellITbl[MAX_SPELLS] = { 1, 1, @@ -184,6 +198,7 @@ char SpellITbl[MAX_SPELLS] = { 36, 30, }; +/** Maps from panel_button_id to the position and dimensions of a panel button. */ int PanBtnPos[8][5] = { // clang-format off { PANEL_LEFT + 9, PANEL_TOP + 9, 71, 19, 1 }, // char button @@ -196,7 +211,9 @@ int PanBtnPos[8][5] = { { PANEL_LEFT + 527, PANEL_TOP + 91, 33, 32, 1 }, // friendly fire button // clang-format on }; +/** Maps from panel_button_id to hotkey name. */ char *PanBtnHotKey[8] = { "'c'", "'q'", "Tab", "Esc", "'i'", "'b'", "Enter", NULL }; +/** Maps from panel_button_id to panel button description. */ char *PanBtnStr[8] = { "Character Information", "Quests log", @@ -207,6 +224,7 @@ char *PanBtnStr[8] = { "Send Message", "Player Attack" }; +/** Maps from attribute_id to the rectangle on screen used for attribute increment buttons. */ RECT32 ChrBtnsRect[4] = { { 137, 138, 41, 22 }, { 137, 166, 41, 22 }, @@ -214,6 +232,7 @@ RECT32 ChrBtnsRect[4] = { { 137, 223, 41, 22 } }; +/** Maps from spellbook page number and position to spell_id. */ int SpellPages[6][7] = { { SPL_NULL, SPL_FIREBOLT, SPL_CBOLT, SPL_HBOLT, SPL_HEAL, SPL_HEALOTHER, SPL_FLAME }, { SPL_RESURRECT, SPL_FIREWALL, SPL_TELEKINESIS, SPL_LIGHTNING, SPL_TOWN, SPL_FLASH, SPL_STONE }, diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 7a167b4b..df156c0a 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -43,6 +43,10 @@ int color_cycle_timer; /* rdata */ +/** + * Specifies whether to give the game exclusive access to the + * screen, as needed for efficient rendering in fullscreen mode. + */ BOOL fullscreen = TRUE; #ifdef _DEBUG int showintrodebug = 1; @@ -62,6 +66,7 @@ int frameend; int framerate; int framestart; #endif +/** Specifies whether players are in non-PvP mode. */ BOOL FriendlyMode = TRUE; /** Default quick messages */ char *spszMsgTbl[4] = { @@ -1238,7 +1243,9 @@ void diablo_pause_game() } } -/* NOTE: `return` must be used instead of `break` to be bin exact as C++ */ +/** + * @internal `return` must be used instead of `break` to be bin exact as C++ + */ void PressChar(int vkey) { if (gmenu_is_active() || control_talk_last_key(vkey) || sgnTimeoutCurs != 0 || deathflag) { diff --git a/Source/effects.cpp b/Source/effects.cpp index d8c0b09b..9285a012 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -8,7 +8,9 @@ int sfxdelay; int sfxdnum; +/** A handle to the current sound effect playing. */ HANDLE sghStream; +/** Specifies the sound file and the playback state of the current sound effect. */ TSFX *sgpStreamSFX; /** diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index 1545fa20..b761e8d4 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -5,6 +5,7 @@ */ #include "all.h" +/** Contains the game menu items of the single player menu. */ TMenuItem sgSingleMenu[6] = { // clang-format off // dwFlags, pszStr, fnMenu @@ -16,6 +17,7 @@ TMenuItem sgSingleMenu[6] = { { GMENU_ENABLED, NULL, NULL } // clang-format on }; +/** Contains the game menu items of the multi player menu. */ TMenuItem sgMultiMenu[5] = { // clang-format off // dwFlags, pszStr, fnMenu @@ -37,8 +39,11 @@ TMenuItem sgOptionsMenu[6] = { { GMENU_ENABLED , NULL, NULL } // clang-format on }; +/** Specifies the menu names for music enabled and disabled. */ char *music_toggle_names[] = { "Music", "Music Disabled" }; +/** Specifies the menu names for sound enabled and disabled. */ char *sound_toggle_names[] = { "Sound", "Sound Disabled" }; +/** Specifies the menu names for colour cycling disabled and enabled. */ char *color_cycling_toggle_names[] = { "Color Cycling Off", "Color Cycling On" }; void gamemenu_on() diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 3ba56654..778fa120 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -34,7 +34,8 @@ const BYTE lfontframe[127] = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 20, 0, 21, 0 }; -/* Maps from bigtgold.cel frame number to character width. */ + +/** Maps from bigtgold.cel frame number to character width. */ const BYTE lfontkern[56] = { 18, 33, 21, 26, 28, 19, 19, 26, 25, 11, 12, 25, 19, 34, 28, 32, 20, 32, 28, 20, diff --git a/Source/inv.cpp b/Source/inv.cpp index 023e0ea2..affddfda 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -10,6 +10,22 @@ BYTE *pInvCels; BOOL drawsbarflag; int sgdwLastTime; // check name +/** + * Maps from inventory slot to screen position. The inventory slots are + * arranged as follows: + * 00 01 + * 02 03 06 + * 07 08 19 20 13 14 + * 09 10 21 22 15 16 + * 11 12 23 24 17 18 + * 04 05 + * 25 26 27 28 29 30 31 32 33 34 + * 35 36 37 38 39 40 41 42 43 44 + * 45 46 47 48 49 50 51 52 53 54 + * 55 56 57 58 59 60 61 62 63 64 + * 65 66 67 68 69 70 71 72 + * @see graphics/inv/inventory.png + */ const InvXY InvRect[73] = { // clang-format off // X, Y @@ -90,7 +106,7 @@ const InvXY InvRect[73] = { }; /* data */ - +/** Specifies the starting inventory slots for placement of 2x2 items. */ int AP2x2Tbl[10] = { 8, 28, 6, 26, 4, 24, 2, 22, 0, 20 }; void FreeInvGFX() diff --git a/Source/itemdat.cpp b/Source/itemdat.cpp index ee9c1433..2def8840 100644 --- a/Source/itemdat.cpp +++ b/Source/itemdat.cpp @@ -5,6 +5,7 @@ */ #include "all.h" +/** Contains the data related to each item ID. */ 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 @@ -168,6 +169,7 @@ ItemDataStruct AllItemsList[] = { // clang-format on }; +/** Contains the data related to each item prefix. */ const PLStruct PL_Prefix[] = { // clang-format off // PLName, PLPower, PLParam1, PLParam2, PLMinLvl, PLIType, PLGOE, PLDouble, PLOk, PLMinVal, PLMaxVal, PLMultVal @@ -258,6 +260,7 @@ const PLStruct PL_Prefix[] = { // clang-format on }; +/** Contains the data related to each item suffix. */ const PLStruct PL_Suffix[] = { // clang-format off // PLName, PLPower, PLParam1, PLParam2, PLMinLvl, PLIType, PLGOE, PLDouble, PLOk, PLMinVal, PLMaxVal, PLMultVal @@ -360,6 +363,7 @@ const PLStruct PL_Suffix[] = { // clang-format on }; +/** Contains the data related to each unique item ID. */ 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 diff --git a/Source/minitext.cpp b/Source/minitext.cpp index c89d3125..54ca65f1 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -14,6 +14,7 @@ int sgLastScroll; BYTE *pMedTextCels; BYTE *pTextBoxCels; +/** Maps from font index to medtexts.cel frame number. */ const BYTE mfontframe[127] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -29,6 +30,11 @@ const BYTE mfontframe[127] = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 48, 0, 49, 0 }; +/** + * Maps from medtexts.cel frame number to character width. Note, the + * character width may be distinct from the frame width, which is 22 for every + * medtexts.cel frame. + */ const BYTE mfontkern[56] = { 5, 15, 10, 13, 14, 10, 9, 13, 11, 5, 5, 11, 10, 16, 13, 16, 10, 15, 12, 10, @@ -41,7 +47,8 @@ const BYTE mfontkern[56] = { /* data */ /** - * Positive numbers will delay scrolling 1 out of n frames, negative numbers will scroll 1+(-n) pixels. + * Text scroll speeds. Positive numbers will delay scrolling 1 out of n frames, + * negative numbers will scroll 1+(-n) pixels. */ int qscroll_spd_tbl[9] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 }; diff --git a/Source/multi.cpp b/Source/multi.cpp index 6de6af8f..c4c9f4a4 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -28,6 +28,10 @@ int sglTimeoutStart; int sgdwPlayerLeftReasonTbl[MAX_PLRS]; TBuffer sgLoPriBuf; DWORD sgdwGameLoops; +/** + * Specifies the maximum number of players in a game, where 1 + * represents a single player game and 4 represents a multi player game. + */ BYTE gbMaxPlayers; BOOLEAN sgbTimeout; char szPlayerName[128]; @@ -35,6 +39,10 @@ BYTE gbDeltaSender; BOOL sgbNetInited; int player_state[MAX_PLRS]; +/** + * Contains the set of supported event types supported by the multiplayer + * event handler. + */ const int event_types[3] = { EVENT_TYPE_PLAYER_LEAVE_GAME, EVENT_TYPE_PLAYER_CREATE_GAME, diff --git a/Source/objdat.cpp b/Source/objdat.cpp index 070be9f6..a835be14 100644 --- a/Source/objdat.cpp +++ b/Source/objdat.cpp @@ -1,5 +1,6 @@ #include "all.h" +/** Maps from dun_object_id to object_id. */ int ObjTypeConv[113] = { 0, 4, @@ -116,6 +117,7 @@ int ObjTypeConv[113] = { 94 }; +/** Contains the data related to each object ID. */ ObjDataStruct AllObjects[99] = { // clang-format off // oload, ofindex, ominlvl, omaxlvl, olvltype, otheme, oquest, oAnimFlag, oAnimDelay, oAnimLen, oAnimWidth, oSolidFlag, oMissFlag, oLightFlag, oBreak, oSelFlag, oTrapFlag @@ -221,8 +223,8 @@ ObjDataStruct AllObjects[99] = { // clang-format on }; -// might be const -char *ObjMasterLoadList[56] = { +/** Maps from object_graphic_id to object CEL name. */ +char *ObjMasterLoadList[56] = { // might be const "L1Braz", "L1Doors", "Lever", diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 56d69dfa..4d265c80 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -30,7 +30,7 @@ void DrawAndBlit(); /* data */ -/* used in 1.00 debug */ +/** used in 1.00 debug */ extern char *szMonModeAssert[18]; extern char *szPlrModeAssert[12]; diff --git a/Source/textdat.cpp b/Source/textdat.cpp index dbf7898a..7df9be0d 100644 --- a/Source/textdat.cpp +++ b/Source/textdat.cpp @@ -2,6 +2,7 @@ /* todo: move text out of struct */ +/** Contains the data related to each speech ID. */ const TextDataStruct alltext[] = { #ifdef SPAWN { "Nice try... ", 0, 0, TSFX_TAVERN36 },