diff options
author | Bardur Arantsson <bardur@scientician.net> | 2014-12-21 14:46:44 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2014-12-23 12:07:55 +0100 |
commit | e4e6bc690bb319a2fb1ddca60a1e9fb7b5f89a81 (patch) | |
tree | 62713e5ac9900dab6e5f2c337f9da4e5fdd4a682 /src | |
parent | c1a907e0bf6acc94e77f5af50cd8099977a9ab30 (diff) |
Update HOOK_CALC_HP to new-style hook
Diffstat (limited to 'src')
-rw-r--r-- | src/q_one.cc | 16 | ||||
-rw-r--r-- | src/types.h | 10 | ||||
-rw-r--r-- | src/xtra1.cc | 8 |
3 files changed, 24 insertions, 10 deletions
diff --git a/src/q_one.cc b/src/q_one.cc index a1f37f76..f7994c8a 100644 --- a/src/q_one.cc +++ b/src/q_one.cc @@ -151,19 +151,19 @@ static bool_ quest_one_wield_hook(void *, void *in_, void *) return FALSE; } -static bool_ quest_one_hp_hook(const char *fmt) +static bool_ quest_one_hp_hook(void *, void *in_, void *out_) { + struct hook_calculate_hp_in *in = static_cast<struct hook_calculate_hp_in *>(in_); + struct hook_calculate_hp_out *out = static_cast<struct hook_calculate_hp_out *>(out_); + if (cquest.status == QUEST_STATUS_FAILED_DONE) { - s32b mhp; - int i; - - mhp = get_next_arg(fmt); + s32b mhp = in->mhp; - for (i = 0; i < p_ptr->lives + 1; i++) + for (int i = 0; i < p_ptr->lives + 1; i++) mhp = (mhp * 2) / 3; - process_hooks_return[0].num = mhp; + out->mhp = mhp; return (TRUE); } return (FALSE); @@ -349,7 +349,7 @@ bool_ quest_one_init_hook(int q_idx) add_hook_new(HOOK_MOVE, quest_one_move_hook, "one_move", NULL); } add_hook_new(HOOK_CHAR_DUMP, quest_one_dump_hook, "one_dump", NULL); - add_hook (HOOK_CALC_HP, quest_one_hp_hook, "one_hp"); + add_hook_new(HOOK_CALC_HP, quest_one_hp_hook, "one_hp", NULL); add_hook (HOOK_DIE, quest_one_die_hook, "one_die"); return (FALSE); } diff --git a/src/types.h b/src/types.h index 32615672..de38baca 100644 --- a/src/types.h +++ b/src/types.h @@ -2239,6 +2239,16 @@ struct hook_monster_ai_out { s32b x; }; +typedef struct hook_calculate_hp_in hook_calculate_hp_in; +struct hook_calculate_hp_in { + s32b mhp; +}; + +typedef struct hook_calculate_hp_out hook_calculate_hp_out; +struct hook_calculate_hp_out { + s32b mhp; +}; + typedef struct hook_chat_in hook_chat_in; struct hook_chat_in { s32b m_idx; diff --git a/src/xtra1.cc b/src/xtra1.cc index 043386ee..e125025e 100644 --- a/src/xtra1.cc +++ b/src/xtra1.cc @@ -1910,9 +1910,13 @@ void calc_hitpoints(void) } /* Hp mods? */ - if (process_hooks_ret(HOOK_CALC_HP, "d", "(d)", mhp)) { - mhp = process_hooks_return[0].num; + struct hook_calculate_hp_in in = { mhp }; + struct hook_calculate_hp_out out = { 0 }; + if (process_hooks_new(HOOK_CALC_HP, &in, &out)) + { + mhp = out.mhp; + } } /* Never less than 1 */ |