diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-06-30 08:51:51 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-06-30 20:40:26 +0200 |
commit | 763a1c383895f5f04d025ba6ebf79aee9425df70 (patch) | |
tree | baaed2501a0a9815ee95261d856661244128c682 /src/cmd6.c | |
parent | f7e87bc98111f97ca489e1f13999058a7df8171e (diff) |
Change spell_type to a semi-ADT
Diffstat (limited to 'src/cmd6.c')
-rw-r--r-- | src/cmd6.c | 40 |
1 files changed, 6 insertions, 34 deletions
@@ -12,6 +12,7 @@ #include "angband.h" +#include "spell_type.h" /* * Forward declare @@ -3666,9 +3667,8 @@ static void activate_stick(s16b s, bool_ *obvious, bool_ *use_charge) assert(obvious != NULL); assert(use_charge != NULL); - assert(spell->effect_func != NULL); - ret = spell->effect_func(-1); + ret = spell_type_produce_effect(spell, -1); switch (ret) { @@ -5029,35 +5029,6 @@ void do_cmd_activate(void) msg_print("Oops. That object cannot be activated."); } - -static void get_activation_desc(char *buf, int spl) -{ - spell_type *spell = spell_at(spl); - char turns[32]; - - dice_print(&spell->activation_duration, turns); - - assert(spell->description != NULL); - assert(spell->description->s != NULL); - - sprintf(buf, "%s every %s turns", - spell->description->s, - turns); -} - -static int get_activation_timeout(int spl) -{ - spell_type *spell = spell_at(spl); - return dice_roll(&spell->activation_duration); -} - -static void activate_activation(long s, int item) -{ - spell_type *spell = spell_at(s); - assert(spell->effect_func != NULL); - spell->effect_func(item); -} - const char *activation_aux(object_type * o_ptr, bool_ doit, int item) { static char buf[256]; @@ -5100,14 +5071,15 @@ const char *activation_aux(object_type * o_ptr, bool_ doit, int item) /* Negative means a unified spell index */ if (spell < 0) { + struct spell_type *spell_ptr = spell_at(-spell); if (doit) { - activate_activation(-spell, item); - o_ptr->timeout = get_activation_timeout(-spell); + spell_type_produce_effect(spell_ptr, item); + o_ptr->timeout = spell_type_activation_roll_timeout(spell_ptr); } else { - get_activation_desc(buf, -spell); + spell_type_activation_description(spell_ptr, buf); return buf; } } |