X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fload.c;h=ac6d9b0ab706b4c3b8370d332f48022a68bd2b04;hb=f0235f7ff522d1afbb51ecbf737325249757ac8f;hp=27ce1bd9d5a1d801f1fe57b5c7340dc6304ca467;hpb=a3d7bcc218eac8433e5af981c7f4d1a15cdecb23;p=hengband%2Fhengband.git diff --git a/src/load.c b/src/load.c index 27ce1bd9d..ac6d9b0ab 100644 --- a/src/load.c +++ b/src/load.c @@ -130,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 (current_world_ptr->h_ver_major < major) return (TRUE); - if (current_world_ptr->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 (current_world_ptr->h_ver_minor < minor) return (TRUE); - if (current_world_ptr->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 (current_world_ptr->h_ver_patch < patch) return (TRUE); - if (current_world_ptr->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 (current_world_ptr->h_ver_extra < extra) return (TRUE); - if (current_world_ptr->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; } @@ -160,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 (current_world_ptr->z_major < x) return (TRUE); - if (current_world_ptr->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 (current_world_ptr->z_minor < y) return (TRUE); - if (current_world_ptr->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 (current_world_ptr->z_patch < z) return (TRUE); - if (current_world_ptr->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; } @@ -1918,7 +1918,7 @@ static void rd_extra(player_type *creature_ptr) { 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; @@ -1926,7 +1926,7 @@ static void rd_extra(player_type *creature_ptr) } else { - for (i = 0; i < MAX_KUBI; i++) + for (i = 0; i < MAX_BOUNTY; i++) { rd_s16b(¤t_world_ptr->bounty_r_idx[i]); } @@ -1934,7 +1934,7 @@ static void rd_extra(player_type *creature_ptr) if (z_older_than(10, 0, 3)) { - update_gambling_monsters(); + update_gambling_monsters(creature_ptr); } else { @@ -2261,8 +2261,8 @@ static void rd_extra(player_type *creature_ptr) /* Special stuff */ rd_u16b(&creature_ptr->panic_save); - rd_u16b(&creature_ptr->total_winner); - rd_u16b(&creature_ptr->noscore); + rd_u16b(¤t_world_ptr->total_winner); + rd_u16b(¤t_world_ptr->noscore); /* Read "death" */ @@ -2324,7 +2324,7 @@ static void rd_extra(player_type *creature_ptr) if (z_older_than(10,0,3)) { - determine_today_mon(TRUE); + determine_daily_bounty(creature_ptr, TRUE); } else { @@ -2429,7 +2429,7 @@ static errr rd_inventory(void) C_MAKE(p_ptr->inventory_list, INVEN_TOTAL, object_type); /* Read until done */ - while (1) + while (TRUE) { u16b n; @@ -2560,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; @@ -2580,31 +2581,32 @@ static errr rd_dungeon_old(void) /* Header info */ rd_s16b(&tmp16s); - p_ptr->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 */ - p_ptr->current_floor_ptr->base_level = p_ptr->current_floor_ptr->dun_level; + floor_ptr->base_level = floor_ptr->dun_level; rd_s16b(&tmp16s); - p_ptr->current_floor_ptr->base_level = (DEPTH)tmp16s; + floor_ptr->base_level = (DEPTH)tmp16s; rd_s16b(&tmp16s); - p_ptr->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) && !p_ptr->current_floor_ptr->dun_level && !p_ptr->current_floor_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); - p_ptr->current_floor_ptr->height = (POSITION)tmp16s; + floor_ptr->height = (POSITION)tmp16s; rd_s16b(&tmp16s); - p_ptr->current_floor_ptr->width = (POSITION)tmp16s; + floor_ptr->width = (POSITION)tmp16s; rd_s16b(&tmp16s); /* max_panel_rows */ rd_s16b(&tmp16s); /* max_panel_cols */ @@ -2613,8 +2615,8 @@ static errr rd_dungeon_old(void) #endif /* Maximal size */ - ymax = p_ptr->current_floor_ptr->height; - xmax = p_ptr->current_floor_ptr->width; + ymax = floor_ptr->height; + xmax = floor_ptr->width; /*** Run length decoding ***/ @@ -2642,7 +2644,7 @@ static errr rd_dungeon_old(void) /* Apply the RLE info */ for (i = count; i > 0; i--) { - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Extract "info" */ g_ptr->info = info; @@ -2672,7 +2674,7 @@ static errr rd_dungeon_old(void) /* Apply the RLE info */ for (i = count; i > 0; i--) { - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Extract "feat" */ g_ptr->feat = (s16b)tmp8u; @@ -2701,7 +2703,7 @@ static errr rd_dungeon_old(void) /* Apply the RLE info */ for (i = count; i > 0; i--) { - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Extract "mimic" */ g_ptr->mimic = (s16b)tmp8u; @@ -2730,7 +2732,7 @@ static errr rd_dungeon_old(void) /* Apply the RLE info */ for (i = count; i > 0; i--) { - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Extract "feat" */ g_ptr->special = tmp16s; @@ -2752,7 +2754,7 @@ static errr rd_dungeon_old(void) for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++) { /* Wipe old unused flags */ - p_ptr->current_floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK); + floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK); } } @@ -2760,7 +2762,7 @@ static errr rd_dungeon_old(void) { for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++) { - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; /* Very old */ if (g_ptr->feat == OLD_FEAT_INVIS) @@ -2782,7 +2784,7 @@ static errr rd_dungeon_old(void) { for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++) { - g_ptr = &p_ptr->current_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) @@ -2804,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 */ @@ -2821,9 +2823,9 @@ static errr rd_dungeon_old(void) { for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++) { - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + g_ptr = &floor_ptr->grid_array[y][x]; - if ((g_ptr->special == OLD_QUEST_WATER_CAVE) && !p_ptr->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) { @@ -2836,7 +2838,7 @@ static errr rd_dungeon_old(void) } } else if ((g_ptr->feat == OLD_FEAT_QUEST_EXIT) && - (p_ptr->current_floor_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; @@ -2865,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) { @@ -2875,7 +2877,7 @@ static errr rd_dungeon_old(void) /* Acquire place */ - o_ptr = &p_ptr->current_floor_ptr->o_list[o_idx]; + o_ptr = &floor_ptr->o_list[o_idx]; /* Read the item */ rd_item(o_ptr); @@ -2884,7 +2886,7 @@ static errr rd_dungeon_old(void) if (OBJECT_IS_HELD_MONSTER(o_ptr)) { monster_type *m_ptr; - m_ptr = &p_ptr->current_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; @@ -2896,7 +2898,7 @@ static errr rd_dungeon_old(void) else { /* Access the item location */ - g_ptr = &p_ptr->current_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; @@ -2933,14 +2935,14 @@ static errr rd_dungeon_old(void) return (162); } - m_ptr = &p_ptr->current_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 = &p_ptr->current_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; @@ -2952,7 +2954,7 @@ static errr rd_dungeon_old(void) /*** Success ***/ /* The dungeon is ready */ - if (z_older_than(10, 3, 13) && !p_ptr->current_floor_ptr->dun_level && !p_ptr->current_floor_ptr->inside_arena) + if (z_older_than(10, 3, 13) && !floor_ptr->dun_level && !floor_ptr->inside_arena) current_world_ptr->character_dungeon = FALSE; else current_world_ptr->character_dungeon = TRUE; @@ -2964,6 +2966,8 @@ static errr rd_dungeon_old(void) /*! * @brief 保存されたフロアを読み込む / Read the saved floor + * @param player_ptr プレーヤーへの参照ポインタ + * @param sf_ptr 最後に保存されたフロアへの参照ポインタ * @return info読み込みエラーコード * @details * この関数は、セーブデータの互換性を保つために多くのデータ改変処理を備えている。 @@ -2975,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; @@ -2989,11 +2993,11 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) u16b limit; grid_template_type *templates; - - clear_cave(p_ptr->current_floor_ptr); + floor_type *floor_ptr = player_ptr->current_floor_ptr; + clear_cave(player_ptr); /* Mega-Hack -- no player yet */ - p_ptr->x = p_ptr->y = 0; + player_ptr->x = player_ptr->y = 0; /*** Basic info ***/ @@ -3004,8 +3008,8 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) /*** Not a saved floor ***/ rd_s16b(&tmp16s); - p_ptr->current_floor_ptr->dun_level = (DEPTH)tmp16s; - p_ptr->current_floor_ptr->base_level = p_ptr->current_floor_ptr->dun_level; + floor_ptr->dun_level = (DEPTH)tmp16s; + floor_ptr->base_level = floor_ptr->dun_level; } else { @@ -3019,7 +3023,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) rd_s16b(&tmp16s); if (tmp16s != sf_ptr->dun_level) return 171; - p_ptr->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; @@ -3035,22 +3039,22 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) } rd_s16b(&tmp16s); - p_ptr->current_floor_ptr->base_level = (DEPTH)tmp16s; + floor_ptr->base_level = (DEPTH)tmp16s; rd_s16b(&tmp16s); - p_ptr->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); - p_ptr->current_floor_ptr->height = (POSITION)tmp16s; + floor_ptr->height = (POSITION)tmp16s; rd_s16b(&tmp16s); - p_ptr->current_floor_ptr->width = (POSITION)tmp16s; + floor_ptr->width = (POSITION)tmp16s; - rd_byte(&p_ptr->feeling); + rd_byte(&player_ptr->feeling); @@ -3086,8 +3090,8 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) } /* Maximal size */ - ymax = p_ptr->current_floor_ptr->height; - xmax = p_ptr->current_floor_ptr->width; + ymax = floor_ptr->height; + xmax = floor_ptr->width; /*** Run length decoding ***/ @@ -3110,7 +3114,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) /* Apply the RLE info */ for (i = count; i > 0; i--) { - grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + 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; @@ -3133,9 +3137,9 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) { for (y = 0; y < ymax; y++) for (x = 0; x < xmax; x++) { - grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + grid_type *g_ptr = &floor_ptr->grid_array[y][x]; - if ((g_ptr->special == OLD_QUEST_WATER_CAVE) && !p_ptr->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) { @@ -3148,7 +3152,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) } } else if ((g_ptr->feat == OLD_FEAT_QUEST_EXIT) && - (p_ptr->current_floor_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; @@ -3177,12 +3181,12 @@ 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 = &p_ptr->current_floor_ptr->o_list[o_idx]; + o_ptr = &floor_ptr->o_list[o_idx]; /* Read the item */ rd_item(o_ptr); @@ -3190,7 +3194,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) if (OBJECT_IS_HELD_MONSTER(o_ptr)) { monster_type *m_ptr; - m_ptr = &p_ptr->current_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; @@ -3202,7 +3206,7 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) else { /* Access the item location */ - grid_type *g_ptr = &p_ptr->current_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; @@ -3232,14 +3236,14 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr) if (i != m_idx) return 162; - m_ptr = &p_ptr->current_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 = &p_ptr->current_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; @@ -3255,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; @@ -3268,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 = p_ptr->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; @@ -3294,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); @@ -3303,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 ***/ @@ -3329,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]; @@ -3342,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; } } @@ -3386,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: @@ -3406,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; @@ -3546,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->current_floor_ptr->inside_quest; + s16b old_inside_quest = creature_ptr->current_floor_ptr->inside_quest; /* Number of towns */ rd_u16b(&max_towns_load); @@ -3642,10 +3647,10 @@ static errr rd_savefile_new_aux(void) else { init_flags = INIT_ASSIGN; - p_ptr->current_floor_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->current_floor_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 @@ -3683,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)) p_ptr->ambush_flag = FALSE; - else rd_byte((byte *)&p_ptr->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); @@ -3753,8 +3758,8 @@ static errr rd_savefile_new_aux(void) if (arg_fiddle) note(_("伝説のアイテムをロードしました", "Loaded Artifacts")); /* Read the extra stuff */ - rd_extra(p_ptr); - 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")); @@ -3773,77 +3778,77 @@ 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; } if (rd_inventory()) @@ -3866,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)) @@ -3914,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++) { @@ -3924,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); @@ -3949,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->current_floor_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; - p_ptr->current_floor_ptr->dun_level = 1; - p_ptr->current_floor_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; } } @@ -4013,7 +4018,7 @@ errr rd_savefile_new(void) 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; @@ -4024,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; @@ -4046,7 +4052,7 @@ 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 */ + /* 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; @@ -4057,7 +4063,7 @@ static bool load_floor_aux(saved_floor_type *sf_ptr) 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 @@ -4086,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; @@ -4108,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 @@ -4159,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;