From bc13ca605bb1c16124974b15ccbd52ad41c3a6c6 Mon Sep 17 00:00:00 2001 From: deskull Date: Mon, 16 Sep 2019 12:46:46 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20leave=5Ffloor()=20?= =?utf8?q?=E3=81=AB=20player=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92?= =?utf8?q?=E8=BF=BD=E5=8A=A0=EF=BC=8E=20/=20Add=20player=5Ftype=20*=20argu?= =?utf8?q?ment=20to=20leave=5Ffloor().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/core.c | 4 ++-- src/floor-save.c | 38 +++++++++++++++++++------------------- src/floor-save.h | 4 ++-- src/player-status.c | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/core.c b/src/core.c index 476f45faa..8d51ab06a 100644 --- a/src/core.c +++ b/src/core.c @@ -5146,7 +5146,7 @@ static void dungeon(bool load_game) * Maintain Unique monsters and artifact, save current * floor, then prepare next floor */ - leave_floor(p_ptr->change_floor_mode); + leave_floor(p_ptr, p_ptr->change_floor_mode); /* Forget the flag */ reinit_wilderness = FALSE; @@ -5656,7 +5656,7 @@ void play_game(bool new_game) prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_RAND_CONNECT); /* prepare next floor */ - leave_floor(p_ptr->change_floor_mode); + leave_floor(p_ptr, p_ptr->change_floor_mode); } else { diff --git a/src/floor-save.c b/src/floor-save.c index a439fed56..535422dc7 100644 --- a/src/floor-save.c +++ b/src/floor-save.c @@ -858,7 +858,7 @@ static void locate_connected_stairs(saved_floor_type *sf_ptr, BIT_FLAGS floor_mo * / Maintain quest monsters, mark next floor_id at stairs, save current floor, and prepare to enter next floor. * @return なし */ -void leave_floor(BIT_FLAGS floor_mode) +void leave_floor(player_type *creature_ptr, BIT_FLAGS floor_mode) { grid_type *g_ptr = NULL; feature_type *f_ptr; @@ -872,18 +872,18 @@ void leave_floor(BIT_FLAGS floor_mode) /* Remove all mirrors without explosion */ remove_all_mirrors(FALSE); - if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(p_ptr, FALSE); + if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE); /* New floor is not yet prepared */ new_floor_id = 0; /* Temporary get a floor_id (for Arena) */ - if (!p_ptr->floor_id && + if (!creature_ptr->floor_id && (floor_mode & CFM_SAVE_FLOORS) && !(floor_mode & CFM_NO_RETURN)) { /* Get temporal floor_id */ - p_ptr->floor_id = get_new_floor_id(); + creature_ptr->floor_id = get_new_floor_id(); } /* Search the quest monster index */ @@ -893,7 +893,7 @@ void leave_floor(BIT_FLAGS floor_mode) ((quest[i].type == QUEST_TYPE_KILL_LEVEL) || (quest[i].type == QUEST_TYPE_RANDOM)) && (quest[i].level == current_floor_ptr->dun_level) && - (p_ptr->dungeon_idx == quest[i].dungeon) && + (creature_ptr->dungeon_idx == quest[i].dungeon) && !(quest[i].flags & QUEST_FLAG_PRESET)) { quest_r_idx = quest[i].r_idx; @@ -925,7 +925,7 @@ void leave_floor(BIT_FLAGS floor_mode) /* Check if there is a same item */ for (i = 0; i < INVEN_PACK; i++) { - object_type *o_ptr = &p_ptr->inventory_list[i]; + object_type *o_ptr = &creature_ptr->inventory_list[i]; if (!OBJECT_IS_VALID(o_ptr)) continue; @@ -937,10 +937,10 @@ void leave_floor(BIT_FLAGS floor_mode) } /* Extract current floor info or NULL */ - sf_ptr = get_sf_ptr(p_ptr->floor_id); + sf_ptr = get_sf_ptr(creature_ptr->floor_id); /* Choose random stairs */ - if ((floor_mode & CFM_RAND_CONNECT) && p_ptr->floor_id) + if ((floor_mode & CFM_RAND_CONNECT) && creature_ptr->floor_id) { locate_connected_stairs(sf_ptr, floor_mode); } @@ -949,7 +949,7 @@ void leave_floor(BIT_FLAGS floor_mode) if (floor_mode & CFM_SAVE_FLOORS) { /* Extract stair position */ - g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x]; + g_ptr = ¤t_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x]; f_ptr = &f_info[g_ptr->feat]; /* Get back to old saved floor? */ @@ -983,11 +983,11 @@ void leave_floor(BIT_FLAGS floor_mode) if (floor_mode & CFM_DOWN) { if (!current_floor_ptr->dun_level) - move_num = d_info[p_ptr->dungeon_idx].mindepth; + move_num = d_info[creature_ptr->dungeon_idx].mindepth; } else if (floor_mode & CFM_UP) { - if (current_floor_ptr->dun_level + move_num < d_info[p_ptr->dungeon_idx].mindepth) + if (current_floor_ptr->dun_level + move_num < d_info[creature_ptr->dungeon_idx].mindepth) move_num = -current_floor_ptr->dun_level; } @@ -995,16 +995,16 @@ void leave_floor(BIT_FLAGS floor_mode) } /* Leaving the dungeon to town */ - if (!current_floor_ptr->dun_level && p_ptr->dungeon_idx) + if (!current_floor_ptr->dun_level && creature_ptr->dungeon_idx) { - p_ptr->leaving_dungeon = TRUE; + creature_ptr->leaving_dungeon = TRUE; if (!vanilla_town && !lite_town) { - p_ptr->wilderness_y = d_info[p_ptr->dungeon_idx].dy; - p_ptr->wilderness_x = d_info[p_ptr->dungeon_idx].dx; + creature_ptr->wilderness_y = d_info[creature_ptr->dungeon_idx].dy; + creature_ptr->wilderness_x = d_info[creature_ptr->dungeon_idx].dx; } - p_ptr->recall_dungeon = p_ptr->dungeon_idx; - p_ptr->dungeon_idx = 0; + creature_ptr->recall_dungeon = creature_ptr->dungeon_idx; + creature_ptr->dungeon_idx = 0; /* Reach to the surface -- Clear all saved floors */ floor_mode &= ~CFM_SAVE_FLOORS; @@ -1027,7 +1027,7 @@ void leave_floor(BIT_FLAGS floor_mode) } /* No current floor -- Left/Enter dungeon etc... */ - if (!p_ptr->floor_id) + if (!creature_ptr->floor_id) { /* No longer need to save current floor */ return; @@ -1077,7 +1077,7 @@ void leave_floor(BIT_FLAGS floor_mode) prepare_change_floor_mode(CFM_NO_RETURN); /* Kill current floor */ - kill_saved_floor(get_sf_ptr(p_ptr->floor_id)); + kill_saved_floor(get_sf_ptr(creature_ptr->floor_id)); } } } diff --git a/src/floor-save.h b/src/floor-save.h index 434769586..53be74dee 100644 --- a/src/floor-save.h +++ b/src/floor-save.h @@ -20,7 +20,7 @@ extern u32b saved_floor_file_sign; extern void init_saved_floors(bool force); extern void change_floor(BIT_FLAGS floor_mode); -extern void leave_floor(BIT_FLAGS floor_mode); +extern void leave_floor(player_type *creature_ptr, BIT_FLAGS floor_mode); extern void clear_saved_floor_files(void); extern saved_floor_type *get_sf_ptr(FLOOR_IDX floor_id); extern FLOOR_IDX get_new_floor_id(void); @@ -41,4 +41,4 @@ extern FLOOR_IDX get_new_floor_id(void); extern void prepare_change_floor_mode(BIT_FLAGS mode); extern void precalc_cur_num_of_pet(void); -extern FLOOR_IDX max_floor_id; \ No newline at end of file +extern FLOOR_IDX max_floor_id; diff --git a/src/player-status.c b/src/player-status.c index e815d3219..a7d7fe6d5 100644 --- a/src/player-status.c +++ b/src/player-status.c @@ -5883,7 +5883,7 @@ void cheat_death(player_type *creature_ptr) " but revived.")); /* Prepare next floor */ - leave_floor(creature_ptr->change_floor_mode); + leave_floor(creature_ptr, creature_ptr->change_floor_mode); wipe_m_list(); } -- 2.11.0