summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/externs.h1
-rw-r--r--src/spells1.c4
-rw-r--r--src/spells2.c38
-rw-r--r--src/types.h8
4 files changed, 44 insertions, 7 deletions
diff --git a/src/externs.h b/src/externs.h
index 3b952681..f727da82 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -1264,6 +1264,7 @@ extern void explosive_rune(void);
extern bool_ do_dec_stat(int stat, int mode);
extern bool_ do_res_stat(int stat, bool_ full);
extern bool_ do_inc_stat(int stat);
+extern void identify_hooks(int i, object_type *o_ptr, identify_mode type);
extern bool_ identify_pack(void);
extern void identify_pack_fully(void);
extern bool_ remove_curse(void);
diff --git a/src/spells1.c b/src/spells1.c
index ccd9f489..e82d708a 100644
--- a/src/spells1.c
+++ b/src/spells1.c
@@ -4151,7 +4151,7 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
o_ptr->ident |= (IDENT_MENTAL);
/* Process the appropriate hooks */
- process_hooks(HOOK_IDENTIFY, "(d,s)", 0 - this_o_idx, "full");
+ identify_hooks(0 - this_o_idx, o_ptr, IDENT_FULL);
/* Squelch ! */
squeltch_grid();
@@ -4164,7 +4164,7 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
object_known(o_ptr);
/* Process the appropriate hooks */
- process_hooks(HOOK_IDENTIFY, "(d,s)", 0 - this_o_idx, "normal");
+ identify_hooks(0 - this_o_idx, o_ptr, IDENT_NORMAL);
/* Squelch ! */
squeltch_grid();
diff --git a/src/spells2.c b/src/spells2.c
index 634c69e0..8df782a4 100644
--- a/src/spells2.c
+++ b/src/spells2.c
@@ -343,6 +343,34 @@ bool_ do_inc_stat(int stat)
}
+/*
+ * Process all identify hooks
+ */
+void identify_hooks(int i, object_type *o_ptr, identify_mode mode)
+{
+ cptr mode_s = NULL;
+
+ switch (mode)
+ {
+ case IDENT_NORMAL:
+ mode_s = "normal";
+ break;
+ case IDENT_FULL:
+ mode_s = "full";
+ break;
+ default:
+ assert(FALSE);
+ }
+
+ /* Process the appropriate hooks */
+ process_hooks(HOOK_IDENTIFY, "(d,s)", i, mode_s);
+
+ {
+ hook_identify_in in = { o_ptr, mode };
+ process_hooks_new(HOOK_IDENTIFY, &in, NULL);
+ }
+}
+
/*
* Identify everything being carried.
@@ -365,7 +393,7 @@ bool_ identify_pack(void)
object_known(o_ptr);
/* Process the appropriate hooks */
- process_hooks(HOOK_IDENTIFY, "(d,s)", i, "normal");
+ identify_hooks(i, o_ptr, IDENT_NORMAL);
}
p_ptr->notice |= (PN_COMBINE | PN_REORDER);
@@ -408,7 +436,7 @@ void identify_pack_fully(void)
make_item_fully_identified(o_ptr);
/* Process the appropriate hooks */
- process_hooks(HOOK_IDENTIFY, "(d,s)", i, "full");
+ identify_hooks(i, o_ptr, IDENT_FULL);
}
p_ptr->update |= (PU_BONUS);
@@ -4294,7 +4322,7 @@ bool_ ident_spell(void)
add_note(note, 'A');
}
/* Process the appropriate hooks */
- process_hooks(HOOK_IDENTIFY, "(d,s)", item, "normal");
+ identify_hooks(item, o_ptr, IDENT_NORMAL);
/* Something happened */
return (TRUE);
@@ -4330,7 +4358,7 @@ bool_ ident_all(void)
add_note(note, 'A');
}
/* Process the appropriate hooks */
- process_hooks(HOOK_IDENTIFY, "(d,s)", -i, "normal");
+ identify_hooks(-i, o_ptr, IDENT_NORMAL);
}
/* Something happened */
@@ -4416,7 +4444,7 @@ bool_ identify_fully(void)
object_out_desc(o_ptr, NULL, FALSE, TRUE);
/* Process the appropriate hooks */
- process_hooks(HOOK_IDENTIFY, "(d,s)", item, "full");
+ identify_hooks(item, o_ptr, IDENT_FULL);
/* Success */
return (TRUE);
diff --git a/src/types.h b/src/types.h
index 82b4890e..3e634beb 100644
--- a/src/types.h
+++ b/src/types.h
@@ -2276,6 +2276,14 @@ struct hook_player_level_in {
int gained_levels;
};
+typedef enum { IDENT_NORMAL, IDENT_FULL } identify_mode;
+
+typedef struct hook_identify_in hook_identify_in;
+struct hook_identify_in {
+ object_type *o_ptr;
+ identify_mode mode;
+};
+
/*
* Structure for the "quests"
*/