OSDN Git Service

[Refactor] #40233 Somefunctions moved from store.c/h to store-util.c/h and separated...
[hengband/hengband.git] / src / core.c
index 7415fad..1f7321f 100644 (file)
 
 #include "birth.h"
 #include "bldg.h"
-#include "cmd-activate.h"
-#include "cmd-dump.h"
-#include "cmd-eat.h"
-#include "cmd-hissatsu.h"
-#include "cmd-item.h"
-#include "cmd-magiceat.h"
-#include "cmd-mane.h"
-#include "cmd-quaff.h"
-#include "cmd-read.h"
-#include "cmd-smith.h"
-#include "cmd-usestaff.h"
-#include "cmd-zaprod.h"
-#include "cmd-zapwand.h"
-#include "cmd-pet.h"
-#include "cmd-basic.h"
+#include "io/write-diary.h"
+#include "cmd/cmd-activate.h"
+#include "cmd/cmd-diary.h"
+#include "cmd/cmd-draw.h"
+#include "cmd/cmd-dump.h"
+#include "cmd/cmd-eat.h"
+#include "cmd/cmd-help.h"
+#include "cmd/cmd-hissatsu.h"
+#include "cmd/cmd-item.h"
+#include "cmd/cmd-magiceat.h"
+#include "cmd/cmd-mane.h"
+#include "cmd/cmd-macro.h"
+#include "cmd/cmd-quaff.h"
+#include "cmd/cmd-read.h"
+#include "cmd/cmd-save.h"
+#include "cmd/cmd-smith.h"
+#include "cmd/cmd-usestaff.h"
+#include "cmd/cmd-zaprod.h"
+#include "cmd/cmd-zapwand.h"
+#include "cmd/cmd-pet.h"
+#include "cmd/cmd-basic.h"
+#include "cmd/cmd-visuals.h"
 #include "racial.h"
 #include "snipe.h"
 #include "dungeon.h"
 #include "mind.h"
 #include "world.h"
 #include "mutation.h"
+#include "market/store-util.h"
 #include "quest.h"
 #include "artifact.h"
 #include "avatar.h"
+#include "view/display-player.h"
+#include "player/process-name.h"
 #include "player-move.h"
 #include "player-status.h"
 #include "player-class.h"
@@ -83,6 +93,9 @@
 
 #include "view-mainwindow.h"
 #include "dungeon-file.h"
+#include "uid-checker.h"
+#include "player/process-death.h"
+#include "io/read-pref-file.h"
 #include "files.h"
 #include "scores.h"
 #include "autopick.h"
@@ -1064,48 +1077,51 @@ static object_type *choose_cursed_obj_name(player_type *player_ptr, BIT_FLAGS fl
 }
 
 
+/*!
+ * @brief 10ゲームターンが進行するごとにプレイヤーの空腹状態を飢餓方向に向かわせる
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
 static void process_world_aux_digestion(player_type *creature_ptr)
 {
-       if (!creature_ptr->phase_out)
+       if (creature_ptr->phase_out) return;
+
+       if (creature_ptr->food >= PY_FOOD_MAX)
        {
-               if (creature_ptr->food >= PY_FOOD_MAX)
-               {
-                       (void)set_food(creature_ptr, creature_ptr->food - 100);
-               }
-               else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
-               {
-                       int digestion = SPEED_TO_ENERGY(creature_ptr->pspeed);
-                       if (creature_ptr->regenerate)
-                               digestion += 20;
-                       if (creature_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
-                               digestion += 20;
-                       if (creature_ptr->cursed & TRC_FAST_DIGEST)
-                               digestion += 30;
+               (void)set_food(creature_ptr, creature_ptr->food - 100);
+       }
+       else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5)))
+       {
+               int digestion = SPEED_TO_ENERGY(creature_ptr->pspeed);
+               if (creature_ptr->regenerate)
+                       digestion += 20;
+               if (creature_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
+                       digestion += 20;
+               if (creature_ptr->cursed & TRC_FAST_DIGEST)
+                       digestion += 30;
 
-                       if (creature_ptr->slow_digest)
-                               digestion -= 5;
+               if (creature_ptr->slow_digest)
+                       digestion -= 5;
 
-                       if (digestion < 1) digestion = 1;
-                       if (digestion > 100) digestion = 100;
+               if (digestion < 1) digestion = 1;
+               if (digestion > 100) digestion = 100;
 
-                       (void)set_food(creature_ptr, creature_ptr->food - digestion);
-               }
+               (void)set_food(creature_ptr, creature_ptr->food - digestion);
+       }
 
-               if ((creature_ptr->food < PY_FOOD_FAINT))
-               {
-                       if (!creature_ptr->paralyzed && (randint0(100) < 10))
-                       {
-                               msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
-                               disturb(creature_ptr, TRUE, TRUE);
-                               (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 1 + randint0(5));
-                       }
+       if ((creature_ptr->food >= PY_FOOD_FAINT)) return;
 
-                       if (creature_ptr->food < PY_FOOD_STARVE)
-                       {
-                               HIT_POINT dam = (PY_FOOD_STARVE - creature_ptr->food) / 10;
-                               if (!IS_INVULN(creature_ptr)) take_hit(creature_ptr, DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
-                       }
-               }
+       if (!creature_ptr->paralyzed && (randint0(100) < 10))
+       {
+               msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
+               disturb(creature_ptr, TRUE, TRUE);
+               (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 1 + randint0(5));
+       }
+
+       if (creature_ptr->food < PY_FOOD_STARVE)
+       {
+               HIT_POINT dam = (PY_FOOD_STARVE - creature_ptr->food) / 10;
+               if (!IS_INVULN(creature_ptr)) take_hit(creature_ptr, DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
        }
 }
 
@@ -2215,35 +2231,10 @@ static void process_world_aux_mutation(player_type *creature_ptr)
 
        if ((creature_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
        {
-               INVENTORY_IDX slot = 0;
-               object_type *o_ptr = NULL;
-
                disturb(creature_ptr, FALSE, TRUE);
                msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
                take_hit(creature_ptr, DAMAGE_NOESCAPE, randint1(creature_ptr->wt / 6), _("転倒", "tripping"), -1);
-
-               msg_print(NULL);
-               if (has_melee_weapon(creature_ptr, INVEN_RARM))
-               {
-                       slot = INVEN_RARM;
-                       o_ptr = &creature_ptr->inventory_list[INVEN_RARM];
-
-                       if (has_melee_weapon(creature_ptr, INVEN_LARM) && one_in_(2))
-                       {
-                               o_ptr = &creature_ptr->inventory_list[INVEN_LARM];
-                               slot = INVEN_LARM;
-                       }
-               }
-               else if (has_melee_weapon(creature_ptr, INVEN_LARM))
-               {
-                       o_ptr = &creature_ptr->inventory_list[INVEN_LARM];
-                       slot = INVEN_LARM;
-               }
-               if (slot && !object_is_cursed(o_ptr))
-               {
-                       msg_print(_("武器を落としてしまった!", "You drop your weapon!"));
-                       drop_from_inventory(creature_ptr, slot, 1);
-               }
+               drop_weapons(creature_ptr);
        }
 }
 
@@ -3625,7 +3616,7 @@ static void process_fishing(player_type *creature_ptr)
                MONRACE_IDX r_idx;
                bool success = FALSE;
                get_mon_num_prep(creature_ptr, monster_is_fishing_target, NULL);
-               r_idx = get_mon_num(creature_ptr, creature_ptr->current_floor_ptr->dun_level ? creature_ptr->current_floor_ptr->dun_level : wilderness[creature_ptr->wilderness_y][creature_ptr->wilderness_x].level);
+               r_idx = get_mon_num(creature_ptr, creature_ptr->current_floor_ptr->dun_level ? creature_ptr->current_floor_ptr->dun_level : wilderness[creature_ptr->wilderness_y][creature_ptr->wilderness_x].level, 0);
                msg_print(NULL);
                if (r_idx && one_in_(2))
                {
@@ -4324,7 +4315,7 @@ void play_game(player_type *player_ptr, bool new_game)
 
                /* 町名消失バグ対策(#38205)のためここで世界マップ情報を読み出す */
                process_dungeon_file(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
-               success = send_world_score(player_ptr, TRUE);
+               success = send_world_score(player_ptr, TRUE, update_playtime, display_player, map_name);
 
                if (!success && !get_check_strict(_("スコア登録を諦めますか?", "Do you give up score registration? "), CHECK_NO_HISTORY))
                {
@@ -4638,18 +4629,18 @@ void prevent_turn_overflow(player_type *player_ptr)
        {
                for (int j = 0; j < MAX_STORES; j++)
                {
-                       store_type *st_ptr = &town_info[i].store[j];
+                       store_type *store_ptr = &town_info[i].store[j];
 
-                       if (st_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
+                       if (store_ptr->last_visit > -10L * TURNS_PER_TICK * STORE_TICKS)
                        {
-                               st_ptr->last_visit -= rollback_turns;
-                               if (st_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
+                               store_ptr->last_visit -= rollback_turns;
+                               if (store_ptr->last_visit < -10L * TURNS_PER_TICK * STORE_TICKS) store_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
                        }
 
-                       if (st_ptr->store_open)
+                       if (store_ptr->store_open)
                        {
-                               st_ptr->store_open -= rollback_turns;
-                               if (st_ptr->store_open < 1) st_ptr->store_open = 1;
+                               store_ptr->store_open -= rollback_turns;
+                               if (store_ptr->store_open < 1) store_ptr->store_open = 1;
                        }
                }
        }
@@ -4696,12 +4687,12 @@ void close_game(player_type *player_ptr)
                print_tomb(player_ptr);
                flush();
 
-               show_info(player_ptr);
+               show_info(player_ptr, handle_stuff, update_playtime, display_player, map_name);
                Term_clear();
 
                if (check_score(player_ptr))
                {
-                       if ((!send_world_score(player_ptr, do_send)))
+                       if ((!send_world_score(player_ptr, do_send, update_playtime, display_player, map_name)))
                        {
                                if (get_check_strict(_("後でスコアを登録するために待機しますか?", "Stand by for later score registration? "),
                                        (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))