diff options
author | Bardur Arantsson <bardur@scientician.net> | 2017-05-02 19:20:57 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2017-05-02 19:20:57 +0200 |
commit | fdb532aec5234db77a9111d219f8a870d660c4fc (patch) | |
tree | a997c53b956dfdadc09b22967c0afe9d348fd2c2 /src | |
parent | 6a35e3de332df186eab39c3b67506882409a3ca2 (diff) |
Change away from bool_ for hooks
Diffstat (limited to 'src')
62 files changed, 1002 insertions, 611 deletions
diff --git a/src/cmd7.cc b/src/cmd7.cc index 312c657e..ec13c908 100644 --- a/src/cmd7.cc +++ b/src/cmd7.cc @@ -844,7 +844,7 @@ void do_cmd_mimic_lore() p_ptr->update |= (PU_BONUS); } -static bool_ mimic_forbid_travel(void *, void *, void *) +static bool mimic_forbid_travel(void *, void *, void *) { u32b value = p_ptr->mimic_extra >> 16; u32b att = p_ptr->mimic_extra & 0xFFFF; @@ -852,10 +852,10 @@ static bool_ mimic_forbid_travel(void *, void *, void *) if(value > 0 && (att & CLASS_ARMS || att & CLASS_LEGS)) { msg_print("You had best not travel with your extra limbs."); - return TRUE; + return true; } - return FALSE; + return false; } /* diff --git a/src/help.cc b/src/help.cc index 43d4873f..08956f70 100644 --- a/src/help.cc +++ b/src/help.cc @@ -558,7 +558,7 @@ static triggered_help_type triggered_help[TRIGGERED_HELP_MAX] = } }; -static bool_ triggered_help_hook(void *data, void *in, void *out) +static bool triggered_help_hook(void *data, void *in, void *out) { triggered_help_type *triggered_help = (triggered_help_type *) data; /* Not triggered before and trigger now? */ @@ -576,13 +576,13 @@ static bool_ triggered_help_hook(void *data, void *in, void *out) } } /* Don't stop processing */ - return FALSE; + return false; } -static bool_ hook_game_start(void *data, void *in, void *out) +static bool hook_game_start(void *data, void *in, void *out) { game_started = TRUE; - return FALSE; + return false; } static void setup_triggered_help_hook(int i) diff --git a/src/hooks.cc b/src/hooks.cc index 4fcc39d3..bd2ea905 100644 --- a/src/hooks.cc +++ b/src/hooks.cc @@ -81,7 +81,7 @@ void del_hook_new(int h_idx, hook_func_t hook_func) } } -bool_ process_hooks_new(int h_idx, void *in, void *out) +bool process_hooks_new(int h_idx, void *in, void *out) { auto const &hooks = hooks_instance()[h_idx]; @@ -94,7 +94,7 @@ bool_ process_hooks_new(int h_idx, void *in, void *out) returns TRUE */ if (hook_data.invoke(in, out)) { - return TRUE; + return true; } /* Should we restart processing at the beginning? */ @@ -109,5 +109,5 @@ bool_ process_hooks_new(int h_idx, void *in, void *out) } } - return FALSE; + return false; } diff --git a/src/hooks.hpp b/src/hooks.hpp index 78896def..7cf4285b 100644 --- a/src/hooks.hpp +++ b/src/hooks.hpp @@ -2,9 +2,9 @@ #include "h-basic.h" -typedef bool_ (*hook_func_t)(void *, void *, void *); +typedef bool (*hook_func_t)(void *, void *, void *); void add_hook_new(int h_idx, hook_func_t hook_func, cptr name, void *data); void del_hook_new(int h_idx, hook_func_t hook_func); extern int process_hooks_restart; -bool_ process_hooks_new(int h_idx, void *in, void *out); +bool process_hooks_new(int h_idx, void *in, void *out); diff --git a/src/joke.cc b/src/joke.cc index eefee404..07149b3f 100644 --- a/src/joke.cc +++ b/src/joke.cc @@ -22,7 +22,7 @@ static void gen_joke_place_monster(int r_idx) } } -bool_ gen_joke_monsters(void *data, void *in, void *out) +bool gen_joke_monsters(void *data, void *in, void *out) { if (options->joke_monsters) { diff --git a/src/joke.hpp b/src/joke.hpp index 46795e7c..2721636e 100644 --- a/src/joke.hpp +++ b/src/joke.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ gen_joke_monsters(void *data, void *in, void *out); +bool gen_joke_monsters(void *data, void *in, void *out); diff --git a/src/modules.cc b/src/modules.cc index 4d60c960..aba71731 100644 --- a/src/modules.cc +++ b/src/modules.cc @@ -557,7 +557,7 @@ exit: screen_load(); } -static bool_ auto_stat_gain_hook(void *data, void *in, void *out) +static bool auto_stat_gain_hook(void *data, void *in, void *out) { while (p_ptr->last_rewarded_level * 5 <= p_ptr->lev) { @@ -571,10 +571,10 @@ static bool_ auto_stat_gain_hook(void *data, void *in, void *out) p_ptr->last_rewarded_level += 1; } - return FALSE; + return false; } -static bool_ drunk_takes_wine(void *data, void *in_, void *out) +static bool drunk_takes_wine(void *, void *in_, void *) { hook_give_in *in = (hook_give_in *) in_; monster_type *m_ptr = &m_list[in->m_idx]; @@ -604,7 +604,7 @@ static bool_ drunk_takes_wine(void *data, void *in_, void *out) } } -static bool_ hobbit_food(void *data, void *in_, void *out) +static bool hobbit_food(void *, void *in_, void *) { hook_give_in *in = (hook_give_in *) in_; monster_type *m_ptr = &m_list[in->m_idx]; @@ -617,15 +617,15 @@ static bool_ hobbit_food(void *data, void *in_, void *out) inc_stack_size_ex(in->item, -1, OPTIMIZE, NO_DESCRIBE); - return TRUE; + return true; } else { - return FALSE; + return false; } } -static bool_ smeagol_ring(void *data, void *in_, void *out) +static bool smeagol_ring(void *data, void *in_, void *out) { hook_give_in *in = (hook_give_in *) in_; monster_type *m_ptr = &m_list[in->m_idx]; @@ -638,15 +638,15 @@ static bool_ smeagol_ring(void *data, void *in_, void *out) inc_stack_size_ex(in->item, -1, OPTIMIZE, NO_DESCRIBE); - return TRUE; + return true; } else { - return FALSE; + return false; } } -static bool_ longbottom_leaf(void *data, void *in_, void *out_) +static bool longbottom_leaf(void *, void *in_, void *) { hook_eat_in *in = (hook_eat_in *) in_; @@ -655,13 +655,13 @@ static bool_ longbottom_leaf(void *data, void *in_, void *out_) { msg_print("What a stress reliever!"); heal_insanity(1000); - return TRUE; + return true; } - return FALSE; + return false; } -static bool_ food_vessel(void *data, void *in_, void *out) +static bool food_vessel(void *, void *in_, void *ut) { hook_eat_in *in = (hook_eat_in *) in_; @@ -675,16 +675,16 @@ static bool_ food_vessel(void *data, void *in_, void *out) forge.ident |= IDENT_MENTAL | IDENT_KNOWN; inven_carry(&forge, FALSE); - return TRUE; + return true; } - return FALSE; + return false; } /* * Player must have appropriate keys to enter Erebor. */ -static bool_ erebor_stair(void *data, void *in_, void *out_) +static bool erebor_stair(void *, void *in_, void *out_) { hook_stair_in *in = (hook_stair_in *) in_; hook_stair_out *out = (hook_stair_out *) out_; @@ -719,13 +719,13 @@ static bool_ erebor_stair(void *data, void *in_, void *out_) } } - return FALSE; + return false; } /* * Orthanc requires a key. */ -static bool_ orthanc_stair(void *data, void *in_, void *out_) +static bool orthanc_stair(void *, void *in_, void *out_) { hook_stair_in *in = (hook_stair_in *) in_; hook_stair_out *out = (hook_stair_out *) out_; @@ -757,13 +757,13 @@ static bool_ orthanc_stair(void *data, void *in_, void *out_) } } - return FALSE; + return false; } /* * Movement from Theme */ -static bool_ theme_push_past(void *data, void *in_, void *out_) +static bool theme_push_past(void *data, void *in_, void *out_) { hook_move_in *p = (hook_move_in *) in_; cave_type *c_ptr = &cave[p->y][p->x]; @@ -796,19 +796,19 @@ static bool_ theme_push_past(void *data, void *in_, void *out_) msg_print(format("%s is in your way!", buf)); energy_use = 0; - return TRUE; + return true; } } } - return FALSE; + return false; } /* * Check if monster race is in list. The list is terminated * with a -1. */ -static bool_ race_in_list(int r_idx, int race_idxs[]) +static bool race_in_list(int r_idx, int race_idxs[]) { int i; @@ -816,11 +816,11 @@ static bool_ race_in_list(int r_idx, int race_idxs[]) { if (r_idx == race_idxs[i]) { - return TRUE; + return true; } } - return FALSE; + return false; } /* @@ -1155,11 +1155,9 @@ s16b *theme_race_status(int r_idx) return NULL; } -static bool_ theme_level_end_gen(void *data, void *in, void *out) +static bool theme_level_end_gen(void *, void *, void *) { - int i = 0; - - for (i = 0; i < m_max; i++) + for (int i = 0; i < m_max; i++) { monster_type *m_ptr = &m_list[i]; int r_idx = m_ptr->r_idx; @@ -1170,10 +1168,10 @@ static bool_ theme_level_end_gen(void *data, void *in, void *out) } } - return FALSE; + return false; } -static bool_ theme_new_monster_end(void *data, void *in_, void *out) +static bool theme_new_monster_end(void *, void *in_, void *) { hook_new_monster_end_in *in = (hook_new_monster_end_in *) in_; s16b *status = theme_race_status(in->m_ptr->r_idx); @@ -1183,7 +1181,7 @@ static bool_ theme_new_monster_end(void *data, void *in_, void *out) in->m_ptr->status = *status; } - return FALSE; + return false; } void init_hooks_module() diff --git a/src/q_betwen.cc b/src/q_betwen.cc index 8deb6667..ca8243b4 100644 --- a/src/q_betwen.cc +++ b/src/q_betwen.cc @@ -19,7 +19,7 @@ #define cquest (quest[QUEST_BETWEEN]) -static bool_ quest_between_move_hook(void *, void *in_, void *) +static bool quest_between_move_hook(void *, void *in_, void *) { struct hook_move_in *in = static_cast<struct hook_move_in *>(in_); s32b y = in->y; @@ -28,7 +28,10 @@ static bool_ quest_between_move_hook(void *, void *in_, void *) c_ptr = &cave[y][x]; - if (cquest.status != QUEST_STATUS_TAKEN) return FALSE; + if (cquest.status != QUEST_STATUS_TAKEN) + { + return false; + } /* The tower of Turgon */ if ((c_ptr->feat == FEAT_SHOP) && (c_ptr->special == 27)) @@ -38,19 +41,28 @@ static bool_ quest_between_move_hook(void *, void *in_, void *) cquest.status = QUEST_STATUS_COMPLETED; - return TRUE; + return true; } /* Only 1 ambush */ - if (cquest.data[0]) return (FALSE); + if (cquest.data[0]) + { + return false; + } if (!p_ptr->wild_mode) { - if (p_ptr->wilderness_y > 19) return (FALSE); + if (p_ptr->wilderness_y > 19) + { + return false; + } } else { - if (p_ptr->py > 19) return (FALSE); + if (p_ptr->py > 19) + { + return false; + } } /* Mark as entered */ @@ -64,16 +76,19 @@ static bool_ quest_between_move_hook(void *, void *in_, void *) cmsg_print(TERM_YELLOW, "Trone steps forth and speaks: 'The secret of the Void Jumpgates"); cmsg_print(TERM_YELLOW, "will not be used by any but the thunderlords!'"); - return FALSE; + return false; } -static bool_ quest_between_gen_hook(void *, void *, void *) +static bool quest_between_gen_hook(void *, void *, void *) { int x, y; int xstart = 2; int ystart = 2; - if (p_ptr->inside_quest != QUEST_BETWEEN) return FALSE; + if (p_ptr->inside_quest != QUEST_BETWEEN) + { + return false; + } /* Start with perm walls */ for (y = 0; y < cur_hgt; y++) @@ -99,16 +114,16 @@ static bool_ quest_between_gen_hook(void *, void *, void *) dungeon_flags |= DF_NO_GENO; - return TRUE; + return true; } -static bool_ quest_between_finish_hook(void *, void *in_, void *) +static bool quest_between_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_BETWEEN) return FALSE; + if (q_idx != QUEST_BETWEEN) return false; c_put_str(TERM_YELLOW, "Ah you finally arrived, I hope your travel wasn't too hard.", 8, 0); c_put_str(TERM_YELLOW, "As a reward you can freely use the Void Jumpgates for quick travel.", 9, 0); @@ -137,14 +152,17 @@ static bool_ quest_between_finish_hook(void *, void *in_, void *) del_hook_new(HOOK_QUEST_FINISH, quest_between_finish_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_between_death_hook(void *, void *, void *) +static bool quest_between_death_hook(void *, void *, void *) { int i, mcnt = 0; - if (p_ptr->inside_quest != QUEST_BETWEEN) return FALSE; + if (p_ptr->inside_quest != QUEST_BETWEEN) + { + return false; + } for (i = m_max - 1; i >= 1; i--) { @@ -163,14 +181,14 @@ static bool_ quest_between_death_hook(void *, void *, void *) cave_set_feat(p_ptr->py, p_ptr->px, FEAT_LESS); cave[p_ptr->py][p_ptr->px].special = 0; - return FALSE; + return false; } - return FALSE; + return false; } -static bool_ quest_between_dump_hook(void *, void *in_, void *) +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; @@ -180,10 +198,10 @@ static bool_ quest_between_dump_hook(void *, void *in_, void *) 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); + return false; } -static bool_ quest_between_forbid_hook(void *, void *in_, void *) +static bool quest_between_forbid_hook(void *, void *in_, void *) { hook_init_quest_in *in = static_cast<struct hook_init_quest_in *>(in_); s32b q_idx = in->q_idx; @@ -193,12 +211,12 @@ static bool_ quest_between_forbid_hook(void *, void *in_, void *) if (p_ptr->lev < 45) { c_put_str(TERM_WHITE, "I fear you are not ready for the next quest, come back later.", 8, 0); - return (TRUE); + return true; } - return (FALSE); + return false; } -bool_ quest_between_init_hook() +void quest_between_init_hook() { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -209,5 +227,4 @@ bool_ quest_between_init_hook() } add_hook_new(HOOK_CHAR_DUMP, quest_between_dump_hook, "between_dump", NULL); add_hook_new(HOOK_INIT_QUEST, quest_between_forbid_hook, "between_forbid", NULL); - return (FALSE); } diff --git a/src/q_betwen.hpp b/src/q_betwen.hpp index 1171d138..54042a24 100644 --- a/src/q_betwen.hpp +++ b/src/q_betwen.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_between_init_hook(); +void quest_between_init_hook(); diff --git a/src/q_bounty.cc b/src/q_bounty.cc index 1bdb1fe6..f0a431de 100644 --- a/src/q_bounty.cc +++ b/src/q_bounty.cc @@ -81,9 +81,9 @@ static bool bounty_item_tester_hook(object_type const *o_ptr) return ((o_ptr->tval == TV_CORPSE) && (o_ptr->pval2 == bounty_quest_monster)); } -bool_ quest_bounty_init_hook() +void quest_bounty_init_hook() { - return FALSE; + // Initialized by building action } bool_ quest_bounty_drop_item() diff --git a/src/q_bounty.hpp b/src/q_bounty.hpp index e4ebe084..fe9742ef 100644 --- a/src/q_bounty.hpp +++ b/src/q_bounty.hpp @@ -4,7 +4,7 @@ #include <string> -bool_ quest_bounty_init_hook(); +void quest_bounty_init_hook(); bool_ quest_bounty_drop_item(); bool_ quest_bounty_get_item(); std::string quest_bounty_describe(); diff --git a/src/q_dragons.cc b/src/q_dragons.cc index 1ed5a97b..9f89089c 100644 --- a/src/q_dragons.cc +++ b/src/q_dragons.cc @@ -19,7 +19,7 @@ #define cquest (quest[QUEST_DRAGONS]) -static bool_ quest_dragons_gen_hook(void *, void *, void *) +static bool quest_dragons_gen_hook(void *, void *, void *) { auto const &f_info = game->edit_data.f_info; @@ -107,7 +107,7 @@ static bool_ quest_dragons_gen_hook(void *, void *, void *) return TRUE; } -static bool_ quest_dragons_death_hook(void *, void *, void *) +static bool quest_dragons_death_hook(void *, void *, void *) { int i, mcnt = 0; @@ -120,9 +120,15 @@ static bool_ quest_dragons_death_hook(void *, void *, 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_ENEMY) mcnt++; + if (m_ptr->status <= MSTATUS_ENEMY) + { + mcnt++; + } } /* Nobody left ? */ @@ -134,17 +140,21 @@ static bool_ quest_dragons_death_hook(void *, void *, void *) process_hooks_restart = TRUE; cmsg_print(TERM_YELLOW, "Gondolin is safer now."); - return (FALSE); + return false; } - return FALSE; + + return false; } -static bool_ quest_dragons_finish_hook(void *, void *in_, void *) +static bool quest_dragons_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; - if (q_idx != QUEST_DRAGONS) return FALSE; + if (q_idx != QUEST_DRAGONS) + { + return false; + } c_put_str(TERM_YELLOW, "Thank you for killing the dragons!", 8, 0); c_put_str(TERM_YELLOW, "You can use the cave as your house as a reward.", 9, 0); @@ -152,10 +162,10 @@ static bool_ quest_dragons_finish_hook(void *, void *in_, void *) /* Continue the plot */ *(quest[q_idx].plot) = QUEST_EOL; - return TRUE; + return true; } -bool_ quest_dragons_init_hook() +void quest_dragons_init_hook() { if ((cquest.status >= QUEST_STATUS_UNTAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -163,5 +173,4 @@ bool_ quest_dragons_init_hook() add_hook_new(HOOK_QUEST_FINISH, quest_dragons_finish_hook, "dragons_finish", NULL); add_hook_new(HOOK_GEN_QUEST, quest_dragons_gen_hook, "dragons_geb", NULL); } - return (FALSE); } diff --git a/src/q_dragons.hpp b/src/q_dragons.hpp index af1bef20..cda41321 100644 --- a/src/q_dragons.hpp +++ b/src/q_dragons.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_dragons_init_hook(); +void quest_dragons_init_hook(); diff --git a/src/q_eol.cc b/src/q_eol.cc index ae1cd96a..815b3107 100644 --- a/src/q_eol.cc +++ b/src/q_eol.cc @@ -25,14 +25,17 @@ GENERATE_MONSTER_LOOKUP_FN(get_eol, "Eol, the Dark Elf") -static bool_ quest_eol_gen_hook(void *, void *, void *) +static bool quest_eol_gen_hook(void *, void *, void *) { int x, y; bool_ done = FALSE; int xsize = 50, ysize = 30, y0, x0; int m_idx = 0; - if (p_ptr->inside_quest != QUEST_EOL) return FALSE; + if (p_ptr->inside_quest != QUEST_EOL) + { + return false; + } x0 = 2 + (xsize / 2); y0 = 2 + (ysize / 2); @@ -102,16 +105,19 @@ static bool_ quest_eol_gen_hook(void *, void *, void *) cave_set_feat(p_ptr->py, p_ptr->px, FEAT_LESS); - return TRUE; + return true; } -static bool_ quest_eol_finish_hook(void *, void *in_, void *) +static bool quest_eol_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_EOL) return FALSE; + if (q_idx != QUEST_EOL) + { + return false; + } c_put_str(TERM_YELLOW, "A tragedy, but the deed needed to be done.", 8, 0); c_put_str(TERM_YELLOW, "Accept my thanks, and that reward.", 9, 0); @@ -134,15 +140,18 @@ static bool_ quest_eol_finish_hook(void *, void *in_, void *) del_hook_new(HOOK_QUEST_FINISH, quest_eol_finish_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_eol_fail_hook(void *, void *in_, void *) +static bool quest_eol_fail_hook(void *, void *in_, void *) { struct hook_quest_fail_in *in = static_cast<struct hook_quest_fail_in *>(in_); s32b q_idx = in->q_idx; - if (q_idx != QUEST_EOL) return FALSE; + if (q_idx != QUEST_EOL) + { + return false; + } c_put_str(TERM_YELLOW, "You fled ! I did not think you would flee...", 8, 0); @@ -152,16 +161,19 @@ static bool_ quest_eol_fail_hook(void *, void *in_, void *) del_hook_new(HOOK_QUEST_FAIL, quest_eol_fail_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_eol_death_hook(void *, void *in_, void *) +static bool quest_eol_death_hook(void *, void *in_, void *) { struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_); s32b m_idx = in->m_idx; s32b r_idx = m_list[m_idx].r_idx; - if (p_ptr->inside_quest != QUEST_EOL) return FALSE; + if (p_ptr->inside_quest != QUEST_EOL) + { + return false; + } if (r_idx == get_eol()) { @@ -171,22 +183,28 @@ static bool_ quest_eol_death_hook(void *, void *in_, void *) del_hook_new(HOOK_MONSTER_DEATH, quest_eol_death_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } - return FALSE; + return false; } -static bool_ quest_eol_stair_hook(void *, void *in_, void *) +static bool quest_eol_stair_hook(void *, void *in_, void *) { auto const &r_info = game->edit_data.r_info; struct hook_stair_in *in = static_cast<struct hook_stair_in *>(in_); auto r_ptr = &r_info[get_eol()]; - if (p_ptr->inside_quest != QUEST_EOL) return FALSE; + if (p_ptr->inside_quest != QUEST_EOL) + { + return false; + } - if (cave[p_ptr->py][p_ptr->px].feat != FEAT_LESS) return TRUE; + if (cave[p_ptr->py][p_ptr->px].feat != FEAT_LESS) + { + return true; + } if (r_ptr->max_num) { @@ -195,21 +213,24 @@ static bool_ quest_eol_stair_hook(void *, void *in_, void *) /* Flush input */ flush(); - if (!get_check("Really abandon the quest?")) return TRUE; + if (!get_check("Really abandon the quest?")) + { + return true; + } cmsg_print(TERM_YELLOW, "You flee away from Eol..."); cquest.status = QUEST_STATUS_FAILED; del_hook_new(HOOK_STAIR, quest_eol_stair_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } } - return FALSE; + return false; } -bool_ quest_eol_init_hook() +void quest_eol_init_hook() { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -219,5 +240,4 @@ bool_ quest_eol_init_hook() add_hook_new(HOOK_QUEST_FAIL, quest_eol_fail_hook, "eol_fail", NULL); add_hook_new(HOOK_QUEST_FINISH, quest_eol_finish_hook, "eol_finish", NULL); } - return (FALSE); } diff --git a/src/q_eol.hpp b/src/q_eol.hpp index 6043b3ba..19af3583 100644 --- a/src/q_eol.hpp +++ b/src/q_eol.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_eol_init_hook(); +void quest_eol_init_hook(); diff --git a/src/q_evil.cc b/src/q_evil.cc index 21d608e7..4636356a 100644 --- a/src/q_evil.cc +++ b/src/q_evil.cc @@ -19,7 +19,7 @@ #define cquest (quest[QUEST_EVIL]) -static bool_ quest_evil_gen_hook(void *, void *, void *) +static bool quest_evil_gen_hook(void *, void *, void *) { auto const &f_info = game->edit_data.f_info; @@ -27,11 +27,16 @@ static bool_ quest_evil_gen_hook(void *, void *, void *) int xstart = 2; int ystart = 2; - if (p_ptr->inside_quest != QUEST_EVIL) return FALSE; + if (p_ptr->inside_quest != QUEST_EVIL) + { + return false; + } /* Just in case we didnt talk the the mayor */ if (cquest.status == QUEST_STATUS_UNTAKEN) + { cquest.status = QUEST_STATUS_TAKEN; + } /* Start with perm walls */ for (y = 0; y < cur_hgt; y++) @@ -70,14 +75,17 @@ static bool_ quest_evil_gen_hook(void *, void *, void *) process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_evil_death_hook(void *, void *, void *) +static bool quest_evil_death_hook(void *, void *, void *) { int i, mcnt = 0; - if (p_ptr->inside_quest != QUEST_EVIL) return FALSE; + if (p_ptr->inside_quest != QUEST_EVIL) + { + return false; + } /* Process the monsters (backwards) */ for (i = m_max - 1; i >= 1; i--) @@ -103,17 +111,20 @@ static bool_ quest_evil_death_hook(void *, void *, void *) process_hooks_restart = TRUE; cmsg_print(TERM_YELLOW, "Khazad-Dum is safer now."); - return (FALSE); + return false; } - return FALSE; + return false; } -static bool_ quest_evil_finish_hook(void *, void *in_, void *) +static bool quest_evil_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; - if (q_idx != QUEST_EVIL) return FALSE; + if (q_idx != QUEST_EVIL) + { + return false; + } c_put_str(TERM_YELLOW, "Thank you for saving us!", 8, 0); c_put_str(TERM_YELLOW, "You can use the cave as your house as a reward.", 9, 0); @@ -121,10 +132,10 @@ static bool_ quest_evil_finish_hook(void *, void *in_, void *) /* End the plot */ *(quest[q_idx].plot) = QUEST_NULL; - return TRUE; + return true; } -bool_ quest_evil_init_hook() +void quest_evil_init_hook() { if ((cquest.status >= QUEST_STATUS_UNTAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -132,5 +143,4 @@ bool_ quest_evil_init_hook() add_hook_new(HOOK_QUEST_FINISH, quest_evil_finish_hook, "evil_finish", NULL); add_hook_new(HOOK_GEN_QUEST, quest_evil_gen_hook, "evil_geb", NULL); } - return (FALSE); } diff --git a/src/q_evil.hpp b/src/q_evil.hpp index 5346afe4..0079e56c 100644 --- a/src/q_evil.hpp +++ b/src/q_evil.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_evil_init_hook(); +void quest_evil_init_hook(); diff --git a/src/q_fireprof.cc b/src/q_fireprof.cc index 9e36ce5c..26bf75af 100644 --- a/src/q_fireprof.cc +++ b/src/q_fireprof.cc @@ -359,7 +359,7 @@ void quest_fireproof_building(bool_ *paid, bool_ *recreate) } } -static bool_ fireproof_get_hook(void *, void *in_, void *) +static bool fireproof_get_hook(void *, void *in_, void *) { struct hook_get_in *in = static_cast<struct hook_get_in *>(in_); object_type *o_ptr = in->o_ptr; @@ -376,17 +376,17 @@ static bool_ fireproof_get_hook(void *, void *in_, void *) cmsg_print(TERM_YELLOW, "Fine! Looks like you've found it."); } - return FALSE; + return false; } -static bool_ fireproof_stair_hook(void *, void *, void *) +static bool fireproof_stair_hook(void *, void *, void *) { /* only ask this if player about to go up stairs of quest and * hasn't retrieved item */ if ((p_ptr->inside_quest != QUEST_FIREPROOF) || (cquest.status == QUEST_STATUS_COMPLETED)) { - return FALSE; + return false; } else { @@ -394,7 +394,7 @@ static bool_ fireproof_stair_hook(void *, void *, void *) if (cave[p_ptr->py][p_ptr->px].feat != FEAT_LESS) { - return FALSE; + return false; } /* flush all pending input */ @@ -408,12 +408,12 @@ static bool_ fireproof_stair_hook(void *, void *, void *) { /* fail the quest */ cquest.status = QUEST_STATUS_FAILED; - return FALSE; + return false; } else { /* if no, they stay in the quest */ - return TRUE; + return true; } } } @@ -458,14 +458,14 @@ std::string quest_fireproof_describe() return w.str(); } -static bool_ fireproof_gen_hook(void *, void *, void *) +static bool fireproof_gen_hook(void *, void *, void *) { fireproof_settings const *settings = fireproof_get_settings(); /* Only if player doing this quest */ if (p_ptr->inside_quest != QUEST_FIREPROOF) { - return FALSE; + return false; } /* Go ahead */ @@ -497,11 +497,11 @@ static bool_ fireproof_gen_hook(void *, void *, void *) drop_near(&forge, -1, y, x); } - return TRUE; + return true; } } -bool_ quest_fireproof_init_hook() +void quest_fireproof_init_hook() { /* Only need hooks if the quest is unfinished. */ if ((cquest.status >= QUEST_STATUS_UNTAKEN) && @@ -511,8 +511,4 @@ bool_ quest_fireproof_init_hook() add_hook_new(HOOK_GET , fireproof_get_hook , "fireproof_get_hook", NULL); add_hook_new(HOOK_STAIR , fireproof_stair_hook, "fireproof_stair_hook", NULL); } - - return FALSE; } - -#undef print_hook diff --git a/src/q_fireprof.hpp b/src/q_fireprof.hpp index 39b319e5..361d45ad 100644 --- a/src/q_fireprof.hpp +++ b/src/q_fireprof.hpp @@ -5,5 +5,5 @@ #include <string> void quest_fireproof_building(bool_ *paid, bool_ *recreate); -bool_ quest_fireproof_init_hook(); +void quest_fireproof_init_hook(); std::string quest_fireproof_describe(); diff --git a/src/q_god.cc b/src/q_god.cc index 14052fe4..68296f36 100644 --- a/src/q_god.cc +++ b/src/q_god.cc @@ -901,13 +901,13 @@ static void quest_god_set_god_dungeon_attributes_mandos() d_info[DUNGEON_GOD].rules[0].mflags = RF_UNDEAD | RF_EVIL; } -static bool_ quest_god_level_end_gen_hook(void *, void *, void *) +static bool quest_god_level_end_gen_hook(void *, void *, void *) { /* Check for dungeon */ if ((dungeon_type != DUNGEON_GOD) || (cquest.status == QUEST_STATUS_UNTAKEN)) { - return FALSE; + return false; } /* if the relic has been created at this point, then it was @@ -955,17 +955,17 @@ static bool_ quest_god_level_end_gen_hook(void *, void *, void *) } } - return FALSE; + return false; } -static bool_ quest_god_player_level_hook(void *, void *in_, void *) +static bool quest_god_player_level_hook(void *, void *in_, void *) { struct hook_player_level_in *in = static_cast<struct hook_player_level_in *>(in_); s32b gained = in->gained_levels; if (gained <= 0) { - return FALSE; + return false; } /* check player is worshipping a god, not already on a god quest. */ @@ -984,7 +984,7 @@ static bool_ quest_god_player_level_hook(void *, void *in_, void *) { cquest_dun_minplev = p_ptr->lev; } - return FALSE; + return false; } else { @@ -1017,10 +1017,10 @@ static bool_ quest_god_player_level_hook(void *, void *in_, void *) cquest_dun_maxdepth = cquest_dun_mindepth + 4; } - return FALSE; + return false; } -static bool_ quest_god_get_hook(void *, void *in_, void *) +static bool quest_god_get_hook(void *, void *in_, void *) { auto &s_info = game->s_info; @@ -1071,13 +1071,13 @@ static bool_ quest_god_get_hook(void *, void *in_, void *) /* Prevent further processing of 'take' action; we've destroyed the item. */ - return TRUE; + return true; } - return FALSE; + return false; } -static bool_ quest_god_char_dump_hook(void *, void *in_, void *) +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; @@ -1110,7 +1110,7 @@ static bool_ quest_god_char_dump_hook(void *, void *in_, void *) fprintf(f, "\n You found %s of the relic pieces%s.", relics_text, append_text); } - return FALSE; + return false; } static void set_god_dungeon_attributes() @@ -1181,26 +1181,26 @@ static void quest_god_dungeon_setup(int d_idx) set_god_dungeon_attributes(); } -static bool_ quest_god_enter_dungeon_hook(void *, void *in_, void *) +static bool quest_god_enter_dungeon_hook(void *, void *in_, void *) { struct hook_enter_dungeon_in *in = static_cast<struct hook_enter_dungeon_in *>(in_); quest_god_dungeon_setup(in->d_idx); - return FALSE; + return false; } -static bool_ quest_god_gen_level_begin_hook(void *, void *, void *) +static bool quest_god_gen_level_begin_hook(void *, void *, void *) { quest_god_dungeon_setup(dungeon_type); - return FALSE; + return false; } -static bool_ quest_god_stair_hook(void *, void *, void *) +static bool quest_god_stair_hook(void *, void *, void *) { quest_god_dungeon_setup(dungeon_type); - return FALSE; + return false; } -static bool_ quest_god_birth_objects_hook(void *, void *, void *) +static bool quest_god_birth_objects_hook(void *, void *, void *) { cquest_quests_given = 0; cquest_relics_found = 0; @@ -1210,10 +1210,10 @@ static bool_ quest_god_birth_objects_hook(void *, void *, void *) cquest_relic_gen_tries = 0; cquest_relic_generated = FALSE; - return FALSE; + return false; } -bool_ quest_god_init_hook() +void quest_god_init_hook() { /* Only need hooks if the quest is unfinished. */ if ((cquest.status >= QUEST_STATUS_UNTAKEN) && @@ -1231,6 +1231,4 @@ bool_ quest_god_init_hook() /* Need this to re-initialize at birth; the quest data is * zeroed which isn't quite right. */ add_hook_new(HOOK_BIRTH_OBJECTS, quest_god_birth_objects_hook, "q_god_birth_objects", NULL); - - return FALSE; } diff --git a/src/q_god.hpp b/src/q_god.hpp index 9feef832..839d4eaa 100644 --- a/src/q_god.hpp +++ b/src/q_god.hpp @@ -5,4 +5,4 @@ #include <string> std::string quest_god_describe(); -bool_ quest_god_init_hook(); +void quest_god_init_hook(); diff --git a/src/q_haunted.cc b/src/q_haunted.cc index f3725830..f460ee80 100644 --- a/src/q_haunted.cc +++ b/src/q_haunted.cc @@ -19,7 +19,7 @@ #define cquest (quest[QUEST_HAUNTED]) -static bool_ quest_haunted_gen_hook(void *, void *, void *) +static bool quest_haunted_gen_hook(void *, void *, void *) { auto const &f_info = game->edit_data.f_info; @@ -27,7 +27,10 @@ static bool_ quest_haunted_gen_hook(void *, void *, void *) int xstart = 2; int ystart = 2; - if (p_ptr->inside_quest != QUEST_HAUNTED) return FALSE; + if (p_ptr->inside_quest != QUEST_HAUNTED) + { + return false; + } /* Just in case we didnt talk the the mayor */ if (cquest.status == QUEST_STATUS_UNTAKEN) @@ -87,14 +90,17 @@ static bool_ quest_haunted_gen_hook(void *, void *, void *) process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_haunted_death_hook(void *, void *, void *) +static bool quest_haunted_death_hook(void *, void *, void *) { int i, mcnt = 0; - if (p_ptr->inside_quest != QUEST_HAUNTED) return FALSE; + if (p_ptr->inside_quest != QUEST_HAUNTED) + { + return false; + } /* Process the monsters (backwards) */ for (i = m_max - 1; i >= 1; i--) @@ -103,9 +109,15 @@ static bool_ quest_haunted_death_hook(void *, void *, 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_ENEMY) mcnt++; + if (m_ptr->status <= MSTATUS_ENEMY) + { + mcnt++; + } } /* Nobody left ? */ @@ -118,17 +130,21 @@ static bool_ quest_haunted_death_hook(void *, void *, void *) process_hooks_restart = TRUE; cmsg_print(TERM_YELLOW, "Minas Anor is safer now."); - return (FALSE); + return false; } - return FALSE; + + return false; } -static bool_ quest_haunted_finish_hook(void *, void *in_, void *) +static bool quest_haunted_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; - if (q_idx != QUEST_HAUNTED) return FALSE; + if (q_idx != QUEST_HAUNTED) + { + return false; + } c_put_str(TERM_YELLOW, "Thank you for saving us!", 8, 0); c_put_str(TERM_YELLOW, "You can use the building as your house as a reward.", 9, 0); @@ -136,10 +152,10 @@ static bool_ quest_haunted_finish_hook(void *, void *in_, void *) /* Continue the plot */ *(quest[q_idx].plot) = QUEST_BETWEEN; - return TRUE; + return true; } -bool_ quest_haunted_init_hook() +void quest_haunted_init_hook() { if ((cquest.status >= QUEST_STATUS_UNTAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -147,5 +163,4 @@ bool_ quest_haunted_init_hook() add_hook_new(HOOK_QUEST_FINISH, quest_haunted_finish_hook, "haunted_finish", NULL); add_hook_new(HOOK_GEN_QUEST, quest_haunted_gen_hook, "haunted_geb", NULL); } - return (FALSE); } diff --git a/src/q_haunted.hpp b/src/q_haunted.hpp index 9df36239..3965f0c3 100644 --- a/src/q_haunted.hpp +++ b/src/q_haunted.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_haunted_init_hook(); +void quest_haunted_init_hook(); diff --git a/src/q_hobbit.cc b/src/q_hobbit.cc index 04cd3064..011269eb 100644 --- a/src/q_hobbit.cc +++ b/src/q_hobbit.cc @@ -25,13 +25,16 @@ GENERATE_MONSTER_LOOKUP_FN(get_melinda_proudfoot, "Melinda Proudfoot") GENERATE_MONSTER_LOOKUP_FN(get_merton_proudfoot, "Merton Proudfoot, the lost hobbit") -static bool_ quest_hobbit_town_gen_hook(void *, void *in_, void *) +static bool quest_hobbit_town_gen_hook(void *, void *in_, void *) { struct hook_wild_gen_in *in = static_cast<struct hook_wild_gen_in *>(in_); int x = 1, y = 1, tries = 10000; bool_ small = in->small; - if ((turn < (cquest.data[1] + (DAY * 10L))) || (cquest.status > QUEST_STATUS_COMPLETED) || (small) || (p_ptr->town_num != 1)) return (FALSE); + if ((turn < (cquest.data[1] + (DAY * 10L))) || (cquest.status > QUEST_STATUS_COMPLETED) || (small) || (p_ptr->town_num != 1)) + { + return false; + } /* Find a good position */ while (tries) @@ -55,14 +58,17 @@ static bool_ quest_hobbit_town_gen_hook(void *, void *in_, void *) place_monster_one(y, x, r_idx, 0, FALSE, MSTATUS_ENEMY); m_allow_special[r_idx] = FALSE; - return FALSE; + return false; } -static bool_ quest_hobbit_gen_hook(void *, void *, void *) +static bool quest_hobbit_gen_hook(void *, void *, void *) { int x = 1, y = 1, tries = 10000; - if ((cquest.status != QUEST_STATUS_TAKEN) || (dun_level != cquest.data[0]) || (dungeon_type != DUNGEON_MAZE)) return FALSE; + if ((cquest.status != QUEST_STATUS_TAKEN) || (dun_level != cquest.data[0]) || (dungeon_type != DUNGEON_MAZE)) + { + return false; + } /* Find a good position */ while (tries) @@ -84,10 +90,10 @@ static bool_ quest_hobbit_gen_hook(void *, void *, void *) place_monster_one(y, x, r_idx, 0, FALSE, MSTATUS_FRIEND); m_allow_special[r_idx] = FALSE; - return FALSE; + return false; } -static bool_ quest_hobbit_give_hook(void *, void *in_, void *) +static bool quest_hobbit_give_hook(void *, void *in_, void *) { struct hook_give_in *in = static_cast<struct hook_give_in *>(in_); object_type *o_ptr; @@ -98,9 +104,9 @@ static bool_ quest_hobbit_give_hook(void *, void *in_, void *) o_ptr = &p_ptr->inventory[item]; m_ptr = &m_list[m_idx]; - if (m_ptr->r_idx != get_merton_proudfoot()) return (FALSE); + if (m_ptr->r_idx != get_merton_proudfoot()) return false; - if ((o_ptr->tval != TV_SCROLL) || (o_ptr->sval != SV_SCROLL_WORD_OF_RECALL)) return (FALSE); + if ((o_ptr->tval != TV_SCROLL) || (o_ptr->sval != SV_SCROLL_WORD_OF_RECALL)) return false; msg_print("'Oh, thank you, noble one!'"); msg_print("Merton Proudfoot reads the scroll and is recalled to the safety of his home."); @@ -114,27 +120,27 @@ static bool_ quest_hobbit_give_hook(void *, void *in_, void *) del_hook_new(HOOK_GIVE, quest_hobbit_give_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_hobbit_speak_hook(void *, void *in_, void *) +static bool quest_hobbit_speak_hook(void *, void *in_, void *) { struct hook_mon_speak_in *in = static_cast<struct hook_mon_speak_in *>(in_); s32b m_idx = in->m_idx; if (m_list[m_idx].r_idx != get_melinda_proudfoot()) { - return (FALSE); + return false; } if (cquest.status < QUEST_STATUS_COMPLETED) { msg_format("%^s begs for your help.", in->m_name); } - return (TRUE); + return true; } -static bool_ quest_hobbit_chat_hook(void *, void *in_, void *) +static bool quest_hobbit_chat_hook(void *, void *in_, void *) { struct hook_chat_in *in = static_cast<struct hook_chat_in *>(in_); s32b m_idx = in->m_idx; @@ -142,7 +148,10 @@ static bool_ quest_hobbit_chat_hook(void *, void *in_, void *) m_ptr = &m_list[m_idx]; - if (m_ptr->r_idx != get_melinda_proudfoot()) return (FALSE); + if (m_ptr->r_idx != get_melinda_proudfoot()) + { + return false; + } if (cquest.status < QUEST_STATUS_COMPLETED) { @@ -176,17 +185,17 @@ static bool_ quest_hobbit_chat_hook(void *, void *in_, void *) process_hooks_restart = TRUE; delete_monster_idx(m_idx); - return TRUE; + return true; } else { msg_print("Thanks again."); } - return TRUE; + return true; } -static bool_ quest_hobbit_dump_hook(void *, void *in_, void *) +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; @@ -195,10 +204,10 @@ static bool_ quest_hobbit_dump_hook(void *, void *in_, void *) { fprintf(f, "\n You saved a young hobbit from an horrible fate."); } - return (FALSE); + return false; } -bool_ quest_hobbit_init_hook() +void quest_hobbit_init_hook() { /* Get a level to place the hobbit */ if (!cquest.data[0]) @@ -226,5 +235,4 @@ bool_ quest_hobbit_init_hook() add_hook_new(HOOK_CHAT, quest_hobbit_chat_hook, "hobbit_chat", NULL); } add_hook_new(HOOK_CHAR_DUMP, quest_hobbit_dump_hook, "hobbit_dump", NULL); - return (FALSE); } diff --git a/src/q_hobbit.hpp b/src/q_hobbit.hpp index 283ba0dd..c3482fd9 100644 --- a/src/q_hobbit.hpp +++ b/src/q_hobbit.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_hobbit_init_hook(); +void quest_hobbit_init_hook(); diff --git a/src/q_invas.cc b/src/q_invas.cc index f1cf43da..60ca0b65 100644 --- a/src/q_invas.cc +++ b/src/q_invas.cc @@ -19,13 +19,16 @@ #define cquest (quest[QUEST_INVASION]) -static bool_ quest_invasion_gen_hook(void *, void *, void *) +static bool quest_invasion_gen_hook(void *, void *, void *) { int x, y; int xstart = 2; int ystart = 2; - if (p_ptr->inside_quest != QUEST_INVASION) return FALSE; + if (p_ptr->inside_quest != QUEST_INVASION) + { + return false; + } /* Start with perm walls */ for (y = 0; y < cur_hgt; y++) @@ -47,6 +50,7 @@ static bool_ quest_invasion_gen_hook(void *, void *, void *) process_dungeon_file("maeglin.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); for (x = 3; x < xstart; x++) + { for (y = 3; y < ystart; y++) { if (cave[y][x].feat == FEAT_MARKER) @@ -58,18 +62,22 @@ static bool_ quest_invasion_gen_hook(void *, void *, void *) cave_set_feat(p_ptr->py, p_ptr->px, FEAT_LESS); } } + } - return TRUE; + return true; } -static bool_ quest_invasion_ai_hook(void *, void *in_, void *out_) +static bool quest_invasion_ai_hook(void *, void *in_, void *out_) { struct hook_monster_ai_in *in = static_cast<struct hook_monster_ai_in *>(in_); struct hook_monster_ai_out *out = static_cast<struct hook_monster_ai_out *>(out_); monster_type *m_ptr = in->m_ptr; s32b m_idx = in->m_idx; - if (p_ptr->inside_quest != QUEST_INVASION) return FALSE; + if (p_ptr->inside_quest != QUEST_INVASION) + { + return false; + } /* Ugly but thats better than a call to test_monster_name which is SLOW */ if (m_ptr->r_idx == 825) @@ -82,26 +90,26 @@ static bool_ quest_invasion_ai_hook(void *, void *in_, void *out_) cmsg_print(TERM_YELLOW, "Maeglin found the way to Gondolin! All hope is lost now!"); cquest.status = QUEST_STATUS_FAILED; town_info[2].destroyed = TRUE; - return (FALSE); + return false; } /* Attack or flee ?*/ if (distance(m_ptr->fy, m_ptr->fx, p_ptr->py, p_ptr->px) <= 2) { - return (FALSE); + return false; } else { out->y = cquest.data[0]; out->x = cquest.data[1]; - return (TRUE); + return true; } } - return (FALSE); + return false; } -static bool_ quest_invasion_turn_hook(void *, void *, void *) +static bool quest_invasion_turn_hook(void *, void *, void *) { if (cquest.status != QUEST_STATUS_UNTAKEN) return (FALSE); if (p_ptr->lev < 45) return (FALSE); @@ -124,10 +132,10 @@ static bool_ quest_invasion_turn_hook(void *, void *, void *) del_hook_new(HOOK_END_TURN, quest_invasion_turn_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } -static bool_ quest_invasion_dump_hook(void *, void *in_, void *) +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; @@ -140,16 +148,19 @@ static bool_ quest_invasion_dump_hook(void *, void *in_, void *) { fprintf(f, "\n You saved Gondolin from destruction."); } - return (FALSE); + return false; } -static bool_ quest_invasion_death_hook(void *, void *in_, void *) +static bool quest_invasion_death_hook(void *, void *in_, void *) { struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_); s32b m_idx = in->m_idx; s32b r_idx = m_list[m_idx].r_idx; - if (p_ptr->inside_quest != QUEST_INVASION) return FALSE; + if (p_ptr->inside_quest != QUEST_INVASION) + { + return false; + } if (r_idx == test_monster_name("Maeglin, the Traitor of Gondolin")) { @@ -159,13 +170,13 @@ static bool_ quest_invasion_death_hook(void *, void *in_, void *) del_hook_new(HOOK_MONSTER_DEATH, quest_invasion_death_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } - return FALSE; + return false; } -static bool_ quest_invasion_stair_hook(void *, void *in_, void *) +static bool quest_invasion_stair_hook(void *, void *in_, void *) { struct hook_stair_in *in = static_cast<struct hook_stair_in *>(in_); @@ -201,13 +212,13 @@ static bool_ quest_invasion_stair_hook(void *, void *in_, void *) } del_hook_new(HOOK_STAIR, quest_invasion_stair_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } - return TRUE; + return true; } -bool_ quest_invasion_init_hook() +void quest_invasion_init_hook() { add_hook_new(HOOK_END_TURN, quest_invasion_turn_hook, "invasion_turn", NULL); add_hook_new(HOOK_CHAR_DUMP, quest_invasion_dump_hook, "invasion_dump", NULL); @@ -218,5 +229,4 @@ bool_ quest_invasion_init_hook() add_hook_new(HOOK_MONSTER_DEATH, quest_invasion_death_hook, "invasion_death", NULL); add_hook_new(HOOK_STAIR, quest_invasion_stair_hook, "invasion_stair", NULL); } - return (FALSE); } diff --git a/src/q_invas.hpp b/src/q_invas.hpp index 9993ac2b..dc2d8780 100644 --- a/src/q_invas.hpp +++ b/src/q_invas.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_invasion_init_hook(); +void quest_invasion_init_hook(); diff --git a/src/q_library.cc b/src/q_library.cc index c9855591..e267e2b7 100644 --- a/src/q_library.cc +++ b/src/q_library.cc @@ -312,12 +312,12 @@ static void library_quest_fill_book() screen_load(); } -static bool_ quest_library_gen_hook(void *, void *, void *) +static bool quest_library_gen_hook(void *, void *, void *) { /* Only if player doing this quest */ if (p_ptr->inside_quest != QUEST_LIBRARY) { - return FALSE; + return false; } { @@ -352,46 +352,41 @@ static bool_ quest_library_gen_hook(void *, void *, void *) library_quest_place_nrandom( 10, 10, 37, 67, MONSTER_MITHRIL_GOLEM, 1); - return TRUE; + return true; } -static bool_ quest_library_stair_hook(void *, void *, void *) +static bool quest_library_stair_hook(void *, void *, void *) { - bool_ ret; - /* only ask this if player about to go up stairs of quest and hasn't won yet */ if ((p_ptr->inside_quest != QUEST_LIBRARY) || (cquest.status == QUEST_STATUS_COMPLETED)) { - return FALSE; + return false; } if (cave[p_ptr->py][p_ptr->px].feat != FEAT_LESS) { - return FALSE; + return false; } /* flush all pending input */ flush(); /* confirm */ - ret = get_check("Really abandon the quest?"); - - /* if yes, then */ - if (ret == TRUE) + if (get_check("Really abandon the quest?")) { /* fail the quest */ cquest.status = QUEST_STATUS_FAILED; - return FALSE; + return false; } else { /* if no, they stay in the quest */ - return TRUE; + return true; } } -static bool_ quest_library_monster_death_hook(void *, void *, void *) +static bool quest_library_monster_death_hook(void *, void *, void *) { int i, count = -1; @@ -399,7 +394,7 @@ static bool_ quest_library_monster_death_hook(void *, void *, void *) if ((p_ptr->inside_quest != QUEST_LIBRARY) || (cquest.status == QUEST_STATUS_COMPLETED)) { - return FALSE; + return false; } /* Count all the enemies left alive */ @@ -421,7 +416,7 @@ static bool_ quest_library_monster_death_hook(void *, void *, void *) } /* Normal processing */ - return FALSE; + return false; } void quest_library_building(bool_ *paid, bool_ *recreate) @@ -500,7 +495,7 @@ std::string quest_library_describe() return w.str(); } -bool_ quest_library_init_hook() +void quest_library_init_hook() { /* Only need hooks if the quest is unfinished. */ if ((cquest.status >= QUEST_STATUS_UNTAKEN) && @@ -516,8 +511,4 @@ bool_ quest_library_init_hook() { quest_library_finalize_book(); } - - return FALSE; } - -#undef print_hook diff --git a/src/q_library.hpp b/src/q_library.hpp index 467fac5e..266accc3 100644 --- a/src/q_library.hpp +++ b/src/q_library.hpp @@ -4,7 +4,7 @@ #include <string> -bool_ quest_library_init_hook(); +void quest_library_init_hook(); std::string quest_library_describe(); void quest_library_building(bool_ *paid, bool_ *recreate); void initialize_bookable_spells(); diff --git a/src/q_main.cc b/src/q_main.cc index 159d0f7b..2d3473f1 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -29,7 +29,7 @@ static void quest_describe(int q_idx) } } -static bool_ quest_main_monsters_hook(void *, void *in_, void *) +static bool quest_main_monsters_hook(void *, void *in_, void *) { auto const &r_info = game->edit_data.r_info; @@ -40,18 +40,24 @@ static bool_ quest_main_monsters_hook(void *, void *in_, void *) if (r_idx == get_sauron()) { /* No Sauron until Necromancer dies */ - if (r_info[get_necromancer()].max_num) return TRUE; + if (r_info[get_necromancer()].max_num) + { + return true; + } } /* Morgoth */ else if (r_idx == get_morgoth()) { /* No Morgoth until Sauron dies */ - if (r_info[get_sauron()].max_num) return TRUE; + if (r_info[get_sauron()].max_num) + { + return true; + } } - return FALSE; + return false; } -static bool_ quest_morgoth_hook(void *, void *, void *) +static bool quest_morgoth_hook(void *, void *, void *) { auto const &r_info = game->edit_data.r_info; @@ -100,10 +106,10 @@ static bool_ quest_morgoth_hook(void *, void *, void *) *(quest[QUEST_MORGOTH].plot) = QUEST_ULTRA_EVIL; quest[*(quest[QUEST_MORGOTH].plot)].init(); } - return (FALSE); + return false; } -static bool_ quest_morgoth_dump_hook(void *, void *in_, void *) +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; @@ -111,14 +117,18 @@ static bool_ quest_morgoth_dump_hook(void *, void *in_, void *) if (quest[QUEST_MORGOTH].status >= QUEST_STATUS_COMPLETED) { if (quest[QUEST_ONE].status == QUEST_STATUS_FINISHED) + { fprintf(f, "\n You saved Arda and became a famed hero."); + } else + { fprintf(f, "\n You became a new force of darkness and enslaved all free people."); + } } - return (FALSE); + return false; } -bool_ quest_morgoth_init_hook() +void quest_morgoth_init_hook() { if ((quest[QUEST_MORGOTH].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_MORGOTH].status < QUEST_STATUS_FINISHED)) { @@ -126,10 +136,9 @@ bool_ quest_morgoth_init_hook() } add_hook_new(HOOK_CHAR_DUMP, quest_morgoth_dump_hook, "morgoth_dump", NULL); add_hook_new(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster", NULL); - return (FALSE); } -static bool_ quest_sauron_hook(void *, void *, void *) +static bool quest_sauron_hook(void *, void *, void *) { auto const &r_info = game->edit_data.r_info; @@ -151,10 +160,11 @@ static bool_ quest_sauron_hook(void *, void *, void *) process_hooks_restart = TRUE; } - return (FALSE); + + return false; } -static bool_ quest_sauron_resurect_hook(void *, void *in_, void *) +static bool quest_sauron_resurrect_hook(void *, void *in_, void *) { auto &r_info = game->edit_data.r_info; @@ -173,21 +183,20 @@ static bool_ quest_sauron_resurect_hook(void *, void *in_, void *) msg_print("Sauron will not be permanently defeated until the One Ring is either destroyed or used..."); r_ptr->max_num = 1; } - return FALSE; + return false; } -bool_ quest_sauron_init_hook() +void quest_sauron_init_hook() { if ((quest[QUEST_SAURON].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_SAURON].status < QUEST_STATUS_FINISHED)) { add_hook_new(HOOK_MONSTER_DEATH, quest_sauron_hook, "sauron_death", NULL); } add_hook_new(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster", NULL); - add_hook_new(HOOK_MONSTER_DEATH, quest_sauron_resurect_hook, "sauron_resurect_death", NULL); - return (FALSE); + add_hook_new(HOOK_MONSTER_DEATH, quest_sauron_resurrect_hook, "sauron_resurect_death", NULL); } -static bool_ quest_necro_hook(void *, void *, void *) +static bool quest_necro_hook(void *, void *, void *) { auto const &r_info = game->edit_data.r_info; @@ -208,15 +217,15 @@ static bool_ quest_necro_hook(void *, void *, void *) del_hook_new(HOOK_MONSTER_DEATH, quest_necro_hook); process_hooks_restart = TRUE; } - return (FALSE); + + return false; } -bool_ quest_necro_init_hook() +void quest_necro_init_hook() { if ((quest[QUEST_NECRO].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_NECRO].status < QUEST_STATUS_FINISHED)) { add_hook_new(HOOK_MONSTER_DEATH, quest_necro_hook, "necro_death", NULL); } add_hook_new(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster", NULL); - return (FALSE); } diff --git a/src/q_main.hpp b/src/q_main.hpp index f677586e..be33897b 100644 --- a/src/q_main.hpp +++ b/src/q_main.hpp @@ -2,6 +2,6 @@ #include "h-basic.h" -bool_ quest_necro_init_hook(); -bool_ quest_sauron_init_hook(); -bool_ quest_morgoth_init_hook(); +void quest_necro_init_hook(); +void quest_sauron_init_hook(); +void quest_morgoth_init_hook(); diff --git a/src/q_narsil.cc b/src/q_narsil.cc index 4f358451..8d3c2775 100644 --- a/src/q_narsil.cc +++ b/src/q_narsil.cc @@ -14,7 +14,7 @@ #define cquest (quest[QUEST_NARSIL]) -static bool_ quest_narsil_move_hook(void *, void *in_, void *) +static bool quest_narsil_move_hook(void *, void *in_, void *) { struct hook_move_in *in = static_cast<struct hook_move_in *>(in_); s32b y = in->y; @@ -23,10 +23,16 @@ static bool_ quest_narsil_move_hook(void *, void *in_, void *) int i; object_type *o_ptr; - if (cquest.status != QUEST_STATUS_TAKEN) return FALSE; + if (cquest.status != QUEST_STATUS_TAKEN) + { + return false; + } /* The castle of Aragorn */ - if ((c_ptr->feat != FEAT_SHOP) || (c_ptr->special != 14)) return FALSE; + if ((c_ptr->feat != FEAT_SHOP) || (c_ptr->special != 14)) + { + return false; + } /* Look out for Narsil */ for (i = 0; i < INVEN_TOTAL; i++) @@ -38,7 +44,10 @@ static bool_ quest_narsil_move_hook(void *, void *in_, void *) if (o_ptr->name1 == ART_NARSIL) break; } - if (i == INVEN_TOTAL) return FALSE; + if (i == INVEN_TOTAL) + { + return false; + } cmsg_print(TERM_YELLOW, "I heard that the broken sword had been found!"); cmsg_print(TERM_YELLOW, "I thought it was only a rumor... until now."); @@ -65,10 +74,10 @@ static bool_ quest_narsil_move_hook(void *, void *in_, void *) del_hook_new(HOOK_MOVE, quest_narsil_move_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_narsil_dump_hook(void *, void *in_, void *) +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; @@ -77,10 +86,10 @@ static bool_ quest_narsil_dump_hook(void *, void *in_, void *) { fprintf(f, "\n The sword that was broken is now reforged."); } - return (FALSE); + return false; } -static bool_ quest_narsil_identify_hook(void *, void *in_, void *) +static bool quest_narsil_identify_hook(void *, void *in_, void *) { struct hook_identify_in *in = static_cast<struct hook_identify_in *>(in_); @@ -104,10 +113,10 @@ static bool_ quest_narsil_identify_hook(void *, void *in_, void *) } } - return (FALSE); + return false; } -bool_ quest_narsil_init_hook() +void quest_narsil_init_hook() { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -118,5 +127,4 @@ bool_ quest_narsil_init_hook() add_hook_new(HOOK_IDENTIFY, quest_narsil_identify_hook, "narsil_id", NULL); } add_hook_new(HOOK_CHAR_DUMP, quest_narsil_dump_hook, "narsil_dump", NULL); - return (FALSE); } diff --git a/src/q_narsil.hpp b/src/q_narsil.hpp index 7dd6cd15..da0fa85d 100644 --- a/src/q_narsil.hpp +++ b/src/q_narsil.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_narsil_init_hook(); +void quest_narsil_init_hook(); diff --git a/src/q_nazgul.cc b/src/q_nazgul.cc index a59a8df3..99735eed 100644 --- a/src/q_nazgul.cc +++ b/src/q_nazgul.cc @@ -22,13 +22,16 @@ GENERATE_MONSTER_LOOKUP_FN(get_uvatha, "Uvatha the Horseman") -static bool_ quest_nazgul_gen_hook(void *, void *in_, void *) +static bool quest_nazgul_gen_hook(void *, void *in_, void *) { struct hook_wild_gen_in *in = static_cast<struct hook_wild_gen_in *>(in_); int m_idx, x = 1, y = 1, tries = 10000; bool_ small = in->small; - if ((cquest.status != QUEST_STATUS_TAKEN) || (small) || (p_ptr->town_num != 1)) return (FALSE); + if ((cquest.status != QUEST_STATUS_TAKEN) || (small) || (p_ptr->town_num != 1)) + { + return false; + } /* Find a good position */ while (tries) @@ -54,16 +57,19 @@ static bool_ quest_nazgul_gen_hook(void *, void *in_, void *) if (m_idx) m_list[m_idx].mflag |= MFLAG_QUEST; - return FALSE; + return false; } -static bool_ quest_nazgul_finish_hook(void *, void *in_, void *) +static bool quest_nazgul_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_NAZGUL) return FALSE; + if (q_idx != QUEST_NAZGUL) + { + return false; + } c_put_str(TERM_YELLOW, "I believe he will not come back! Thank you.", 8, 0); c_put_str(TERM_YELLOW, "Some time ago a ranger gave me this.", 9, 0); @@ -84,10 +90,10 @@ static bool_ quest_nazgul_finish_hook(void *, void *in_, void *) del_hook_new(HOOK_QUEST_FINISH, quest_nazgul_finish_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_nazgul_dump_hook(void *, void *in_, void *) +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; @@ -96,42 +102,53 @@ static bool_ quest_nazgul_dump_hook(void *, void *in_, void *) { fprintf(f, "\n You saved Bree from a dreadful Nazgul."); } - return (FALSE); + return false; } -static bool_ quest_nazgul_forbid_hook(void *, void *in_, void *) +static bool quest_nazgul_forbid_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; - if (q_idx != QUEST_NAZGUL) return (FALSE); + if (q_idx != QUEST_NAZGUL) + { + return false; + } if (p_ptr->lev < 30) { c_put_str(TERM_WHITE, "I fear you are not ready for the next quest, come back later.", 8, 0); - return (TRUE); + return true; } - return (FALSE); + + return false; } -static bool_ quest_nazgul_death_hook(void *, void *in_, void *) +static bool quest_nazgul_death_hook(void *, void *in_, void *) { struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_); s32b m_idx = in->m_idx; s32b r_idx = m_list[m_idx].r_idx; - if (cquest.status != QUEST_STATUS_TAKEN) return (FALSE); - if (r_idx != get_uvatha()) return (FALSE); + if (cquest.status != QUEST_STATUS_TAKEN) + { + return false; + } + + if (r_idx != get_uvatha()) + { + return false; + } cquest.status = QUEST_STATUS_COMPLETED; del_hook_new(HOOK_MONSTER_DEATH, quest_nazgul_death_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } -bool_ quest_nazgul_init_hook() +void quest_nazgul_init_hook() { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -141,5 +158,4 @@ bool_ quest_nazgul_init_hook() } add_hook_new(HOOK_CHAR_DUMP, quest_nazgul_dump_hook, "nazgul_dump", NULL); add_hook_new(HOOK_INIT_QUEST, quest_nazgul_forbid_hook, "nazgul_forbid", NULL); - return (FALSE); } diff --git a/src/q_nazgul.hpp b/src/q_nazgul.hpp index 7efcd5a6..ad35e5b3 100644 --- a/src/q_nazgul.hpp +++ b/src/q_nazgul.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_nazgul_init_hook(); +void quest_nazgul_init_hook(); diff --git a/src/q_nirna.cc b/src/q_nirna.cc index 7609bd06..822d8b6c 100644 --- a/src/q_nirna.cc +++ b/src/q_nirna.cc @@ -13,13 +13,16 @@ #define cquest (quest[QUEST_NIRNAETH]) -static bool_ quest_nirnaeth_gen_hook(void *, void *, void *) +static bool quest_nirnaeth_gen_hook(void *, void *, void *) { int x, y; int xstart = 2; int ystart = 2; - if (p_ptr->inside_quest != QUEST_NIRNAETH) return FALSE; + if (p_ptr->inside_quest != QUEST_NIRNAETH) + { + return false; + } /* Start with perm walls */ for (y = 0; y < cur_hgt; y++) @@ -44,20 +47,25 @@ static bool_ quest_nirnaeth_gen_hook(void *, void *, void *) cquest.data[0] = 0; cquest.data[1] = 0; for (x = 2; x < xstart; x++) + { for (y = 2; y < ystart; y++) { if (cave[y][x].m_idx) cquest.data[0]++; } + } - return TRUE; + return true; } -static bool_ quest_nirnaeth_finish_hook(void *, void *in_, void *) +static bool quest_nirnaeth_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; - if (q_idx != QUEST_NIRNAETH) return FALSE; + if (q_idx != QUEST_NIRNAETH) + { + return false; + } /* Killed at least 2/3 of them ? better reward ! */ if (cquest.data[1] >= (2 * cquest.data[0] / 3)) @@ -86,33 +94,39 @@ static bool_ quest_nirnaeth_finish_hook(void *, void *in_, void *) del_hook_new(HOOK_QUEST_FINISH, quest_nirnaeth_finish_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_nirnaeth_death_hook(void *, void *, void *) +static bool quest_nirnaeth_death_hook(void *, void *, void *) { if (p_ptr->inside_quest != QUEST_NIRNAETH) return FALSE; cquest.data[1]++; - return FALSE; + return false; } -static bool_ quest_nirnaeth_stair_hook(void *, void *, void *) +static bool quest_nirnaeth_stair_hook(void *, void *, void *) { - if (p_ptr->inside_quest != QUEST_NIRNAETH) return FALSE; + if (p_ptr->inside_quest != QUEST_NIRNAETH) + { + return false; + } - if (cave[p_ptr->py][p_ptr->px].feat != FEAT_LESS) return (FALSE); + if (cave[p_ptr->py][p_ptr->px].feat != FEAT_LESS) + { + return false; + } cmsg_print(TERM_YELLOW, "You found a way out!"); cquest.status = QUEST_STATUS_COMPLETED; del_hook_new(HOOK_STAIR, quest_nirnaeth_stair_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } -bool_ quest_nirnaeth_init_hook() +void quest_nirnaeth_init_hook() { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -121,5 +135,4 @@ bool_ quest_nirnaeth_init_hook() add_hook_new(HOOK_STAIR, quest_nirnaeth_stair_hook, "nirnaeth_stair", NULL); add_hook_new(HOOK_QUEST_FINISH, quest_nirnaeth_finish_hook, "nirnaeth_finish", NULL); } - return (FALSE); } diff --git a/src/q_nirna.hpp b/src/q_nirna.hpp index 0076dcd2..1aaeae54 100644 --- a/src/q_nirna.hpp +++ b/src/q_nirna.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_nirnaeth_init_hook(); +void quest_nirnaeth_init_hook(); diff --git a/src/q_one.cc b/src/q_one.cc index 043e7d0e..8985b695 100644 --- a/src/q_one.cc +++ b/src/q_one.cc @@ -27,7 +27,7 @@ #define cquest (quest[QUEST_ONE]) -static bool_ quest_one_move_hook(void *, void *in_, void *) +static bool quest_one_move_hook(void *, void *in_, void *) { struct hook_move_in *in = static_cast<struct hook_move_in *>(in_); s32b y = in->y; @@ -36,10 +36,16 @@ static bool_ quest_one_move_hook(void *, void *in_, void *) if (cquest.status == QUEST_STATUS_UNTAKEN) { - if (quest[QUEST_NECRO].status < QUEST_STATUS_FINISHED) return (FALSE); + if (quest[QUEST_NECRO].status < QUEST_STATUS_FINISHED) + { + return false; + } /* The mirror of Galadriel */ - if ((c_ptr->feat != FEAT_SHOP) || (c_ptr->special != 23)) return (FALSE); + if ((c_ptr->feat != FEAT_SHOP) || (c_ptr->special != 23)) + { + return false; + } cmsg_print(TERM_YELLOW, "You meet Galadriel; she seems worried."); cmsg_print(TERM_YELLOW, "'So it was Sauron that lurked in Dol Guldur...'"); @@ -85,22 +91,32 @@ static bool_ quest_one_move_hook(void *, void *in_, void *) cquest.status = QUEST_STATUS_TAKEN; cquest.init(); - return TRUE; + return true; } - return FALSE; + return false; } -static bool_ quest_one_drop_hook(void *, void *in_, void *) +static bool quest_one_drop_hook(void *, void *in_, void *) { 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; + if (cquest.status != QUEST_STATUS_TAKEN) + { + return false; + } - if (o_ptr->name1 != ART_POWER) return FALSE; - if (cave[p_ptr->py][p_ptr->px].feat != FEAT_GREAT_FIRE) return FALSE; + if (o_ptr->name1 != ART_POWER) + { + return false; + } + + if (cave[p_ptr->py][p_ptr->px].feat != FEAT_GREAT_FIRE) + { + return false; + } cmsg_print(TERM_YELLOW, "You throw the One Ring into the #RGreat Fire#y; it is rapidly consumed"); cmsg_print(TERM_YELLOW, "by the searing flames."); @@ -117,32 +133,44 @@ static bool_ quest_one_drop_hook(void *, void *in_, void *) quest[*(quest[QUEST_ONE].plot)].status = QUEST_STATUS_TAKEN; quest[*(quest[QUEST_ONE].plot)].init(); - return TRUE; + return true; } -static bool_ quest_one_wield_hook(void *, void *in_, void *) +static bool quest_one_wield_hook(void *, void *in_, void *) { struct hook_wield_in *in = static_cast<struct hook_wield_in *>(in_); object_type *o_ptr = in->o_ptr; - if (cquest.status != QUEST_STATUS_TAKEN) return FALSE; + if (cquest.status != QUEST_STATUS_TAKEN) + { + return false; + } - if (o_ptr->name1 != ART_POWER) return FALSE; + if (o_ptr->name1 != ART_POWER) + { + return false; + } - /* Flush input */ + // Make sure player is **really** warned flush(); + if (!get_check("You were warned not to wear it; are you sure?")) + { + return true; + } - if (!get_check("You were warned not to wear it; are you sure?")) return TRUE; - /* Flush input */ flush(); + if (!get_check("You were warned not to wear it; are you *REALLY* sure?")) + { + return true; + } - if (!get_check("You were warned not to wear it; are you *REALLY* sure?")) return TRUE; - - /* Flush input */ flush(); + if (!get_check("You were *WARNED* not to wear it; are you *R*E*A*L*L*Y* sure?")) + { + return true; + } - if (!get_check("You were *WARNED* not to wear it; are you *R*E*A*L*L*Y* sure?")) return TRUE; - + // Ok, that's enough warning cmsg_print(TERM_YELLOW, "As you put it on your finger you feel #Ddark powers #ysapping your soul."); cmsg_print(TERM_YELLOW, "The ring firmly binds to your finger!"); cmsg_print(TERM_YELLOW, "You feel you are drawn to the shadow world! Your material form weakens."); @@ -172,10 +200,10 @@ static bool_ quest_one_wield_hook(void *, void *in_, void *) /* Ok lets reset the lives counter */ p_ptr->lives = 0; - return FALSE; + return false; } -static bool_ quest_one_hp_hook(void *, void *in_, void *out_) +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_); @@ -185,15 +213,18 @@ static bool_ quest_one_hp_hook(void *, void *in_, void *out_) s32b mhp = in->mhp; for (int i = 0; i < p_ptr->lives + 1; i++) + { mhp = (mhp * 2) / 3; + } out->mhp = mhp; - return (TRUE); + return true; } - return (FALSE); + + return false; } -static bool_ quest_one_die_hook(void *, void *, void *) +static bool quest_one_die_hook(void *, void *, void *) { if (cquest.status == QUEST_STATUS_FAILED_DONE) { @@ -201,7 +232,7 @@ static bool_ quest_one_die_hook(void *, void *, void *) { cmsg_print(TERM_YELLOW, "You feel the power of the One Ring sustaining your life,"); cmsg_print(TERM_YELLOW, "but it drags you even more into the shadow world."); - return (TRUE); + return true; } else { @@ -210,10 +241,10 @@ static bool_ quest_one_die_hook(void *, void *, void *) game->died_from = "being drawn to the shadow world"; } } - return (FALSE); + return false; } -static bool_ quest_one_identify_hook(void *, void *in_, void *) +static bool quest_one_identify_hook(void *, void *in_, void *) { struct hook_identify_in *in = static_cast<struct hook_identify_in *>(in_); object_type *o_ptr = in->o_ptr; @@ -228,46 +259,52 @@ static bool_ quest_one_identify_hook(void *, void *in_, void *) } } - return (FALSE); + return false; } -static bool_ quest_one_death_hook(void *, void *in_, void *) +static bool quest_one_death_hook(void *, void *in_, void *) { auto const &a_info = game->edit_data.a_info; struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_); s32b m_idx = in->m_idx; s32b r_idx = m_list[m_idx].r_idx; - bool_ ok = FALSE; + bool ok = false; - if (a_info[ART_POWER].cur_num) return FALSE; + if (a_info[ART_POWER].cur_num) + { + return false; + } /* Paranoia */ - if (cquest.status != QUEST_STATUS_TAKEN) return (FALSE); + if (cquest.status != QUEST_STATUS_TAKEN) + { + return false; + } if (magik(30) && (r_idx == test_monster_name("Sauron, the Sorcerer"))) { - ok = TRUE; + ok = true; } else if (magik(10) && (r_idx == test_monster_name("Ar-Pharazon the Golden"))) { - ok = TRUE; + ok = true; } else if (magik(10) && (r_idx == test_monster_name("Shelob, Spider of Darkness"))) { - ok = TRUE; + ok = true; } else if (magik(10) && (r_idx == test_monster_name("The Watcher in the Water"))) { - ok = TRUE; + ok = true; } else if (magik(10) && (r_idx == test_monster_name("Glaurung, Father of the Dragons"))) { - ok = TRUE; + ok = true; } else if (magik(10) && (r_idx == test_monster_name("Feagwath, the Undead Sorcerer"))) { - ok = TRUE; + ok = true; } if (ok) @@ -290,7 +327,10 @@ static bool_ quest_one_death_hook(void *, void *in_, void *) for (i = 0; i < INVEN_PACK; i++) { /* Skip non-objects */ - if (!p_ptr->inventory[i].k_idx) break; + if (!p_ptr->inventory[i].k_idx) + { + break; + } } /* Arg, no space ! */ if (i == INVEN_PACK) @@ -310,10 +350,10 @@ static bool_ quest_one_death_hook(void *, void *in_, void *) inven_carry(q_ptr, FALSE); } - return (FALSE); + return false; } -static bool_ quest_one_dump_hook(void *, void *in_, void *) +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; @@ -326,16 +366,22 @@ static bool_ quest_one_dump_hook(void *, void *in_, void *) { fprintf(f, "\n You fell under the evil influence of the One Ring and decided to wear it."); } - return (FALSE); + return false; } -static bool_ quest_one_gen_hook(void *, void *, void *) +static bool quest_one_gen_hook(void *, void *, void *) { s32b x, y, tries = 10000; /* Paranoia */ - if (cquest.status != QUEST_STATUS_TAKEN) return (FALSE); - if ((dungeon_type != DUNGEON_ANGBAND) || (dun_level != 99)) return (FALSE); + if (cquest.status != QUEST_STATUS_TAKEN) + { + return false; + } + if ((dungeon_type != DUNGEON_ANGBAND) || (dun_level != 99)) + { + return false; + } /* Find a good position */ while (tries) @@ -357,10 +403,10 @@ static bool_ quest_one_gen_hook(void *, void *, void *) if (m_idx) m_list[m_idx].mflag |= MFLAG_QUEST; } - return (FALSE); + return false; } -bool_ quest_one_init_hook() +void quest_one_init_hook() { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -377,5 +423,4 @@ bool_ quest_one_init_hook() add_hook_new(HOOK_CHAR_DUMP, quest_one_dump_hook, "one_dump", NULL); add_hook_new(HOOK_CALC_HP, quest_one_hp_hook, "one_hp", NULL); add_hook_new(HOOK_DIE, quest_one_die_hook, "one_die", NULL); - return (FALSE); } diff --git a/src/q_one.hpp b/src/q_one.hpp index 0ad4e851..13389968 100644 --- a/src/q_one.hpp +++ b/src/q_one.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_one_init_hook(); +void quest_one_init_hook(); 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); } diff --git a/src/q_poison.hpp b/src/q_poison.hpp index 0c054e0c..6c4e771b 100644 --- a/src/q_poison.hpp +++ b/src/q_poison.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_poison_init_hook(); +void quest_poison_init_hook(); diff --git a/src/q_rand.cc b/src/q_rand.cc index 7f0b2503..177ba7a9 100644 --- a/src/q_rand.cc +++ b/src/q_rand.cc @@ -404,51 +404,60 @@ static void hero_death(s32b m_idx, s32b r_idx) } } -static bool_ quest_random_death_hook(void *, void *in_, void *) +static bool quest_random_death_hook(void *, void *in_, void *) { struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_); s32b m_idx = in->m_idx; int r_idx = m_list[m_idx].r_idx; - if (!(dungeon_flags & DF_PRINCIPAL)) return (FALSE); - if ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) return (FALSE); - if (!random_quests[dun_level].type) return (FALSE); - if (random_quests[dun_level].done) return (FALSE); - if (p_ptr->inside_quest) return (FALSE); - if (random_quests[dun_level].r_idx != r_idx) return (FALSE); - - if (!(m_list[m_idx].mflag & MFLAG_QUEST)) return (FALSE); + if ((!(dungeon_flags & DF_PRINCIPAL)) || + ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) || + (!random_quests[dun_level].type) || + (random_quests[dun_level].done) || + (p_ptr->inside_quest) || + (random_quests[dun_level].r_idx != r_idx) || + (!(m_list[m_idx].mflag & MFLAG_QUEST))) + { + return false; + } /* Killed enough ?*/ quest[QUEST_RANDOM].data[0]++; if (quest[QUEST_RANDOM].data[0] == random_quests[dun_level].type) { if (is_randhero(dun_level)) + { hero_death(m_idx, r_idx); + } else + { princess_death(m_idx, r_idx); + } } - return (FALSE); + return false; } -static bool_ quest_random_turn_hook(void *, void *, void *) +static bool quest_random_turn_hook(void *, void *, void *) { quest[QUEST_RANDOM].data[0] = 0; quest[QUEST_RANDOM].data[1] = 0; - return (FALSE); + return false; } -static bool_ quest_random_feeling_hook(void *, void *, void *) +static bool quest_random_feeling_hook(void *, void *, void *) { auto const &r_info = game->edit_data.r_info; - if (!(dungeon_flags & DF_PRINCIPAL)) return (FALSE); - if ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) return (FALSE); - if (!random_quests[dun_level].type) return (FALSE); - if (random_quests[dun_level].done) return (FALSE); - if (p_ptr->inside_quest) return (FALSE); - if (!dun_level) return (FALSE); + if ((!(dungeon_flags & DF_PRINCIPAL)) || + ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) || + (!random_quests[dun_level].type) || + (random_quests[dun_level].done) || + (p_ptr->inside_quest) || + (!dun_level)) + { + return false; + } if (is_randhero(dun_level)) { @@ -456,22 +465,25 @@ static bool_ quest_random_feeling_hook(void *, void *, void *) cmsg_format(TERM_YELLOW, "'Oh, please help me! A horrible %s stole my sword! I'm nothing without it.'", r_info[random_quests[dun_level].r_idx].name); } else + { cmsg_format(TERM_YELLOW, "You hear someone shouting: 'Leave me alone, stupid %s'", r_info[random_quests[dun_level].r_idx].name); - return (FALSE); + } + return false; } -static bool_ quest_random_gen_hero_hook(void *, void *, void *) +static bool quest_random_gen_hero_hook(void *, void *, void *) { - int i; - - if (!(dungeon_flags & DF_PRINCIPAL)) return (FALSE); - if ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) return (FALSE); - if (!random_quests[dun_level].type) return (FALSE); - if (random_quests[dun_level].done) return (FALSE); - if (p_ptr->inside_quest) return (FALSE); - if (!is_randhero(dun_level)) return (FALSE); + if ((!(dungeon_flags & DF_PRINCIPAL)) || + ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) || + (!random_quests[dun_level].type) || + (random_quests[dun_level].done) || + (p_ptr->inside_quest) || + (!is_randhero(dun_level))) + { + return false; + } - i = random_quests[dun_level].type; + int i = random_quests[dun_level].type; m_allow_special[random_quests[dun_level].r_idx] = TRUE; while (i) @@ -488,10 +500,10 @@ static bool_ quest_random_gen_hero_hook(void *, void *, void *) } m_allow_special[random_quests[dun_level].r_idx] = FALSE; - return (FALSE); + return false; } -static bool_ quest_random_gen_hook(void *, void *in_, void *) +static bool quest_random_gen_hook(void *, void *in_, void *) { struct hook_build_room1_in *in = static_cast<struct hook_build_room1_in *>(in_); s32b bx0 = in->x; @@ -502,19 +514,25 @@ static bool_ quest_random_gen_hook(void *, void *in_, void *) int y2, x2, yval, xval; int y1, x1, xsize, ysize; - if (!(dungeon_flags & DF_PRINCIPAL)) return (FALSE); - if ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) return (FALSE); - if (!random_quests[dun_level].type) return (FALSE); - if (random_quests[dun_level].done) return (FALSE); - if (p_ptr->inside_quest) return (FALSE); - if (quest[QUEST_RANDOM].data[1]) return (FALSE); - if (is_randhero(dun_level)) return (FALSE); + if ((!(dungeon_flags & DF_PRINCIPAL)) || + ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) || + (!random_quests[dun_level].type) || + (random_quests[dun_level].done) || + (p_ptr->inside_quest) || + (quest[QUEST_RANDOM].data[1]) || + (is_randhero(dun_level))) + { + return false; + } /* Pick a room size */ get_map_size(format("qrand%d.map", random_quests[dun_level].type), &ysize, &xsize); /* Try to allocate space for room. If fails, exit */ - if (!room_alloc(xsize + 2, ysize + 2, FALSE, by0, bx0, &xval, &yval)) return FALSE; + if (!room_alloc(xsize + 2, ysize + 2, FALSE, by0, bx0, &xval, &yval)) + { + return false; + } /* Get corner values */ y1 = yval - ysize / 2; @@ -546,24 +564,23 @@ static bool_ quest_random_gen_hook(void *, void *in_, void *) process_dungeon_file(format("qrand%d.map", random_quests[dun_level].type), &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); for (x = x1; x < xstart; x++) + { for (y = y1; y < ystart; y++) { cave[y][x].info |= CAVE_ICKY | CAVE_ROOM; if (cave[y][x].feat == FEAT_MARKER) { - monster_type *m_ptr; - int i; - m_allow_special[random_quests[dun_level].r_idx] = TRUE; - i = place_monster_one(y, x, random_quests[dun_level].r_idx, 0, FALSE, MSTATUS_ENEMY); + int i = place_monster_one(y, x, random_quests[dun_level].r_idx, 0, FALSE, MSTATUS_ENEMY); m_allow_special[random_quests[dun_level].r_idx] = FALSE; if (i) { - m_ptr = &m_list[i]; + auto m_ptr = &m_list[i]; m_ptr->mflag |= MFLAG_QUEST; } } } + } /* Dont try another one for this generation */ quest[QUEST_RANDOM].data[1] = 1; @@ -571,10 +588,10 @@ static bool_ quest_random_gen_hook(void *, void *in_, void *) /* Boost level feeling a bit - a la pits */ rating += 10; - return (TRUE); + return true; } -static bool_ quest_random_dump_hook(void *, void *in_, void *) +static bool quest_random_dump_hook(void *, void *in_, void *) { 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_); @@ -617,7 +634,7 @@ static bool_ quest_random_dump_hook(void *, void *in_, void *) fprintf(f, "\n You haven't completed a single lost sword quest."); } - return (FALSE); + return false; } std::string quest_random_describe() @@ -626,12 +643,15 @@ std::string quest_random_describe() // Only emit description if we're actually on a // random quest level. - if (!(dungeon_flags & DF_PRINCIPAL)) return ""; - if ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) return ""; - if (!random_quests[dun_level].type) return ""; - if (random_quests[dun_level].done) return ""; - if (p_ptr->inside_quest) return ""; - if (!dun_level) return ""; + if ((!(dungeon_flags & DF_PRINCIPAL)) || + ((dun_level < 1) || (dun_level >= MAX_RANDOM_QUEST)) || + (!random_quests[dun_level].type) || + (random_quests[dun_level].done) || + (p_ptr->inside_quest) || + (!dun_level)) + { + return ""; + } fmt::MemoryWriter w; @@ -655,7 +675,7 @@ std::string quest_random_describe() return w.str(); } -bool_ quest_random_init_hook() +void quest_random_init_hook() { add_hook_new(HOOK_MONSTER_DEATH, quest_random_death_hook, "rand_death", NULL); add_hook_new(HOOK_NEW_LEVEL, quest_random_turn_hook, "rand_new_lvl", NULL); @@ -664,5 +684,4 @@ bool_ quest_random_init_hook() add_hook_new(HOOK_BUILD_ROOM1, quest_random_gen_hook, "rand_gen", NULL); add_hook_new(HOOK_FEELING, quest_random_feeling_hook, "rand_feel", NULL); add_hook_new(HOOK_CHAR_DUMP, quest_random_dump_hook, "rand_dump", NULL); - return (FALSE); } diff --git a/src/q_rand.hpp b/src/q_rand.hpp index 02961c8c..a992aa98 100644 --- a/src/q_rand.hpp +++ b/src/q_rand.hpp @@ -6,5 +6,5 @@ void initialize_random_quests(int n); bool_ is_randhero(int level); -bool_ quest_random_init_hook(); +void quest_random_init_hook(); std::string quest_random_describe(); diff --git a/src/q_shroom.cc b/src/q_shroom.cc index 8834e0f7..f14c7faf 100644 --- a/src/q_shroom.cc +++ b/src/q_shroom.cc @@ -23,15 +23,15 @@ #define cquest (quest[QUEST_SHROOM]) -static bool_ quest_shroom_speak_hook(void *, void *, void *); -static bool_ quest_shroom_chat_hook(void *, void *, void *); +static bool quest_shroom_speak_hook(void *, void *, void *); +static bool quest_shroom_chat_hook(void *, void *, void *); GENERATE_MONSTER_LOOKUP_FN(get_grip, "Grip, Farmer Maggot's dog") GENERATE_MONSTER_LOOKUP_FN(get_wolf, "Wolf, Farmer Maggot's dog") GENERATE_MONSTER_LOOKUP_FN(get_fang, "Fang, Farmer Maggot's dog") GENERATE_MONSTER_LOOKUP_FN(get_farmer_maggot, "Farmer Maggot") -static bool_ quest_shroom_town_gen_hook(void *, void *in_, void *) +static bool quest_shroom_town_gen_hook(void *, void *in_, void *) { struct hook_wild_gen_in *in = static_cast<struct hook_wild_gen_in *>(in_); int m_idx, x = 1, y = 1, tries = 10000; @@ -42,8 +42,12 @@ static bool_ quest_shroom_town_gen_hook(void *, void *in_, void *) { /* Create the field */ for (x = (cur_wid / 2) - 7; x <= (cur_wid / 2) + 7; x++) + { for (y = (cur_hgt / 2) - 5; y <= (cur_hgt / 2) + 5; y++) + { cave_set_feat(y, x, 181); + } + } /* Throw in some 'shrooms */ for (x = 0; x < (cquest.data[1] - cquest.data[0]); x++) @@ -83,7 +87,10 @@ static bool_ quest_shroom_town_gen_hook(void *, void *in_, void *) } /* Generate maggot in town, in daylight */ - if ((bst(HOUR, turn) < 6) || (bst(HOUR, turn) >= 18) || (cquest.status > QUEST_STATUS_COMPLETED) || (small) || (p_ptr->town_num != 1)) return (FALSE); + if ((bst(HOUR, turn) < 6) || (bst(HOUR, turn) >= 18) || (cquest.status > QUEST_STATUS_COMPLETED) || (small) || (p_ptr->town_num != 1)) + { + return false; + } /* Find a good position */ while (tries) @@ -95,7 +102,10 @@ static bool_ quest_shroom_town_gen_hook(void *, void *in_, void *) /* Is it a good spot ? */ /* Not in player los, and avoid shop grids */ if (!los(p_ptr->py, p_ptr->px, y, x) && cave_empty_bold(y, x) && - cave_plain_floor_bold(y, x)) break; + cave_plain_floor_bold(y, x)) + { + break; + } /* One less try */ tries--; @@ -106,16 +116,19 @@ static bool_ quest_shroom_town_gen_hook(void *, void *in_, void *) place_monster_one(y, x, get_farmer_maggot(), 0, FALSE, MSTATUS_ENEMY); m_allow_special[get_farmer_maggot()] = FALSE; - return FALSE; + return false; } -static bool_ quest_shroom_death_hook(void *, void *in_, void *) +static bool quest_shroom_death_hook(void *, void *in_, void *) { struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_); s32b m_idx = in->m_idx; s32b r_idx = m_list[m_idx].r_idx; - if (cquest.status > QUEST_STATUS_COMPLETED) return FALSE; + if (cquest.status > QUEST_STATUS_COMPLETED) + { + return false; + } if ((r_idx == get_wolf()) || (r_idx == get_grip()) || @@ -124,10 +137,10 @@ static bool_ quest_shroom_death_hook(void *, void *in_, void *) msg_print("The dog yells a last time and drops dead on the grass."); } - return FALSE; + return false; } -static bool_ quest_shroom_give_hook(void *, void *in_, void *) +static bool quest_shroom_give_hook(void *, void *in_, void *) { auto const &r_info = game->edit_data.r_info; @@ -141,7 +154,10 @@ static bool_ quest_shroom_give_hook(void *, void *in_, void *) o_ptr = &p_ptr->inventory[item]; m_ptr = &m_list[m_idx]; - if (m_ptr->r_idx != get_farmer_maggot()) return (FALSE); + if (m_ptr->r_idx != get_farmer_maggot()) + { + return false; + } /* If one is dead .. its bad */ if ((r_info[get_grip()].max_num == 0) || @@ -157,10 +173,13 @@ static bool_ quest_shroom_give_hook(void *, void *in_, void *) del_hook_new(HOOK_CHAT, quest_shroom_speak_hook); del_hook_new(HOOK_WILD_GEN, quest_shroom_town_gen_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } - if ((o_ptr->tval != TV_FOOD) || (o_ptr->pval2 != 1)) return (FALSE); + if ((o_ptr->tval != TV_FOOD) || (o_ptr->pval2 != 1)) + { + return false; + } /* Take a mushroom */ inc_stack_size_ex(item, -1, OPTIMIZE, NO_DESCRIBE); @@ -184,9 +203,13 @@ static bool_ quest_shroom_give_hook(void *, void *in_, void *) q_ptr->discount = 100; q_ptr->ident |= IDENT_STOREB; if (inven_carry_okay(q_ptr)) + { inven_carry(q_ptr, FALSE); + } else + { drop_near(q_ptr, 0, p_ptr->py, p_ptr->px); + } /* The sling of farmer maggot */ q_ptr = &forge; @@ -209,9 +232,11 @@ static bool_ quest_shroom_give_hook(void *, void *in_, void *) process_hooks_restart = TRUE; } else + { msg_format("Oh thank you, but you still have %d mushrooms to bring back!", cquest.data[1] - cquest.data[0]); + } - return TRUE; + return true; } static void check_dogs_alive(s32b m_idx) @@ -239,12 +264,15 @@ static void check_dogs_alive(s32b m_idx) } } -static bool_ quest_shroom_speak_hook(void *, void *in_, void *) +static bool quest_shroom_speak_hook(void *, void *in_, void *) { struct hook_mon_speak_in *in = static_cast<struct hook_mon_speak_in *>(in_); s32b m_idx = in->m_idx; - if (m_list[m_idx].r_idx != get_farmer_maggot()) return (FALSE); + if (m_list[m_idx].r_idx != get_farmer_maggot()) + { + return false; + } if (cquest.status == QUEST_STATUS_UNTAKEN) { @@ -255,16 +283,20 @@ static bool_ quest_shroom_speak_hook(void *, void *in_, void *) { check_dogs_alive(m_idx); } - return (TRUE); + + return true; } -static bool_ quest_shroom_chat_hook(void *, void *in_, void *) +static bool quest_shroom_chat_hook(void *, void *in_, void *) { struct hook_chat_in *in = static_cast<struct hook_chat_in *>(in_); s32b m_idx = in->m_idx; monster_type *m_ptr = &m_list[m_idx]; - if (m_ptr->r_idx != get_farmer_maggot()) return (FALSE); + if (m_ptr->r_idx != get_farmer_maggot()) + { + return false; + } if (cquest.status == QUEST_STATUS_UNTAKEN) { @@ -282,10 +314,10 @@ static bool_ quest_shroom_chat_hook(void *, void *in_, void *) check_dogs_alive(m_idx); } - return TRUE; + return true; } -bool_ quest_shroom_init_hook() +void quest_shroom_init_hook() { /* Get a number of 'shrooms */ if (!cquest.data[1]) @@ -312,5 +344,4 @@ bool_ quest_shroom_init_hook() add_hook_new(HOOK_WILD_GEN, quest_shroom_town_gen_hook, "shroom_town_gen", NULL); add_hook_new(HOOK_CHAT, quest_shroom_chat_hook, "shroom_chat", NULL); } - return (FALSE); } diff --git a/src/q_shroom.hpp b/src/q_shroom.hpp index f729e29e..4478aee2 100644 --- a/src/q_shroom.hpp +++ b/src/q_shroom.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_shroom_init_hook(); +void quest_shroom_init_hook(); diff --git a/src/q_spider.cc b/src/q_spider.cc index a39c60d5..a5fa3486 100644 --- a/src/q_spider.cc +++ b/src/q_spider.cc @@ -16,13 +16,16 @@ #define cquest (quest[QUEST_SPIDER]) -static bool_ quest_spider_gen_hook(void *, void *, void *) +static bool quest_spider_gen_hook(void *, void *, void *) { int x, y; int xstart = 2; int ystart = 2; - if (p_ptr->inside_quest != QUEST_SPIDER) return FALSE; + if (p_ptr->inside_quest != QUEST_SPIDER) + { + return false; + } /* Start with perm walls */ for (y = 0; y < cur_hgt; y++) @@ -43,14 +46,17 @@ static bool_ quest_spider_gen_hook(void *, void *, void *) init_flags = INIT_CREATE_DUNGEON; process_dungeon_file("spiders.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); - return TRUE; + return true; } -static bool_ quest_spider_death_hook(void *, void *, void *) +static bool quest_spider_death_hook(void *, void *, void *) { int i, mcnt = 0; - if (p_ptr->inside_quest != QUEST_SPIDER) return FALSE; + if (p_ptr->inside_quest != QUEST_SPIDER) + { + return false; + } for (i = m_max - 1; i >= 1; i--) { @@ -58,9 +64,15 @@ static bool_ quest_spider_death_hook(void *, void *, 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_ENEMY) mcnt++; + if (m_ptr->status <= MSTATUS_ENEMY) + { + mcnt++; + } } if (mcnt <= 1) @@ -79,19 +91,22 @@ static bool_ quest_spider_death_hook(void *, void *, void *) del_hook_new(HOOK_MONSTER_DEATH, quest_spider_death_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } - return (FALSE); + return false; } -static bool_ quest_spider_finish_hook(void *, void *in_, void *) +static bool quest_spider_finish_hook(void *, void *in_, void *) { struct hook_quest_finish_in *in = static_cast<struct hook_quest_finish_in *>(in_); object_type forge, *q_ptr; s32b q_idx = in->q_idx; - if (q_idx != QUEST_SPIDER) return FALSE; + if (q_idx != QUEST_SPIDER) + { + return false; + } c_put_str(TERM_YELLOW, "All of us praise your mighty deed in driving back the", 8, 0); c_put_str(TERM_YELLOW, "menace. Take this as a reward.", 9, 0); @@ -112,10 +127,10 @@ static bool_ quest_spider_finish_hook(void *, void *in_, void *) del_hook_new(HOOK_QUEST_FINISH, quest_spider_finish_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -bool_ quest_spider_init_hook() +void quest_spider_init_hook() { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -123,5 +138,4 @@ bool_ quest_spider_init_hook() add_hook_new(HOOK_GEN_QUEST, quest_spider_gen_hook, "spider_gen", NULL); add_hook_new(HOOK_QUEST_FINISH, quest_spider_finish_hook, "spider_finish", NULL); } - return (FALSE); } diff --git a/src/q_spider.hpp b/src/q_spider.hpp index d76cccf1..bd16c06a 100644 --- a/src/q_spider.hpp +++ b/src/q_spider.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_spider_init_hook(); +void quest_spider_init_hook(); diff --git a/src/q_thief.cc b/src/q_thief.cc index e471aeab..a4505d2a 100644 --- a/src/q_thief.cc +++ b/src/q_thief.cc @@ -22,18 +22,23 @@ #define cquest (quest[QUEST_THIEVES]) -static bool_ quest_thieves_gen_hook(void *, void *, void *) +static bool quest_thieves_gen_hook(void *, void *, void *) { int x, y; int xstart = 2; int ystart = 2; bool_ again = TRUE; - if (p_ptr->inside_quest != QUEST_THIEVES) return FALSE; + if (p_ptr->inside_quest != QUEST_THIEVES) + { + return false; + } /* Just in case we didnt talk the the mayor */ if (cquest.status == QUEST_STATUS_UNTAKEN) + { cquest.status = QUEST_STATUS_TAKEN; + } /* Start with perm walls */ for (y = 0; y < cur_hgt; y++) @@ -65,9 +70,15 @@ static bool_ quest_thieves_gen_hook(void *, void *, void *) { object_type *o_ptr = &p_ptr->inventory[x]; - if (!o_ptr->k_idx) continue; + if (!o_ptr->k_idx) + { + continue; + } - if ((x >= INVEN_WIELD) && cursed_p(o_ptr)) continue; + if ((x >= INVEN_WIELD) && cursed_p(o_ptr)) + { + continue; + } inven_drop(x, 99, 4, 24, TRUE); @@ -83,11 +94,14 @@ static bool_ quest_thieves_gen_hook(void *, void *, void *) return TRUE; } -static bool_ quest_thieves_hook(void *, void *, void *) +static bool quest_thieves_hook(void *, void *, void *) { int i, mcnt = 0; - if (p_ptr->inside_quest != QUEST_THIEVES) return FALSE; + if (p_ptr->inside_quest != QUEST_THIEVES) + { + return false; + } /* ALARM !!! */ if ((cave[17][22].feat == FEAT_OPEN) || @@ -132,19 +146,22 @@ static bool_ quest_thieves_hook(void *, void *, void *) process_hooks_restart = TRUE; cmsg_print(TERM_YELLOW, "You stopped the thieves and saved Bree!"); - return (FALSE); + return false; } - return FALSE; + return false; } -static bool_ quest_thieves_finish_hook(void *, void *in_, void *) +static bool quest_thieves_finish_hook(void *, void *in_, void *) { auto const &s_info = game->s_info; struct hook_quest_finish_in *in = static_cast<struct hook_quest_finish_in *>(in_); s32b q_idx = in->q_idx; - if (q_idx != QUEST_THIEVES) return FALSE; + if (q_idx != QUEST_THIEVES) + { + return false; + } c_put_str(TERM_YELLOW, "Thank you for killing the band of thieves!", 8, 0); c_put_str(TERM_YELLOW, "You can use the hideout as your house as a reward.", 9, 0); @@ -159,21 +176,28 @@ static bool_ quest_thieves_finish_hook(void *, void *in_, void *) else { if (s_info[SKILL_COMBAT].value > s_info[SKILL_MAGIC].value) + { *(quest[q_idx].plot) = QUEST_TROLL; + } else + { *(quest[q_idx].plot) = QUEST_WIGHT; + } } quest[*(quest[q_idx].plot)].init(); del_hook_new(HOOK_QUEST_FINISH, quest_thieves_finish_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_thieves_feeling_hook(void *, void *, void *) +static bool quest_thieves_feeling_hook(void *, void *, void *) { - if (p_ptr->inside_quest != QUEST_THIEVES) return FALSE; + if (p_ptr->inside_quest != QUEST_THIEVES) + { + return false; + } msg_print("You wake up in a prison cell."); msg_print("All your possessions have been stolen!"); @@ -181,10 +205,10 @@ static bool_ quest_thieves_feeling_hook(void *, void *, void *) del_hook_new(HOOK_FEELING, quest_thieves_feeling_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -bool_ quest_thieves_init_hook() +void quest_thieves_init_hook() { if ((cquest.status >= QUEST_STATUS_UNTAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -193,5 +217,4 @@ bool_ quest_thieves_init_hook() add_hook_new(HOOK_GEN_QUEST, quest_thieves_gen_hook, "thieves_geb", NULL); add_hook_new(HOOK_FEELING, quest_thieves_feeling_hook, "thieves_feel", NULL); } - return (FALSE); } diff --git a/src/q_thief.hpp b/src/q_thief.hpp index 1ff74fac..0e191db7 100644 --- a/src/q_thief.hpp +++ b/src/q_thief.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_thieves_init_hook(); +void quest_thieves_init_hook(); diff --git a/src/q_thrain.cc b/src/q_thrain.cc index 2ec46cda..025ff01f 100644 --- a/src/q_thrain.cc +++ b/src/q_thrain.cc @@ -30,33 +30,52 @@ GENERATE_MONSTER_LOOKUP_FN(get_thrain, "Thrain, the King Under the Mountain") GENERATE_MONSTER_LOOKUP_FN(get_dwar, "Dwar, Dog Lord of Waw") GENERATE_MONSTER_LOOKUP_FN(get_hoarmurath, "Hoarmurath of Dir") -static bool_ quest_thrain_death_hook(void *, void *in_, void *) +static bool quest_thrain_death_hook(void *, void *in_, void *) { struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_); s32b m_idx = in->m_idx; int r, x, y; monster_type *m_ptr; - if ((cquest.status >= QUEST_STATUS_FINISHED) || (dun_level !=cquest.data[0]) || (dungeon_type != DUNGEON_DOL_GULDUR)) return (FALSE); + if ((cquest.status >= QUEST_STATUS_FINISHED) || (dun_level !=cquest.data[0]) || (dungeon_type != DUNGEON_DOL_GULDUR)) + { + return false; + } + m_ptr = &m_list[m_idx]; - if ((m_ptr->r_idx != get_dwar()) && (m_ptr->r_idx != get_hoarmurath())) return (FALSE); + if ((m_ptr->r_idx != get_dwar()) && (m_ptr->r_idx != get_hoarmurath())) + { + return false; + } cquest.data[2]++; - if (cquest.data[2] < 2) return (FALSE); + if (cquest.data[2] < 2) + { + return false; + } cmsg_print(TERM_YELLOW, "The magic hiding the room dissipates."); for (x = 0; x < cur_wid; x++) + { for (y = 0; y < cur_hgt; y++) { cave_type *c_ptr = &cave[y][x]; - if (c_ptr->mimic != 61) continue; - if (!(c_ptr->info & CAVE_FREE)) continue; + if (c_ptr->mimic != 61) + { + continue; + } + + if (!(c_ptr->info & CAVE_FREE)) + { + continue; + } c_ptr->mimic = 0; lite_spot(y, x); } + } cquest.status = QUEST_STATUS_FINISHED; cmsg_print(TERM_YELLOW, "Thrain speaks:"); @@ -72,7 +91,10 @@ static bool_ quest_thrain_death_hook(void *, void *in_, void *) monster_type *m_ptr = &m_list[r]; /* Ignore "dead" monsters */ - if (!m_ptr->r_idx) continue; + if (!m_ptr->r_idx) + { + continue; + } /* Is it the princess? */ if (m_ptr->r_idx == get_thrain()) @@ -114,10 +136,10 @@ static bool_ quest_thrain_death_hook(void *, void *in_, void *) del_hook_new(HOOK_MONSTER_DEATH, quest_thrain_death_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } -static bool_ quest_thrain_gen_hook(void *, void *in_, void *) +static bool quest_thrain_gen_hook(void *, void *in_, void *) { struct hook_build_room1_in *in = static_cast<struct hook_build_room1_in *>(in_); s32b bx0 = in->x; @@ -128,16 +150,16 @@ static bool_ quest_thrain_gen_hook(void *, void *in_, void *) int y2, x2, yval, xval; int y1, x1, xsize, ysize; - if (dungeon_type != DUNGEON_DOL_GULDUR) return (FALSE); - if (cquest.data[0] != dun_level) return (FALSE); - if (cquest.data[1]) return (FALSE); - if ((cquest.status < QUEST_STATUS_TAKEN) || (cquest.status >= QUEST_STATUS_FINISHED)) return (FALSE); + if (dungeon_type != DUNGEON_DOL_GULDUR) return false; + if (cquest.data[0] != dun_level) return false; + if (cquest.data[1]) return false; + if ((cquest.status < QUEST_STATUS_TAKEN) || (cquest.status >= QUEST_STATUS_FINISHED)) return false; /* Pick a room size */ get_map_size("thrain.map", &ysize, &xsize); /* Try to allocate space for room. If fails, exit */ - if (!room_alloc(xsize + 2, ysize + 2, FALSE, by0, bx0, &xval, &yval)) return FALSE; + if (!room_alloc(xsize + 2, ysize + 2, FALSE, by0, bx0, &xval, &yval)) return false; /* Get corner values */ y1 = yval - ysize / 2; @@ -185,37 +207,38 @@ static bool_ quest_thrain_gen_hook(void *, void *in_, void *) /* Don't try another one for this generation */ cquest.data[1] = 1; - return (TRUE); + return true; } -static bool_ quest_thrain_feeling_hook(void *, void *, void *) +static bool quest_thrain_feeling_hook(void *, void *, void *) { - if (dungeon_type != DUNGEON_DOL_GULDUR) return (FALSE); - if (cquest.data[0] != dun_level) return (FALSE); - if (cquest.status != QUEST_STATUS_UNTAKEN) return (FALSE); + if (dungeon_type != DUNGEON_DOL_GULDUR) return false; + if (cquest.data[0] != dun_level) return false; + if (cquest.status != QUEST_STATUS_UNTAKEN) return false; cmsg_format(TERM_YELLOW, "You hear someone shouting under the torture."); cquest.status = QUEST_STATUS_TAKEN; cquest.init(); - return (FALSE); + return false; } -static bool_ quest_thrain_move_hook(void *, void *in_, void *) +static bool quest_thrain_move_hook(void *, void *in_, void *) { struct hook_move_in *in = static_cast<struct hook_move_in *>(in_); s32b y = in->y; s32b x = in->x; cave_type *c_ptr = &cave[y][x]; - if (dungeon_type != DUNGEON_DOL_GULDUR) return (FALSE); - if (cquest.data[0] != dun_level) return (FALSE); - if ((cquest.status < QUEST_STATUS_TAKEN) || (cquest.status >= QUEST_STATUS_FINISHED)) return (FALSE); - if (!(c_ptr->info & CAVE_FREE)) return (FALSE); - if (c_ptr->mimic != 61) return (FALSE); + if (dungeon_type != DUNGEON_DOL_GULDUR) return false; + if (cquest.data[0] != dun_level) return false; + if ((cquest.status < QUEST_STATUS_TAKEN) || (cquest.status >= QUEST_STATUS_FINISHED)) return false; + if (!(c_ptr->info & CAVE_FREE)) return false; + if (c_ptr->mimic != 61) return false; cmsg_print(TERM_YELLOW, "The magic hiding the room dissipates."); for (x = 0; x < cur_wid; x++) + { for (y = 0; y < cur_hgt; y++) { c_ptr = &cave[y][x]; @@ -226,18 +249,19 @@ static bool_ quest_thrain_move_hook(void *, void *in_, void *) c_ptr->mimic = 0; lite_spot(y, x); } + } - return (FALSE); + return false; } -static bool_ quest_thrain_turn_hook(void *, void *, void *) +static bool quest_thrain_turn_hook(void *, void *, void *) { cquest.data[1] = 0; cquest.data[2] = 0; - return (FALSE); + return false; } -bool_ quest_thrain_init_hook() +void quest_thrain_init_hook() { auto const &d_info = game->edit_data.d_info; @@ -261,5 +285,4 @@ bool_ quest_thrain_init_hook() add_hook_new(HOOK_FEELING, quest_thrain_feeling_hook, "thrain_feel", NULL); add_hook_new(HOOK_MONSTER_DEATH, quest_thrain_death_hook, "thrain_death", NULL); } - return (FALSE); } diff --git a/src/q_thrain.hpp b/src/q_thrain.hpp index 4e269357..aa42385d 100644 --- a/src/q_thrain.hpp +++ b/src/q_thrain.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_thrain_init_hook(); +void quest_thrain_init_hook(); diff --git a/src/q_troll.cc b/src/q_troll.cc index dfb5a867..54eb3406 100644 --- a/src/q_troll.cc +++ b/src/q_troll.cc @@ -26,7 +26,7 @@ GENERATE_MONSTER_LOOKUP_FN(get_tom, "Tom the Stone Troll") GENERATE_MONSTER_LOOKUP_FN(get_stone_troll, "Stone troll") GENERATE_MONSTER_LOOKUP_FN(get_forest_troll, "Forest troll") -static bool_ quest_troll_gen_hook(void *, void *, void *) +static bool quest_troll_gen_hook(void *, void *, void *) { auto &a_info = game->edit_data.a_info; @@ -34,7 +34,10 @@ static bool_ quest_troll_gen_hook(void *, void *, void *) int xstart = 2; int ystart = 2; - if (p_ptr->inside_quest != QUEST_TROLL) return FALSE; + if (p_ptr->inside_quest != QUEST_TROLL) + { + return false; + } /* Start with perm walls */ for (y = 0; y < cur_hgt; y++) @@ -113,15 +116,18 @@ static bool_ quest_troll_gen_hook(void *, void *, void *) /* Reinitialize the ambush ... hehehe */ cquest.data[0] = FALSE; - return TRUE; + return true; } -static bool_ quest_troll_finish_hook(void *, void *in_, void *) +static bool quest_troll_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; - if (q_idx != QUEST_TROLL) return FALSE; + if (q_idx != QUEST_TROLL) + { + return false; + } c_put_str(TERM_YELLOW, "I heard about your noble deeds.", 8, 0); c_put_str(TERM_YELLOW, "Keep what you found... may it serve you well.", 9, 0); @@ -133,17 +139,20 @@ static bool_ quest_troll_finish_hook(void *, void *in_, void *) del_hook_new(HOOK_QUEST_FINISH, quest_troll_finish_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_troll_death_hook(void *, void *in_, void *) +static bool quest_troll_death_hook(void *, void *in_, void *) { struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_); s32b m_idx = in->m_idx; s32b r_idx = m_list[m_idx].r_idx; int x, y, xstart = 2, ystart = 2; - if (p_ptr->inside_quest != QUEST_TROLL) return FALSE; + if (p_ptr->inside_quest != QUEST_TROLL) + { + return false; + } if (r_idx == get_tom()) { @@ -154,19 +163,23 @@ static bool_ quest_troll_death_hook(void *, void *in_, void *) cquest.status = QUEST_STATUS_COMPLETED; del_hook_new(HOOK_MONSTER_DEATH, quest_troll_death_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } init_flags = INIT_GET_SIZE; process_dungeon_file("trolls.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); - if (cquest.data[0]) return FALSE; + if (cquest.data[0]) + { + return false; + } cquest.data[0] = TRUE; msg_print("Oops, seems like an ambush..."); for (x = 3; x < xstart; x++) + { for (y = 3; y < ystart; y++) { cave_type *c_ptr = &cave[y][x]; @@ -181,11 +194,12 @@ static bool_ quest_troll_death_hook(void *, void *in_, void *) place_monster_one(y, x, r_idx, 0, FALSE, MSTATUS_ENEMY); } } + } - return FALSE; + return false; } -bool_ quest_troll_init_hook() +void quest_troll_init_hook() { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -193,5 +207,4 @@ bool_ quest_troll_init_hook() add_hook_new(HOOK_GEN_QUEST, quest_troll_gen_hook, "troll_gen", NULL); add_hook_new(HOOK_QUEST_FINISH, quest_troll_finish_hook, "troll_finish", NULL); } - return (FALSE); } diff --git a/src/q_troll.hpp b/src/q_troll.hpp index 4564ace2..08bba3dd 100644 --- a/src/q_troll.hpp +++ b/src/q_troll.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_troll_init_hook(); +void quest_troll_init_hook(); diff --git a/src/q_ultrae.cc b/src/q_ultrae.cc index de0d5f16..ff2a6a48 100644 --- a/src/q_ultrae.cc +++ b/src/q_ultrae.cc @@ -2,7 +2,7 @@ #define cquest (quest[QUEST_ULTRA_EVIL]) -bool_ quest_ultra_evil_init_hook() +void quest_ultra_evil_init_hook() { - return FALSE; + // Initialized by other hook. } diff --git a/src/q_ultrae.hpp b/src/q_ultrae.hpp index 42584387..77ec2e38 100644 --- a/src/q_ultrae.hpp +++ b/src/q_ultrae.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_ultra_evil_init_hook(); +void quest_ultra_evil_init_hook(); diff --git a/src/q_ultrag.cc b/src/q_ultrag.cc index 9e250146..e3da974f 100644 --- a/src/q_ultrag.cc +++ b/src/q_ultrag.cc @@ -20,7 +20,7 @@ #define cquest (quest[QUEST_ULTRA_GOOD]) -static bool_ quest_ultra_good_move_hook(void *, void *in_, void *) +static bool quest_ultra_good_move_hook(void *, void *in_, void *) { struct hook_move_in *in = static_cast<struct hook_move_in *>(in_); s32b y = in->y; @@ -29,10 +29,16 @@ static bool_ quest_ultra_good_move_hook(void *, void *in_, void *) if (cquest.status == QUEST_STATUS_UNTAKEN) { - if (quest[QUEST_MORGOTH].status < QUEST_STATUS_FINISHED) return (FALSE); + if (quest[QUEST_MORGOTH].status < QUEST_STATUS_FINISHED) + { + return false; + } /* The mirror of Galadriel */ - if ((c_ptr->feat != FEAT_SHOP) || (c_ptr->special != 23)) return (FALSE); + if ((c_ptr->feat != FEAT_SHOP) || (c_ptr->special != 23)) + { + return false; + } auto old_quick_messages = options->quick_messages; options->quick_messages = FALSE; @@ -85,33 +91,37 @@ static bool_ quest_ultra_good_move_hook(void *, void *in_, void *) options->quick_messages = old_quick_messages; - return TRUE; + return true; } - return FALSE; + return false; } -static bool_ quest_ultra_good_stair_hook(void *, void *in_, void *) +static bool quest_ultra_good_stair_hook(void *, void *in_, void *) { struct hook_stair_in *in = static_cast<struct hook_stair_in *>(in_); stairs_direction dir = in->direction; if (dungeon_type != DUNGEON_VOID) - return FALSE; + { + return false; + } /* Cant leave */ if ((dir == STAIRS_UP) && (dun_level == 128)) { cmsg_print(TERM_YELLOW, "The portal to Arda is now closed."); - return TRUE; + return true; } + /* there is no coming back */ if ((dir == STAIRS_UP) && (dun_level == 150)) { cmsg_print(TERM_YELLOW, "The barrier seems to be impenetrable from this side."); cmsg_print(TERM_YELLOW, "You will have to move on."); - return TRUE; + return true; } + /* Cant enter without the flame imperishable */ if ((dir == STAIRS_DOWN) && (dun_level == 149)) { @@ -123,7 +133,10 @@ static bool_ quest_ultra_good_stair_hook(void *, void *in_, void *) { object_type *o_ptr = get_object(i); - if (!o_ptr->k_idx) continue; + if (!o_ptr->k_idx) + { + continue; + } auto const flags = object_flags(o_ptr); @@ -148,19 +161,21 @@ static bool_ quest_ultra_good_stair_hook(void *, void *in_, void *) } } - return FALSE; + return false; } -static bool_ quest_ultra_good_recall_hook(void *, void *, void *) +static bool quest_ultra_good_recall_hook(void *, void *, void *) { if ((dungeon_type != DUNGEON_VOID) && (dungeon_type != DUNGEON_NETHER_REALM)) - return FALSE; + { + return false; + } cmsg_print(TERM_YELLOW, "You cannot recall. The portal to Arda is closed."); - return TRUE; + return true; } -static bool_ quest_ultra_good_death_hook(void *, void *in_, void *) +static bool quest_ultra_good_death_hook(void *, void *in_, void *) { struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_); s32b m_idx = in->m_idx; @@ -226,7 +241,10 @@ static bool_ quest_ultra_good_death_hook(void *, void *in_, void *) for (i = 0; i < INVEN_PACK; i++) { /* Skip non-objects */ - if (!p_ptr->inventory[i].k_idx) break; + if (!p_ptr->inventory[i].k_idx) + { + break; + } } /* Arg, no space ! */ if (i == INVEN_PACK) @@ -245,10 +263,11 @@ static bool_ quest_ultra_good_death_hook(void *, void *in_, void *) cmsg_format(TERM_VIOLET, "You feel the urge to pick up the Flame Imperishable."); inven_carry(q_ptr, FALSE); } - return (FALSE); + + return false; } -static bool_ quest_ultra_good_dump_hook(void *, void *in_, void *) +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; @@ -271,11 +290,12 @@ static bool_ quest_ultra_good_dump_hook(void *, void *in_, void *) } } } - return (FALSE); + + return false; } -bool_ quest_ultra_good_init_hook() +void quest_ultra_good_init_hook() { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -288,5 +308,4 @@ bool_ quest_ultra_good_init_hook() add_hook_new(HOOK_MOVE, quest_ultra_good_move_hook, "ultrag_move", NULL); } add_hook_new(HOOK_CHAR_DUMP, quest_ultra_good_dump_hook, "ultrag_dump", NULL); - return (FALSE); } diff --git a/src/q_ultrag.hpp b/src/q_ultrag.hpp index 32c4a1ae..cef81fa5 100644 --- a/src/q_ultrag.hpp +++ b/src/q_ultrag.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_ultra_good_init_hook(); +void quest_ultra_good_init_hook(); diff --git a/src/q_wight.cc b/src/q_wight.cc index f635ed29..ced87277 100644 --- a/src/q_wight.cc +++ b/src/q_wight.cc @@ -22,13 +22,16 @@ GENERATE_MONSTER_LOOKUP_FN(get_wight_king, "The Wight-King of the Barrow-downs") -static bool_ quest_wight_gen_hook(void *, void *, void *) +static bool quest_wight_gen_hook(void *, void *, void *) { int x, y; int xstart = 2; int ystart = 2; - if (p_ptr->inside_quest != QUEST_WIGHT) return FALSE; + if (p_ptr->inside_quest != QUEST_WIGHT) + { + return false; + } /* Start with perm walls */ for (y = 0; y < cur_hgt; y++) @@ -50,6 +53,7 @@ static bool_ quest_wight_gen_hook(void *, void *, void *) process_dungeon_file("wights.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, TRUE); for (x = 3; x < xstart; x++) + { for (y = 3; y < ystart; y++) { if (cave[y][x].feat == FEAT_MARKER) @@ -123,17 +127,21 @@ static bool_ quest_wight_gen_hook(void *, void *, void *) } } } + } - return TRUE; + return true; } -static bool_ quest_wight_death_hook(void *, void *in_, void *) +static bool quest_wight_death_hook(void *, void *in_, void *) { struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_); s32b m_idx = in->m_idx; s32b r_idx = m_list[m_idx].r_idx; - if (p_ptr->inside_quest != QUEST_WIGHT) return FALSE; + if (p_ptr->inside_quest != QUEST_WIGHT) + { + return false; + } if (r_idx == get_wight_king()) { @@ -147,18 +155,21 @@ static bool_ quest_wight_death_hook(void *, void *in_, void *) del_hook_new(HOOK_MONSTER_DEATH, quest_wight_death_hook); process_hooks_restart = TRUE; - return (FALSE); + return false; } - return (FALSE); + return false; } -static bool_ quest_wight_finish_hook(void *, void *in_, void *) +static bool quest_wight_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; - if (q_idx != QUEST_WIGHT) return FALSE; + if (q_idx != QUEST_WIGHT) + { + return false; + } c_put_str(TERM_YELLOW, "I heard about your noble deeds.", 8, 0); c_put_str(TERM_YELLOW, "Keep what you found .. may it serve you well.", 9, 0); @@ -170,10 +181,10 @@ static bool_ quest_wight_finish_hook(void *, void *in_, void *) del_hook_new(HOOK_QUEST_FINISH, quest_wight_finish_hook); process_hooks_restart = TRUE; - return TRUE; + return true; } -bool_ quest_wight_init_hook() +void quest_wight_init_hook() { if ((cquest.status >= QUEST_STATUS_TAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -181,5 +192,4 @@ bool_ quest_wight_init_hook() add_hook_new(HOOK_GEN_QUEST, quest_wight_gen_hook, "wight_gen", NULL); add_hook_new(HOOK_QUEST_FINISH, quest_wight_finish_hook, "wight_finish", NULL); } - return (FALSE); } diff --git a/src/q_wight.hpp b/src/q_wight.hpp index d3c0a912..16713332 100644 --- a/src/q_wight.hpp +++ b/src/q_wight.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_wight_init_hook(); +void quest_wight_init_hook(); diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 637003dc..0e811ce6 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -20,7 +20,7 @@ #define cquest (quest[QUEST_WOLVES]) -static bool_ quest_wolves_gen_hook(void *, void *, void *) +static bool quest_wolves_gen_hook(void *, void *, void *) { auto const &f_info = game->edit_data.f_info; @@ -28,11 +28,16 @@ static bool_ quest_wolves_gen_hook(void *, void *, void *) int xstart = 2; int ystart = 2; - if (p_ptr->inside_quest != QUEST_WOLVES) return FALSE; + if (p_ptr->inside_quest != QUEST_WOLVES) + { + return false; + } /* Just in case we didnt talk the the mayor */ if (cquest.status == QUEST_STATUS_UNTAKEN) + { cquest.status = QUEST_STATUS_TAKEN; + } /* Start with perm walls */ for (y = 0; y < cur_hgt; y++) @@ -85,14 +90,17 @@ static bool_ quest_wolves_gen_hook(void *, void *, void *) process_hooks_restart = TRUE; - return TRUE; + return true; } -static bool_ quest_wolves_death_hook(void *, void *, void *) +static bool quest_wolves_death_hook(void *, void *, void *) { int i, mcnt = 0; - if (p_ptr->inside_quest != QUEST_WOLVES) return FALSE; + if (p_ptr->inside_quest != QUEST_WOLVES) + { + return false; + } /* Process the monsters (backwards) */ for (i = m_max - 1; i >= 1; i--) @@ -116,17 +124,20 @@ static bool_ quest_wolves_death_hook(void *, void *, void *) process_hooks_restart = TRUE; cmsg_print(TERM_YELLOW, "Lothlorien is safer now."); - return (FALSE); + return false; } - return FALSE; + return false; } -static bool_ quest_wolves_finish_hook(void *, void *in_, void *) +static bool quest_wolves_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; - if (q_idx != QUEST_WOLVES) return FALSE; + if (q_idx != QUEST_WOLVES) + { + return false; + } c_put_str(TERM_YELLOW, "Thank you for killing the pack of wolves!", 8, 0); c_put_str(TERM_YELLOW, "You can use the hut as your house as a reward.", 9, 0); @@ -134,10 +145,10 @@ static bool_ quest_wolves_finish_hook(void *, void *in_, void *) /* Continue the plot */ *(quest[q_idx].plot) = QUEST_SPIDER; - return TRUE; + return true; } -bool_ quest_wolves_init_hook() +void quest_wolves_init_hook() { if ((cquest.status >= QUEST_STATUS_UNTAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { @@ -145,5 +156,4 @@ bool_ quest_wolves_init_hook() add_hook_new(HOOK_QUEST_FINISH, quest_wolves_finish_hook, "wolves_finish", NULL); add_hook_new(HOOK_GEN_QUEST, quest_wolves_gen_hook, "wolves_geb", NULL); } - return (FALSE); } diff --git a/src/q_wolves.hpp b/src/q_wolves.hpp index 27d9b0f3..c5596fc6 100644 --- a/src/q_wolves.hpp +++ b/src/q_wolves.hpp @@ -2,4 +2,4 @@ #include "h-basic.h" -bool_ quest_wolves_init_hook(); +void quest_wolves_init_hook(); diff --git a/src/quest_type.hpp b/src/quest_type.hpp index 267ba4d2..ae97af35 100644 --- a/src/quest_type.hpp +++ b/src/quest_type.hpp @@ -21,7 +21,7 @@ struct quest_type s16b *plot; /* Which plot does it belongs to? */ - bool_ (*init)(); /* Function that takes care of generating hardcoded quests */ + void (*init)(); /* Function that takes care of generating hardcoded quests */ s32b data[9]; /* Various datas used by the quests */ |