mirror of
https://github.com/libretro/devilutionX.git
synced 2026-11-09 02:49:43 -10:00
enum spell_type -> enum class SpellType (#5674)
This commit is contained in:
1 parent
30c1991039
commit
ef3a57b7d9
18 files changed
+155
-153
No files matched your search
+6
-6
@@ -773,7 +773,7 @@ void DoPanBtn()
|
||||
if ((SDL_GetModState() & KMOD_SHIFT) != 0) {
|
||||
Player &myPlayer = *MyPlayer;
|
||||
myPlayer._pRSpell = SPL_INVALID;
|
||||
myPlayer._pRSplType = RSPLTYPE_INVALID;
|
||||
myPlayer._pRSplType = SpellType::Invalid;
|
||||
RedrawEverything();
|
||||
return;
|
||||
}
|
||||
@@ -843,15 +843,15 @@ void CheckPanelInfo()
|
||||
const spell_id spellId = myPlayer._pRSpell;
|
||||
if (IsValidSpell(spellId)) {
|
||||
switch (myPlayer._pRSplType) {
|
||||
case RSPLTYPE_SKILL:
|
||||
case SpellType::Skill:
|
||||
AddPanelString(fmt::format(fmt::runtime(_("{:s} Skill")), pgettext("spell", spelldata[spellId].sNameText)));
|
||||
break;
|
||||
case RSPLTYPE_SPELL: {
|
||||
case SpellType::Spell: {
|
||||
AddPanelString(fmt::format(fmt::runtime(_("{:s} Spell")), pgettext("spell", spelldata[spellId].sNameText)));
|
||||
const int spellLevel = myPlayer.GetSpellLevel(spellId);
|
||||
AddPanelString(spellLevel == 0 ? _("Spell Level 0 - Unusable") : fmt::format(fmt::runtime(_("Spell Level {:d}")), spellLevel));
|
||||
} break;
|
||||
case RSPLTYPE_SCROLL: {
|
||||
case SpellType::Scroll: {
|
||||
AddPanelString(fmt::format(fmt::runtime(_("Scroll of {:s}")), pgettext("spell", spelldata[spellId].sNameText)));
|
||||
const InventoryAndBeltPlayerItemsRange items { myPlayer };
|
||||
const int scrollCount = std::count_if(items.begin(), items.end(), [spellId](const Item &item) {
|
||||
@@ -859,11 +859,11 @@ void CheckPanelInfo()
|
||||
});
|
||||
AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Scroll", "{:d} Scrolls", scrollCount)), scrollCount));
|
||||
} break;
|
||||
case RSPLTYPE_CHARGES:
|
||||
case SpellType::Charges:
|
||||
AddPanelString(fmt::format(fmt::runtime(_("Staff of {:s}")), pgettext("spell", spelldata[spellId].sNameText)));
|
||||
AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Charge", "{:d} Charges", myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges)), myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges));
|
||||
break;
|
||||
case RSPLTYPE_INVALID:
|
||||
case SpellType::Invalid:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,15 +126,15 @@ void DrawSpellsCircleMenuHint(const Surface &out, const Point &origin)
|
||||
};
|
||||
uint64_t spells = myPlayer._pAblSpells | myPlayer._pMemSpells | myPlayer._pScrlSpells | myPlayer._pISpells;
|
||||
spell_id splId;
|
||||
spell_type splType;
|
||||
SpellType splType;
|
||||
|
||||
for (int slot = 0; slot < 4; ++slot) {
|
||||
splId = myPlayer._pSplHotKey[slot];
|
||||
|
||||
if (IsValidSpell(splId) && (spells & GetSpellBitmask(splId)) != 0)
|
||||
splType = (leveltype == DTYPE_TOWN && !spelldata[splId].sTownSpell) ? RSPLTYPE_INVALID : myPlayer._pSplTHotKey[slot];
|
||||
splType = (leveltype == DTYPE_TOWN && !spelldata[splId].sTownSpell) ? SpellType::Invalid : myPlayer._pSplTHotKey[slot];
|
||||
else {
|
||||
splType = RSPLTYPE_INVALID;
|
||||
splType = SpellType::Invalid;
|
||||
splId = SPL_NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -2138,7 +2138,7 @@ void QuickCast(size_t slot)
|
||||
MouseActionType prevMouseButtonAction = LastMouseButtonAction;
|
||||
Player &myPlayer = *MyPlayer;
|
||||
spell_id spell = myPlayer._pSplHotKey[slot];
|
||||
spell_type spellType = myPlayer._pSplTHotKey[slot];
|
||||
SpellType spellType = myPlayer._pSplTHotKey[slot];
|
||||
|
||||
if (ControlMode != ControlTypes::KeyboardAndMouse) {
|
||||
UpdateSpellTarget(spell);
|
||||
|
||||
+1
-1
@@ -3818,7 +3818,7 @@ void UseItem(size_t pnum, item_misc_id mid, spell_id spl)
|
||||
} else {
|
||||
ClrPlrPath(player);
|
||||
player.queuedSpell.spellId = spl;
|
||||
player.queuedSpell.spellType = RSPLTYPE_SCROLL;
|
||||
player.queuedSpell.spellType = SpellType::Scroll;
|
||||
player.queuedSpell.spellFrom = 0;
|
||||
player.destAction = ACTION_SPELL;
|
||||
player.destParam1 = cursPosition.x;
|
||||
|
||||
+11
-11
@@ -357,14 +357,14 @@ void LoadPlayer(LoadHelper &file, Player &player)
|
||||
player._pvid = file.NextLE<int32_t>();
|
||||
|
||||
player.queuedSpell.spellId = static_cast<spell_id>(file.NextLE<int32_t>());
|
||||
player.queuedSpell.spellType = static_cast<spell_type>(file.NextLE<int8_t>());
|
||||
player.queuedSpell.spellType = static_cast<SpellType>(file.NextLE<int8_t>());
|
||||
player.queuedSpell.spellFrom = file.NextLE<int8_t>();
|
||||
file.Skip(2); // Alignment
|
||||
player._pTSpell = static_cast<spell_id>(file.NextLE<int32_t>());
|
||||
file.Skip<int8_t>(); // Skip _pTSplType
|
||||
file.Skip(3); // Alignment
|
||||
player._pRSpell = static_cast<spell_id>(file.NextLE<int32_t>());
|
||||
player._pRSplType = static_cast<spell_type>(file.NextLE<int8_t>());
|
||||
player._pRSplType = static_cast<SpellType>(file.NextLE<int8_t>());
|
||||
file.Skip(3); // Alignment
|
||||
player._pSBkSpell = static_cast<spell_id>(file.NextLE<int32_t>());
|
||||
file.Skip<int8_t>(); // Skip _pSBkSplType
|
||||
@@ -382,7 +382,7 @@ void LoadPlayer(LoadHelper &file, Player &player)
|
||||
player._pSplHotKey[i] = static_cast<spell_id>(file.NextLE<int32_t>());
|
||||
}
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
player._pSplTHotKey[i] = static_cast<spell_type>(file.NextLE<uint8_t>());
|
||||
player._pSplTHotKey[i] = static_cast<SpellType>(file.NextLE<uint8_t>());
|
||||
}
|
||||
|
||||
file.Skip<int32_t>(); // Skip _pwtype
|
||||
@@ -1131,14 +1131,14 @@ void SavePlayer(SaveHelper &file, const Player &player)
|
||||
file.WriteLE<int32_t>(player._pvid);
|
||||
|
||||
file.WriteLE<int32_t>(player.queuedSpell.spellId);
|
||||
file.WriteLE<int8_t>(player.queuedSpell.spellType);
|
||||
file.WriteLE<int8_t>(static_cast<int8_t>(player.queuedSpell.spellType));
|
||||
file.WriteLE<int8_t>(player.queuedSpell.spellFrom);
|
||||
file.Skip(2); // Alignment
|
||||
file.WriteLE<int32_t>(player._pTSpell);
|
||||
file.Skip<int8_t>(); // Skip _pTSplType
|
||||
file.Skip(3); // Alignment
|
||||
file.WriteLE<int32_t>(player._pRSpell);
|
||||
file.WriteLE<int8_t>(player._pRSplType);
|
||||
file.WriteLE<int8_t>(static_cast<uint8_t>(player._pRSplType));
|
||||
file.Skip(3); // Alignment
|
||||
file.WriteLE<int32_t>(player._pSBkSpell);
|
||||
file.Skip<int8_t>(); // Skip _pSBkSplType
|
||||
@@ -1158,7 +1158,7 @@ void SavePlayer(SaveHelper &file, const Player &player)
|
||||
file.WriteLE<int32_t>(player._pSplHotKey[i]);
|
||||
}
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
file.WriteLE<uint8_t>(player._pSplTHotKey[i]);
|
||||
file.WriteLE<uint8_t>(static_cast<uint8_t>(player._pSplTHotKey[i]));
|
||||
}
|
||||
|
||||
file.WriteLE<int32_t>(player.UsesRangedWeapon() ? 1 : 0);
|
||||
@@ -1903,7 +1903,7 @@ void LoadHotkeys()
|
||||
|
||||
// Refill the spell arrays with no selection
|
||||
std::fill(myPlayer._pSplHotKey, myPlayer._pSplHotKey + NumHotkeys, SPL_INVALID);
|
||||
std::fill(myPlayer._pSplTHotKey, myPlayer._pSplTHotKey + NumHotkeys, RSPLTYPE_INVALID);
|
||||
std::fill(myPlayer._pSplTHotKey, myPlayer._pSplTHotKey + NumHotkeys, SpellType::Invalid);
|
||||
|
||||
// Checking if the save file has the old format with only 4 hotkeys and no header
|
||||
if (file.IsValid(HotkeysSize(nHotkeys))) {
|
||||
@@ -1923,7 +1923,7 @@ void LoadHotkeys()
|
||||
for (size_t i = 0; i < nHotkeys; i++) {
|
||||
// Do not load hotkeys past the size of the spells array, discard the rest
|
||||
if (i < NumHotkeys) {
|
||||
myPlayer._pSplTHotKey[i] = static_cast<spell_type>(file.NextLE<uint8_t>());
|
||||
myPlayer._pSplTHotKey[i] = static_cast<SpellType>(file.NextLE<uint8_t>());
|
||||
} else {
|
||||
file.Skip<uint8_t>();
|
||||
}
|
||||
@@ -1931,7 +1931,7 @@ void LoadHotkeys()
|
||||
|
||||
// Load the selected spell last
|
||||
myPlayer._pRSpell = static_cast<spell_id>(file.NextLE<int32_t>());
|
||||
myPlayer._pRSplType = static_cast<spell_type>(file.NextLE<uint8_t>());
|
||||
myPlayer._pRSplType = static_cast<SpellType>(file.NextLE<uint8_t>());
|
||||
}
|
||||
|
||||
void SaveHotkeys(SaveWriter &saveWriter, const Player &player)
|
||||
@@ -1946,12 +1946,12 @@ void SaveHotkeys(SaveWriter &saveWriter, const Player &player)
|
||||
file.WriteLE<int32_t>(spellId);
|
||||
}
|
||||
for (auto &spellType : player._pSplTHotKey) {
|
||||
file.WriteLE<uint8_t>(spellType);
|
||||
file.WriteLE<uint8_t>(static_cast<uint8_t>(spellType));
|
||||
}
|
||||
|
||||
// Write the selected spell last
|
||||
file.WriteLE<int32_t>(player._pRSpell);
|
||||
file.WriteLE<uint8_t>(player._pRSplType);
|
||||
file.WriteLE<uint8_t>(static_cast<uint8_t>(player._pRSplType));
|
||||
}
|
||||
|
||||
void LoadHeroItems(Player &player)
|
||||
|
||||
+12
-12
@@ -1462,7 +1462,7 @@ size_t OnSpellWall(const TCmd *pCmd, Player &player)
|
||||
if (wParam1 > SPL_LAST)
|
||||
return sizeof(message);
|
||||
const uint16_t wParam2 = SDL_SwapLE16(message.wParam2);
|
||||
if (wParam2 > RSPLTYPE_INVALID)
|
||||
if (wParam2 > static_cast<uint8_t>(SpellType::LAST))
|
||||
return sizeof(message);
|
||||
|
||||
auto spell = static_cast<spell_id>(wParam1);
|
||||
@@ -1482,7 +1482,7 @@ size_t OnSpellWall(const TCmd *pCmd, Player &player)
|
||||
player.destParam3 = SDL_SwapLE16(message.wParam3);
|
||||
player.destParam4 = SDL_SwapLE16(message.wParam4);
|
||||
player.queuedSpell.spellId = spell;
|
||||
player.queuedSpell.spellType = static_cast<spell_type>(wParam2);
|
||||
player.queuedSpell.spellType = static_cast<SpellType>(wParam2);
|
||||
player.queuedSpell.spellFrom = 0;
|
||||
|
||||
return sizeof(message);
|
||||
@@ -1503,7 +1503,7 @@ size_t OnSpellTile(const TCmd *pCmd, Player &player)
|
||||
if (wParam1 > SPL_LAST)
|
||||
return sizeof(message);
|
||||
const uint16_t wParam2 = SDL_SwapLE16(message.wParam2);
|
||||
if (wParam2 > RSPLTYPE_INVALID)
|
||||
if (wParam2 > static_cast<uint8_t>(SpellType::LAST))
|
||||
return sizeof(message);
|
||||
|
||||
auto spell = static_cast<spell_id>(wParam1);
|
||||
@@ -1522,7 +1522,7 @@ size_t OnSpellTile(const TCmd *pCmd, Player &player)
|
||||
player.destParam2 = position.y;
|
||||
player.destParam3 = SDL_SwapLE16(message.wParam3);
|
||||
player.queuedSpell.spellId = spell;
|
||||
player.queuedSpell.spellType = static_cast<spell_type>(wParam2);
|
||||
player.queuedSpell.spellType = static_cast<SpellType>(wParam2);
|
||||
|
||||
return sizeof(message);
|
||||
}
|
||||
@@ -1557,7 +1557,7 @@ size_t OnTargetSpellTile(const TCmd *pCmd, Player &player)
|
||||
player.destParam2 = position.y;
|
||||
player.destParam3 = SDL_SwapLE16(message.wParam2);
|
||||
player.queuedSpell.spellId = spell;
|
||||
player.queuedSpell.spellType = RSPLTYPE_SCROLL;
|
||||
player.queuedSpell.spellType = SpellType::Scroll;
|
||||
player.queuedSpell.spellFrom = static_cast<int8_t>(wParam3);
|
||||
|
||||
return sizeof(message);
|
||||
@@ -1653,7 +1653,7 @@ size_t OnSpellMonster(const TCmd *pCmd, Player &player)
|
||||
if (wParam2 > SPL_LAST)
|
||||
return sizeof(message);
|
||||
const uint16_t wParam3 = SDL_SwapLE16(message.wParam3);
|
||||
if (wParam3 > RSPLTYPE_INVALID)
|
||||
if (wParam3 > static_cast<uint8_t>(SpellType::LAST))
|
||||
return sizeof(message);
|
||||
|
||||
auto spell = static_cast<spell_id>(wParam2);
|
||||
@@ -1671,7 +1671,7 @@ size_t OnSpellMonster(const TCmd *pCmd, Player &player)
|
||||
player.destParam1 = monsterIdx;
|
||||
player.destParam2 = SDL_SwapLE16(message.wParam4);
|
||||
player.queuedSpell.spellId = spell;
|
||||
player.queuedSpell.spellType = static_cast<spell_type>(wParam3);
|
||||
player.queuedSpell.spellType = static_cast<SpellType>(wParam3);
|
||||
player.queuedSpell.spellFrom = 0;
|
||||
|
||||
return sizeof(message);
|
||||
@@ -1692,7 +1692,7 @@ size_t OnSpellPlayer(const TCmd *pCmd, Player &player)
|
||||
if (wParam2 > SPL_LAST)
|
||||
return sizeof(message);
|
||||
const uint16_t wParam3 = SDL_SwapLE16(message.wParam3);
|
||||
if (wParam3 > RSPLTYPE_INVALID)
|
||||
if (wParam3 > static_cast<uint8_t>(SpellType::LAST))
|
||||
return sizeof(message);
|
||||
|
||||
auto spell = static_cast<spell_id>(wParam2);
|
||||
@@ -1710,7 +1710,7 @@ size_t OnSpellPlayer(const TCmd *pCmd, Player &player)
|
||||
player.destParam1 = playerIdx;
|
||||
player.destParam2 = SDL_SwapLE16(message.wParam4);
|
||||
player.queuedSpell.spellId = spell;
|
||||
player.queuedSpell.spellType = static_cast<spell_type>(wParam3);
|
||||
player.queuedSpell.spellType = static_cast<SpellType>(wParam3);
|
||||
player.queuedSpell.spellFrom = 0;
|
||||
|
||||
return sizeof(message);
|
||||
@@ -1745,7 +1745,7 @@ size_t OnTargetSpellMonster(const TCmd *pCmd, Player &player)
|
||||
player.destParam1 = monsterIdx;
|
||||
player.destParam2 = SDL_SwapLE16(message.wParam3);
|
||||
player.queuedSpell.spellId = spell;
|
||||
player.queuedSpell.spellType = RSPLTYPE_SCROLL;
|
||||
player.queuedSpell.spellType = SpellType::Scroll;
|
||||
player.queuedSpell.spellFrom = static_cast<int8_t>(wParam4);
|
||||
|
||||
return sizeof(message);
|
||||
@@ -1780,7 +1780,7 @@ size_t OnTargetSpellPlayer(const TCmd *pCmd, Player &player)
|
||||
player.destParam1 = playerIdx;
|
||||
player.destParam2 = SDL_SwapLE16(message.wParam3);
|
||||
player.queuedSpell.spellId = spell;
|
||||
player.queuedSpell.spellType = RSPLTYPE_SCROLL;
|
||||
player.queuedSpell.spellType = SpellType::Scroll;
|
||||
player.queuedSpell.spellFrom = static_cast<int8_t>(wParam4);
|
||||
|
||||
return sizeof(message);
|
||||
@@ -2481,7 +2481,7 @@ size_t OnNova(const TCmd *pCmd, Player &player)
|
||||
if (player.isOnActiveLevel() && &player != MyPlayer && InDungeonBounds(position)) {
|
||||
ClrPlrPath(player);
|
||||
player.queuedSpell.spellId = SPL_NOVA;
|
||||
player.queuedSpell.spellType = RSPLTYPE_SCROLL;
|
||||
player.queuedSpell.spellType = SpellType::Scroll;
|
||||
player.queuedSpell.spellFrom = 3;
|
||||
player.destAction = ACTION_SPELL;
|
||||
player.destParam1 = position.x;
|
||||
|
||||
@@ -48,28 +48,28 @@ void PrintSBookStr(const Surface &out, Point position, string_view text, UiFlags
|
||||
UiFlags::ColorWhite | flags);
|
||||
}
|
||||
|
||||
spell_type GetSBookTrans(spell_id ii, bool townok)
|
||||
SpellType GetSBookTrans(spell_id ii, bool townok)
|
||||
{
|
||||
Player &player = *MyPlayer;
|
||||
if ((player._pClass == HeroClass::Monk) && (ii == SPL_SEARCH))
|
||||
return RSPLTYPE_SKILL;
|
||||
spell_type st = RSPLTYPE_SPELL;
|
||||
return SpellType::Skill;
|
||||
SpellType st = SpellType::Spell;
|
||||
if ((player._pISpells & GetSpellBitmask(ii)) != 0) {
|
||||
st = RSPLTYPE_CHARGES;
|
||||
st = SpellType::Charges;
|
||||
}
|
||||
if ((player._pAblSpells & GetSpellBitmask(ii)) != 0) {
|
||||
st = RSPLTYPE_SKILL;
|
||||
st = SpellType::Skill;
|
||||
}
|
||||
if (st == RSPLTYPE_SPELL) {
|
||||
if (st == SpellType::Spell) {
|
||||
if (CheckSpell(*MyPlayer, ii, st, true) != SpellCheckResult::Success) {
|
||||
st = RSPLTYPE_INVALID;
|
||||
st = SpellType::Invalid;
|
||||
}
|
||||
if (player.GetSpellLevel(ii) == 0) {
|
||||
st = RSPLTYPE_INVALID;
|
||||
st = SpellType::Invalid;
|
||||
}
|
||||
}
|
||||
if (townok && leveltype == DTYPE_TOWN && st != RSPLTYPE_INVALID && !spelldata[ii].sTownSpell) {
|
||||
st = RSPLTYPE_INVALID;
|
||||
if (townok && leveltype == DTYPE_TOWN && st != SpellType::Invalid && !spelldata[ii].sTownSpell) {
|
||||
st = SpellType::Invalid;
|
||||
}
|
||||
|
||||
return st;
|
||||
@@ -129,12 +129,12 @@ void DrawSpellBook(const Surface &out)
|
||||
for (int i = 1; i < 8; i++) {
|
||||
spell_id sn = SpellPages[sbooktab][i - 1];
|
||||
if (IsValidSpell(sn) && (spl & GetSpellBitmask(sn)) != 0) {
|
||||
spell_type st = GetSBookTrans(sn, true);
|
||||
SpellType st = GetSBookTrans(sn, true);
|
||||
SetSpellTrans(st);
|
||||
const Point spellCellPosition = GetPanelPosition(UiPanels::Spell, { 11, yp + SpellBookDescription.height });
|
||||
DrawSmallSpellIcon(out, spellCellPosition, sn);
|
||||
if (sn == player._pRSpell && st == player._pRSplType) {
|
||||
SetSpellTrans(RSPLTYPE_SKILL);
|
||||
SetSpellTrans(SpellType::Skill);
|
||||
DrawSmallSpellIconBorder(out, spellCellPosition);
|
||||
}
|
||||
|
||||
@@ -142,10 +142,10 @@ void DrawSpellBook(const Surface &out)
|
||||
const Point line1 { 0, yp + textPaddingTop + lineHeight };
|
||||
PrintSBookStr(out, line0, pgettext("spell", spelldata[sn].sNameText));
|
||||
switch (GetSBookTrans(sn, false)) {
|
||||
case RSPLTYPE_SKILL:
|
||||
case SpellType::Skill:
|
||||
PrintSBookStr(out, line1, _("Skill"));
|
||||
break;
|
||||
case RSPLTYPE_CHARGES: {
|
||||
case SpellType::Charges: {
|
||||
int charges = player.InvBody[INVLOC_HAND_LEFT]._iCharges;
|
||||
PrintSBookStr(out, line1, fmt::format(fmt::runtime(ngettext("Staff ({:d} charge)", "Staff ({:d} charges)", charges)), charges));
|
||||
} break;
|
||||
@@ -191,12 +191,12 @@ void CheckSBook()
|
||||
Player &player = *MyPlayer;
|
||||
uint64_t spl = player._pMemSpells | player._pISpells | player._pAblSpells;
|
||||
if (IsValidSpell(sn) && (spl & GetSpellBitmask(sn)) != 0) {
|
||||
spell_type st = RSPLTYPE_SPELL;
|
||||
SpellType st = SpellType::Spell;
|
||||
if ((player._pISpells & GetSpellBitmask(sn)) != 0) {
|
||||
st = RSPLTYPE_CHARGES;
|
||||
st = SpellType::Charges;
|
||||
}
|
||||
if ((player._pAblSpells & GetSpellBitmask(sn)) != 0) {
|
||||
st = RSPLTYPE_SKILL;
|
||||
st = SpellType::Skill;
|
||||
}
|
||||
player._pRSpell = sn;
|
||||
player._pRSplType = st;
|
||||
|
||||
@@ -97,7 +97,7 @@ void LoadLargeSpellIcons()
|
||||
LargeSpellIcons = LoadCel("data\\spelicon", SPLICONLENGTH);
|
||||
#endif
|
||||
}
|
||||
SetSpellTrans(RSPLTYPE_SKILL);
|
||||
SetSpellTrans(SpellType::Skill);
|
||||
}
|
||||
|
||||
void FreeLargeSpellIcons()
|
||||
@@ -156,9 +156,9 @@ void DrawSmallSpellIconBorder(const Surface &out, Point position)
|
||||
UnsafeDrawBorder2px(out, Rectangle { Point { position.x, position.y - height + 1 }, Size { width, height } }, SplTransTbl[PAL8_YELLOW + 2]);
|
||||
}
|
||||
|
||||
void SetSpellTrans(spell_type t)
|
||||
void SetSpellTrans(SpellType t)
|
||||
{
|
||||
if (t == RSPLTYPE_SKILL) {
|
||||
if (t == SpellType::Skill) {
|
||||
for (int i = 0; i < 128; i++)
|
||||
SplTransTbl[i] = i;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ void SetSpellTrans(spell_type t)
|
||||
SplTransTbl[255] = 0;
|
||||
|
||||
switch (t) {
|
||||
case RSPLTYPE_SPELL:
|
||||
case SpellType::Spell:
|
||||
SplTransTbl[PAL8_YELLOW] = PAL16_BLUE + 1;
|
||||
SplTransTbl[PAL8_YELLOW + 1] = PAL16_BLUE + 3;
|
||||
SplTransTbl[PAL8_YELLOW + 2] = PAL16_BLUE + 5;
|
||||
@@ -177,7 +177,7 @@ void SetSpellTrans(spell_type t)
|
||||
SplTransTbl[PAL16_ORANGE - PAL16_BLUE + i] = i;
|
||||
}
|
||||
break;
|
||||
case RSPLTYPE_SCROLL:
|
||||
case SpellType::Scroll:
|
||||
SplTransTbl[PAL8_YELLOW] = PAL16_BEIGE + 1;
|
||||
SplTransTbl[PAL8_YELLOW + 1] = PAL16_BEIGE + 3;
|
||||
SplTransTbl[PAL8_YELLOW + 2] = PAL16_BEIGE + 5;
|
||||
@@ -186,7 +186,7 @@ void SetSpellTrans(spell_type t)
|
||||
SplTransTbl[PAL16_ORANGE - PAL16_BEIGE + i] = i;
|
||||
}
|
||||
break;
|
||||
case RSPLTYPE_CHARGES:
|
||||
case SpellType::Charges:
|
||||
SplTransTbl[PAL8_YELLOW] = PAL16_ORANGE + 1;
|
||||
SplTransTbl[PAL8_YELLOW + 1] = PAL16_ORANGE + 3;
|
||||
SplTransTbl[PAL8_YELLOW + 2] = PAL16_ORANGE + 5;
|
||||
@@ -195,7 +195,7 @@ void SetSpellTrans(spell_type t)
|
||||
SplTransTbl[PAL16_YELLOW - PAL16_ORANGE + i] = i;
|
||||
}
|
||||
break;
|
||||
case RSPLTYPE_INVALID:
|
||||
case SpellType::Invalid:
|
||||
SplTransTbl[PAL8_YELLOW] = PAL16_GRAY + 1;
|
||||
SplTransTbl[PAL8_YELLOW + 1] = PAL16_GRAY + 3;
|
||||
SplTransTbl[PAL8_YELLOW + 2] = PAL16_GRAY + 5;
|
||||
@@ -208,7 +208,7 @@ void SetSpellTrans(spell_type t)
|
||||
SplTransTbl[PAL16_YELLOW + 15] = 0;
|
||||
SplTransTbl[PAL16_ORANGE + 15] = 0;
|
||||
break;
|
||||
case RSPLTYPE_SKILL:
|
||||
case SpellType::Skill:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void DrawSmallSpellIconBorder(const Surface &out, Point position);
|
||||
/**
|
||||
* @brief Set the color mapping for the `Draw(Small|Large)SpellIcon(Border)` calls.
|
||||
*/
|
||||
void SetSpellTrans(spell_type t);
|
||||
void SetSpellTrans(SpellType t);
|
||||
|
||||
void LoadLargeSpellIcons();
|
||||
void FreeLargeSpellIcons();
|
||||
|
||||
@@ -43,10 +43,10 @@ void PrintSBookHotkey(const Surface &out, Point position, const string_view text
|
||||
DrawString(out, text, position, UiFlags::ColorWhite | UiFlags::Outlined);
|
||||
}
|
||||
|
||||
bool GetSpellListSelection(spell_id &pSpell, spell_type &pSplType)
|
||||
bool GetSpellListSelection(spell_id &pSpell, SpellType &pSplType)
|
||||
{
|
||||
pSpell = spell_id::SPL_INVALID;
|
||||
pSplType = spell_type::RSPLTYPE_INVALID;
|
||||
pSplType = SpellType::Invalid;
|
||||
Player &myPlayer = *MyPlayer;
|
||||
|
||||
for (auto &spellListItem : GetSpellListItems()) {
|
||||
@@ -54,7 +54,7 @@ bool GetSpellListSelection(spell_id &pSpell, spell_type &pSplType)
|
||||
pSpell = spellListItem.id;
|
||||
pSplType = spellListItem.type;
|
||||
if (myPlayer._pClass == HeroClass::Monk && spellListItem.id == SPL_SEARCH)
|
||||
pSplType = RSPLTYPE_SKILL;
|
||||
pSplType = SpellType::Skill;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ bool GetSpellListSelection(spell_id &pSpell, spell_type &pSplType)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<string_view> GetHotkeyName(spell_id spellId, spell_type spellType)
|
||||
std::optional<string_view> GetHotkeyName(spell_id spellId, SpellType spellType)
|
||||
{
|
||||
Player &myPlayer = *MyPlayer;
|
||||
for (size_t t = 0; t < NumHotkeys; t++) {
|
||||
@@ -80,23 +80,23 @@ void DrawSpell(const Surface &out)
|
||||
{
|
||||
Player &myPlayer = *MyPlayer;
|
||||
spell_id spl = myPlayer._pRSpell;
|
||||
spell_type st = myPlayer._pRSplType;
|
||||
SpellType st = myPlayer._pRSplType;
|
||||
|
||||
if (!IsValidSpell(spl)) {
|
||||
st = RSPLTYPE_INVALID;
|
||||
st = SpellType::Invalid;
|
||||
spl = SPL_NULL;
|
||||
}
|
||||
|
||||
if (st == RSPLTYPE_SPELL) {
|
||||
if (st == SpellType::Spell) {
|
||||
int tlvl = myPlayer.GetSpellLevel(spl);
|
||||
if (CheckSpell(*MyPlayer, spl, st, true) != SpellCheckResult::Success)
|
||||
st = RSPLTYPE_INVALID;
|
||||
st = SpellType::Invalid;
|
||||
if (tlvl <= 0)
|
||||
st = RSPLTYPE_INVALID;
|
||||
st = SpellType::Invalid;
|
||||
}
|
||||
|
||||
if (leveltype == DTYPE_TOWN && st != RSPLTYPE_INVALID && !spelldata[spl].sTownSpell)
|
||||
st = RSPLTYPE_INVALID;
|
||||
if (leveltype == DTYPE_TOWN && st != SpellType::Invalid && !spelldata[spl].sTownSpell)
|
||||
st = SpellType::Invalid;
|
||||
|
||||
SetSpellTrans(st);
|
||||
const Point position = GetMainPanel().position + Displacement { 565, 119 };
|
||||
@@ -115,16 +115,16 @@ void DrawSpellList(const Surface &out)
|
||||
|
||||
for (auto &spellListItem : GetSpellListItems()) {
|
||||
const spell_id spellId = spellListItem.id;
|
||||
spell_type transType = spellListItem.type;
|
||||
SpellType transType = spellListItem.type;
|
||||
int spellLevel = 0;
|
||||
const SpellData &spellDataItem = spelldata[static_cast<size_t>(spellListItem.id)];
|
||||
if (leveltype == DTYPE_TOWN && !spellDataItem.sTownSpell) {
|
||||
transType = RSPLTYPE_INVALID;
|
||||
transType = SpellType::Invalid;
|
||||
}
|
||||
if (spellListItem.type == RSPLTYPE_SPELL) {
|
||||
if (spellListItem.type == SpellType::Spell) {
|
||||
spellLevel = myPlayer.GetSpellLevel(spellListItem.id);
|
||||
if (spellLevel == 0)
|
||||
transType = RSPLTYPE_INVALID;
|
||||
transType = SpellType::Invalid;
|
||||
}
|
||||
|
||||
SetSpellTrans(transType);
|
||||
@@ -141,12 +141,12 @@ void DrawSpellList(const Surface &out)
|
||||
uint8_t spellColor = PAL16_GRAY + 5;
|
||||
|
||||
switch (spellListItem.type) {
|
||||
case RSPLTYPE_SKILL:
|
||||
case SpellType::Skill:
|
||||
spellColor = PAL16_YELLOW - 46;
|
||||
PrintSBookSpellType(out, spellListItem.location, _("Skill"), spellColor);
|
||||
InfoString = fmt::format(fmt::runtime(_("{:s} Skill")), pgettext("spell", spellDataItem.sNameText));
|
||||
break;
|
||||
case RSPLTYPE_SPELL:
|
||||
case SpellType::Spell:
|
||||
if (!myPlayer.isOnLevel(0)) {
|
||||
spellColor = PAL16_BLUE + 5;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ void DrawSpellList(const Surface &out)
|
||||
else
|
||||
AddPanelString(fmt::format(fmt::runtime(_("Spell Level {:d}")), spellLevel));
|
||||
break;
|
||||
case RSPLTYPE_SCROLL: {
|
||||
case SpellType::Scroll: {
|
||||
if (!myPlayer.isOnLevel(0)) {
|
||||
spellColor = PAL16_RED - 59;
|
||||
}
|
||||
@@ -172,7 +172,7 @@ void DrawSpellList(const Surface &out)
|
||||
});
|
||||
AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Scroll", "{:d} Scrolls", scrollCount)), scrollCount));
|
||||
} break;
|
||||
case RSPLTYPE_CHARGES: {
|
||||
case SpellType::Charges: {
|
||||
if (!myPlayer.isOnLevel(0)) {
|
||||
spellColor = PAL16_ORANGE + 5;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ void DrawSpellList(const Surface &out)
|
||||
int charges = myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges;
|
||||
AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Charge", "{:d} Charges", charges)), charges));
|
||||
} break;
|
||||
case RSPLTYPE_INVALID:
|
||||
case SpellType::Invalid:
|
||||
break;
|
||||
}
|
||||
if (hotkeyName) {
|
||||
@@ -200,22 +200,22 @@ std::vector<SpellListItem> GetSpellListItems()
|
||||
int x = mainPanelPosition.x + 12 + SPLICONLENGTH * SPLROWICONLS;
|
||||
int y = mainPanelPosition.y - 17;
|
||||
|
||||
for (int i = RSPLTYPE_SKILL; i < RSPLTYPE_INVALID; i++) {
|
||||
for (auto i : enum_values<SpellType>()) {
|
||||
Player &myPlayer = *MyPlayer;
|
||||
switch ((spell_type)i) {
|
||||
case RSPLTYPE_SKILL:
|
||||
switch (static_cast<SpellType>(i)) {
|
||||
case SpellType::Skill:
|
||||
mask = myPlayer._pAblSpells;
|
||||
break;
|
||||
case RSPLTYPE_SPELL:
|
||||
case SpellType::Spell:
|
||||
mask = myPlayer._pMemSpells;
|
||||
break;
|
||||
case RSPLTYPE_SCROLL:
|
||||
case SpellType::Scroll:
|
||||
mask = myPlayer._pScrlSpells;
|
||||
break;
|
||||
case RSPLTYPE_CHARGES:
|
||||
case SpellType::Charges:
|
||||
mask = myPlayer._pISpells;
|
||||
break;
|
||||
case RSPLTYPE_INVALID:
|
||||
case SpellType::Invalid:
|
||||
break;
|
||||
}
|
||||
int8_t j = SPL_FIREBOLT;
|
||||
@@ -225,7 +225,7 @@ std::vector<SpellListItem> GetSpellListItems()
|
||||
int lx = x;
|
||||
int ly = y - SPLICONLENGTH;
|
||||
bool isSelected = (MousePosition.x >= lx && MousePosition.x < lx + SPLICONLENGTH && MousePosition.y >= ly && MousePosition.y < ly + SPLICONLENGTH);
|
||||
spellListItems.emplace_back(SpellListItem { { x, y }, (spell_type)i, (spell_id)j, isSelected });
|
||||
spellListItems.emplace_back(SpellListItem { { x, y }, static_cast<SpellType>(i), (spell_id)j, isSelected });
|
||||
x -= SPLICONLENGTH;
|
||||
if (x == mainPanelPosition.x + 12 - SPLICONLENGTH) {
|
||||
x = mainPanelPosition.x + 12 + SPLICONLENGTH * SPLROWICONLS;
|
||||
@@ -246,7 +246,7 @@ std::vector<SpellListItem> GetSpellListItems()
|
||||
void SetSpell()
|
||||
{
|
||||
spell_id pSpell;
|
||||
spell_type pSplType;
|
||||
SpellType pSplType;
|
||||
|
||||
spselflag = false;
|
||||
if (!GetSpellListSelection(pSpell, pSplType)) {
|
||||
@@ -263,7 +263,7 @@ void SetSpell()
|
||||
void SetSpeedSpell(size_t slot)
|
||||
{
|
||||
spell_id pSpell;
|
||||
spell_type pSplType;
|
||||
SpellType pSplType;
|
||||
|
||||
if (!GetSpellListSelection(pSpell, pSplType)) {
|
||||
return;
|
||||
@@ -289,19 +289,19 @@ void ToggleSpell(size_t slot)
|
||||
}
|
||||
|
||||
switch (myPlayer._pSplTHotKey[slot]) {
|
||||
case RSPLTYPE_SKILL:
|
||||
case SpellType::Skill:
|
||||
spells = myPlayer._pAblSpells;
|
||||
break;
|
||||
case RSPLTYPE_SPELL:
|
||||
case SpellType::Spell:
|
||||
spells = myPlayer._pMemSpells;
|
||||
break;
|
||||
case RSPLTYPE_SCROLL:
|
||||
case SpellType::Scroll:
|
||||
spells = myPlayer._pScrlSpells;
|
||||
break;
|
||||
case RSPLTYPE_CHARGES:
|
||||
case SpellType::Charges:
|
||||
spells = myPlayer._pISpells;
|
||||
break;
|
||||
case RSPLTYPE_INVALID:
|
||||
case SpellType::Invalid:
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -324,26 +324,26 @@ void DoSpeedBook()
|
||||
Player &myPlayer = *MyPlayer;
|
||||
|
||||
if (IsValidSpell(myPlayer._pRSpell)) {
|
||||
for (int i = RSPLTYPE_SKILL; i <= RSPLTYPE_CHARGES; i++) {
|
||||
for (auto i : enum_values<SpellType>()) {
|
||||
uint64_t spells;
|
||||
switch (i) {
|
||||
case RSPLTYPE_SKILL:
|
||||
switch (static_cast<SpellType>(i)) {
|
||||
case SpellType::Skill:
|
||||
spells = myPlayer._pAblSpells;
|
||||
break;
|
||||
case RSPLTYPE_SPELL:
|
||||
case SpellType::Spell:
|
||||
spells = myPlayer._pMemSpells;
|
||||
break;
|
||||
case RSPLTYPE_SCROLL:
|
||||
case SpellType::Scroll:
|
||||
spells = myPlayer._pScrlSpells;
|
||||
break;
|
||||
case RSPLTYPE_CHARGES:
|
||||
case SpellType::Charges:
|
||||
spells = myPlayer._pISpells;
|
||||
break;
|
||||
}
|
||||
uint64_t spell = 1;
|
||||
for (int j = 1; j < MAX_SPELLS; j++) {
|
||||
if ((spell & spells) != 0) {
|
||||
if (j == myPlayer._pRSpell && i == myPlayer._pRSplType) {
|
||||
if (j == myPlayer._pRSpell && static_cast<SpellType>(i) == myPlayer._pRSplType) {
|
||||
x = xo + SPLICONLENGTH / 2;
|
||||
y = yo - SPLICONLENGTH / 2;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace devilution {
|
||||
|
||||
struct SpellListItem {
|
||||
Point location;
|
||||
spell_type type;
|
||||
SpellType type;
|
||||
spell_id id;
|
||||
bool isSelected;
|
||||
};
|
||||
|
||||
+21
-21
@@ -453,17 +453,17 @@ void StartSpell(Player &player, Direction d, WorldTileCoord cx, WorldTileCoord c
|
||||
// Checks conditions for spell again, cause initial check was done when spell was queued and the parameters could be changed meanwhile
|
||||
bool isValid = true;
|
||||
switch (player.queuedSpell.spellType) {
|
||||
case RSPLTYPE_SKILL:
|
||||
case RSPLTYPE_SPELL:
|
||||
case SpellType::Skill:
|
||||
case SpellType::Spell:
|
||||
isValid = CheckSpell(player, player.queuedSpell.spellId, player.queuedSpell.spellType, true) == SpellCheckResult::Success;
|
||||
break;
|
||||
case RSPLTYPE_SCROLL:
|
||||
case SpellType::Scroll:
|
||||
isValid = CanUseScroll(player, player.queuedSpell.spellId);
|
||||
break;
|
||||
case RSPLTYPE_CHARGES:
|
||||
case SpellType::Charges:
|
||||
isValid = CanUseStaff(player, player.queuedSpell.spellId);
|
||||
break;
|
||||
case RSPLTYPE_INVALID:
|
||||
case SpellType::Invalid:
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
@@ -1236,7 +1236,7 @@ bool DoSpell(Player &player)
|
||||
player.position.temp.y,
|
||||
player.executedSpell.spellLevel);
|
||||
|
||||
if (IsAnyOf(player.executedSpell.spellType, RSPLTYPE_SCROLL, RSPLTYPE_CHARGES)) {
|
||||
if (IsAnyOf(player.executedSpell.spellType, SpellType::Scroll, SpellType::Charges)) {
|
||||
EnsureValidReadiedSpell(player);
|
||||
}
|
||||
}
|
||||
@@ -1997,7 +1997,7 @@ void Player::ReadySpellFromEquipment(inv_body_loc bodyLocation)
|
||||
auto &item = InvBody[bodyLocation];
|
||||
if (item._itype == ItemType::Staff && IsValidSpell(item._iSpell) && item._iCharges > 0) {
|
||||
_pRSpell = item._iSpell;
|
||||
_pRSplType = RSPLTYPE_CHARGES;
|
||||
_pRSplType = SpellType::Charges;
|
||||
RedrawEverything();
|
||||
}
|
||||
}
|
||||
@@ -2540,7 +2540,7 @@ void CreatePlayer(Player &player, HeroClass c)
|
||||
player._pLightRad = 10;
|
||||
player._pInfraFlag = false;
|
||||
|
||||
player._pRSplType = RSPLTYPE_SKILL;
|
||||
player._pRSplType = SpellType::Skill;
|
||||
if (c == HeroClass::Warrior) {
|
||||
player._pAblSpells = GetSpellBitmask(SPL_REPAIR);
|
||||
player._pRSpell = SPL_REPAIR;
|
||||
@@ -2563,7 +2563,7 @@ void CreatePlayer(Player &player, HeroClass c)
|
||||
|
||||
if (c == HeroClass::Sorcerer) {
|
||||
player._pMemSpells = GetSpellBitmask(SPL_FIREBOLT);
|
||||
player._pRSplType = RSPLTYPE_SPELL;
|
||||
player._pRSplType = SpellType::Spell;
|
||||
player._pRSpell = SPL_FIREBOLT;
|
||||
} else {
|
||||
player._pMemSpells = 0;
|
||||
@@ -2749,7 +2749,7 @@ void AddPlrMonstExper(int lvl, int exp, char pmask)
|
||||
void InitPlayer(Player &player, bool firstTime)
|
||||
{
|
||||
if (firstTime) {
|
||||
player._pRSplType = RSPLTYPE_INVALID;
|
||||
player._pRSplType = SpellType::Invalid;
|
||||
player._pRSpell = SPL_INVALID;
|
||||
if (&player == MyPlayer)
|
||||
LoadHotkeys();
|
||||
@@ -3417,7 +3417,7 @@ void CalcPlrStaff(Player &player)
|
||||
}
|
||||
}
|
||||
|
||||
void CheckPlrSpell(bool isShiftHeld, spell_id spellID, spell_type spellType)
|
||||
void CheckPlrSpell(bool isShiftHeld, spell_id spellID, SpellType spellType)
|
||||
{
|
||||
bool addflag = false;
|
||||
|
||||
@@ -3456,23 +3456,23 @@ void CheckPlrSpell(bool isShiftHeld, spell_id spellID, spell_type spellType)
|
||||
|
||||
SpellCheckResult spellcheck = SpellCheckResult::Success;
|
||||
switch (spellType) {
|
||||
case RSPLTYPE_SKILL:
|
||||
case RSPLTYPE_SPELL:
|
||||
case SpellType::Skill:
|
||||
case SpellType::Spell:
|
||||
spellcheck = CheckSpell(*MyPlayer, spellID, spellType, false);
|
||||
addflag = spellcheck == SpellCheckResult::Success;
|
||||
break;
|
||||
case RSPLTYPE_SCROLL:
|
||||
case SpellType::Scroll:
|
||||
addflag = pcurs == CURSOR_HAND && CanUseScroll(myPlayer, spellID);
|
||||
break;
|
||||
case RSPLTYPE_CHARGES:
|
||||
case SpellType::Charges:
|
||||
addflag = pcurs == CURSOR_HAND && CanUseStaff(myPlayer, spellID);
|
||||
break;
|
||||
case RSPLTYPE_INVALID:
|
||||
case SpellType::Invalid:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!addflag) {
|
||||
if (spellType == RSPLTYPE_SPELL) {
|
||||
if (spellType == SpellType::Spell) {
|
||||
switch (spellcheck) {
|
||||
case SpellCheckResult::Fail_NoMana:
|
||||
myPlayer.Say(HeroSpeech::NotEnoughMana);
|
||||
@@ -3493,16 +3493,16 @@ void CheckPlrSpell(bool isShiftHeld, spell_id spellID, spell_type spellType)
|
||||
if (IsWallSpell(spellID)) {
|
||||
LastMouseButtonAction = MouseActionType::Spell;
|
||||
Direction sd = GetDirection(myPlayer.position.tile, cursPosition);
|
||||
NetSendCmdLocParam4(true, CMD_SPELLXYD, cursPosition, spellID, spellType, static_cast<uint16_t>(sd), sl);
|
||||
NetSendCmdLocParam4(true, CMD_SPELLXYD, cursPosition, spellID, static_cast<uint8_t>(spellType), static_cast<uint16_t>(sd), sl);
|
||||
} else if (pcursmonst != -1 && !isShiftHeld) {
|
||||
LastMouseButtonAction = MouseActionType::SpellMonsterTarget;
|
||||
NetSendCmdParam4(true, CMD_SPELLID, pcursmonst, spellID, spellType, sl);
|
||||
NetSendCmdParam4(true, CMD_SPELLID, pcursmonst, spellID, static_cast<uint8_t>(spellType), sl);
|
||||
} else if (pcursplr != -1 && !isShiftHeld && !myPlayer.friendlyMode) {
|
||||
LastMouseButtonAction = MouseActionType::SpellPlayerTarget;
|
||||
NetSendCmdParam4(true, CMD_SPELLPID, pcursplr, spellID, spellType, sl);
|
||||
NetSendCmdParam4(true, CMD_SPELLPID, pcursplr, spellID, static_cast<uint8_t>(spellType), sl);
|
||||
} else {
|
||||
LastMouseButtonAction = MouseActionType::Spell;
|
||||
NetSendCmdLocParam3(true, CMD_SPELLXY, cursPosition, spellID, spellType, sl);
|
||||
NetSendCmdLocParam3(true, CMD_SPELLXY, cursPosition, spellID, static_cast<uint8_t>(spellType), sl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -208,7 +208,7 @@ struct PlayerAnimationData {
|
||||
|
||||
struct SpellCastInfo {
|
||||
spell_id spellId;
|
||||
spell_type spellType;
|
||||
SpellType spellType;
|
||||
/* @brief Inventory location for scrolls */
|
||||
int8_t spellFrom;
|
||||
/* @brief Used for spell level */
|
||||
@@ -324,7 +324,7 @@ struct Player {
|
||||
SpellCastInfo executedSpell;
|
||||
spell_id _pTSpell;
|
||||
spell_id _pRSpell;
|
||||
spell_type _pRSplType;
|
||||
SpellType _pRSplType;
|
||||
spell_id _pSBkSpell;
|
||||
int8_t _pSplLvl[64];
|
||||
/** @brief Bitmask of staff spell */
|
||||
@@ -337,7 +337,7 @@ struct Player {
|
||||
uint64_t _pScrlSpells;
|
||||
SpellFlag _pSpellFlags;
|
||||
spell_id _pSplHotKey[NumHotkeys];
|
||||
spell_type _pSplTHotKey[NumHotkeys];
|
||||
SpellType _pSplTHotKey[NumHotkeys];
|
||||
bool _pBlockFlag;
|
||||
bool _pInvincible;
|
||||
int8_t _pLightRad;
|
||||
@@ -817,7 +817,7 @@ void ClrPlrPath(Player &player);
|
||||
bool PosOkPlayer(const Player &player, Point position);
|
||||
void MakePlrPath(Player &player, Point targetPosition, bool endspace);
|
||||
void CalcPlrStaff(Player &player);
|
||||
void CheckPlrSpell(bool isShiftHeld, spell_id spellID = MyPlayer->_pRSpell, spell_type spellType = MyPlayer->_pRSplType);
|
||||
void CheckPlrSpell(bool isShiftHeld, spell_id spellID = MyPlayer->_pRSpell, SpellType spellType = MyPlayer->_pRSplType);
|
||||
void SyncPlrAnim(Player &player);
|
||||
void SyncInitPlrPos(Player &player);
|
||||
void SyncInitPlr(Player &player);
|
||||
|
||||
+8
-6
@@ -13,12 +13,14 @@ namespace devilution {
|
||||
|
||||
#define MAX_SPELLS 52
|
||||
|
||||
enum spell_type : uint8_t {
|
||||
RSPLTYPE_SKILL,
|
||||
RSPLTYPE_SPELL,
|
||||
RSPLTYPE_SCROLL,
|
||||
RSPLTYPE_CHARGES,
|
||||
RSPLTYPE_INVALID,
|
||||
enum class SpellType : uint8_t {
|
||||
Skill,
|
||||
FIRST = Skill,
|
||||
Spell,
|
||||
Scroll,
|
||||
Charges,
|
||||
Invalid,
|
||||
LAST = Invalid,
|
||||
};
|
||||
|
||||
enum spell_id : int8_t {
|
||||
|
||||
+14
-14
@@ -31,15 +31,15 @@ namespace {
|
||||
bool IsReadiedSpellValid(const Player &player)
|
||||
{
|
||||
switch (player._pRSplType) {
|
||||
case RSPLTYPE_SKILL:
|
||||
case RSPLTYPE_SPELL:
|
||||
case RSPLTYPE_INVALID:
|
||||
case SpellType::Skill:
|
||||
case SpellType::Spell:
|
||||
case SpellType::Invalid:
|
||||
return true;
|
||||
|
||||
case RSPLTYPE_CHARGES:
|
||||
case SpellType::Charges:
|
||||
return (player._pISpells & GetSpellBitmask(player._pRSpell)) != 0;
|
||||
|
||||
case RSPLTYPE_SCROLL:
|
||||
case SpellType::Scroll:
|
||||
return (player._pScrlSpells & GetSpellBitmask(player._pRSpell)) != 0;
|
||||
|
||||
default:
|
||||
@@ -59,8 +59,8 @@ void ClearReadiedSpell(Player &player)
|
||||
RedrawEverything();
|
||||
}
|
||||
|
||||
if (player._pRSplType != RSPLTYPE_INVALID) {
|
||||
player._pRSplType = RSPLTYPE_INVALID;
|
||||
if (player._pRSplType != SpellType::Invalid) {
|
||||
player._pRSplType = SpellType::Invalid;
|
||||
RedrawEverything();
|
||||
}
|
||||
}
|
||||
@@ -175,16 +175,16 @@ int GetManaAmount(const Player &player, spell_id sn)
|
||||
void ConsumeSpell(Player &player, spell_id sn)
|
||||
{
|
||||
switch (player.executedSpell.spellType) {
|
||||
case RSPLTYPE_SKILL:
|
||||
case RSPLTYPE_INVALID:
|
||||
case SpellType::Skill:
|
||||
case SpellType::Invalid:
|
||||
break;
|
||||
case RSPLTYPE_SCROLL:
|
||||
case SpellType::Scroll:
|
||||
ConsumeScroll(player);
|
||||
break;
|
||||
case RSPLTYPE_CHARGES:
|
||||
case SpellType::Charges:
|
||||
ConsumeStaffCharge(player);
|
||||
break;
|
||||
case RSPLTYPE_SPELL:
|
||||
case SpellType::Spell:
|
||||
#ifdef _DEBUG
|
||||
if (DebugGodMode)
|
||||
break;
|
||||
@@ -210,7 +210,7 @@ void EnsureValidReadiedSpell(Player &player)
|
||||
}
|
||||
}
|
||||
|
||||
SpellCheckResult CheckSpell(const Player &player, spell_id sn, spell_type st, bool manaonly)
|
||||
SpellCheckResult CheckSpell(const Player &player, spell_id sn, SpellType st, bool manaonly)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (DebugGodMode)
|
||||
@@ -221,7 +221,7 @@ SpellCheckResult CheckSpell(const Player &player, spell_id sn, spell_type st, bo
|
||||
return SpellCheckResult::Fail_Busy;
|
||||
}
|
||||
|
||||
if (st == RSPLTYPE_SKILL) {
|
||||
if (st == SpellType::Skill) {
|
||||
return SpellCheckResult::Success;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ bool IsWallSpell(spell_id spl);
|
||||
bool TargetsMonster(spell_id id);
|
||||
int GetManaAmount(const Player &player, spell_id sn);
|
||||
void ConsumeSpell(Player &player, spell_id sn);
|
||||
SpellCheckResult CheckSpell(const Player &player, spell_id sn, spell_type st, bool manaonly);
|
||||
SpellCheckResult CheckSpell(const Player &player, spell_id sn, SpellType st, bool manaonly);
|
||||
|
||||
/**
|
||||
* @brief Ensures the player's current readied spell is a valid selection for the character. If the current selection is
|
||||
|
||||
@@ -139,11 +139,11 @@ static void AssertPlayer(Player &player)
|
||||
ASSERT_EQ(player._pmode, 0);
|
||||
ASSERT_EQ(Count8(player.walkpath, MaxPathLength), 0);
|
||||
ASSERT_EQ(player.queuedSpell.spellId, 0);
|
||||
ASSERT_EQ(player.queuedSpell.spellType, 0);
|
||||
ASSERT_EQ(player.queuedSpell.spellType, SpellType::Skill);
|
||||
ASSERT_EQ(player.queuedSpell.spellFrom, 0);
|
||||
ASSERT_EQ(player._pTSpell, 0);
|
||||
ASSERT_EQ(player._pRSpell, 28);
|
||||
ASSERT_EQ(player._pRSplType, 0);
|
||||
ASSERT_EQ(player._pRSplType, SpellType::Skill);
|
||||
ASSERT_EQ(player._pSBkSpell, 0);
|
||||
ASSERT_EQ(player._pAblSpells, 134217728);
|
||||
ASSERT_EQ(player._pScrlSpells, 0);
|
||||
|
||||
@@ -310,11 +310,11 @@ void AssertPlayer(Player &player)
|
||||
ASSERT_EQ(player.AnimInfo.numberOfFrames, 20);
|
||||
ASSERT_EQ(player.AnimInfo.currentFrame, 0);
|
||||
ASSERT_EQ(player.queuedSpell.spellId, -1);
|
||||
ASSERT_EQ(player.queuedSpell.spellType, 4);
|
||||
ASSERT_EQ(player.queuedSpell.spellType, SpellType::Invalid);
|
||||
ASSERT_EQ(player.queuedSpell.spellFrom, 0);
|
||||
ASSERT_EQ(player._pTSpell, 0);
|
||||
ASSERT_EQ(player._pRSpell, -1);
|
||||
ASSERT_EQ(player._pRSplType, 4);
|
||||
ASSERT_EQ(player._pRSplType, SpellType::Invalid);
|
||||
ASSERT_EQ(player._pSBkSpell, -1);
|
||||
ASSERT_EQ(player._pAblSpells, 134217728);
|
||||
ASSERT_EQ(player._pScrlSpells, 0);
|
||||
|
||||
Reference in new issue
Block a user