summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2014-12-18 22:28:59 +0100
committerBardur Arantsson <bardur@scientician.net>2014-12-23 12:07:54 +0100
commit666ce02020925a67386429b451d23071521d6da8 (patch)
tree9369a82a16042186f77210d47d7173780ce5d8e5 /src
parent132e99238140b1628a2f0175a6edc85358fe8101 (diff)
Update HOOK_CHAR_DUMP to new-style hook
Diffstat (limited to 'src')
-rw-r--r--src/files.cc4
-rw-r--r--src/q_betwen.cc13
-rw-r--r--src/q_god.cc11
-rw-r--r--src/q_hobbit.cc9
-rw-r--r--src/q_invas.cc13
-rw-r--r--src/q_main.cc13
-rw-r--r--src/q_narsil.cc9
-rw-r--r--src/q_nazgul.cc11
-rw-r--r--src/q_one.cc15
-rw-r--r--src/q_poison.cc9
-rw-r--r--src/q_rand.cc37
-rw-r--r--src/q_ultrag.cc15
-rw-r--r--src/types.h5
13 files changed, 99 insertions, 65 deletions
diff --git a/src/files.cc b/src/files.cc
index 04066bbd..67e531ac 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -2712,8 +2712,8 @@ errr file_character(cptr name, bool_ full)
fprintf(fff, "\n You have defeated %ld enemies.", (long int) Total);
}
- hook_file = fff;
- process_hooks(HOOK_CHAR_DUMP, "()");
+ struct hook_chardump_in in = { fff };
+ process_hooks_new(HOOK_CHAR_DUMP, &in, NULL);
/* Date */
{
diff --git a/src/q_betwen.cc b/src/q_betwen.cc
index 6f4072ca..f8d0ff7a 100644
--- a/src/q_betwen.cc
+++ b/src/q_betwen.cc
@@ -156,12 +156,15 @@ static bool_ quest_between_death_hook(const char *fmt)
return FALSE;
}
-static bool_ quest_between_dump_hook(const char *fmt)
+static bool_ quest_between_dump_hook(void *, void *in_, void *)
{
+ struct hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
+
if (cquest.status >= QUEST_STATUS_COMPLETED)
{
- fprintf(hook_file, "\n You established a permanent void jumpgates liaison between Minas Anor and Gondolin,");
- fprintf(hook_file, "\n thus allowing the last alliance to exist.");
+ fprintf(f, "\n You established a permanent void jumpgates liaison between Minas Anor and Gondolin,");
+ fprintf(f, "\n thus allowing the last alliance to exist.");
}
return (FALSE);
}
@@ -190,7 +193,7 @@ bool_ quest_between_init_hook(int q)
add_hook(HOOK_QUEST_FINISH, quest_between_finish_hook, "between_finish");
add_hook(HOOK_MONSTER_DEATH, quest_between_death_hook, "between_death");
}
- add_hook(HOOK_CHAR_DUMP, quest_between_dump_hook, "between_dump");
- add_hook(HOOK_INIT_QUEST, quest_between_forbid_hook, "between_forbid");
+ add_hook_new(HOOK_CHAR_DUMP, quest_between_dump_hook, "between_dump", NULL);
+ add_hook (HOOK_INIT_QUEST, quest_between_forbid_hook, "between_forbid");
return (FALSE);
}
diff --git a/src/q_god.cc b/src/q_god.cc
index 64456ee2..47bfb0dc 100644
--- a/src/q_god.cc
+++ b/src/q_god.cc
@@ -1037,8 +1037,11 @@ static bool_ quest_god_get_hook(void *, void *in_, void *)
return FALSE;
}
-static bool_ quest_god_char_dump_hook(const char *fmt)
+static bool_ quest_god_char_dump_hook(void *, void *in_, void *)
{
+ struct hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
+
if (cquest_quests_given > 0)
{
int relics = cquest_relics_found;
@@ -1064,9 +1067,7 @@ static bool_ quest_god_char_dump_hook(const char *fmt)
}
}
- fprintf(hook_file, "\n You found %s of the relic pieces%s.",
- relics_text,
- append_text);
+ fprintf(f, "\n You found %s of the relic pieces%s.", relics_text, append_text);
}
return FALSE;
@@ -1181,7 +1182,7 @@ bool_ quest_god_init_hook(int q)
add_hook (HOOK_GEN_LEVEL_BEGIN, quest_god_gen_level_begin_hook, "q_god_gen_level_begin");
add_hook (HOOK_STAIR, quest_god_stair_hook, "q_god_hook_stair");
add_hook_new(HOOK_GET, quest_god_get_hook, "q_god_get", NULL);
- add_hook (HOOK_CHAR_DUMP, quest_god_char_dump_hook, "q_god_char_dump");
+ add_hook_new(HOOK_CHAR_DUMP, quest_god_char_dump_hook, "q_god_char_dump", NULL);
add_hook (HOOK_PLAYER_LEVEL, quest_god_player_level_hook, "q_god_player_level");
}
diff --git a/src/q_hobbit.cc b/src/q_hobbit.cc
index 143e7599..c52b8653 100644
--- a/src/q_hobbit.cc
+++ b/src/q_hobbit.cc
@@ -160,11 +160,14 @@ static bool_ quest_hobbit_chat_hook(void *, void *in_, void *)
return TRUE;
}
-static bool_ quest_hobbit_dump_hook(const char *fmt)
+static bool_ quest_hobbit_dump_hook(void *, void *in_, void *)
{
+ struct hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
+
if (cquest.status >= QUEST_STATUS_COMPLETED)
{
- fprintf(hook_file, "\n You saved a young hobbit from an horrible fate.");
+ fprintf(f, "\n You saved a young hobbit from an horrible fate.");
}
return (FALSE);
}
@@ -196,6 +199,6 @@ bool_ quest_hobbit_init_hook(int q_idx)
add_hook_new(HOOK_WILD_GEN, quest_hobbit_town_gen_hook, "hobbit_town_gen", NULL);
add_hook_new(HOOK_CHAT, quest_hobbit_chat_hook, "hobbit_chat", NULL);
}
- add_hook(HOOK_CHAR_DUMP, quest_hobbit_dump_hook, "hobbit_dump");
+ add_hook_new(HOOK_CHAR_DUMP, quest_hobbit_dump_hook, "hobbit_dump", NULL);
return (FALSE);
}
diff --git a/src/q_invas.cc b/src/q_invas.cc
index 10cb5dc6..489ecbad 100644
--- a/src/q_invas.cc
+++ b/src/q_invas.cc
@@ -111,15 +111,18 @@ static bool_ quest_invasion_turn_hook(const char *fmt)
return (FALSE);
}
-static bool_ quest_invasion_dump_hook(const char *fmt)
+static bool_ quest_invasion_dump_hook(void *, void *in_, void *)
{
+ struct hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
+
if (cquest.status == QUEST_STATUS_FAILED)
{
- fprintf(hook_file, "\n You abandoned Gondolin when it most needed you, thus causing its destruction.");
+ fprintf(f, "\n You abandoned Gondolin when it most needed you, thus causing its destruction.");
}
if ((cquest.status == QUEST_STATUS_FINISHED) || (cquest.status == QUEST_STATUS_REWARDED) || (cquest.status == QUEST_STATUS_COMPLETED))
{
- fprintf(hook_file, "\n You saved Gondolin from destruction.");
+ fprintf(f, "\n You saved Gondolin from destruction.");
}
return (FALSE);
}
@@ -191,8 +194,8 @@ static bool_ quest_invasion_stair_hook(const char *fmt)
bool_ quest_invasion_init_hook(int q_idx)
{
- add_hook(HOOK_END_TURN, quest_invasion_turn_hook, "invasion_turn");
- add_hook(HOOK_CHAR_DUMP, quest_invasion_dump_hook, "invasion_dump");
+ add_hook (HOOK_END_TURN, quest_invasion_turn_hook, "invasion_turn");
+ add_hook_new(HOOK_CHAR_DUMP, quest_invasion_dump_hook, "invasion_dump", NULL);
if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED))
{
add_hook(HOOK_MONSTER_AI, quest_invasion_ai_hook, "invasion_ai");
diff --git a/src/q_main.cc b/src/q_main.cc
index 3e4e569f..17651da2 100644
--- a/src/q_main.cc
+++ b/src/q_main.cc
@@ -82,14 +82,17 @@ static bool_ quest_morgoth_hook(const char *fmt)
return (FALSE);
}
-static bool_ quest_morgoth_dump_hook(const char *fmt)
+static bool_ quest_morgoth_dump_hook(void *, void *in_, void *)
{
+ struct hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
+
if (quest[QUEST_MORGOTH].status >= QUEST_STATUS_COMPLETED)
{
if (quest[QUEST_ONE].status == QUEST_STATUS_FINISHED)
- fprintf(hook_file, "\n You saved Arda and became a famed %s.", sp_ptr->winner);
+ fprintf(f, "\n You saved Arda and became a famed %s.", sp_ptr->winner);
else
- fprintf(hook_file, "\n You became a new force of darkness and enslaved all free people.");
+ fprintf(f, "\n You became a new force of darkness and enslaved all free people.");
}
return (FALSE);
}
@@ -100,8 +103,8 @@ bool_ quest_morgoth_init_hook(int q_idx)
{
add_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death");
}
- add_hook(HOOK_CHAR_DUMP, quest_morgoth_dump_hook, "morgoth_dump");
- add_hook(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster");
+ add_hook_new(HOOK_CHAR_DUMP, quest_morgoth_dump_hook, "morgoth_dump", NULL);
+ add_hook (HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster");
return (FALSE);
}
diff --git a/src/q_narsil.cc b/src/q_narsil.cc
index 521e344b..119d3ada 100644
--- a/src/q_narsil.cc
+++ b/src/q_narsil.cc
@@ -59,11 +59,14 @@ static bool_ quest_narsil_move_hook(const char *fmt)
return TRUE;
}
-static bool_ quest_narsil_dump_hook(const char *fmt)
+static bool_ quest_narsil_dump_hook(void *, void *in_, void *)
{
+ struct hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
+
if (cquest.status >= QUEST_STATUS_COMPLETED)
{
- fprintf(hook_file, "\n The sword that was broken is now reforged.");
+ fprintf(f, "\n The sword that was broken is now reforged.");
}
return (FALSE);
}
@@ -108,6 +111,6 @@ bool_ quest_narsil_init_hook(int q_idx)
add_hook(HOOK_MOVE, quest_narsil_move_hook, "narsil_move");
}
if (cquest.status == QUEST_STATUS_UNTAKEN) add_hook(HOOK_IDENTIFY, quest_narsil_identify_hook, "narsil_id");
- add_hook(HOOK_CHAR_DUMP, quest_narsil_dump_hook, "narsil_dump");
+ add_hook_new(HOOK_CHAR_DUMP, quest_narsil_dump_hook, "narsil_dump", NULL);
return (FALSE);
}
diff --git a/src/q_nazgul.cc b/src/q_nazgul.cc
index ebc7f3b6..ccea9560 100644
--- a/src/q_nazgul.cc
+++ b/src/q_nazgul.cc
@@ -66,11 +66,14 @@ static bool_ quest_nazgul_finish_hook(const char *fmt)
return TRUE;
}
-static bool_ quest_nazgul_dump_hook(const char *fmt)
+static bool_ quest_nazgul_dump_hook(void *, void *in_, void *)
{
+ struct hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
+
if (cquest.status >= QUEST_STATUS_COMPLETED)
{
- fprintf(hook_file, "\n You saved Bree from a dreadful Nazgul.");
+ fprintf(f, "\n You saved Bree from a dreadful Nazgul.");
}
return (FALSE);
}
@@ -116,7 +119,7 @@ bool_ quest_nazgul_init_hook(int q_idx)
add_hook_new(HOOK_WILD_GEN, quest_nazgul_gen_hook, "nazgul_gen", NULL);
add_hook (HOOK_QUEST_FINISH, quest_nazgul_finish_hook, "nazgul_finish");
}
- add_hook(HOOK_CHAR_DUMP, quest_nazgul_dump_hook, "nazgul_dump");
- add_hook(HOOK_INIT_QUEST, quest_nazgul_forbid_hook, "nazgul_forbid");
+ add_hook_new(HOOK_CHAR_DUMP, quest_nazgul_dump_hook, "nazgul_dump", NULL);
+ add_hook (HOOK_INIT_QUEST, quest_nazgul_forbid_hook, "nazgul_forbid");
return (FALSE);
}
diff --git a/src/q_one.cc b/src/q_one.cc
index de80afad..cdd0baff 100644
--- a/src/q_one.cc
+++ b/src/q_one.cc
@@ -300,15 +300,18 @@ static bool_ quest_one_death_hook(const char *fmt)
return (FALSE);
}
-static bool_ quest_one_dump_hook(const char *fmt)
+static bool_ quest_one_dump_hook(void *, void *in_, void *)
{
+ struct hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
+
if (cquest.status == QUEST_STATUS_FINISHED)
{
- fprintf(hook_file, "\n You destroyed the One Ring, thus weakening Sauron.");
+ fprintf(f, "\n You destroyed the One Ring, thus weakening Sauron.");
}
if (cquest.status == QUEST_STATUS_FAILED_DONE)
{
- fprintf(hook_file, "\n You fell under the evil influence of the One Ring and decided to wear it.");
+ fprintf(f, "\n You fell under the evil influence of the One Ring and decided to wear it.");
}
return (FALSE);
}
@@ -358,8 +361,8 @@ bool_ quest_one_init_hook(int q_idx)
{
add_hook(HOOK_MOVE, quest_one_move_hook, "one_move");
}
- add_hook(HOOK_CHAR_DUMP, quest_one_dump_hook, "one_dump");
- add_hook(HOOK_CALC_HP, quest_one_hp_hook, "one_hp");
- add_hook(HOOK_DIE, quest_one_die_hook, "one_die");
+ 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 (HOOK_DIE, quest_one_die_hook, "one_die");
return (FALSE);
}
diff --git a/src/q_poison.cc b/src/q_poison.cc
index d65b8802..aa03eeab 100644
--- a/src/q_poison.cc
+++ b/src/q_poison.cc
@@ -135,11 +135,14 @@ static bool_ quest_poison_finish_hook(const char *fmt)
return TRUE;
}
-static bool_ quest_poison_dump_hook(const char *fmt)
+static bool_ quest_poison_dump_hook(void *, void *in_, void *)
{
+ hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
+
if (cquest.status >= QUEST_STATUS_COMPLETED)
{
- fprintf(hook_file, "\n You saved the beautiful Mallorns of Lothlorien.");
+ fprintf(f, "\n You saved the beautiful Mallorns of Lothlorien.");
}
return (FALSE);
}
@@ -242,6 +245,6 @@ bool_ quest_poison_init_hook(int q_idx)
{
add_hook(HOOK_INIT_QUEST, quest_poison_quest_hook, "poison_iquest");
}
- add_hook(HOOK_CHAR_DUMP, quest_poison_dump_hook, "poison_dump");
+ add_hook_new(HOOK_CHAR_DUMP, quest_poison_dump_hook, "poison_dump", NULL);
return (FALSE);
}
diff --git a/src/q_rand.cc b/src/q_rand.cc
index 76f129e2..71ff645a 100644
--- a/src/q_rand.cc
+++ b/src/q_rand.cc
@@ -541,10 +541,11 @@ static bool_ quest_random_gen_hook(const char *fmt)
return (TRUE);
}
-static bool_ quest_random_dump_hook(const char *fmt)
+static bool_ quest_random_dump_hook(void *, void *in_, void *)
{
- static const char *number[] =
- { "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
+ static const char *number[] = { "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
+ struct hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
int i, valid = 0, lscnt = 0, pcnt = 0;
for (i = 0; i < MAX_RANDOM_QUEST; i++)
@@ -565,22 +566,22 @@ static bool_ quest_random_dump_hook(const char *fmt)
if (valid)
{
if (pcnt > 10)
- fprintf(hook_file, "\n You have completed %d princess quests.", pcnt);
+ fprintf(f, "\n You have completed %d princess quests.", pcnt);
else if (pcnt > 1)
- fprintf(hook_file, "\n You have completed %s princess quests.", number[pcnt-2]);
+ fprintf(f, "\n You have completed %s princess quests.", number[pcnt-2]);
else if (pcnt == 1)
- fprintf(hook_file, "\n You have completed one princess quest.");
+ fprintf(f, "\n You have completed one princess quest.");
else
- fprintf(hook_file, "\n You haven't completed a single princess quest.");
+ fprintf(f, "\n You haven't completed a single princess quest.");
if (lscnt > 10)
- fprintf(hook_file, "\n You have completed %d lost sword quests.", lscnt);
+ fprintf(f, "\n You have completed %d lost sword quests.", lscnt);
else if (lscnt > 1)
- fprintf(hook_file, "\n You have completed %s lost sword quests.", number[lscnt-2]);
+ fprintf(f, "\n You have completed %s lost sword quests.", number[lscnt-2]);
else if (lscnt == 1)
- fprintf(hook_file, "\n You have completed one lost sword quest.");
+ fprintf(f, "\n You have completed one lost sword quest.");
else
- fprintf(hook_file, "\n You haven't completed a single lost sword quest.");
+ fprintf(f, "\n You haven't completed a single lost sword quest.");
}
return (FALSE);
@@ -617,12 +618,12 @@ bool_ quest_random_describe(FILE *fff)
bool_ quest_random_init_hook(int q_idx)
{
- add_hook(HOOK_MONSTER_DEATH, quest_random_death_hook, "rand_death");
- add_hook(HOOK_NEW_LEVEL, quest_random_turn_hook, "rand_new_lvl");
- add_hook(HOOK_LEVEL_REGEN, quest_random_turn_hook, "rand_regen_lvl");
- add_hook(HOOK_LEVEL_END_GEN, quest_random_gen_hero_hook, "rand_gen_hero");
- add_hook(HOOK_BUILD_ROOM1, quest_random_gen_hook, "rand_gen");
- add_hook(HOOK_FEELING, quest_random_feeling_hook, "rand_feel");
- add_hook(HOOK_CHAR_DUMP, quest_random_dump_hook, "rand_dump");
+ add_hook (HOOK_MONSTER_DEATH, quest_random_death_hook, "rand_death");
+ add_hook (HOOK_NEW_LEVEL, quest_random_turn_hook, "rand_new_lvl");
+ add_hook (HOOK_LEVEL_REGEN, quest_random_turn_hook, "rand_regen_lvl");
+ add_hook (HOOK_LEVEL_END_GEN, quest_random_gen_hero_hook, "rand_gen_hero");
+ add_hook (HOOK_BUILD_ROOM1, quest_random_gen_hook, "rand_gen");
+ add_hook (HOOK_FEELING, quest_random_feeling_hook, "rand_feel");
+ add_hook_new(HOOK_CHAR_DUMP, quest_random_dump_hook, "rand_dump", NULL);
return (FALSE);
}
diff --git a/src/q_ultrag.cc b/src/q_ultrag.cc
index 504fb775..cddacda4 100644
--- a/src/q_ultrag.cc
+++ b/src/q_ultrag.cc
@@ -234,23 +234,26 @@ static bool_ quest_ultra_good_death_hook(const char *fmt)
return (FALSE);
}
-static bool_ quest_ultra_good_dump_hook(const char *fmt)
+static bool_ quest_ultra_good_dump_hook(void *, void *in_, void *)
{
+ struct hook_chardump_in *in = static_cast<struct hook_chardump_in *>(in_);
+ FILE *f = in->file;
+
if (quest[QUEST_ULTRA_GOOD].status >= QUEST_STATUS_TAKEN)
{
/* Ultra winner ! */
if (total_winner == WINNER_ULTRA)
{
- fprintf(hook_file, "\n You destroyed Melkor forever and have been elevated to the status of Vala by Eru Iluvatar.");
- fprintf(hook_file, "\n Arda will forever be free.");
+ fprintf(f, "\n You destroyed Melkor forever and have been elevated to the status of Vala by Eru Iluvatar.");
+ fprintf(f, "\n Arda will forever be free.");
}
else
{
/* Tried and failed */
if (death)
{
- fprintf(hook_file, "\n You tried to destroy Melkor forever, but died in the attempt.");
- fprintf(hook_file, "\n Arda will be quiet, but not free from evil.");
+ fprintf(f, "\n You tried to destroy Melkor forever, but died in the attempt.");
+ fprintf(f, "\n Arda will be quiet, but not free from evil.");
}
}
}
@@ -270,6 +273,6 @@ bool_ quest_ultra_good_init_hook(int q)
{
add_hook(HOOK_MOVE, quest_ultra_good_move_hook, "ultrag_move");
}
- add_hook(HOOK_CHAR_DUMP, quest_ultra_good_dump_hook, "ultrag_dump");
+ add_hook_new(HOOK_CHAR_DUMP, quest_ultra_good_dump_hook, "ultrag_dump", NULL);
return (FALSE);
}
diff --git a/src/types.h b/src/types.h
index 9efd9d13..218a4c60 100644
--- a/src/types.h
+++ b/src/types.h
@@ -2232,6 +2232,11 @@ struct hook_wild_gen_in {
bool_ small;
};
+typedef struct hook_chardump_in hook_chardump_in;
+struct hook_chardump_in {
+ FILE *file;
+};
+
typedef struct hook_eat_in hook_eat_in;
struct hook_eat_in {
object_type *o_ptr;