OSDN Git Service

[Refactor] #40482 Separated display-sub-window-spells.c/h from spells3.c/h
authorHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 04:41:45 +0000 (13:41 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 04:41:45 +0000 (13:41 +0900)
12 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/core/window-redrawer.c
src/effect/effect-monster-resist-hurt.c
src/effect/effect-player-resist-hurt.c
src/spell/spells3.c
src/spell/spells3.h
src/view/display-sub-window-spells.c [new file with mode: 0644]
src/view/display-sub-window-spells.h [new file with mode: 0644]
src/view/display-sub-windows.c
src/view/display-sub-windows.h

index baa5cf6..4b741c9 100644 (file)
     <ClCompile Include="..\..\src\status\temporary-resistance.c" />\r
     <ClCompile Include="..\..\src\view\display-inventory.c" />\r
     <ClCompile Include="..\..\src\view\display-map.c" />\r
+    <ClCompile Include="..\..\src\view\display-sub-window-spells.c" />\r
     <ClCompile Include="..\..\src\view\display-sub-windows.c" />\r
     <ClCompile Include="..\..\src\view\main-window-left-frame.c" />\r
     <ClCompile Include="..\..\src\view\main-window-stat-poster.c" />\r
     <ClInclude Include="..\..\src\view\display-map.h" />\r
     <ClInclude Include="..\..\src\view\display-messages.h" />\r
     <ClInclude Include="..\..\src\view\display-monster-status.h" />\r
+    <ClInclude Include="..\..\src\view\display-sub-window-spells.h" />\r
     <ClInclude Include="..\..\src\view\display-sub-windows.h" />\r
     <ClInclude Include="..\..\src\view\main-window-left-frame.h" />\r
     <ClInclude Include="..\..\src\view\main-window-row-column.h" />\r
index c7e9008..eebad30 100644 (file)
     <ClCompile Include="..\..\src\spell-kind\spells-equipment.c">
       <Filter>spell-kind</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\view\display-sub-window-spells.c">
+      <Filter>view</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\spell-kind\spells-equipment.h">
       <Filter>spell-kind</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\view\display-sub-window-spells.h">
+      <Filter>view</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 8bea251..0adc9e1 100644 (file)
@@ -628,7 +628,6 @@ hengband_SOURCES = \
        \
        view/display-birth.c view/display-birth.h \
        view/display-characteristic.c view/display-characteristic.h \
-       view/display-sub-windows.c view/display-sub-windows.h \
        view/display-fruit.c view/display-fruit.h \
        view/display-inventory.c view/display-inventory.h\
        view/display-lore-attacks.c view/display-lore-attacks.h \
@@ -643,6 +642,8 @@ hengband_SOURCES = \
        view/display-player-misc-info.c view/display-player-misc-info.h \
        view/display-player-middle.c view/display-player-middle.h \
        view/display-player.c view/display-player.h \
+       view/display-sub-window-spells.c view/display-sub-window-spells.h \
+       view/display-sub-windows.c view/display-sub-windows.h \
        view/display-util.c view/display-util.h \
        view/main-window-left-frame.c view/main-window-left-frame.h \
        view/main-window-row-column.h \
index 1d3a905..48b15d8 100644 (file)
@@ -14,6 +14,7 @@
 #include "view/display-messages.h"
 #include "view/display-player.h"
 #include "view/display-sub-windows.h"
+#include "view/display-sub-window-spells.h"
 #include "view/main-window-left-frame.h"
 #include "view/main-window-row-column.h"
 #include "view/main-window-stat-poster.h"
index 185ed57..b79cd46 100644 (file)
@@ -6,7 +6,6 @@
 #include "monster-race/race-indice-types.h"
 #include "monster/monster-status.h"
 #include "monster/monster-info.h"
-#include "spell-kind/spells-equipment.h"
 
 gf_switch_result effect_monster_void(effect_monster_type *em_ptr)
 {
index b80d06c..f30f679 100644 (file)
@@ -12,6 +12,7 @@
 #include "player/player-race-types.h"
 #include "player/player-race.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell-kind/spells-equipment.h"
 #include "spell/spells-status.h"
 #include "spell/spells3.h"
 #include "status/bad-status-setter.h"
index d8f28cb..9c2484d 100644 (file)
@@ -455,156 +455,6 @@ bool recharge(player_type *caster_ptr, int power)
 }
 
 /*!
- * @brief クリーチャー全既知呪文を表示する /
- * Hack -- Display all known spells in a window
- * @param caster_ptr 術者の参照ポインタ
- * return なし
- * @details
- * Need to analyze size of the window.
- * Need more color coding.
- */
-void display_spell_list(player_type *caster_ptr)
-{
-    TERM_LEN y, x;
-    int m[9];
-    const magic_type *s_ptr;
-    GAME_TEXT name[MAX_NLEN];
-    char out_val[160];
-
-    clear_from(0);
-
-    if (caster_ptr->pclass == CLASS_SORCERER)
-        return;
-    if (caster_ptr->pclass == CLASS_RED_MAGE)
-        return;
-    if (caster_ptr->pclass == CLASS_SNIPER) {
-        display_snipe_list(caster_ptr);
-        return;
-    }
-
-    if ((caster_ptr->pclass == CLASS_MINDCRAFTER) || (caster_ptr->pclass == CLASS_BERSERKER) || (caster_ptr->pclass == CLASS_NINJA)
-        || (caster_ptr->pclass == CLASS_MIRROR_MASTER) || (caster_ptr->pclass == CLASS_FORCETRAINER)) {
-        PERCENTAGE minfail = 0;
-        PLAYER_LEVEL plev = caster_ptr->lev;
-        PERCENTAGE chance = 0;
-        mind_type spell;
-        char comment[80];
-        char psi_desc[80];
-        int use_mind;
-        bool use_hp = FALSE;
-
-        y = 1;
-        x = 1;
-
-        prt("", y, x);
-        put_str(_("名前", "Name"), y, x + 5);
-        put_str(_("Lv   MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
-
-        switch (caster_ptr->pclass) {
-        case CLASS_MINDCRAFTER:
-            use_mind = MIND_MINDCRAFTER;
-            break;
-        case CLASS_FORCETRAINER:
-            use_mind = MIND_KI;
-            break;
-        case CLASS_BERSERKER:
-            use_mind = MIND_BERSERKER;
-            use_hp = TRUE;
-            break;
-        case CLASS_MIRROR_MASTER:
-            use_mind = MIND_MIRROR_MASTER;
-            break;
-        case CLASS_NINJA:
-            use_mind = MIND_NINJUTSU;
-            use_hp = TRUE;
-            break;
-        default:
-            use_mind = 0;
-            break;
-        }
-
-        for (int i = 0; i < MAX_MIND_POWERS; i++) {
-            byte a = TERM_WHITE;
-            spell = mind_powers[use_mind].info[i];
-            if (spell.min_lev > plev)
-                break;
-
-            chance = spell.fail;
-            chance -= 3 * (caster_ptr->lev - spell.min_lev);
-            chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
-            if (!use_hp) {
-                if (spell.mana_cost > caster_ptr->csp) {
-                    chance += 5 * (spell.mana_cost - caster_ptr->csp);
-                    a = TERM_ORANGE;
-                }
-            } else {
-                if (spell.mana_cost > caster_ptr->chp) {
-                    chance += 100;
-                    a = TERM_RED;
-                }
-            }
-
-            minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]];
-            if (chance < minfail)
-                chance = minfail;
-
-            if (caster_ptr->stun > 50)
-                chance += 25;
-            else if (caster_ptr->stun)
-                chance += 15;
-
-            if (chance > 95)
-                chance = 95;
-
-            mindcraft_info(caster_ptr, comment, use_mind, i);
-            sprintf(psi_desc, "  %c) %-30s%2d %4d %3d%%%s", I2A(i), spell.name, spell.min_lev, spell.mana_cost, chance, comment);
-
-            Term_putstr(x, y + i + 1, -1, a, psi_desc);
-        }
-
-        return;
-    }
-
-    if (REALM_NONE == caster_ptr->realm1)
-        return;
-
-    for (int j = 0; j < ((caster_ptr->realm2 > REALM_NONE) ? 2 : 1); j++) {
-        m[j] = 0;
-        y = (j < 3) ? 0 : (m[j - 3] + 2);
-        x = 27 * (j % 3);
-        int n = 0;
-        for (int i = 0; i < 32; i++) {
-            byte a = TERM_WHITE;
-
-            if (!is_magic((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2)) {
-                s_ptr = &technic_info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - MIN_TECHNIC][i % 32];
-            } else {
-                s_ptr = &mp_ptr->info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - 1][i % 32];
-            }
-
-            strcpy(name, exe_spell(caster_ptr, (j < 1) ? caster_ptr->realm1 : caster_ptr->realm2, i % 32, SPELL_NAME));
-
-            if (s_ptr->slevel >= 99) {
-                strcpy(name, _("(判読不能)", "(illegible)"));
-                a = TERM_L_DARK;
-            } else if ((j < 1) ? ((caster_ptr->spell_forgotten1 & (1L << i))) : ((caster_ptr->spell_forgotten2 & (1L << (i % 32))))) {
-                a = TERM_ORANGE;
-            } else if (!((j < 1) ? (caster_ptr->spell_learned1 & (1L << i)) : (caster_ptr->spell_learned2 & (1L << (i % 32))))) {
-                a = TERM_RED;
-            } else if (!((j < 1) ? (caster_ptr->spell_worked1 & (1L << i)) : (caster_ptr->spell_worked2 & (1L << (i % 32))))) {
-                a = TERM_YELLOW;
-            }
-
-            sprintf(out_val, "%c/%c) %-20.20s", I2A(n / 8), I2A(n % 8), name);
-
-            m[j] = y + n;
-            Term_putstr(x, m[j], -1, a, out_val);
-            n++;
-        }
-    }
-}
-
-/*!
  * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
  * Helper function -- return a "nearby" race for polymorphing
  * @param floor_ptr 配置するフロアの参照ポインタ
index 7cd2bc8..ab0f00c 100644 (file)
@@ -6,7 +6,6 @@ void reserve_alter_reality(player_type* caster_ptr);
 bool artifact_scroll(player_type* caster_ptr);
 bool mundane_spell(player_type* ownner_ptr, bool only_equip);
 bool recharge(player_type* caster_ptr, int power);
-void display_spell_list(player_type* caster_ptr);
 bool polymorph_monster(player_type* caster_ptr, POSITION y, POSITION x);
 void massacre(player_type* caster_ptr);
 bool eat_rock(player_type* caster_ptr);
diff --git a/src/view/display-sub-window-spells.c b/src/view/display-sub-window-spells.c
new file mode 100644 (file)
index 0000000..9114f3e
--- /dev/null
@@ -0,0 +1,187 @@
+#include "view/display-sub-window-spells.h"
+#include "game-option/option-flags.h"
+#include "mind/mind-sniper.h"
+#include "mind/mind.h"
+#include "player/player-class.h"
+#include "realm/realm-names-table.h"
+#include "spell/spells-execution.h"
+#include "spell/spells-util.h"
+#include "spell/technic-info-table.h"
+#include "term/gameterm.h"
+#include "term/screen-processor.h"
+#include "term/term-color-types.h"
+#include "util/int-char-converter.h"
+#include "view/display-messages.h"
+
+/*!
+ * @brief クリーチャー全既知呪文を表示する /
+ * Hack -- Display all known spells in a window
+ * @param caster_ptr 術者の参照ポインタ
+ * return なし
+ * @details
+ * Need to analyze size of the window.
+ * Need more color coding.
+ */
+static void display_spell_list(player_type *caster_ptr)
+{
+    TERM_LEN y, x;
+    int m[9];
+    const magic_type *s_ptr;
+    GAME_TEXT name[MAX_NLEN];
+    char out_val[160];
+
+    clear_from(0);
+
+    if (caster_ptr->pclass == CLASS_SORCERER)
+        return;
+    if (caster_ptr->pclass == CLASS_RED_MAGE)
+        return;
+    if (caster_ptr->pclass == CLASS_SNIPER) {
+        display_snipe_list(caster_ptr);
+        return;
+    }
+
+    if ((caster_ptr->pclass == CLASS_MINDCRAFTER) || (caster_ptr->pclass == CLASS_BERSERKER) || (caster_ptr->pclass == CLASS_NINJA)
+        || (caster_ptr->pclass == CLASS_MIRROR_MASTER) || (caster_ptr->pclass == CLASS_FORCETRAINER)) {
+        PERCENTAGE minfail = 0;
+        PLAYER_LEVEL plev = caster_ptr->lev;
+        PERCENTAGE chance = 0;
+        mind_type spell;
+        char comment[80];
+        char psi_desc[80];
+        int use_mind;
+        bool use_hp = FALSE;
+
+        y = 1;
+        x = 1;
+
+        prt("", y, x);
+        put_str(_("名前", "Name"), y, x + 5);
+        put_str(_("Lv   MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
+
+        switch (caster_ptr->pclass) {
+        case CLASS_MINDCRAFTER:
+            use_mind = MIND_MINDCRAFTER;
+            break;
+        case CLASS_FORCETRAINER:
+            use_mind = MIND_KI;
+            break;
+        case CLASS_BERSERKER:
+            use_mind = MIND_BERSERKER;
+            use_hp = TRUE;
+            break;
+        case CLASS_MIRROR_MASTER:
+            use_mind = MIND_MIRROR_MASTER;
+            break;
+        case CLASS_NINJA:
+            use_mind = MIND_NINJUTSU;
+            use_hp = TRUE;
+            break;
+        default:
+            use_mind = 0;
+            break;
+        }
+
+        for (int i = 0; i < MAX_MIND_POWERS; i++) {
+            byte a = TERM_WHITE;
+            spell = mind_powers[use_mind].info[i];
+            if (spell.min_lev > plev)
+                break;
+
+            chance = spell.fail;
+            chance -= 3 * (caster_ptr->lev - spell.min_lev);
+            chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
+            if (!use_hp) {
+                if (spell.mana_cost > caster_ptr->csp) {
+                    chance += 5 * (spell.mana_cost - caster_ptr->csp);
+                    a = TERM_ORANGE;
+                }
+            } else {
+                if (spell.mana_cost > caster_ptr->chp) {
+                    chance += 100;
+                    a = TERM_RED;
+                }
+            }
+
+            minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]];
+            if (chance < minfail)
+                chance = minfail;
+
+            if (caster_ptr->stun > 50)
+                chance += 25;
+            else if (caster_ptr->stun)
+                chance += 15;
+
+            if (chance > 95)
+                chance = 95;
+
+            mindcraft_info(caster_ptr, comment, use_mind, i);
+            sprintf(psi_desc, "  %c) %-30s%2d %4d %3d%%%s", I2A(i), spell.name, spell.min_lev, spell.mana_cost, chance, comment);
+
+            Term_putstr(x, y + i + 1, -1, a, psi_desc);
+        }
+
+        return;
+    }
+
+    if (REALM_NONE == caster_ptr->realm1)
+        return;
+
+    for (int j = 0; j < ((caster_ptr->realm2 > REALM_NONE) ? 2 : 1); j++) {
+        m[j] = 0;
+        y = (j < 3) ? 0 : (m[j - 3] + 2);
+        x = 27 * (j % 3);
+        int n = 0;
+        for (int i = 0; i < 32; i++) {
+            byte a = TERM_WHITE;
+
+            if (!is_magic((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2)) {
+                s_ptr = &technic_info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - MIN_TECHNIC][i % 32];
+            } else {
+                s_ptr = &mp_ptr->info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - 1][i % 32];
+            }
+
+            strcpy(name, exe_spell(caster_ptr, (j < 1) ? caster_ptr->realm1 : caster_ptr->realm2, i % 32, SPELL_NAME));
+
+            if (s_ptr->slevel >= 99) {
+                strcpy(name, _("(判読不能)", "(illegible)"));
+                a = TERM_L_DARK;
+            } else if ((j < 1) ? ((caster_ptr->spell_forgotten1 & (1L << i))) : ((caster_ptr->spell_forgotten2 & (1L << (i % 32))))) {
+                a = TERM_ORANGE;
+            } else if (!((j < 1) ? (caster_ptr->spell_learned1 & (1L << i)) : (caster_ptr->spell_learned2 & (1L << (i % 32))))) {
+                a = TERM_RED;
+            } else if (!((j < 1) ? (caster_ptr->spell_worked1 & (1L << i)) : (caster_ptr->spell_worked2 & (1L << (i % 32))))) {
+                a = TERM_YELLOW;
+            }
+
+            sprintf(out_val, "%c/%c) %-20.20s", I2A(n / 8), I2A(n % 8), name);
+
+            m[j] = y + n;
+            Term_putstr(x, m[j], -1, a, out_val);
+            n++;
+        }
+    }
+}
+
+/*!
+ * @brief 現在の習得済魔法をサブウィンドウに表示する /
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * Hack -- display spells in sub-windows
+ * @return なし
+ */
+void fix_spell(player_type *player_ptr)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        if (!angband_term[j])
+            continue;
+
+        if (!(window_flag[j] & (PW_SPELL)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        display_spell_list(player_ptr);
+        Term_fresh();
+        Term_activate(old);
+    }
+}
diff --git a/src/view/display-sub-window-spells.h b/src/view/display-sub-window-spells.h
new file mode 100644 (file)
index 0000000..4d86fa9
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "system/angband.h"
+
+void fix_spell(player_type *player_ptr);
index ac5a13d..43e6fc1 100644 (file)
@@ -266,29 +266,6 @@ void fix_equip(player_type *player_ptr, tval_type item_tester_tval)
 }
 
 /*!
- * @brief 現在の習得済魔法をサブウィンドウに表示する /
- * @param player_ptr プレーヤーへの参照ポインタ
- * Hack -- display spells in sub-windows
- * @return なし
- */
-void fix_spell(player_type *player_ptr)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        if (!angband_term[j])
-            continue;
-
-        if (!(window_flag[j] & (PW_SPELL)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        display_spell_list(player_ptr);
-        Term_fresh();
-        Term_activate(old);
-    }
-}
-
-/*!
  * @brief 現在のプレイヤーステータスをサブウィンドウに表示する /
  * @param player_ptr プレーヤーへの参照ポインタ
  * Hack -- display character in sub-windows
index 20e5813..b6ac6b5 100644 (file)
@@ -7,7 +7,6 @@ void fix_inventory(player_type *player_ptr, tval_type item_tester_tval);
 void print_monster_list(floor_type *floor_ptr, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines);
 void fix_monster_list(player_type *player_ptr);
 void fix_equip(player_type *player_ptr, tval_type item_tester_tval);
-void fix_spell(player_type *player_ptr);
 void fix_player(player_type *player_ptr);
 void fix_message(void);
 void fix_overhead(player_type *player_ptr);