From 56ff826111b66055a93bdb840d0c2771cea73452 Mon Sep 17 00:00:00 2001 From: Hourier Date: Wed, 29 Apr 2020 11:05:38 +0900 Subject: [PATCH] [Refactor] #39963 Separated spells-common.c.h from spells1.c/spells.h --- Hengband_vcs2017/Hengband/Hengband.vcxproj | 2 + Hengband_vcs2017/Hengband/Hengband.vcxproj.filters | 114 +++++++++--------- src/Makefile.am | 3 +- src/cmd/cmd-hissatsu.c | 2 +- src/cmd/cmd-spell.c | 1 + src/core.c | 2 +- src/knowledge/knowledge-experiences.c | 1 + src/player-class.h | 1 + src/player-status.c | 2 +- src/realm-hex.c | 2 +- src/realm-hissatsu.c | 2 +- src/spell/spells-common.c | 125 ++++++++++++++++++++ src/spell/spells-common.h | 15 +++ src/spells.h | 16 --- src/spells1.c | 128 +-------------------- src/spells3.c | 1 + 16 files changed, 214 insertions(+), 203 deletions(-) create mode 100644 src/spell/spells-common.c create mode 100644 src/spell/spells-common.h diff --git a/Hengband_vcs2017/Hengband/Hengband.vcxproj b/Hengband_vcs2017/Hengband/Hengband.vcxproj index e2486c807..8e1c8f666 100644 --- a/Hengband_vcs2017/Hengband/Hengband.vcxproj +++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj @@ -305,6 +305,7 @@ + @@ -508,6 +509,7 @@ + diff --git a/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters b/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters index 8feb5defb..3da005dc5 100644 --- a/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters +++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters @@ -7,31 +7,31 @@ - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell floor @@ -143,55 +143,55 @@ player - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell floor @@ -209,7 +209,7 @@ io - spells + spell player @@ -302,7 +302,7 @@ io - spells + spell creature @@ -694,6 +694,9 @@ effect + + spell + @@ -708,25 +711,25 @@ - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell floor @@ -828,46 +831,46 @@ player - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell - spells + spell floor @@ -882,7 +885,7 @@ player - spells + spell object @@ -972,7 +975,7 @@ cmd - spells + spell io @@ -1391,6 +1394,9 @@ effect + + spell + @@ -1415,9 +1421,6 @@ {1be1a971-e67f-4d7c-ace0-aab22a039851} - - {4e443fe1-9ff8-4786-b43f-7e4d106760dc} - {dae7a35f-36af-4097-905f-b9b9aad50d6e} @@ -1451,6 +1454,9 @@ {ed8a9f97-b54e-4204-9076-f32f646f3762} + + {4e443fe1-9ff8-4786-b43f-7e4d106760dc} + diff --git a/src/Makefile.am b/src/Makefile.am index 53c284dfe..564870b62 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -161,6 +161,7 @@ hengband_SOURCES = \ effect/effect-feature.c effect/effect-feature.h \ effect/effect-item.c effect/effect-item.h \ \ + spell/spells-common.c spell/spells-common.h \ spells.h \ spells1.c spells2.c spells3.c \ spells-diceroll.c spells-diceroll.h \ @@ -225,7 +226,7 @@ LIBS += $(XFT_LIBS) COMPILE = $(srcdir)/gcc-wrap $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \ -Iautopick -Icmd -Icombat -Icore -Ieffect -Iio -Iknowledge -Imarket \ - -Imonster -Iobject -Iplayer -Iroom -Iview + -Imonster -Iobject -Iplayer -Iroom -Ispell -Iview install-exec-hook: if SET_GID diff --git a/src/cmd/cmd-hissatsu.c b/src/cmd/cmd-hissatsu.c index a31c9163f..4af1bd77d 100644 --- a/src/cmd/cmd-hissatsu.c +++ b/src/cmd/cmd-hissatsu.c @@ -19,7 +19,7 @@ #include "player-status.h" #include "player-effects.h" #include "player-inventory.h" -#include "spells.h" +#include "spell/spells-common.h" #include "cmd-basic.h" #include "cmd-spell.h" diff --git a/src/cmd/cmd-spell.c b/src/cmd/cmd-spell.c index 343fc4352..cc1851797 100644 --- a/src/cmd/cmd-spell.c +++ b/src/cmd/cmd-spell.c @@ -15,6 +15,7 @@ #include "io/write-diary.h" #include "cmd/cmd-dump.h" #include "selfinfo.h" +#include "spell/spells-common.h" #include "spells.h" #include "spells-summon.h" #include "realm-hex.h" diff --git a/src/core.c b/src/core.c index aeff6148f..a7c44c571 100644 --- a/src/core.c +++ b/src/core.c @@ -63,7 +63,7 @@ #include "knowledge/knowledge-autopick.h" #include "knowledge/knowledge-quests.h" #include "market/store.h" -#include "spells.h" +#include "spell/spells-common.h" #include "spells-summon.h" #include "spells-object.h" #include "spells-status.h" diff --git a/src/knowledge/knowledge-experiences.c b/src/knowledge/knowledge-experiences.c index 55694b67c..1822586cf 100644 --- a/src/knowledge/knowledge-experiences.c +++ b/src/knowledge/knowledge-experiences.c @@ -11,6 +11,7 @@ #include "object-flavor.h" #include "object/object-kind.h" #include "player-skill.h" +#include "spell/spells-common.h" /* * Display weapon-exp diff --git a/src/player-class.h b/src/player-class.h index ebe90f6f5..f0ec5edb6 100644 --- a/src/player-class.h +++ b/src/player-class.h @@ -1,5 +1,6 @@ #pragma once #include "spells.h" +#include "spell/spells-common.h" #include "player-status.h" /* diff --git a/src/player-status.c b/src/player-status.c index b7ab80c89..6b3f279c7 100644 --- a/src/player-status.c +++ b/src/player-status.c @@ -19,7 +19,7 @@ #include "feature.h" #include "artifact.h" #include "avatar.h" -#include "spells.h" +#include "spell/spells-common.h" #include "spells-status.h" #include "object.h" #include "object-hook.h" diff --git a/src/realm-hex.c b/src/realm-hex.c index 0894ccd6a..3934420d0 100644 --- a/src/realm-hex.c +++ b/src/realm-hex.c @@ -25,7 +25,7 @@ #include "object-hook.h" #include "object-curse.h" #include "spells-status.h" -#include "spells.h" +#include "spell/spells-common.h" #include "player-status.h" #include "player-effects.h" #include "player-skill.h" diff --git a/src/realm-hissatsu.c b/src/realm-hissatsu.c index cad6e44bd..a34d798de 100644 --- a/src/realm-hissatsu.c +++ b/src/realm-hissatsu.c @@ -15,7 +15,7 @@ #include "player-effects.h" #include "player-damage.h" #include "feature.h" -#include "spells.h" +#include "spell/spells-common.h" #include "grid.h" #include "targeting.h" #include "view/display-main-window.h" diff --git a/src/spell/spells-common.c b/src/spell/spells-common.c new file mode 100644 index 000000000..53dc4d25c --- /dev/null +++ b/src/spell/spells-common.c @@ -0,0 +1,125 @@ +#include "angband.h" +#include "spell/spells-common.h" + +/*! + * @brief ‰ÌAŒ•pAŽôp—̈æî•ñƒe[ƒuƒ‹ + */ +const magic_type technic_info[NUM_TECHNIC][32] = +{ + { + /* Music */ + { 1, 1, 10, 2}, + { 2, 1, 10, 2}, + { 3, 2, 20, 3}, + { 4, 2, 20, 4}, + { 5, 2, 20, 6}, + { 7, 4, 30, 8}, + { 9, 3, 30, 10}, + { 10, 2, 30, 12}, + + { 12, 3, 40, 20}, + { 15, 16, 42, 35}, + { 17, 18, 40, 25}, + { 18, 2, 45, 30}, + { 23, 8, 50, 38}, + { 28, 30, 50, 41}, + { 33, 35, 60, 42}, + { 38, 35, 70, 46}, + + { 10, 4, 20, 13}, + { 22, 5, 30, 26}, + { 23, 3, 35, 27}, + { 26, 28, 37, 29}, + { 32, 37, 41, 36}, + { 33, 22, 43, 40}, + { 37, 35, 46, 42}, + { 45, 60, 50, 56}, + + { 23, 18, 20, 23}, + { 30, 30, 30, 26}, + { 33, 65, 41, 30}, + { 37, 35, 43, 35}, + { 40, 30, 46, 50}, + { 42, 75, 50, 68}, + { 45, 58, 62, 73}, + { 49, 48, 70, 200} + }, + + { + /* Hissatsu */ + { 1, 15, 0, 0}, + { 3, 10, 0, 0}, + { 6, 15, 0, 0}, + { 9, 8, 0, 0}, + { 10, 12, 0, 0}, + { 12, 25, 0, 0}, + { 14, 7, 0, 0}, + { 17, 20, 0, 0}, + + { 19, 10, 0, 0}, + { 22, 20, 0, 0}, + { 24, 30, 0, 0}, + { 25, 10, 0, 0}, + { 27, 15, 0, 0}, + { 29, 45, 0, 0}, + { 32, 70, 0, 0}, + { 35, 50, 0, 0}, + + { 18, 40, 0, 0}, + { 22, 22, 0, 0}, + { 24, 30, 0, 0}, + { 26, 35, 0, 0}, + { 30, 30, 0, 0}, + { 32, 60, 0, 0}, + { 36, 40, 0, 0}, + { 39, 80, 0, 0}, + + { 26, 20, 0, 0}, + { 29, 40, 0, 0}, + { 31, 35, 0, 0}, + { 36, 80, 0, 0}, + { 39, 100, 0, 0}, + { 42, 110, 0, 0}, + { 45, 130, 0, 0}, + { 50, 255, 0, 0} + }, + + { + /* Hex */ + { 1, 2, 20, 2}, + { 1, 2, 20, 2}, + { 3, 2, 30, 3}, + { 5, 3, 30, 4}, + { 7, 3, 40, 6}, + { 8, 10, 60, 8}, + { 9, 3, 30, 10}, + { 10, 5, 40, 12}, + + { 12, 8, 40, 15}, + { 12, 9, 35, 15}, + { 15, 10, 50, 20}, + { 20, 12, 45, 35}, + { 25, 15, 50, 50}, + { 30, 12, 60, 70}, + { 35, 10, 60, 80}, + { 40, 16, 70, 100}, + + { 15, 8, 20, 20}, + { 18, 15, 50, 20}, + { 22, 10, 65, 35}, + { 25, 28, 70, 50}, + { 28, 10, 70, 60}, + { 30, 20, 60, 60}, + { 36, 22, 70, 80}, + { 40, 28, 70, 100}, + + { 5, 6, 35, 5}, + { 22, 24, 70, 40}, + { 25, 2, 65, 50}, + { 32, 20, 50, 70}, + { 35, 35, 70, 80}, + { 38, 32, 70, 90}, + { 42, 24, 70, 120}, + { 46, 45, 80, 200} + }, +}; diff --git a/src/spell/spells-common.h b/src/spell/spells-common.h new file mode 100644 index 000000000..888caf2df --- /dev/null +++ b/src/spell/spells-common.h @@ -0,0 +1,15 @@ +#pragma once + +/* + * The "name" of spell 'N' is stored as spell_names[X][N], + * where X is 0 for mage-spells and 1 for priest-spells. + */ +typedef struct +{ + PLAYER_LEVEL slevel; /* Required level (to learn) */ + MANA_POINT smana; /* Required mana (to cast) */ + PERCENTAGE sfail; /* Minimum chance of failure */ + EXP sexp; /* Encoded experience bonus */ +} magic_type; + +extern const magic_type technic_info[NUM_TECHNIC][32]; diff --git a/src/spells.h b/src/spells.h index 4795be33e..7644fe9bd 100644 --- a/src/spells.h +++ b/src/spells.h @@ -126,20 +126,6 @@ extern concptr exe_spell(player_type *caster_ptr, REALM_IDX realm, SPELL_IDX spe #define MAX_GF 117 -/* - * The "name" of spell 'N' is stored as spell_names[X][N], - * where X is 0 for mage-spells and 1 for priest-spells. - */ -typedef struct magic_type magic_type; - -struct magic_type -{ - PLAYER_LEVEL slevel; /* Required level (to learn) */ - MANA_POINT smana; /* Required mana (to cast) */ - PERCENTAGE sfail; /* Minimum chance of failure */ - EXP sexp; /* Encoded experience bonus */ -}; - extern int cap_mon; extern int cap_mspeed; extern HIT_POINT cap_hp; @@ -147,8 +133,6 @@ extern HIT_POINT cap_maxhp; extern STR_OFFSET cap_nickname; extern bool sukekaku; -extern const magic_type technic_info[NUM_TECHNIC][32]; - /* spells1.c */ extern bool in_disintegration_range(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2); extern void breath_shape(player_type *caster_ptr, u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *gy, POSITION *gm, POSITION *pgm_rad, POSITION rad, POSITION y1, POSITION x1, POSITION y2, POSITION x2, EFFECT_ID typ); diff --git a/src/spells1.c b/src/spells1.c index 27c831969..a65e74353 100644 --- a/src/spells1.c +++ b/src/spells1.c @@ -81,130 +81,6 @@ HIT_POINT cap_maxhp; STR_OFFSET cap_nickname; /*! - * @brief 歌、剣術、呪術領域情報テーブル - */ -const magic_type technic_info[NUM_TECHNIC][32] = -{ - { - /* Music */ - { 1, 1, 10, 2}, - { 2, 1, 10, 2}, - { 3, 2, 20, 3}, - { 4, 2, 20, 4}, - { 5, 2, 20, 6}, - { 7, 4, 30, 8}, - { 9, 3, 30, 10}, - { 10, 2, 30, 12}, - - { 12, 3, 40, 20}, - { 15, 16, 42, 35}, - { 17, 18, 40, 25}, - { 18, 2, 45, 30}, - { 23, 8, 50, 38}, - { 28, 30, 50, 41}, - { 33, 35, 60, 42}, - { 38, 35, 70, 46}, - - { 10, 4, 20, 13}, - { 22, 5, 30, 26}, - { 23, 3, 35, 27}, - { 26, 28, 37, 29}, - { 32, 37, 41, 36}, - { 33, 22, 43, 40}, - { 37, 35, 46, 42}, - { 45, 60, 50, 56}, - - { 23, 18, 20, 23}, - { 30, 30, 30, 26}, - { 33, 65, 41, 30}, - { 37, 35, 43, 35}, - { 40, 30, 46, 50}, - { 42, 75, 50, 68}, - { 45, 58, 62, 73}, - { 49, 48, 70, 200} - }, - - { - /* Hissatsu */ - { 1, 15, 0, 0}, - { 3, 10, 0, 0}, - { 6, 15, 0, 0}, - { 9, 8, 0, 0}, - { 10, 12, 0, 0}, - { 12, 25, 0, 0}, - { 14, 7, 0, 0}, - { 17, 20, 0, 0}, - - { 19, 10, 0, 0}, - { 22, 20, 0, 0}, - { 24, 30, 0, 0}, - { 25, 10, 0, 0}, - { 27, 15, 0, 0}, - { 29, 45, 0, 0}, - { 32, 70, 0, 0}, - { 35, 50, 0, 0}, - - { 18, 40, 0, 0}, - { 22, 22, 0, 0}, - { 24, 30, 0, 0}, - { 26, 35, 0, 0}, - { 30, 30, 0, 0}, - { 32, 60, 0, 0}, - { 36, 40, 0, 0}, - { 39, 80, 0, 0}, - - { 26, 20, 0, 0}, - { 29, 40, 0, 0}, - { 31, 35, 0, 0}, - { 36, 80, 0, 0}, - { 39, 100, 0, 0}, - { 42, 110, 0, 0}, - { 45, 130, 0, 0}, - { 50, 255, 0, 0} - }, - - { - /* Hex */ - { 1, 2, 20, 2}, - { 1, 2, 20, 2}, - { 3, 2, 30, 3}, - { 5, 3, 30, 4}, - { 7, 3, 40, 6}, - { 8, 10, 60, 8}, - { 9, 3, 30, 10}, - { 10, 5, 40, 12}, - - { 12, 8, 40, 15}, - { 12, 9, 35, 15}, - { 15, 10, 50, 20}, - { 20, 12, 45, 35}, - { 25, 15, 50, 50}, - { 30, 12, 60, 70}, - { 35, 10, 60, 80}, - { 40, 16, 70, 100}, - - { 15, 8, 20, 20}, - { 18, 15, 50, 20}, - { 22, 10, 65, 35}, - { 25, 28, 70, 50}, - { 28, 10, 70, 60}, - { 30, 20, 60, 60}, - { 36, 22, 70, 80}, - { 40, 28, 70, 100}, - - { 5, 6, 35, 5}, - { 22, 24, 70, 40}, - { 25, 2, 65, 50}, - { 32, 20, 50, 70}, - { 35, 35, 70, 80}, - { 38, 32, 70, 90}, - { 42, 24, 70, 120}, - { 46, 45, 80, 200} - }, -}; - - -/*! * @brief 魔法処理のメインルーチン * @param realm 魔法領域のID * @param spell 各領域の魔法ID @@ -350,8 +226,6 @@ static POSITION monster_target_y; /*!< モンスターの攻撃目標Y座標 */ */ static bool project_m(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, bool see_s_msg) { - int tmp; - floor_type *floor_ptr = caster_ptr->current_floor_ptr; grid_type *g_ptr = &floor_ptr->grid_array[y][x]; @@ -2458,7 +2332,7 @@ static bool project_m(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSI if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(caster_ptr, V_HONOUR, -1); } - tmp = dam; + int tmp = dam; dam = mon_damage_mod(caster_ptr, m_ptr, dam, (bool)(typ == GF_PSY_SPEAR)); if ((tmp > 0) && (dam == 0)) note = _("はダメージを受けていない。", " is unharmed."); diff --git a/src/spells3.c b/src/spells3.c index e72e573b8..2a5f1f9ba 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -39,6 +39,7 @@ #include "avatar.h" #include "spells.h" #include "spells-floor.h" +#include "spell/spells-common.h" #include "grid.h" #include "market/building-util.h" #include "monster-process.h" -- 2.11.0