Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Book requirements not updating from Objects #6316

Merged
merged 3 commits into from
Jul 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Source/objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ void OperateBook(Player &player, Object &book, bool sendmsg)
if (sendmsg) {
uint8_t newSpellLevel = player._pSplLvl[static_cast<int8_t>(SpellID::Guardian)] + 1;
if (newSpellLevel <= MaxSpellLevel) {
player._pSplLvl[static_cast<int8_t>(SpellID::Guardian)]++;
player._pSplLvl[static_cast<int8_t>(SpellID::Guardian)] = newSpellLevel;
NetSendCmdParam2(true, CMD_CHANGE_SPELL_LEVEL, static_cast<uint16_t>(SpellID::Guardian), newSpellLevel);
}

Expand Down Expand Up @@ -2548,15 +2548,17 @@ void OperateShrineEnchanted(Player &player)
spell = 1;
for (uint8_t j = static_cast<uint8_t>(SpellID::Firebolt); j < maxSpells; j++) {
if ((player._pMemSpells & spell) != 0 && player._pSplLvl[j] < MaxSpellLevel && j != spellToReduce) {
player._pSplLvl[j]++;
NetSendCmdParam2(true, CMD_CHANGE_SPELL_LEVEL, j, static_cast<uint8_t>(player._pSplLvl[j] + 1));
uint8_t newSpellLevel = static_cast<uint8_t>(player._pSplLvl[j] + 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you static_cast<uint8_t> if there's no casting in the function above (with guardian)? it's inconsistent :(

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left the previous static_cast intact. wasn't really sure why it's there to begin with but just wanted to make as little changes as possible to fix the issue with magic requirements. I'm going to open another PR since this PR isn't complete (forgot to refresh item cache). I will make that change in that PR.

player._pSplLvl[j] = newSpellLevel;
NetSendCmdParam2(true, CMD_CHANGE_SPELL_LEVEL, j, newSpellLevel);
}
spell *= 2;
}

if (player._pSplLvl[spellToReduce] > 0) {
player._pSplLvl[spellToReduce]--;
NetSendCmdParam2(true, CMD_CHANGE_SPELL_LEVEL, spellToReduce, player._pSplLvl[spellToReduce] - 1);
uint8_t newSpellLevel = static_cast<uint8_t>(player._pSplLvl[spellToReduce] - 1);
player._pSplLvl[spellToReduce] = newSpellLevel;
NetSendCmdParam2(true, CMD_CHANGE_SPELL_LEVEL, spellToReduce, newSpellLevel);
}
}

Expand Down
Loading