From 7d95bfed3960622ba7fef70830a33ab622107bad Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Sat, 10 Apr 2021 20:59:59 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Convert=20'plr=5Fclass'=20?= =?UTF-8?q?to=20a=20scoped=20enumeration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/control.cpp | 24 +-- Source/effects.cpp | 12 +- Source/inv.cpp | 212 ++++++++++----------- Source/items.cpp | 76 ++++---- Source/loadsave.cpp | 4 +- Source/missiles.cpp | 92 +++++----- Source/monster.cpp | 6 +- Source/objects.cpp | 148 +++++++-------- Source/pack.cpp | 4 +- Source/player.cpp | 334 +++++++++++++++++----------------- Source/player.h | 12 +- Source/quests.cpp | 84 ++++----- Source/spells.cpp | 10 +- Source/towners.cpp | 16 +- Source/trigs.cpp | 12 +- SourceX/DiabloUI/diabloui.cpp | 18 +- SourceX/DiabloUI/selhero.cpp | 26 +-- SourceX/controls/plrctrls.cpp | 6 +- SourceX/miniwin/misc_msg.cpp | 6 +- test/writehero_test.cpp | 4 +- 20 files changed, 553 insertions(+), 553 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 56c4d8adf..d9e4ea2b9 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -412,7 +412,7 @@ void DrawSpellList(CelOutputBuffer out) if (MouseX >= lx && MouseX < lx + SPLICONLENGTH && MouseY >= ly && MouseY < ly + SPLICONLENGTH) { pSpell = (spell_id)j; pSplType = (spell_type)i; - if (plr[myplr]._pClass == PC_MONK && j == SPL_SEARCH) + if (plr[myplr]._pClass == plr_class::PC_MONK && j == SPL_SEARCH) pSplType = RSPLTYPE_SKILL; DrawSpellCel(out, x, y, pSpellCels, c, SPLICONLENGTH); switch (pSplType) { @@ -831,17 +831,17 @@ void InitControlPan() pSBkIconCels = LoadFileInMem("Data\\SpellI2.CEL", NULL); sbooktab = 0; sbookflag = false; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { SpellPages[0][0] = SPL_REPAIR; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { SpellPages[0][0] = SPL_DISARM; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { SpellPages[0][0] = SPL_RECHARGE; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { SpellPages[0][0] = SPL_SEARCH; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { SpellPages[0][0] = SPL_IDENTIFY; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { SpellPages[0][0] = SPL_BLODBOIL; } pQLogCel = LoadFileInMem("Data\\Quest.CEL", NULL); @@ -1327,7 +1327,7 @@ void DrawInfoBox(CelOutputBuffer out) infoclr = COL_GOLD; strcpy(infostr, plr[pcursplr]._pName); ClearPanel(); - sprintf(tempstr, "%s, Level: %i", ClassStrTbl[plr[pcursplr]._pClass], plr[pcursplr]._pLevel); + sprintf(tempstr, "%s, Level: %i", ClassStrTbl[static_cast(plr[pcursplr]._pClass)], plr[pcursplr]._pLevel); AddPanelString(tempstr, true); sprintf(tempstr, "Hit Points %i of %i", plr[pcursplr]._pHitPoints >> 6, plr[pcursplr]._pMaxHP >> 6); AddPanelString(tempstr, true); @@ -1398,7 +1398,7 @@ void DrawChr(CelOutputBuffer out) CelDrawTo(out, 0, 351, pChrPanel, 1, SPANEL_WIDTH); ADD_PlrStringXY(out, 20, 32, 151, plr[myplr]._pName, COL_WHITE); - ADD_PlrStringXY(out, 168, 32, 299, ClassStrTbl[plr[myplr]._pClass], COL_WHITE); + ADD_PlrStringXY(out, 168, 32, 299, ClassStrTbl[static_cast(plr[myplr]._pClass)], COL_WHITE); sprintf(chrstr, "%i", plr[myplr]._pLevel); ADD_PlrStringXY(out, 66, 69, 109, chrstr, COL_WHITE); @@ -1443,7 +1443,7 @@ void DrawChr(CelOutputBuffer out) mindam += plr[myplr]._pIBonusDam * mindam / 100; mindam += plr[myplr]._pIBonusDamMod; if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_BOW) { - if (plr[myplr]._pClass == PC_ROGUE) + if (plr[myplr]._pClass == plr_class::PC_ROGUE) mindam += plr[myplr]._pDamageMod; else mindam += plr[myplr]._pDamageMod >> 1; @@ -1454,7 +1454,7 @@ void DrawChr(CelOutputBuffer out) maxdam += plr[myplr]._pIBonusDam * maxdam / 100; maxdam += plr[myplr]._pIBonusDamMod; if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_BOW) { - if (plr[myplr]._pClass == PC_ROGUE) + if (plr[myplr]._pClass == plr_class::PC_ROGUE) maxdam += plr[myplr]._pDamageMod; else maxdam += plr[myplr]._pDamageMod >> 1; @@ -1833,7 +1833,7 @@ static void PrintSBookStr(CelOutputBuffer out, int x, int y, bool cjustflag, con spell_type GetSBookTrans(spell_id ii, bool townok) { - if ((plr[myplr]._pClass == PC_MONK) && (ii == SPL_SEARCH)) + if ((plr[myplr]._pClass == plr_class::PC_MONK) && (ii == SPL_SEARCH)) return RSPLTYPE_SKILL; spell_type st = RSPLTYPE_SPELL; if (plr[myplr]._pISpells & GetSpellBitmask(ii)) { diff --git a/Source/effects.cpp b/Source/effects.cpp index 9aa9c0ffc..0d21a4352 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1368,17 +1368,17 @@ void sound_init() mask |= (sfx_ROGUE | sfx_SORCERER); if (gbIsHellfire) mask |= sfx_MONK; - } else if (plr[myplr]._pClass == PC_WARRIOR) { + } else if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { mask |= sfx_WARRIOR; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { mask |= sfx_ROGUE; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { mask |= sfx_SORCERER; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { mask |= sfx_MONK; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { mask |= sfx_ROGUE; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { mask |= sfx_WARRIOR; } else { app_fatal("effects:1"); diff --git a/Source/inv.cpp b/Source/inv.cpp index 5d4b5b879..563f1e709 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -119,20 +119,20 @@ void FreeInvGFX() void InitInv() { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { pInvCels = LoadFileInMem("Data\\Inv\\Inv.CEL", NULL); - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { pInvCels = LoadFileInMem("Data\\Inv\\Inv_rog.CEL", NULL); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { pInvCels = LoadFileInMem("Data\\Inv\\Inv_Sor.CEL", NULL); - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { if (!gbIsSpawn) pInvCels = LoadFileInMem("Data\\Inv\\Inv_Sor.CEL", NULL); else pInvCels = LoadFileInMem("Data\\Inv\\Inv.CEL", NULL); - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { pInvCels = LoadFileInMem("Data\\Inv\\Inv_rog.CEL", NULL); - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { pInvCels = LoadFileInMem("Data\\Inv\\Inv.CEL", NULL); } @@ -353,7 +353,7 @@ void DrawInv(CelOutputBuffer out) } if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) { - if (plr[myplr]._pClass != PC_BARBARIAN + if (plr[myplr]._pClass != plr_class::PC_BARBARIAN || (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_SWORD && plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_MACE)) { InvDrawSlotBack(out, RIGHT_PANEL_X + 248, 160, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); @@ -696,14 +696,14 @@ bool CanWield(int playerNumber, const ItemStruct &item) // Barbarian can wield two handed swords and maces in one hand, so we allow equiping any sword/mace as long as his occupied // hand has a shield (i.e. no dual wielding allowed) - if (player._pClass == PC_BARBARIAN) { + if (player._pClass == plr_class::PC_BARBARIAN) { if (occupiedHand._itype == ITYPE_SHIELD && (item._itype == ITYPE_SWORD || item._itype == ITYPE_MACE)) return true; } // Bard can dual wield swords and maces, so we allow equiping one-handed weapons in her free slot as long as her occupied // slot is another one-handed weapon. - if (player._pClass == PC_BARD) { + if (player._pClass == plr_class::PC_BARD) { bool occupiedHandIsOneHandedSwordOrMace = occupiedHand._iLoc == ILOC_ONEHAND && (occupiedHand._itype == ITYPE_SWORD || occupiedHand._itype == ITYPE_MACE); @@ -823,7 +823,7 @@ bool AutoEquipEnabled(const PlayerStruct &player, const ItemStruct &item) if (item.isWeapon()) { // Monk can use unarmed attack as an encouraged option, thus we do not automatically equip weapons on him so as to not // annoy players who prefer that playstyle. - return player._pClass != PC_MONK && sgOptions.Gameplay.bAutoEquipWeapons; + return player._pClass != plr_class::PC_MONK && sgOptions.Gameplay.bAutoEquipWeapons; } if (item.isArmor()) { @@ -1049,11 +1049,11 @@ bool GoldAutoPlace(int pnum) bool WeaponAutoPlace(int pnum) { - if (plr[pnum]._pClass == PC_MONK) + if (plr[pnum]._pClass == plr_class::PC_MONK) return false; if (plr[pnum].HoldItem._iLoc != ILOC_TWOHAND - || (plr[pnum]._pClass == PC_BARBARIAN && (plr[pnum].HoldItem._itype == ITYPE_SWORD || plr[pnum].HoldItem._itype == ITYPE_MACE))) { - if (plr[pnum]._pClass != PC_BARD) { + || (plr[pnum]._pClass == plr_class::PC_BARBARIAN && (plr[pnum].HoldItem._itype == ITYPE_SWORD || plr[pnum].HoldItem._itype == ITYPE_MACE))) { + if (plr[pnum]._pClass != plr_class::PC_BARD) { if (!plr[pnum].InvBody[INVLOC_HAND_LEFT].isEmpty() && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON) return false; if (!plr[pnum].InvBody[INVLOC_HAND_RIGHT].isEmpty() && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON) @@ -1146,7 +1146,7 @@ void CheckInvPaste(int pnum, int mx, int my) if (plr[pnum].HoldItem._iLoc == il) done = true; if (il == ILOC_ONEHAND && plr[pnum].HoldItem._iLoc == ILOC_TWOHAND) { - if (plr[pnum]._pClass == PC_BARBARIAN + if (plr[pnum]._pClass == plr_class::PC_BARBARIAN && (plr[pnum].HoldItem._itype == ITYPE_SWORD || plr[pnum].HoldItem._itype == ITYPE_MACE)) il = ILOC_ONEHAND; else @@ -1219,17 +1219,17 @@ void CheckInvPaste(int pnum, int mx, int my) if (il != ILOC_UNEQUIPABLE && il != ILOC_BELT && !plr[pnum].HoldItem._iStatFlag) { done = false; - if (plr[pnum]._pClass == PC_WARRIOR) + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) PlaySFX(PS_WARR13); - else if (plr[pnum]._pClass == PC_ROGUE) + else if (plr[pnum]._pClass == plr_class::PC_ROGUE) PlaySFX(PS_ROGUE13); - else if (plr[pnum]._pClass == PC_SORCERER) + else if (plr[pnum]._pClass == plr_class::PC_SORCERER) PlaySFX(PS_MAGE13); - else if (plr[pnum]._pClass == PC_MONK) + else if (plr[pnum]._pClass == plr_class::PC_MONK) PlaySFX(PS_MONK13); - else if (plr[pnum]._pClass == PC_BARD) + else if (plr[pnum]._pClass == plr_class::PC_BARD) PlaySFX(PS_ROGUE13); - else if (plr[pnum]._pClass == PC_BARBARIAN) + else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) PlaySFX(PS_MAGE13); } @@ -1274,7 +1274,7 @@ void CheckInvPaste(int pnum, int mx, int my) if (r <= SLOTXY_HAND_LEFT_LAST) { if (plr[pnum].InvBody[INVLOC_HAND_LEFT].isEmpty()) { if ((plr[pnum].InvBody[INVLOC_HAND_RIGHT].isEmpty() || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass != plr[pnum].HoldItem._iClass) - || (plr[pnum]._pClass == PC_BARD && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON && plr[pnum].HoldItem._iClass == ICLASS_WEAPON)) { + || (plr[pnum]._pClass == plr_class::PC_BARD && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON && plr[pnum].HoldItem._iClass == ICLASS_WEAPON)) { NetSendCmdChItem(false, INVLOC_HAND_LEFT); plr[pnum].InvBody[INVLOC_HAND_LEFT] = plr[pnum].HoldItem; } else { @@ -1284,7 +1284,7 @@ void CheckInvPaste(int pnum, int mx, int my) break; } if ((plr[pnum].InvBody[INVLOC_HAND_RIGHT].isEmpty() || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass != plr[pnum].HoldItem._iClass) - || (plr[pnum]._pClass == PC_BARD && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON && plr[pnum].HoldItem._iClass == ICLASS_WEAPON)) { + || (plr[pnum]._pClass == plr_class::PC_BARD && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON && plr[pnum].HoldItem._iClass == ICLASS_WEAPON)) { NetSendCmdChItem(false, INVLOC_HAND_LEFT); cn = SwapItem(&plr[pnum].InvBody[INVLOC_HAND_LEFT], &plr[pnum].HoldItem); break; @@ -1296,9 +1296,9 @@ void CheckInvPaste(int pnum, int mx, int my) } if (plr[pnum].InvBody[INVLOC_HAND_RIGHT].isEmpty()) { if ((plr[pnum].InvBody[INVLOC_HAND_LEFT].isEmpty() || plr[pnum].InvBody[INVLOC_HAND_LEFT]._iLoc != ILOC_TWOHAND) - || (plr[pnum]._pClass == PC_BARBARIAN && (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SWORD || plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_MACE))) { + || (plr[pnum]._pClass == plr_class::PC_BARBARIAN && (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SWORD || plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_MACE))) { if ((plr[pnum].InvBody[INVLOC_HAND_LEFT].isEmpty() || plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass != plr[pnum].HoldItem._iClass) - || (plr[pnum]._pClass == PC_BARD && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON && plr[pnum].HoldItem._iClass == ICLASS_WEAPON)) { + || (plr[pnum]._pClass == plr_class::PC_BARD && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON && plr[pnum].HoldItem._iClass == ICLASS_WEAPON)) { NetSendCmdChItem(false, INVLOC_HAND_RIGHT); plr[pnum].InvBody[INVLOC_HAND_RIGHT] = plr[pnum].HoldItem; break; @@ -1315,7 +1315,7 @@ void CheckInvPaste(int pnum, int mx, int my) } if ((!plr[pnum].InvBody[INVLOC_HAND_LEFT].isEmpty() && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == plr[pnum].HoldItem._iClass) - && !(plr[pnum]._pClass == PC_BARD && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON && plr[pnum].HoldItem._iClass == ICLASS_WEAPON)) { + && !(plr[pnum]._pClass == plr_class::PC_BARD && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON && plr[pnum].HoldItem._iClass == ICLASS_WEAPON)) { NetSendCmdChItem(false, INVLOC_HAND_LEFT); cn = SwapItem(&plr[pnum].InvBody[INVLOC_HAND_LEFT], &plr[pnum].HoldItem); break; @@ -1742,40 +1742,40 @@ void CheckInvCut(int pnum, int mx, int my, bool automaticMove) if (!automaticallyMoved) { if (CanBePlacedOnBelt(holdItem) || automaticallyUnequip) { switch (player._pClass) { - case PC_WARRIOR: - case PC_BARBARIAN: + case plr_class::PC_WARRIOR: + case plr_class::PC_BARBARIAN: PlaySFX(PS_WARR15, false); break; - case PC_ROGUE: - case PC_BARD: + case plr_class::PC_ROGUE: + case plr_class::PC_BARD: PlaySFX(PS_ROGUE15, false); break; - case PC_SORCERER: + case plr_class::PC_SORCERER: PlaySFX(PS_MAGE15, false); break; - case PC_MONK: + case plr_class::PC_MONK: PlaySFX(PS_MONK15, false); break; - case NUM_CLASSES: + case plr_class::NUM_CLASSES: break; } } else { switch (player._pClass) { - case PC_WARRIOR: - case PC_BARBARIAN: + case plr_class::PC_WARRIOR: + case plr_class::PC_BARBARIAN: PlaySFX(PS_WARR37, false); break; - case PC_ROGUE: - case PC_BARD: + case plr_class::PC_ROGUE: + case plr_class::PC_BARD: PlaySFX(PS_ROGUE37, false); break; - case PC_SORCERER: + case plr_class::PC_SORCERER: PlaySFX(PS_MAGE37, false); break; - case PC_MONK: + case plr_class::PC_MONK: PlaySFX(PS_MONK37, false); break; - case NUM_CLASSES: + case plr_class::NUM_CLASSES: break; } } @@ -1899,17 +1899,17 @@ void CheckQuestItem(int pnum) 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) { sfxdelay = 10; - if (plr[pnum]._pClass == PC_WARRIOR) { // BUGFIX: Voice for this quest might be wrong in MP + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { // BUGFIX: Voice for this quest might be wrong in MP sfxdnum = PS_WARR95; - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE95; - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE95; - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK95; - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE95; - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR95; } quests[Q_MUSHROOM]._qvar1 = QS_MUSHPICKED; @@ -1921,34 +1921,34 @@ void CheckQuestItem(int pnum) } if (quests[Q_ANVIL]._qlog) { sfxdelay = 10; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR89; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE89; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE89; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK89; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE89; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR89; } } } if (plr[pnum].HoldItem.IDidx == IDI_GLDNELIX && quests[Q_VEIL]._qactive != QUEST_NOTAVAIL) { sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR88; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE88; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE88; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK88; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE88; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR88; } } @@ -1959,17 +1959,17 @@ void CheckQuestItem(int pnum) } if (quests[Q_ROCK]._qlog) { sfxdelay = 10; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR87; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE87; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE87; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK87; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE87; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR87; } } @@ -1977,17 +1977,17 @@ void CheckQuestItem(int pnum) if (plr[pnum].HoldItem.IDidx == IDI_ARMOFVAL && quests[Q_BLOOD]._qactive == QUEST_ACTIVE) { quests[Q_BLOOD]._qactive = QUEST_DONE; sfxdelay = 20; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR91; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE91; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE91; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK91; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE91; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR91; } } @@ -1996,17 +1996,17 @@ void CheckQuestItem(int pnum) quests[Q_GRAVE]._qactive = QUEST_ACTIVE; quests[Q_GRAVE]._qvar1 = 1; sfxdelay = 10; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR79; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE79; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE79; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK79; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE79; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR79; } } @@ -2024,17 +2024,17 @@ void CheckQuestItem(int pnum) mask |= 4; if (mask == 7) { sfxdelay = 10; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR46; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE46; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE46; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK46; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE46; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR46; } switch (idx) { @@ -2167,17 +2167,17 @@ void AutoGetItem(int pnum, ItemStruct *item, int ii) } if (pnum == myplr) { - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { PlaySFX(PS_WARR14); - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { PlaySFX(PS_ROGUE14); - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { PlaySFX(PS_MAGE14); - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { PlaySFX(PS_MONK14); - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { PlaySFX(PS_ROGUE14); - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { PlaySFX(PS_WARR14); } } @@ -2529,7 +2529,7 @@ char CheckInvHLight() } else if (r >= SLOTXY_HAND_RIGHT_FIRST && r <= SLOTXY_HAND_RIGHT_LAST) { pi = &p->InvBody[INVLOC_HAND_LEFT]; if (pi->isEmpty() || pi->_iLoc != ILOC_TWOHAND - || (p->_pClass == PC_BARBARIAN && (p->InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SWORD || p->InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_MACE))) { + || (p->_pClass == plr_class::PC_BARBARIAN && (p->InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SWORD || p->InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_MACE))) { rv = INVLOC_HAND_RIGHT; pi = &p->InvBody[rv]; } else { @@ -2699,34 +2699,34 @@ bool UseInvItem(int pnum, int cii) switch (Item->IDidx) { case IDI_MUSHROOM: sfxdelay = 10; - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR95; - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE95; - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE95; - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK95; - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE95; - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR95; } return true; case IDI_FUNGALTM: PlaySFX(IS_IBOOK); sfxdelay = 10; - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR29; - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE29; - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE29; - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK29; - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE29; - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR29; } return true; @@ -2736,17 +2736,17 @@ bool UseInvItem(int pnum, int cii) return false; if (!Item->_iStatFlag) { - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { PlaySFX(PS_WARR13); - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { PlaySFX(PS_ROGUE13); - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { PlaySFX(PS_MAGE13); - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { PlaySFX(PS_MONK13); - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { PlaySFX(PS_ROGUE13); - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { PlaySFX(PS_WARR13); } return true; diff --git a/Source/items.cpp b/Source/items.cpp index d78b19828..180759f46 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -794,7 +794,7 @@ void CalcPlrItemVals(int p, bool Loadgfx) maxd = 3; } - if (plr[p]._pClass == PC_MONK) { + if (plr[p]._pClass == plr_class::PC_MONK) { mind = std::max(mind, plr[p]._pLevel >> 1); maxd = std::max(maxd, (int)plr[p]._pLevel); } @@ -855,9 +855,9 @@ void CalcPlrItemVals(int p, bool Loadgfx) plr[p]._pVitality = 0; } - if (plr[p]._pClass == PC_ROGUE) { + if (plr[p]._pClass == plr_class::PC_ROGUE) { plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 200; - } else if (plr[p]._pClass == PC_MONK) { + } else if (plr[p]._pClass == plr_class::PC_MONK) { if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_STAFF) { if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_STAFF && (!plr[p].InvBody[INVLOC_HAND_LEFT].isEmpty() || !plr[p].InvBody[INVLOC_HAND_RIGHT].isEmpty())) { plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 300; @@ -867,7 +867,7 @@ void CalcPlrItemVals(int p, bool Loadgfx) } else { plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 150; } - } else if (plr[p]._pClass == PC_BARD) { + } else if (plr[p]._pClass == plr_class::PC_BARD) { if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SWORD || plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SWORD) plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 150; else if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_BOW || plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_BOW) { @@ -875,7 +875,7 @@ void CalcPlrItemVals(int p, bool Loadgfx) } else { plr[p]._pDamageMod = plr[p]._pLevel * plr[p]._pStrength / 100; } - } else if (plr[p]._pClass == PC_BARBARIAN) { + } else if (plr[p]._pClass == plr_class::PC_BARBARIAN) { if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_AXE || plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_AXE) { plr[p]._pDamageMod = plr[p]._pLevel * plr[p]._pStrength / 75; @@ -907,7 +907,7 @@ void CalcPlrItemVals(int p, bool Loadgfx) plr[p]._pISplLvlAdd = spllvladd; plr[p]._pIEnAc = enac; - if (plr[p]._pClass == PC_BARBARIAN) { + if (plr[p]._pClass == plr_class::PC_BARBARIAN) { mr += plr[p]._pLevel; fr += plr[p]._pLevel; lr += plr[p]._pLevel; @@ -944,22 +944,22 @@ void CalcPlrItemVals(int p, bool Loadgfx) lr = 0; plr[p]._pLghtResist = lr; - if (plr[p]._pClass == PC_WARRIOR) { + if (plr[p]._pClass == plr_class::PC_WARRIOR) { vadd <<= 1; - } else if (plr[p]._pClass == PC_BARBARIAN) { + } else if (plr[p]._pClass == plr_class::PC_BARBARIAN) { vadd += vadd; vadd += (vadd >> 2); - } else if (plr[p]._pClass == PC_ROGUE || plr[p]._pClass == PC_MONK || plr[p]._pClass == PC_BARD) { + } else if (plr[p]._pClass == plr_class::PC_ROGUE || plr[p]._pClass == plr_class::PC_MONK || plr[p]._pClass == plr_class::PC_BARD) { vadd += vadd >> 1; } ihp += (vadd << 6); // BUGFIX: blood boil can cause negative shifts here (see line 757) - if (plr[p]._pClass == PC_SORCERER) { + if (plr[p]._pClass == plr_class::PC_SORCERER) { madd <<= 1; } - if (plr[p]._pClass == PC_ROGUE || plr[p]._pClass == PC_MONK) { + if (plr[p]._pClass == plr_class::PC_ROGUE || plr[p]._pClass == plr_class::PC_MONK) { madd += madd >> 1; - } else if (plr[p]._pClass == PC_BARD) { + } else if (plr[p]._pClass == plr_class::PC_BARD) { madd += (madd >> 2) + (madd >> 1); } imana += (madd << 6); @@ -990,7 +990,7 @@ void CalcPlrItemVals(int p, bool Loadgfx) } plr[p]._pBlockFlag = false; - if (plr[p]._pClass == PC_MONK) { + if (plr[p]._pClass == plr_class::PC_MONK) { if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_STAFF && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { plr[p]._pBlockFlag = true; plr[p]._pIFlags |= ISPL_FASTBLOCK; @@ -1051,18 +1051,18 @@ void CalcPlrItemVals(int p, bool Loadgfx) } if (plr[p].InvBody[INVLOC_CHEST]._itype == ITYPE_HARMOR && plr[p].InvBody[INVLOC_CHEST]._iStatFlag) { - if (plr[p]._pClass == PC_MONK && plr[p].InvBody[INVLOC_CHEST]._iMagical == ITEM_QUALITY_UNIQUE) + if (plr[p]._pClass == plr_class::PC_MONK && plr[p].InvBody[INVLOC_CHEST]._iMagical == ITEM_QUALITY_UNIQUE) plr[p]._pIAC += plr[p]._pLevel >> 1; g += ANIM_ID_HEAVY_ARMOR; } else if (plr[p].InvBody[INVLOC_CHEST]._itype == ITYPE_MARMOR && plr[p].InvBody[INVLOC_CHEST]._iStatFlag) { - if (plr[p]._pClass == PC_MONK) { + if (plr[p]._pClass == plr_class::PC_MONK) { if (plr[p].InvBody[INVLOC_CHEST]._iMagical == ITEM_QUALITY_UNIQUE) plr[p]._pIAC += plr[p]._pLevel << 1; else plr[p]._pIAC += plr[p]._pLevel >> 1; } g += ANIM_ID_MEDIUM_ARMOR; - } else if (plr[p]._pClass == PC_MONK) { + } else if (plr[p]._pClass == plr_class::PC_MONK) { plr[p]._pIAC += plr[p]._pLevel << 1; } @@ -1401,7 +1401,7 @@ void CreatePlrItems(int p) } switch (plr[p]._pClass) { - case PC_WARRIOR: + case plr_class::PC_WARRIOR: SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], IDI_WARRIOR); GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); @@ -1423,7 +1423,7 @@ void CreatePlrItems(int p) SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL); GetPlrHandSeed(&plr[p].SpdList[1]); break; - case PC_ROGUE: + case plr_class::PC_ROGUE: SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], IDI_ROGUE); GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); @@ -1433,7 +1433,7 @@ void CreatePlrItems(int p) SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL); GetPlrHandSeed(&plr[p].SpdList[1]); break; - case PC_SORCERER: + case plr_class::PC_SORCERER: SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], gbIsHellfire ? IDI_SORCERER : 166); GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); @@ -1444,7 +1444,7 @@ void CreatePlrItems(int p) GetPlrHandSeed(&plr[p].SpdList[1]); break; - case PC_MONK: + case plr_class::PC_MONK: SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], IDI_SHORTSTAFF); GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); SetPlrHandItem(&plr[p].SpdList[0], IDI_HEAL); @@ -1453,7 +1453,7 @@ void CreatePlrItems(int p) SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL); GetPlrHandSeed(&plr[p].SpdList[1]); break; - case PC_BARD: + case plr_class::PC_BARD: SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], IDI_BARDSWORD); GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); @@ -1465,7 +1465,7 @@ void CreatePlrItems(int p) SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL); GetPlrHandSeed(&plr[p].SpdList[1]); break; - case PC_BARBARIAN: + case plr_class::PC_BARBARIAN: SetPlrHandItem(&plr[p].InvBody[INVLOC_HAND_LEFT], 139); // TODO: add more enums to items GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]); @@ -1477,7 +1477,7 @@ void CreatePlrItems(int p) SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL); GetPlrHandSeed(&plr[p].SpdList[1]); break; - case NUM_CLASSES: + case plr_class::NUM_CLASSES: break; } @@ -4231,9 +4231,9 @@ void UseItem(int p, item_misc_id Mid, spell_id spl) case IMISC_FOOD: j = plr[p]._pMaxHP >> 8; l = ((j >> 1) + random_(39, j)) << 6; - if (plr[p]._pClass == PC_WARRIOR || plr[p]._pClass == PC_BARBARIAN) + if (plr[p]._pClass == plr_class::PC_WARRIOR || plr[p]._pClass == plr_class::PC_BARBARIAN) l <<= 1; - if (plr[p]._pClass == PC_ROGUE || plr[p]._pClass == PC_MONK || plr[p]._pClass == PC_BARD) + if (plr[p]._pClass == plr_class::PC_ROGUE || plr[p]._pClass == plr_class::PC_MONK || plr[p]._pClass == plr_class::PC_BARD) l += l >> 1; plr[p]._pHitPoints += l; if (plr[p]._pHitPoints > plr[p]._pMaxHP) @@ -4251,9 +4251,9 @@ void UseItem(int p, item_misc_id Mid, spell_id spl) case IMISC_MANA: j = plr[p]._pMaxMana >> 8; l = ((j >> 1) + random_(40, j)) << 6; - if (plr[p]._pClass == PC_SORCERER) + if (plr[p]._pClass == plr_class::PC_SORCERER) l <<= 1; - if (plr[p]._pClass == PC_ROGUE || plr[p]._pClass == PC_MONK || plr[p]._pClass == PC_BARD) + if (plr[p]._pClass == plr_class::PC_ROGUE || plr[p]._pClass == plr_class::PC_MONK || plr[p]._pClass == plr_class::PC_BARD) l += l >> 1; if (!(plr[p]._pIFlags & ISPL_NOMANA)) { plr[p]._pMana += l; @@ -4297,9 +4297,9 @@ void UseItem(int p, item_misc_id Mid, spell_id spl) case IMISC_REJUV: j = plr[p]._pMaxHP >> 8; l = ((j >> 1) + random_(39, j)) << 6; - if (plr[p]._pClass == PC_WARRIOR || plr[p]._pClass == PC_BARBARIAN) + if (plr[p]._pClass == plr_class::PC_WARRIOR || plr[p]._pClass == plr_class::PC_BARBARIAN) l <<= 1; - if (plr[p]._pClass == PC_ROGUE) + if (plr[p]._pClass == plr_class::PC_ROGUE) l += l >> 1; plr[p]._pHitPoints += l; if (plr[p]._pHitPoints > plr[p]._pMaxHP) @@ -4310,9 +4310,9 @@ void UseItem(int p, item_misc_id Mid, spell_id spl) drawhpflag = true; j = plr[p]._pMaxMana >> 8; l = ((j >> 1) + random_(40, j)) << 6; - if (plr[p]._pClass == PC_SORCERER) + if (plr[p]._pClass == plr_class::PC_SORCERER) l <<= 1; - if (plr[p]._pClass == PC_ROGUE) + if (plr[p]._pClass == plr_class::PC_ROGUE) l += l >> 1; if (!(plr[p]._pIFlags & ISPL_NOMANA)) { plr[p]._pMana += l; @@ -5028,31 +5028,31 @@ void SpawnBoy(int lvl) if (count < 200) { switch (pc) { - case PC_WARRIOR: + case plr_class::PC_WARRIOR: if (itemType == ITYPE_BOW || itemType == ITYPE_STAFF) ivalue = INT_MAX; break; - case PC_ROGUE: + case plr_class::PC_ROGUE: if (itemType == ITYPE_SWORD || itemType == ITYPE_STAFF || itemType == ITYPE_AXE || itemType == ITYPE_MACE || itemType == ITYPE_SHIELD) ivalue = INT_MAX; break; - case PC_SORCERER: + case plr_class::PC_SORCERER: if (itemType == ITYPE_STAFF || itemType == ITYPE_AXE || itemType == ITYPE_BOW || itemType == ITYPE_MACE) ivalue = INT_MAX; break; - case PC_MONK: + case plr_class::PC_MONK: if (itemType == ITYPE_BOW || itemType == ITYPE_MARMOR || itemType == ITYPE_SHIELD || itemType == ITYPE_MACE) ivalue = INT_MAX; break; - case PC_BARD: + case plr_class::PC_BARD: if (itemType == ITYPE_AXE || itemType == ITYPE_MACE || itemType == ITYPE_STAFF) ivalue = INT_MAX; break; - case PC_BARBARIAN: + case plr_class::PC_BARBARIAN: if (itemType == ITYPE_BOW || itemType == ITYPE_STAFF) ivalue = INT_MAX; break; - case NUM_CLASSES: + case plr_class::NUM_CLASSES: break; } } diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index fd3ead39e..55178121f 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -381,7 +381,7 @@ static void LoadPlayer(LoadHelper *file, int p) pPlayer->_pDamageMod = file->nextLE(); pPlayer->_pBaseToBlk = file->nextLE(); if (pPlayer->_pBaseToBlk == 0) - pPlayer->_pBaseToBlk = ToBlkTbl[pPlayer->_pClass]; + pPlayer->_pBaseToBlk = ToBlkTbl[static_cast(pPlayer->_pClass)]; pPlayer->_pHPBase = file->nextLE(); pPlayer->_pMaxHPBase = file->nextLE(); pPlayer->_pHitPoints = file->nextLE(); @@ -1343,7 +1343,7 @@ static void SavePlayer(SaveHelper *file, int p) file->writeLE(pPlayer->_pLvlChanging); file->writeBytes(pPlayer->_pName, PLR_NAME_LEN); - file->writeLE(pPlayer->_pClass); + file->writeLE(static_cast(pPlayer->_pClass)); file->skip(3); // Alignment file->writeLE(pPlayer->_pStrength); file->writeLE(pPlayer->_pBaseStr); diff --git a/Source/missiles.cpp b/Source/missiles.cpp index dc4c46fd2..31a97fd6c 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -37,9 +37,9 @@ void GetDamageAmt(int i, int *mind, int *maxd) break; case SPL_HEAL: /// BUGFIX: healing calculation is unused *mind = plr[myplr]._pLevel + sl + 1; - if (plr[myplr]._pClass == PC_WARRIOR || plr[myplr]._pClass == PC_MONK || plr[myplr]._pClass == PC_BARBARIAN) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR || plr[myplr]._pClass == plr_class::PC_MONK || plr[myplr]._pClass == plr_class::PC_BARBARIAN) { *mind <<= 1; - } else if (plr[myplr]._pClass == PC_ROGUE || plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE || plr[myplr]._pClass == plr_class::PC_BARD) { *mind += *mind >> 1; } *maxd = 10; @@ -49,9 +49,9 @@ void GetDamageAmt(int i, int *mind, int *maxd) for (k = 0; k < sl; k++) { *maxd += 6; } - if (plr[myplr]._pClass == PC_WARRIOR || plr[myplr]._pClass == PC_MONK || plr[myplr]._pClass == PC_BARBARIAN) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR || plr[myplr]._pClass == plr_class::PC_MONK || plr[myplr]._pClass == plr_class::PC_BARBARIAN) { *maxd <<= 1; - } else if (plr[myplr]._pClass == PC_ROGUE || plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE || plr[myplr]._pClass == plr_class::PC_BARD) { *maxd += *maxd >> 1; } *mind = -1; @@ -187,10 +187,10 @@ void GetDamageAmt(int i, int *mind, int *maxd) break; case SPL_HEALOTHER: /// BUGFIX: healing calculation is unused *mind = plr[myplr]._pLevel + sl + 1; - if (plr[myplr]._pClass == PC_WARRIOR || plr[myplr]._pClass == PC_MONK || plr[myplr]._pClass == PC_BARBARIAN) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR || plr[myplr]._pClass == plr_class::PC_MONK || plr[myplr]._pClass == plr_class::PC_BARBARIAN) { *mind <<= 1; } - if (plr[myplr]._pClass == PC_ROGUE || plr[myplr]._pClass == PC_BARD) { + if (plr[myplr]._pClass == plr_class::PC_ROGUE || plr[myplr]._pClass == plr_class::PC_BARD) { *mind += *mind >> 1; } *maxd = 10; @@ -200,10 +200,10 @@ void GetDamageAmt(int i, int *mind, int *maxd) for (k = 0; k < sl; k++) { *maxd += 6; } - if (plr[myplr]._pClass == PC_WARRIOR || plr[myplr]._pClass == PC_MONK || plr[myplr]._pClass == PC_BARBARIAN) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR || plr[myplr]._pClass == plr_class::PC_MONK || plr[myplr]._pClass == plr_class::PC_BARBARIAN) { *maxd <<= 1; } - if (plr[myplr]._pClass == PC_ROGUE || plr[myplr]._pClass == PC_BARD) { + if (plr[myplr]._pClass == plr_class::PC_ROGUE || plr[myplr]._pClass == plr_class::PC_BARD) { *maxd += *maxd >> 1; } *mind = -1; @@ -652,15 +652,15 @@ bool MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist, int t, bool hper -= (dist * dist) >> 1; hper += plr[pnum]._pIEnAc; hper += 50; - if (plr[pnum]._pClass == PC_ROGUE) + if (plr[pnum]._pClass == plr_class::PC_ROGUE) hper += 20; - if (plr[pnum]._pClass == PC_WARRIOR || plr[pnum]._pClass == PC_BARD) + if (plr[pnum]._pClass == plr_class::PC_WARRIOR || plr[pnum]._pClass == plr_class::PC_BARD) hper += 10; } else { hper = plr[pnum]._pMagic - (monster[m].mLevel << 1) - dist + 50; - if (plr[pnum]._pClass == PC_SORCERER) + if (plr[pnum]._pClass == plr_class::PC_SORCERER) hper += 20; - else if (plr[pnum]._pClass == PC_BARD) + else if (plr[pnum]._pClass == plr_class::PC_BARD) hper += 10; } } else { @@ -687,7 +687,7 @@ bool MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist, int t, bool } if (missiledata[t].mType == 0) { dam = plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100 + dam; - if (plr[pnum]._pClass == PC_ROGUE) + if (plr[pnum]._pClass == plr_class::PC_ROGUE) dam += plr[pnum]._pDamageMod; else dam += (plr[pnum]._pDamageMod >> 1); @@ -868,17 +868,17 @@ bool PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, bool s if (plr[pnum]._pHitPoints >> 6 <= 0) { SyncPlrKill(pnum, earflag); } else { - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { PlaySfxLoc(PS_WARR69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { PlaySfxLoc(PS_ROGUE69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { PlaySfxLoc(PS_MAGE69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { PlaySfxLoc(PS_MONK69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { PlaySfxLoc(PS_ROGUE69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { PlaySfxLoc(PS_WARR69, plr[pnum]._px, plr[pnum]._py); } drawhpflag = true; @@ -948,18 +948,18 @@ bool Plr2PlrMHit(int pnum, int p, int mindam, int maxdam, int dist, int mtype, b - plr[p]._pIBonusAC - plr[p]._pIAC + plr[pnum]._pDexterity + 50; - if (plr[pnum]._pClass == PC_ROGUE) + if (plr[pnum]._pClass == plr_class::PC_ROGUE) hit += 20; - if (plr[pnum]._pClass == PC_WARRIOR || plr[pnum]._pClass == PC_BARD) + if (plr[pnum]._pClass == plr_class::PC_WARRIOR || plr[pnum]._pClass == plr_class::PC_BARD) hit += 10; } else { hit = plr[pnum]._pMagic - (plr[p]._pLevel << 1) - dist + 50; - if (plr[pnum]._pClass == PC_SORCERER) + if (plr[pnum]._pClass == plr_class::PC_SORCERER) hit += 20; - else if (plr[pnum]._pClass == PC_BARD) + else if (plr[pnum]._pClass == plr_class::PC_BARD) hit += 10; } if (hit < 5) @@ -998,17 +998,17 @@ bool Plr2PlrMHit(int pnum, int p, int mindam, int maxdam, int dist, int mtype, b dam -= (dam * resper) / 100; if (pnum == myplr) NetSendCmdDamage(true, p, dam); - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { PlaySfxLoc(PS_WARR69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { PlaySfxLoc(PS_ROGUE69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { PlaySfxLoc(PS_MAGE69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { PlaySfxLoc(PS_MONK69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { PlaySfxLoc(PS_ROGUE69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { PlaySfxLoc(PS_WARR69, plr[pnum]._px, plr[pnum]._py); } return true; @@ -1708,9 +1708,9 @@ void AddSpecArrow(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 av = 0; if (mienemy == TARGET_MONSTERS) { - if (plr[id]._pClass == PC_ROGUE) + if (plr[id]._pClass == plr_class::PC_ROGUE) av += (plr[id]._pLevel - 1) >> 2; - else if (plr[id]._pClass == PC_WARRIOR || plr[id]._pClass == PC_BARD) + else if (plr[id]._pClass == plr_class::PC_WARRIOR || plr[id]._pClass == plr_class::PC_BARD) av += (plr[id]._pLevel - 1) >> 3; if (plr[id]._pIFlags & ISPL_QUICKATTACK) @@ -1916,9 +1916,9 @@ void AddMana(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 midir for (i = 0; i < missile[mi]._mispllvl; i++) { ManaAmount += (random_(57, 6) + 1) << 6; } - if (plr[id]._pClass == PC_SORCERER) + if (plr[id]._pClass == plr_class::PC_SORCERER) ManaAmount <<= 1; - if (plr[id]._pClass == PC_ROGUE || plr[id]._pClass == PC_BARD) + if (plr[id]._pClass == plr_class::PC_ROGUE || plr[id]._pClass == plr_class::PC_BARD) ManaAmount += ManaAmount >> 1; plr[id]._pMana += ManaAmount; if (plr[id]._pMana > plr[id]._pMaxMana) @@ -2055,9 +2055,9 @@ void AddLArrow(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 mid if (mienemy == TARGET_MONSTERS) { int av = 32; - if (plr[id]._pClass == PC_ROGUE) + if (plr[id]._pClass == plr_class::PC_ROGUE) av += (plr[id]._pLevel) >> 2; - else if (plr[id]._pClass == PC_WARRIOR || plr[id]._pClass == PC_BARD) + else if (plr[id]._pClass == plr_class::PC_WARRIOR || plr[id]._pClass == plr_class::PC_BARD) av += (plr[id]._pLevel) >> 3; if (gbIsHellfire) { @@ -2070,7 +2070,7 @@ void AddLArrow(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 mid if (plr[id]._pIFlags & ISPL_FASTESTATTACK) av += 8; } else { - if (plr[id]._pClass == PC_ROGUE || plr[id]._pClass == PC_WARRIOR || plr[id]._pClass == PC_BARD) + if (plr[id]._pClass == plr_class::PC_ROGUE || plr[id]._pClass == plr_class::PC_WARRIOR || plr[id]._pClass == plr_class::PC_BARD) av -= 1; } @@ -2098,9 +2098,9 @@ void AddArrow(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 midi if (plr[id]._pIFlags & ISPL_RNDARROWVEL) { av = random_(64, 32) + 16; } - if (plr[id]._pClass == PC_ROGUE) + if (plr[id]._pClass == plr_class::PC_ROGUE) av += (plr[id]._pLevel - 1) >> 2; - else if (plr[id]._pClass == PC_WARRIOR || plr[id]._pClass == PC_BARD) + else if (plr[id]._pClass == plr_class::PC_WARRIOR || plr[id]._pClass == plr_class::PC_BARD) av += (plr[id]._pLevel - 1) >> 3; if (gbIsHellfire) { if (plr[id]._pIFlags & ISPL_QUICKATTACK) @@ -2923,9 +2923,9 @@ void AddHeal(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 midir HealAmount += (random_(57, 6) + 1) << 6; } - if (plr[id]._pClass == PC_WARRIOR || plr[id]._pClass == PC_BARBARIAN || plr[id]._pClass == PC_MONK) + if (plr[id]._pClass == plr_class::PC_WARRIOR || plr[id]._pClass == plr_class::PC_BARBARIAN || plr[id]._pClass == plr_class::PC_MONK) HealAmount <<= 1; - else if (plr[id]._pClass == PC_ROGUE || plr[id]._pClass == PC_BARD) + else if (plr[id]._pClass == plr_class::PC_ROGUE || plr[id]._pClass == plr_class::PC_BARD) HealAmount += HealAmount >> 1; plr[id]._pHitPoints += HealAmount; @@ -3084,7 +3084,7 @@ void AddBlodboil(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 m if (id == -1 || plr[id]._pSpellFlags & 6 || plr[id]._pHitPoints <= plr[id]._pLevel << 6) { missile[mi]._miDelFlag = true; } else { - _sfx_id blodboilSFX[NUM_CLASSES] = { + _sfx_id blodboilSFX[static_cast(plr_class::NUM_CLASSES)] = { PS_WARR70, PS_ROGUE70, PS_MAGE70, @@ -3104,7 +3104,7 @@ void AddBlodboil(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 m missile[mi]._mirange = lvl + 10 * missile[mi]._mispllvl + 245; CalcPlrItemVals(id, true); force_redraw = 255; - PlaySfxLoc(blodboilSFX[plr[id]._pClass], plr[id]._px, plr[id]._py); + PlaySfxLoc(blodboilSFX[static_cast(plr[id]._pClass)], plr[id]._px, plr[id]._py); } } @@ -5234,7 +5234,7 @@ void MI_Blodboil(Sint32 i) if (missile[i]._mirange == 0) { id = missile[i]._miVar1; if ((plr[id]._pSpellFlags & 2) == 2) { - _sfx_id blodboilSFX[NUM_CLASSES] = { + _sfx_id blodboilSFX[static_cast(plr_class::NUM_CLASSES)] = { PS_WARR72, PS_ROGUE72, PS_MAGE72, @@ -5254,9 +5254,9 @@ void MI_Blodboil(Sint32 i) if (plr[id]._pHitPoints < 64) plr[id]._pHitPoints = 64; force_redraw = 255; - PlaySfxLoc(blodboilSFX[plr[id]._pClass], plr[id]._px, plr[id]._py); + PlaySfxLoc(blodboilSFX[static_cast(plr[id]._pClass)], plr[id]._px, plr[id]._py); } else { - _sfx_id blodboilSFX[NUM_CLASSES] = { + _sfx_id blodboilSFX[static_cast(plr_class::NUM_CLASSES)] = { PS_WARR72, PS_ROGUE72, PS_MAGE72, @@ -5272,7 +5272,7 @@ void MI_Blodboil(Sint32 i) if (plr[id]._pHitPoints < 64) plr[id]._pHitPoints = 64; force_redraw = 255; - PlaySfxLoc(blodboilSFX[plr[id]._pClass], plr[id]._px, plr[id]._py); + PlaySfxLoc(blodboilSFX[static_cast(plr[id]._pClass)], plr[id]._px, plr[id]._py); } } } diff --git a/Source/monster.cpp b/Source/monster.cpp index e37c473f7..c428a17b8 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -2629,11 +2629,11 @@ void DoEnding() if (gbIsSpawn) return; - if (plr[myplr]._pClass == PC_WARRIOR || plr[myplr]._pClass == PC_BARBARIAN) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR || plr[myplr]._pClass == plr_class::PC_BARBARIAN) { play_movie("gendata\\DiabVic2.smk", false); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { play_movie("gendata\\DiabVic1.smk", false); - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { play_movie("gendata\\DiabVic1.smk", false); } else { play_movie("gendata\\DiabVic3.smk", false); diff --git a/Source/objects.cpp b/Source/objects.cpp index 23f0ac3f7..cc2f79a8d 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1075,17 +1075,17 @@ void InitObjects() AddL2Objs(0, 0, MAXDUNX, MAXDUNY); AddL2Torches(); if (QuestStatus(Q_BLIND)) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sp_id = TEXT_BLINDING; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sp_id = TEXT_RBLINDING; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sp_id = TEXT_MBLINDING; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sp_id = TEXT_HBLINDING; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sp_id = TEXT_BBLINDING; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sp_id = TEXT_BLINDING; } quests[Q_BLIND]._qmsg = sp_id; @@ -1095,17 +1095,17 @@ void InitObjects() mem_free_dbg(mem); } if (QuestStatus(Q_BLOOD)) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sp_id = TEXT_BLOODY; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sp_id = TEXT_RBLOODY; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sp_id = TEXT_MBLOODY; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sp_id = TEXT_HBLOODY; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sp_id = TEXT_BBLOODY; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sp_id = TEXT_BLOODY; } quests[Q_BLOOD]._qmsg = sp_id; @@ -1120,17 +1120,17 @@ void InitObjects() } if (leveltype == DTYPE_HELL) { if (QuestStatus(Q_WARLORD)) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sp_id = TEXT_BLOODWAR; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sp_id = TEXT_RBLOODWAR; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sp_id = TEXT_MBLOODWAR; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sp_id = TEXT_HBLOODWAR; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sp_id = TEXT_BBLOODWAR; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sp_id = TEXT_BLOODWAR; } quests[Q_WARLORD]._qmsg = sp_id; @@ -1653,47 +1653,47 @@ void objects_44DA68(int i, int a2) object[i]._oVar8 = a2; switch (a2) { case 6: - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { object[i]._oVar2 = TEXT_BOOKA; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { object[i]._oVar2 = TEXT_RBOOKA; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { object[i]._oVar2 = TEXT_MBOOKA; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { object[i]._oVar2 = TEXT_OBOOKA; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { object[i]._oVar2 = TEXT_BBOOKA; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { object[i]._oVar2 = TEXT_BOOKA; } break; case 7: - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { object[i]._oVar2 = TEXT_BOOKB; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { object[i]._oVar2 = TEXT_RBOOKB; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { object[i]._oVar2 = TEXT_MBOOKB; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { object[i]._oVar2 = TEXT_OBOOKB; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { object[i]._oVar2 = TEXT_BBOOKB; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { object[i]._oVar2 = TEXT_BOOKB; } break; case 8: - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { object[i]._oVar2 = TEXT_BOOKC; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { object[i]._oVar2 = TEXT_RBOOKC; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { object[i]._oVar2 = TEXT_MBOOKC; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { object[i]._oVar2 = TEXT_OBOOKC; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { object[i]._oVar2 = TEXT_BBOOKC; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { object[i]._oVar2 = TEXT_BOOKC; } break; @@ -2122,17 +2122,17 @@ void Obj_BCrossDamage(int i) if (plr[myplr]._pHitPoints >> 6 <= 0) { SyncPlrKill(myplr, 0); } else { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { PlaySfxLoc(PS_WARR68, plr[myplr]._px, plr[myplr]._py); - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { PlaySfxLoc(PS_ROGUE68, plr[myplr]._px, plr[myplr]._py); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { PlaySfxLoc(PS_MAGE68, plr[myplr]._px, plr[myplr]._py); - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { PlaySfxLoc(PS_MONK68, plr[myplr]._px, plr[myplr]._py); - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { PlaySfxLoc(PS_ROGUE68, plr[myplr]._px, plr[myplr]._py); - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { PlaySfxLoc(PS_WARR68, plr[myplr]._px, plr[myplr]._py); } } @@ -3055,17 +3055,17 @@ void OperateSChambBk(int pnum, int i) quests[Q_SCHAMB]._qactive = QUEST_ACTIVE; quests[Q_SCHAMB]._qlog = true; } - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { textdef = TEXT_BONER; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { textdef = TEXT_RBONER; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { textdef = TEXT_MBONER; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { textdef = TEXT_HBONER; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { textdef = TEXT_BBONER; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { textdef = TEXT_BONER; } quests[Q_SCHAMB]._qmsg = textdef; @@ -3140,17 +3140,17 @@ void OperateMushPatch(int pnum, int i) if (quests[Q_MUSHROOM]._qactive != QUEST_ACTIVE || quests[Q_MUSHROOM]._qvar1 < QS_TOMEGIVEN) { if (!deltaload && pnum == myplr) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { PlaySFX(PS_WARR13); - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { PlaySFX(PS_ROGUE13); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { PlaySFX(PS_MAGE13); - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { PlaySFX(PS_MONK13); - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { PlaySFX(PS_ROGUE13); - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { PlaySFX(PS_WARR13); } } @@ -3179,17 +3179,17 @@ void OperateInnSignChest(int pnum, int i) if (quests[Q_LTBANNER]._qvar1 != 2) { if (!deltaload && pnum == myplr) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { PlaySFX(PS_WARR24); - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { PlaySFX(PS_ROGUE24); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { PlaySFX(PS_MAGE24); - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { PlaySFX(PS_MONK24); - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { PlaySFX(PS_ROGUE24); - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { PlaySFX(PS_WARR24); } } @@ -3212,22 +3212,22 @@ void OperateSlainHero(int pnum, int i, bool sendmsg) if (object[i]._oSelFlag != 0) { object[i]._oSelFlag = 0; if (!deltaload) { - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { CreateMagicArmor(object[i]._ox, object[i]._oy, ITYPE_HARMOR, ICURS_BREAST_PLATE, false, true); PlaySfxLoc(PS_WARR9, plr[myplr]._px, plr[myplr]._py); - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { CreateMagicWeapon(object[i]._ox, object[i]._oy, ITYPE_BOW, ICURS_LONG_WAR_BOW, false, true); PlaySfxLoc(PS_ROGUE9, plr[myplr]._px, plr[myplr]._py); - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { CreateSpellBook(object[i]._ox, object[i]._oy, SPL_LIGHTNING, false, true); PlaySfxLoc(PS_MAGE9, plr[myplr]._px, plr[myplr]._py); - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { CreateMagicWeapon(object[i]._ox, object[i]._oy, ITYPE_STAFF, ICURS_WAR_STAFF, false, true); PlaySfxLoc(PS_MONK9, plr[myplr]._px, plr[myplr]._py); - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { CreateMagicWeapon(object[i]._ox, object[i]._oy, ITYPE_SWORD, ICURS_BASTARD_SWORD, false, true); PlaySfxLoc(PS_ROGUE9, plr[myplr]._px, plr[myplr]._py); - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { CreateMagicWeapon(object[i]._ox, object[i]._oy, ITYPE_AXE, ICURS_BATTLE_AXE, false, true); PlaySfxLoc(PS_WARR9, plr[myplr]._px, plr[myplr]._py); } @@ -4133,27 +4133,27 @@ bool OperateShrineOily(int pnum, int x, int y) return false; switch (plr[myplr]._pClass) { - case PC_WARRIOR: + case plr_class::PC_WARRIOR: ModifyPlrStr(myplr, 2); break; - case PC_ROGUE: + case plr_class::PC_ROGUE: ModifyPlrDex(myplr, 2); break; - case PC_SORCERER: + case plr_class::PC_SORCERER: ModifyPlrMag(myplr, 2); break; - case PC_BARBARIAN: + case plr_class::PC_BARBARIAN: ModifyPlrVit(myplr, 2); break; - case PC_MONK: + case plr_class::PC_MONK: ModifyPlrStr(myplr, 1); ModifyPlrDex(myplr, 1); break; - case PC_BARD: + case plr_class::PC_BARD: ModifyPlrDex(myplr, 1); ModifyPlrMag(myplr, 1); break; - case NUM_CLASSES: + case plr_class::NUM_CLASSES: break; } @@ -5594,7 +5594,7 @@ void GetObjectStr(int i) default: break; } - if (plr[myplr]._pClass == PC_ROGUE) { + if (plr[myplr]._pClass == plr_class::PC_ROGUE) { if (object[i]._oTrapFlag) { sprintf(tempstr, "Trapped %s", infostr); strcpy(infostr, tempstr); diff --git a/Source/pack.cpp b/Source/pack.cpp index 8c6bdb0a7..2905d5659 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -61,7 +61,7 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, bool manashield) pPack->targx = pPlayer->_ptargx; pPack->targy = pPlayer->_ptargy; strcpy(pPack->pName, pPlayer->_pName); - pPack->pClass = pPlayer->_pClass; + pPack->pClass = static_cast(pPlayer->_pClass); pPack->pBaseStr = pPlayer->_pBaseStr; pPack->pBaseMag = pPlayer->_pBaseMag; pPack->pBaseDex = pPlayer->_pBaseDex; @@ -233,7 +233,7 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool netSync) pPlayer->_pGold = SwapLE32(pPack->pGold); pPlayer->_pMaxHPBase = SwapLE32(pPack->pMaxHPBase); pPlayer->_pHPBase = SwapLE32(pPack->pHPBase); - pPlayer->_pBaseToBlk = ToBlkTbl[pPlayer->_pClass]; + pPlayer->_pBaseToBlk = ToBlkTbl[static_cast(pPlayer->_pClass)]; if (!netSync) if ((int)(pPlayer->_pHPBase & 0xFFFFFFC0) < 64) pPlayer->_pHPBase = 64; diff --git a/Source/player.cpp b/Source/player.cpp index a30cf8102..7100c2602 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -42,7 +42,7 @@ int plrxoff2[9] = { 0, 1, 0, 1, 2, 0, 1, 2, 2 }; /** Specifies the Y-coordinate delta from a player, used for instanced when casting resurrect. */ int plryoff2[9] = { 0, 0, 1, 1, 0, 2, 2, 1, 2 }; /** Specifies the frame of each animation for which an action is triggered, for each player class. */ -char PlrGFXAnimLens[NUM_CLASSES][11] = { +char PlrGFXAnimLens[static_cast(plr_class::NUM_CLASSES)][11] = { { 10, 16, 8, 2, 20, 20, 6, 20, 8, 9, 14 }, { 8, 18, 8, 4, 20, 16, 7, 20, 8, 10, 12 }, { 8, 16, 8, 6, 20, 12, 8, 20, 8, 12, 8 }, @@ -51,7 +51,7 @@ char PlrGFXAnimLens[NUM_CLASSES][11] = { { 10, 16, 8, 2, 20, 20, 6, 20, 8, 9, 14 }, }; /** Maps from player class to player velocity. */ -int PWVel[NUM_CLASSES][3] = { +int PWVel[static_cast(plr_class::NUM_CLASSES)][3] = { { 2048, 1024, 512 }, { 2048, 1024, 512 }, { 2048, 1024, 512 }, @@ -60,7 +60,7 @@ int PWVel[NUM_CLASSES][3] = { { 2048, 1024, 512 }, }; /** Total number of frames in walk animation. */ -int AnimLenFromClass[NUM_CLASSES] = { +int AnimLenFromClass[static_cast(plr_class::NUM_CLASSES)] = { 8, 8, 8, @@ -69,7 +69,7 @@ int AnimLenFromClass[NUM_CLASSES] = { 8, }; /** Maps from player_class to starting stat in strength. */ -int StrengthTbl[NUM_CLASSES] = { +int StrengthTbl[static_cast(plr_class::NUM_CLASSES)] = { 30, 20, 15, @@ -78,7 +78,7 @@ int StrengthTbl[NUM_CLASSES] = { 40, }; /** Maps from player_class to starting stat in magic. */ -int MagicTbl[NUM_CLASSES] = { +int MagicTbl[static_cast(plr_class::NUM_CLASSES)] = { // clang-format off 10, 15, @@ -89,7 +89,7 @@ int MagicTbl[NUM_CLASSES] = { // clang-format on }; /** Maps from player_class to starting stat in dexterity. */ -int DexterityTbl[NUM_CLASSES] = { +int DexterityTbl[static_cast(plr_class::NUM_CLASSES)] = { 20, 30, 15, @@ -98,7 +98,7 @@ int DexterityTbl[NUM_CLASSES] = { 20, }; /** Maps from player_class to starting stat in vitality. */ -int VitalityTbl[NUM_CLASSES] = { +int VitalityTbl[static_cast(plr_class::NUM_CLASSES)] = { 25, 20, 20, @@ -107,7 +107,7 @@ int VitalityTbl[NUM_CLASSES] = { 25, }; /** Specifies the chance to block bonus of each player class.*/ -int ToBlkTbl[NUM_CLASSES] = { +int ToBlkTbl[static_cast(plr_class::NUM_CLASSES)] = { 30, 20, 10, @@ -197,7 +197,7 @@ Sint32 PlayerStruct::GetBaseAttributeValue(attribute_id attribute) const Sint32 PlayerStruct::GetMaximumAttributeValue(attribute_id attribute) const { - static const int MaxStats[NUM_CLASSES][4] = { + static const int MaxStats[static_cast(plr_class::NUM_CLASSES)][4] = { // clang-format off { 250, 50, 60, 100 }, { 55, 70, 250, 80 }, @@ -208,7 +208,7 @@ Sint32 PlayerStruct::GetMaximumAttributeValue(attribute_id attribute) const // clang-format on }; - return MaxStats[_pClass][attribute]; + return MaxStats[static_cast(_pClass)][attribute]; } void SetPlayerGPtrs(BYTE *pData, BYTE **pAnim) @@ -236,14 +236,14 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) p = &plr[pnum]; plr_class c = p->_pClass; - if (c == PC_BARD && hfbard_mpq == NULL) { - c = PC_ROGUE; - } else if (c == PC_BARBARIAN && hfbarb_mpq == NULL) { - c = PC_WARRIOR; + if (c == plr_class::PC_BARD && hfbard_mpq == NULL) { + c = plr_class::PC_ROGUE; + } else if (c == plr_class::PC_BARBARIAN && hfbarb_mpq == NULL) { + c = plr_class::PC_WARRIOR; } - sprintf(prefix, "%c%c%c", CharChar[c], ArmourChar[p->_pgfxnum >> 4], WepChar[p->_pgfxnum & 0xF]); - const char *cs = ClassPathTbl[c]; + sprintf(prefix, "%c%c%c", CharChar[static_cast(c)], ArmourChar[p->_pgfxnum >> 4], WepChar[p->_pgfxnum & 0xF]); + const char *cs = ClassPathTbl[static_cast(c)]; for (i = 1; i <= PFILE_NONDEATH; i <<= 1) { if (!(i & gfxflag)) { @@ -355,10 +355,10 @@ void InitPlayerGFX(int pnum) static plr_class GetPlrGFXClass(plr_class c) { switch (c) { - case PC_BARD: - return hfbard_mpq == nullptr ? PC_ROGUE : c; - case PC_BARBARIAN: - return hfbarb_mpq == nullptr ? PC_WARRIOR : c; + case plr_class::PC_BARD: + return hfbard_mpq == nullptr ? plr_class::PC_ROGUE : c; + case plr_class::PC_BARBARIAN: + return hfbarb_mpq == nullptr ? plr_class::PC_WARRIOR : c; default: return c; } @@ -385,8 +385,8 @@ static DWORD GetPlrGFXSize(plr_class c, const char *szCel) if (szCel[0] == 'B' && szCel[1] == 'L' && (*w != 'U' && *w != 'D' && *w != 'H')) { continue; //No block without weapon } - sprintf(Type, "%c%c%c", CharChar[c], *a, *w); - sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassPathTbl[c], Type, Type, szCel); + sprintf(Type, "%c%c%c", CharChar[static_cast(c)], *a, *w); + sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassPathTbl[static_cast(c)], Type, Type, szCel); if (SFileOpenFile(pszName, &hsFile)) { assert(hsFile); dwSize = SFileGetFileSize(hsFile, NULL); @@ -506,24 +506,24 @@ void SetPlrAnims(int pnum) plr_class pc = plr[pnum]._pClass; if (leveltype == DTYPE_TOWN) { - plr[pnum]._pNFrames = PlrGFXAnimLens[pc][7]; - plr[pnum]._pWFrames = PlrGFXAnimLens[pc][8]; - plr[pnum]._pDFrames = PlrGFXAnimLens[pc][4]; - plr[pnum]._pSFrames = PlrGFXAnimLens[pc][5]; + plr[pnum]._pNFrames = PlrGFXAnimLens[static_cast(pc)][7]; + plr[pnum]._pWFrames = PlrGFXAnimLens[static_cast(pc)][8]; + plr[pnum]._pDFrames = PlrGFXAnimLens[static_cast(pc)][4]; + plr[pnum]._pSFrames = PlrGFXAnimLens[static_cast(pc)][5]; } else { - plr[pnum]._pNFrames = PlrGFXAnimLens[pc][0]; - plr[pnum]._pWFrames = PlrGFXAnimLens[pc][2]; - plr[pnum]._pAFrames = PlrGFXAnimLens[pc][1]; - plr[pnum]._pHFrames = PlrGFXAnimLens[pc][6]; - plr[pnum]._pSFrames = PlrGFXAnimLens[pc][5]; - plr[pnum]._pDFrames = PlrGFXAnimLens[pc][4]; - plr[pnum]._pBFrames = PlrGFXAnimLens[pc][3]; - plr[pnum]._pAFNum = PlrGFXAnimLens[pc][9]; + plr[pnum]._pNFrames = PlrGFXAnimLens[static_cast(pc)][0]; + plr[pnum]._pWFrames = PlrGFXAnimLens[static_cast(pc)][2]; + plr[pnum]._pAFrames = PlrGFXAnimLens[static_cast(pc)][1]; + plr[pnum]._pHFrames = PlrGFXAnimLens[static_cast(pc)][6]; + plr[pnum]._pSFrames = PlrGFXAnimLens[static_cast(pc)][5]; + plr[pnum]._pDFrames = PlrGFXAnimLens[static_cast(pc)][4]; + plr[pnum]._pBFrames = PlrGFXAnimLens[static_cast(pc)][3]; + plr[pnum]._pAFNum = PlrGFXAnimLens[static_cast(pc)][9]; } - plr[pnum]._pSFNum = PlrGFXAnimLens[pc][10]; + plr[pnum]._pSFNum = PlrGFXAnimLens[static_cast(pc)][10]; anim_weapon_id gn = static_cast(plr[pnum]._pgfxnum & 0xF); - if (pc == PC_WARRIOR) { + if (pc == plr_class::PC_WARRIOR) { if (gn == ANIM_ID_BOW) { if (leveltype != DTYPE_TOWN) { plr[pnum]._pNFrames = 8; @@ -537,7 +537,7 @@ void SetPlrAnims(int pnum) plr[pnum]._pAFrames = 16; plr[pnum]._pAFNum = 11; } - } else if (pc == PC_ROGUE) { + } else if (pc == plr_class::PC_ROGUE) { if (gn == ANIM_ID_AXE) { plr[pnum]._pAFrames = 22; plr[pnum]._pAFNum = 13; @@ -548,7 +548,7 @@ void SetPlrAnims(int pnum) plr[pnum]._pAFrames = 16; plr[pnum]._pAFNum = 11; } - } else if (pc == PC_SORCERER) { + } else if (pc == plr_class::PC_SORCERER) { plr[pnum]._pSWidth = 128; if (gn == ANIM_ID_UNARMED) { plr[pnum]._pAFrames = 20; @@ -561,7 +561,7 @@ void SetPlrAnims(int pnum) plr[pnum]._pAFrames = 24; plr[pnum]._pAFNum = 16; } - } else if (pc == PC_MONK) { + } else if (pc == plr_class::PC_MONK) { plr[pnum]._pNWidth = 112; plr[pnum]._pWWidth = 112; plr[pnum]._pAWidth = 130; @@ -591,7 +591,7 @@ void SetPlrAnims(int pnum) default: break; } - } else if (pc == PC_BARD) { + } else if (pc == plr_class::PC_BARD) { if (gn == ANIM_ID_AXE) { plr[pnum]._pAFrames = 22; plr[pnum]._pAFNum = 13; @@ -604,7 +604,7 @@ void SetPlrAnims(int pnum) } else if (gn == ANIM_ID_SWORD_SHIELD || gn == ANIM_ID_SWORD) { plr[pnum]._pAFrames = 10; } - } else if (pc == PC_BARBARIAN) { + } else if (pc == plr_class::PC_BARBARIAN) { if (gn == ANIM_ID_AXE) { plr[pnum]._pAFrames = 20; plr[pnum]._pAFNum = 8; @@ -640,19 +640,19 @@ void CreatePlayer(int pnum, plr_class c) } plr[pnum]._pClass = c; - val = StrengthTbl[c]; + val = StrengthTbl[static_cast(c)]; plr[pnum]._pStrength = val; plr[pnum]._pBaseStr = val; - val = MagicTbl[c]; + val = MagicTbl[static_cast(c)]; plr[pnum]._pMagic = val; plr[pnum]._pBaseMag = val; - val = DexterityTbl[c]; + val = DexterityTbl[static_cast(c)]; plr[pnum]._pDexterity = val; plr[pnum]._pBaseDex = val; - val = VitalityTbl[c]; + val = VitalityTbl[static_cast(c)]; plr[pnum]._pVitality = val; plr[pnum]._pBaseVit = val; @@ -666,20 +666,20 @@ void CreatePlayer(int pnum, plr_class c) plr[pnum]._pLevel = 1; - if (plr[pnum]._pClass == PC_MONK) { + if (plr[pnum]._pClass == plr_class::PC_MONK) { plr[pnum]._pDamageMod = (plr[pnum]._pStrength + plr[pnum]._pDexterity) * plr[pnum]._pLevel / 150; - } else if (plr[pnum]._pClass == PC_ROGUE || plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE || plr[pnum]._pClass == plr_class::PC_BARD) { plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; } else { plr[pnum]._pDamageMod = plr[pnum]._pStrength * plr[pnum]._pLevel / 100; } - plr[pnum]._pBaseToBlk = ToBlkTbl[c]; + plr[pnum]._pBaseToBlk = ToBlkTbl[static_cast(c)]; plr[pnum]._pHitPoints = (plr[pnum]._pVitality + 10) << 6; - if (plr[pnum]._pClass == PC_WARRIOR || plr[pnum]._pClass == PC_BARBARIAN) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR || plr[pnum]._pClass == plr_class::PC_BARBARIAN) { plr[pnum]._pHitPoints <<= 1; - } else if (plr[pnum]._pClass == PC_ROGUE || plr[pnum]._pClass == PC_MONK || plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE || plr[pnum]._pClass == plr_class::PC_MONK || plr[pnum]._pClass == plr_class::PC_BARD) { plr[pnum]._pHitPoints += plr[pnum]._pHitPoints >> 1; } @@ -688,11 +688,11 @@ void CreatePlayer(int pnum, plr_class c) plr[pnum]._pMaxHPBase = plr[pnum]._pHitPoints; plr[pnum]._pMana = plr[pnum]._pMagic << 6; - if (plr[pnum]._pClass == PC_SORCERER) { + if (plr[pnum]._pClass == plr_class::PC_SORCERER) { plr[pnum]._pMana <<= 1; - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { plr[pnum]._pMana += plr[pnum]._pMana * 3 / 4; - } else if (plr[pnum]._pClass == PC_ROGUE || plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE || plr[pnum]._pClass == plr_class::PC_MONK) { plr[pnum]._pMana += plr[pnum]._pMana >> 1; } @@ -705,7 +705,7 @@ void CreatePlayer(int pnum, plr_class c) plr[pnum]._pMaxExp = plr[pnum]._pExperience; plr[pnum]._pNextExper = ExpLvlsTbl[1]; plr[pnum]._pArmorClass = 0; - if (plr[pnum]._pClass == PC_BARBARIAN) { + if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { plr[pnum]._pMagResist = 1; plr[pnum]._pFireResist = 1; plr[pnum]._pLghtResist = 1; @@ -718,27 +718,27 @@ void CreatePlayer(int pnum, plr_class c) plr[pnum]._pInfraFlag = false; plr[pnum]._pRSplType = RSPLTYPE_SKILL; - if (c == PC_WARRIOR) { + if (c == plr_class::PC_WARRIOR) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_REPAIR); plr[pnum]._pRSpell = SPL_REPAIR; - } else if (c == PC_ROGUE) { + } else if (c == plr_class::PC_ROGUE) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_DISARM); plr[pnum]._pRSpell = SPL_DISARM; - } else if (c == PC_SORCERER) { + } else if (c == plr_class::PC_SORCERER) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_RECHARGE); plr[pnum]._pRSpell = SPL_RECHARGE; - } else if (c == PC_MONK) { + } else if (c == plr_class::PC_MONK) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_SEARCH); plr[pnum]._pRSpell = SPL_SEARCH; - } else if (c == PC_BARD) { + } else if (c == plr_class::PC_BARD) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_IDENTIFY); plr[pnum]._pRSpell = SPL_IDENTIFY; - } else if (c == PC_BARBARIAN) { + } else if (c == plr_class::PC_BARBARIAN) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_BLODBOIL); plr[pnum]._pRSpell = SPL_BLODBOIL; } - if (c == PC_SORCERER) { + if (c == plr_class::PC_SORCERER) { plr[pnum]._pMemSpells = GetSpellBitmask(SPL_FIREBOLT); plr[pnum]._pRSplType = RSPLTYPE_SPELL; plr[pnum]._pRSpell = SPL_FIREBOLT; @@ -752,7 +752,7 @@ void CreatePlayer(int pnum, plr_class c) plr[pnum]._pSpellFlags = 0; - if (plr[pnum]._pClass == PC_SORCERER) { + if (plr[pnum]._pClass == plr_class::PC_SORCERER) { plr[pnum]._pSplLvl[SPL_FIREBOLT] = 2; } @@ -762,17 +762,17 @@ void CreatePlayer(int pnum, plr_class c) plr[pnum]._pSplHotKey[i] = SPL_INVALID; } - if (c == PC_WARRIOR) { + if (c == plr_class::PC_WARRIOR) { plr[pnum]._pgfxnum = ANIM_ID_SWORD_SHIELD; - } else if (c == PC_ROGUE) { + } else if (c == plr_class::PC_ROGUE) { plr[pnum]._pgfxnum = ANIM_ID_BOW; - } else if (c == PC_SORCERER) { + } else if (c == plr_class::PC_SORCERER) { plr[pnum]._pgfxnum = ANIM_ID_STAFF; - } else if (c == PC_MONK) { + } else if (c == plr_class::PC_MONK) { plr[pnum]._pgfxnum = ANIM_ID_STAFF; - } else if (c == PC_BARD) { + } else if (c == plr_class::PC_BARD) { plr[pnum]._pgfxnum = ANIM_ID_SWORD_SHIELD; - } else if (c == PC_BARBARIAN) { + } else if (c == plr_class::PC_BARBARIAN) { plr[pnum]._pgfxnum = ANIM_ID_SWORD_SHIELD; } @@ -830,7 +830,7 @@ void NextPlrLevel(int pnum) plr[pnum]._pNextExper = ExpLvlsTbl[plr[pnum]._pLevel]; - hp = plr[pnum]._pClass == PC_SORCERER ? 64 : 128; + hp = plr[pnum]._pClass == plr_class::PC_SORCERER ? 64 : 128; if (!gbIsMultiplayer) { hp++; } @@ -843,9 +843,9 @@ void NextPlrLevel(int pnum) drawhpflag = true; } - if (plr[pnum]._pClass == PC_WARRIOR) + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) mana = 64; - else if (plr[pnum]._pClass == PC_BARBARIAN) + else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) mana = 0; else mana = 128; @@ -1035,17 +1035,17 @@ void InitPlayer(int pnum, bool FirstTime) plr[pnum]._pvid = AddVision(plr[pnum]._px, plr[pnum]._py, plr[pnum]._pLightRad, pnum == myplr); } - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_REPAIR); - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_DISARM); - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_RECHARGE); - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_SEARCH); - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_IDENTIFY); - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { plr[pnum]._pAblSpells = GetSpellBitmask(SPL_BLODBOIL); } @@ -1597,22 +1597,22 @@ void StartPlrHit(int pnum, int dam, bool forcehit) return; } - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { PlaySfxLoc(PS_WARR69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { PlaySfxLoc(PS_ROGUE69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { PlaySfxLoc(PS_MAGE69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { PlaySfxLoc(PS_MONK69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { PlaySfxLoc(PS_ROGUE69, plr[pnum]._px, plr[pnum]._py); - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { PlaySfxLoc(PS_WARR69, plr[pnum]._px, plr[pnum]._py); } drawhpflag = true; - if (plr[pnum]._pClass == PC_BARBARIAN) { + if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { if (dam >> 6 < plr[pnum]._pLevel + plr[pnum]._pLevel / 4 && !forcehit) { return; } @@ -1715,17 +1715,17 @@ StartPlayerKill(int pnum, int earflag) app_fatal("StartPlayerKill: illegal player %d", pnum); } - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { PlaySfxLoc(PS_DEAD, p->_px, p->_py); // BUGFIX: should use `PS_WARR71` like other classes - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { PlaySfxLoc(PS_ROGUE71, p->_px, p->_py); - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[pnum]._pClass == plr_class::PC_SORCERER) { PlaySfxLoc(PS_MAGE71, p->_px, p->_py); - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { PlaySfxLoc(PS_MONK71, p->_px, p->_py); - } else if (plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_BARD) { PlaySfxLoc(PS_ROGUE71, p->_px, p->_py); - } else if (plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { PlaySfxLoc(PS_WARR71, p->_px, p->_py); } @@ -1775,13 +1775,13 @@ StartPlayerKill(int pnum, int earflag) if (earflag != 0) { SetPlrHandItem(&ear, IDI_EAR); sprintf(ear._iName, "Ear of %s", plr[pnum]._pName); - if (plr[pnum]._pClass == PC_SORCERER) { + if (plr[pnum]._pClass == plr_class::PC_SORCERER) { ear._iCurs = ICURS_EAR_SORCERER; - } else if (plr[pnum]._pClass == PC_WARRIOR) { + } else if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { ear._iCurs = ICURS_EAR_WARRIOR; - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE) { ear._iCurs = ICURS_EAR_ROGUE; - } else if (plr[pnum]._pClass == PC_MONK || plr[pnum]._pClass == PC_BARD || plr[pnum]._pClass == PC_BARBARIAN) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK || plr[pnum]._pClass == plr_class::PC_BARD || plr[pnum]._pClass == plr_class::PC_BARBARIAN) { ear._iCurs = ICURS_EAR_ROGUE; } @@ -2155,7 +2155,7 @@ bool PM_DoWalk(int pnum, int variant) //Acquire length of walk animation length (this is 8 for every class, so the AnimLenFromClass array is redundant right now) int anim_len = 8; if (currlevel != 0) { - anim_len = AnimLenFromClass[plr[pnum]._pClass]; + anim_len = AnimLenFromClass[static_cast(plr[pnum]._pClass)]; } //Check if we reached new tile @@ -2359,7 +2359,7 @@ bool PlrHitMonst(int pnum, int m) else tmac -= tmac >> 2; - if (plr[pnum]._pClass == PC_BARBARIAN) { + if (plr[pnum]._pClass == plr_class::PC_BARBARIAN) { tmac -= monster[m].mArmorClass / 8; } @@ -2370,7 +2370,7 @@ bool PlrHitMonst(int pnum, int m) } hper += (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - tmac; - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { hper += 20; } hper += plr[pnum]._pIBonusToHit; @@ -2400,7 +2400,7 @@ bool PlrHitMonst(int pnum, int m) dam += plr[pnum]._pIBonusDamMod; int dam2 = dam << 6; dam += plr[pnum]._pDamageMod; - if (plr[pnum]._pClass == PC_WARRIOR || plr[pnum]._pClass == PC_BARBARIAN) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR || plr[pnum]._pClass == plr_class::PC_BARBARIAN) { ddp = plr[pnum]._pLevel; if (random_(6, 100) < ddp) { dam <<= 1; @@ -2579,7 +2579,7 @@ bool PlrHitPlr(int pnum, char p) hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (plr[p]._pIBonusAC + plr[p]._pIAC + plr[p]._pDexterity / 5); - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR) { hper += 20; } hper += plr[pnum]._pIBonusToHit; @@ -2615,7 +2615,7 @@ bool PlrHitPlr(int pnum, char p) dam += (dam * plr[pnum]._pIBonusDam) / 100; dam += plr[pnum]._pIBonusDamMod + plr[pnum]._pDamageMod; - if (plr[pnum]._pClass == PC_WARRIOR || plr[pnum]._pClass == PC_BARBARIAN) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR || plr[pnum]._pClass == plr_class::PC_BARBARIAN) { lvl = plr[pnum]._pLevel; if (random_(6, 100) < lvl) { dam <<= 1; @@ -2733,11 +2733,11 @@ bool PM_DoAttack(int pnum) } else if (dObject[dx][dy] > 0) { didhit = PlrHitObj(pnum, dx, dy); } - if ((plr[pnum]._pClass == PC_MONK + if ((plr[pnum]._pClass == plr_class::PC_MONK && (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_STAFF || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_STAFF)) - || (plr[pnum]._pClass == PC_BARD + || (plr[pnum]._pClass == plr_class::PC_BARD && plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SWORD && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SWORD) - || (plr[pnum]._pClass == PC_BARBARIAN + || (plr[pnum]._pClass == plr_class::PC_BARBARIAN && (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_AXE || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_AXE || (((plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_MACE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) || (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_MACE && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iLoc == ILOC_TWOHAND) @@ -3121,9 +3121,9 @@ void CheckNewPath(int pnum) } if (currlevel != 0) { - xvel3 = PWVel[plr[pnum]._pClass][0]; - xvel = PWVel[plr[pnum]._pClass][1]; - yvel = PWVel[plr[pnum]._pClass][2]; + xvel3 = PWVel[static_cast(plr[pnum]._pClass)][0]; + xvel = PWVel[static_cast(plr[pnum]._pClass)][1]; + yvel = PWVel[static_cast(plr[pnum]._pClass)][2]; } else { xvel3 = 2048; xvel = 1024; @@ -3740,34 +3740,34 @@ void CheckPlrSpell() spell_id rspell = plr[myplr]._pRSpell; if (rspell == SPL_INVALID) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { PlaySFX(PS_WARR34); - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { PlaySFX(PS_ROGUE34); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { PlaySFX(PS_MAGE34); - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { PlaySFX(PS_MONK34); - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { PlaySFX(PS_ROGUE34); - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { PlaySFX(PS_WARR34); } return; } if (leveltype == DTYPE_TOWN && !spelldata[rspell].sTownSpell) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { PlaySFX(PS_WARR27); - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { PlaySFX(PS_ROGUE27); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { PlaySFX(PS_MAGE27); - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { PlaySFX(PS_MONK27); - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { PlaySFX(PS_ROGUE27); - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { PlaySFX(PS_WARR27); } return; @@ -3827,17 +3827,17 @@ void CheckPlrSpell() } if (plr[myplr]._pRSplType == RSPLTYPE_SPELL) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { PlaySFX(PS_WARR35); - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { PlaySFX(PS_ROGUE35); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { PlaySFX(PS_MAGE35); - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { PlaySFX(PS_MONK35); - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { PlaySFX(PS_ROGUE35); - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { PlaySFX(PS_WARR35); } } @@ -4014,7 +4014,7 @@ void ModifyPlrStr(int p, int l) plr[p]._pStrength += l; plr[p]._pBaseStr += l; - if (plr[p]._pClass == PC_ROGUE) { + if (plr[p]._pClass == plr_class::PC_ROGUE) { plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 200; } else { plr[p]._pDamageMod = plr[p]._pLevel * plr[p]._pStrength / 100; @@ -4042,9 +4042,9 @@ void ModifyPlrMag(int p, int l) plr[p]._pBaseMag += l; int ms = l << 6; - if (plr[p]._pClass == PC_SORCERER) { + if (plr[p]._pClass == plr_class::PC_SORCERER) { ms <<= 1; - } else if (plr[p]._pClass == PC_BARD) { + } else if (plr[p]._pClass == plr_class::PC_BARD) { ms += ms >> 1; } @@ -4077,7 +4077,7 @@ void ModifyPlrDex(int p, int l) plr[p]._pBaseDex += l; CalcPlrInv(p, true); - if (plr[p]._pClass == PC_ROGUE) { + if (plr[p]._pClass == plr_class::PC_ROGUE) { plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pDexterity + plr[p]._pStrength) / 200; } @@ -4101,9 +4101,9 @@ void ModifyPlrVit(int p, int l) plr[p]._pBaseVit += l; int ms = l << 6; - if (plr[p]._pClass == PC_WARRIOR) { + if (plr[p]._pClass == plr_class::PC_WARRIOR) { ms <<= 1; - } else if (plr[p]._pClass == PC_BARBARIAN) { + } else if (plr[p]._pClass == plr_class::PC_BARBARIAN) { ms <<= 1; } @@ -4144,7 +4144,7 @@ void SetPlrStr(int p, int v) plr[p]._pBaseStr = v; CalcPlrInv(p, true); - if (plr[p]._pClass == PC_ROGUE) { + if (plr[p]._pClass == plr_class::PC_ROGUE) { dm = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 200; } else { dm = plr[p]._pLevel * plr[p]._pStrength / 100; @@ -4164,9 +4164,9 @@ void SetPlrMag(int p, int v) plr[p]._pBaseMag = v; m = v << 6; - if (plr[p]._pClass == PC_SORCERER) { + if (plr[p]._pClass == plr_class::PC_SORCERER) { m <<= 1; - } else if (plr[p]._pClass == PC_BARD) { + } else if (plr[p]._pClass == plr_class::PC_BARD) { m += m >> 1; } @@ -4186,7 +4186,7 @@ void SetPlrDex(int p, int v) plr[p]._pBaseDex = v; CalcPlrInv(p, true); - if (plr[p]._pClass == PC_ROGUE) { + if (plr[p]._pClass == plr_class::PC_ROGUE) { dm = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 200; } else { dm = plr[p]._pStrength * plr[p]._pLevel / 100; @@ -4206,9 +4206,9 @@ void SetPlrVit(int p, int v) plr[p]._pBaseVit = v; hp = v << 6; - if (plr[p]._pClass == PC_WARRIOR) { + if (plr[p]._pClass == plr_class::PC_WARRIOR) { hp <<= 1; - } else if (plr[p]._pClass == PC_BARBARIAN) { + } else if (plr[p]._pClass == plr_class::PC_BARBARIAN) { hp <<= 1; } @@ -4245,71 +4245,71 @@ void PlayDungMsgs() if (currlevel == 1 && !plr[myplr]._pLvlVisited[1] && !gbIsMultiplayer && !(plr[myplr].pDungMsgs & DMSG_CATHEDRAL)) { sfxdelay = 40; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR97; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE97; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE97; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK97; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE97; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR97; } plr[myplr].pDungMsgs = plr[myplr].pDungMsgs | DMSG_CATHEDRAL; } else if (currlevel == 5 && !plr[myplr]._pLvlVisited[5] && !gbIsMultiplayer && !(plr[myplr].pDungMsgs & DMSG_CATACOMBS)) { sfxdelay = 40; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR96B; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE96; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE96; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK96; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE96; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR96B; } plr[myplr].pDungMsgs |= DMSG_CATACOMBS; } else if (currlevel == 9 && !plr[myplr]._pLvlVisited[9] && !gbIsMultiplayer && !(plr[myplr].pDungMsgs & DMSG_CAVES)) { sfxdelay = 40; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR98; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE98; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE98; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK98; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE98; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR98; } plr[myplr].pDungMsgs |= DMSG_CAVES; } else if (currlevel == 13 && !plr[myplr]._pLvlVisited[13] && !gbIsMultiplayer && !(plr[myplr].pDungMsgs & DMSG_HELL)) { sfxdelay = 40; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR99; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE99; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE99; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK99; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE99; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR99; } plr[myplr].pDungMsgs |= DMSG_HELL; } else if (currlevel == 16 && !plr[myplr]._pLvlVisited[15] && !gbIsMultiplayer && !(plr[myplr].pDungMsgs & DMSG_DIABLO)) { // BUGFIX: _pLvlVisited should check 16 or this message will never play sfxdelay = 40; - if (plr[myplr]._pClass == PC_WARRIOR || plr[myplr]._pClass == PC_ROGUE || plr[myplr]._pClass == PC_SORCERER || plr[myplr]._pClass == PC_MONK || plr[myplr]._pClass == PC_BARD || plr[myplr]._pClass == PC_BARBARIAN) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR || plr[myplr]._pClass == plr_class::PC_ROGUE || plr[myplr]._pClass == plr_class::PC_SORCERER || plr[myplr]._pClass == plr_class::PC_MONK || plr[myplr]._pClass == plr_class::PC_BARD || plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_DIABLVLINT; } plr[myplr].pDungMsgs |= DMSG_DIABLO; @@ -4326,17 +4326,17 @@ void PlayDungMsgs() plr[myplr].pDungMsgs2 |= 4; } else if (currlevel == 21 && !plr[myplr]._pLvlVisited[21] && !gbIsMultiplayer && !(plr[myplr].pDungMsgs & 32)) { sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR92; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE92; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE92; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK92; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE92; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR92; } plr[myplr].pDungMsgs |= 32; diff --git a/Source/player.h b/Source/player.h index f1bc96fda..9711d1626 100644 --- a/Source/player.h +++ b/Source/player.h @@ -29,7 +29,7 @@ enum { // clang-format on }; -enum plr_class : uint8_t { +enum class plr_class : uint8_t { PC_WARRIOR, PC_ROGUE, PC_SORCERER, @@ -323,7 +323,7 @@ struct PlayerStruct { extern int myplr; extern PlayerStruct plr[MAX_PLRS]; extern bool deathflag; -extern int ToBlkTbl[NUM_CLASSES]; +extern int ToBlkTbl[static_cast(plr_class::NUM_CLASSES)]; void LoadPlrGFX(int pnum, player_graphic gfxflag); void InitPlayerGFX(int pnum); @@ -386,10 +386,10 @@ extern int plrxoff[9]; extern int plryoff[9]; extern int plrxoff2[9]; extern int plryoff2[9]; -extern int StrengthTbl[NUM_CLASSES]; -extern int MagicTbl[NUM_CLASSES]; -extern int DexterityTbl[NUM_CLASSES]; -extern int VitalityTbl[NUM_CLASSES]; +extern int StrengthTbl[static_cast(plr_class::NUM_CLASSES)]; +extern int MagicTbl[static_cast(plr_class::NUM_CLASSES)]; +extern int DexterityTbl[static_cast(plr_class::NUM_CLASSES)]; +extern int VitalityTbl[static_cast(plr_class::NUM_CLASSES)]; extern int ExpLvlsTbl[MAXCHARLEVEL]; } diff --git a/Source/quests.cpp b/Source/quests.cpp index 73a6a7f6f..e2975c06d 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -307,17 +307,17 @@ void CheckQuestKill(int m, bool sendmsg) if (monster[m].MType->mtype == MT_SKING) { quests[Q_SKELKING]._qactive = QUEST_DONE; sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR82; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE82; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE82; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK82; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE82; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR82; } if (sendmsg) @@ -326,17 +326,17 @@ void CheckQuestKill(int m, bool sendmsg) } else if (monster[m].MType->mtype == MT_CLEAVER) { quests[Q_BUTCHER]._qactive = QUEST_DONE; sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR80; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE80; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE80; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK80; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE80; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR80; } if (sendmsg) @@ -344,33 +344,33 @@ void CheckQuestKill(int m, bool sendmsg) } else if (monster[m]._uniqtype - 1 == UMT_GARBUD) { //"Gharbad the Weak" quests[Q_GARBUD]._qactive = QUEST_DONE; sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR61; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE61; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE61; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK61; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE61; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR61; } } else if (monster[m]._uniqtype - 1 == UMT_ZHAR) { //"Zhar the Mad" quests[Q_ZHAR]._qactive = QUEST_DONE; sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR62; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE62; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE62; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK62; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE62; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR62; } } else if (monster[m]._uniqtype - 1 == UMT_LAZURUS && gbIsMultiplayer) { //"Arch-Bishop Lazarus" @@ -389,17 +389,17 @@ void CheckQuestKill(int m, bool sendmsg) } } } - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR83; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE83; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE83; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK83; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE83; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR83; } if (sendmsg) { @@ -414,33 +414,33 @@ void CheckQuestKill(int m, bool sendmsg) quests[Q_BETRAYER]._qvar2 = 4; quests[Q_DIABLO]._qactive = QUEST_ACTIVE; AddMissile(35, 32, 35, 32, 0, MIS_RPORTAL, TARGET_MONSTERS, myplr, 0, 0); - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR83; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE83; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE83; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK83; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE83; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR83; } } else if (monster[m]._uniqtype - 1 == UMT_WARLORD) { //"Warlord of Blood" quests[Q_WARLORD]._qactive = QUEST_DONE; sfxdelay = 30; - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { sfxdnum = PS_WARR94; - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { sfxdnum = PS_ROGUE94; - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { sfxdnum = PS_MAGE94; - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { sfxdnum = PS_MONK94; - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { sfxdnum = PS_ROGUE94; - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { sfxdnum = PS_WARR94; } } diff --git a/Source/spells.cpp b/Source/spells.cpp index 1b3bcc8a2..a1165f3cc 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -43,9 +43,9 @@ int GetManaAmount(int id, spell_id sn) ma = 0; ma <<= 6; - if (plr[id]._pClass == PC_SORCERER) { + if (plr[id]._pClass == plr_class::PC_SORCERER) { ma >>= 1; - } else if (plr[id]._pClass == PC_ROGUE || plr[id]._pClass == PC_MONK || plr[id]._pClass == PC_BARD) { + } else if (plr[id]._pClass == plr_class::PC_ROGUE || plr[id]._pClass == plr_class::PC_MONK || plr[id]._pClass == plr_class::PC_BARD) { ma -= ma >> 2; } @@ -319,11 +319,11 @@ void DoHealOther(int pnum, int rid) hp += (random_(57, 6) + 1) << 6; } - if (plr[pnum]._pClass == PC_WARRIOR || plr[pnum]._pClass == PC_BARBARIAN) { + if (plr[pnum]._pClass == plr_class::PC_WARRIOR || plr[pnum]._pClass == plr_class::PC_BARBARIAN) { hp <<= 1; - } else if (plr[pnum]._pClass == PC_ROGUE || plr[pnum]._pClass == PC_BARD) { + } else if (plr[pnum]._pClass == plr_class::PC_ROGUE || plr[pnum]._pClass == plr_class::PC_BARD) { hp += hp >> 1; - } else if (plr[pnum]._pClass == PC_MONK) { + } else if (plr[pnum]._pClass == plr_class::PC_MONK) { hp *= 3; } diff --git a/Source/towners.cpp b/Source/towners.cpp index 8134d2a16..8592b4898 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -21,7 +21,7 @@ TownerStruct towner[NUM_TOWNERS]; * ref: enum _sfx_id * ref: enum plr_class */ -const _sfx_id snSFX[3][NUM_CLASSES] = { +const _sfx_id snSFX[3][static_cast(plr_class::NUM_CLASSES)] = { { PS_WARR52, PS_ROGUE52, PS_MAGE52, PS_MONK52, PS_ROGUE52, PS_WARR52 }, // BUGFIX: add warrior sounds for barbarian instead of 0 - walk sound (fixed) { PS_WARR49, PS_ROGUE49, PS_MAGE49, PS_MONK49, PS_ROGUE49, PS_WARR49 }, { PS_WARR50, PS_ROGUE50, PS_MAGE50, PS_MONK50, PS_ROGUE50, PS_WARR50 }, @@ -154,7 +154,7 @@ void CowSFX(int pnum) if (sgdwCowClicks >= 8) { PlaySfxLoc(TSFX_COW1, plr[pnum]._px, plr[pnum]._py + 5); sgdwCowClicks = 4; - CowPlaying = snSFX[sgnCowMsg][plr[pnum]._pClass]; /* snSFX is local */ + CowPlaying = snSFX[sgnCowMsg][static_cast(plr[pnum]._pClass)]; /* snSFX is local */ sgnCowMsg++; if (sgnCowMsg >= 3) sgnCowMsg = 0; @@ -818,17 +818,17 @@ void TalkToTowner(int p, int t) towner[t]._tbtcnt = true; towner[t]._tTalkingToPlayer = p; quests[Q_BUTCHER]._qvar1 = 1; - if (plr[p]._pClass == PC_WARRIOR && !effect_is_playing(PS_WARR8)) { + if (plr[p]._pClass == plr_class::PC_WARRIOR && !effect_is_playing(PS_WARR8)) { PlaySFX(PS_WARR8); - } else if (plr[p]._pClass == PC_ROGUE && !effect_is_playing(PS_ROGUE8)) { + } else if (plr[p]._pClass == plr_class::PC_ROGUE && !effect_is_playing(PS_ROGUE8)) { PlaySFX(PS_ROGUE8); - } else if (plr[p]._pClass == PC_SORCERER && !effect_is_playing(PS_MAGE8)) { + } else if (plr[p]._pClass == plr_class::PC_SORCERER && !effect_is_playing(PS_MAGE8)) { PlaySFX(PS_MAGE8); - } else if (plr[p]._pClass == PC_MONK && !effect_is_playing(PS_MONK8)) { + } else if (plr[p]._pClass == plr_class::PC_MONK && !effect_is_playing(PS_MONK8)) { PlaySFX(PS_MONK8); - } else if (plr[p]._pClass == PC_BARD && !effect_is_playing(PS_ROGUE8)) { + } else if (plr[p]._pClass == plr_class::PC_BARD && !effect_is_playing(PS_ROGUE8)) { PlaySFX(PS_ROGUE8); - } else if (plr[p]._pClass == PC_BARBARIAN && !effect_is_playing(PS_WARR8)) { + } else if (plr[p]._pClass == plr_class::PC_BARBARIAN && !effect_is_playing(PS_WARR8)) { PlaySFX(PS_WARR8); } towner[t]._tMsgSaid = true; diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 9c52be1a6..27c8d80a5 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -888,17 +888,17 @@ void CheckTriggers() } if (abort) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { PlaySFX(PS_WARR43); - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { PlaySFX(PS_ROGUE43); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { PlaySFX(PS_MAGE43); - } else if (plr[myplr]._pClass == PC_MONK) { + } else if (plr[myplr]._pClass == plr_class::PC_MONK) { PlaySFX(PS_MONK43); - } else if (plr[myplr]._pClass == PC_BARD) { + } else if (plr[myplr]._pClass == plr_class::PC_BARD) { PlaySFX(PS_ROGUE43); - } else if (plr[myplr]._pClass == PC_BARBARIAN) { + } else if (plr[myplr]._pClass == plr_class::PC_BARBARIAN) { PlaySFX(PS_WARR43); } diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index 053d494a8..235292523 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -454,19 +454,19 @@ void LoadHeros() LoadArt("ui_art\\heros.pcx", &ArtHero); const int portraitHeight = 76; - int portraitOrder[NUM_CLASSES + 1] = { 0, 1, 2, 2, 1, 0, 3 }; + int portraitOrder[static_cast(plr_class::NUM_CLASSES) + 1] = { 0, 1, 2, 2, 1, 0, 3 }; if (ArtHero.h() >= portraitHeight * 6) { - portraitOrder[PC_MONK] = 3; - portraitOrder[PC_BARD] = 4; - portraitOrder[NUM_CLASSES] = 5; + portraitOrder[static_cast(plr_class::PC_MONK)] = 3; + portraitOrder[static_cast(plr_class::PC_BARD)] = 4; + portraitOrder[static_cast(plr_class::NUM_CLASSES)] = 5; } if (ArtHero.h() >= portraitHeight * 7) { - portraitOrder[PC_BARBARIAN] = 6; + portraitOrder[static_cast(plr_class::PC_BARBARIAN)] = 6; } - SDL_Surface *heros = SDL_CreateRGBSurfaceWithFormat(0, ArtHero.w(), portraitHeight * (NUM_CLASSES + 1), 8, SDL_PIXELFORMAT_INDEX8); + SDL_Surface *heros = SDL_CreateRGBSurfaceWithFormat(0, ArtHero.w(), portraitHeight * (static_cast(plr_class::NUM_CLASSES) + 1), 8, SDL_PIXELFORMAT_INDEX8); - for (int i = 0; i <= NUM_CLASSES; i++) { + for (int i = 0; i <= static_cast(plr_class::NUM_CLASSES); i++) { int offset = portraitOrder[i] * portraitHeight; if (offset + portraitHeight > ArtHero.h()) { offset = 0; @@ -476,7 +476,7 @@ void LoadHeros() SDL_BlitSurface(ArtHero.surface.get(), &src_rect, heros, &dst_rect); } - for (int i = 0; i <= NUM_CLASSES; i++) { + for (int i = 0; i <= static_cast(plr_class::NUM_CLASSES); i++) { Art portrait; char portraitPath[18]; sprintf(portraitPath, "ui_art\\hero%i.pcx", i); @@ -490,7 +490,7 @@ void LoadHeros() ArtHero.surface = SDLSurfaceUniquePtr { heros }; ArtHero.frame_height = portraitHeight; - ArtHero.frames = NUM_CLASSES; + ArtHero.frames = static_cast(plr_class::NUM_CLASSES); } void LoadUiGFX() diff --git a/SourceX/DiabloUI/selhero.cpp b/SourceX/DiabloUI/selhero.cpp index 1c0ab7328..fe99e4333 100644 --- a/SourceX/DiabloUI/selhero.cpp +++ b/SourceX/DiabloUI/selhero.cpp @@ -96,7 +96,7 @@ void selhero_Free() void selhero_SetStats() { - SELHERO_DIALOG_HERO_IMG->m_frame = selhero_heroInfo.heroclass; + SELHERO_DIALOG_HERO_IMG->m_frame = static_cast(selhero_heroInfo.heroclass); snprintf(textStats[0], sizeof(textStats[0]), "%d", selhero_heroInfo.level); snprintf(textStats[1], sizeof(textStats[1]), "%d", selhero_heroInfo.strength); snprintf(textStats[2], sizeof(textStats[2]), "%d", selhero_heroInfo.magic); @@ -162,7 +162,7 @@ void selhero_Init() vecSelHeroDialog.push_back(new UiArtText(title, rect1, UIS_CENTER | UIS_BIG)); SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 30), (Sint16)(UI_OFFSET_Y + 211), 180, 76 }; - SELHERO_DIALOG_HERO_IMG = new UiImage(&ArtHero, NUM_CLASSES, rect2); + SELHERO_DIALOG_HERO_IMG = new UiImage(&ArtHero, static_cast(plr_class::NUM_CLASSES), rect2); vecSelHeroDialog.push_back(SELHERO_DIALOG_HERO_IMG); SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 39), (Sint16)(UI_OFFSET_Y + 323), 110, 21 }; @@ -247,7 +247,7 @@ void selhero_List_Focus(int value) return; } - SELHERO_DIALOG_HERO_IMG->m_frame = NUM_CLASSES; + SELHERO_DIALOG_HERO_IMG->m_frame = static_cast(plr_class::NUM_CLASSES); strncpy(textStats[0], "--", sizeof(textStats[0]) - 1); strncpy(textStats[1], "--", sizeof(textStats[1]) - 1); strncpy(textStats[2], "--", sizeof(textStats[2]) - 1); @@ -274,17 +274,17 @@ void selhero_List_Select(int value) selhero_FreeListItems(); int itemH = 33; - vecSelHeroDlgItems.push_back(new UiListItem("Warrior", PC_WARRIOR)); - vecSelHeroDlgItems.push_back(new UiListItem("Rogue", PC_ROGUE)); - vecSelHeroDlgItems.push_back(new UiListItem("Sorcerer", PC_SORCERER)); + vecSelHeroDlgItems.push_back(new UiListItem("Warrior", static_cast(plr_class::PC_WARRIOR))); + vecSelHeroDlgItems.push_back(new UiListItem("Rogue", static_cast(plr_class::PC_ROGUE))); + vecSelHeroDlgItems.push_back(new UiListItem("Sorcerer", static_cast(plr_class::PC_SORCERER))); if (gbIsHellfire) { - vecSelHeroDlgItems.push_back(new UiListItem("Monk", PC_MONK)); + vecSelHeroDlgItems.push_back(new UiListItem("Monk", static_cast(plr_class::PC_MONK))); } if (gbBard || sgOptions.Gameplay.bTestBard) { - vecSelHeroDlgItems.push_back(new UiListItem("Bard", PC_BARD)); + vecSelHeroDlgItems.push_back(new UiListItem("Bard", static_cast(plr_class::PC_BARD))); } if (gbBarbarian || sgOptions.Gameplay.bTestBarbarian) { - vecSelHeroDlgItems.push_back(new UiListItem("Barbarian", PC_BARBARIAN)); + vecSelHeroDlgItems.push_back(new UiListItem("Barbarian", static_cast(plr_class::PC_BARBARIAN))); } if (vecSelHeroDlgItems.size() > 4) itemH = 26; @@ -344,7 +344,7 @@ void selhero_ClassSelector_Focus(int value) const auto hero_class = static_cast(vecSelHeroDlgItems[value]->m_value); _uidefaultstats defaults; - gfnHeroStats(hero_class, &defaults); + gfnHeroStats(static_cast(hero_class), &defaults); selhero_heroInfo.level = 1; selhero_heroInfo.heroclass = hero_class; @@ -369,8 +369,8 @@ static bool shouldPrefillHeroName() void selhero_ClassSelector_Select(int value) { - int hClass = vecSelHeroDlgItems[value]->m_value; - if (gbSpawned && (hClass == PC_ROGUE || hClass == PC_SORCERER || (hClass == PC_BARD && !hfbard_mpq))) { + auto hClass = static_cast(vecSelHeroDlgItems[value]->m_value); + if (gbSpawned && (hClass == plr_class::PC_ROGUE || hClass == plr_class::PC_SORCERER || (hClass == plr_class::PC_BARD && !hfbard_mpq))) { ArtBackground.Unload(); UiSelOkDialog(NULL, "The Rogue and Sorcerer are only available in the full retail version of Diablo. Visit https://www.gog.com/game/diablo to purchase.", false); LoadBackgroundArt("ui_art\\selhero.pcx"); @@ -651,7 +651,7 @@ static const char *selhero_GenerateName(plr_class hero_class) int iRand = rand() % 10; - return kNames[hero_class % 6][iRand]; + return kNames[static_cast(hero_class) % 6][iRand]; } } // namespace devilution diff --git a/SourceX/controls/plrctrls.cpp b/SourceX/controls/plrctrls.cpp index 946ab7a61..83d9b08a5 100644 --- a/SourceX/controls/plrctrls.cpp +++ b/SourceX/controls/plrctrls.cpp @@ -1187,11 +1187,11 @@ void PerformSpellAction() int spl = plr[myplr]._pRSpell; if ((pcursplr == -1 && (spl == SPL_RESURRECT || spl == SPL_HEALOTHER)) || (pcursobj == -1 && spl == SPL_DISARM)) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { PlaySFX(PS_WARR27); - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { PlaySFX(PS_ROGUE27); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { PlaySFX(PS_MAGE27); } return; diff --git a/SourceX/miniwin/misc_msg.cpp b/SourceX/miniwin/misc_msg.cpp index b65f83d40..419ca8fe4 100644 --- a/SourceX/miniwin/misc_msg.cpp +++ b/SourceX/miniwin/misc_msg.cpp @@ -279,11 +279,11 @@ bool BlurInventory() { if (pcurs >= CURSOR_FIRSTITEM) { if (!TryDropItem()) { - if (plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == plr_class::PC_WARRIOR) { PlaySFX(PS_WARR16); // "Where would I put this?" - } else if (plr[myplr]._pClass == PC_ROGUE) { + } else if (plr[myplr]._pClass == plr_class::PC_ROGUE) { PlaySFX(PS_ROGUE16); - } else if (plr[myplr]._pClass == PC_SORCERER) { + } else if (plr[myplr]._pClass == plr_class::PC_SORCERER) { PlaySFX(PS_MAGE16); } return false; diff --git a/test/writehero_test.cpp b/test/writehero_test.cpp index ecf444c53..8c3cca6e7 100644 --- a/test/writehero_test.cpp +++ b/test/writehero_test.cpp @@ -184,7 +184,7 @@ static void PackPlayerTest(PkPlayerStruct *pPack) for (auto i = 0; i < 7; i++) pPack->InvBody[i].idx = -1; strcpy(pPack->pName, "TestPlayer"); - pPack->pClass = PC_ROGUE; + pPack->pClass = plr_class::PC_ROGUE; pPack->pBaseStr = 20 + 35; pPack->pBaseMag = 15 + 55; pPack->pBaseDex = 30 + 220; @@ -371,7 +371,7 @@ TEST(Writehero, pfile_write_hero) myplr = 0; _uiheroinfo info {}; strcpy(info.name, "TestPlayer"); - info.heroclass = PC_ROGUE; + info.heroclass = plr_class::PC_ROGUE; pfile_ui_save_create(&info); PkPlayerStruct pks; PackPlayerTest(&pks);