OSDN Git Service

Replace sprintf() with std::string and/or format(). Does part of the work of resolvi...
[hengbandforosx/hengbandosx.git] / src / market / building-quest.cpp
index 2169ed6..eeaa304 100644 (file)
@@ -9,10 +9,11 @@
 #include "monster/monster-list.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
-#include "system/monster-race-definition.h"
+#include "system/monster-race-info.h"
 #include "system/player-type-definition.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
+#include "term/z-form.h"
 #include "view/display-messages.h"
 
 /*!
@@ -38,7 +39,7 @@ static void get_questinfo(PlayerType *player_ptr, QuestId questnum, bool do_init
         init_flags = i2enum<init_flags_type>(init_flags | INIT_ASSIGN);
     }
 
-    parse_fixed_map(player_ptr, "q_info.txt", 0, 0, 0, 0);
+    parse_fixed_map(player_ptr, QUEST_DEFINITION_LIST, 0, 0, 0, 0);
     floor_ptr->quest_number = old_quest;
 }
 
@@ -48,14 +49,14 @@ static void get_questinfo(PlayerType *player_ptr, QuestId questnum, bool do_init
  * @param questnum クエストのID
  * @param do_init クエストの開始処理か(true)、結果処理か(FALSE)
  */
-void print_questinfo(PlayerType *player_ptr, QuestId questnum, bool do_init)
+static void print_questinfo(PlayerType *player_ptr, QuestId questnum, bool do_init)
 {
     get_questinfo(player_ptr, questnum, do_init);
 
-    GAME_TEXT tmp_str[80];
-    sprintf(tmp_str, _("クエスト情報 (危険度: %d 階相当)", "Quest Information (Danger level: %d)"), (int)quest_map[questnum].level);
-    prt(tmp_str, 5, 0);
-    prt(quest_map[questnum].name, 7, 0);
+    const auto &quest_list = QuestList::get_instance();
+    const auto *q_ptr = &quest_list[questnum];
+    prt(format(_("クエスト情報 (危険度: %d 階相当)", "Quest Information (Danger level: %d)"), (int)q_ptr->level), 5, 0);
+    prt(q_ptr->name, 7, 0);
 
     for (int i = 0; i < 10; i++) {
         c_put_str(TERM_YELLOW, quest_text[i], i + 8, 0);
@@ -76,8 +77,8 @@ void castle_quest(PlayerType *player_ptr)
         return;
     }
 
-    quest_type *q_ptr;
-    q_ptr = &quest_map[q_index];
+    auto &quest_list = QuestList::get_instance();
+    auto *q_ptr = &quest_list[q_index];
     if (q_ptr->status == QuestStatusType::COMPLETED) {
         q_ptr->status = QuestStatusType::REWARDED;
         print_questinfo(player_ptr, q_index, false);
@@ -122,36 +123,5 @@ void castle_quest(PlayerType *player_ptr)
 
     q_ptr->status = QuestStatusType::TAKEN;
     reinit_wilderness = true;
-    if (q_ptr->type != QuestKindType::KILL_ANY_LEVEL) {
-        print_questinfo(player_ptr, q_index, true);
-        return;
-    }
-
-    if (q_ptr->r_idx == 0) {
-        q_ptr->r_idx = get_mon_num(player_ptr, 0, q_ptr->level + 4 + randint1(6), 0);
-    }
-
-    monster_race *r_ptr;
-    r_ptr = &r_info[q_ptr->r_idx];
-    while (r_ptr->kind_flags.has(MonsterKindType::UNIQUE) || (r_ptr->rarity != 1)) {
-        q_ptr->r_idx = get_mon_num(player_ptr, 0, q_ptr->level + 4 + randint1(6), 0);
-        r_ptr = &r_info[q_ptr->r_idx];
-    }
-
-    if (q_ptr->max_num == 0) {
-        if (randint1(10) > 7) {
-            q_ptr->max_num = 1;
-        } else {
-            q_ptr->max_num = randint1(3) + 1;
-        }
-    }
-
-    q_ptr->cur_num = 0;
-    concptr name = r_ptr->name.c_str();
-#ifdef JP
-    msg_format("クエスト: %sを %d体倒す", name, q_ptr->max_num);
-#else
-    msg_format("Your quest: kill %d %s", q_ptr->max_num, name);
-#endif
     print_questinfo(player_ptr, q_index, true);
 }