diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd5.cc | 19 | ||||
-rw-r--r-- | src/cmd5.hpp | 2 | ||||
-rw-r--r-- | src/spells4.cc | 2 |
3 files changed, 12 insertions, 11 deletions
diff --git a/src/cmd5.cc b/src/cmd5.cc index f57c6d62..aea592ab 100644 --- a/src/cmd5.cc +++ b/src/cmd5.cc @@ -1829,7 +1829,8 @@ int use_symbiotic_power(int r_idx, bool_ great, bool_ only_number, bool_ no_cost * Find a spell in any books/objects */ static int hack_force_spell = -1; -static object_type *hack_force_spell_obj = NULL; +static s32b hack_force_spell_pval = -1; + bool_ get_item_hook_find_spell(int *item) { int i, spell; @@ -1863,7 +1864,7 @@ bool_ get_item_hook_find_spell(int *item) { *item = i; hack_force_spell = spell; - hack_force_spell_obj = o_ptr; + hack_force_spell_pval = o_ptr->pval; return TRUE; } } @@ -1872,7 +1873,7 @@ bool_ get_item_hook_find_spell(int *item) { *item = i; hack_force_spell = spell; - hack_force_spell_obj = o_ptr; + hack_force_spell_pval = o_ptr->pval; return TRUE; } } @@ -1882,10 +1883,10 @@ bool_ get_item_hook_find_spell(int *item) /* * Is the spell castable? */ -bool_ is_ok_spell(s32b spell_idx, object_type *o_ptr) +bool_ is_ok_spell(s32b spell_idx, s32b pval) { spell_type *spell = spell_at(spell_idx); - assert(o_ptr != NULL); + // Calculate availability based on caster's skill level. s32b level; bool_ na; @@ -1896,7 +1897,7 @@ bool_ is_ok_spell(s32b spell_idx, object_type *o_ptr) } // Are we permitted to cast based on item pval? Only music // spells have non-zero minimum PVAL. - if (o_ptr->pval < spell_type_minimum_pval(spell)) + if (pval < spell_type_minimum_pval(spell)) { return FALSE; } @@ -1925,7 +1926,7 @@ s32b get_school_spell(cptr do_what, s16b force_book) u32b f1, f2, f3, f4, f5, esp; hack_force_spell = -1; - hack_force_spell_obj = NULL; + hack_force_spell_pval = -1; /* Ok do we need to ask for a book ? */ if (!force_book) @@ -2047,7 +2048,7 @@ s32b get_school_spell(cptr do_what, s16b force_book) spell = spell_x(sval, pval, i); /* Do we need to do some pre test */ - ok = is_ok_spell(spell, o_ptr); + ok = is_ok_spell(spell, o_ptr->pval); /* Require "okay" spells */ if (!ok) @@ -2068,7 +2069,7 @@ s32b get_school_spell(cptr do_what, s16b force_book) bool_ ok; /* Require "okay" spells */ - ok = is_ok_spell(hack_force_spell, hack_force_spell_obj); + ok = is_ok_spell(hack_force_spell, hack_force_spell_pval); if (ok) { flag = TRUE; diff --git a/src/cmd5.hpp b/src/cmd5.hpp index 497b9b86..39cfeef0 100644 --- a/src/cmd5.hpp +++ b/src/cmd5.hpp @@ -9,7 +9,7 @@ extern void fetch(int dir, int wgt, bool_ require_los); extern void do_poly_self(void); extern cptr symbiote_name(bool_ capitalize); extern int use_symbiotic_power(int r_idx, bool_ great, bool_ only_number, bool_ no_cost); -extern bool_ is_ok_spell(s32b spell_idx, object_type *o_ptr); +extern bool_ is_ok_spell(s32b spell_idx, s32b pval); extern s32b get_school_spell(cptr do_what, s16b force_book); extern void do_cmd_copy_spell(void); extern void cast_school_spell(void); diff --git a/src/spells4.cc b/src/spells4.cc index 45eb8c15..4a952b18 100644 --- a/src/spells4.cc +++ b/src/spells4.cc @@ -463,7 +463,7 @@ int print_book(s16b sval, s32b pval, object_type *obj) bool_ is_ok; char label[8]; - is_ok = is_ok_spell(spell_idx, obj); + is_ok = is_ok_spell(spell_idx, obj->pval); if (is_ok) { color = (get_mana(spell_idx) > get_power(spell_idx)) ? TERM_ORANGE : TERM_L_GREEN; |