From 47b5cdb43a60fd596bfdc4d1eef328b7e1caa148 Mon Sep 17 00:00:00 2001 From: Roman Melnik Date: Thu, 2 Mar 2023 21:47:49 +0200 Subject: [PATCH] Allow randomizing starting hour through options (#63623) * Allow randomizing starting hour through options * Remove 'override?' bool variable * Update option description * One space for cland tidy --- src/options.cpp | 4 ++-- src/scenario.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/options.cpp b/src/options.cpp index a36e98f55fc8d..bd129b3a035ed 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2502,8 +2502,8 @@ void options_manager::add_options_world_default() add_empty_line(); add( "INITIAL_TIME", "world_default", to_translation( "Initial time" ), - to_translation( "Initial starting time of day on character generation." ), - 0, 23, 8 + to_translation( "Initial starting time of day on character generation. Value -1 randomizes the starting time and overrides scenario setting." ), + -1, 23, 8 ); add( "INITIAL_DAY", "world_default", to_translation( "Initial day" ), diff --git a/src/scenario.cpp b/src/scenario.cpp index 0a5489d8adcc9..937ffa685ce11 100644 --- a/src/scenario.cpp +++ b/src/scenario.cpp @@ -547,9 +547,11 @@ time_point scenario::start_of_game() const { time_point ret; + const int options_start_hour = get_option( "INITIAL_TIME" ); + if( custom_start_date() ) { ret = calendar::turn_zero - + 1_hours * start_hour() + + 1_hours * ( options_start_hour == -1 ? rng( 0, 23 ) : start_hour() ) + 1_days * start_day() + 1_days * get_option( "SEASON_LENGTH" ) * start_season() + calendar::year_length() * ( start_year() - 1 ); @@ -560,7 +562,7 @@ time_point scenario::start_of_game() const } } else { ret = start_of_cataclysm() - + 1_hours * get_option( "INITIAL_TIME" ) + + 1_hours * ( options_start_hour == -1 ? rng( 0, 23 ) : options_start_hour ) + 1_days * get_option( "SPAWN_DELAY" ); } return ret;