OSDN Git Service

[Refactor] #3496 optional 型の存在判定 has_value() を撤廃した その4
authorHourier <66951241+Hourier@users.noreply.github.com>
Thu, 9 Nov 2023 11:54:47 +0000 (20:54 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Thu, 9 Nov 2023 11:54:47 +0000 (20:54 +0900)
13 files changed:
src/object-enchant/others/apply-magic-amulet.cpp
src/object-enchant/others/apply-magic-lite.cpp
src/object-enchant/others/apply-magic-others.cpp
src/object-enchant/others/apply-magic-ring.cpp
src/object-enchant/protector/apply-magic-soft-armor.cpp
src/object-enchant/vorpal-weapon.cpp
src/object/object-info.cpp
src/object/object-kind-hook.cpp
src/object/object-value-calc.cpp
src/player-base/player-race.cpp
src/player/player-damage.cpp
src/player/process-name.cpp
src/room/rooms-pit-nest.cpp

index 1ba8430..39ce00d 100644 (file)
@@ -69,7 +69,7 @@ void AmuletEnchanter::apply_magic()
 void AmuletEnchanter::sval_enchant()
 {
     const auto sval = this->o_ptr->bi_key.sval();
-    if (!sval.has_value()) {
+    if (!sval) {
         return;
     }
 
@@ -265,7 +265,7 @@ void AmuletEnchanter::give_ego_index()
 void AmuletEnchanter::give_high_ego_index()
 {
     const auto sval = this->o_ptr->bi_key.sval();
-    if (!sval.has_value()) {
+    if (!sval) {
         return;
     }
 
index b9edb9e..6060cac 100644 (file)
@@ -12,7 +12,7 @@ LiteEnchanter::LiteEnchanter(PlayerType *player_ptr, ItemEntity *o_ptr, int powe
     , power(power)
 {
     const auto sval = this->o_ptr->bi_key.sval();
-    if (!sval.has_value()) {
+    if (!sval) {
         return;
     }
 
@@ -86,7 +86,7 @@ void LiteEnchanter::give_cursed()
 void LiteEnchanter::add_dark_flag()
 {
     const auto sval = this->o_ptr->bi_key.sval();
-    if (!sval.has_value()) {
+    if (!sval) {
         return;
     }
 
index 5622194..68a411e 100644 (file)
@@ -152,7 +152,7 @@ void OtherItemsEnchanter::generate_corpse()
         auto &r_ref = monraces_info[r_idx];
         auto check = (floor_ptr->dun_level < r_ref.level) ? (r_ref.level - floor_ptr->dun_level) : 0;
         const auto sval = this->o_ptr->bi_key.sval();
-        if (!sval.has_value()) {
+        if (!sval) {
             continue;
         }
 
index a8f434d..fc72cf6 100644 (file)
@@ -68,7 +68,7 @@ void RingEnchanter::apply_magic()
 void RingEnchanter::sval_enchant()
 {
     const auto sval = this->o_ptr->bi_key.sval();
-    if (!sval.has_value()) {
+    if (!sval) {
         return;
     }
 
@@ -406,7 +406,7 @@ void RingEnchanter::give_ego_index()
 void RingEnchanter::give_high_ego_index()
 {
     const auto sval = this->o_ptr->bi_key.sval();
-    if (!sval.has_value()) {
+    if (!sval) {
         return;
     }
 
index 4a1187d..f78a22f 100644 (file)
@@ -48,7 +48,7 @@ void SoftArmorEnchanter::apply_magic()
 void SoftArmorEnchanter::sval_enchant()
 {
     const auto sval = this->o_ptr->bi_key.sval();
-    if (!sval.has_value()) {
+    if (!sval) {
         return;
     }
 
index b7e7d2c..a885cf9 100644 (file)
@@ -63,7 +63,7 @@ static void print_chainsword_noise(ItemEntity *o_ptr)
     }
 
     const auto chainsword_noise = get_random_line(_("chainswd_j.txt", "chainswd.txt"), 0);
-    if (chainsword_noise.has_value()) {
+    if (chainsword_noise) {
         msg_print(chainsword_noise.value());
     }
 }
index 91a2ea7..6eb1ce4 100644 (file)
@@ -70,7 +70,7 @@ static concptr item_activation_aux(const ItemEntity *o_ptr)
 {
     static std::string activation_detail;
     auto tmp_act_ptr = find_activation_info(o_ptr);
-    if (!tmp_act_ptr.has_value()) {
+    if (!tmp_act_ptr) {
         return _("未定義", "something undefined");
     }
 
index 81b2049..9daf1d9 100644 (file)
@@ -250,7 +250,7 @@ static short exe_lookup(const BaseitemKey &key)
 short lookup_baseitem_id(const BaseitemKey &key)
 {
     const auto sval = key.sval();
-    if (sval.has_value()) {
+    if (sval) {
         return exe_lookup(key);
     }
 
index 5d67cb3..42de5c5 100644 (file)
@@ -529,7 +529,7 @@ PRICE flag_cost(const ItemEntity *o_ptr, int plusses)
     /* Also, give some extra for activatable powers... */
     if (o_ptr->is_random_artifact() && o_ptr->art_flags.has(TR_ACTIVATE)) {
         auto act_ptr = find_activation_info(o_ptr);
-        if (act_ptr.has_value()) {
+        if (act_ptr) {
             total += act_ptr.value()->value;
         }
     }
index 315979c..6a0d344 100644 (file)
@@ -45,7 +45,7 @@ TrFlags PlayerRace::tr_flags() const
         if (this->player_ptr->lev < cond.level) {
             continue;
         }
-        if (cond.pclass.has_value()) {
+        if (cond.pclass) {
             auto is_class_equal = PlayerClass(this->player_ptr).equals(cond.pclass.value());
             if (cond.not_class && is_class_equal) {
                 continue;
index bde4de3..f397918 100644 (file)
@@ -473,7 +473,7 @@ int take_hit(PlayerType *player_ptr, int damage_type, int damage, std::string_vi
                 const auto prompt = winning_seppuku ? _("辞世の句: ", "Haiku: ") : _("断末魔の叫び: ", "Last words: ");
                 while (true) {
                     const auto input_last_words = input_string(prompt, max_last_words, death_message);
-                    if (!input_last_words.has_value()) {
+                    if (!input_last_words) {
                         continue;
                     }
 
index 0aa920b..a2dcb99 100644 (file)
@@ -138,7 +138,7 @@ void get_name(PlayerType *player_ptr)
     const auto copy_size = sizeof(player_ptr->name);
     constexpr auto prompt = _("キャラクターの名前を入力して下さい: ", "Enter a name for your character: ");
     const auto name = input_string(prompt, max_name_size, initial_name);
-    if (name.has_value()) {
+    if (name) {
         if (!name->empty()) {
             angband_strcpy(player_ptr->name, name.value(), copy_size);
         }
index 16dd986..6623eb3 100644 (file)
@@ -275,7 +275,7 @@ bool build_type5(PlayerType *player_ptr, dun_data_type *dd_ptr)
         };
 
         const auto r_idx = select_r_idx();
-        if (!r_idx.has_value()) {
+        if (!r_idx) {
             return false;
         }