X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fload.c;h=ac6d9b0ab706b4c3b8370d332f48022a68bd2b04;hb=f0235f7ff522d1afbb51ecbf737325249757ac8f;hp=8a62a1814f27fea380fef88a9f2aeece10b84863;hpb=b11660b6e42a6aa31ec2db2349329493972a565d;p=hengband%2Fhengband.git diff --git a/src/load.c b/src/load.c index 8a62a1814..ac6d9b0ab 100644 --- a/src/load.c +++ b/src/load.c @@ -41,23 +41,55 @@ */ #include "angband.h" -#include "generate.h" +#include "util.h" +#include "core.h" + +#include "load.h" +#include "bldg.h" +#include "report.h" + +#include "dungeon.h" +#include "feature.h" +#include "floor-generate.h" #include "trap.h" #include "mutation.h" +#include "monster.h" #include "quest.h" #include "store.h" #include "artifact.h" #include "avatar.h" #include "spells-status.h" #include "object-hook.h" - +#include "wild.h" +#include "patron.h" + +#include "floor.h" +#include "floor-save.h" +#include "floor-town.h" +#include "grid.h" + +#include "cmd-pet.h" +#include "dungeon-file.h" +#include "files.h" +#include "player-skill.h" +#include "player-class.h" +#include "player-race.h" +#include "player-personality.h" +#include "player-sex.h" +#include "birth.h" +#include "world.h" +#include "objectkind.h" +#include "object-ego.h" +#include "save.h" +#include "japanese.h" +#include "realm-song.h" +#include "cmd-smith.h" /* * Maximum number of tries for selection of a proper quest monster */ #define MAX_TRIES 100 - /* * Local "savefile" pointer */ @@ -98,23 +130,23 @@ static byte kanji_code = 0; static bool h_older_than(byte major, byte minor, byte patch, byte extra) { /* Much older, or much more recent */ - if (h_ver_major < major) return (TRUE); - if (h_ver_major > major) return (FALSE); + if (current_world_ptr->h_ver_major < major) return TRUE; + if (current_world_ptr->h_ver_major > major) return FALSE; /* Distinctly older, or distinctly more recent */ - if (h_ver_minor < minor) return (TRUE); - if (h_ver_minor > minor) return (FALSE); + if (current_world_ptr->h_ver_minor < minor) return TRUE; + if (current_world_ptr->h_ver_minor > minor) return FALSE; /* Barely older, or barely more recent */ - if (h_ver_patch < patch) return (TRUE); - if (h_ver_patch > patch) return (FALSE); + if (current_world_ptr->h_ver_patch < patch) return TRUE; + if (current_world_ptr->h_ver_patch > patch) return FALSE; /* Barely older, or barely more recent */ - if (h_ver_extra < extra) return (TRUE); - if (h_ver_extra > extra) return (FALSE); + if (current_world_ptr->h_ver_extra < extra) return TRUE; + if (current_world_ptr->h_ver_extra > extra) return FALSE; /* Identical versions */ - return (FALSE); + return FALSE; } @@ -128,19 +160,19 @@ static bool h_older_than(byte major, byte minor, byte patch, byte extra) static bool z_older_than(byte x, byte y, byte z) { /* Much older, or much more recent */ - if (z_major < x) return (TRUE); - if (z_major > x) return (FALSE); + if (current_world_ptr->z_major < x) return TRUE; + if (current_world_ptr->z_major > x) return FALSE; /* Distinctly older, or distinctly more recent */ - if (z_minor < y) return (TRUE); - if (z_minor > y) return (FALSE); + if (current_world_ptr->z_minor < y) return TRUE; + if (current_world_ptr->z_minor > y) return FALSE; /* Barely older, or barely more recent */ - if (z_patch < z) return (TRUE); - if (z_patch > z) return (FALSE); + if (current_world_ptr->z_patch < z) return TRUE; + if (current_world_ptr->z_patch > z) return FALSE; /* Identical versions */ - return (FALSE); + return FALSE; } @@ -580,8 +612,6 @@ static void rd_item_old(object_type *o_ptr) add_flag(o_ptr->art_flags, TR_DEC_MANA); } } - - /* Paranoia */ if (object_is_fixed_artifact(o_ptr)) { artifact_type *a_ptr; @@ -592,8 +622,6 @@ static void rd_item_old(object_type *o_ptr) /* Verify that artifact */ if (!a_ptr->name) o_ptr->name1 = 0; } - - /* Paranoia */ if (object_is_ego(o_ptr)) { ego_item_type *e_ptr; @@ -788,7 +816,6 @@ static void rd_item(object_type *o_ptr) } else { - /* Paranoia */ add_flag(o_ptr->art_flags, TR_LITE_M1); } } @@ -853,6 +880,7 @@ static void rd_monster_old(monster_type *m_ptr) m_ptr->fy = (POSITION)tmp8u; rd_byte(&tmp8u); m_ptr->fx = (POSITION)tmp8u; + m_ptr->current_floor_ptr = p_ptr->current_floor_ptr; rd_s16b(&tmp16s); m_ptr->hp = tmp16s; @@ -931,7 +959,7 @@ static void rd_monster_old(monster_type *m_ptr) rd_byte(&tmp8u); m_ptr->mtimed[MTIMED_INVULNER] = (s16b)tmp8u; - if (!(z_major == 2 && z_minor == 0 && z_patch == 6)) + if (!(current_world_ptr->z_major == 2 && current_world_ptr->z_minor == 0 && current_world_ptr->z_patch == 6)) rd_u32b(&m_ptr->smart); else m_ptr->smart = 0; @@ -1349,7 +1377,7 @@ static void home_carry(store_type *st_ptr, object_type *o_ptr) /* Insert the new item */ st_ptr->stock[slot] = *o_ptr; - chg_virtue(V_SACRIFICE, -1); + chg_virtue(p_ptr, V_SACRIFICE, -1); /* Return the location */ return; @@ -1514,7 +1542,7 @@ static void rd_options(void) rd_u16b(&c); - if (c & 0x0002) p_ptr->wizard = TRUE; + if (c & 0x0002) current_world_ptr->wizard = TRUE; cheat_peek = (c & 0x0100) ? TRUE : FALSE; cheat_hear = (c & 0x0200) ? TRUE : FALSE; @@ -1558,11 +1586,8 @@ static void rd_options(void) /* Set */ option_flag[n] |= (1L << i); } - - /* Clear */ else { - /* Clear */ option_flag[n] &= ~(1L << i); } } @@ -1622,11 +1647,8 @@ static void rd_options(void) /* Set */ window_flag[n] |= (1L << i); } - - /* Clear */ else { - /* Clear */ window_flag[n] &= ~(1L << i); } } @@ -1715,7 +1737,7 @@ static void load_quick_start(void) * @brief その他の情報を読み込む / Read the "extra" information * @return なし */ -static void rd_extra(void) +static void rd_extra(player_type *creature_ptr) { int i,j; @@ -1724,9 +1746,9 @@ static void rd_extra(void) s32b tmp32s; u16b tmp16u; - rd_string(p_ptr->name, sizeof(p_ptr->name)); + rd_string(creature_ptr->name, sizeof(creature_ptr->name)); - rd_string(p_ptr->died_from, sizeof(p_ptr->died_from)); + rd_string(creature_ptr->died_from, sizeof(creature_ptr->died_from)); if (!h_older_than(1, 7, 0, 1)) { @@ -1734,136 +1756,136 @@ static void rd_extra(void) /* Read the message */ rd_string(buf, sizeof buf); - if (buf[0]) p_ptr->last_message = string_make(buf); + if (buf[0]) creature_ptr->last_message = string_make(buf); } load_quick_start(); for (i = 0; i < 4; i++) { - rd_string(p_ptr->history[i], sizeof(p_ptr->history[i])); + rd_string(creature_ptr->history[i], sizeof(creature_ptr->history[i])); } /* Class/Race/Seikaku/Gender/Spells */ rd_byte(&tmp8u); - p_ptr->prace = (RACE_IDX)tmp8u; + creature_ptr->prace = (RACE_IDX)tmp8u; rd_byte(&tmp8u); - p_ptr->pclass = (CLASS_IDX)tmp8u; + creature_ptr->pclass = (CLASS_IDX)tmp8u; rd_byte(&tmp8u); - p_ptr->pseikaku = (CHARACTER_IDX)tmp8u; - rd_byte(&p_ptr->psex); + creature_ptr->pseikaku = (CHARACTER_IDX)tmp8u; + rd_byte(&creature_ptr->psex); rd_byte(&tmp8u); - p_ptr->realm1 = (REALM_IDX)tmp8u; + creature_ptr->realm1 = (REALM_IDX)tmp8u; rd_byte(&tmp8u); - p_ptr->realm2 = (REALM_IDX)tmp8u; + creature_ptr->realm2 = (REALM_IDX)tmp8u; rd_byte(&tmp8u); if (z_older_than(10, 4, 4)) { - if (p_ptr->realm1 == 9) p_ptr->realm1 = REALM_MUSIC; - if (p_ptr->realm2 == 9) p_ptr->realm2 = REALM_MUSIC; - if (p_ptr->realm1 == 10) p_ptr->realm1 = REALM_HISSATSU; - if (p_ptr->realm2 == 10) p_ptr->realm2 = REALM_HISSATSU; + if (creature_ptr->realm1 == 9) creature_ptr->realm1 = REALM_MUSIC; + if (creature_ptr->realm2 == 9) creature_ptr->realm2 = REALM_MUSIC; + if (creature_ptr->realm1 == 10) creature_ptr->realm1 = REALM_HISSATSU; + if (creature_ptr->realm2 == 10) creature_ptr->realm2 = REALM_HISSATSU; } /* Special Race/Class info */ rd_byte(&tmp8u); - p_ptr->hitdie = tmp8u; - rd_u16b(&p_ptr->expfact); + creature_ptr->hitdie = tmp8u; + rd_u16b(&creature_ptr->expfact); /* Age/Height/Weight */ - rd_s16b(&p_ptr->age); - rd_s16b(&p_ptr->ht); - rd_s16b(&p_ptr->wt); + rd_s16b(&creature_ptr->age); + rd_s16b(&creature_ptr->ht); + rd_s16b(&creature_ptr->wt); /* Read the stat info */ - 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]); + for (i = 0; i < A_MAX; i++) rd_s16b(&creature_ptr->stat_max[i]); + for (i = 0; i < A_MAX; i++) rd_s16b(&creature_ptr->stat_max_max[i]); + for (i = 0; i < A_MAX; i++) rd_s16b(&creature_ptr->stat_cur[i]); strip_bytes(24); - rd_s32b(&p_ptr->au); + rd_s32b(&creature_ptr->au); - rd_s32b(&p_ptr->max_exp); - if (h_older_than(1, 5, 4, 1)) p_ptr->max_max_exp = p_ptr->max_exp; - else rd_s32b(&p_ptr->max_max_exp); - rd_s32b(&p_ptr->exp); + rd_s32b(&creature_ptr->max_exp); + if (h_older_than(1, 5, 4, 1)) creature_ptr->max_max_exp = creature_ptr->max_exp; + else rd_s32b(&creature_ptr->max_max_exp); + rd_s32b(&creature_ptr->exp); if (h_older_than(1, 7, 0, 3)) { rd_u16b(&tmp16u); - p_ptr->exp_frac = (u32b)tmp16u; + creature_ptr->exp_frac = (u32b)tmp16u; } else { - rd_u32b(&p_ptr->exp_frac); + rd_u32b(&creature_ptr->exp_frac); } - rd_s16b(&p_ptr->lev); + rd_s16b(&creature_ptr->lev); - for (i = 0; i < 64; i++) rd_s16b(&p_ptr->spell_exp[i]); - if ((p_ptr->pclass == CLASS_SORCERER) && z_older_than(10, 4, 2)) + for (i = 0; i < 64; i++) rd_s16b(&creature_ptr->spell_exp[i]); + if ((creature_ptr->pclass == CLASS_SORCERER) && z_older_than(10, 4, 2)) { - for (i = 0; i < 64; i++) p_ptr->spell_exp[i] = SPELL_EXP_MASTER; + for (i = 0; i < 64; i++) creature_ptr->spell_exp[i] = SPELL_EXP_MASTER; } if (z_older_than(10, 3, 6)) - for (i = 0; i < 5; i++) for (j = 0; j < 60; j++) rd_s16b(&p_ptr->weapon_exp[i][j]); + for (i = 0; i < 5; i++) for (j = 0; j < 60; j++) rd_s16b(&creature_ptr->weapon_exp[i][j]); else - for (i = 0; i < 5; i++) for (j = 0; j < 64; j++) rd_s16b(&p_ptr->weapon_exp[i][j]); - for (i = 0; i < GINOU_MAX; i++) rd_s16b(&p_ptr->skill_exp[i]); + for (i = 0; i < 5; i++) for (j = 0; j < 64; j++) rd_s16b(&creature_ptr->weapon_exp[i][j]); + for (i = 0; i < GINOU_MAX; i++) rd_s16b(&creature_ptr->skill_exp[i]); if (z_older_than(10, 4, 1)) { - if (p_ptr->pclass != CLASS_BEASTMASTER) p_ptr->skill_exp[GINOU_RIDING] /= 2; - p_ptr->skill_exp[GINOU_RIDING] = MIN(p_ptr->skill_exp[GINOU_RIDING], s_info[p_ptr->pclass].s_max[GINOU_RIDING]); + if (creature_ptr->pclass != CLASS_BEASTMASTER) creature_ptr->skill_exp[GINOU_RIDING] /= 2; + creature_ptr->skill_exp[GINOU_RIDING] = MIN(creature_ptr->skill_exp[GINOU_RIDING], s_info[creature_ptr->pclass].s_max[GINOU_RIDING]); } if (z_older_than(10, 3, 14)) { - for (i = 0; i < 108; i++) p_ptr->magic_num1[i] = 0; - for (i = 0; i < 108; i++) p_ptr->magic_num2[i] = 0; + for (i = 0; i < 108; i++) creature_ptr->magic_num1[i] = 0; + for (i = 0; i < 108; i++) creature_ptr->magic_num2[i] = 0; } else { - for (i = 0; i < 108; i++) rd_s32b(&p_ptr->magic_num1[i]); - for (i = 0; i < 108; i++) rd_byte(&p_ptr->magic_num2[i]); + for (i = 0; i < 108; i++) rd_s32b(&creature_ptr->magic_num1[i]); + for (i = 0; i < 108; i++) rd_byte(&creature_ptr->magic_num2[i]); if (h_older_than(1, 3, 0, 1)) { - if (p_ptr->pclass == CLASS_SMITH) + if (creature_ptr->pclass == CLASS_SMITH) { - p_ptr->magic_num1[TR_ES_ATTACK] = p_ptr->magic_num1[96]; - p_ptr->magic_num1[96] = 0; - p_ptr->magic_num1[TR_ES_AC] = p_ptr->magic_num1[97]; - p_ptr->magic_num1[97] = 0; + creature_ptr->magic_num1[TR_ES_ATTACK] = creature_ptr->magic_num1[96]; + creature_ptr->magic_num1[96] = 0; + creature_ptr->magic_num1[TR_ES_AC] = creature_ptr->magic_num1[97]; + creature_ptr->magic_num1[97] = 0; } } } - if (music_singing_any()) p_ptr->action = ACTION_SING; + if (music_singing_any(creature_ptr)) creature_ptr->action = ACTION_SING; if (z_older_than(11, 0, 7)) { - p_ptr->start_race = p_ptr->prace; - p_ptr->old_race1 = 0L; - p_ptr->old_race2 = 0L; - p_ptr->old_realm = 0; + creature_ptr->start_race = creature_ptr->prace; + creature_ptr->old_race1 = 0L; + creature_ptr->old_race2 = 0L; + creature_ptr->old_realm = 0; } else { rd_byte(&tmp8u); - p_ptr->start_race = (RACE_IDX)tmp8u; + creature_ptr->start_race = (RACE_IDX)tmp8u; rd_s32b(&tmp32s); - p_ptr->old_race1 = (BIT_FLAGS)tmp32s; + creature_ptr->old_race1 = (BIT_FLAGS)tmp32s; rd_s32b(&tmp32s); - p_ptr->old_race2 = (BIT_FLAGS)tmp32s; - rd_s16b(&p_ptr->old_realm); + creature_ptr->old_race2 = (BIT_FLAGS)tmp32s; + rd_s16b(&creature_ptr->old_realm); } if (z_older_than(10, 0, 1)) { for (i = 0; i < MAX_MANE; i++) { - p_ptr->mane_spell[i] = -1; - p_ptr->mane_dam[i] = 0; + creature_ptr->mane_spell[i] = -1; + creature_ptr->mane_dam[i] = 0; } - p_ptr->mane_num = 0; + creature_ptr->mane_num = 0; } else if (z_older_than(10, 2, 3)) { @@ -1874,29 +1896,29 @@ static void rd_extra(void) } for (i = 0; i < MAX_MANE; i++) { - p_ptr->mane_spell[i] = -1; - p_ptr->mane_dam[i] = 0; + creature_ptr->mane_spell[i] = -1; + creature_ptr->mane_dam[i] = 0; } rd_s16b(&tmp16s); - p_ptr->mane_num = 0; + creature_ptr->mane_num = 0; } else { for (i = 0; i < MAX_MANE; i++) { rd_s16b(&tmp16s); - p_ptr->mane_spell[i] = (SPELL_IDX)tmp16s; + creature_ptr->mane_spell[i] = (SPELL_IDX)tmp16s; rd_s16b(&tmp16s); - p_ptr->mane_dam[i] = (SPELL_IDX)tmp16s; + creature_ptr->mane_dam[i] = (SPELL_IDX)tmp16s; } - rd_s16b(&p_ptr->mane_num); + rd_s16b(&creature_ptr->mane_num); } if (z_older_than(10, 0, 3)) { determine_bounty_uniques(); - for (i = 0; i < MAX_KUBI; i++) + for (i = 0; i < MAX_BOUNTY; i++) { /* Is this bounty unique already dead? */ if (!r_info[current_world_ptr->bounty_r_idx[i]].max_num) current_world_ptr->bounty_r_idx[i] += 10000; @@ -1904,7 +1926,7 @@ static void rd_extra(void) } else { - for (i = 0; i < MAX_KUBI; i++) + for (i = 0; i < MAX_BOUNTY; i++) { rd_s16b(¤t_world_ptr->bounty_r_idx[i]); } @@ -1912,7 +1934,7 @@ static void rd_extra(void) if (z_older_than(10, 0, 3)) { - battle_monsters(); + update_gambling_monsters(creature_ptr); } else { @@ -1928,35 +1950,35 @@ static void rd_extra(void) } } - rd_s16b(&p_ptr->town_num); + rd_s16b(&creature_ptr->town_num); /* Read arena and rewards information */ - rd_s16b(&p_ptr->arena_number); + rd_s16b(&creature_ptr->arena_number); if (h_older_than(1, 5, 0, 1)) { /* Arena loser of previous version was marked number 99 */ - if (p_ptr->arena_number >= 99) p_ptr->arena_number = ARENA_DEFEATED_OLD_VER; + if (creature_ptr->arena_number >= 99) creature_ptr->arena_number = ARENA_DEFEATED_OLD_VER; } rd_s16b(&tmp16s); - p_ptr->inside_arena = (bool)tmp16s; - rd_s16b(&p_ptr->inside_quest); - if (z_older_than(10, 3, 5)) p_ptr->inside_battle = FALSE; + creature_ptr->current_floor_ptr->inside_arena = (bool)tmp16s; + rd_s16b(&creature_ptr->current_floor_ptr->inside_quest); + if (z_older_than(10, 3, 5)) creature_ptr->phase_out = FALSE; else { rd_s16b(&tmp16s); - p_ptr->inside_battle = (bool)tmp16s; + creature_ptr->phase_out = (bool)tmp16s; } - rd_byte(&p_ptr->exit_bldg); + rd_byte(&creature_ptr->exit_bldg); rd_byte(&tmp8u); rd_s16b(&tmp16s); - p_ptr->oldpx = (POSITION)tmp16s; + creature_ptr->oldpx = (POSITION)tmp16s; rd_s16b(&tmp16s); - p_ptr->oldpy = (POSITION)tmp16s; + creature_ptr->oldpy = (POSITION)tmp16s; - if (z_older_than(10, 3, 13) && !current_floor_ptr->dun_level && !p_ptr->inside_arena) {p_ptr->oldpy = 33;p_ptr->oldpx = 131;} + if (z_older_than(10, 3, 13) && !creature_ptr->current_floor_ptr->dun_level && !creature_ptr->current_floor_ptr->inside_arena) {creature_ptr->oldpy = 33;creature_ptr->oldpx = 131;} - /* Was p_ptr->rewards[MAX_BACT] */ + /* Was creature_ptr->rewards[MAX_BACT] */ rd_s16b(&tmp16s); for (i = 0; i < tmp16s; i++) { @@ -1967,40 +1989,40 @@ static void rd_extra(void) if (h_older_than(1, 7, 0, 3)) { rd_s16b(&tmp16s); - p_ptr->mhp = tmp16s; + creature_ptr->mhp = tmp16s; rd_s16b(&tmp16s); - p_ptr->chp = tmp16s; + creature_ptr->chp = tmp16s; rd_u16b(&tmp16u); - p_ptr->chp_frac = (u32b)tmp16u; + creature_ptr->chp_frac = (u32b)tmp16u; } else { - rd_s32b(&p_ptr->mhp); - rd_s32b(&p_ptr->chp); - rd_u32b(&p_ptr->chp_frac); + rd_s32b(&creature_ptr->mhp); + rd_s32b(&creature_ptr->chp); + rd_u32b(&creature_ptr->chp_frac); } if (h_older_than(1, 7, 0, 3)) { rd_s16b(&tmp16s); - p_ptr->msp = tmp16s; + creature_ptr->msp = tmp16s; rd_s16b(&tmp16s); - p_ptr->csp = tmp16s; + creature_ptr->csp = tmp16s; rd_u16b(&tmp16u); - p_ptr->csp_frac = (u32b)tmp16u; + creature_ptr->csp_frac = (u32b)tmp16u; } else { - rd_s32b(&p_ptr->msp); - rd_s32b(&p_ptr->csp); - rd_u32b(&p_ptr->csp_frac); + rd_s32b(&creature_ptr->msp); + rd_s32b(&creature_ptr->csp); + rd_u32b(&creature_ptr->csp_frac); } - rd_s16b(&p_ptr->max_plv); + rd_s16b(&creature_ptr->max_plv); if (z_older_than(10, 3, 8)) { rd_s16b(&tmp16s); @@ -2008,7 +2030,7 @@ static void rd_extra(void) } else { - byte max = (byte)max_d_idx; + byte max = (byte)current_world_ptr->max_d_idx; rd_byte(&max); @@ -2021,209 +2043,209 @@ static void rd_extra(void) } /* Repair maximum player level */ - if (p_ptr->max_plv < p_ptr->lev) p_ptr->max_plv = p_ptr->lev; + if (creature_ptr->max_plv < creature_ptr->lev) creature_ptr->max_plv = creature_ptr->lev; /* More info */ strip_bytes(8); - rd_s16b(&p_ptr->sc); - rd_s16b(&p_ptr->concent); + rd_s16b(&creature_ptr->sc); + rd_s16b(&creature_ptr->concent); /* Read the flags */ strip_bytes(2); /* Old "rest" */ - rd_s16b(&p_ptr->blind); - rd_s16b(&p_ptr->paralyzed); - rd_s16b(&p_ptr->confused); - rd_s16b(&p_ptr->food); + rd_s16b(&creature_ptr->blind); + rd_s16b(&creature_ptr->paralyzed); + rd_s16b(&creature_ptr->confused); + rd_s16b(&creature_ptr->food); strip_bytes(4); /* Old "food_digested" / "protection" */ - rd_s16b(&p_ptr->energy_need); + rd_s16b(&creature_ptr->energy_need); if (z_older_than(11, 0, 13)) - p_ptr->energy_need = 100 - p_ptr->energy_need; + creature_ptr->energy_need = 100 - creature_ptr->energy_need; if (h_older_than(2, 1, 2, 0)) - p_ptr->enchant_energy_need = 0; + creature_ptr->enchant_energy_need = 0; else - rd_s16b(&p_ptr->enchant_energy_need); - - rd_s16b(&p_ptr->fast); - rd_s16b(&p_ptr->slow); - rd_s16b(&p_ptr->afraid); - rd_s16b(&p_ptr->cut); - rd_s16b(&p_ptr->stun); - rd_s16b(&p_ptr->poisoned); - rd_s16b(&p_ptr->image); - rd_s16b(&p_ptr->protevil); - rd_s16b(&p_ptr->invuln); + rd_s16b(&creature_ptr->enchant_energy_need); + + rd_s16b(&creature_ptr->fast); + rd_s16b(&creature_ptr->slow); + rd_s16b(&creature_ptr->afraid); + rd_s16b(&creature_ptr->cut); + rd_s16b(&creature_ptr->stun); + rd_s16b(&creature_ptr->poisoned); + rd_s16b(&creature_ptr->image); + rd_s16b(&creature_ptr->protevil); + rd_s16b(&creature_ptr->invuln); if(z_older_than(10, 0, 0)) - p_ptr->ult_res = 0; + creature_ptr->ult_res = 0; else - rd_s16b(&p_ptr->ult_res); - rd_s16b(&p_ptr->hero); - rd_s16b(&p_ptr->shero); - rd_s16b(&p_ptr->shield); - rd_s16b(&p_ptr->blessed); - rd_s16b(&p_ptr->tim_invis); - rd_s16b(&p_ptr->word_recall); + rd_s16b(&creature_ptr->ult_res); + rd_s16b(&creature_ptr->hero); + rd_s16b(&creature_ptr->shero); + rd_s16b(&creature_ptr->shield); + rd_s16b(&creature_ptr->blessed); + rd_s16b(&creature_ptr->tim_invis); + rd_s16b(&creature_ptr->word_recall); if (z_older_than(10, 3, 8)) - p_ptr->recall_dungeon = DUNGEON_ANGBAND; + creature_ptr->recall_dungeon = DUNGEON_ANGBAND; else { rd_s16b(&tmp16s); - p_ptr->recall_dungeon = (byte)tmp16s; + creature_ptr->recall_dungeon = (byte)tmp16s; } if (h_older_than(1, 5, 0, 0)) - p_ptr->alter_reality = 0; + creature_ptr->alter_reality = 0; else - rd_s16b(&p_ptr->alter_reality); - - rd_s16b(&p_ptr->see_infra); - rd_s16b(&p_ptr->tim_infra); - rd_s16b(&p_ptr->oppose_fire); - rd_s16b(&p_ptr->oppose_cold); - rd_s16b(&p_ptr->oppose_acid); - rd_s16b(&p_ptr->oppose_elec); - rd_s16b(&p_ptr->oppose_pois); - if (z_older_than(10,0,2)) p_ptr->tsuyoshi = 0; - else rd_s16b(&p_ptr->tsuyoshi); + rd_s16b(&creature_ptr->alter_reality); + + rd_s16b(&creature_ptr->see_infra); + rd_s16b(&creature_ptr->tim_infra); + rd_s16b(&creature_ptr->oppose_fire); + rd_s16b(&creature_ptr->oppose_cold); + rd_s16b(&creature_ptr->oppose_acid); + rd_s16b(&creature_ptr->oppose_elec); + rd_s16b(&creature_ptr->oppose_pois); + if (z_older_than(10,0,2)) creature_ptr->tsuyoshi = 0; + else rd_s16b(&creature_ptr->tsuyoshi); /* Old savefiles do not have the following fields... */ - if ((z_major == 2) && (z_minor == 0) && (z_patch == 6)) - { - p_ptr->tim_esp = 0; - p_ptr->wraith_form = 0; - p_ptr->resist_magic = 0; - p_ptr->tim_regen = 0; - p_ptr->kabenuke = 0; - p_ptr->tim_stealth = 0; - p_ptr->tim_levitation = 0; - p_ptr->tim_sh_touki = 0; - p_ptr->lightspeed = 0; - p_ptr->tsubureru = 0; - p_ptr->tim_res_nether = 0; - p_ptr->tim_res_time = 0; - p_ptr->mimic_form = 0; - p_ptr->tim_mimic = 0; - p_ptr->tim_sh_fire = 0; + if ((current_world_ptr->z_major == 2) && (current_world_ptr->z_minor == 0) && (current_world_ptr->z_patch == 6)) + { + creature_ptr->tim_esp = 0; + creature_ptr->wraith_form = 0; + creature_ptr->resist_magic = 0; + creature_ptr->tim_regen = 0; + creature_ptr->kabenuke = 0; + creature_ptr->tim_stealth = 0; + creature_ptr->tim_levitation = 0; + creature_ptr->tim_sh_touki = 0; + creature_ptr->lightspeed = 0; + creature_ptr->tsubureru = 0; + creature_ptr->tim_res_nether = 0; + creature_ptr->tim_res_time = 0; + creature_ptr->mimic_form = 0; + creature_ptr->tim_mimic = 0; + creature_ptr->tim_sh_fire = 0; /* by henkma */ - p_ptr->tim_reflect = 0; - p_ptr->multishadow = 0; - p_ptr->dustrobe = 0; + creature_ptr->tim_reflect = 0; + creature_ptr->multishadow = 0; + creature_ptr->dustrobe = 0; - p_ptr->chaos_patron = ((p_ptr->age + p_ptr->sc) % MAX_PATRON); - p_ptr->muta1 = 0; - p_ptr->muta2 = 0; - p_ptr->muta3 = 0; - get_virtues(); + creature_ptr->chaos_patron = ((creature_ptr->age + creature_ptr->sc) % MAX_PATRON); + creature_ptr->muta1 = 0; + creature_ptr->muta2 = 0; + creature_ptr->muta3 = 0; + get_virtues(creature_ptr); } else { - rd_s16b(&p_ptr->tim_esp); - rd_s16b(&p_ptr->wraith_form); - rd_s16b(&p_ptr->resist_magic); - rd_s16b(&p_ptr->tim_regen); - rd_s16b(&p_ptr->kabenuke); - rd_s16b(&p_ptr->tim_stealth); - rd_s16b(&p_ptr->tim_levitation); - rd_s16b(&p_ptr->tim_sh_touki); - rd_s16b(&p_ptr->lightspeed); - rd_s16b(&p_ptr->tsubureru); + rd_s16b(&creature_ptr->tim_esp); + rd_s16b(&creature_ptr->wraith_form); + rd_s16b(&creature_ptr->resist_magic); + rd_s16b(&creature_ptr->tim_regen); + rd_s16b(&creature_ptr->kabenuke); + rd_s16b(&creature_ptr->tim_stealth); + rd_s16b(&creature_ptr->tim_levitation); + rd_s16b(&creature_ptr->tim_sh_touki); + rd_s16b(&creature_ptr->lightspeed); + rd_s16b(&creature_ptr->tsubureru); if (z_older_than(10, 4, 7)) - p_ptr->magicdef = 0; + creature_ptr->magicdef = 0; else - rd_s16b(&p_ptr->magicdef); - rd_s16b(&p_ptr->tim_res_nether); + rd_s16b(&creature_ptr->magicdef); + rd_s16b(&creature_ptr->tim_res_nether); if (z_older_than(10, 4, 11)) { - p_ptr->tim_res_time = 0; - p_ptr->mimic_form = 0; - p_ptr->tim_mimic = 0; - p_ptr->tim_sh_fire = 0; + creature_ptr->tim_res_time = 0; + creature_ptr->mimic_form = 0; + creature_ptr->tim_mimic = 0; + creature_ptr->tim_sh_fire = 0; } else { - rd_s16b(&p_ptr->tim_res_time); + rd_s16b(&creature_ptr->tim_res_time); rd_byte(&tmp8u); - p_ptr->mimic_form = (IDX)tmp8u; - rd_s16b(&p_ptr->tim_mimic); - rd_s16b(&p_ptr->tim_sh_fire); + creature_ptr->mimic_form = (IDX)tmp8u; + rd_s16b(&creature_ptr->tim_mimic); + rd_s16b(&creature_ptr->tim_sh_fire); } if (z_older_than(11, 0, 99)) { - p_ptr->tim_sh_holy = 0; - p_ptr->tim_eyeeye = 0; + creature_ptr->tim_sh_holy = 0; + creature_ptr->tim_eyeeye = 0; } else { - rd_s16b(&p_ptr->tim_sh_holy); - rd_s16b(&p_ptr->tim_eyeeye); + rd_s16b(&creature_ptr->tim_sh_holy); + rd_s16b(&creature_ptr->tim_eyeeye); } /* by henkma */ if ( z_older_than(11,0,3) ){ - p_ptr->tim_reflect=0; - p_ptr->multishadow=0; - p_ptr->dustrobe=0; + creature_ptr->tim_reflect=0; + creature_ptr->multishadow=0; + creature_ptr->dustrobe=0; } else { - rd_s16b(&p_ptr->tim_reflect); - rd_s16b(&p_ptr->multishadow); - rd_s16b(&p_ptr->dustrobe); + rd_s16b(&creature_ptr->tim_reflect); + rd_s16b(&creature_ptr->multishadow); + rd_s16b(&creature_ptr->dustrobe); } - rd_s16b(&p_ptr->chaos_patron); - rd_u32b(&p_ptr->muta1); - rd_u32b(&p_ptr->muta2); - rd_u32b(&p_ptr->muta3); + rd_s16b(&creature_ptr->chaos_patron); + rd_u32b(&creature_ptr->muta1); + rd_u32b(&creature_ptr->muta2); + rd_u32b(&creature_ptr->muta3); for (i = 0; i < 8; i++) - rd_s16b(&p_ptr->virtues[i]); + rd_s16b(&creature_ptr->virtues[i]); for (i = 0; i < 8; i++) - rd_s16b(&p_ptr->vir_types[i]); + rd_s16b(&creature_ptr->vir_types[i]); } /* Calc the regeneration modifier for mutations */ - p_ptr->mutant_regenerate_mod = calc_mutant_regenerate_mod(); + creature_ptr->mutant_regenerate_mod = calc_mutant_regenerate_mod(creature_ptr); if (z_older_than(10,0,9)) { rd_byte(&tmp8u); - if (tmp8u) p_ptr->special_attack = ATTACK_CONFUSE; - p_ptr->ele_attack = 0; + if (tmp8u) creature_ptr->special_attack = ATTACK_CONFUSE; + creature_ptr->ele_attack = 0; } else { - rd_s16b(&p_ptr->ele_attack); - rd_u32b(&p_ptr->special_attack); + rd_s16b(&creature_ptr->ele_attack); + rd_u32b(&creature_ptr->special_attack); } - if (p_ptr->special_attack & KAMAE_MASK) p_ptr->action = ACTION_KAMAE; - else if (p_ptr->special_attack & KATA_MASK) p_ptr->action = ACTION_KATA; + if (creature_ptr->special_attack & KAMAE_MASK) creature_ptr->action = ACTION_KAMAE; + else if (creature_ptr->special_attack & KATA_MASK) creature_ptr->action = ACTION_KATA; if (z_older_than(10,0,12)) { - p_ptr->ele_immune = 0; - p_ptr->special_defense = 0; + creature_ptr->ele_immune = 0; + creature_ptr->special_defense = 0; } else { - rd_s16b(&p_ptr->ele_immune); - rd_u32b(&p_ptr->special_defense); + rd_s16b(&creature_ptr->ele_immune); + rd_u32b(&creature_ptr->special_defense); } - rd_byte(&p_ptr->knowledge); + rd_byte(&creature_ptr->knowledge); rd_byte(&tmp8u); - p_ptr->autopick_autoregister = tmp8u ? TRUE : FALSE; + creature_ptr->autopick_autoregister = tmp8u ? TRUE : FALSE; rd_byte(&tmp8u); rd_byte(&tmp8u); - p_ptr->action = (ACTION_IDX)tmp8u; + creature_ptr->action = (ACTION_IDX)tmp8u; if (!z_older_than(10, 4, 3)) { rd_byte(&tmp8u); - if (tmp8u) p_ptr->action = ACTION_LEARN; + if (tmp8u) creature_ptr->action = ACTION_LEARN; } rd_byte((byte *)&preserve_mode); - rd_byte((byte *)&p_ptr->wait_report_score); + rd_byte((byte *)&creature_ptr->wait_report_score); /* Future use */ for (i = 0; i < 48; i++) rd_byte(&tmp8u); @@ -2233,24 +2255,24 @@ static void rd_extra(void) /* Hack -- the two "special seeds" */ - rd_u32b(&seed_flavor); - rd_u32b(&seed_town); + rd_u32b(¤t_world_ptr->seed_flavor); + rd_u32b(¤t_world_ptr->seed_town); /* Special stuff */ - rd_u16b(&p_ptr->panic_save); - rd_u16b(&p_ptr->total_winner); - rd_u16b(&p_ptr->noscore); + rd_u16b(&creature_ptr->panic_save); + rd_u16b(¤t_world_ptr->total_winner); + rd_u16b(¤t_world_ptr->noscore); /* Read "death" */ rd_byte(&tmp8u); - p_ptr->is_dead = tmp8u; + creature_ptr->is_dead = tmp8u; /* Read "feeling" */ - rd_byte(&p_ptr->feeling); + rd_byte(&creature_ptr->feeling); - switch (p_ptr->start_race) + switch (creature_ptr->start_race) { case RACE_VAMPIRE: case RACE_SKELETON: @@ -2265,19 +2287,19 @@ static void rd_extra(void) current_world_ptr->dungeon_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4; /* Turn when level began */ - rd_s32b(¤t_floor_ptr->generated_turn); + rd_s32b(&creature_ptr->current_floor_ptr->generated_turn); if (h_older_than(1, 7, 0, 4)) { - p_ptr->feeling_turn = current_floor_ptr->generated_turn; + creature_ptr->feeling_turn = creature_ptr->current_floor_ptr->generated_turn; } else { /* Turn of last "feeling" */ - rd_s32b(&p_ptr->feeling_turn); + rd_s32b(&creature_ptr->feeling_turn); } - /* Current current_world_ptr->game_turn */ + /* Current turn */ rd_s32b(¤t_world_ptr->game_turn); if (z_older_than(10, 3, 12)) @@ -2288,45 +2310,45 @@ static void rd_extra(void) if (z_older_than(11, 0, 13)) { - current_floor_ptr->generated_turn /= 2; - p_ptr->feeling_turn /= 2; + creature_ptr->current_floor_ptr->generated_turn /= 2; + creature_ptr->feeling_turn /= 2; current_world_ptr->game_turn /= 2; current_world_ptr->dungeon_turn /= 2; } if (z_older_than(10, 3, 13)) { - old_battle = current_world_ptr->game_turn; + current_world_ptr->arena_start_turn = current_world_ptr->game_turn; } - else rd_s32b(&old_battle); + else rd_s32b(¤t_world_ptr->arena_start_turn); if (z_older_than(10,0,3)) { - determine_today_mon(TRUE); + determine_daily_bounty(creature_ptr, TRUE); } else { rd_s16b(&today_mon); - rd_s16b(&p_ptr->today_mon); + rd_s16b(&creature_ptr->today_mon); } if (z_older_than(10,0,7)) { - p_ptr->riding = 0; + creature_ptr->riding = 0; } else { - rd_s16b(&p_ptr->riding); + rd_s16b(&creature_ptr->riding); } /* Current floor_id */ if (h_older_than(1, 5, 0, 0)) { - p_ptr->floor_id = 0; + creature_ptr->floor_id = 0; } else { - rd_s16b(&p_ptr->floor_id); + rd_s16b(&creature_ptr->floor_id); } if (h_older_than(1, 5, 0, 2)) @@ -2349,30 +2371,30 @@ static void rd_extra(void) if (z_older_than(10,1,2)) { - playtime = 0; + current_world_ptr->play_time = 0; } else { - rd_u32b(&playtime); + rd_u32b(¤t_world_ptr->play_time); } if (z_older_than(10,3,9)) { - p_ptr->visit = 1L; + creature_ptr->visit = 1L; } else if (z_older_than(10, 3, 10)) { rd_s32b(&tmp32s); - p_ptr->visit = 1L; + creature_ptr->visit = 1L; } else { rd_s32b(&tmp32s); - p_ptr->visit = (BIT_FLAGS)tmp32s; + creature_ptr->visit = (BIT_FLAGS)tmp32s; } if (!z_older_than(11, 0, 5)) { - rd_u32b(&p_ptr->count); + rd_u32b(&creature_ptr->count); } } @@ -2400,11 +2422,14 @@ static errr rd_inventory(void) p_ptr->total_weight = 0; /* No items */ - inven_cnt = 0; - equip_cnt = 0; + p_ptr->inven_cnt = 0; + p_ptr->equip_cnt = 0; + + if (p_ptr->inventory_list != NULL) C_WIPE(p_ptr->inventory_list, INVEN_TOTAL, object_type); + C_MAKE(p_ptr->inventory_list, INVEN_TOTAL, object_type); /* Read until done */ - while (1) + while (TRUE) { u16b n; @@ -2426,38 +2451,36 @@ static errr rd_inventory(void) if (n >= INVEN_RARM) { q_ptr->marked |= OM_TOUCHED; - object_copy(&inventory[n], q_ptr); + object_copy(&p_ptr->inventory_list[n], q_ptr); /* Add the weight */ p_ptr->total_weight += (q_ptr->number * q_ptr->weight); /* One more item */ - equip_cnt++; + p_ptr->equip_cnt++; } /* Warning -- backpack is full */ - else if (inven_cnt == INVEN_PACK) + else if (p_ptr->inven_cnt == INVEN_PACK) { - note(_("持ち物の中のアイテムが多すぎる!", "Too many items in the inventory!")); + note(_("持ち物の中のアイテムが多すぎる!", "Too many items in the inventory")); /* Fail */ return (54); } - - /* Carry inventory */ else { /* Get a slot */ n = slot++; q_ptr->marked |= OM_TOUCHED; - object_copy(&inventory[n], q_ptr); + object_copy(&p_ptr->inventory_list[n], q_ptr); /* Add the weight */ p_ptr->total_weight += (q_ptr->number * q_ptr->weight); /* One more item */ - inven_cnt++; + p_ptr->inven_cnt++; } } @@ -2537,12 +2560,13 @@ static void rd_messages(void) /*! * @brief メッセージログを読み込む / Read the dungeon (old method) + * @param creature_ptr プレーヤーへの参照ポインタ * @return なし * @details * The monsters/objects must be loaded in the same order * that they were stored, since the actual indexes matter. */ -static errr rd_dungeon_old(void) +static errr rd_dungeon_old(player_type *creature_ptr) { int i, y, x; int ymax, xmax; @@ -2557,31 +2581,32 @@ static errr rd_dungeon_old(void) /* Header info */ rd_s16b(&tmp16s); - current_floor_ptr->dun_level = (DEPTH)tmp16s; - if (z_older_than(10, 3, 8)) p_ptr->dungeon_idx = DUNGEON_ANGBAND; + floor_type *floor_ptr = creature_ptr->current_floor_ptr; + floor_ptr->dun_level = (DEPTH)tmp16s; + if (z_older_than(10, 3, 8)) creature_ptr->dungeon_idx = DUNGEON_ANGBAND; else { rd_byte(&tmp8u); - p_ptr->dungeon_idx = (IDX)tmp8u; + creature_ptr->dungeon_idx = (IDX)tmp8u; } /* Set the base level for old versions */ - current_floor_ptr->base_level = current_floor_ptr->dun_level; + floor_ptr->base_level = floor_ptr->dun_level; rd_s16b(&tmp16s); - current_floor_ptr->base_level = (DEPTH)tmp16s; + floor_ptr->base_level = (DEPTH)tmp16s; rd_s16b(&tmp16s); - current_floor_ptr->num_repro = (MONSTER_NUMBER)tmp16s; + floor_ptr->num_repro = (MONSTER_NUMBER)tmp16s; rd_s16b(&tmp16s); - p_ptr->y = (POSITION)tmp16s; + creature_ptr->y = (POSITION)tmp16s; rd_s16b(&tmp16s); - p_ptr->x = (POSITION)tmp16s; - if (z_older_than(10, 3, 13) && !current_floor_ptr->dun_level && !p_ptr->inside_arena) {p_ptr->y = 33;p_ptr->x = 131;} + creature_ptr->x = (POSITION)tmp16s; + if (z_older_than(10, 3, 13) && !floor_ptr->dun_level && !floor_ptr->inside_arena) { creature_ptr->y = 33; creature_ptr->x = 131;} rd_s16b(&tmp16s); - current_floor_ptr->height = (POSITION)tmp16s; + floor_ptr->height = (POSITION)tmp16s; rd_s16b(&tmp16s); - current_floor_ptr->width = (POSITION)tmp16s; + floor_ptr->width = (POSITION)tmp16s; rd_s16b(&tmp16s); /* max_panel_rows */ rd_s16b(&tmp16s); /* max_panel_cols */ @@ -2590,8 +2615,8 @@ static errr rd_dungeon_old(void) #endif /* Maximal size */ - ymax = current_floor_ptr->height; - xmax = current_floor_ptr->width; + ymax = floor_ptr->height; + xmax = floor_ptr->width; /*** Run length decoding ***/ @@ -2619,8 +2644,7 @@ static errr rd_dungeon_old(void) /* Apply the RLE info */ for (i = count; i > 0; i--) { - /* Access the current_floor_ptr->grid_array */ - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Extract "info" */ g_ptr->info = info; @@ -2650,8 +2674,7 @@ static errr rd_dungeon_old(void) /* Apply the RLE info */ for (i = count; i > 0; i--) { - /* Access the current_floor_ptr->grid_array */ - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Extract "feat" */ g_ptr->feat = (s16b)tmp8u; @@ -2680,8 +2703,7 @@ static errr rd_dungeon_old(void) /* Apply the RLE info */ for (i = count; i > 0; i--) { - /* Access the current_floor_ptr->grid_array */ - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Extract "mimic" */ g_ptr->mimic = (s16b)tmp8u; @@ -2710,8 +2732,7 @@ static errr rd_dungeon_old(void) /* Apply the RLE info */ for (i = count; i > 0; i--) { - /* Access the current_floor_ptr->grid_array */ - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Extract "feat" */ g_ptr->special = tmp16s; @@ -2728,13 +2749,12 @@ static errr rd_dungeon_old(void) } } - /* Convert current_floor_ptr->grid_array data */ if (z_older_than(11, 0, 99)) { for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++) { /* Wipe old unused flags */ - current_floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK); + floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK); } } @@ -2742,8 +2762,7 @@ static errr rd_dungeon_old(void) { for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++) { - /* Access the current_floor_ptr->grid_array */ - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Very old */ if (g_ptr->feat == OLD_FEAT_INVIS) @@ -2765,8 +2784,7 @@ static errr rd_dungeon_old(void) { for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++) { - /* Access the current_floor_ptr->grid_array */ - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Old CAVE_IN_MIRROR flag */ if (g_ptr->info & CAVE_OBJECT) @@ -2788,7 +2806,7 @@ static errr rd_dungeon_old(void) { g_ptr->info &= ~CAVE_TRAP; g_ptr->mimic = g_ptr->feat; - g_ptr->feat = choose_random_trap(); + g_ptr->feat = choose_random_trap(creature_ptr); } /* Another hidden trap */ @@ -2805,10 +2823,9 @@ static errr rd_dungeon_old(void) { for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++) { - /* Access the current_floor_ptr->grid_array */ - g_ptr = ¤t_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; - if ((g_ptr->special == OLD_QUEST_WATER_CAVE) && !current_floor_ptr->dun_level) + if ((g_ptr->special == OLD_QUEST_WATER_CAVE) && !floor_ptr->dun_level) { if (g_ptr->feat == OLD_FEAT_QUEST_ENTER) { @@ -2821,7 +2838,7 @@ static errr rd_dungeon_old(void) } } else if ((g_ptr->feat == OLD_FEAT_QUEST_EXIT) && - (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE)) + (floor_ptr->inside_quest == OLD_QUEST_WATER_CAVE)) { g_ptr->feat = feat_up_stair; g_ptr->special = 0; @@ -2835,7 +2852,7 @@ static errr rd_dungeon_old(void) rd_u16b(&limit); /* Verify maximum */ - if (limit > current_floor_ptr->max_o_idx) + if (limit > current_world_ptr->max_o_idx) { note(format(_("アイテムの配列が大きすぎる(%d)!", "Too many (%d) object entries!"), limit)); return (151); @@ -2850,7 +2867,7 @@ static errr rd_dungeon_old(void) /* Get a new record */ - o_idx = o_pop(); + o_idx = o_pop(floor_ptr); if (i != o_idx) { @@ -2860,26 +2877,20 @@ static errr rd_dungeon_old(void) /* Acquire place */ - o_ptr = ¤t_floor_ptr->o_list[o_idx]; + o_ptr = &floor_ptr->o_list[o_idx]; /* Read the item */ rd_item(o_ptr); - /* XXX XXX */ - - /* Monster */ - if (o_ptr->held_m_idx) + if (OBJECT_IS_HELD_MONSTER(o_ptr)) { monster_type *m_ptr; - - /* Monster */ - m_ptr = ¤t_floor_ptr->m_list[o_ptr->held_m_idx]; + m_ptr = &floor_ptr->m_list[o_ptr->held_m_idx]; /* Build a stack */ o_ptr->next_o_idx = m_ptr->hold_o_idx; - /* Place the object */ m_ptr->hold_o_idx = o_idx; } @@ -2887,12 +2898,11 @@ static errr rd_dungeon_old(void) else { /* Access the item location */ - g_ptr = ¤t_floor_ptr->grid_array[o_ptr->iy][o_ptr->ix]; + g_ptr = &floor_ptr->grid_array[o_ptr->iy][o_ptr->ix]; /* Build a stack */ o_ptr->next_o_idx = g_ptr->o_idx; - /* Place the object */ g_ptr->o_idx = o_idx; } } @@ -2904,7 +2914,7 @@ static errr rd_dungeon_old(void) rd_u16b(&limit); /* Hack -- verify */ - if (limit > current_floor_ptr->max_m_idx) + if (limit > current_world_ptr->max_m_idx) { note(format(_("モンスターの配列が大きすぎる(%d)!", "Too many (%d) monster entries!"), limit)); return (161); @@ -2925,16 +2935,14 @@ static errr rd_dungeon_old(void) return (162); } - - /* Acquire monster */ - m_ptr = ¤t_floor_ptr->m_list[m_idx]; + m_ptr = &floor_ptr->m_list[m_idx]; /* Read the monster */ rd_monster(m_ptr); /* Access grid */ - g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx]; + g_ptr = &floor_ptr->grid_array[m_ptr->fy][m_ptr->fx]; /* Mark the location */ g_ptr->m_idx = m_idx; @@ -2946,10 +2954,10 @@ static errr rd_dungeon_old(void) /*** Success ***/ /* The dungeon is ready */ - if (z_older_than(10, 3, 13) && !current_floor_ptr->dun_level && !p_ptr->inside_arena) - character_dungeon = FALSE; + if (z_older_than(10, 3, 13) && !floor_ptr->dun_level && !floor_ptr->inside_arena) + current_world_ptr->character_dungeon = FALSE; else - character_dungeon = TRUE; + current_world_ptr->character_dungeon = TRUE; /* Success */ return (0); @@ -2958,6 +2966,8 @@ static errr rd_dungeon_old(void) /*! * @brief 保存されたフロアを読み込む / Read the saved floor + * @param player_ptr プレーヤーへの参照ポインタ + * @param sf_ptr 最後に保存されたフロアへの参照ポインタ * @return info読み込みエラーコード * @details * この関数は、セーブデータの互換性を保つために多くのデータ改変処理を備えている。 @@ -2969,7 +2979,7 @@ static errr rd_dungeon_old(void) * The monsters/objects must be loaded in the same order * that they were stored, since the actual indexes matter. */ -static errr rd_saved_floor(saved_floor_type *sf_ptr) +static errr rd_saved_floor(player_type *player_ptr, saved_floor_type *sf_ptr) { POSITION ymax, xmax; POSITION y, x; @@ -2982,12 +2992,12 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) u32b tmp32u; u16b limit; - cave_template_type *templates; - - - /*** Wipe all current_floor_ptr->grid_array ***/ - clear_cave(); + grid_template_type *templates; + floor_type *floor_ptr = player_ptr->current_floor_ptr; + clear_cave(player_ptr); + /* Mega-Hack -- no player yet */ + player_ptr->x = player_ptr->y = 0; /*** Basic info ***/ @@ -2998,8 +3008,8 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) /*** Not a saved floor ***/ rd_s16b(&tmp16s); - current_floor_ptr->dun_level = (DEPTH)tmp16s; - current_floor_ptr->base_level = current_floor_ptr->dun_level; + floor_ptr->dun_level = (DEPTH)tmp16s; + floor_ptr->base_level = floor_ptr->dun_level; } else { @@ -3013,7 +3023,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) rd_s16b(&tmp16s); if (tmp16s != sf_ptr->dun_level) return 171; - current_floor_ptr->dun_level = sf_ptr->dun_level; + floor_ptr->dun_level = sf_ptr->dun_level; rd_s32b(&tmp32s); if (tmp32s != sf_ptr->last_visit) return 171; @@ -3029,22 +3039,22 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) } rd_s16b(&tmp16s); - current_floor_ptr->base_level = (DEPTH)tmp16s; + floor_ptr->base_level = (DEPTH)tmp16s; rd_s16b(&tmp16s); - current_floor_ptr->num_repro = (MONSTER_NUMBER)tmp16s; + floor_ptr->num_repro = (MONSTER_NUMBER)tmp16s; rd_u16b(&tmp16u); - p_ptr->y = (POSITION)tmp16u; + player_ptr->y = (POSITION)tmp16u; rd_u16b(&tmp16u); - p_ptr->x = (POSITION)tmp16u; + player_ptr->x = (POSITION)tmp16u; rd_s16b(&tmp16s); - current_floor_ptr->height = (POSITION)tmp16s; + floor_ptr->height = (POSITION)tmp16s; rd_s16b(&tmp16s); - current_floor_ptr->width = (POSITION)tmp16s; + floor_ptr->width = (POSITION)tmp16s; - rd_byte(&p_ptr->feeling); + rd_byte(&player_ptr->feeling); @@ -3054,12 +3064,12 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) rd_u16b(&limit); /* Allocate the "template" array */ - C_MAKE(templates, limit, cave_template_type); + C_MAKE(templates, limit, grid_template_type); /* Read the templates */ for (i = 0; i < limit; i++) { - cave_template_type *ct_ptr = &templates[i]; + grid_template_type *ct_ptr = &templates[i]; /* Read it */ rd_u16b(&tmp16u); @@ -3080,8 +3090,8 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) } /* Maximal size */ - ymax = current_floor_ptr->height; - xmax = current_floor_ptr->width; + ymax = floor_ptr->height; + xmax = floor_ptr->width; /*** Run length decoding ***/ @@ -3104,10 +3114,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) /* Apply the RLE info */ for (i = count; i > 0; i--) { - /* Access the current_floor_ptr->grid_array */ - grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x]; - - /* Extract current_floor_ptr->grid_array data */ + grid_type *g_ptr = &floor_ptr->grid_array[y][x]; g_ptr->info = templates[id].info; g_ptr->feat = templates[id].feat; g_ptr->mimic = templates[id].mimic; @@ -3130,10 +3137,9 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) { for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++) { - /* Access the current_floor_ptr->grid_array */ - grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x]; + grid_type *g_ptr = &floor_ptr->grid_array[y][x]; - if ((g_ptr->special == OLD_QUEST_WATER_CAVE) && !current_floor_ptr->dun_level) + if ((g_ptr->special == OLD_QUEST_WATER_CAVE) && !floor_ptr->dun_level) { if (g_ptr->feat == OLD_FEAT_QUEST_ENTER) { @@ -3146,7 +3152,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) } } else if ((g_ptr->feat == OLD_FEAT_QUEST_EXIT) && - (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE)) + (floor_ptr->inside_quest == OLD_QUEST_WATER_CAVE)) { g_ptr->feat = feat_up_stair; g_ptr->special = 0; @@ -3155,7 +3161,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) } /* Free the "template" array */ - C_KILL(templates, limit, cave_template_type); + C_KILL(templates, limit, grid_template_type); /*** Objects ***/ @@ -3164,7 +3170,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) rd_u16b(&limit); /* Verify maximum */ - if (limit > current_floor_ptr->max_o_idx) return 151; + if (limit > current_world_ptr->max_o_idx) return 151; /* Read the dungeon items */ @@ -3175,29 +3181,24 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) /* Get a new record */ - o_idx = o_pop(); + o_idx = o_pop(floor_ptr); if (i != o_idx) return 152; /* Acquire place */ - o_ptr = ¤t_floor_ptr->o_list[o_idx]; + o_ptr = &floor_ptr->o_list[o_idx]; /* Read the item */ rd_item(o_ptr); - - /* Monster */ - if (o_ptr->held_m_idx) + if (OBJECT_IS_HELD_MONSTER(o_ptr)) { monster_type *m_ptr; - - /* Monster */ - m_ptr = ¤t_floor_ptr->m_list[o_ptr->held_m_idx]; + m_ptr = &floor_ptr->m_list[o_ptr->held_m_idx]; /* Build a stack */ o_ptr->next_o_idx = m_ptr->hold_o_idx; - /* Place the object */ m_ptr->hold_o_idx = o_idx; } @@ -3205,12 +3206,11 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) else { /* Access the item location */ - grid_type *g_ptr = ¤t_floor_ptr->grid_array[o_ptr->iy][o_ptr->ix]; + grid_type *g_ptr = &floor_ptr->grid_array[o_ptr->iy][o_ptr->ix]; /* Build a stack */ o_ptr->next_o_idx = g_ptr->o_idx; - /* Place the object */ g_ptr->o_idx = o_idx; } } @@ -3222,7 +3222,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) rd_u16b(&limit); /* Hack -- verify */ - if (limit > current_floor_ptr->max_m_idx) return 161; + if (limit > current_world_ptr->max_m_idx) return 161; /* Read the monsters */ for (i = 1; i < limit; i++) @@ -3236,16 +3236,14 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) if (i != m_idx) return 162; - - /* Acquire monster */ - m_ptr = ¤t_floor_ptr->m_list[m_idx]; + m_ptr = &floor_ptr->m_list[m_idx]; /* Read the monster */ rd_monster(m_ptr); /* Access grid */ - g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx]; + g_ptr = &floor_ptr->grid_array[m_ptr->fy][m_ptr->fx]; /* Mark the location */ g_ptr->m_idx = m_idx; @@ -3261,12 +3259,13 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) /*! * @brief 保存されたフロアを読み込む(現版) / Read the dungeon (new method) - * @return なし + * @param player_ptr プレーヤーへの参照ポインタ + * @return エラーコード * @details * The monsters/objects must be loaded in the same order * that they were stored, since the actual indexes matter. */ -static errr rd_dungeon(void) +static errr rd_dungeon(player_type *player_ptr) { errr err = 0; s16b tmp16s; @@ -3274,19 +3273,19 @@ static errr rd_dungeon(void) byte num; int i; - /* Initialize saved_floors array and temporal files */ - init_saved_floors(FALSE); + /* Initialize saved_floors array and temporary files */ + init_saved_floors(player_ptr, FALSE); /* Older method */ if (h_older_than(1, 5, 0, 0)) { - err = rd_dungeon_old(); + err = rd_dungeon_old(player_ptr); /* Prepare floor_id of current floor */ - if (p_ptr->dungeon_idx) + if (player_ptr->dungeon_idx) { - p_ptr->floor_id = get_new_floor_id(); - get_sf_ptr(p_ptr->floor_id)->dun_level = current_floor_ptr->dun_level; + player_ptr->floor_id = get_new_floor_id(player_ptr); + get_sf_ptr(player_ptr->floor_id)->dun_level = player_ptr->current_floor_ptr->dun_level; } return err; @@ -3300,7 +3299,7 @@ static errr rd_dungeon(void) /* Current dungeon type */ rd_byte(&tmp8u); - p_ptr->dungeon_idx = (DUNGEON_IDX)tmp8u; + player_ptr->dungeon_idx = (DUNGEON_IDX)tmp8u; /* Number of the saved_floors array elements */ rd_byte(&num); @@ -3309,7 +3308,7 @@ static errr rd_dungeon(void) if (!num) { /* Read the current floor data */ - err = rd_saved_floor(NULL); + err = rd_saved_floor(player_ptr, NULL); } /*** In the dungeon ***/ @@ -3335,7 +3334,7 @@ static errr rd_dungeon(void) } - /* Move saved floors data to temporal files */ + /* Move saved floors data to temporary files */ for (i = 0; i < num; i++) { saved_floor_type *sf_ptr = &saved_floors[i]; @@ -3348,22 +3347,22 @@ static errr rd_dungeon(void) if (tmp8u) continue; /* Read from the save file */ - err = rd_saved_floor(sf_ptr); + err = rd_saved_floor(player_ptr, sf_ptr); /* Error? */ if (err) break; - /* Re-save as temporal saved floor file */ - if (!save_floor(sf_ptr, SLF_SECOND)) err = 182; + /* Re-save as temporary saved floor file */ + if (!save_floor(player_ptr, sf_ptr, SLF_SECOND)) err = 182; /* Error? */ if (err) break; } - /* Finally load current floor data from temporal file */ + /* Finally load current floor data from temporary file */ if (!err) { - if (!load_floor(get_sf_ptr(p_ptr->floor_id), SLF_SECOND)) err = 183; + if (!load_floor(player_ptr, get_sf_ptr(player_ptr->floor_id), SLF_SECOND)) err = 183; } } @@ -3392,7 +3391,7 @@ static errr rd_dungeon(void) break; case 182: - note(_("テンポラリ・ファイルを作成できません!", "Failed to make temporal files!")); + note(_("テンポラリ・ファイルを作成できません!", "Failed to make temporary files!")); break; case 183: @@ -3401,7 +3400,7 @@ static errr rd_dungeon(void) } /* The dungeon is ready */ - character_dungeon = TRUE; + current_world_ptr->character_dungeon = TRUE; /* Success or Error */ return err; @@ -3412,7 +3411,7 @@ static errr rd_dungeon(void) * @brief ロード処理全体のサブ関数 / Actually read the savefile * @return エラーコード */ -static errr rd_savefile_new_aux(void) +static errr rd_savefile_new_aux(player_type *creature_ptr) { int i, j; int town_count; @@ -3435,7 +3434,7 @@ static errr rd_savefile_new_aux(void) strip_bytes(4); /* Hack -- decrypt */ - xor_byte = sf_extra; + xor_byte = current_world_ptr->sf_extra; /* Clear the checksums */ @@ -3444,28 +3443,28 @@ static errr rd_savefile_new_aux(void) /* Read the version number of the savefile */ /* Old savefile will be version 0.0.0.3 */ - rd_byte(&h_ver_extra); - rd_byte(&h_ver_patch); - rd_byte(&h_ver_minor); - rd_byte(&h_ver_major); + rd_byte(¤t_world_ptr->h_ver_extra); + rd_byte(¤t_world_ptr->h_ver_patch); + rd_byte(¤t_world_ptr->h_ver_minor); + rd_byte(¤t_world_ptr->h_ver_major); /* Mention the savefile version */ note(format( _("バージョン %d.%d.%d.%d のセーブ・ファイルをロード中...", "Loading a %d.%d.%d.%d savefile..."), - (h_ver_major > 9) ? h_ver_major - 10 : h_ver_major, h_ver_minor, h_ver_patch, h_ver_extra)); + (current_world_ptr->h_ver_major > 9) ? current_world_ptr->h_ver_major - 10 : current_world_ptr->h_ver_major, current_world_ptr->h_ver_minor, current_world_ptr->h_ver_patch, current_world_ptr->h_ver_extra)); /* Operating system info */ - rd_u32b(&sf_system); + rd_u32b(¤t_world_ptr->sf_system); /* Time of savefile creation */ - rd_u32b(&sf_when); + rd_u32b(¤t_world_ptr->sf_when); /* Number of resurrections */ - rd_u16b(&sf_lives); + rd_u16b(¤t_world_ptr->sf_lives); /* Number of times played */ - rd_u16b(&sf_saves); + rd_u16b(¤t_world_ptr->sf_saves); /* Later use (always zero) */ @@ -3552,7 +3551,7 @@ static errr rd_savefile_new_aux(void) u16b max_towns_load; u16b max_quests_load; byte max_rquests_load; - s16b old_inside_quest = p_ptr->inside_quest; + s16b old_inside_quest = creature_ptr->current_floor_ptr->inside_quest; /* Number of towns */ rd_u16b(&max_towns_load); @@ -3648,10 +3647,10 @@ static errr rd_savefile_new_aux(void) else { init_flags = INIT_ASSIGN; - p_ptr->inside_quest = (QUEST_IDX)i; + creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)i; - process_dungeon_file("q_info.txt", 0, 0, 0, 0); - p_ptr->inside_quest = old_inside_quest; + process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0); + creature_ptr->current_floor_ptr->inside_quest = old_inside_quest; } } else @@ -3689,18 +3688,18 @@ static errr rd_savefile_new_aux(void) } /* Position in the wilderness */ - rd_s32b(&p_ptr->wilderness_x); - rd_s32b(&p_ptr->wilderness_y); + rd_s32b(&creature_ptr->wilderness_x); + rd_s32b(&creature_ptr->wilderness_y); if (z_older_than(10, 3, 13)) { - p_ptr->wilderness_x = 5; - p_ptr->wilderness_y = 48; + creature_ptr->wilderness_x = 5; + creature_ptr->wilderness_y = 48; } - if (z_older_than(10, 3, 7)) p_ptr->wild_mode = FALSE; - else rd_byte((byte *)&p_ptr->wild_mode); - if (z_older_than(10, 3, 7)) ambush_flag = FALSE; - else rd_byte((byte *)&ambush_flag); + if (z_older_than(10, 3, 7)) creature_ptr->wild_mode = FALSE; + else rd_byte((byte *)&creature_ptr->wild_mode); + if (z_older_than(10, 3, 7)) creature_ptr->ambush_flag = FALSE; + else rd_byte((byte *)&creature_ptr->ambush_flag); /* Size of the wilderness */ rd_s32b(&wild_x_size); @@ -3759,8 +3758,8 @@ static errr rd_savefile_new_aux(void) if (arg_fiddle) note(_("伝説のアイテムをロードしました", "Loaded Artifacts")); /* Read the extra stuff */ - rd_extra(); - if (p_ptr->energy_need < -999) p_ptr->timewalk = TRUE; + rd_extra(creature_ptr); + if (creature_ptr->energy_need < -999) creature_ptr->timewalk = TRUE; if (arg_fiddle) note(_("特別情報をロードしました", "Loaded extra information")); @@ -3779,81 +3778,79 @@ static errr rd_savefile_new_aux(void) for (i = 0; i < tmp16u; i++) { rd_s16b(&tmp16s); - p_ptr->player_hp[i] = (HIT_POINT)tmp16s; + creature_ptr->player_hp[i] = (HIT_POINT)tmp16s; } /* Important -- Initialize the sex */ - sp_ptr = &sex_info[p_ptr->psex]; + sp_ptr = &sex_info[creature_ptr->psex]; /* Important -- Initialize the race/class */ - rp_ptr = &race_info[p_ptr->prace]; - cp_ptr = &class_info[p_ptr->pclass]; - ap_ptr = &seikaku_info[p_ptr->pseikaku]; + rp_ptr = &race_info[creature_ptr->prace]; + cp_ptr = &class_info[creature_ptr->pclass]; + ap_ptr = &seikaku_info[creature_ptr->pseikaku]; - if(z_older_than(10, 2, 2) && (p_ptr->pclass == CLASS_BEASTMASTER) && !p_ptr->is_dead) + if(z_older_than(10, 2, 2) && (creature_ptr->pclass == CLASS_BEASTMASTER) && !creature_ptr->is_dead) { - p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp; - roll_hitdice(p_ptr, 0L); + creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp; + roll_hitdice(creature_ptr, 0L); } - if(z_older_than(10, 3, 2) && (p_ptr->pclass == CLASS_ARCHER) && !p_ptr->is_dead) + if(z_older_than(10, 3, 2) && (creature_ptr->pclass == CLASS_ARCHER) && !creature_ptr->is_dead) { - p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp; - roll_hitdice(p_ptr, 0L); + creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp; + roll_hitdice(creature_ptr, 0L); } - if(z_older_than(10, 2, 6) && (p_ptr->pclass == CLASS_SORCERER) && !p_ptr->is_dead) + if(z_older_than(10, 2, 6) && (creature_ptr->pclass == CLASS_SORCERER) && !creature_ptr->is_dead) { - p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp; - roll_hitdice(p_ptr, 0L); + creature_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp; + roll_hitdice(creature_ptr, 0L); } - if(z_older_than(10, 4, 7) && (p_ptr->pclass == CLASS_BLUE_MAGE) && !p_ptr->is_dead) + if(z_older_than(10, 4, 7) && (creature_ptr->pclass == CLASS_BLUE_MAGE) && !creature_ptr->is_dead) { - p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp; - roll_hitdice(p_ptr, 0L); + creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp; + roll_hitdice(creature_ptr, 0L); } /* Important -- Initialize the magic */ - mp_ptr = &m_info[p_ptr->pclass]; + mp_ptr = &m_info[creature_ptr->pclass]; /* Read spell info */ - rd_u32b(&p_ptr->spell_learned1); - rd_u32b(&p_ptr->spell_learned2); - rd_u32b(&p_ptr->spell_worked1); - rd_u32b(&p_ptr->spell_worked2); - rd_u32b(&p_ptr->spell_forgotten1); - rd_u32b(&p_ptr->spell_forgotten2); + rd_u32b(&creature_ptr->spell_learned1); + rd_u32b(&creature_ptr->spell_learned2); + rd_u32b(&creature_ptr->spell_worked1); + rd_u32b(&creature_ptr->spell_worked2); + rd_u32b(&creature_ptr->spell_forgotten1); + rd_u32b(&creature_ptr->spell_forgotten2); if (z_older_than(10,0,5)) { - p_ptr->learned_spells = 0; + creature_ptr->learned_spells = 0; for (i = 0; i < 64; i++) { /* Count known spells */ if ((i < 32) ? - (p_ptr->spell_learned1 & (1L << i)) : - (p_ptr->spell_learned2 & (1L << (i - 32)))) + (creature_ptr->spell_learned1 & (1L << i)) : + (creature_ptr->spell_learned2 & (1L << (i - 32)))) { - p_ptr->learned_spells++; + creature_ptr->learned_spells++; } } } - else rd_s16b(&p_ptr->learned_spells); + else rd_s16b(&creature_ptr->learned_spells); if (z_older_than(10,0,6)) { - p_ptr->add_spells = 0; + creature_ptr->add_spells = 0; } - else rd_s16b(&p_ptr->add_spells); - if (p_ptr->pclass == CLASS_MINDCRAFTER) p_ptr->add_spells = 0; + else rd_s16b(&creature_ptr->add_spells); + if (creature_ptr->pclass == CLASS_MINDCRAFTER) creature_ptr->add_spells = 0; for (i = 0; i < 64; i++) { rd_byte(&tmp8u); - p_ptr->spell_order[i] = (SPELL_IDX)tmp8u; + creature_ptr->spell_order[i] = (SPELL_IDX)tmp8u; } - - /* Read the inventory */ if (rd_inventory()) { note(_("持ち物情報を読み込むことができません", "Unable to read inventory")); @@ -3874,45 +3871,45 @@ static errr rd_savefile_new_aux(void) } } - rd_s16b(&p_ptr->pet_follow_distance); + rd_s16b(&creature_ptr->pet_follow_distance); if (z_older_than(10, 4, 10)) { - p_ptr->pet_extra_flags = 0; + creature_ptr->pet_extra_flags = 0; rd_byte(&tmp8u); - if (tmp8u) p_ptr->pet_extra_flags |= PF_OPEN_DOORS; + if (tmp8u) creature_ptr->pet_extra_flags |= PF_OPEN_DOORS; rd_byte(&tmp8u); - if (tmp8u) p_ptr->pet_extra_flags |= PF_PICKUP_ITEMS; + if (tmp8u) creature_ptr->pet_extra_flags |= PF_PICKUP_ITEMS; - if (z_older_than(10,0,4)) p_ptr->pet_extra_flags |= PF_TELEPORT; + if (z_older_than(10,0,4)) creature_ptr->pet_extra_flags |= PF_TELEPORT; else { rd_byte(&tmp8u); - if (tmp8u) p_ptr->pet_extra_flags |= PF_TELEPORT; + if (tmp8u) creature_ptr->pet_extra_flags |= PF_TELEPORT; } - if (z_older_than(10,0,7)) p_ptr->pet_extra_flags |= PF_ATTACK_SPELL; + if (z_older_than(10,0,7)) creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL; else { rd_byte(&tmp8u); - if (tmp8u) p_ptr->pet_extra_flags |= PF_ATTACK_SPELL; + if (tmp8u) creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL; } - if (z_older_than(10,0,8)) p_ptr->pet_extra_flags |= PF_SUMMON_SPELL; + if (z_older_than(10,0,8)) creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL; else { rd_byte(&tmp8u); - if (tmp8u) p_ptr->pet_extra_flags |= PF_SUMMON_SPELL; + if (tmp8u) creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL; } if (!z_older_than(10,0,8)) { rd_byte(&tmp8u); - if (tmp8u) p_ptr->pet_extra_flags |= PF_BALL_SPELL; + if (tmp8u) creature_ptr->pet_extra_flags |= PF_BALL_SPELL; } } else { - rd_s16b(&p_ptr->pet_extra_flags); + rd_s16b(&creature_ptr->pet_extra_flags); } if (!z_older_than(11, 0, 9)) @@ -3922,7 +3919,7 @@ static errr rd_savefile_new_aux(void) if (buf[0]) screen_dump = string_make(buf); } - if (p_ptr->is_dead) + if (creature_ptr->is_dead) { for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++) { @@ -3932,12 +3929,12 @@ static errr rd_savefile_new_aux(void) /* I'm not dead yet... */ - if (!p_ptr->is_dead) + if (!creature_ptr->is_dead) { /* Dead players have no dungeon */ note(_("ダンジョン復元中...", "Restoring Dungeon...")); - if (rd_dungeon()) + if (rd_dungeon(creature_ptr)) { note(_("ダンジョンデータ読み込み失敗", "Error reading dungeon data")); return (34); @@ -3957,11 +3954,11 @@ static errr rd_savefile_new_aux(void) /* Quest 18 was removed */ if (h_older_than(1, 7, 0, 6)) { - if (p_ptr->inside_quest == OLD_QUEST_WATER_CAVE) + if (creature_ptr->current_floor_ptr->inside_quest == OLD_QUEST_WATER_CAVE) { - p_ptr->dungeon_idx = lite_town ? DUNGEON_ANGBAND : DUNGEON_GALGALS; - current_floor_ptr->dun_level = 1; - p_ptr->inside_quest = 0; + creature_ptr->dungeon_idx = lite_town ? DUNGEON_ANGBAND : DUNGEON_GALGALS; + creature_ptr->current_floor_ptr->dun_level = 1; + creature_ptr->current_floor_ptr->inside_quest = 0; } } @@ -4018,12 +4015,10 @@ errr rd_savefile_new(void) /* Drop permissions */ safe_setuid_drop(); - - /* Paranoia */ if (!fff) return (-1); /* Call the sub-function */ - err = rd_savefile_new_aux(); + err = rd_savefile_new_aux(p_ptr); /* Check for errors */ if (ferror(fff)) err = -1; @@ -4034,10 +4029,11 @@ errr rd_savefile_new(void) /*! * @brief 保存フロア読み込みのサブ関数 / Actually load and verify a floor save data + * @param player_ptr プレーヤーへの参照ポインタ * @param sf_ptr 保存フロア読み込み先 * @return 成功したらtrue */ -static bool load_floor_aux(saved_floor_type *sf_ptr) +static bool load_floor_aux(player_type *player_ptr, saved_floor_type *sf_ptr) { byte tmp8u; u32b tmp32u; @@ -4056,18 +4052,18 @@ static bool load_floor_aux(saved_floor_type *sf_ptr) x_check = 0L; /* Set the version number to current version */ - /* Never load old temporal files */ - h_ver_extra = H_VER_EXTRA; - h_ver_patch = H_VER_PATCH; - h_ver_minor = H_VER_MINOR; - h_ver_major = H_VER_MAJOR; + /* Never load old temporary files */ + current_world_ptr->h_ver_extra = H_VER_EXTRA; + current_world_ptr->h_ver_patch = H_VER_PATCH; + current_world_ptr->h_ver_minor = H_VER_MINOR; + current_world_ptr->h_ver_major = H_VER_MAJOR; /* Verify the sign */ rd_u32b(&tmp32u); if (saved_floor_file_sign != tmp32u) return FALSE; /* Read -- have error? */ - if (rd_saved_floor(sf_ptr)) return FALSE; + if (rd_saved_floor(player_ptr, sf_ptr)) return FALSE; #ifdef VERIFY_CHECKSUMS @@ -4096,12 +4092,13 @@ static bool load_floor_aux(saved_floor_type *sf_ptr) /*! - * @brief 一時保存フロア情報を読み込む / Attempt to load the temporally saved-floor data + * @brief 一時保存フロア情報を読み込む / Attempt to load the temporarily saved-floor data + * @param player_ptr プレーヤーへの参照ポインタ * @param sf_ptr 保存フロア読み込み先 * @param mode オプション * @return 成功したらtrue */ -bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode) +bool load_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mode) { FILE *old_fff = NULL; byte old_xor_byte = 0; @@ -4118,7 +4115,7 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode) byte old_kanji_code = kanji_code; /* - * Temporal files are always written in system depended kanji + * Temporary files are always written in system depended kanji * code. */ #ifdef JP @@ -4144,10 +4141,10 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode) old_xor_byte = xor_byte; old_v_check = v_check; old_x_check = x_check; - old_h_ver_major = h_ver_major; - old_h_ver_minor = h_ver_minor; - old_h_ver_patch = h_ver_patch; - old_h_ver_extra = h_ver_extra; + old_h_ver_major = current_world_ptr->h_ver_major; + old_h_ver_minor = current_world_ptr->h_ver_minor; + old_h_ver_patch = current_world_ptr->h_ver_patch; + old_h_ver_extra = current_world_ptr->h_ver_extra; } /* floor savefile */ @@ -4169,7 +4166,7 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode) if (ok) { /* Load saved floor data from file */ - ok = load_floor_aux(sf_ptr); + ok = load_floor_aux(player_ptr, sf_ptr); /* Check for errors */ if (ferror(fff)) ok = FALSE; @@ -4193,10 +4190,10 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode) xor_byte = old_xor_byte; v_check = old_v_check; x_check = old_x_check; - h_ver_major = old_h_ver_major; - h_ver_minor = old_h_ver_minor; - h_ver_patch = old_h_ver_patch; - h_ver_extra = old_h_ver_extra; + current_world_ptr->h_ver_major = old_h_ver_major; + current_world_ptr->h_ver_minor = old_h_ver_minor; + current_world_ptr->h_ver_patch = old_h_ver_patch; + current_world_ptr->h_ver_extra = old_h_ver_extra; } /* Restore old knowledge */