OSDN Git Service

[Refactor] #40236 Separated do_cmd_knowledge_autopick() and do_cmd_reload_autopick...
[hengband/hengband.git] / src / core.c
index 7415fad..77eebf2 100644 (file)
 #include "angband.h"
 #include "signal-handlers.h"
 #include "util.h"
+#include "main/music-definitions-table.h"
+#include "main/sound-definitions-table.h"
 #include "core.h"
 #include "inet.h"
-#include "term.h"
+#include "gameterm.h"
 #include "chuukei.h"
 
 #include "creature.h"
 
 #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 "market/building.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-process-screen.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"
@@ -48,7 +58,8 @@
 #include "object-ego.h"
 #include "object-curse.h"
 #include "object-flavor.h"
-#include "store.h"
+#include "knowledge/knowledge-autopick.h"
+#include "market/store.h"
 #include "spells.h"
 #include "spells-summon.h"
 #include "spells-object.h"
 #include "mind.h"
 #include "world.h"
 #include "mutation.h"
+#include "market/arena-info-table.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"
@@ -70,7 +85,7 @@
 #include "player-effects.h"
 #include "cmd-spell.h"
 #include "realm-hex.h"
-#include "objectkind.h"
+#include "object/object-kind.h"
 #include "object-hook.h"
 #include "wild.h"
 #include "monster-process.h"
@@ -83,6 +98,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 +1082,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 +2236,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);
        }
 }
 
@@ -2930,7 +2926,7 @@ static bool enter_wizard_mode(player_type *player_ptr)
                        return FALSE;
                }
 
-               exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "give up recording score to enter wizard mode."));
+               exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, _("ウィザードモードに突入してスコアを残せなくなった。", "gave up recording score to enter wizard mode."));
                current_world_ptr->noscore |= 0x0002;
        }
 
@@ -2962,7 +2958,7 @@ static bool enter_debug_mode(player_type *player_ptr)
                        return FALSE;
                }
 
-               exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, _("デバッグモードに突入してスコアを残せなくなった。", "give up sending score to use debug commands."));
+               exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, _("デバッグモードに突入してスコアを残せなくなった。", "gave up sending score to use debug commands."));
                current_world_ptr->noscore |= 0x0008;
        }
 
@@ -3521,7 +3517,7 @@ static void process_command(player_type *creature_ptr)
        }
        case ')':
        {
-               do_cmd_save_screen(creature_ptr);
+               do_cmd_save_screen(creature_ptr, handle_stuff);
                break;
        }
        case ']':
@@ -3625,7 +3621,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 +4320,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))
                {
@@ -4396,7 +4392,7 @@ void play_game(player_type *player_ptr, bool new_game)
                write_level = FALSE;
                exe_write_diary(player_ptr, DIARY_GAMESTART, 1,
                        _("                            ----ゲーム再開----",
-                               "                            ---- Restart Game ----"));
+                               "                            --- Restarted Game ---"));
 
                /*
                 * todo もう2.2.Xなので互換性は打ち切ってもいいのでは?
@@ -4490,7 +4486,7 @@ void play_game(player_type *player_ptr, bool new_game)
        if (new_game)
        {
                char buf[80];
-               sprintf(buf, _("%sに降り立った。", "You are standing in the %s."), map_name(player_ptr));
+               sprintf(buf, _("%sに降り立った。", "arrived in %s."), map_name(player_ptr));
                exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, buf);
        }
 
@@ -4638,18 +4634,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 +4692,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)))