Clean up some spell-related code

Add two helper functions and use those outside of spell.c,
instead of iterating through all the spells.
This commit is contained in:
Pasi Kallinen
2022-02-20 21:12:23 +02:00
parent 041a07468a
commit 038ae7f984
5 changed files with 42 additions and 44 deletions

View File

@@ -1761,15 +1761,8 @@ jump(int magic) /* 0=Physical, otherwise skill level */
coord cc;
/* attempt "jumping" spell if hero has no innate jumping ability */
if (!magic && !Jumping) {
int sp_no;
for (sp_no = 0; sp_no < MAXSPELL; ++sp_no)
if (g.spl_book[sp_no].sp_id == NO_SPELL)
break;
else if (g.spl_book[sp_no].sp_id == SPE_JUMPING)
return spelleffects(sp_no, FALSE);
}
if (!magic && !Jumping && known_spell(SPE_JUMPING))
return spelleffects(spell_idx(SPE_JUMPING), FALSE);
if (!magic && (nolimbs(g.youmonst.data) || slithy(g.youmonst.data))) {
/* normally (nolimbs || slithy) implies !Jumping,