|
|
|
|
@ -102,18 +102,24 @@ void DrawSpell(const Surface &out)
|
|
|
|
|
spell_id spl = myPlayer._pRSpell; |
|
|
|
|
spell_type st = myPlayer._pRSplType; |
|
|
|
|
|
|
|
|
|
// BUGFIX: Move the next line into the if statement to avoid OOB (SPL_INVALID is -1) (fixed)
|
|
|
|
|
if (st == RSPLTYPE_SPELL && spl != SPL_INVALID) { |
|
|
|
|
if (!IsValidSpell(spl)) { |
|
|
|
|
st = RSPLTYPE_INVALID; |
|
|
|
|
spl = SPL_NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (st == RSPLTYPE_SPELL) { |
|
|
|
|
int tlvl = myPlayer.GetSpellLevel(spl); |
|
|
|
|
if (CheckSpell(MyPlayerId, spl, st, true) != SpellCheckResult::Success) |
|
|
|
|
st = RSPLTYPE_INVALID; |
|
|
|
|
if (tlvl <= 0) |
|
|
|
|
st = RSPLTYPE_INVALID; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (leveltype == DTYPE_TOWN && st != RSPLTYPE_INVALID && !spelldata[spl].sTownSpell) |
|
|
|
|
st = RSPLTYPE_INVALID; |
|
|
|
|
|
|
|
|
|
SetSpellTrans(st); |
|
|
|
|
const int nCel = (spl != SPL_INVALID) ? SpellITbl[spl] : 26; |
|
|
|
|
const int nCel = SpellITbl[spl]; |
|
|
|
|
const Point position = GetMainPanel().position + Displacement { 565, 119 }; |
|
|
|
|
DrawSpellCel(out, position, nCel); |
|
|
|
|
|
|
|
|
|
@ -301,7 +307,8 @@ void ToggleSpell(size_t slot)
|
|
|
|
|
|
|
|
|
|
Player &myPlayer = *MyPlayer; |
|
|
|
|
|
|
|
|
|
if (myPlayer._pSplHotKey[slot] == SPL_INVALID) { |
|
|
|
|
const spell_id spellId = myPlayer._pSplHotKey[slot]; |
|
|
|
|
if (!IsValidSpell(spellId)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -322,8 +329,7 @@ void ToggleSpell(size_t slot)
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const spell_id spellId = myPlayer._pSplHotKey[slot]; |
|
|
|
|
if (spellId != SPL_INVALID && spellId != SPL_NULL && (spells & GetSpellBitmask(spellId)) != 0) { |
|
|
|
|
if ((spells & GetSpellBitmask(spellId)) != 0) { |
|
|
|
|
myPlayer._pRSpell = spellId; |
|
|
|
|
myPlayer._pRSplType = myPlayer._pSplTHotKey[slot]; |
|
|
|
|
force_redraw = 255; |
|
|
|
|
@ -341,7 +347,7 @@ void DoSpeedBook()
|
|
|
|
|
|
|
|
|
|
Player &myPlayer = *MyPlayer; |
|
|
|
|
|
|
|
|
|
if (myPlayer._pRSpell != SPL_INVALID) { |
|
|
|
|
if (IsValidSpell(myPlayer._pRSpell)) { |
|
|
|
|
for (int i = RSPLTYPE_SKILL; i <= RSPLTYPE_CHARGES; i++) { |
|
|
|
|
uint64_t spells; |
|
|
|
|
switch (i) { |
|
|
|
|
|