KEMBAR78
SAGA2: Fix Wrong spellID crash when using spells from inventory! by hari01584 · Pull Request #4751 · scummvm/scummvm · GitHub
Skip to content

Conversation

@hari01584
Copy link
Contributor

In function skillProtoFromID, magic.cpp the logic to get skill is simple, If the id given is greater than maximum spells then it simply returns game object from address, whereas if not then it will return spell from the spell book! This is based upon the assumption that Spell objects will have IDs > the number of spells, however, it sometimes happens that spell object get Id between this safe range, thus the error of Wrong spellID.

The patch fixes this by fetching the game object from the address and checking if it is a spell, If it is, then it simply returns the address, else checks for range.

int16 manaColor = spellBook[sProto->getSpellID()].getManaType();
int16 manaCost  = spellBook[sProto->getSpellID()].getManaAmt();
if (manaColor >= ksManaIDRed &&  manaColor <= ksManaIDViolet &&  manaCost > 0) // A spell
return sProto;

@sev-
Copy link
Member

sev- commented Mar 1, 2023

Thank you!

@sev- sev- merged commit 72234ec into scummvm:master Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants