OSDN Git Service

[Refactor] #2607 cur_num をbool 型にし、is_generated へ改名した
authorHourier <66951241+Hourier@users.noreply.github.com>
Wed, 7 Sep 2022 09:40:39 +0000 (18:40 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Wed, 7 Sep 2022 09:42:06 +0000 (18:42 +0900)
19 files changed:
src/artifact/fixed-art-generator.cpp
src/birth/game-play-initializer.cpp
src/combat/shoot.cpp
src/floor/fixed-map-generator.cpp
src/floor/floor-changer.cpp
src/floor/floor-object.cpp
src/floor/floor-streams.cpp
src/floor/floor-util.cpp
src/grid/object-placer.cpp
src/knowledge/knowledge-items.cpp
src/load/item/item-loader-base.cpp
src/monster-floor/monster-death.cpp
src/monster-floor/special-death-switcher.cpp
src/object-enchant/item-magic-applier.cpp
src/save/save.cpp
src/spell-kind/spells-floor.cpp
src/spell/spells-object.cpp
src/system/artifact-type-definition.h
src/wizard/wizard-item-modifier.cpp

index b3704ec..a7c7d54 100644 (file)
@@ -303,7 +303,7 @@ bool make_artifact(PlayerType *player_ptr, ObjectType *o_ptr)
             continue;
         }
 
-        if (a_ref.cur_num) {
+        if (a_ref.is_generated) {
             continue;
         }
 
@@ -376,7 +376,7 @@ bool make_artifact_special(PlayerType *player_ptr, ObjectType *o_ptr)
         }
 
         /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
-        if (a_ref.cur_num) {
+        if (a_ref.is_generated) {
             continue;
         }
         if (a_ref.gen_flags.has(ItemGenerationTraitType::QUESTITEM)) {
index 6f1441c..4906025 100644 (file)
@@ -78,7 +78,7 @@ void player_wipe_without_name(PlayerType *player_ptr)
     }
 
     for (auto &a_ref : a_info) {
-        a_ref.cur_num = 0;
+        a_ref.is_generated = false;
     }
 
     k_info_reset();
index 3fcc532..fa73364 100644 (file)
@@ -951,7 +951,7 @@ void exe_fire(PlayerType *player_ptr, INVENTORY_IDX item, ObjectType *j_ptr, SPE
             if (!o_idx) {
                 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
                 if (q_ptr->is_fixed_artifact()) {
-                    a_info[j_ptr->fixed_artifact_idx].cur_num = 0;
+                    a_info[j_ptr->fixed_artifact_idx].is_generated = false;
                 }
                 return;
             }
index 6636cd1..bb7d577 100644 (file)
@@ -80,8 +80,8 @@ static void generate_artifact(PlayerType *player_ptr, qtwg_type *qtwg_ptr, const
         return;
     }
 
-    if ((a_info[artifact_index].cur_num == 0) && create_named_art(player_ptr, artifact_index, *qtwg_ptr->y, *qtwg_ptr->x)) {
-        a_info[artifact_index].cur_num = 1;
+    if (!a_info[artifact_index].is_generated && create_named_art(player_ptr, artifact_index, *qtwg_ptr->y, *qtwg_ptr->x)) {
+        a_info[artifact_index].is_generated = true;
         return;
     }
 
@@ -257,7 +257,7 @@ static bool parse_qtw_QR(quest_type *q_ptr, char **zz, int num)
         if (a_idx < 1) {
             continue;
         }
-        if (a_info[a_idx].cur_num > 0) {
+        if (a_info[a_idx].is_generated) {
             continue;
         }
         count++;
index 1355f78..532701a 100644 (file)
@@ -295,7 +295,7 @@ static void new_floor_allocation(PlayerType *player_ptr, saved_floor_type *sf_pt
         }
 
         if (a_info[o_ptr->fixed_artifact_idx].floor_id == new_floor_id) {
-            a_info[o_ptr->fixed_artifact_idx].cur_num = 1;
+            a_info[o_ptr->fixed_artifact_idx].is_generated = true;
         } else {
             delete_object_idx(player_ptr, i);
         }
index 402b585..b3cee63 100644 (file)
@@ -485,7 +485,7 @@ OBJECT_IDX drop_near(PlayerType *player_ptr, ObjectType *j_ptr, PERCENTAGE chanc
 
             if (preserve_mode) {
                 if (j_ptr->is_fixed_artifact() && !j_ptr->is_known()) {
-                    a_info[j_ptr->fixed_artifact_idx].cur_num = 0;
+                    a_info[j_ptr->fixed_artifact_idx].is_generated = false;
                 }
             }
 
@@ -538,7 +538,7 @@ OBJECT_IDX drop_near(PlayerType *player_ptr, ObjectType *j_ptr, PERCENTAGE chanc
         }
 
         if (j_ptr->is_fixed_artifact()) {
-            a_info[j_ptr->fixed_artifact_idx].cur_num = 0;
+            a_info[j_ptr->fixed_artifact_idx].is_generated = false;
         }
 
         return 0;
index 1ccbc3e..4d68112 100644 (file)
@@ -353,8 +353,7 @@ void build_streamer(PlayerType *player_ptr, FEAT_IDX feat, int chance)
 
                     /* Hack -- Preserve unknown artifacts */
                     if (o_ptr->is_fixed_artifact()) {
-                        /* Mega-Hack -- Preserve the artifact */
-                        a_info[o_ptr->fixed_artifact_idx].cur_num = 0;
+                        a_info[o_ptr->fixed_artifact_idx].is_generated = false;
 
                         if (cheat_peek) {
                             GAME_TEXT o_name[MAX_NLEN];
index 6802fcf..5462f0b 100644 (file)
@@ -131,7 +131,7 @@ void wipe_o_list(floor_type *floor_ptr)
 
         if (!w_ptr->character_dungeon || preserve_mode) {
             if (o_ptr->is_fixed_artifact() && !o_ptr->is_known()) {
-                a_info[o_ptr->fixed_artifact_idx].cur_num = 0;
+                a_info[o_ptr->fixed_artifact_idx].is_generated = false;
             }
         }
 
index 8140ac8..1789fa2 100644 (file)
@@ -90,7 +90,7 @@ void place_object(PlayerType *player_ptr, POSITION y, POSITION x, BIT_FLAGS mode
     OBJECT_IDX o_idx = o_pop(floor_ptr);
     if (o_idx == 0) {
         if (q_ptr->is_fixed_artifact()) {
-            a_info[q_ptr->fixed_artifact_idx].cur_num = 0;
+            a_info[q_ptr->fixed_artifact_idx].is_generated = false;
         }
 
         return;
index 840c7c1..4c2d791 100644 (file)
@@ -55,7 +55,7 @@ void do_cmd_knowledge_artifacts(PlayerType *player_ptr)
         if (a_ref.name.empty()) {
             continue;
         }
-        if (!a_ref.cur_num) {
+        if (!a_ref.is_generated) {
             continue;
         }
 
index f4854d1..7c1161e 100644 (file)
@@ -31,7 +31,7 @@ void ItemLoaderBase::load_artifact(void)
     artifact_type dummy;
     for (auto i = 0U; i < loading_max_a_idx; i++) {
         auto *a_ptr = i < a_info.size() ? &a_info[i] : &dummy;
-        a_ptr->cur_num = rd_byte();
+        a_ptr->is_generated = rd_bool();
         if (h_older_than(1, 5, 0, 0)) {
             a_ptr->floor_id = 0;
             strip_bytes(3);
index 4abc5d8..0074153 100644 (file)
@@ -179,19 +179,19 @@ static ARTIFACT_IDX drop_artifact_index(PlayerType *player_ptr, monster_death_ty
 bool drop_single_artifact(PlayerType *player_ptr, monster_death_type *md_ptr, ARTIFACT_IDX a_idx)
 {
     auto *a_ptr = &a_info[a_idx];
-    if (a_ptr->cur_num == 1) {
+    if (a_ptr->is_generated) {
         return false;
     }
 
     if (create_named_art(player_ptr, a_idx, md_ptr->md_y, md_ptr->md_x)) {
-        a_ptr->cur_num = 1;
+        a_ptr->is_generated = true;
 
         if (w_ptr->character_dungeon) {
             a_ptr->floor_id = player_ptr->floor_id;
         }
 
         if (!preserve_mode) {
-            a_ptr->cur_num = 1;
+            a_ptr->is_generated = true;
         }
 
         return true;
@@ -208,16 +208,16 @@ static KIND_OBJECT_IDX drop_dungeon_final_artifact(PlayerType *player_ptr, monst
 
     a_idx = d_info[player_ptr->dungeon_idx].final_artifact;
     auto *a_ptr = &a_info[a_idx];
-    if (a_ptr->cur_num == 1) {
+    if (a_ptr->is_generated) {
         return k_idx;
     }
     if (create_named_art(player_ptr, a_idx, md_ptr->md_y, md_ptr->md_x)) {
-        a_ptr->cur_num = 1;
+        a_ptr->is_generated = true;
         if (w_ptr->character_dungeon) {
             a_ptr->floor_id = player_ptr->floor_id;
         }
     } else if (!preserve_mode) {
-        a_ptr->cur_num = 1;
+        a_ptr->is_generated = true;
     }
 
     return d_info[player_ptr->dungeon_idx].final_object ? k_idx : 0;
index 8656492..244851e 100644 (file)
@@ -184,10 +184,10 @@ static void on_dead_sacred_treasures(PlayerType *player_ptr, monster_death_type
         }
 
         a_ptr = &a_info[a_idx];
-    } while (a_ptr->cur_num == 1);
+    } while (a_ptr->is_generated);
 
     if (create_named_art(player_ptr, a_idx, md_ptr->md_y, md_ptr->md_x)) {
-        a_ptr->cur_num = 1;
+        a_ptr->is_generated = true;
         if (w_ptr->character_dungeon) {
             a_ptr->floor_id = player_ptr->floor_id;
         }
@@ -196,7 +196,7 @@ static void on_dead_sacred_treasures(PlayerType *player_ptr, monster_death_type
     }
 
     if (!preserve_mode) {
-        a_ptr->cur_num = 1;
+        a_ptr->is_generated = true;
     }
 }
 
index 00fbd44..3e4c40d 100644 (file)
@@ -182,7 +182,7 @@ bool ItemMagicApplier::set_fixed_artifact_generation_info()
     }
 
     auto *a_ptr = apply_artifact(this->player_ptr, this->o_ptr);
-    a_ptr->cur_num = 1;
+    a_ptr->is_generated = true;
     if (w_ptr->character_dungeon) {
         a_ptr->floor_id = this->player_ptr->floor_id;
     }
index 79c4038..f4da17f 100644 (file)
@@ -170,7 +170,7 @@ static bool wr_savefile_new(PlayerType *player_ptr, SaveType type)
     wr_u16b(tmp16u);
     for (int i = 0; i < tmp16u; i++) {
         auto *a_ptr = &a_info[i];
-        wr_byte(a_ptr->cur_num);
+        wr_bool(a_ptr->is_generated);
         wr_s16b(a_ptr->floor_id);
     }
 
index 236411f..5fef590 100644 (file)
@@ -345,8 +345,7 @@ bool destroy_area(PlayerType *player_ptr, POSITION y1, POSITION x1, POSITION r,
 
                     /* Hack -- Preserve unknown artifacts */
                     if (o_ptr->is_fixed_artifact() && (!o_ptr->is_known() || in_generate)) {
-                        /* Mega-Hack -- Preserve the artifact */
-                        a_info[o_ptr->fixed_artifact_idx].cur_num = 0;
+                        a_info[o_ptr->fixed_artifact_idx].is_generated = false;
 
                         if (in_generate && cheat_peek) {
                             GAME_TEXT o_name[MAX_NLEN];
index 504bfcf..1cbbc11 100644 (file)
@@ -105,7 +105,7 @@ static std::optional<short> sweep_amusement_artifact(const bool insta_art, const
             continue;
         }
 
-        if (a_ref.cur_num > 0) {
+        if (a_ref.is_generated) {
             continue;
         }
 
index 7769139..9e3733b 100644 (file)
@@ -15,7 +15,7 @@
  * @brief 固定アーティファクト情報の構造体 / Artifact structure.
  * @details
  * @note
- * the save-file only writes "cur_num" to the savefile.
+ * the save-file only writes "is_generated" to the savefile.
  * "max_num" is always "1" (if that artifact "exists")
  */
 enum class RandomArtActType : short;
@@ -39,7 +39,7 @@ struct artifact_type {
     EnumClassFlagGroup<ItemGenerationTraitType> gen_flags; /*! アイテム生成フラグ / flags for generate */
     DEPTH level{}; /*! 基本生成階 / Artifact level */
     RARITY rarity{}; /*! レアリティ / Artifact rarity */
-    byte cur_num{}; /*! 現在の生成数 / Number created (0 or 1) */
+    bool is_generated{}; /*! 生成済か否か (生成済でも、「保存モードON」かつ「帰還等で鑑定前に消滅」したら未生成状態に戻る) */
     FLOOR_IDX floor_id{}; /*! アイテムを落としたフロアのID / Leaved on this location last time */
     RandomArtActType act_idx{}; /*! 発動能力ID / Activative ability index */
 };
index 7f07c09..3fc6036 100644 (file)
@@ -192,7 +192,7 @@ void wiz_restore_aware_flag_of_fixed_arfifact(ARTIFACT_IDX a_idx, bool aware)
     }
 
     auto *a_ptr = &a_info[a_idx];
-    a_ptr->cur_num = aware ? 1 : 0;
+    a_ptr->is_generated = aware;
     msg_print(aware ? "Modified." : "Restored.");
 }
 
@@ -414,7 +414,7 @@ static void wiz_statistics(PlayerType *player_ptr, ObjectType *o_ptr)
     char tmp_val[80];
 
     if (o_ptr->is_fixed_artifact()) {
-        a_info[o_ptr->fixed_artifact_idx].cur_num = 0;
+        a_info[o_ptr->fixed_artifact_idx].is_generated = false;
     }
 
     uint32_t i, matches, better, worse, other, correct;
@@ -468,7 +468,7 @@ static void wiz_statistics(PlayerType *player_ptr, ObjectType *o_ptr)
             q_ptr->wipe();
             make_object(player_ptr, q_ptr, mode);
             if (q_ptr->is_fixed_artifact()) {
-                a_info[q_ptr->fixed_artifact_idx].cur_num = 0;
+                a_info[q_ptr->fixed_artifact_idx].is_generated = false;
             }
 
             if ((o_ptr->tval != q_ptr->tval) || (o_ptr->sval != q_ptr->sval)) {
@@ -492,7 +492,7 @@ static void wiz_statistics(PlayerType *player_ptr, ObjectType *o_ptr)
     }
 
     if (o_ptr->is_fixed_artifact()) {
-        a_info[o_ptr->fixed_artifact_idx].cur_num = 1;
+        a_info[o_ptr->fixed_artifact_idx].is_generated = true;
     }
 }
 
@@ -518,7 +518,7 @@ static void wiz_reroll_item(PlayerType *player_ptr, ObjectType *o_ptr)
         wiz_display_item(player_ptr, q_ptr);
         if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, false)) {
             if (q_ptr->is_fixed_artifact()) {
-                a_info[q_ptr->fixed_artifact_idx].cur_num = 0;
+                a_info[q_ptr->fixed_artifact_idx].is_generated = false;
                 q_ptr->fixed_artifact_idx = 0;
             }
 
@@ -532,7 +532,7 @@ static void wiz_reroll_item(PlayerType *player_ptr, ObjectType *o_ptr)
         }
 
         if (q_ptr->is_fixed_artifact()) {
-            a_info[q_ptr->fixed_artifact_idx].cur_num = 0;
+            a_info[q_ptr->fixed_artifact_idx].is_generated = false;
             q_ptr->fixed_artifact_idx = 0;
         }
 
@@ -1022,10 +1022,10 @@ WishResultType do_cmd_wishing(PlayerType *player_ptr, int prob, bool allow_art,
 
     if (a_ids.size() == 1) {
         ARTIFACT_IDX a_idx = a_ids.back();
-        if (must || (ok_art && !a_info[a_idx].cur_num)) {
+        if (must || (ok_art && !a_info[a_idx].is_generated)) {
             create_named_art(player_ptr, a_idx, player_ptr->y, player_ptr->x);
             if (!w_ptr->wizard) {
-                a_info[a_idx].cur_num = 1;
+                a_info[a_idx].is_generated = true;
             }
         } else {
             wishing_puff_of_smoke();
@@ -1057,10 +1057,10 @@ WishResultType do_cmd_wishing(PlayerType *player_ptr, int prob, bool allow_art,
 
         if (a_idx > 0) {
             a_ptr = &a_info[a_idx];
-            if (must || (ok_art && !a_ptr->cur_num)) {
+            if (must || (ok_art && !a_ptr->is_generated)) {
                 create_named_art(player_ptr, a_idx, player_ptr->y, player_ptr->x);
                 if (!w_ptr->wizard) {
-                    a_info[a_idx].cur_num = 1;
+                    a_info[a_idx].is_generated = true;
                 }
             } else {
                 wishing_puff_of_smoke();