OSDN Git Service

[Refactor] #40466 Separated experience.c/h from player-effects.c/h
authorHourier <hourier@users.sourceforge.jp>
Tue, 30 Jun 2020 13:03:26 +0000 (22:03 +0900)
committerHourier <hourier@users.sourceforge.jp>
Tue, 30 Jun 2020 13:03:26 +0000 (22:03 +0900)
34 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd-action/cmd-spell.c
src/cmd-item/cmd-activate.c
src/cmd-item/cmd-eat.c
src/cmd-item/cmd-item.c
src/cmd-item/cmd-quaff.c
src/cmd-item/cmd-read.c
src/cmd-item/cmd-usestaff.c
src/cmd-item/cmd-zaprod.c
src/cmd-item/cmd-zapwand.c
src/cmd/cmd-basic.c
src/effect/effect-player-resist-hurt.c
src/floor/pattern-walk.c
src/mind/racial.c
src/monster-attack/monster-attack-status.c
src/monster-attack/monster-attack-switcher.c
src/monster-attack/monster-eating.c
src/monster/monster-status.c
src/mspell/mspells3.c
src/player/patron.c
src/player/player-effects.c
src/player/player-effects.h
src/realm/realm-death.c
src/realm/realm-life.c
src/realm/realm-song.c
src/spell-kind/spells-random.c
src/spell-realm/spells-trump.c
src/spell/spells-status.c
src/spell/spells3.c
src/status/experience.c [new file with mode: 0644]
src/status/experience.h [new file with mode: 0644]
src/wizard/wizard-special-process.c

index b5daa56..4efa8be 100644 (file)
     <ClCompile Include="..\..\src\status\element-resistance.c" />\r
     <ClCompile Include="..\..\src\status\form-changer.c" />\r
     <ClCompile Include="..\..\src\status\sight-setter.c" />\r
+    <ClCompile Include="..\..\src\status\experience.c" />\r
     <ClCompile Include="..\..\src\status\temporary-resistance.c" />\r
     <ClCompile Include="..\..\src\view\display-map.c" />\r
     <ClCompile Include="..\..\src\view\display-sub-windows.c" />\r
     <ClInclude Include="..\..\src\status\element-resistance.h" />\r
     <ClInclude Include="..\..\src\status\sight-setter.h" />\r
     <ClInclude Include="..\..\src\status\form-changer.h" />\r
+    <ClInclude Include="..\..\src\status\experience.h" />\r
     <ClInclude Include="..\..\src\status\temporary-resistance.h" />\r
     <ClInclude Include="..\..\src\system\alloc-entries.h" />\r
     <ClInclude Include="..\..\src\term\screen-processor.h" />\r
index 7e489cb..2e65498 100644 (file)
     <ClCompile Include="..\..\src\status\form-changer.c">
       <Filter>status</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\status\experience.c">
+      <Filter>status</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\status\form-changer.h">
       <Filter>status</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\status\experience.h">
+      <Filter>status</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 23a44f2..9d13bd2 100644 (file)
@@ -557,6 +557,7 @@ hengband_SOURCES = \
        status/bad-status-setter.c status/bad-status-setter.h \
        status/buff-setter.c status/buff-setter.h \
        status/element-resistance.c status/element-resistance.h \
+       status/experience.c status/experience.h \
        status/form-changer.c status/form-changer.h \
        status/sight-setter.c status/sight-setter.h \
        status/temporary-resistance.c status/temporary-resistance.h \
index 8d0b692..86f25df 100644 (file)
@@ -50,6 +50,7 @@
 #include "spell/spells-summon.h"
 #include "spell/spells-util.h"
 #include "spell/technic-info-table.h"
+#include "status/experience.h"
 #include "term/screen-processor.h"
 #include "util/buffer-shaper.h"
 #include "util/int-char-converter.h"
index 41280c1..e786bdc 100644 (file)
@@ -79,6 +79,7 @@
 #include "status/bad-status-setter.h"
 #include "status/buff-setter.h"
 #include "status/element-resistance.h"
+#include "status/experience.h"
 #include "status/form-changer.h"
 #include "status/sight-setter.h"
 #include "status/temporary-resistance.h"
index a21f948..7a400be 100644 (file)
@@ -25,6 +25,7 @@
 #include "player/avatar.h"
 #include "status/bad-status-setter.h"
 #include "player/digestion-processor.h"
+#include "player/mimic-info-table.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
@@ -33,7 +34,7 @@
 #include "spell-realm/spells-hex.h"
 #include "spell/spells-status.h"
 #include "status/element-resistance.h"
-#include "player/mimic-info-table.h"
+#include "status/experience.h"
 #include "sv-definition/sv-food-types.h"
 #include "sv-definition/sv-other-types.h"
 #include "util/string-processor.h"
index 383b7ca..20434a0 100644 (file)
@@ -70,6 +70,7 @@
 #include "realm/realm-names-table.h"
 #include "realm/realm-types.h"
 #include "spell-kind/spells-perception.h"
+#include "status/experience.h"
 #include "sv-definition/sv-lite-types.h"
 #include "term/screen-processor.h"
 #include "util/int-char-converter.h"
index 5ef758c..1bc35b3 100644 (file)
@@ -43,6 +43,7 @@
 #include "status/bad-status-setter.h"
 #include "status/buff-setter.h"
 #include "status/element-resistance.h"
+#include "status/experience.h"
 #include "status/form-changer.h"
 #include "status/sight-setter.h"
 #include "sv-definition/sv-potion-types.h"
index cab3730..9fd36c7 100644 (file)
@@ -51,6 +51,7 @@
 #include "status/bad-status-setter.h"
 #include "status/buff-setter.h"
 #include "status/element-resistance.h"
+#include "status/experience.h"
 #include "status/form-changer.h"
 #include "store/rumor.h"
 #include "sv-definition/sv-scroll-types.h"
index 7bfc2ee..eb08350 100644 (file)
@@ -37,6 +37,7 @@
 #include "spell/spells-staff-only.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
+#include "status/experience.h"
 #include "status/form-changer.h"
 #include "sv-definition/sv-staff-types.h"
 #include "term/screen-processor.h"
index f9fccda..4e11018 100644 (file)
@@ -31,6 +31,7 @@
 #include "spell-kind/spells-teleport.h"
 #include "spell/spells-status.h"
 #include "spell/spell-types.h"
+#include "status/experience.h"
 #include "sv-definition/sv-other-types.h"
 #include "sv-definition/sv-rod-types.h"
 #include "status/form-changer.h"
index 8d040ba..79046ca 100644 (file)
@@ -27,6 +27,7 @@
 #include "spell-kind/spells-teleport.h"
 #include "spell/spells-status.h"
 #include "spell/spell-types.h"
+#include "status/experience.h"
 #include "sv-definition/sv-wand-types.h"
 #include "term/screen-processor.h"
 #include "view/display-messages.h"
index 8fd7cf7..28e358c 100644 (file)
@@ -71,7 +71,6 @@
 #include "object/object-info.h"
 #include "perception/object-perception.h"
 #include "player/avatar.h"
-#include "status/bad-status-setter.h"
 #include "player/player-effects.h"
 #include "player/player-move.h"
 #include "player/player-personalities-types.h"
@@ -82,6 +81,8 @@
 #include "specific-object/torch.h"
 #include "spell-kind/spells-teleport.h"
 #include "spell-realm/spells-hex.h"
+#include "status/bad-status-setter.h"
+#include "status/experience.h"
 #include "sv-definition/sv-bow-types.h"
 #include "system/system-variables.h"
 #include "term/screen-processor.h"
index 511a106..35f3207 100644 (file)
@@ -15,6 +15,7 @@
 #include "spell/spells-status.h"
 #include "spell/spells3.h"
 #include "status/element-resistance.h"
+#include "status/experience.h"
 #include "system/object-type-definition.h"
 #include "view/display-messages.h"
 #include "world/world.h"
index 66c396c..874cd64 100644 (file)
@@ -9,14 +9,14 @@
 #include "grid/grid.h"
 #include "io/input-key-requester.h"
 #include "io/write-diary.h"
-#include "status/bad-status-setter.h"
 #include "player/player-damage.h"
-#include "player/player-effects.h"
 #include "player/player-move.h"
 #include "player/player-race-types.h"
 #include "player/player-race.h"
 #include "spell/spells-status.h"
 #include "spell-kind/spells-teleport.h"
+#include "status/bad-status-setter.h"
+#include "status/experience.h"
 #include "view/display-messages.h"
 
 /*!
index 8764527..1cee311 100644 (file)
@@ -66,6 +66,7 @@
 #include "spell/spells-status.h"
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
+#include "status/experience.h"
 #include "term/screen-processor.h"
 #include "util/int-char-converter.h"
 #include "view/display-messages.h"
index bac440c..3aca4f1 100644 (file)
@@ -8,8 +8,9 @@
 #include "mind/mind-mirror-master.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-indice-types.h"
-#include "status/bad-status-setter.h"
 #include "player/player-effects.h"
+#include "status/bad-status-setter.h"
+#include "status/experience.h"
 #include "view/display-messages.h"
 
 void process_blind_attack(player_type *target_ptr, monap_type *monap_ptr)
index f37928e..592694c 100644 (file)
@@ -18,6 +18,7 @@
 #include "spell/spells3.h"
 #include "status/bad-status-setter.h"
 #include "status/element-resistance.h"
+#include "status/experience.h"
 #include "system/object-type-definition.h"
 #include "view/display-messages.h"
 
index 9575be3..3fc90f9 100644 (file)
@@ -16,7 +16,7 @@
 #include "object/object-info.h"
 #include "player/avatar.h"
 #include "player/mimic-info-table.h"
-#include "player/player-effects.h"
+#include "status/experience.h"
 #include "view/display-messages.h"
 #include "world/world-object.h"
 
index 788b8a4..8659661 100644 (file)
 #include "mspell/mspell-mask-definitions.h"
 #include "object-enchant/object-curse.h"
 #include "player/avatar.h"
-#include "player/player-effects.h"
 #include "player/player-personalities-types.h"
 #include "player/special-defense-types.h"
 #include "spell-kind/spells-random.h"
 #include "spell/spells-summon.h"
+#include "status/experience.h"
 #include "view/display-messages.h"
 #include "world/world.h"
 
index e39fb6f..cc459e2 100644 (file)
@@ -57,6 +57,7 @@
 #include "spell/spell-types.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
+#include "status/experience.h"
 #include "term/screen-processor.h"
 #include "util/int-char-converter.h"
 #include "view/display-messages.h"
index a2b78bf..8d9e6a2 100644 (file)
@@ -24,6 +24,7 @@
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
 #include "spell/spell-types.h"
+#include "status/experience.h"
 #include "view/display-messages.h"
 
 #ifdef JP
index 91f7c0b..4a09510 100644 (file)
@@ -930,21 +930,6 @@ bool do_inc_stat(player_type *creature_ptr, int stat)
 }
 
 /*
- * Restores any drained experience
- */
-bool restore_level(player_type *creature_ptr)
-{
-    if (creature_ptr->exp < creature_ptr->max_exp) {
-        msg_print(_("経験値が戻ってきた気がする。", "You feel your experience returning."));
-        creature_ptr->exp = creature_ptr->max_exp;
-        check_experience(creature_ptr);
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-/*
  * Forget everything
  */
 bool lose_all_info(player_type *creature_ptr)
@@ -1143,30 +1128,6 @@ void do_poly_self(player_type *creature_ptr)
     }
 }
 
-/*
- * Gain experience
- */
-void gain_exp_64(player_type *creature_ptr, s32b amount, u32b amount_frac)
-{
-    if (creature_ptr->is_dead)
-        return;
-    if (creature_ptr->prace == RACE_ANDROID)
-        return;
-
-    s64b_add(&(creature_ptr->exp), &(creature_ptr->exp_frac), amount, amount_frac);
-
-    if (creature_ptr->exp < creature_ptr->max_exp) {
-        creature_ptr->max_exp += amount / 5;
-    }
-
-    check_experience(creature_ptr);
-}
-
-/*
- * Gain experience
- */
-void gain_exp(player_type *creature_ptr, s32b amount) { gain_exp_64(creature_ptr, amount, 0L); }
-
 void calc_android_exp(player_type *creature_ptr)
 {
     u32b total_exp = 0;
@@ -1258,44 +1219,3 @@ void calc_android_exp(player_type *creature_ptr)
     creature_ptr->exp = creature_ptr->max_exp = total_exp;
     check_experience(creature_ptr);
 }
-
-/*
- * Lose experience
- */
-void lose_exp(player_type *creature_ptr, s32b amount)
-{
-    if (creature_ptr->prace == RACE_ANDROID)
-        return;
-    if (amount > creature_ptr->exp)
-        amount = creature_ptr->exp;
-
-    creature_ptr->exp -= amount;
-
-    check_experience(creature_ptr);
-}
-
-/*
- * Drain experience
- * If resisted to draining, return FALSE
- */
-bool drain_exp(player_type *creature_ptr, s32b drain, s32b slip, int hold_exp_prob)
-{
-    if (creature_ptr->prace == RACE_ANDROID)
-        return FALSE;
-
-    if (creature_ptr->hold_exp && (randint0(100) < hold_exp_prob)) {
-        msg_print(_("しかし自己の経験値を守りきった!", "You keep hold of your experience!"));
-        return FALSE;
-    }
-
-    if (creature_ptr->hold_exp) {
-        msg_print(_("経験値を少し吸い取られた気がする!", "You feel your experience slipping away!"));
-        lose_exp(creature_ptr, slip);
-    } else {
-        msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away!"));
-        lose_exp(creature_ptr, drain);
-    }
-
-    return TRUE;
-}
-
index 521d0fa..65196ef 100644 (file)
@@ -20,13 +20,8 @@ bool hp_player(player_type *creature_ptr, int num);
 bool do_dec_stat(player_type *creature_ptr, int stat);
 bool do_res_stat(player_type *creature_ptr, int stat);
 bool do_inc_stat(player_type *creature_ptr, int stat);
-bool restore_level(player_type *creature_ptr);
 bool lose_all_info(player_type *creature_ptr);
-void gain_exp_64(player_type *creature_ptr, s32b amount, u32b amount_frac);
-void gain_exp(player_type *creature_ptr, s32b amount);
 void calc_android_exp(player_type *creature_ptr);
-void lose_exp(player_type *creature_ptr, s32b amount);
-bool drain_exp(player_type *creature_ptr, s32b drain, s32b slip, int hold_exp_prob);
 void do_poly_self(player_type *creature_ptr);
 void do_poly_wounds(player_type *creature_ptr);
 void change_race(player_type *creature_ptr, player_race_type new_race, concptr effect_msg);
index 26816b9..ad04113 100644 (file)
@@ -23,6 +23,7 @@
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
 #include "status/buff-setter.h"
+#include "status/experience.h"
 #include "status/form-changer.h"
 #include "status/element-resistance.h"
 
index 6646f71..ed14503 100644 (file)
@@ -3,7 +3,6 @@
 #include "floor/floor.h"
 #include "io/targeting.h"
 #include "player/digestion-processor.h"
-#include "player/player-effects.h"
 #include "spell-kind/spells-curse-removal.h"
 #include "spell-kind/spells-detection.h"
 #include "spell-kind/spells-floor.h"
@@ -21,6 +20,7 @@
 #include "status/bad-status-setter.h"
 #include "status/buff-setter.h"
 #include "status/element-resistance.h"
+#include "status/experience.h"
 #include "status/temporary-resistance.h"
 
 /*!
index 07f9b0a..884a624 100644 (file)
@@ -17,6 +17,7 @@
 #include "spell/spells-status.h"
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
+#include "status/experience.h"
 #include "view/display-messages.h"
 
 /*!
index b837c00..5582ba2 100644 (file)
@@ -32,6 +32,7 @@
 #include "spell/spells-summon.h"
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
+#include "status/experience.h"
 #include "view/display-messages.h"
 
 /*!
index d86fb07..a00cacf 100644 (file)
@@ -17,6 +17,7 @@
 #include "spell-kind/spells-teleport.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
+#include "status/experience.h"
 #include "view/display-messages.h"
 
 /*!
index a3c482d..e402edd 100644 (file)
@@ -29,6 +29,7 @@
 #include "spell-kind/spells-launcher.h"
 #include "spell-kind/spells-teleport.h"
 #include "spell/spell-types.h"
+#include "status/experience.h"
 #include "status/form-changer.h"
 #include "status/sight-setter.h"
 #include "util/bit-flags-calculator.h"
index 6fa94b9..7050710 100644 (file)
 #include "spell/spells-summon.h"
 #include "spell/technic-info-table.h"
 #include "status/bad-status-setter.h"
+#include "status/experience.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
 #include "util/bit-flags-calculator.h"
diff --git a/src/status/experience.c b/src/status/experience.c
new file mode 100644 (file)
index 0000000..1f342ce
--- /dev/null
@@ -0,0 +1,81 @@
+#include "status/experience.h"
+#include "view/display-messages.h"
+
+/*
+ * Gain experience
+ */
+void gain_exp_64(player_type *creature_ptr, s32b amount, u32b amount_frac)
+{
+    if (creature_ptr->is_dead)
+        return;
+    if (creature_ptr->prace == RACE_ANDROID)
+        return;
+
+    s64b_add(&(creature_ptr->exp), &(creature_ptr->exp_frac), amount, amount_frac);
+
+    if (creature_ptr->exp < creature_ptr->max_exp) {
+        creature_ptr->max_exp += amount / 5;
+    }
+
+    check_experience(creature_ptr);
+}
+
+/*
+ * Gain experience
+ */
+void gain_exp(player_type *creature_ptr, s32b amount) { gain_exp_64(creature_ptr, amount, 0L); }
+
+/*
+ * Lose experience
+ */
+void lose_exp(player_type *creature_ptr, s32b amount)
+{
+    if (creature_ptr->prace == RACE_ANDROID)
+        return;
+    if (amount > creature_ptr->exp)
+        amount = creature_ptr->exp;
+
+    creature_ptr->exp -= amount;
+
+    check_experience(creature_ptr);
+}
+
+/*
+ * Restores any drained experience
+ */
+bool restore_level(player_type *creature_ptr)
+{
+    if (creature_ptr->exp < creature_ptr->max_exp) {
+        msg_print(_("経験値が戻ってきた気がする。", "You feel your experience returning."));
+        creature_ptr->exp = creature_ptr->max_exp;
+        check_experience(creature_ptr);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+/*
+ * Drain experience
+ * If resisted to draining, return FALSE
+ */
+bool drain_exp(player_type *creature_ptr, s32b drain, s32b slip, int hold_exp_prob)
+{
+    if (creature_ptr->prace == RACE_ANDROID)
+        return FALSE;
+
+    if (creature_ptr->hold_exp && (randint0(100) < hold_exp_prob)) {
+        msg_print(_("しかし自己の経験値を守りきった!", "You keep hold of your experience!"));
+        return FALSE;
+    }
+
+    if (creature_ptr->hold_exp) {
+        msg_print(_("経験値を少し吸い取られた気がする!", "You feel your experience slipping away!"));
+        lose_exp(creature_ptr, slip);
+    } else {
+        msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away!"));
+        lose_exp(creature_ptr, drain);
+    }
+
+    return TRUE;
+}
diff --git a/src/status/experience.h b/src/status/experience.h
new file mode 100644 (file)
index 0000000..1d811d8
--- /dev/null
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "system/angband.h"
+
+void gain_exp_64(player_type *creature_ptr, s32b amount, u32b amount_frac);
+void gain_exp(player_type *creature_ptr, s32b amount);
+bool restore_level(player_type *creature_ptr);
+void lose_exp(player_type *creature_ptr, s32b amount);
+bool drain_exp(player_type *creature_ptr, s32b drain, s32b slip, int hold_exp_prob);
index e9bbabc..bcc6d46 100644 (file)
@@ -58,7 +58,6 @@
 #include "player/digestion-processor.h"
 #include "player/patron.h"
 #include "player/player-class.h"
-#include "player/player-effects.h"
 #include "player/player-race-types.h"
 #include "player/player-skill.h"
 #include "player/player-status.h"
@@ -72,6 +71,7 @@
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
 #include "spell/spells-util.h"
+#include "status/experience.h"
 #include "system/alloc-entries.h"
 #include "system/angband-version.h"
 #include "term/screen-processor.h"