Skip to content

Commit

Permalink
Allow randomizing starting hour through options (#63623)
Browse files Browse the repository at this point in the history
* Allow randomizing starting hour through options

* Remove 'override?' bool variable

* Update option description

* One space for cland tidy
  • Loading branch information
Kromgart authored Mar 2, 2023
1 parent 2eeffcb commit 47b5cdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ),
Expand Down
6 changes: 4 additions & 2 deletions src/scenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,11 @@ time_point scenario::start_of_game() const
{
time_point ret;

const int options_start_hour = get_option<int>( "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<int>( "SEASON_LENGTH" ) * start_season()
+ calendar::year_length() * ( start_year() - 1 );
Expand All @@ -560,7 +562,7 @@ time_point scenario::start_of_game() const
}
} else {
ret = start_of_cataclysm()
+ 1_hours * get_option<int>( "INITIAL_TIME" )
+ 1_hours * ( options_start_hour == -1 ? rng( 0, 23 ) : options_start_hour )
+ 1_days * get_option<int>( "SPAWN_DELAY" );
}
return ret;
Expand Down

0 comments on commit 47b5cdb

Please sign in to comment.