OSDN Git Service

[Refactor] #37353 save.h を追加して宣言を移動.
[hengband/hengband.git] / src / core.c
index 4c4ae89..3fc0221 100644 (file)
 
 #include "angband.h"
 #include "util.h"
+#include "core.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-basic.h"
 #include "snipe.h"
 #include "dungeon.h"
+#include "feature.h"
 #include "floor.h"
 #include "floor-events.h"
+#include "floor-town.h"
 #include "grid.h"
 #include "object-curse.h"
 #include "object-flavor.h"
 #include "avatar.h"
 #include "player-move.h"
 #include "player-status.h"
+#include "player-class.h"
+#include "player-race.h"
 #include "cmd-spell.h"
 #include "realm-hex.h"
+#include "objectkind.h"
 #include "object-hook.h"
 #include "wild.h"
 #include "monster-process.h"
 #include "files.h"
 #include "player-effects.h"
 #include "scores.h"
+#include "autopick.h"
+#include "save.h"
+
+concptr ANGBAND_SYS = "xxx"; //!< Hack -- The special Angband "System Suffix" This variable is used to choose an appropriate "pref-xxx" file
+
+#ifdef JP
+concptr ANGBAND_KEYBOARD = "JAPAN"; //!< Hack -- The special Angband "Keyboard Suffix" This variable is used to choose an appropriate macro-trigger definition
+#else
+concptr ANGBAND_KEYBOARD = "0";
+#endif
+
+concptr ANGBAND_GRAF = "ascii"; //!< Hack -- The special Angband "Graphics Suffix" This variable is used to choose an appropriate "graf-xxx" file
 
 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
@@ -80,7 +99,7 @@ static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カ
 static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
 {
        byte feel;
-       object_type *o_ptr = &inventory[slot];
+       object_type *o_ptr = &p_ptr->inventory_list[slot];
        GAME_TEXT o_name[MAX_NLEN];
 
        /* We know about it already, do not tell us again */
@@ -165,7 +184,7 @@ static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
 
        }
 
-       /* Message (inventory) */
+       /* Message (p_ptr->inventory_list) */
        else
        {
 #ifdef JP
@@ -198,7 +217,7 @@ static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
  * @brief 1プレイヤーターン毎に武器、防具の擬似鑑定が行われるかを判定する。
  * @return なし
  * @details
- * Sense the inventory\n
+ * Sense the p_ptr->inventory_list\n
  *\n
  *   Class 0 = Warrior --> fast and heavy\n
  *   Class 1 = Mage    --> slow and light\n
@@ -379,7 +398,7 @@ static void sense_inventory1(void)
        {
                bool okay = FALSE;
 
-               o_ptr = &inventory[i];
+               o_ptr = &p_ptr->inventory_list[i];
 
                /* Skip empty slots */
                if (!o_ptr->k_idx) continue;
@@ -414,7 +433,7 @@ static void sense_inventory1(void)
                /* Skip non-sense machines */
                if (!okay) continue;
 
-               /* Occasional failure on inventory items */
+               /* Occasional failure on p_ptr->inventory_list items */
                if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
 
                /* Good luck */
@@ -521,7 +540,7 @@ static void sense_inventory2(void)
        {
                bool okay = FALSE;
 
-               o_ptr = &inventory[i];
+               o_ptr = &p_ptr->inventory_list[i];
 
                /* Skip empty slots */
                if (!o_ptr->k_idx) continue;
@@ -542,7 +561,7 @@ static void sense_inventory2(void)
                /* Skip non-sense machines */
                if (!okay) continue;
 
-               /* Occasional failure on inventory items */
+               /* Occasional failure on p_ptr->inventory_list items */
                if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
 
                sense_inventory_aux(i, TRUE);
@@ -883,7 +902,7 @@ static void regen_monsters(void)
 
 
        /* Regenerate everyone */
-       for (i = 1; i < m_max; i++)
+       for (i = 1; i < current_floor_ptr->m_max; i++)
        {
                /* Check the i'th monster */
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
@@ -931,7 +950,7 @@ static void regen_captured_monsters(void)
        for (i = 0; i < INVEN_TOTAL; i++)
        {
                monster_race *r_ptr;
-               object_type *o_ptr = &inventory[i];
+               object_type *o_ptr = &p_ptr->inventory_list[i];
 
                if (!o_ptr->k_idx) continue;
                if (o_ptr->tval != TV_CAPTURE) continue;
@@ -1153,7 +1172,7 @@ static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
        /* Search Inventry */
        for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
        {
-               object_type *o_ptr = &inventory[i];
+               object_type *o_ptr = &p_ptr->inventory_list[i];
 
                if (o_ptr->curse_flags & flag)
                {
@@ -1205,7 +1224,7 @@ static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
        }
 
        /* Choice one of them */
-       return (&inventory[choices[randint0(number)]]);
+       return (&p_ptr->inventory_list[choices[randint0(number)]]);
 }
 
 static void process_world_aux_digestion(void)
@@ -1354,10 +1373,10 @@ static void process_world_aux_hp_and_sp(void)
                        }
                }
 
-               if (inventory[INVEN_LITE].tval && (inventory[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
+               if (p_ptr->inventory_list[INVEN_LITE].tval && (p_ptr->inventory_list[INVEN_LITE].name2 != EGO_LITE_DARKNESS) &&
                    !p_ptr->resist_lite)
                {
-                       object_type * o_ptr = &inventory[INVEN_LITE];
+                       object_type * o_ptr = &p_ptr->inventory_list[INVEN_LITE];
                        GAME_TEXT o_name [MAX_NLEN];
                        char ouch [MAX_NLEN+40];
 
@@ -2061,7 +2080,7 @@ static void process_world_aux_timeout(void)
 static void process_world_aux_light(void)
 {
        /* Check for light being wielded */
-       object_type *o_ptr = &inventory[INVEN_LITE];
+       object_type *o_ptr = &p_ptr->inventory_list[INVEN_LITE];
 
        /* Burn some fuel in the current lite */
        if (o_ptr->tval == TV_LITE)
@@ -2280,7 +2299,7 @@ static void process_world_aux_mutation(void)
                        hp_player(10);
                }
 
-               o_ptr = &inventory[INVEN_LITE];
+               o_ptr = &p_ptr->inventory_list[INVEN_LITE];
 
                /* Absorb some fuel in the current lite */
                if (o_ptr->tval == TV_LITE)
@@ -2432,7 +2451,7 @@ static void process_world_aux_mutation(void)
                int danger_amount = 0;
                MONSTER_IDX monster;
 
-               for (monster = 0; monster < m_max; monster++)
+               for (monster = 0; monster < current_floor_ptr->m_max; monster++)
                {
                        monster_type *m_ptr = &current_floor_ptr->m_list[monster];
                        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -2509,17 +2528,17 @@ static void process_world_aux_mutation(void)
                if (has_melee_weapon(INVEN_RARM))
                {
                        slot = INVEN_RARM;
-                       o_ptr = &inventory[INVEN_RARM];
+                       o_ptr = &p_ptr->inventory_list[INVEN_RARM];
 
                        if (has_melee_weapon(INVEN_LARM) && one_in_(2))
                        {
-                               o_ptr = &inventory[INVEN_LARM];
+                               o_ptr = &p_ptr->inventory_list[INVEN_LARM];
                                slot = INVEN_LARM;
                        }
                }
                else if (has_melee_weapon(INVEN_LARM))
                {
-                       o_ptr = &inventory[INVEN_LARM];
+                       o_ptr = &p_ptr->inventory_list[INVEN_LARM];
                        slot = INVEN_LARM;
                }
                if (slot && !object_is_cursed(o_ptr))
@@ -2554,7 +2573,7 @@ static void process_world_aux_curse(void)
                        for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
                        {
                                BIT_FLAGS flgs[TR_FLAG_SIZE];
-                               o_ptr = &inventory[i];
+                               o_ptr = &p_ptr->inventory_list[i];
                                if (!o_ptr->k_idx) continue;
 
                                object_flags(o_ptr, flgs);
@@ -2570,7 +2589,7 @@ static void process_world_aux_curse(void)
                                }
                        }
 
-                       o_ptr = &inventory[i_keep];
+                       o_ptr = &p_ptr->inventory_list[i_keep];
                        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
                        msg_format(_("%sがテレポートの能力を発動させようとしている。", "Your %s is activating teleportation."), o_name);
                        if (get_check_strict(_("テレポートしますか?", "Teleport? "), CHECK_OKAY_CANCEL))
@@ -2749,7 +2768,7 @@ static void process_world_aux_curse(void)
        /* Rarely, take damage from the Jewel of Judgement */
        if (one_in_(999) && !p_ptr->anti_magic)
        {
-               object_type *o_ptr = &inventory[INVEN_LITE];
+               object_type *o_ptr = &p_ptr->inventory_list[INVEN_LITE];
 
                if (o_ptr->name1 == ART_JUDGE)
                {
@@ -2777,7 +2796,7 @@ static void process_world_aux_recharge(void)
        for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
        {
                /* Get the object */
-               object_type *o_ptr = &inventory[i];
+               object_type *o_ptr = &p_ptr->inventory_list[i];
                if (!o_ptr->k_idx) continue;
 
                /* Recharge activatable objects */
@@ -2809,7 +2828,7 @@ static void process_world_aux_recharge(void)
         */
        for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
        {
-               object_type *o_ptr = &inventory[i];
+               object_type *o_ptr = &p_ptr->inventory_list[i];
                object_kind *k_ptr = &k_info[o_ptr->k_idx];
                if (!o_ptr->k_idx) continue;
 
@@ -2849,7 +2868,7 @@ static void process_world_aux_recharge(void)
        }
 
        /* Process objects on floor */
-       for (i = 1; i < o_max; i++)
+       for (i = 1; i < current_floor_ptr->o_max; i++)
        {
                object_type *o_ptr = &current_floor_ptr->o_list[i];
 
@@ -3128,38 +3147,6 @@ static void process_world(void)
        /* Every 10 game turns */
        if (current_world_ptr->game_turn % TURNS_PER_TICK) return;
 
-       /*** Check the Time and Load ***/
-
-       if (!(current_world_ptr->game_turn % (50*TURNS_PER_TICK)))
-       {
-               /* Check time and load */
-               if ((0 != check_time()) || (0 != check_load()))
-               {
-                       /* Warning */
-                       if (closing_flag <= 2)
-                       {
-                               disturb(FALSE, TRUE);
-
-                               /* Count warnings */
-                               closing_flag++;
-
-                               msg_print(_("アングバンドへの門が閉じかかっています...", "The gates to ANGBAND are closing..."));
-                               msg_print(_("ゲームを終了するかセーブするかして下さい。", "Please finish up and/or save your game."));
-
-                       }
-
-                       /* Slam the gate */
-                       else
-                       {
-                               msg_print(_("今、アングバンドへの門が閉ざされました。", "The gates to ANGBAND are now closed."));
-
-                               /* Stop playing */
-                               p_ptr->playing = FALSE;
-                               p_ptr->leaving = TRUE;
-                       }
-               }
-       }
-
        /*** Attempt timed autosave ***/
        if (autosave_t && autosave_freq && !p_ptr->inside_battle)
        {
@@ -3356,7 +3343,7 @@ static void process_world(void)
        /* Process recharging */
        process_world_aux_recharge();
 
-       /* Feel the inventory */
+       /* Feel the p_ptr->inventory_list */
        sense_inventory1();
        sense_inventory2();
 
@@ -4312,17 +4299,17 @@ static void process_command(void)
  */
 static void pack_overflow(void)
 {
-       if (inventory[INVEN_PACK].k_idx)
+       if (p_ptr->inventory_list[INVEN_PACK].k_idx)
        {
                GAME_TEXT o_name[MAX_NLEN];
                object_type *o_ptr;
 
                /* Is auto-destroy done? */
                update_creature(p_ptr);
-               if (!inventory[INVEN_PACK].k_idx) return;
+               if (!p_ptr->inventory_list[INVEN_PACK].k_idx) return;
 
                /* Access the slot to be dropped */
-               o_ptr = &inventory[INVEN_PACK];
+               o_ptr = &p_ptr->inventory_list[INVEN_PACK];
 
                disturb(FALSE, TRUE);
 
@@ -4387,12 +4374,12 @@ static void process_player(void)
 
        /*** Apply energy ***/
 
-       if (hack_mutation)
+       if (p_ptr->hack_mutation)
        {
                msg_print(_("何か変わった気がする!", "You feel different!"));
 
                (void)gain_mutation(p_ptr, 0);
-               hack_mutation = FALSE;
+               p_ptr->hack_mutation = FALSE;
        }
 
        if (invoking_midnight_curse)
@@ -4404,7 +4391,7 @@ static void process_player(void)
 
        if (p_ptr->inside_battle)
        {
-               for(m_idx = 1; m_idx < m_max; m_idx++)
+               for(m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
                {
                        monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
 
@@ -4766,7 +4753,7 @@ static void process_player(void)
                                shimmer_monsters = FALSE;
 
                                /* Shimmer multi-hued monsters */
-                               for (m_idx = 1; m_idx < m_max; m_idx++)
+                               for (m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
                                {
                                        monster_type *m_ptr;
                                        monster_race *r_ptr;
@@ -4800,7 +4787,7 @@ static void process_player(void)
                                repair_monsters = FALSE;
 
                                /* Rotate detection flags */
-                               for (m_idx = 1; m_idx < m_max; m_idx++)
+                               for (m_idx = 1; m_idx < current_floor_ptr->m_max; m_idx++)
                                {
                                        monster_type *m_ptr;
                                        m_ptr = &current_floor_ptr->m_list[m_idx];
@@ -5078,17 +5065,17 @@ static void dungeon(bool load_game)
        while (TRUE)
        {
                /* Hack -- Compact the monster list occasionally */
-               if ((m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
+               if ((current_floor_ptr->m_cnt + 32 > current_floor_ptr->max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
 
                /* Hack -- Compress the monster list occasionally */
-               if ((m_cnt + 32 < m_max) && !p_ptr->inside_battle) compact_monsters(0);
+               if ((current_floor_ptr->m_cnt + 32 < current_floor_ptr->m_max) && !p_ptr->inside_battle) compact_monsters(0);
 
 
                /* Hack -- Compact the object list occasionally */
-               if (o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
+               if (current_floor_ptr->o_cnt + 32 > current_floor_ptr->max_o_idx) compact_objects(64);
 
                /* Hack -- Compress the object list occasionally */
-               if (o_cnt + 32 < o_max) compact_objects(0);
+               if (current_floor_ptr->o_cnt + 32 < current_floor_ptr->o_max) compact_objects(0);
 
                /* Process the player */
                process_player();
@@ -5239,89 +5226,6 @@ static void load_all_pref_files(void)
        autopick_load_pref(FALSE);
 }
 
-
-/*!
- * @brief ビットセットからゲームオプションを展開する / Extract option variables from bit sets
- * @return なし
- */
-void extract_option_vars(void)
-{
-       int i;
-
-       for (i = 0; option_info[i].o_desc; i++)
-       {
-               int os = option_info[i].o_set;
-               int ob = option_info[i].o_bit;
-
-               /* Set the "default" options */
-               if (option_info[i].o_var)
-               {
-                       /* Set */
-                       if (option_flag[os] & (1L << ob))
-                       {
-                               /* Set */
-                               (*option_info[i].o_var) = TRUE;
-                       }
-
-                       /* Clear */
-                       else
-                       {
-                               /* Clear */
-                               (*option_info[i].o_var) = FALSE;
-                       }
-               }
-       }
-}
-
-
-/*!
- * @brief 賞金首となるユニークを確定する / Determine bounty uniques
- * @return なし
- */
-void determine_bounty_uniques(void)
-{
-       int i, j;
-       MONRACE_IDX tmp;
-       monster_race *r_ptr;
-
-       get_mon_num_prep(NULL, NULL);
-       for (i = 0; i < MAX_KUBI; i++)
-       {
-               while (1)
-               {
-                       current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
-                       r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
-
-                       if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
-
-                       if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
-
-                       if (r_ptr->rarity > 100) continue;
-
-                       if (no_questor_or_bounty_uniques(current_world_ptr->bounty_r_idx[i])) continue;
-
-                       for (j = 0; j < i; j++)
-                               if (current_world_ptr->bounty_r_idx[i] == current_world_ptr->bounty_r_idx[j]) break;
-
-                       if (j == i) break;
-               }
-       }
-
-       /* Sort them */
-       for (i = 0; i < MAX_KUBI - 1; i++)
-       {
-               for (j = i; j < MAX_KUBI; j++)
-               {
-                       if (r_info[current_world_ptr->bounty_r_idx[i]].level > r_info[current_world_ptr->bounty_r_idx[j]].level)
-                       {
-                               tmp = current_world_ptr->bounty_r_idx[i];
-                               current_world_ptr->bounty_r_idx[i] = current_world_ptr->bounty_r_idx[j];
-                               current_world_ptr->bounty_r_idx[j] = tmp;
-                       }
-               }
-       }
-}
-
 /*!
  * @brief 1ゲームプレイの主要ルーチン / Actually play a game
  * @return なし
@@ -5357,7 +5261,7 @@ void play_game(bool new_game)
                return;
        }
 
-       hack_mutation = FALSE;
+       p_ptr->hack_mutation = FALSE;
 
        /* Hack -- Character is "icky" */
        character_icky = TRUE;
@@ -5501,10 +5405,10 @@ void play_game(bool new_game)
                write_level = TRUE;
 
                /* Hack -- seed for flavors */
-               seed_flavor = randint0(0x10000000);
+               current_world_ptr->seed_flavor = randint0(0x10000000);
 
                /* Hack -- seed for town layout */
-               seed_town = randint0(0x10000000);
+               current_world_ptr->seed_town = randint0(0x10000000);
 
                /* Roll up a new character */
                player_birth();
@@ -5535,7 +5439,7 @@ void play_game(bool new_game)
                if (p_ptr->riding == -1)
                {
                        p_ptr->riding = 0;
-                       for (i = m_max; i > 0; i--)
+                       for (i = current_floor_ptr->m_max; i > 0; i--)
                        {
                                if (player_bold(current_floor_ptr->m_list[i].fy, current_floor_ptr->m_list[i].fx))
                                {