From cbef37bd5bfb938a2303ee3887520c08be85d8e8 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Mar 2013 17:10:10 +0100 Subject: Switch almost everything over to C++ --- src/q_wolves.cc | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 src/q_wolves.cc (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc new file mode 100644 index 00000000..5da28ee7 --- /dev/null +++ b/src/q_wolves.cc @@ -0,0 +1,132 @@ +#include "q_wolves.h" +#include "hooks.h" + +#define cquest (quest[QUEST_WOLVES]) + +static bool_ quest_wolves_gen_hook(const char *fmt) +{ + int x, y, i; + int xstart = 2; + int ystart = 2; + + 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++) + { + for (x = 0; x < cur_wid; x++) + { + cave_set_feat(y, x, FEAT_PERM_SOLID); + } + } + + dun_level = quest[p_ptr->inside_quest].level; + + /* Set the correct monster hook */ + set_mon_num_hook(); + + /* Prepare allocation table */ + get_mon_num_prep(); + + init_flags = INIT_CREATE_DUNGEON; + process_dungeon_file("wolves.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, FALSE); + dungeon_flags2 |= DF2_NO_GENO; + + /* Place some random wolves */ + for (i = damroll(4, 4); i > 0; ) + { + int m_idx, flags; + y = rand_int(21) + 3; + x = rand_int(31) + 3; + flags = f_info[cave[y][x].feat].flags1; + if (!(flags & FF1_PERMANENT) && (flags & FF1_FLOOR)) + { + m_idx = place_monster_one(y, x, 196, 0, magik(50), MSTATUS_ENEMY); + if (m_idx) m_list[m_idx].mflag |= MFLAG_QUEST; + --i; + } + } + + /* Place some random wargs */ + for (i = damroll(4, 4); i > 0; ) + { + int m_idx, flags; + y = rand_int(21) + 3; + x = rand_int(31) + 3; + flags = f_info[cave[y][x].feat].flags1; + if (!(flags & FF1_PERMANENT) && (flags & FF1_FLOOR)) + { + m_idx = place_monster_one(y, x, 257, 0, magik(50), MSTATUS_ENEMY); + if (m_idx) m_list[m_idx].mflag |= MFLAG_QUEST; + --i; + } + } + + process_hooks_restart = TRUE; + + return TRUE; +} + +static bool_ quest_wolves_death_hook(const char *fmt) +{ + int i, mcnt = 0; + + if (p_ptr->inside_quest != QUEST_WOLVES) return FALSE; + + /* Process the monsters (backwards) */ + for (i = m_max - 1; i >= 1; i--) + { + /* Access the monster */ + monster_type *m_ptr = &m_list[i]; + + /* Ignore "dead" monsters */ + if (!m_ptr->r_idx) continue; + + if (m_ptr->status <= MSTATUS_ENEMY) mcnt++; + } + + /* Nobody left ? */ + if (mcnt <= 1) + { + quest[p_ptr->inside_quest].status = QUEST_STATUS_COMPLETED; + del_hook(HOOK_MONSTER_DEATH, quest_wolves_death_hook); + del_hook(HOOK_GEN_QUEST, quest_wolves_gen_hook); + process_hooks_restart = TRUE; + + cmsg_print(TERM_YELLOW, "Lothlorien is safer now."); + return (FALSE); + } + return FALSE; +} + +static bool_ quest_wolves_finish_hook(const char *fmt) +{ + s32b q_idx; + + q_idx = get_next_arg(fmt); + + 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); + + /* Continue the plot */ + *(quest[q_idx].plot) = QUEST_SPIDER; + + return TRUE; +} + +bool_ quest_wolves_init_hook(int q_idx) +{ + if ((cquest.status >= QUEST_STATUS_UNTAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) + { + add_hook(HOOK_MONSTER_DEATH, quest_wolves_death_hook, "wolves_monster_death"); + add_hook(HOOK_QUEST_FINISH, quest_wolves_finish_hook, "wolves_finish"); + add_hook(HOOK_GEN_QUEST, quest_wolves_gen_hook, "wolves_geb"); + } + return (FALSE); +} -- cgit v1.2.3 From 3ba08796130deb101c2b5cf8c00b86a965b3de22 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Fri, 19 Dec 2014 00:24:43 +0100 Subject: Update HOOK_GEN_QUEST to new-style hook --- src/q_wolves.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 5da28ee7..75a50aff 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -3,7 +3,7 @@ #define cquest (quest[QUEST_WOLVES]) -static bool_ quest_wolves_gen_hook(const char *fmt) +static bool_ quest_wolves_gen_hook(void *, void *, void *) { int x, y, i; int xstart = 2; @@ -93,8 +93,9 @@ static bool_ quest_wolves_death_hook(const char *fmt) if (mcnt <= 1) { quest[p_ptr->inside_quest].status = QUEST_STATUS_COMPLETED; - del_hook(HOOK_MONSTER_DEATH, quest_wolves_death_hook); - del_hook(HOOK_GEN_QUEST, quest_wolves_gen_hook); + + del_hook (HOOK_MONSTER_DEATH, quest_wolves_death_hook); + del_hook_new(HOOK_GEN_QUEST, quest_wolves_gen_hook); process_hooks_restart = TRUE; cmsg_print(TERM_YELLOW, "Lothlorien is safer now."); @@ -124,9 +125,9 @@ bool_ quest_wolves_init_hook(int q_idx) { if ((cquest.status >= QUEST_STATUS_UNTAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { - add_hook(HOOK_MONSTER_DEATH, quest_wolves_death_hook, "wolves_monster_death"); - add_hook(HOOK_QUEST_FINISH, quest_wolves_finish_hook, "wolves_finish"); - add_hook(HOOK_GEN_QUEST, quest_wolves_gen_hook, "wolves_geb"); + add_hook (HOOK_MONSTER_DEATH, quest_wolves_death_hook, "wolves_monster_death"); + add_hook (HOOK_QUEST_FINISH, quest_wolves_finish_hook, "wolves_finish"); + add_hook_new(HOOK_GEN_QUEST, quest_wolves_gen_hook, "wolves_geb", NULL); } return (FALSE); } -- cgit v1.2.3 From 0ff3645a99ce2ba66e8309c0d34d7a7b2ad5ef51 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Fri, 19 Dec 2014 01:02:33 +0100 Subject: Update HOOK_MONSTER_DEATH to new-style hook --- src/q_wolves.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 75a50aff..ef3c22ec 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -71,7 +71,7 @@ static bool_ quest_wolves_gen_hook(void *, void *, void *) return TRUE; } -static bool_ quest_wolves_death_hook(const char *fmt) +static bool_ quest_wolves_death_hook(void *, void *, void *) { int i, mcnt = 0; @@ -94,7 +94,7 @@ static bool_ quest_wolves_death_hook(const char *fmt) { quest[p_ptr->inside_quest].status = QUEST_STATUS_COMPLETED; - del_hook (HOOK_MONSTER_DEATH, quest_wolves_death_hook); + del_hook_new(HOOK_MONSTER_DEATH, quest_wolves_death_hook); del_hook_new(HOOK_GEN_QUEST, quest_wolves_gen_hook); process_hooks_restart = TRUE; @@ -125,7 +125,7 @@ bool_ quest_wolves_init_hook(int q_idx) { if ((cquest.status >= QUEST_STATUS_UNTAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { - add_hook (HOOK_MONSTER_DEATH, quest_wolves_death_hook, "wolves_monster_death"); + add_hook_new(HOOK_MONSTER_DEATH, quest_wolves_death_hook, "wolves_monster_death", NULL); add_hook (HOOK_QUEST_FINISH, quest_wolves_finish_hook, "wolves_finish"); add_hook_new(HOOK_GEN_QUEST, quest_wolves_gen_hook, "wolves_geb", NULL); } -- cgit v1.2.3 From cbc0dcecffb9cf29708b1c1c4e60df49a1994add Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 21 Dec 2014 15:27:44 +0100 Subject: Update HOOK_QUEST_FINISH to new-style hook --- src/q_wolves.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index ef3c22ec..1afa0fb8 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -104,11 +104,10 @@ static bool_ quest_wolves_death_hook(void *, void *, void *) return FALSE; } -static bool_ quest_wolves_finish_hook(const char *fmt) +static bool_ quest_wolves_finish_hook(void *, void *in_, void *) { - s32b q_idx; - - q_idx = get_next_arg(fmt); + struct hook_quest_finish_in *in = static_cast(in_); + s32b q_idx = in->q_idx; if (q_idx != QUEST_WOLVES) return FALSE; @@ -126,8 +125,8 @@ bool_ quest_wolves_init_hook(int q_idx) if ((cquest.status >= QUEST_STATUS_UNTAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) { add_hook_new(HOOK_MONSTER_DEATH, quest_wolves_death_hook, "wolves_monster_death", NULL); - add_hook (HOOK_QUEST_FINISH, quest_wolves_finish_hook, "wolves_finish"); - add_hook_new(HOOK_GEN_QUEST, quest_wolves_gen_hook, "wolves_geb", NULL); + 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); } -- cgit v1.2.3 From fe6ebd4af16244a02e16eb095181c0d8d5c56858 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:12:00 +0100 Subject: Move cave.cc function declarations to separate header --- src/q_wolves.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 1afa0fb8..9a68c7ca 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -1,4 +1,6 @@ #include "q_wolves.h" + +#include "cave.hpp" #include "hooks.h" #define cquest (quest[QUEST_WOLVES]) -- cgit v1.2.3 From 37ac44add61e4547507770017dcb85b53c20acb5 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:12:01 +0100 Subject: Split util.cc function declarations into separate header files We need one .h file and one .hpp since some of the functions are being called from plain C code. --- src/q_wolves.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 9a68c7ca..2afa173e 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -2,6 +2,7 @@ #include "cave.hpp" #include "hooks.h" +#include "util.hpp" #define cquest (quest[QUEST_WOLVES]) -- cgit v1.2.3 From d379c47aaec011921c1d09140ee1098a7053b5b6 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 7 Mar 2015 16:55:40 +0100 Subject: Split monster2.cc declarations into separate header --- src/q_wolves.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 2afa173e..190d774e 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -2,6 +2,7 @@ #include "cave.hpp" #include "hooks.h" +#include "monster2.hpp" #include "util.hpp" #define cquest (quest[QUEST_WOLVES]) -- cgit v1.2.3 From 5fbaba97d2613e30671a447a10093c4fd9df2e96 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 7 Mar 2015 16:55:41 +0100 Subject: Split init1.cc declarations into separate header file --- src/q_wolves.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 190d774e..b1d325cf 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -2,6 +2,7 @@ #include "cave.hpp" #include "hooks.h" +#include "init1.hpp" #include "monster2.hpp" #include "util.hpp" -- cgit v1.2.3 From f93c700dc8320da438ad46b59b2541e29d9b6d68 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 7 Mar 2015 16:55:42 +0100 Subject: Split tables.cc declarations into separate header files --- src/q_wolves.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index b1d325cf..5ab28fb0 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -4,6 +4,7 @@ #include "hooks.h" #include "init1.hpp" #include "monster2.hpp" +#include "tables.hpp" #include "util.hpp" #define cquest (quest[QUEST_WOLVES]) -- cgit v1.2.3 From 6f612c6e6cf9b20c00fd2f515d3694d2b7f7f444 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 7 Mar 2015 16:55:42 +0100 Subject: Split variables.cc declarations to separate header files - Can now remove externs.h. Yay! - Put a stray option variable into its rightful place in options.hpp --- src/q_wolves.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 5ab28fb0..2585a449 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -6,6 +6,7 @@ #include "monster2.hpp" #include "tables.hpp" #include "util.hpp" +#include "variable.hpp" #define cquest (quest[QUEST_WOLVES]) -- cgit v1.2.3 From f498e18ca748427db1de1bf0301df5113e4f5ba2 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 22 Mar 2015 14:23:30 +0100 Subject: Rename q_*.h headers to *.hpp and remove "extern C" wrappers --- src/q_wolves.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 2585a449..b6f9d8e2 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -1,4 +1,4 @@ -#include "q_wolves.h" +#include "q_wolves.hpp" #include "cave.hpp" #include "hooks.h" -- cgit v1.2.3 From c17c9486a22ce9f2160b2d2ad559d9a19e453f83 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 22 Mar 2015 15:22:02 +0100 Subject: Rename miscellaneous .h headers to .hpp --- src/q_wolves.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index b6f9d8e2..2270f498 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -1,7 +1,7 @@ #include "q_wolves.hpp" #include "cave.hpp" -#include "hooks.h" +#include "hooks.hpp" #include "init1.hpp" #include "monster2.hpp" #include "tables.hpp" -- cgit v1.2.3 From c8a270e51dc22f39ed048ab1cc609e6e456df58f Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 7 Jun 2015 17:49:09 +0200 Subject: Split types.h into separate header for each type --- src/q_wolves.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 2270f498..117e8d42 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -1,9 +1,15 @@ #include "q_wolves.hpp" #include "cave.hpp" +#include "cave_type.hpp" +#include "feature_type.hpp" +#include "hook_quest_finish_in.hpp" #include "hooks.hpp" #include "init1.hpp" #include "monster2.hpp" +#include "monster_type.hpp" +#include "player_type.hpp" +#include "quest_type.hpp" #include "tables.hpp" #include "util.hpp" #include "variable.hpp" -- cgit v1.2.3 From 97bcf1bc612d9920390c885b8dcea0b0cda6f246 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Fri, 11 Dec 2015 08:09:30 +0100 Subject: Migrate z-rand.c to C++ - Include explicitly instead of via angband.h - Change to regular functions instead of macros. --- src/q_wolves.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/q_wolves.cc') diff --git a/src/q_wolves.cc b/src/q_wolves.cc index 117e8d42..c5863b59 100644 --- a/src/q_wolves.cc +++ b/src/q_wolves.cc @@ -13,6 +13,7 @@ #include "tables.hpp" #include "util.hpp" #include "variable.hpp" +#include "z-rand.hpp" #define cquest (quest[QUEST_WOLVES]) -- cgit v1.2.3