OSDN Git Service

[Fix] #38965 「気合いため」のための concentration() 関数抜け修正。 / Fix forgotten calling concentration().
[hengband/hengband.git] / src / load.c
index 408c0f3..f97a04a 100644 (file)
  * the existing "number of turns to protect for", and where each hit
  * by a monster will reduce the shield by that amount.
  *
- * XXX XXX XXX
+ * 
  */
 
 #include "angband.h"
 #include "generate.h"
 #include "trap.h"
+#include "mutation.h"
+#include "quest.h"
+#include "store.h"
+#include "artifact.h"
+#include "avatar.h"
+#include "spells-status.h"
 
 
 /*
@@ -144,9 +150,9 @@ static bool z_older_than(byte x, byte y, byte z)
  * @details
  * Avoid the top two lines, to avoid interference with "msg_print()".
  */
-static void note(cptr msg)
+static void note(concptr msg)
 {
-       static int y = 2;
+       static TERM_LEN y = 2;
 
        /* Draw the message */
        prt(msg, y, 0);
@@ -347,7 +353,6 @@ static void rd_item_old(object_type *o_ptr)
        /* Kind */
        rd_s16b(&o_ptr->k_idx);
 
-       /* Location */
        rd_byte(&tmp8u);
        o_ptr->iy = (POSITION)tmp8u;
        rd_byte(&tmp8u);
@@ -610,7 +615,7 @@ static void rd_item_old(object_type *o_ptr)
 static void rd_item(object_type *o_ptr)
 {
        object_kind *k_ptr;
-       u32b flags;
+       BIT_FLAGS flags;
        char buf[128];
        byte_hack tmp8u;
        s16b tmp16s;
@@ -628,7 +633,6 @@ static void rd_item(object_type *o_ptr)
        /* Kind */
        rd_s16b(&o_ptr->k_idx);
 
-       /* Location */
        rd_byte(&tmp8u);
        o_ptr->iy = (POSITION)tmp8u;
        rd_byte(&tmp8u);
@@ -873,7 +877,10 @@ static void rd_monster_old(monster_type *m_ptr)
        }
        
        rd_s16b(&m_ptr->mtimed[MTIMED_CSLEEP]);
-       rd_byte(&m_ptr->mspeed);
+
+       rd_byte(&tmp8u);
+       m_ptr->mspeed = tmp8u;
+
        if (z_older_than(10, 4, 2))
        {
                rd_byte(&tmp8u);
@@ -975,7 +982,7 @@ static void rd_monster_old(monster_type *m_ptr)
  */
 static void rd_monster(monster_type *m_ptr)
 {
-       u32b flags;
+       BIT_FLAGS flags;
        char buf[128];
        byte tmp8u;
        s16b tmp16s;
@@ -1027,7 +1034,8 @@ static void rd_monster(monster_type *m_ptr)
        if (flags & SAVE_MON_CSLEEP) rd_s16b(&m_ptr->mtimed[MTIMED_CSLEEP]);
        else m_ptr->mtimed[MTIMED_CSLEEP] = 0;
 
-       rd_byte(&m_ptr->mspeed);
+       rd_byte(&tmp8u);
+       m_ptr->mspeed = tmp8u;
 
        rd_s16b(&m_ptr->energy_need);
 
@@ -1366,12 +1374,12 @@ static errr rd_store(int town_number, int store_number)
 
        if (z_older_than(10, 3, 3) && (store_number == STORE_HOME))
        {
-               st_ptr = &town[1].store[store_number];
+               st_ptr = &town_info[1].store[store_number];
                if (st_ptr->stock_num) sort = TRUE;
        }
        else
        {
-               st_ptr = &town[town_number].store[store_number];
+               st_ptr = &town_info[town_number].store[store_number];
        }
 
        /* Read the basic info */
@@ -1401,11 +1409,7 @@ static errr rd_store(int town_number, int store_number)
        {
                object_type forge;
                object_type *q_ptr;
-
-               /* Get local object */
                q_ptr = &forge;
-
-               /* Wipe the object */
                object_wipe(q_ptr);
 
                /* Read the item */
@@ -1475,21 +1479,15 @@ static void rd_randomizer(void)
 static void rd_options(void)
 {
        int i, n;
-
        byte b;
-
        u16b c;
 
-       u32b flag[8];
-       u32b mask[8];
-
-
-       /*** Oops ***/
+       BIT_FLAGS flag[8];
+       BIT_FLAGS mask[8];
 
        /* Ignore old options */
        strip_bytes(16);
 
-
        /*** Special info */
 
        /* Read "delay_factor" */
@@ -1511,7 +1509,6 @@ static void rd_options(void)
                mana_warn = b;
        }
 
-
        /*** Cheating options ***/
 
        rd_u16b(&c);
@@ -1643,7 +1640,7 @@ static void rd_options(void)
  * @brief ダミー情報スキップ / Hack -- strip the "ghost" info
  * @return なし
  * @details
- * XXX XXX XXX This is such a nasty hack it hurts.
+ * This is such a nasty hack it hurts.
  */
 static void rd_ghost(void)
 {
@@ -1674,9 +1671,12 @@ static void load_quick_start(void)
        }
 
        rd_byte(&previous_char.psex);
-       rd_byte(&previous_char.prace);
-       rd_byte(&previous_char.pclass);
-       rd_byte(&previous_char.pseikaku);
+       rd_byte(&tmp8u);
+       previous_char.prace = (RACE_IDX)tmp8u;
+       rd_byte(&tmp8u);
+       previous_char.pclass = (CLASS_IDX)tmp8u;
+       rd_byte(&tmp8u);
+       previous_char.pseikaku = (CHARACTER_IDX)tmp8u;
        rd_byte(&tmp8u);
        previous_char.realm1 = (REALM_IDX)tmp8u;
        rd_byte(&tmp8u);
@@ -1688,8 +1688,8 @@ static void load_quick_start(void)
        rd_s16b(&previous_char.sc);
        rd_s32b(&previous_char.au);
 
-       for (i = 0; i < 6; i++) rd_s16b(&previous_char.stat_max[i]);
-       for (i = 0; i < 6; i++) rd_s16b(&previous_char.stat_max_max[i]);
+       for (i = 0; i < A_MAX; i++) rd_s16b(&previous_char.stat_max[i]);
+       for (i = 0; i < A_MAX; i++) rd_s16b(&previous_char.stat_max_max[i]);
 
        for (i = 0; i < PY_MAX_LEVEL; i++)
        {
@@ -1744,15 +1744,18 @@ static void rd_extra(void)
        }
 
        /* Class/Race/Seikaku/Gender/Spells */
-       rd_byte(&p_ptr->prace);
-       rd_byte(&p_ptr->pclass);
-       rd_byte(&p_ptr->pseikaku);
+       rd_byte(&tmp8u);
+       p_ptr->prace = (RACE_IDX)tmp8u;
+       rd_byte(&tmp8u);
+       p_ptr->pclass = (CLASS_IDX)tmp8u;
+       rd_byte(&tmp8u);
+       p_ptr->pseikaku = (CHARACTER_IDX)tmp8u;
        rd_byte(&p_ptr->psex);
        rd_byte(&tmp8u);
        p_ptr->realm1 = (REALM_IDX)tmp8u;
        rd_byte(&tmp8u);
        p_ptr->realm2 = (REALM_IDX)tmp8u;
-       rd_byte(&tmp8u); /* oops */
+       rd_byte(&tmp8u);
 
        if (z_older_than(10, 4, 4))
        {
@@ -1773,12 +1776,11 @@ static void rd_extra(void)
        rd_s16b(&p_ptr->wt);
 
        /* Read the stat info */
-       for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_max[i]);
-       for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_max_max[i]);
-       for (i = 0; i < 6; i++) rd_s16b(&p_ptr->stat_cur[i]);
-
-       strip_bytes(24); /* oops */
+       for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_max[i]);
+       for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_max_max[i]);
+       for (i = 0; i < A_MAX; i++) rd_s16b(&p_ptr->stat_cur[i]);
 
+       strip_bytes(24);
        rd_s32b(&p_ptr->au);
 
        rd_s32b(&p_ptr->max_exp);
@@ -1844,7 +1846,8 @@ static void rd_extra(void)
        }
        else
        {
-               rd_byte(&p_ptr->start_race);
+               rd_byte(&tmp8u);
+               p_ptr->start_race = (RACE_IDX)tmp8u;
                rd_s32b(&tmp32s);
                p_ptr->old_race1 = (BIT_FLAGS)tmp32s;
                rd_s32b(&tmp32s);
@@ -2016,7 +2019,7 @@ static void rd_extra(void)
                }
        }
 
-       /* Repair maximum player level XXX XXX XXX */
+       /* Repair maximum player level */
        if (p_ptr->max_plv < p_ptr->lev) p_ptr->max_plv = p_ptr->lev;
 
        /* More info */
@@ -2210,7 +2213,7 @@ static void rd_extra(void)
        rd_byte(&tmp8u);
        p_ptr->autopick_autoregister = tmp8u ? TRUE : FALSE;
 
-       rd_byte(&tmp8u); /* oops */
+       rd_byte(&tmp8u);
        rd_byte(&tmp8u);
        p_ptr->action = (ACTION_IDX)tmp8u;
        if (!z_older_than(10, 4, 3))
@@ -2409,11 +2412,7 @@ static errr rd_inventory(void)
 
                /* Nope, we reached the end */
                if (n == 0xFFFF) break;
-
-               /* Get local object */
                q_ptr = &forge;
-
-               /* Wipe the object */
                object_wipe(q_ptr);
 
                /* Read the item */
@@ -2425,10 +2424,7 @@ static errr rd_inventory(void)
                /* Wield equipment */
                if (n >= INVEN_RARM)
                {
-                       /* Player touches it */
                        q_ptr->marked |= OM_TOUCHED;
-
-                       /* Copy object */
                        object_copy(&inventory[n], q_ptr);
 
                        /* Add the weight */
@@ -2441,7 +2437,6 @@ static errr rd_inventory(void)
                /* Warning -- backpack is full */
                else if (inven_cnt == INVEN_PACK)
                {
-                       /* Oops */
                        note(_("持ち物の中のアイテムが多すぎる!", "Too many items in the inventory!"));
 
                        /* Fail */
@@ -2454,10 +2449,7 @@ static errr rd_inventory(void)
                        /* Get a slot */
                        n = slot++;
 
-                       /* Player touches it */
                        q_ptr->marked |= OM_TOUCHED;
-
-                       /* Copy object */
                        object_copy(&inventory[n], q_ptr);
 
                        /* Add the weight */
@@ -2565,11 +2557,11 @@ static errr rd_dungeon_old(void)
        /* Header info */
        rd_s16b(&tmp16s);
        dun_level = (DEPTH)tmp16s;
-       if (z_older_than(10, 3, 8)) dungeon_type = DUNGEON_ANGBAND;
+       if (z_older_than(10, 3, 8)) p_ptr->dungeon_idx = DUNGEON_ANGBAND;
        else
        { 
                rd_byte(&tmp8u);
-               dungeon_type = (IDX)tmp8u;
+               p_ptr->dungeon_idx = (IDX)tmp8u;
        }
 
        /* Set the base level for old versions */
@@ -2578,7 +2570,8 @@ static errr rd_dungeon_old(void)
        rd_s16b(&tmp16s);
        base_level = (DEPTH)tmp16s;
 
-       rd_s16b(&num_repro);
+       rd_s16b(&tmp16s);
+       num_repro = (MONSTER_NUMBER)tmp16s;
        rd_s16b(&tmp16s);
        p_ptr->y = (POSITION)tmp16s;
        rd_s16b(&tmp16s);
@@ -2850,7 +2843,7 @@ static errr rd_dungeon_old(void)
        /* Read the dungeon items */
        for (i = 1; i < limit; i++)
        {
-               IDX o_idx;
+               OBJECT_IDX o_idx;
 
                object_type *o_ptr;
 
@@ -2858,7 +2851,6 @@ static errr rd_dungeon_old(void)
                /* Get a new record */
                o_idx = o_pop();
 
-               /* Oops */
                if (i != o_idx)
                {
                        note(format(_("アイテム配置エラー (%d <> %d)", "Object allocation error (%d <> %d)"), i, o_idx));
@@ -2873,7 +2865,7 @@ static errr rd_dungeon_old(void)
                rd_item(o_ptr);
 
 
-               /* XXX XXX XXX XXX XXX */
+               /* XXX XXX */
 
                /* Monster */
                if (o_ptr->held_m_idx)
@@ -2926,7 +2918,6 @@ static errr rd_dungeon_old(void)
                /* Get a new record */
                m_idx = m_pop();
 
-               /* Oops */
                if (i != m_idx)
                {
                        note(format(_("モンスター配置エラー (%d <> %d)", "Monster allocation error (%d <> %d)"), i, m_idx));
@@ -3038,7 +3029,8 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
 
        rd_s16b(&tmp16s);
        base_level = (DEPTH)tmp16s;
-       rd_s16b(&num_repro);
+       rd_s16b(&tmp16s);
+       num_repro = (MONSTER_NUMBER)tmp16s;
 
        rd_u16b(&tmp16u);
        p_ptr->y = (POSITION)tmp16u;
@@ -3177,14 +3169,13 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        /* Read the dungeon items */
        for (i = 1; i < limit; i++)
        {
-               IDX o_idx;
+               OBJECT_IDX o_idx;
                object_type *o_ptr;
 
 
                /* Get a new record */
                o_idx = o_pop();
 
-               /* Oops */
                if (i != o_idx) return 152;
 
                /* Acquire place */
@@ -3242,7 +3233,6 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
                /* Get a new record */
                m_idx = m_pop();
 
-               /* Oops */
                if (i != m_idx) return 162;
 
 
@@ -3292,7 +3282,7 @@ static errr rd_dungeon(void)
                err = rd_dungeon_old();
 
                /* Prepare floor_id of current floor */
-               if (dungeon_type)
+               if (p_ptr->dungeon_idx)
                {
                        p_ptr->floor_id = get_new_floor_id();
                        get_sf_ptr(p_ptr->floor_id)->dun_level = dun_level;
@@ -3309,7 +3299,7 @@ static errr rd_dungeon(void)
 
        /* Current dungeon type */
        rd_byte(&tmp8u);
-       dungeon_type = (DUNGEON_IDX)tmp8u;
+       p_ptr->dungeon_idx = (DUNGEON_IDX)tmp8u;
 
        /* Number of the saved_floors array elements */
        rd_byte(&num);
@@ -3769,7 +3759,7 @@ static errr rd_savefile_new_aux(void)
 
        /* Read the extra stuff */
        rd_extra();
-       if (p_ptr->energy_need < -999) world_player = TRUE;
+       if (p_ptr->energy_need < -999) p_ptr->timewalk = TRUE;
 
        if (arg_fiddle) note(_("特別情報をロードしました", "Loaded extra information"));
 
@@ -3802,22 +3792,22 @@ static errr rd_savefile_new_aux(void)
        if(z_older_than(10, 2, 2) && (p_ptr->pclass == CLASS_BEASTMASTER) && !p_ptr->is_dead)
        {
                p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-               do_cmd_rerate(FALSE);
+               roll_hitdice(0L);
        }
        if(z_older_than(10, 3, 2) && (p_ptr->pclass == CLASS_ARCHER) && !p_ptr->is_dead)
        {
                p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-               do_cmd_rerate(FALSE);
+               roll_hitdice(0L);
        }
        if(z_older_than(10, 2, 6) && (p_ptr->pclass == CLASS_SORCERER) && !p_ptr->is_dead)
        {
                p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
-               do_cmd_rerate(FALSE);
+               roll_hitdice(0L);
        }
        if(z_older_than(10, 4, 7) && (p_ptr->pclass == CLASS_BLUE_MAGE) && !p_ptr->is_dead)
        {
                p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-               do_cmd_rerate(FALSE);
+               roll_hitdice(0L);
        }
 
        /* Important -- Initialize the magic */
@@ -3968,7 +3958,7 @@ static errr rd_savefile_new_aux(void)
        {
                if (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE)
                {
-                       dungeon_type = lite_town ? DUNGEON_ANGBAND : DUNGEON_GALGALS;
+                       p_ptr->dungeon_idx = lite_town ? DUNGEON_ANGBAND : DUNGEON_GALGALS;
                        dun_level = 1;
                        p_ptr->inside_quest = 0;
                }
@@ -4036,11 +4026,7 @@ errr rd_savefile_new(void)
 
        /* Check for errors */
        if (ferror(fff)) err = -1;
-
-       /* Close the file */
        my_fclose(fff);
-
-       /* Result */
        return (err);
 }
 
@@ -4186,8 +4172,6 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode)
 
                /* Check for errors */
                if (ferror(fff)) ok = FALSE;
-
-               /* Close the file */
                my_fclose(fff);
 
                /* Grab permissions */
@@ -4216,7 +4200,5 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode)
 
        /* Restore old knowledge */
        kanji_code = old_kanji_code;
-
-       /* Result */
        return ok;
 }