OSDN Git Service

[Refactor] 連想配列 quest を quest_map に改名
[hengbandforosx/hengbandosx.git] / src / wizard / wizard-game-modifier.cpp
index 6ba5f0e..fb3dac7 100644 (file)
@@ -30,7 +30,7 @@
 
 void wiz_enter_quest(PlayerType *player_ptr);
 void wiz_complete_quest(PlayerType *player_ptr);
-void wiz_restore_monster_max_num();
+void wiz_restore_monster_max_num(MONRACE_IDX r_idx);
 
 /*!
  * @brief ゲーム設定コマンド一覧表
@@ -48,8 +48,9 @@ constexpr std::array wizard_game_modifier_menu_table = {
  */
 void display_wizard_game_modifier_menu()
 {
-    for (auto y = 1U; y <= wizard_game_modifier_menu_table.size(); y++)
+    for (auto y = 1U; y <= wizard_game_modifier_menu_table.size(); y++) {
         term_erase(14, y, 64);
+    }
 
     int r = 1;
     int c = 15;
@@ -89,7 +90,7 @@ void wizard_game_modifier(PlayerType *player_ptr)
         wiz_enter_quest(player_ptr);
         break;
     case 'u':
-        wiz_restore_monster_max_num();
+        wiz_restore_monster_max_num(command_arg);
         break;
     case 't':
         set_gametime();
@@ -109,19 +110,24 @@ void wiz_enter_quest(PlayerType *player_ptr)
     sprintf(ppp, "QuestID (0-%d):", max_q_idx - 1);
     sprintf(tmp_val, "%d", 0);
 
-    if (!get_string(ppp, tmp_val, 3))
+    if (!get_string(ppp, tmp_val, 3)) {
         return;
+    }
 
     tmp_int = atoi(tmp_val);
-    if ((tmp_int < 0) || (tmp_int >= max_q_idx))
+    if ((tmp_int < 0) || (tmp_int >= max_q_idx)) {
         return;
+    }
+
+    auto q_idx = i2enum<QuestId>(tmp_int);
 
     init_flags = i2enum<init_flags_type>(INIT_SHOW_TEXT | INIT_ASSIGN);
-    player_ptr->current_floor_ptr->quest_number = i2enum<QuestId>(tmp_int);
+    player_ptr->current_floor_ptr->quest_number = q_idx;
     parse_fixed_map(player_ptr, "q_info.txt", 0, 0, 0, 0);
-    quest[tmp_int].status = QuestStatusType::TAKEN;
-    if (quest[tmp_int].dungeon == 0)
-        exe_enter_quest(player_ptr, i2enum<QuestId>(tmp_int));
+    quest_map[q_idx].status = QuestStatusType::TAKEN;
+    if (quest_map[q_idx].dungeon == 0) {
+        exe_enter_quest(player_ptr, q_idx);
+    }
 }
 
 /*!
@@ -136,24 +142,19 @@ void wiz_complete_quest(PlayerType *player_ptr)
         return;
     }
 
-    if (quest[enum2i(player_ptr->current_floor_ptr->quest_number)].status == QuestStatusType::TAKEN)
+    if (quest_map[player_ptr->current_floor_ptr->quest_number].status == QuestStatusType::TAKEN) {
         complete_quest(player_ptr, player_ptr->current_floor_ptr->quest_number);
+    }
 }
 
-void wiz_restore_monster_max_num()
+void wiz_restore_monster_max_num(MONRACE_IDX r_idx)
 {
-    MONRACE_IDX r_idx = command_arg;
     if (r_idx <= 0) {
-        std::stringstream ss;
-        ss << "Monster race (1-" << r_info.size() << "): ";
-
-        char tmp_val[160] = "\0";
-        if (!get_string(ss.str().c_str(), tmp_val, 5))
-            return;
-
-        r_idx = (MONRACE_IDX)atoi(tmp_val);
-        if (r_idx <= 0 || r_idx >= static_cast<MONRACE_IDX>(r_info.size()))
+        int val;
+        if (!get_value("MonsterID", 1, r_info.size() - 1, &val)) {
             return;
+        }
+        r_idx = static_cast<MONRACE_IDX>(val);
     }
 
     auto *r_ptr = &r_info[r_idx];
@@ -163,11 +164,12 @@ void wiz_restore_monster_max_num()
         return;
     }
 
-    MONSTER_NUMBER n = 0;
-    if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE))
+    auto n = 0;
+    if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE)) {
         n = 1;
-    else if (any_bits(r_ptr->flags7, RF7_NAZGUL))
+    } else if (any_bits(r_ptr->flags7, RF7_NAZGUL)) {
         n = MAX_NAZGUL_NUM;
+    }
 
     if (n == 0) {
         msg_print("出現数に制限がないモンスターです。");