From fdb695f80b8707f243081f83f7a51578ab95c07c Mon Sep 17 00:00:00 2001 From: Hourier Date: Tue, 21 Apr 2020 22:44:28 +0900 Subject: [PATCH] [Refactor] #40236 Separated pass_game_turn_by_stay() from inn_comm() --- src/cmd/cmd-inn.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/cmd/cmd-inn.c b/src/cmd/cmd-inn.c index fbf0cbc1e..26e87c39a 100644 --- a/src/cmd/cmd-inn.c +++ b/src/cmd/cmd-inn.c @@ -46,6 +46,7 @@ static bool is_healthy_stay(player_type *customer_ptr) * @brief 宿屋に泊まったことを日記に残す * @param customer_ptr プレーヤーへの参照ポインタ * @param prev_hour 宿屋に入った直後の時刻の時刻 + * @return なし */ static void stay_inn(player_type *customer_ptr, int prev_hour) { @@ -66,6 +67,26 @@ static void stay_inn(player_type *customer_ptr, int prev_hour) /*! + * @brief 宿泊によってゲーム内ターンを経過させる + * @param なし + * @return なし + */ +static void pass_game_turn_by_stay(void) +{ + s32b oldturn = current_world_ptr->game_turn; + current_world_ptr->game_turn = + (current_world_ptr->game_turn / (TURNS_PER_TICK * TOWN_DAWN / 2) + 1) * + (TURNS_PER_TICK * TOWN_DAWN / 2); + if (current_world_ptr->dungeon_turn >= current_world_ptr->dungeon_turn_limit) + return; + + current_world_ptr->dungeon_turn += MIN((current_world_ptr->game_turn - oldturn), TURNS_PER_TICK * 250) * INN_DUNGEON_TURN_ADJ; + if (current_world_ptr->dungeon_turn > current_world_ptr->dungeon_turn_limit) + current_world_ptr->dungeon_turn = current_world_ptr->dungeon_turn_limit; +} + + +/*! * @brief 宿屋を利用する * @param customer_ptr プレーヤーへの参照ポインタ * @param cmd 宿屋の利用施設ID @@ -88,21 +109,16 @@ bool inn_comm(player_type *customer_ptr, int cmd) { if (!is_healthy_stay(customer_ptr)) return FALSE; - s32b oldturn = current_world_ptr->game_turn; int prev_day, prev_hour, prev_min; extract_day_hour_min(customer_ptr, &prev_day, &prev_hour, &prev_min); stay_inn(customer_ptr, prev_hour); - current_world_ptr->game_turn = (current_world_ptr->game_turn / (TURNS_PER_TICK * TOWN_DAWN / 2) + 1) * (TURNS_PER_TICK * TOWN_DAWN / 2); - if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit) - { - current_world_ptr->dungeon_turn += MIN((current_world_ptr->game_turn - oldturn), TURNS_PER_TICK * 250) * INN_DUNGEON_TURN_ADJ; - if (current_world_ptr->dungeon_turn > current_world_ptr->dungeon_turn_limit) current_world_ptr->dungeon_turn = current_world_ptr->dungeon_turn_limit; - } - + pass_game_turn_by_stay(); prevent_turn_overflow(customer_ptr); - if ((prev_hour >= 18) && (prev_hour <= 23)) exe_write_diary(customer_ptr, DIARY_DIALY, 0, NULL); + if ((prev_hour >= 18) && (prev_hour <= 23)) + exe_write_diary(customer_ptr, DIARY_DIALY, 0, NULL); + customer_ptr->chp = customer_ptr->mhp; if (ironman_nightmare) -- 2.11.0