OSDN Git Service

[Fix] #38965 「気合いため」のための concentration() 関数抜け修正。 / Fix forgotten calling concentration().
[hengband/hengband.git] / src / load.c
index 061f285..f97a04a 100644 (file)
 #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,7 +150,7 @@ 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 TERM_LEN y = 2;
 
@@ -871,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);
@@ -1025,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);
 
@@ -1364,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 */
@@ -1399,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 */
@@ -1473,21 +1479,15 @@ static void rd_randomizer(void)
 static void rd_options(void)
 {
        int i, n;
-
        byte b;
-
        u16b c;
 
        BIT_FLAGS flag[8];
        BIT_FLAGS mask[8];
 
-
-       /*** Oops ***/
-
        /* Ignore old options */
        strip_bytes(16);
 
-
        /*** Special info */
 
        /* Read "delay_factor" */
@@ -1509,7 +1509,6 @@ static void rd_options(void)
                mana_warn = b;
        }
 
-
        /*** Cheating options ***/
 
        rd_u16b(&c);
@@ -1672,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);
@@ -1686,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++)
        {
@@ -1742,9 +1744,12 @@ 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;
@@ -1771,9 +1776,9 @@ 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]);
+       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);
@@ -1841,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);
@@ -2406,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 */
@@ -2422,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 */
@@ -2450,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 */
@@ -2561,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 */
@@ -3286,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;
@@ -3303,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);
@@ -3763,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"));
 
@@ -3796,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 */
@@ -3962,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;
                }
@@ -4030,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);
 }
 
@@ -4180,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 */
@@ -4210,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;
 }