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_main.cc | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 src/q_main.cc (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc new file mode 100644 index 00000000..f0e6214e --- /dev/null +++ b/src/q_main.cc @@ -0,0 +1,193 @@ +#include "q_main.h" +#include "hooks.h" + +static void quest_describe(int q_idx) +{ + int i = 0; + + while ((i < 10) && (quest[q_idx].desc[i][0] != '\0')) + { + cmsg_print(TERM_YELLOW, quest[q_idx].desc[i++]); + } +} + +static bool_ quest_main_monsters_hook(const char *fmt) +{ + s32b r_idx; + r_idx = get_next_arg(fmt); + + /* Sauron */ + if (r_idx == 860) + { + /* No Sauron until Necromancer dies */ + if (r_info[819].max_num) return TRUE; + } + /* Morgoth */ + else if (r_idx == 862) + { + /* No Morgoth until Sauron dies */ + if (r_info[860].max_num) return TRUE; + } + return FALSE; +} + +static bool_ quest_morgoth_hook(const char *fmt) +{ + /* Using test_monster_name() here would be a lot less ugly, but would take much more time */ + monster_race *r_ptr = &r_info[862]; + + /* Need to kill him */ + if (!r_ptr->max_num) + { + /* Total winner */ + total_winner = WINNER_NORMAL; + has_won = WINNER_NORMAL; + quest[QUEST_MORGOTH].status = QUEST_STATUS_FINISHED; + + /* Redraw the "title" */ + p_ptr->redraw |= (PR_TITLE); + + /* Congratulations */ + if (quest[QUEST_ONE].status == QUEST_STATUS_FINISHED) + { + cmsg_print(TERM_L_GREEN, "*** CONGRATULATIONS ***"); + cmsg_print(TERM_L_GREEN, "You have banished Morgoth's foul spirit from Ea, and as you watch, a cleansing"); + cmsg_print(TERM_L_GREEN, "wind roars through the dungeon, dispersing the nether mists around where the"); + cmsg_print(TERM_L_GREEN, "body fell. You feel thanks, and a touch of sorrow, from the Valar"); + cmsg_print(TERM_L_GREEN, "for your deed. You will be forever heralded, your deed forever legendary."); + cmsg_print(TERM_L_GREEN, "You may retire (commit suicide) when you are ready."); + } + else + { + cmsg_print(TERM_VIOLET, "*** CONGRATULATIONS ***"); + cmsg_print(TERM_VIOLET, "You have banished Morgoth from Arda, and made Ea a safer place."); + cmsg_print(TERM_VIOLET, "As you look down at the dispersing mists around Morgoth, a sudden intuition"); + cmsg_print(TERM_VIOLET, "grasps you. Fingering the One Ring, you gather the nether mists around"); + cmsg_print(TERM_VIOLET, "yourself, and inhale deeply their seductive power."); + cmsg_print(TERM_VIOLET, "You will be forever feared, your orders forever obeyed."); + cmsg_print(TERM_VIOLET, "You may retire (commit suicide) when you are ready."); + } + + /* Continue the plot(maybe) */ + del_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook); + process_hooks_restart = TRUE; + + /* Either ultra good if the one Ring is destroyed, or ultra evil if used */ + if (quest[QUEST_ONE].status == QUEST_STATUS_FINISHED) + *(quest[QUEST_MORGOTH].plot) = QUEST_ULTRA_GOOD; + else + *(quest[QUEST_MORGOTH].plot) = QUEST_ULTRA_EVIL; + quest[*(quest[QUEST_MORGOTH].plot)].init(*(quest[QUEST_MORGOTH].plot)); + } + return (FALSE); +} + +static bool_ quest_morgoth_dump_hook(const char *fmt) +{ + if (quest[QUEST_MORGOTH].status >= QUEST_STATUS_COMPLETED) + { + if (quest[QUEST_ONE].status == QUEST_STATUS_FINISHED) + fprintf(hook_file, "\n You saved Arda and became a famed %s.", sp_ptr->winner); + else + fprintf(hook_file, "\n You became a new force of darkness and enslaved all free people."); + } + return (FALSE); +} + +bool_ quest_morgoth_init_hook(int q_idx) +{ + if ((quest[QUEST_MORGOTH].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_MORGOTH].status < QUEST_STATUS_FINISHED)) + { + add_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death"); + } + add_hook(HOOK_CHAR_DUMP, quest_morgoth_dump_hook, "morgoth_dump"); + add_hook(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster"); + return (FALSE); +} + +static bool_ quest_sauron_hook(const char *fmt) +{ + /* Using test_monster_name() here would be a lot less ugly, but would take much more time */ + monster_race *r_ptr = &r_info[860]; + + /* Need to kill him */ + if (!r_ptr->max_num) + { + cmsg_print(TERM_YELLOW, "Well done! You are on the way to slaying Morgoth..."); + quest[QUEST_SAURON].status = QUEST_STATUS_FINISHED; + + quest[QUEST_MORGOTH].status = QUEST_STATUS_TAKEN; + quest_describe(QUEST_MORGOTH); + + del_hook(HOOK_MONSTER_DEATH, quest_sauron_hook); + add_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death"); + *(quest[QUEST_SAURON].plot) = QUEST_MORGOTH; + quest_morgoth_init_hook(QUEST_MORGOTH); + + process_hooks_restart = TRUE; + } + return (FALSE); +} + +static bool_ quest_sauron_resurect_hook(const char *fmt) +{ + s32b m_idx = get_next_arg(fmt); + monster_type *m_ptr = &m_list[m_idx]; + monster_race *r_ptr = &r_info[m_ptr->r_idx]; + + if ((r_ptr->flags7 & RF7_NAZGUL) && r_info[860].max_num) + { + msg_format("Somehow you feel %s is not totally destroyed...", (r_ptr->flags1 & RF1_FEMALE ? "she" : "he")); + r_ptr->max_num = 1; + } + else if ((m_ptr->r_idx == 860) && (quest[QUEST_ONE].status < QUEST_STATUS_FINISHED)) + { + msg_print("Sauron will not be permanently defeated until the One Ring is either destroyed or used..."); + r_ptr->max_num = 1; + } + return FALSE; +} + +bool_ quest_sauron_init_hook(int q_idx) +{ + if ((quest[QUEST_SAURON].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_SAURON].status < QUEST_STATUS_FINISHED)) + { + add_hook(HOOK_MONSTER_DEATH, quest_sauron_hook, "sauron_death"); + } + add_hook(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster"); + add_hook(HOOK_MONSTER_DEATH, quest_sauron_resurect_hook, "sauron_resurect_death"); + return (FALSE); +} + +static bool_ quest_necro_hook(const char *fmt) +{ + /* Using test_monster_name() here would be a lot less ugly, but would take much more time */ + monster_race *r_ptr = &r_info[819]; + + /* Need to kill him */ + if (!r_ptr->max_num) + { + cmsg_print(TERM_YELLOW, "You see the spirit of the necromancer rise and flee..."); + cmsg_print(TERM_YELLOW, "It looks like it was indeed Sauron..."); + cmsg_print(TERM_YELLOW, "You should report that to Galadriel as soon as possible."); + + quest[QUEST_NECRO].status = QUEST_STATUS_FINISHED; + + *(quest[QUEST_NECRO].plot) = QUEST_ONE; + quest[*(quest[QUEST_NECRO].plot)].init(*(quest[QUEST_NECRO].plot)); + + del_hook(HOOK_MONSTER_DEATH, quest_necro_hook); + process_hooks_restart = TRUE; + } + return (FALSE); +} + +bool_ quest_necro_init_hook(int q_idx) +{ + if ((quest[QUEST_NECRO].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_NECRO].status < QUEST_STATUS_FINISHED)) + { + add_hook(HOOK_MONSTER_DEATH, quest_necro_hook, "necro_death"); + } + add_hook(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster"); + return (FALSE); +} -- cgit v1.2.1 From ca71ccff098e4eec97480d2a08773a06629cc66e Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Thu, 26 Jun 2014 06:50:06 +0200 Subject: Simplify PR_* redraw code and remove direct references to Term members --- src/q_main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index f0e6214e..3e4e569f 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -45,7 +45,7 @@ static bool_ quest_morgoth_hook(const char *fmt) quest[QUEST_MORGOTH].status = QUEST_STATUS_FINISHED; /* Redraw the "title" */ - p_ptr->redraw |= (PR_TITLE); + p_ptr->redraw |= (PR_FRAME); /* Congratulations */ if (quest[QUEST_ONE].status == QUEST_STATUS_FINISHED) -- cgit v1.2.1 From 666ce02020925a67386429b451d23071521d6da8 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Thu, 18 Dec 2014 22:28:59 +0100 Subject: Update HOOK_CHAR_DUMP to new-style hook --- src/q_main.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 3e4e569f..17651da2 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -82,14 +82,17 @@ static bool_ quest_morgoth_hook(const char *fmt) return (FALSE); } -static bool_ quest_morgoth_dump_hook(const char *fmt) +static bool_ quest_morgoth_dump_hook(void *, void *in_, void *) { + struct hook_chardump_in *in = static_cast(in_); + FILE *f = in->file; + if (quest[QUEST_MORGOTH].status >= QUEST_STATUS_COMPLETED) { if (quest[QUEST_ONE].status == QUEST_STATUS_FINISHED) - fprintf(hook_file, "\n You saved Arda and became a famed %s.", sp_ptr->winner); + fprintf(f, "\n You saved Arda and became a famed %s.", sp_ptr->winner); else - fprintf(hook_file, "\n You became a new force of darkness and enslaved all free people."); + fprintf(f, "\n You became a new force of darkness and enslaved all free people."); } return (FALSE); } @@ -100,8 +103,8 @@ bool_ quest_morgoth_init_hook(int q_idx) { add_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death"); } - add_hook(HOOK_CHAR_DUMP, quest_morgoth_dump_hook, "morgoth_dump"); - add_hook(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster"); + add_hook_new(HOOK_CHAR_DUMP, quest_morgoth_dump_hook, "morgoth_dump", NULL); + add_hook (HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster"); return (FALSE); } -- cgit v1.2.1 From f7840bdcc6490388bc8d99afab2ab36ba85cfe45 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Thu, 18 Dec 2014 22:52:04 +0100 Subject: Update HOOK_NEW_MONSTER to new-style hook --- src/q_main.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 17651da2..0efd41c9 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -11,10 +11,10 @@ static void quest_describe(int q_idx) } } -static bool_ quest_main_monsters_hook(const char *fmt) +static bool_ quest_main_monsters_hook(void *, void *in_, void *) { - s32b r_idx; - r_idx = get_next_arg(fmt); + struct hook_new_monster_in *in = static_cast(in_); + s32b r_idx = in->r_idx; /* Sauron */ if (r_idx == 860) @@ -103,8 +103,8 @@ bool_ quest_morgoth_init_hook(int q_idx) { add_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death"); } - add_hook_new(HOOK_CHAR_DUMP, quest_morgoth_dump_hook, "morgoth_dump", NULL); - add_hook (HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster"); + 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); } @@ -157,8 +157,8 @@ bool_ quest_sauron_init_hook(int q_idx) { add_hook(HOOK_MONSTER_DEATH, quest_sauron_hook, "sauron_death"); } - add_hook(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster"); - add_hook(HOOK_MONSTER_DEATH, quest_sauron_resurect_hook, "sauron_resurect_death"); + add_hook_new(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster", NULL); + add_hook (HOOK_MONSTER_DEATH, quest_sauron_resurect_hook, "sauron_resurect_death"); return (FALSE); } @@ -191,6 +191,6 @@ bool_ quest_necro_init_hook(int q_idx) { add_hook(HOOK_MONSTER_DEATH, quest_necro_hook, "necro_death"); } - add_hook(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster"); + add_hook_new(HOOK_NEW_MONSTER, quest_main_monsters_hook, "main_new_monster", NULL); return (FALSE); } -- cgit v1.2.1 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_main.cc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 0efd41c9..0b6d19e2 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -31,7 +31,7 @@ static bool_ quest_main_monsters_hook(void *, void *in_, void *) return FALSE; } -static bool_ quest_morgoth_hook(const char *fmt) +static bool_ quest_morgoth_hook(void *, void *, void *) { /* Using test_monster_name() here would be a lot less ugly, but would take much more time */ monster_race *r_ptr = &r_info[862]; @@ -69,7 +69,7 @@ static bool_ quest_morgoth_hook(const char *fmt) } /* Continue the plot(maybe) */ - del_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook); + del_hook_new(HOOK_MONSTER_DEATH, quest_morgoth_hook); process_hooks_restart = TRUE; /* Either ultra good if the one Ring is destroyed, or ultra evil if used */ @@ -101,14 +101,14 @@ bool_ quest_morgoth_init_hook(int q_idx) { if ((quest[QUEST_MORGOTH].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_MORGOTH].status < QUEST_STATUS_FINISHED)) { - add_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death"); + add_hook_new(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgoth_death", NULL); } 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(const char *fmt) +static bool_ quest_sauron_hook(void *, void *, void *) { /* Using test_monster_name() here would be a lot less ugly, but would take much more time */ monster_race *r_ptr = &r_info[860]; @@ -122,8 +122,8 @@ static bool_ quest_sauron_hook(const char *fmt) quest[QUEST_MORGOTH].status = QUEST_STATUS_TAKEN; quest_describe(QUEST_MORGOTH); - del_hook(HOOK_MONSTER_DEATH, quest_sauron_hook); - add_hook(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death"); + del_hook_new(HOOK_MONSTER_DEATH, quest_sauron_hook); + add_hook_new(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death", NULL); *(quest[QUEST_SAURON].plot) = QUEST_MORGOTH; quest_morgoth_init_hook(QUEST_MORGOTH); @@ -132,9 +132,10 @@ static bool_ quest_sauron_hook(const char *fmt) return (FALSE); } -static bool_ quest_sauron_resurect_hook(const char *fmt) +static bool_ quest_sauron_resurect_hook(void *, void *in_, void *) { - s32b m_idx = get_next_arg(fmt); + struct hook_monster_death_in *in = static_cast(in_); + s32b m_idx = in->m_idx; monster_type *m_ptr = &m_list[m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; @@ -155,14 +156,14 @@ bool_ quest_sauron_init_hook(int q_idx) { if ((quest[QUEST_SAURON].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_SAURON].status < QUEST_STATUS_FINISHED)) { - add_hook(HOOK_MONSTER_DEATH, quest_sauron_hook, "sauron_death"); + 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 (HOOK_MONSTER_DEATH, quest_sauron_resurect_hook, "sauron_resurect_death"); + 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); } -static bool_ quest_necro_hook(const char *fmt) +static bool_ quest_necro_hook(void *, void *, void *) { /* Using test_monster_name() here would be a lot less ugly, but would take much more time */ monster_race *r_ptr = &r_info[819]; @@ -179,7 +180,7 @@ static bool_ quest_necro_hook(const char *fmt) *(quest[QUEST_NECRO].plot) = QUEST_ONE; quest[*(quest[QUEST_NECRO].plot)].init(*(quest[QUEST_NECRO].plot)); - del_hook(HOOK_MONSTER_DEATH, quest_necro_hook); + del_hook_new(HOOK_MONSTER_DEATH, quest_necro_hook); process_hooks_restart = TRUE; } return (FALSE); @@ -189,7 +190,7 @@ bool_ quest_necro_init_hook(int q_idx) { if ((quest[QUEST_NECRO].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_NECRO].status < QUEST_STATUS_FINISHED)) { - add_hook(HOOK_MONSTER_DEATH, quest_necro_hook, "necro_death"); + 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); -- cgit v1.2.1 From 987fe8afd5245232ef347ad2e1559bf36fd12d44 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:11:57 +0100 Subject: Reduce ridiculous number of test_monster_name usages --- src/q_main.cc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 0b6d19e2..73969f1a 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -1,5 +1,10 @@ #include "q_main.h" #include "hooks.h" +#include + +GENERATE_MONSTER_LOOKUP_FN(get_necromancer, "The Necromancer of Dol Guldur") +GENERATE_MONSTER_LOOKUP_FN(get_sauron, "Sauron, the Sorcerer") +GENERATE_MONSTER_LOOKUP_FN(get_morgoth, "Morgoth, Lord of Darkness") static void quest_describe(int q_idx) { @@ -17,24 +22,23 @@ static bool_ quest_main_monsters_hook(void *, void *in_, void *) s32b r_idx = in->r_idx; /* Sauron */ - if (r_idx == 860) + if (r_idx == get_sauron()) { /* No Sauron until Necromancer dies */ - if (r_info[819].max_num) return TRUE; + if (r_info[get_necromancer()].max_num) return TRUE; } /* Morgoth */ - else if (r_idx == 862) + else if (r_idx == get_morgoth()) { /* No Morgoth until Sauron dies */ - if (r_info[860].max_num) return TRUE; + if (r_info[get_sauron()].max_num) return TRUE; } return FALSE; } static bool_ quest_morgoth_hook(void *, void *, void *) { - /* Using test_monster_name() here would be a lot less ugly, but would take much more time */ - monster_race *r_ptr = &r_info[862]; + monster_race *r_ptr = &r_info[get_morgoth()]; /* Need to kill him */ if (!r_ptr->max_num) @@ -110,8 +114,7 @@ bool_ quest_morgoth_init_hook(int q_idx) static bool_ quest_sauron_hook(void *, void *, void *) { - /* Using test_monster_name() here would be a lot less ugly, but would take much more time */ - monster_race *r_ptr = &r_info[860]; + monster_race *r_ptr = &r_info[get_sauron()]; /* Need to kill him */ if (!r_ptr->max_num) @@ -139,12 +142,12 @@ static bool_ quest_sauron_resurect_hook(void *, void *in_, void *) monster_type *m_ptr = &m_list[m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; - if ((r_ptr->flags7 & RF7_NAZGUL) && r_info[860].max_num) + if ((r_ptr->flags7 & RF7_NAZGUL) && r_info[get_sauron()].max_num) { msg_format("Somehow you feel %s is not totally destroyed...", (r_ptr->flags1 & RF1_FEMALE ? "she" : "he")); r_ptr->max_num = 1; } - else if ((m_ptr->r_idx == 860) && (quest[QUEST_ONE].status < QUEST_STATUS_FINISHED)) + else if ((m_ptr->r_idx == get_sauron()) && (quest[QUEST_ONE].status < QUEST_STATUS_FINISHED)) { msg_print("Sauron will not be permanently defeated until the One Ring is either destroyed or used..."); r_ptr->max_num = 1; @@ -165,8 +168,7 @@ bool_ quest_sauron_init_hook(int q_idx) static bool_ quest_necro_hook(void *, void *, void *) { - /* Using test_monster_name() here would be a lot less ugly, but would take much more time */ - monster_race *r_ptr = &r_info[819]; + monster_race *r_ptr = &r_info[get_necromancer()]; /* Need to kill him */ if (!r_ptr->max_num) -- cgit v1.2.1 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_main.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 73969f1a..866e7ffa 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -1,5 +1,8 @@ #include "q_main.h" + #include "hooks.h" +#include "util.hpp" + #include GENERATE_MONSTER_LOOKUP_FN(get_necromancer, "The Necromancer of Dol Guldur") -- cgit v1.2.1 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_main.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 866e7ffa..3c105307 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -1,6 +1,7 @@ #include "q_main.h" #include "hooks.h" +#include "tables.hpp" #include "util.hpp" #include -- cgit v1.2.1 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_main.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 3c105307..a71ec15f 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -3,6 +3,7 @@ #include "hooks.h" #include "tables.hpp" #include "util.hpp" +#include "variable.hpp" #include -- cgit v1.2.1 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_main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index a71ec15f..45c50e9b 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -1,4 +1,4 @@ -#include "q_main.h" +#include "q_main.hpp" #include "hooks.h" #include "tables.hpp" -- cgit v1.2.1 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_main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 45c50e9b..27aa9ad6 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -1,6 +1,6 @@ #include "q_main.hpp" -#include "hooks.h" +#include "hooks.hpp" #include "tables.hpp" #include "util.hpp" #include "variable.hpp" -- cgit v1.2.1 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_main.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 27aa9ad6..ed11b9dc 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -1,6 +1,12 @@ #include "q_main.hpp" +#include "hook_chardump_in.hpp" +#include "hook_monster_death_in.hpp" +#include "hook_new_monster_in.hpp" #include "hooks.hpp" +#include "monster_race.hpp" +#include "monster_type.hpp" +#include "player_type.hpp" #include "tables.hpp" #include "util.hpp" #include "variable.hpp" -- cgit v1.2.1 From a343ccf6b05df1d889cb4302a3e9e21c4816c048 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Thu, 10 Mar 2016 18:41:54 +0100 Subject: Remove player gender, age, height, etc. --- src/q_main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index ed11b9dc..b81ba9b3 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -105,7 +105,7 @@ 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 %s.", sp_ptr->winner); + 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."); } -- cgit v1.2.1 From 68e2a10b2d76cb3a2f5aa6818b4b184b6a02ef14 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 20 Jun 2016 22:49:05 +0200 Subject: Rework RF{1,2,3,7,8,9}_* monster flags to use flag_set<> --- src/q_main.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index b81ba9b3..4cbf63ef 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -5,6 +5,7 @@ #include "hook_new_monster_in.hpp" #include "hooks.hpp" #include "monster_race.hpp" +#include "monster_race_flag.hpp" #include "monster_type.hpp" #include "player_type.hpp" #include "tables.hpp" @@ -153,9 +154,9 @@ static bool_ quest_sauron_resurect_hook(void *, void *in_, void *) monster_type *m_ptr = &m_list[m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; - if ((r_ptr->flags7 & RF7_NAZGUL) && r_info[get_sauron()].max_num) + if ((r_ptr->flags & RF_NAZGUL) && r_info[get_sauron()].max_num) { - msg_format("Somehow you feel %s is not totally destroyed...", (r_ptr->flags1 & RF1_FEMALE ? "she" : "he")); + msg_format("Somehow you feel %s is not totally destroyed...", (r_ptr->flags & RF_FEMALE ? "she" : "he")); r_ptr->max_num = 1; } else if ((m_ptr->r_idx == get_sauron()) && (quest[QUEST_ONE].status < QUEST_STATUS_FINISHED)) -- cgit v1.2.1 From d9d9d8c5e96eadbefb2c8506a387fc282c2fe8b5 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Remove unused "quest_idx" parameter from quest_type::init() --- src/q_main.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 4cbf63ef..81b6ac85 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -93,7 +93,7 @@ static bool_ quest_morgoth_hook(void *, void *, void *) *(quest[QUEST_MORGOTH].plot) = QUEST_ULTRA_GOOD; else *(quest[QUEST_MORGOTH].plot) = QUEST_ULTRA_EVIL; - quest[*(quest[QUEST_MORGOTH].plot)].init(*(quest[QUEST_MORGOTH].plot)); + quest[*(quest[QUEST_MORGOTH].plot)].init(); } return (FALSE); } @@ -113,7 +113,7 @@ static bool_ quest_morgoth_dump_hook(void *, void *in_, void *) return (FALSE); } -bool_ quest_morgoth_init_hook(int q_idx) +bool_ quest_morgoth_init_hook() { if ((quest[QUEST_MORGOTH].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_MORGOTH].status < QUEST_STATUS_FINISHED)) { @@ -140,7 +140,7 @@ static bool_ quest_sauron_hook(void *, void *, void *) del_hook_new(HOOK_MONSTER_DEATH, quest_sauron_hook); add_hook_new(HOOK_MONSTER_DEATH, quest_morgoth_hook, "morgort_death", NULL); *(quest[QUEST_SAURON].plot) = QUEST_MORGOTH; - quest_morgoth_init_hook(QUEST_MORGOTH); + quest_morgoth_init_hook(); process_hooks_restart = TRUE; } @@ -167,7 +167,7 @@ static bool_ quest_sauron_resurect_hook(void *, void *in_, void *) return FALSE; } -bool_ quest_sauron_init_hook(int q_idx) +bool_ quest_sauron_init_hook() { if ((quest[QUEST_SAURON].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_SAURON].status < QUEST_STATUS_FINISHED)) { @@ -192,7 +192,7 @@ static bool_ quest_necro_hook(void *, void *, void *) quest[QUEST_NECRO].status = QUEST_STATUS_FINISHED; *(quest[QUEST_NECRO].plot) = QUEST_ONE; - quest[*(quest[QUEST_NECRO].plot)].init(*(quest[QUEST_NECRO].plot)); + quest[*(quest[QUEST_NECRO].plot)].init(); del_hook_new(HOOK_MONSTER_DEATH, quest_necro_hook); process_hooks_restart = TRUE; @@ -200,7 +200,7 @@ static bool_ quest_necro_hook(void *, void *, void *) return (FALSE); } -bool_ quest_necro_init_hook(int q_idx) +bool_ quest_necro_init_hook() { if ((quest[QUEST_NECRO].status >= QUEST_STATUS_TAKEN) && (quest[QUEST_NECRO].status < QUEST_STATUS_FINISHED)) { -- cgit v1.2.1 From 0c2f30b56c221a826ba64f0ec864c29d0f717644 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Wed, 5 Oct 2016 18:45:08 +0200 Subject: Move r_info into GameEditData --- src/q_main.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/q_main.cc') diff --git a/src/q_main.cc b/src/q_main.cc index 81b6ac85..159d0f7b 100644 --- a/src/q_main.cc +++ b/src/q_main.cc @@ -1,5 +1,6 @@ #include "q_main.hpp" +#include "game.hpp" #include "hook_chardump_in.hpp" #include "hook_monster_death_in.hpp" #include "hook_new_monster_in.hpp" @@ -30,6 +31,8 @@ static void quest_describe(int q_idx) static bool_ quest_main_monsters_hook(void *, void *in_, void *) { + auto const &r_info = game->edit_data.r_info; + struct hook_new_monster_in *in = static_cast(in_); s32b r_idx = in->r_idx; @@ -50,7 +53,9 @@ static bool_ quest_main_monsters_hook(void *, void *in_, void *) static bool_ quest_morgoth_hook(void *, void *, void *) { - monster_race *r_ptr = &r_info[get_morgoth()]; + auto const &r_info = game->edit_data.r_info; + + auto r_ptr = &r_info[get_morgoth()]; /* Need to kill him */ if (!r_ptr->max_num) @@ -126,7 +131,9 @@ bool_ quest_morgoth_init_hook() static bool_ quest_sauron_hook(void *, void *, void *) { - monster_race *r_ptr = &r_info[get_sauron()]; + auto const &r_info = game->edit_data.r_info; + + auto r_ptr = &r_info[get_sauron()]; /* Need to kill him */ if (!r_ptr->max_num) @@ -149,10 +156,12 @@ static bool_ quest_sauron_hook(void *, void *, void *) static bool_ quest_sauron_resurect_hook(void *, void *in_, void *) { + auto &r_info = game->edit_data.r_info; + struct hook_monster_death_in *in = static_cast(in_); s32b m_idx = in->m_idx; monster_type *m_ptr = &m_list[m_idx]; - monster_race *r_ptr = &r_info[m_ptr->r_idx]; + auto r_ptr = &r_info[m_ptr->r_idx]; if ((r_ptr->flags & RF_NAZGUL) && r_info[get_sauron()].max_num) { @@ -180,7 +189,9 @@ bool_ quest_sauron_init_hook() static bool_ quest_necro_hook(void *, void *, void *) { - monster_race *r_ptr = &r_info[get_necromancer()]; + auto const &r_info = game->edit_data.r_info; + + auto r_ptr = &r_info[get_necromancer()]; /* Need to kill him */ if (!r_ptr->max_num) -- cgit v1.2.1 From fdb532aec5234db77a9111d219f8a870d660c4fc Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 2 May 2017 19:20:57 +0200 Subject: Change away from bool_ for hooks --- src/q_main.cc | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'src/q_main.cc') 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(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); } -- cgit v1.2.1