OSDN Git Service

[Refactor] #3496 optional 型の存在判定 has_value() を撤廃した その6
[hengbandforosx/hengbandosx.git] / src / wizard / wizard-special-process.cpp
index a0f889c..fbe1078 100644 (file)
@@ -138,7 +138,7 @@ static std::optional<short> wiz_select_tval()
     }
 
     const auto item_type_opt = input_command(_("アイテム種別を選んで下さい", "Get what type of object? "));
-    if (!item_type_opt.has_value()) {
+    if (!item_type_opt) {
         return std::nullopt;
     }
 
@@ -181,7 +181,7 @@ static short wiz_select_sval(const ItemKindType tval, std::string_view tval_desc
     auto max_num = num;
     const auto prompt = format(_("%s群の具体的なアイテムを選んで下さい", "What Kind of %s? "), tval_description.data());
     const auto command = input_command(prompt);
-    if (!command.has_value()) {
+    if (!command) {
         return 0;
     }
 
@@ -213,7 +213,7 @@ static short wiz_create_itemtype()
 {
     term_clear();
     auto selection = wiz_select_tval();
-    if (!selection.has_value()) {
+    if (!selection) {
         return 0;
     }
 
@@ -416,7 +416,7 @@ void wiz_change_status(PlayerType *player_ptr)
         const auto max_max_ability_score = player_ptr->stat_max_max[i];
         const auto max_ability_score = player_ptr->stat_max[i];
         const auto new_ability_score = input_numerics(stat_names[i], 3, max_max_ability_score, max_ability_score);
-        if (!new_ability_score.has_value()) {
+        if (!new_ability_score) {
             return;
         }
 
@@ -428,7 +428,7 @@ void wiz_change_status(PlayerType *player_ptr)
     const auto unskilled = PlayerSkill::weapon_exp_at(PlayerSkillRank::UNSKILLED);
     const auto master = PlayerSkill::weapon_exp_at(PlayerSkillRank::MASTER);
     const auto proficiency_opt = input_numerics(_("熟練度", "Proficiency"), unskilled, master, static_cast<short>(master));
-    if (!proficiency_opt.has_value()) {
+    if (!proficiency_opt) {
         return;
     }
 
@@ -458,7 +458,7 @@ void wiz_change_status(PlayerType *player_ptr)
     }
 
     const auto gold = input_numerics("Gold: ", 0, MAX_INT, player_ptr->au);
-    if (!gold.has_value()) {
+    if (!gold) {
         return;
     }
 
@@ -468,7 +468,7 @@ void wiz_change_status(PlayerType *player_ptr)
     }
 
     const auto experience_opt = input_numerics("Experience: ", 0, MAX_INT, player_ptr->max_exp);
-    if (!experience_opt.has_value()) {
+    if (!experience_opt) {
         return;
     }
 
@@ -490,25 +490,26 @@ void wiz_create_feature(PlayerType *player_ptr)
         return;
     }
 
-    auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+    const Pos2D pos(y, x);
+    auto &grid = player_ptr->current_floor_ptr->get_grid(pos);
     const int max = TerrainList::get_instance().size() - 1;
-    const auto f_val1 = input_numerics(_("実地形ID", "FeatureID"), 0, max, g_ptr->feat);
-    if (!f_val1.has_value()) {
+    const auto f_val1 = input_numerics(_("実地形ID", "FeatureID"), 0, max, grid.feat);
+    if (!f_val1) {
         return;
     }
 
     const auto f_val2 = input_numerics(_("偽装地形ID", "FeatureID"), 0, max, f_val1.value());
-    if (!f_val2.has_value()) {
+    if (!f_val2) {
         return;
     }
 
     cave_set_feat(player_ptr, y, x, f_val1.value());
-    g_ptr->mimic = f_val2.value();
-    auto *f_ptr = &terrains_info[g_ptr->get_feat_mimic()];
-    if (f_ptr->flags.has(TerrainCharacteristics::RUNE_PROTECTION) || f_ptr->flags.has(TerrainCharacteristics::RUNE_EXPLOSION)) {
-        g_ptr->info |= CAVE_OBJECT;
-    } else if (f_ptr->flags.has(TerrainCharacteristics::MIRROR)) {
-        g_ptr->info |= CAVE_GLOW | CAVE_OBJECT;
+    grid.mimic = f_val2.value();
+    const auto &terrain = grid.get_terrain_mimic();
+    if (terrain.flags.has(TerrainCharacteristics::RUNE_PROTECTION) || terrain.flags.has(TerrainCharacteristics::RUNE_EXPLOSION)) {
+        grid.info |= CAVE_OBJECT;
+    } else if (terrain.flags.has(TerrainCharacteristics::MIRROR)) {
+        grid.info |= CAVE_GLOW | CAVE_OBJECT;
     }
 
     note_spot(player_ptr, y, x);
@@ -529,7 +530,7 @@ static std::optional<short> select_debugging_dungeon(short initial_dungeon_id)
 
     while (true) {
         const auto dungeon_id = input_numerics("Jump which dungeon", DUNGEON_ANGBAND, DUNGEON_DARKNESS, initial_dungeon_id);
-        if (!dungeon_id.has_value()) {
+        if (!dungeon_id) {
             return std::nullopt;
         }
 
@@ -596,7 +597,7 @@ void wiz_jump_to_dungeon(PlayerType *player_ptr)
     const auto is_in_dungeon = floor.is_in_dungeon();
     const auto dungeon_idx = is_in_dungeon ? floor.dungeon_idx : static_cast<short>(DUNGEON_ANGBAND);
     const auto dungeon_id_opt = select_debugging_dungeon(dungeon_idx);
-    if (!dungeon_id_opt.has_value()) {
+    if (!dungeon_id_opt) {
         if (!is_in_dungeon) {
             return;
         }
@@ -610,7 +611,7 @@ void wiz_jump_to_dungeon(PlayerType *player_ptr)
 
     const auto dungeon_id = dungeon_id_opt.value();
     const auto level_opt = select_debugging_floor(floor, dungeon_id);
-    if (!level_opt.has_value()) {
+    if (!level_opt) {
         return;
     }
 
@@ -666,7 +667,7 @@ static void change_birth_flags()
 void wiz_reset_race(PlayerType *player_ptr)
 {
     const auto new_race = input_numerics("RaceID", 0, MAX_RACES - 1, player_ptr->prace);
-    if (!new_race.has_value()) {
+    if (!new_race) {
         return;
     }
 
@@ -683,7 +684,7 @@ void wiz_reset_race(PlayerType *player_ptr)
 void wiz_reset_class(PlayerType *player_ptr)
 {
     const auto new_class_opt = input_numerics("ClassID", 0, PLAYER_CLASS_TYPE_MAX - 1, player_ptr->pclass);
-    if (!new_class_opt.has_value()) {
+    if (!new_class_opt) {
         return;
     }
 
@@ -704,12 +705,12 @@ void wiz_reset_class(PlayerType *player_ptr)
 void wiz_reset_realms(PlayerType *player_ptr)
 {
     const auto new_realm1 = input_numerics("1st Realm (None=0)", 0, MAX_REALM - 1, player_ptr->realm1);
-    if (!new_realm1.has_value()) {
+    if (!new_realm1) {
         return;
     }
 
     const auto new_realm2 = input_numerics("2nd Realm (None=0)", 0, MAX_REALM - 1, player_ptr->realm2);
-    if (!new_realm2.has_value()) {
+    if (!new_realm2) {
         return;
     }
 
@@ -771,7 +772,7 @@ void wiz_dump_options(void)
 void set_gametime(void)
 {
     const auto game_time = input_integer("Dungeon Turn", 0, w_ptr->dungeon_turn_limit - 1);
-    if (!game_time.has_value()) {
+    if (!game_time) {
         return;
     }