diff options
author | Bardur Arantsson <bardur@scientician.net> | 2014-12-18 22:46:07 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2014-12-23 12:07:54 +0100 |
commit | dd1e7a5ac938eb75ccbf20ea84954d63511f4611 (patch) | |
tree | e2fde4afc776357d8ac0b8a45844c83fad15993a | |
parent | abd9033aa9c55ffbc8140d1fbfa28fb585844f47 (diff) |
Update HOOK_DROP to new-style hook
-rw-r--r-- | src/cmd3.cc | 3 | ||||
-rw-r--r-- | src/q_one.cc | 20 | ||||
-rw-r--r-- | src/q_poison.cc | 15 | ||||
-rw-r--r-- | src/types.h | 5 |
4 files changed, 23 insertions, 20 deletions
diff --git a/src/cmd3.cc b/src/cmd3.cc index b4d9376e..5bb70054 100644 --- a/src/cmd3.cc +++ b/src/cmd3.cc @@ -525,7 +525,8 @@ void do_cmd_drop(void) object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp); /* Can we drop */ - if (process_hooks(HOOK_DROP, "(d)", item)) return; + struct hook_drop_in in = { item }; + if (process_hooks_new(HOOK_DROP, &in, NULL)) return; /* Hack -- Cannot remove cursed items */ if (cursed_p(o_ptr)) diff --git a/src/q_one.cc b/src/q_one.cc index cdd0baff..4f794b07 100644 --- a/src/q_one.cc +++ b/src/q_one.cc @@ -69,13 +69,11 @@ static bool_ quest_one_move_hook(const char *fmt) return FALSE; } -static bool_ quest_one_drop_hook(const char *fmt) +static bool_ quest_one_drop_hook(void *, void *in_, void *) { - s32b o_idx; - object_type *o_ptr; - - o_idx = get_next_arg(fmt); - o_ptr = &p_ptr->inventory[o_idx]; + struct hook_drop_in *in = static_cast<struct hook_drop_in *>(in_); + s32b o_idx = in->o_idx; + object_type *o_ptr = &p_ptr->inventory[o_idx]; if (cquest.status != QUEST_STATUS_TAKEN) return FALSE; @@ -351,11 +349,11 @@ bool_ quest_one_init_hook(int q_idx) { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { - add_hook(HOOK_LEVEL_END_GEN, quest_one_gen_hook, "one_gen"); - add_hook(HOOK_MONSTER_DEATH, quest_one_death_hook, "one_death"); - add_hook(HOOK_DROP, quest_one_drop_hook, "one_drop"); - add_hook(HOOK_WIELD, quest_one_wield_hook, "one_wield"); - add_hook(HOOK_IDENTIFY, quest_one_identify_hook, "one_id"); + add_hook (HOOK_LEVEL_END_GEN, quest_one_gen_hook, "one_gen"); + add_hook (HOOK_MONSTER_DEATH, quest_one_death_hook, "one_death"); + add_hook_new(HOOK_DROP, quest_one_drop_hook, "one_drop", NULL); + add_hook (HOOK_WIELD, quest_one_wield_hook, "one_wield"); + add_hook (HOOK_IDENTIFY, quest_one_identify_hook, "one_id"); } if (cquest.status == QUEST_STATUS_UNTAKEN) { diff --git a/src/q_poison.cc b/src/q_poison.cc index aa03eeab..400f8dde 100644 --- a/src/q_poison.cc +++ b/src/q_poison.cc @@ -171,13 +171,12 @@ static bool_ quest_poison_quest_hook(const char *fmt) return FALSE; } -static bool_ quest_poison_drop_hook(const char *fmt) +static bool_ quest_poison_drop_hook(void *, void *in_, void *) { - s32b mcnt = 0, i, x, y, o_idx; - object_type *o_ptr; - - o_idx = get_next_arg(fmt); - o_ptr = &p_ptr->inventory[o_idx]; + struct hook_drop_in *in = static_cast<struct hook_drop_in *>(in_); + s32b mcnt = 0, i, x, y; + s32b o_idx = in->o_idx; + object_type *o_ptr = &p_ptr->inventory[o_idx]; if (cquest.status != QUEST_STATUS_TAKEN) return FALSE; if (p_ptr->wilderness_y != wild_locs[cquest.data[0]][0]) return FALSE; @@ -212,7 +211,7 @@ static bool_ quest_poison_drop_hook(const char *fmt) cquest.status = QUEST_STATUS_COMPLETED; - del_hook(HOOK_DROP, quest_poison_drop_hook); + del_hook_new(HOOK_DROP, quest_poison_drop_hook); process_hooks_restart = TRUE; return FALSE; @@ -237,7 +236,7 @@ bool_ quest_poison_init_hook(int q_idx) if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { - add_hook (HOOK_DROP, quest_poison_drop_hook, "poison_drop"); + add_hook_new(HOOK_DROP, quest_poison_drop_hook, "poison_drop", NULL); add_hook_new(HOOK_WILD_GEN, quest_poison_gen_hook, "poison_gen", NULL); add_hook (HOOK_QUEST_FINISH, quest_poison_finish_hook, "poison_finish"); } diff --git a/src/types.h b/src/types.h index 218a4c60..c090477f 100644 --- a/src/types.h +++ b/src/types.h @@ -2237,6 +2237,11 @@ struct hook_chardump_in { FILE *file; }; +typedef struct hook_drop_in hook_drop_in; +struct hook_drop_in { + int o_idx; +}; + typedef struct hook_eat_in hook_eat_in; struct hook_eat_in { object_type *o_ptr; |