OSDN Git Service

[Refactor] #40466 Moved set_food() from player-effects.c/h to digestion-processor.c/h
authorHourier <hourier@users.sourceforge.jp>
Mon, 29 Jun 2020 12:45:41 +0000 (21:45 +0900)
committerHourier <hourier@users.sourceforge.jp>
Mon, 29 Jun 2020 12:45:41 +0000 (21:45 +0900)
18 files changed:
src/cmd-building/cmd-inn.c
src/cmd-item/cmd-activate.c
src/cmd-item/cmd-eat.c
src/cmd-item/cmd-quaff.c
src/cmd-item/cmd-read.c
src/mind/racial-vampire.c
src/mutation/mutation-processor.c
src/player/digestion-processor.c
src/player/digestion-processor.h
src/player/player-effects.c
src/player/player-effects.h
src/player/player-status.c
src/realm/realm-arcane.c
src/realm/realm-craft.c
src/realm/realm-death.c
src/realm/realm-life.c
src/spell/spells3.c
src/wizard/wizard-special-process.c

index 7da20a8..8571a64 100644 (file)
@@ -5,8 +5,8 @@
 #include "io/write-diary.h"
 #include "market/building-actions-table.h"
 #include "status/bad-status-setter.h"
+#include "player/digestion-processor.h"
 #include "player/eldritch-horror.h"
-#include "player/player-effects.h"
 #include "player/player-race-types.h"
 #include "player/player-race.h"
 #include "store/rumor.h"
index efd0d23..44a3f58 100644 (file)
@@ -48,6 +48,7 @@
 #include "player/avatar.h"
 #include "status/bad-status-setter.h"
 #include "status/buff-setter.h"
+#include "player/digestion-processor.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
 #include "player/player-race-types.h"
index 1210198..348809e 100644 (file)
@@ -25,6 +25,7 @@
 #include "player/avatar.h"
 #include "status/bad-status-setter.h"
 #include "player/mimic-info-table.h"
+#include "player/digestion-processor.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
index 8a38e4a..f346bd4 100644 (file)
 #include "main/sound-of-music.h"
 #include "mutation/mutation.h"
 #include "object-hook/hook-expendable.h"
+#include "object/item-tester-hooker.h"
 #include "object/item-use-flags.h"
 #include "object/object-broken.h"
 #include "object/object-generator.h"
-#include "object/item-tester-hooker.h"
 #include "object/object-info.h"
 #include "object/object-kind.h"
 #include "perception/object-perception.h"
 #include "player/avatar.h"
-#include "status/bad-status-setter.h"
+#include "player/digestion-processor.h"
 #include "player/eldritch-horror.h"
 #include "player/mimic-info-table.h"
-#include "status/buff-setter.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
@@ -42,6 +41,8 @@
 #include "spell-realm/spells-hex.h"
 #include "spell/spells-status.h"
 #include "spell/spells3.h"
+#include "status/bad-status-setter.h"
+#include "status/buff-setter.h"
 #include "status/sight-setter.h"
 #include "sv-definition/sv-potion-types.h"
 #include "term/screen-processor.h"
index 0643ad8..650020c 100644 (file)
 #include "monster-floor/monster-summon.h"
 #include "monster-floor/place-monster-types.h"
 #include "object-hook/hook-expendable.h"
+#include "object/item-tester-hooker.h"
 #include "object/item-use-flags.h"
 #include "object/object-flavor.h"
-#include "object/item-tester-hooker.h"
 #include "object/object-info.h"
 #include "object/object-kind.h"
 #include "perception/object-perception.h"
 #include "player/avatar.h"
-#include "status/bad-status-setter.h"
-#include "status/buff-setter.h"
+#include "player/digestion-processor.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
 #include "spell-realm/spells-hex.h"
+#include "spell/spell-types.h"
 #include "spell/spells-object.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
-#include "spell/spell-types.h"
 #include "spell/spells3.h"
+#include "status/bad-status-setter.h"
+#include "status/buff-setter.h"
 #include "store/rumor.h"
 #include "sv-definition/sv-scroll-types.h"
 #include "term/screen-processor.h"
index 1932a55..9ccb4da 100644 (file)
@@ -3,6 +3,7 @@
 #include "floor/floor.h"
 #include "grid/grid.h"
 #include "io/targeting.h"
+#include "player/digestion-processor.h"
 #include "player/player-effects.h"
 #include "spell-kind/spells-specific-bolt.h"
 #include "view/display-messages.h"
index 8efd2b3..6711292 100644 (file)
@@ -10,6 +10,7 @@
 #include "object-hook/hook-checker.h"
 #include "object-hook/hook-enchant.h"
 #include "object/lite-processor.h"
+#include "player/digestion-processor.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
 #include "player/player-move.h"
index 49439c9..22720e9 100644 (file)
@@ -1,11 +1,14 @@
 #include "player/digestion-processor.h"
 #include "core/speed-table.h"
+#include "core/stuff-handler.h"
+#include "floor/wild.h"
+#include "game-option/disturbance-options.h"
 #include "object-enchant/trc-types.h"
+#include "player/avatar.h"
 #include "player/player-damage.h"
-#include "status/bad-status-setter.h"
-#include "player/player-effects.h"
 #include "player/player-move.h"
 #include "player/special-defense-types.h"
+#include "status/bad-status-setter.h"
 #include "view/display-messages.h"
 #include "world/world.h"
 
@@ -56,3 +59,135 @@ void starve_player(player_type *creature_ptr)
             take_hit(creature_ptr, DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
     }
 }
+
+/*!
+ * @brief 空腹状態をセットする / Set "food", notice observable changes
+ * @param v 継続時間
+ * @return ステータスに影響を及ぼす変化があった場合TRUEを返す
+ * @details
+ * Set "", notice observable changes\n
+ *\n
+ * The "food" variable can get as large as 20000, allowing the
+ * addition of the most "filling" item, Elvish Waybread, which adds
+ * 7500 food units, without overflowing the 32767 maximum limit.\n
+ *\n
+ * Perhaps we should disturb the player with various messages,
+ * especially messages about hunger status changes.  \n
+ *\n
+ * Digestion of food is handled in "dungeon.c", in which, normally,
+ * the player digests about 20 food units per 100 game turns, more
+ * when "fast", more when "regenerating", less with "slow digestion",
+ * but when the player is "gorged", he digests 100 food units per 10
+ * game turns, or a full 1000 food units per 100 game turns.\n
+ *\n
+ * Note that the player's speed is reduced by 10 units while gorged,
+ * so if the player eats a single food ration (5000 food units) when
+ * full (15000 food units), he will be gorged for (5000/100)*10 = 500
+ * game turns, or 500/(100/5) = 25 player turns (if nothing else is
+ * affecting the player speed).\n
+ */
+bool set_food(player_type *creature_ptr, TIME_EFFECT v)
+{
+    int old_aux, new_aux;
+
+    bool notice = FALSE;
+    v = (v > 20000) ? 20000 : (v < 0) ? 0 : v;
+    if (creature_ptr->food < PY_FOOD_FAINT) {
+        old_aux = 0;
+    } else if (creature_ptr->food < PY_FOOD_WEAK) {
+        old_aux = 1;
+    } else if (creature_ptr->food < PY_FOOD_ALERT) {
+        old_aux = 2;
+    } else if (creature_ptr->food < PY_FOOD_FULL) {
+        old_aux = 3;
+    } else if (creature_ptr->food < PY_FOOD_MAX) {
+        old_aux = 4;
+    } else {
+        old_aux = 5;
+    }
+
+    if (v < PY_FOOD_FAINT) {
+        new_aux = 0;
+    } else if (v < PY_FOOD_WEAK) {
+        new_aux = 1;
+    } else if (v < PY_FOOD_ALERT) {
+        new_aux = 2;
+    } else if (v < PY_FOOD_FULL) {
+        new_aux = 3;
+    } else if (v < PY_FOOD_MAX) {
+        new_aux = 4;
+    } else {
+        new_aux = 5;
+    }
+
+    if (old_aux < 1 && new_aux > 0)
+        chg_virtue(creature_ptr, V_PATIENCE, 2);
+    else if (old_aux < 3 && (old_aux != new_aux))
+        chg_virtue(creature_ptr, V_PATIENCE, 1);
+    if (old_aux == 2)
+        chg_virtue(creature_ptr, V_TEMPERANCE, 1);
+    if (old_aux == 0)
+        chg_virtue(creature_ptr, V_TEMPERANCE, -1);
+
+    if (new_aux > old_aux) {
+        switch (new_aux) {
+        case 1:
+            msg_print(_("まだ空腹で倒れそうだ。", "You are still weak."));
+            break;
+        case 2:
+            msg_print(_("まだ空腹だ。", "You are still hungry."));
+            break;
+        case 3:
+            msg_print(_("空腹感がおさまった。", "You are no longer hungry."));
+            break;
+        case 4:
+            msg_print(_("満腹だ!", "You are full!"));
+            break;
+
+        case 5:
+            msg_print(_("食べ過ぎだ!", "You have gorged yourself!"));
+            chg_virtue(creature_ptr, V_HARMONY, -1);
+            chg_virtue(creature_ptr, V_PATIENCE, -1);
+            chg_virtue(creature_ptr, V_TEMPERANCE, -2);
+            break;
+        }
+
+        notice = TRUE;
+    } else if (new_aux < old_aux) {
+        switch (new_aux) {
+        case 0:
+            msg_print(_("あまりにも空腹で気を失ってしまった!", "You are getting faint from hunger!"));
+            break;
+        case 1:
+            msg_print(_("お腹が空いて倒れそうだ。", "You are getting weak from hunger!"));
+            break;
+        case 2:
+            msg_print(_("お腹が空いてきた。", "You are getting hungry."));
+            break;
+        case 3:
+            msg_print(_("満腹感がなくなった。", "You are no longer full."));
+            break;
+        case 4:
+            msg_print(_("やっとお腹がきつくなくなった。", "You are no longer gorged."));
+            break;
+        }
+
+        if (creature_ptr->wild_mode && (new_aux < 2)) {
+            change_wild_mode(creature_ptr, FALSE);
+        }
+
+        notice = TRUE;
+    }
+
+    creature_ptr->food = v;
+    if (!notice)
+        return FALSE;
+
+    if (disturb_state)
+        disturb(creature_ptr, FALSE, FALSE);
+    creature_ptr->update |= (PU_BONUS);
+    creature_ptr->redraw |= (PR_HUNGER);
+    handle_stuff(creature_ptr);
+
+    return TRUE;
+}
index 8f25e3b..eb81759 100644 (file)
@@ -3,3 +3,4 @@
 #include "system/angband.h"
 
 void starve_player(player_type* creature_ptr);
+bool set_food(player_type *creature_ptr, TIME_EFFECT v);
index dd7c27a..44e37c3 100644 (file)
@@ -1157,138 +1157,6 @@ bool set_oppose_pois(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
 }
 
 /*!
- * @brief 空腹状態をセットする / Set "food", notice observable changes
- * @param v 継続時間
- * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
- * @details
- * Set "", notice observable changes\n
- *\n
- * The "food" variable can get as large as 20000, allowing the
- * addition of the most "filling" item, Elvish Waybread, which adds
- * 7500 food units, without overflowing the 32767 maximum limit.\n
- *\n
- * Perhaps we should disturb the player with various messages,
- * especially messages about hunger status changes.  \n
- *\n
- * Digestion of food is handled in "dungeon.c", in which, normally,
- * the player digests about 20 food units per 100 game turns, more
- * when "fast", more when "regenerating", less with "slow digestion",
- * but when the player is "gorged", he digests 100 food units per 10
- * game turns, or a full 1000 food units per 100 game turns.\n
- *\n
- * Note that the player's speed is reduced by 10 units while gorged,
- * so if the player eats a single food ration (5000 food units) when
- * full (15000 food units), he will be gorged for (5000/100)*10 = 500
- * game turns, or 500/(100/5) = 25 player turns (if nothing else is
- * affecting the player speed).\n
- */
-bool set_food(player_type *creature_ptr, TIME_EFFECT v)
-{
-    int old_aux, new_aux;
-
-    bool notice = FALSE;
-    v = (v > 20000) ? 20000 : (v < 0) ? 0 : v;
-    if (creature_ptr->food < PY_FOOD_FAINT) {
-        old_aux = 0;
-    } else if (creature_ptr->food < PY_FOOD_WEAK) {
-        old_aux = 1;
-    } else if (creature_ptr->food < PY_FOOD_ALERT) {
-        old_aux = 2;
-    } else if (creature_ptr->food < PY_FOOD_FULL) {
-        old_aux = 3;
-    } else if (creature_ptr->food < PY_FOOD_MAX) {
-        old_aux = 4;
-    } else {
-        old_aux = 5;
-    }
-
-    if (v < PY_FOOD_FAINT) {
-        new_aux = 0;
-    } else if (v < PY_FOOD_WEAK) {
-        new_aux = 1;
-    } else if (v < PY_FOOD_ALERT) {
-        new_aux = 2;
-    } else if (v < PY_FOOD_FULL) {
-        new_aux = 3;
-    } else if (v < PY_FOOD_MAX) {
-        new_aux = 4;
-    } else {
-        new_aux = 5;
-    }
-
-    if (old_aux < 1 && new_aux > 0)
-        chg_virtue(creature_ptr, V_PATIENCE, 2);
-    else if (old_aux < 3 && (old_aux != new_aux))
-        chg_virtue(creature_ptr, V_PATIENCE, 1);
-    if (old_aux == 2)
-        chg_virtue(creature_ptr, V_TEMPERANCE, 1);
-    if (old_aux == 0)
-        chg_virtue(creature_ptr, V_TEMPERANCE, -1);
-
-    if (new_aux > old_aux) {
-        switch (new_aux) {
-        case 1:
-            msg_print(_("まだ空腹で倒れそうだ。", "You are still weak."));
-            break;
-        case 2:
-            msg_print(_("まだ空腹だ。", "You are still hungry."));
-            break;
-        case 3:
-            msg_print(_("空腹感がおさまった。", "You are no longer hungry."));
-            break;
-        case 4:
-            msg_print(_("満腹だ!", "You are full!"));
-            break;
-
-        case 5:
-            msg_print(_("食べ過ぎだ!", "You have gorged yourself!"));
-            chg_virtue(creature_ptr, V_HARMONY, -1);
-            chg_virtue(creature_ptr, V_PATIENCE, -1);
-            chg_virtue(creature_ptr, V_TEMPERANCE, -2);
-            break;
-        }
-
-        notice = TRUE;
-    } else if (new_aux < old_aux) {
-        switch (new_aux) {
-        case 0:
-            msg_print(_("あまりにも空腹で気を失ってしまった!", "You are getting faint from hunger!"));
-            break;
-        case 1:
-            msg_print(_("お腹が空いて倒れそうだ。", "You are getting weak from hunger!"));
-            break;
-        case 2:
-            msg_print(_("お腹が空いてきた。", "You are getting hungry."));
-            break;
-        case 3:
-            msg_print(_("満腹感がなくなった。", "You are no longer full."));
-            break;
-        case 4:
-            msg_print(_("やっとお腹がきつくなくなった。", "You are no longer gorged."));
-            break;
-        }
-
-        if (creature_ptr->wild_mode && (new_aux < 2)) {
-            change_wild_mode(creature_ptr, FALSE);
-        }
-
-        notice = TRUE;
-    }
-
-    creature_ptr->food = v;
-    if (!notice)
-        return FALSE;
-
-    if (disturb_state)
-        disturb(creature_ptr, FALSE, FALSE);
-    creature_ptr->update |= (PU_BONUS);
-    creature_ptr->redraw |= (PR_HUNGER);
-    handle_stuff(creature_ptr);
-
-    return TRUE;
-}
-
-/*!
  * @brief プレイヤーの基本能力値を増加させる / Increases a stat by one randomized level -RAK-
  * @param stat 上昇させるステータスID
  * @return 実際に上昇した場合TRUEを返す。
index 76ed245..e40aee1 100644 (file)
@@ -24,7 +24,6 @@ bool set_oppose_elec(player_type *creature_ptr, TIME_EFFECT v, bool do_dec);
 bool set_oppose_fire(player_type *creature_ptr, TIME_EFFECT v, bool do_dec);
 bool set_oppose_cold(player_type *creature_ptr, TIME_EFFECT v, bool do_dec);
 bool set_oppose_pois(player_type *creature_ptr, TIME_EFFECT v, bool do_dec);
-bool set_food(player_type *creature_ptr, TIME_EFFECT v);
 bool inc_stat(player_type *creature_ptr, int stat);
 bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent);
 bool res_stat(player_type *creature_ptr, int stat);
index e61e40e..0f54043 100644 (file)
@@ -1,6 +1,6 @@
 #include "system/angband.h"
-#include "art-definition/art-bow-types.h"
 #include "player/player-status.h"
+#include "art-definition/art-bow-types.h"
 #include "art-definition/art-sword-types.h"
 #include "art-definition/art-weapon-types.h"
 #include "autopick/autopick-reader-writer.h"
 #include "market/arena-info-table.h"
 #include "mind/mind-force-trainer.h"
 #include "mind/mind-ninja.h"
+#include "monster-floor/monster-remover.h"
+#include "monster-race/monster-race-hook.h"
+#include "monster-race/monster-race.h"
 #include "monster-race/race-flags1.h"
 #include "monster-race/race-flags2.h"
 #include "monster-race/race-flags3.h"
 #include "monster-race/race-flags7.h"
-#include "monster-race/monster-race-hook.h"
-#include "monster-race/monster-race.h"
 #include "monster/monster-info.h"
-#include "monster-floor/monster-remover.h"
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
 #include "monster/smart-learn-types.h"
 #include "object-hook/hook-checker.h"
 #include "object-hook/hook-weapon.h"
 #include "object/object-flags.h"
-#include "object/object-mark-types.h"
 #include "object/object-info.h"
+#include "object/object-mark-types.h"
 #include "perception/object-perception.h"
 #include "pet/pet-util.h"
 #include "player/avatar.h"
+#include "player/digestion-processor.h"
 #include "player/mimic-info-table.h"
 #include "player/patron.h"
 #include "player/player-class.h"
index 4a98953..805b41b 100644 (file)
@@ -5,22 +5,23 @@
 #include "monster-floor/monster-summon.h"
 #include "monster-floor/place-monster-types.h"
 #include "player/avatar.h"
-#include "status/bad-status-setter.h"
+#include "player/digestion-processor.h"
 #include "player/player-effects.h"
 #include "player/player-status.h"
 #include "spell-kind/spells-beam.h"
 #include "spell-kind/spells-detection.h"
-#include "spell/spells-diceroll.h"
 #include "spell-kind/spells-floor.h"
 #include "spell-kind/spells-launcher.h"
 #include "spell-kind/spells-lite.h"
 #include "spell-kind/spells-perception.h"
 #include "spell-kind/spells-recall.h"
+#include "spell-kind/spells-teleport.h"
+#include "spell/spell-types.h"
+#include "spell/spells-diceroll.h"
 #include "spell/spells-object.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
-#include "spell-kind/spells-teleport.h"
-#include "spell/spell-types.h"
+#include "status/bad-status-setter.h"
 #include "status/sight-setter.h"
 #include "view/display-messages.h"
 
index 622baa1..2ff6b51 100644 (file)
@@ -3,7 +3,7 @@
 #include "monster-floor/monster-summon.h"
 #include "monster-floor/place-monster-types.h"
 #include "mutation/mutation.h"
-#include "status/buff-setter.h"
+#include "player/digestion-processor.h"
 #include "player/player-effects.h"
 #include "player/player-status.h"
 #include "player/selfinfo.h"
@@ -15,6 +15,7 @@
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
 #include "spell/spells3.h"
+#include "status/buff-setter.h"
 #include "status/sight-setter.h"
 #include "view/display-messages.h"
 
index 6b44bab..c5e5740 100644 (file)
@@ -3,7 +3,7 @@
 #include "effect/effect-characteristics.h"
 #include "io/targeting.h"
 #include "player/avatar.h"
-#include "status/buff-setter.h"
+#include "player/digestion-processor.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-specific-bolt.h"
 #include "spell/process-effect.h"
+#include "spell/spell-types.h"
 #include "spell/spells-diceroll.h"
 #include "spell/spells-object.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
-#include "spell/spell-types.h"
+#include "status/buff-setter.h"
 
 /*!
 * @brief 暗黒領域魔法の各処理を行う
index 24779e9..82a0146 100644 (file)
@@ -2,8 +2,7 @@
 #include "cmd-action/cmd-spell.h"
 #include "floor/floor.h"
 #include "io/targeting.h"
-#include "status/bad-status-setter.h"
-#include "status/buff-setter.h"
+#include "player/digestion-processor.h"
 #include "player/player-effects.h"
 #include "player/player-status.h"
 #include "spell-kind/spells-curse-removal.h"
 #include "spell-kind/spells-floor.h"
 #include "spell-kind/spells-genocide.h"
 #include "spell-kind/spells-grid.h"
-#include "spell-kind/spells-lite.h"
 #include "spell-kind/spells-launcher.h"
+#include "spell-kind/spells-lite.h"
 #include "spell-kind/spells-neighbor.h"
 #include "spell-kind/spells-perception.h"
 #include "spell-kind/spells-recall.h"
 #include "spell-kind/spells-sight.h"
-#include "spell/spells-status.h"
 #include "spell/spell-types.h"
+#include "spell/spells-status.h"
 #include "spell/spells3.h"
+#include "status/bad-status-setter.h"
+#include "status/buff-setter.h"
 
 /*!
 * @brief 生命領域魔法の各処理を行う
index 55da285..6fa94b9 100644 (file)
 #include "object-enchant/trc-types.h"
 #include "object-hook/hook-enchant.h"
 #include "object-hook/hook-expendable.h"
-#include "object-hook/hook-perception.h"
 #include "object-hook/hook-magic.h"
+#include "object-hook/hook-perception.h"
 #include "object-hook/hook-weapon.h"
+#include "object/item-tester-hooker.h"
 #include "object/item-use-flags.h"
 #include "object/object-flavor.h"
 #include "object/object-generator.h"
-#include "object/item-tester-hooker.h"
 #include "object/object-info.h"
 #include "object/object-kind.h"
 #include "object/object-mark-types.h"
@@ -82,7 +82,7 @@
 #include "perception/identification.h"
 #include "perception/object-perception.h"
 #include "player/avatar.h"
-#include "status/bad-status-setter.h"
+#include "player/digestion-processor.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
 #include "spell/spells-execution.h"
 #include "spell/spells-summon.h"
 #include "spell/technic-info-table.h"
+#include "status/bad-status-setter.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
 #include "util/bit-flags-calculator.h"
index c69e243..e9bbabc 100644 (file)
@@ -55,6 +55,7 @@
 #include "object/object-kind.h"
 #include "object/object-value.h"
 #include "perception/object-perception.h"
+#include "player/digestion-processor.h"
 #include "player/patron.h"
 #include "player/player-class.h"
 #include "player/player-effects.h"