OSDN Git Service

[Refactor] #2816 decide_magic_book_exp() におけるtvalの判定が無駄な二重変換になっていたので分かりやすくなるよう修正した
authorHourier <66951241+Hourier@users.noreply.github.com>
Fri, 18 Nov 2022 11:47:39 +0000 (20:47 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sat, 19 Nov 2022 09:46:59 +0000 (18:46 +0900)
src/cmd-item/cmd-destroy.cpp

index 52db196..3176781 100644 (file)
@@ -133,13 +133,15 @@ static bool decide_magic_book_exp(PlayerType *player_ptr, destroy_type *destroy_
         return false;
     }
 
-    bool gain_expr = false;
+    auto gain_expr = false;
+    const auto tval = destroy_ptr->o_ptr->tval;
+    auto is_good_magic_realm = (tval == ItemKindType::LIFE_BOOK) || (tval == ItemKindType::CRUSADE_BOOK);
     if (is_good_realm(player_ptr->realm1)) {
-        if (!is_good_realm(tval2realm(destroy_ptr->q_ptr->tval))) {
+        if (!is_good_magic_realm) {
             gain_expr = true;
         }
     } else {
-        if (is_good_realm(tval2realm(destroy_ptr->q_ptr->tval))) {
+        if (is_good_magic_realm) {
             gain_expr = true;
         }
     }