From 896850cbf59fb105e35e32c63615c92dc78896d3 Mon Sep 17 00:00:00 2001 From: Hourier Date: Sun, 31 May 2020 21:44:12 +0900 Subject: [PATCH] [Refactor] #40416 Separated pet-util.h from cmd-pet.h --- Hengband/Hengband/Hengband.vcxproj | 1 + Hengband/Hengband/Hengband.vcxproj.filters | 6 ++++ src/Makefile.am | 6 ++-- src/birth/game-play-initializer.c | 2 +- src/cmd/cmd-pet.c | 1 + src/cmd/cmd-pet.h | 46 +++--------------------------- src/floor/floor-save.c | 2 +- src/io/character-dump.c | 2 +- src/io/load.c | 2 +- src/monster/monster-direction.c | 2 +- src/monster/monster-move.c | 2 +- src/monster/pet-fall-off.c | 3 +- src/mspell/mspells2.c | 2 +- src/pet/pet-util.h | 39 +++++++++++++++++++++++++ src/player/player-status.c | 1 + src/spell/spells2.c | 1 + 16 files changed, 66 insertions(+), 52 deletions(-) create mode 100644 src/pet/pet-util.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 4f5db611d..f76c45776 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -488,6 +488,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index deb322cd2..158e7cdac 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -2278,6 +2278,9 @@ monster + + pet + @@ -2377,6 +2380,9 @@ {d9907626-9c01-48b8-89da-065f7b8540b5} + + {7c81caa7-dbd8-43f3-8481-9a2ae3967776} + diff --git a/src/Makefile.am b/src/Makefile.am index 9e79a1f80..ee32b8e01 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -188,6 +188,8 @@ hengband_SOURCES = \ monster/horror-descriptions.c monster/horror-descriptions.h \ monster/pet-fall-off.c monster/pet-fall-off.h \ \ + pet/pet-util.h \ + \ mutation/mutation.c mutation/mutation.h \ mutation/mutation-processor.c mutation/mutation-processor.h \ \ @@ -409,8 +411,8 @@ COMPILE = $(srcdir)/gcc-wrap $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \ -Iautopick -Ibirth -Icmd -Icombat -Icore -Idungeon -Ieffect -Ifloor \ -Igrid -Iinventory -Iio -Iknowledge -Imarket -Imind -Imonster -Imspell \ - -Imutation -Iobject -Iplayer -Irealm -Iroom -Ispell -Isystem -Iterm -Iutil \ - -Iview -Iwizard -Iworld + -Imutation -Iobject -Ipet -Iplayer -Irealm -Iroom -Ispell -Isystem -Iterm \ + -Iutil -Iview -Iwizard -Iworld install-exec-hook: if SET_GID diff --git a/src/birth/game-play-initializer.c b/src/birth/game-play-initializer.c index 01a12a1ce..215219652 100644 --- a/src/birth/game-play-initializer.c +++ b/src/birth/game-play-initializer.c @@ -7,7 +7,7 @@ #include "dungeon/dungeon.h" #include "dungeon/dungeon-file.h" #include "object/artifact.h" -#include "cmd/cmd-pet.h" +#include "pet/pet-util.h" #include "system/system-variables.h" #include "player/player-races-table.h" #include "market/arena.h" diff --git a/src/cmd/cmd-pet.c b/src/cmd/cmd-pet.c index 6f91bf424..5ca531136 100644 --- a/src/cmd/cmd-pet.c +++ b/src/cmd/cmd-pet.c @@ -22,6 +22,7 @@ #include "world/world.h" #include "effect/spells-effect-util.h" #include "cmd/cmd-attack.h" +#include "pet/pet-util.h" int total_friends = 0; diff --git a/src/cmd/cmd-pet.h b/src/cmd/cmd-pet.h index 3aeae0d1b..2a65c2de1 100644 --- a/src/cmd/cmd-pet.h +++ b/src/cmd/cmd-pet.h @@ -2,47 +2,9 @@ #include "grid/grid.h" -extern bool do_cmd_riding(player_type *creature_ptr, bool force); -extern void do_cmd_pet_dismiss(player_type *creature_pt); -extern void do_cmd_pet(player_type *creature_ptr); -extern bool player_can_ride_aux(player_type *creature_ptr, grid_type *g_ptr, bool now_riding); - extern int total_friends; -/* - * ペットに関するコマンド群 / Pet Commands - */ -#define PET_DISMISS 1 /*!< ペットに関するコマンド: ペットを離す */ -#define PET_TARGET 2 /*!< ペットに関するコマンド: ペットのターゲットを指定 */ -#define PET_STAY_CLOSE 3 /*!< ペットに関するコマンド: 近くにいろ */ -#define PET_FOLLOW_ME 4 /*!< ペットに関するコマンド: ついて来い */ -#define PET_SEEK_AND_DESTROY 5 /*!< ペットに関するコマンド: 敵を見つけて倒せ */ -#define PET_ALLOW_SPACE 6 /*!< ペットに関するコマンド: 少し離れていろ */ -#define PET_STAY_AWAY 7 /*!< ペットに関するコマンド: 離れていろ */ -#define PET_OPEN_DOORS 8 /*!< ペットに関するコマンド: ドア解放の許可 */ -#define PET_TAKE_ITEMS 9 /*!< ペットに関するコマンド: アイテム取得の許可 */ -#define PET_TELEPORT 10 /*!< ペットに関するコマンド: テレポートの許可 */ -#define PET_ATTACK_SPELL 11 /*!< ペットに関するコマンド: 攻撃魔法の許可 */ -#define PET_SUMMON_SPELL 12 /*!< ペットに関するコマンド: 召喚魔法の許可 */ -#define PET_BALL_SPELL 13 /*!< ペットに関するコマンド: プレイヤーを魔法に巻き込む許可 */ -#define PET_RIDING 14 /*!< ペットに関するコマンド: ペットに乗る */ -#define PET_NAME 15 /*!< ペットに関するコマンド: ペットに名前をつける */ -#define PET_TWO_HANDS 16 /*!< ペットに関するコマンド: 騎乗中に両手で武器を使うかどうか */ - - /* - * Follow distances - */ -#define PET_CLOSE_DIST 1 /*!<ペットの行動範囲…近くにいろ */ -#define PET_FOLLOW_DIST 6 /*!<ペットの行動範囲…ついて来い */ -#define PET_SEEK_DIST 10 /*!<ペットの行動範囲…特になし? */ -#define PET_DESTROY_DIST 255 /*!<ペットの行動範囲…敵を見つけて倒せ */ -#define PET_SPACE_DIST (-10) /*!<ペットの行動範囲…少し離れていろ */ -#define PET_AWAY_DIST (-25) /*!<ペットの行動範囲…離れていろ */ - -#define PF_OPEN_DOORS 0x0001 /*!< ペットの行動許可…ドアを開けてよい */ -#define PF_PICKUP_ITEMS 0x0002 /*!< ペットの行動許可…アイテムを拾ってよい */ -#define PF_TELEPORT 0x0004 /*!< ペットの行動許可…テレポート魔法を使ってよい */ -#define PF_ATTACK_SPELL 0x0008 /*!< ペットの行動許可…攻撃魔法を使ってよい */ -#define PF_SUMMON_SPELL 0x0010 /*!< ペットの行動許可…召喚魔法を使ってよい */ -#define PF_BALL_SPELL 0x0020 /*!< ペットの行動許可…ボール魔法でプレイヤーを巻き込んでよい */ -#define PF_TWO_HANDS 0x0040 /*!< プレイヤーの騎乗フラグ…武器を片手で持つ */ +bool do_cmd_riding(player_type *creature_ptr, bool force); +void do_cmd_pet_dismiss(player_type *creature_pt); +void do_cmd_pet(player_type *creature_ptr); +bool player_can_ride_aux(player_type *creature_ptr, grid_type *g_ptr, bool now_riding); diff --git a/src/floor/floor-save.c b/src/floor/floor-save.c index e98300352..c2cdb748f 100644 --- a/src/floor/floor-save.c +++ b/src/floor/floor-save.c @@ -32,7 +32,7 @@ #include "monster/monster-status.h" #include "object/object2.h" #include "object/object-hook.h" -#include "cmd-pet.h" +#include "pet/pet-util.h" #include "cmd-basic.h" #include "io/uid-checker.h" #include "io/files-util.h" diff --git a/src/io/character-dump.c b/src/io/character-dump.c index bd0a62da6..b09c1c6c9 100644 --- a/src/io/character-dump.c +++ b/src/io/character-dump.c @@ -5,7 +5,7 @@ #include "floor/floor-town.h" #include "dungeon/dungeon.h" #include "store/store.h" -#include "cmd/cmd-pet.h" +#include "pet/pet-util.h" #include "monster/monster-status.h" #include "core/sort.h" #include "dungeon/quest.h" diff --git a/src/io/load.c b/src/io/load.c index c8e9d6ec2..39d3c6fb9 100644 --- a/src/io/load.c +++ b/src/io/load.c @@ -70,7 +70,7 @@ #include "floor/floor-town.h" #include "grid/grid.h" -#include "cmd-pet.h" +#include "pet/pet-util.h" #include "dungeon/dungeon-file.h" #include "io/uid-checker.h" #include "io/files-util.h" diff --git a/src/monster/monster-direction.c b/src/monster/monster-direction.c index 1deb1b8b6..ee2b4af90 100644 --- a/src/monster/monster-direction.c +++ b/src/monster/monster-direction.c @@ -9,7 +9,7 @@ #include "monster/monster-sweep-grid.h" #include "monster/monster-util.h" #include "monster/monster-status.h" -#include "cmd/cmd-pet.h" +#include "pet/pet-util.h" /*! * @brief ペットが敵に接近するための方向を決定する diff --git a/src/monster/monster-move.c b/src/monster/monster-move.c index cf925031d..fd69d325f 100644 --- a/src/monster/monster-move.c +++ b/src/monster/monster-move.c @@ -8,7 +8,7 @@ #include "monster/monster-attack.h" #include "monster/monster-object.h" #include "monster/monster-update.h" -#include "cmd/cmd-pet.h" +#include "pet/pet-util.h" #include "monster/creature.h" #include "io/files-util.h" #include "monster/monster-status.h" diff --git a/src/monster/pet-fall-off.c b/src/monster/pet-fall-off.c index b74a742b0..ab163fb50 100644 --- a/src/monster/pet-fall-off.c +++ b/src/monster/pet-fall-off.c @@ -1,8 +1,9 @@ #include "monster/pet-fall-off.h" +#include "cmd/cmd-pet.h" // 暫定、player_can_ride_aux() を移動する #include "core/stuff-handler.h" -#include "cmd/cmd-pet.h" // 暫定、定数を見ているだけなのでutilへの分離を検討する. #include "floor/floor.h" #include "io/targeting.h" +#include "pet/pet-util.h" #include "player/player-damage.h" #include "player/player-move.h" #include "player/player-skill.h" diff --git a/src/mspell/mspells2.c b/src/mspell/mspells2.c index b12cbdbc5..a79ea481d 100644 --- a/src/mspell/mspells2.c +++ b/src/mspell/mspells2.c @@ -15,7 +15,7 @@ #include "util/util.h" #include "main/sound-definitions-table.h" -#include "cmd-pet.h" +#include "pet/pet-util.h" #include "effect/effect-characteristics.h" #include "grid/grid.h" #include "dungeon/quest.h" diff --git a/src/pet/pet-util.h b/src/pet/pet-util.h new file mode 100644 index 000000000..8ac500c1d --- /dev/null +++ b/src/pet/pet-util.h @@ -0,0 +1,39 @@ +#pragma once + +typedef enum pet_command { + PET_DISMISS = 1, /*!< ペットに関するコマンド: ペットを離す */ + PET_TARGET = 2, /*!< ペットに関するコマンド: ペットのターゲットを指定 */ + PET_STAY_CLOSE = 3, /*!< ペットに関するコマンド: 近くにいろ */ + PET_FOLLOW_ME = 4, /*!< ペットに関するコマンド: ついて来い */ + PET_SEEK_AND_DESTROY = 5, /*!< ペットに関するコマンド: 敵を見つけて倒せ */ + PET_ALLOW_SPACE = 6, /*!< ペットに関するコマンド: 少し離れていろ */ + PET_STAY_AWAY = 7, /*!< ペットに関するコマンド: 離れていろ */ + PET_OPEN_DOORS = 8, /*!< ペットに関するコマンド: ドア解放の許可 */ + PET_TAKE_ITEMS = 9, /*!< ペットに関するコマンド: アイテム取得の許可 */ + PET_TELEPORT = 10, /*!< ペットに関するコマンド: テレポートの許可 */ + PET_ATTACK_SPELL = 11, /*!< ペットに関するコマンド: 攻撃魔法の許可 */ + PET_SUMMON_SPELL = 12, /*!< ペットに関するコマンド: 召喚魔法の許可 */ + PET_BALL_SPELL = 13, /*!< ペットに関するコマンド: プレイヤーを魔法に巻き込む許可 */ + PET_RIDING = 14, /*!< ペットに関するコマンド: ペットに乗る */ + PET_NAME = 15, /*!< ペットに関するコマンド: ペットに名前をつける */ + PET_TWO_HANDS = 16, /*!< ペットに関するコマンド: 騎乗中に両手で武器を使うかどうか */ +} pet_command; + +typedef enum pet_follow_distance { + PET_CLOSE_DIST = 1, /*!<ペットの行動範囲…近くにいろ */ + PET_FOLLOW_DIST = 6, /*!<ペットの行動範囲…ついて来い */ + PET_SEEK_DIST = 10, /*!<ペットの行動範囲…特になし? */ + PET_DESTROY_DIST = 255, /*!<ペットの行動範囲…敵を見つけて倒せ */ + PET_SPACE_DIST = -10, /*!<ペットの行動範囲…少し離れていろ */ + PET_AWAY_DIST = -25, /*!<ペットの行動範囲…離れていろ */ +} pet_follow_distance; + +typedef enum pet_permission { + PF_OPEN_DOORS = 0x0001, /*!< ペットの行動許可…ドアを開けてよい */ + PF_PICKUP_ITEMS = 0x0002, /*!< ペットの行動許可…アイテムを拾ってよい */ + PF_TELEPORT = 0x0004, /*!< ペットの行動許可…テレポート魔法を使ってよい */ + PF_ATTACK_SPELL = 0x0008, /*!< ペットの行動許可…攻撃魔法を使ってよい */ + PF_SUMMON_SPELL = 0x0010, /*!< ペットの行動許可…召喚魔法を使ってよい */ + PF_BALL_SPELL = 0x0020, /*!< ペットの行動許可…ボール魔法でプレイヤーを巻き込んでよい */ + PF_TWO_HANDS = 0x0040, /*!< プレイヤーの騎乗フラグ…武器を片手で持つ */ +} pet_permission; diff --git a/src/player/player-status.c b/src/player/player-status.c index 5bc3ba89d..706b0fa5e 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -37,6 +37,7 @@ #include "realm/realm-hex.h" #include "realm/realm-song.h" #include "cmd/cmd-pet.h" +#include "pet/pet-util.h" #include "cmd/cmd-spell.h" #include "dungeon/dungeon.h" #include "object/object-kind.h" diff --git a/src/spell/spells2.c b/src/spell/spells2.c index 59be05157..149b28702 100644 --- a/src/spell/spells2.c +++ b/src/spell/spells2.c @@ -22,6 +22,7 @@ #include "object/artifact.h" #include "io/write-diary.h" #include "cmd/cmd-pet.h" +#include "pet/pet-util.h" #include "monster/pet-fall-off.h" #include "cmd/cmd-dump.h" #include "effect/effect-characteristics.h" -- 2.11.0