OSDN Git Service

[Refactor] トークン定義を地形関連フラグに合わせる
authorSlimebreath6078 <slimebreath6078@yahoo.co.jp>
Sun, 3 Apr 2022 12:00:31 +0000 (21:00 +0900)
committerSlimebreath6078 <slimebreath6078@yahoo.co.jp>
Sat, 9 Apr 2022 13:49:14 +0000 (22:49 +0900)
src/info-reader/dungeon-reader.cpp
src/info-reader/race-info-tokens-table.cpp
src/info-reader/race-info-tokens-table.h
src/info-reader/race-reader.cpp

index b401a35..be954eb 100644 (file)
@@ -81,6 +81,10 @@ static bool grab_one_basic_monster_flag(dungeon_type *d_ptr, std::string_view wh
         return true;
     }
 
+    if (EnumClassFlagGroup<MonsterFeatureType>::grab_one_flag(d_ptr->mon_feature_flags, r_info_feature_flags, what)) {
+        return true;
+    }
+
     msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what.data());
     return false;
 }
index 0067bb0..c2d6d1f 100644 (file)
@@ -3,6 +3,7 @@
 #include "monster-attack/monster-attack-table.h"
 #include "monster-race/race-ability-flags.h"
 #include "monster-race/race-drop-flags.h"
+#include "monster-race/race-feature-flags.h"
 #include "monster-race/race-kind-flags.h"
 #include "monster-race/race-visual-flags.h"
 #include "monster-race/race-wilderness-flags.h"
@@ -117,8 +118,6 @@ const std::unordered_map<std::string_view, race_flags2> r_info_flags2 = {
     { "ELDRITCH_HORROR", RF2_ELDRITCH_HORROR },
     { "FLAGS2_XX14", RF2_XX14 },
     { "FLAGS2_XX15", RF2_XX15 },
-    { "PASS_WALL", RF2_PASS_WALL },
-    { "KILL_WALL", RF2_KILL_WALL },
 };
 
 /*!
@@ -252,9 +251,6 @@ const std::unordered_map<std::string_view, MonsterAbilityType> r_info_ability_fl
  * "GUARDIAN" ... init.c d_infoの FINAL_GUARDIAN_* にて自動指定
  */
 const std::unordered_map<std::string_view, race_flags7> r_info_flags7 = {
-    { "AQUATIC", RF7_AQUATIC },
-    { "CAN_SWIM", RF7_CAN_SWIM },
-    { "CAN_FLY", RF7_CAN_FLY },
     { "NAZGUL", RF7_NAZGUL },
     { "UNIQUE2", RF7_UNIQUE2 },
     { "RIDING", RF7_RIDING },
@@ -436,3 +432,11 @@ const std::unordered_map<std::string_view, MonsterWildernessType> r_info_wildern
     { "WILD_SWAMP", MonsterWildernessType::WILD_SWAMP },
     { "WILD_ALL", MonsterWildernessType::WILD_ALL },
 };
+
+const std::unordered_map<std::string_view, MonsterFeatureType> r_info_feature_flags = {
+    { "PASS_WALL", MonsterFeatureType::PASS_WALL },
+    { "KILL_WALL", MonsterFeatureType::KILL_WALL },
+    { "AQUATIC", MonsterFeatureType::AQUATIC },
+    { "CAN_SWIM", MonsterFeatureType::CAN_SWIM },
+    { "CAN_FLY", MonsterFeatureType::CAN_FLY },
+};
index 466a3c7..29925f8 100644 (file)
@@ -6,6 +6,7 @@
 #include "monster-race/race-ability-flags.h"
 #include "monster-race/race-behavior-flags.h"
 #include "monster-race/race-drop-flags.h"
+#include "monster-race/race-feature-flags.h"
 #include "monster-race/race-flags-resistance.h"
 #include "monster-race/race-flags1.h"
 #include "monster-race/race-flags2.h"
@@ -37,3 +38,4 @@ extern const std::unordered_map<std::string_view, MonsterVisualType> r_info_visu
 extern const std::unordered_map<std::string_view, MonsterKindType> r_info_kind_flags;
 extern const std::unordered_map<std::string_view, MonsterDropType> r_info_drop_flags;
 extern const std::unordered_map<std::string_view, MonsterWildernessType> r_info_wilderness_flags;
+extern const std::unordered_map<std::string_view, MonsterFeatureType> r_info_feature_flags;
index 5fead67..224822b 100644 (file)
@@ -68,6 +68,10 @@ static bool grab_one_basic_flag(monster_race *r_ptr, std::string_view what)
         return true;
     }
 
+    if (EnumClassFlagGroup<MonsterFeatureType>::grab_one_flag(r_ptr->feature_flags, r_info_feature_flags, what)) {
+        return true;
+    }
+
     msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what.data());
     return false;
 }