summaryrefslogtreecommitdiff
path: root/src/q_library.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/q_library.cc')
-rw-r--r--src/q_library.cc66
1 files changed, 27 insertions, 39 deletions
diff --git a/src/q_library.cc b/src/q_library.cc
index 52a67291..e267e2b7 100644
--- a/src/q_library.cc
+++ b/src/q_library.cc
@@ -1,13 +1,14 @@
#include "q_library.hpp"
#include "cave_type.hpp"
+#include "dungeon_flag.hpp"
+#include "game.hpp"
#include "hooks.hpp"
#include "lua_bind.hpp"
#include "monster2.hpp"
#include "monster_type.hpp"
#include "object2.hpp"
#include "player_type.hpp"
-#include "quark.hpp"
#include "spells3.hpp"
#include "spells4.hpp"
#include "tables.hpp"
@@ -18,11 +19,10 @@
#include "z-rand.hpp"
#include <cassert>
+#include <fmt/format.h>
#define cquest (quest[QUEST_LIBRARY])
-#define print_hook(fmt,...) do { fprintf(hook_file, fmt, ##__VA_ARGS__); } while (0)
-
#define MONSTER_LICH 518
#define MONSTER_MONASTIC_LICH 611
#define MONSTER_FLESH_GOLEM 256
@@ -59,7 +59,6 @@ void initialize_bookable_spells()
push_spell(RECHARGE);
push_spell(DISPERSEMAGIC);
push_spell(BLINK);
- push_spell(DISARM);
push_spell(TELEPORT);
push_spell(SENSEMONSTERS);
push_spell(SENSEHIDDEN);
@@ -313,19 +312,19 @@ 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;
}
{
int y = 2;
int x = 2;
load_map("library.map", &y, &x);
- dungeon_flags2 = DF2_NO_GENO;
+ dungeon_flags = DF_NO_GENO;
}
/* Generate monsters */
@@ -353,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;
@@ -400,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 */
@@ -422,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)
@@ -457,7 +451,7 @@ void quest_library_building(bool_ *paid, bool_ *recreate)
object_type forge;
object_type *q_ptr = &forge;
object_prep(q_ptr, lookup_kind(TV_BOOK, 61));
- q_ptr->art_name = quark_add(player_name);
+ q_ptr->artifact_name = game->player_name;
q_ptr->found = OBJ_FOUND_REWARD;
object_aware(q_ptr);
object_known(q_ptr);
@@ -482,28 +476,26 @@ void quest_library_building(bool_ *paid, bool_ *recreate)
}
}
-bool_ quest_library_describe(FILE *hook_file)
+std::string quest_library_describe()
{
+ fmt::MemoryWriter w;
+
if (cquest.status == QUEST_STATUS_TAKEN)
{
- print_hook("#####yAn Old Mages Quest! (Danger Level: 35)\n");
- print_hook("Make the library safe for the old mage in Minas Anor.\n");
- print_hook("\n");
+ w.write("#####yAn Old Mages Quest! (Danger Level: 35)\n");
+ w.write("Make the library safe for the old mage in Minas Anor.");
}
else if (cquest.status == QUEST_STATUS_COMPLETED)
{
- /* Quest done, book not gotten yet */
- print_hook("#####yAn Old Mages Quest!\n");
- print_hook("You have made the library safe for the old mage in Minas Anor.\n");
- print_hook("Perhaps you should see about a reward.\n");
- print_hook("\n");
+ w.write("#####yAn Old Mages Quest!\n");
+ w.write("You have made the library safe for the old mage in Minas Anor.\n");
+ w.write("Perhaps you should see about a reward.");
}
- /* Normal processing */
- return TRUE;
+ return w.str();
}
-bool_ quest_library_init_hook(int q)
+void quest_library_init_hook()
{
/* Only need hooks if the quest is unfinished. */
if ((cquest.status >= QUEST_STATUS_UNTAKEN) &&
@@ -519,8 +511,4 @@ bool_ quest_library_init_hook(int q)
{
quest_library_finalize_book();
}
-
- return FALSE;
}
-
-#undef print_hook