summaryrefslogtreecommitdiff
path: root/src/q_poison.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2017-05-02 19:20:57 +0200
committerBardur Arantsson <bardur@scientician.net>2017-05-02 19:20:57 +0200
commitfdb532aec5234db77a9111d219f8a870d660c4fc (patch)
treea997c53b956dfdadc09b22967c0afe9d348fd2c2 /src/q_poison.cc
parent6a35e3de332df186eab39c3b67506882409a3ca2 (diff)
Change away from bool_ for hooks
Diffstat (limited to 'src/q_poison.cc')
-rw-r--r--src/q_poison.cc136
1 files changed, 101 insertions, 35 deletions
diff --git a/src/q_poison.cc b/src/q_poison.cc
index c1a637e9..a0d9e025 100644
--- a/src/q_poison.cc
+++ b/src/q_poison.cc
@@ -45,15 +45,27 @@ static bool_ create_molds_hook(int r_idx)
else return FALSE;
}
-static bool_ quest_poison_gen_hook(void *, void *, void *)
+static bool quest_poison_gen_hook(void *, void *, void *)
{
int cy = 1, cx = 1, x, y, tries = 10000, r_idx;
bool_ (*old_get_mon_num_hook)(int r_idx);
- if (cquest.status != QUEST_STATUS_TAKEN) return FALSE;
- if (p_ptr->wilderness_y != wild_locs[cquest.data[0]][0]) return FALSE;
- if (p_ptr->wilderness_x != wild_locs[cquest.data[0]][1]) return FALSE;
- if (p_ptr->wild_mode) return FALSE;
+ if (cquest.status != QUEST_STATUS_TAKEN)
+ {
+ return false;
+ }
+ if (p_ptr->wilderness_y != wild_locs[cquest.data[0]][0])
+ {
+ return false;
+ }
+ if (p_ptr->wilderness_x != wild_locs[cquest.data[0]][1])
+ {
+ return false;
+ }
+ if (p_ptr->wild_mode)
+ {
+ return false;
+ }
/* Find a good position */
while (tries)
@@ -63,7 +75,10 @@ static bool_ quest_poison_gen_hook(void *, void *, void *)
cx = randint(cur_wid - 34) + 32;
/* Is it a good spot ? */
- if (cave_empty_bold(cy, cx)) break;
+ if (cave_empty_bold(cy, cx))
+ {
+ break;
+ }
/* One less try */
tries--;
@@ -82,15 +97,28 @@ static bool_ quest_poison_gen_hook(void *, void *, void *)
/* Pick a monster, using the level calculation */
for (x = cx - 25; x <= cx + 25; x++)
+ {
for (y = cy - 25; y <= cy + 25; y++)
{
- if (!in_bounds(y, x)) continue;
+ if (!in_bounds(y, x))
+ {
+ continue;
+ }
- if (distance(cy, cx, y, x) > 25) continue;
+ if (distance(cy, cx, y, x) > 25)
+ {
+ continue;
+ }
- if (magik(80) && ((cave[y][x].feat == FEAT_DEEP_WATER) || (cave[y][x].feat == FEAT_SHAL_WATER))) cave_set_feat(y, x, FEAT_TAINTED_WATER);
+ if (magik(80) && ((cave[y][x].feat == FEAT_DEEP_WATER) || (cave[y][x].feat == FEAT_SHAL_WATER)))
+ {
+ cave_set_feat(y, x, FEAT_TAINTED_WATER);
+ }
- if (distance(cy, cx, y, x) > 10) continue;
+ if (distance(cy, cx, y, x) > 10)
+ {
+ continue;
+ }
if (magik(60))
{
@@ -113,6 +141,7 @@ static bool_ quest_poison_gen_hook(void *, void *, void *)
}
}
}
+ }
/* Reset restriction */
get_mon_num_hook = old_get_mon_num_hook;
@@ -120,16 +149,19 @@ static bool_ quest_poison_gen_hook(void *, void *, void *)
/* Prepare allocation table */
get_mon_num_prep();
- return FALSE;
+ return false;
}
-static bool_ quest_poison_finish_hook(void *, void *in_, void *)
+static bool quest_poison_finish_hook(void *, void *in_, void *)
{
struct hook_quest_finish_in *in = static_cast<struct hook_quest_finish_in *>(in_);
s32b q_idx = in->q_idx;
object_type forge, *q_ptr;
- if (q_idx != QUEST_POISON) return FALSE;
+ if (q_idx != QUEST_POISON)
+ {
+ return false;
+ }
c_put_str(TERM_YELLOW, "The water is clean again! Thank you so much.", 8, 0);
c_put_str(TERM_YELLOW, "The beautiful Mallorns are safe. Take this as a proof of our gratitude.", 9, 0);
@@ -151,10 +183,10 @@ static bool_ quest_poison_finish_hook(void *, void *in_, void *)
del_hook_new(HOOK_QUEST_FINISH, quest_poison_finish_hook);
process_hooks_restart = TRUE;
- return TRUE;
+ return true;
}
-static bool_ quest_poison_dump_hook(void *, void *in_, void *)
+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;
@@ -163,16 +195,19 @@ static bool_ quest_poison_dump_hook(void *, void *in_, void *)
{
fprintf(f, "\n You saved the beautiful Mallorns of Lothlorien.");
}
- return (FALSE);
+ return false;
}
-static bool_ quest_poison_quest_hook(void *, void *in_, void *)
+static bool quest_poison_quest_hook(void *, void *in_, void *)
{
struct hook_init_quest_in *in = static_cast<struct hook_init_quest_in *>(in_);
s32b q_idx = in->q_idx;
object_type forge, *q_ptr;
- if (q_idx != QUEST_POISON) return FALSE;
+ if (q_idx != QUEST_POISON)
+ {
+ return false;
+ }
q_ptr = &forge;
object_prep(q_ptr, lookup_kind(TV_POTION2, SV_POTION2_CURE_WATER));
@@ -187,23 +222,41 @@ static bool_ quest_poison_quest_hook(void *, void *in_, void *)
del_hook_new(HOOK_INIT_QUEST, quest_poison_quest_hook);
process_hooks_restart = TRUE;
- return FALSE;
+ return false;
}
-static bool_ quest_poison_drop_hook(void *, void *in_, void *)
+static bool quest_poison_drop_hook(void *, void *in_, void *)
{
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;
- if (p_ptr->wilderness_x != wild_locs[cquest.data[0]][1]) return FALSE;
- if (p_ptr->wild_mode) return FALSE;
+ if (cquest.status != QUEST_STATUS_TAKEN)
+ {
+ return false;
+ }
+ if (p_ptr->wilderness_y != wild_locs[cquest.data[0]][0])
+ {
+ return false;
+ }
+ if (p_ptr->wilderness_x != wild_locs[cquest.data[0]][1])
+ {
+ return false;
+ }
+ if (p_ptr->wild_mode)
+ {
+ return false;
+ }
- if (o_ptr->tval != TV_POTION2) return FALSE;
- if (o_ptr->sval != SV_POTION2_CURE_WATER) return FALSE;
+ if (o_ptr->tval != TV_POTION2)
+ {
+ return false;
+ }
+ if (o_ptr->sval != SV_POTION2_CURE_WATER)
+ {
+ return false;
+ }
for (i = m_max - 1; i >= 1; i--)
{
@@ -211,20 +264,34 @@ static bool_ quest_poison_drop_hook(void *, void *in_, void *)
monster_type *m_ptr = &m_list[i];
/* Ignore "dead" monsters */
- if (!m_ptr->r_idx) continue;
+ if (!m_ptr->r_idx)
+ {
+ continue;
+ }
- if (m_ptr->status <= MSTATUS_NEUTRAL) mcnt++;
+ if (m_ptr->status <= MSTATUS_NEUTRAL)
+ {
+ mcnt++;
+ }
}
if (mcnt < 10)
{
for (x = 1; x < cur_wid - 1; x++)
+ {
for (y = 1; y < cur_hgt - 1; y++)
{
- if (!in_bounds(y, x)) continue;
+ if (!in_bounds(y, x))
+ {
+ continue;
+ }
- if (cave[y][x].feat == FEAT_TAINTED_WATER) cave_set_feat(y, x, FEAT_SHAL_WATER);
+ if (cave[y][x].feat == FEAT_TAINTED_WATER)
+ {
+ cave_set_feat(y, x, FEAT_SHAL_WATER);
+ }
}
+ }
cmsg_print(TERM_YELLOW, "Well done! The water seems to be clean now.");
@@ -233,17 +300,17 @@ static bool_ quest_poison_drop_hook(void *, void *in_, void *)
del_hook_new(HOOK_DROP, quest_poison_drop_hook);
process_hooks_restart = TRUE;
- return FALSE;
+ return false;
}
else
{
msg_print("There are too many monsters left to cure the water.");
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-bool_ quest_poison_init_hook()
+void quest_poison_init_hook()
{
/* Get a place to place the poison */
if (!cquest.data[1])
@@ -264,5 +331,4 @@ bool_ quest_poison_init_hook()
add_hook_new(HOOK_INIT_QUEST, quest_poison_quest_hook, "poison_iquest", NULL);
}
add_hook_new(HOOK_CHAR_DUMP, quest_poison_dump_hook, "poison_dump", NULL);
- return (FALSE);
}