From 3ec3829e55f84c167505d97fc6ee318ec887242d Mon Sep 17 00:00:00 2001 From: teamhimeH Date: Sun, 24 Oct 2021 17:14:51 +0900 Subject: [PATCH 1/2] ADD: advance_to_end --- dataobj/settings.cc | 8 ++++++++ dataobj/settings.h | 6 ++++++ gui/settings_stats.cc | 4 ++++ vehicle/rail_vehicle.cc | 3 ++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/dataobj/settings.cc b/dataobj/settings.cc index b05f4569d1..896b2e9471 100644 --- a/dataobj/settings.cc +++ b/dataobj/settings.cc @@ -301,6 +301,8 @@ settings_t::settings_t() : frames_per_second = 20; frames_per_step = 4; server_frames_ahead = 4; + + advance_to_end = true; } @@ -918,6 +920,10 @@ void settings_t::rdwr(loadsave_t *file) case 3: wind_direction = ribi_t::south; break; } } + + if( file->is_version_atleast(122, 2) ) { + file->rdwr_bool(advance_to_end); + } // otherwise the default values of the last one will be used } // sometimes broken savegames could have no legal direction for take off ... @@ -1584,6 +1590,8 @@ void settings_t::parse_simuconf( tabfile_t& simuconf, sint16& disp_width, sint16 world_maximum_height = contents.get_int_clamped("world_maximum_height", world_maximum_height, 16, 127); world_minimum_height = contents.get_int_clamped("world_minimum_height", world_minimum_height, -127, -12); + advance_to_end = contents.get_int("advance_to_end", advance_to_end); + // Default pak file path objfilename = ltrim(contents.get_string("pak_file_path", objfilename.c_str() ) ); diff --git a/dataobj/settings.h b/dataobj/settings.h index 9327f2bdeb..6d20d5efea 100644 --- a/dataobj/settings.h +++ b/dataobj/settings.h @@ -314,6 +314,9 @@ class settings_t // true if companies can make ways public bool disable_make_way_public; + // only for trains. If true, trains advance to the end of the platform. + bool advance_to_end; + public: /* the big cost section */ sint32 maint_building; // normal building @@ -658,6 +661,9 @@ class settings_t bool get_departures_on_time() const { return departures_on_time; } void set_departures_on_time(bool b) { departures_on_time = b; } + + bool get_advance_to_end() const { return advance_to_end; } + void set_advance_to_end(bool b) { advance_to_end = b; } }; #endif diff --git a/gui/settings_stats.cc b/gui/settings_stats.cc index bf86403ee2..3d91c3796d 100644 --- a/gui/settings_stats.cc +++ b/gui/settings_stats.cc @@ -236,6 +236,8 @@ void settings_routing_stats_t::init(settings_t const* const sets) INIT_NUM( "way_tunnel", sets->way_count_tunnel, 1, 1000, gui_numberinput_t::AUTOLINEAR, false ); INIT_NUM( "way_max_bridge_len", sets->way_max_bridge_len, 1, 1000, gui_numberinput_t::AUTOLINEAR, false ); INIT_NUM( "way_leaving_road", sets->way_count_leaving_road, 1, 1000, gui_numberinput_t::AUTOLINEAR, false ); + SEPERATOR + INIT_BOOL( "advance_to_end", sets->get_advance_to_end() ); INIT_END } @@ -262,6 +264,8 @@ void settings_routing_stats_t::read(settings_t* const sets) READ_NUM_VALUE( sets->way_count_tunnel ); READ_NUM_VALUE( sets->way_max_bridge_len ); READ_NUM_VALUE( sets->way_count_leaving_road ); + + READ_BOOL_VALUE( sets->advance_to_end ); } diff --git a/vehicle/rail_vehicle.cc b/vehicle/rail_vehicle.cc index 2e2e535a97..372537f208 100644 --- a/vehicle/rail_vehicle.cc +++ b/vehicle/rail_vehicle.cc @@ -140,7 +140,8 @@ bool rail_vehicle_t::calc_route(koord3d start, koord3d ziel, sint32 max_speed, r cnv->set_next_reservation_index( 0 ); // nothing to reserve target_halt = halthandle_t(); // no block reserved // use length 8888 tiles to advance to the end of all stations - return route->calc_route(welt, start, ziel, this, max_speed, 8888 /*cnv->get_tile_length()*/ ); + const uint16 convoy_length = world()->get_settings().get_advance_to_end() ? 8888 : cnv->get_tile_length(); + return route->calc_route(welt, start, ziel, this, max_speed, convoy_length ); } From edfca94b6ba197ecd7e7c1ade77251c983672bb7 Mon Sep 17 00:00:00 2001 From: teamhimeH Date: Sun, 24 Oct 2021 17:51:37 +0900 Subject: [PATCH 2/2] change parameter name and invert logic --- dataobj/settings.cc | 6 +++--- dataobj/settings.h | 8 ++++---- gui/settings_stats.cc | 4 ++-- vehicle/rail_vehicle.cc | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dataobj/settings.cc b/dataobj/settings.cc index 896b2e9471..12abe392e5 100644 --- a/dataobj/settings.cc +++ b/dataobj/settings.cc @@ -302,7 +302,7 @@ settings_t::settings_t() : frames_per_step = 4; server_frames_ahead = 4; - advance_to_end = true; + stop_halt_as_scheduled = true; } @@ -922,7 +922,7 @@ void settings_t::rdwr(loadsave_t *file) } if( file->is_version_atleast(122, 2) ) { - file->rdwr_bool(advance_to_end); + file->rdwr_bool(stop_halt_as_scheduled); } // otherwise the default values of the last one will be used } @@ -1590,7 +1590,7 @@ void settings_t::parse_simuconf( tabfile_t& simuconf, sint16& disp_width, sint16 world_maximum_height = contents.get_int_clamped("world_maximum_height", world_maximum_height, 16, 127); world_minimum_height = contents.get_int_clamped("world_minimum_height", world_minimum_height, -127, -12); - advance_to_end = contents.get_int("advance_to_end", advance_to_end); + stop_halt_as_scheduled = contents.get_int("stop_halt_as_scheduled", stop_halt_as_scheduled); // Default pak file path objfilename = ltrim(contents.get_string("pak_file_path", objfilename.c_str() ) ); diff --git a/dataobj/settings.h b/dataobj/settings.h index 6d20d5efea..eca49d0bd9 100644 --- a/dataobj/settings.h +++ b/dataobj/settings.h @@ -314,8 +314,8 @@ class settings_t // true if companies can make ways public bool disable_make_way_public; - // only for trains. If true, trains advance to the end of the platform. - bool advance_to_end; + // only for trains. If true, trains stop at the position designated in the schdule.. + bool stop_halt_as_scheduled; public: /* the big cost section */ @@ -662,8 +662,8 @@ class settings_t bool get_departures_on_time() const { return departures_on_time; } void set_departures_on_time(bool b) { departures_on_time = b; } - bool get_advance_to_end() const { return advance_to_end; } - void set_advance_to_end(bool b) { advance_to_end = b; } + bool get_stop_halt_as_scheduled() const { return stop_halt_as_scheduled; } + void set_stop_halt_as_scheduled(bool b) { stop_halt_as_scheduled = b; } }; #endif diff --git a/gui/settings_stats.cc b/gui/settings_stats.cc index 3d91c3796d..b3b0a849f8 100644 --- a/gui/settings_stats.cc +++ b/gui/settings_stats.cc @@ -237,7 +237,7 @@ void settings_routing_stats_t::init(settings_t const* const sets) INIT_NUM( "way_max_bridge_len", sets->way_max_bridge_len, 1, 1000, gui_numberinput_t::AUTOLINEAR, false ); INIT_NUM( "way_leaving_road", sets->way_count_leaving_road, 1, 1000, gui_numberinput_t::AUTOLINEAR, false ); SEPERATOR - INIT_BOOL( "advance_to_end", sets->get_advance_to_end() ); + INIT_BOOL( "stop_halt_as_scheduled", sets->get_stop_halt_as_scheduled() ); INIT_END } @@ -265,7 +265,7 @@ void settings_routing_stats_t::read(settings_t* const sets) READ_NUM_VALUE( sets->way_max_bridge_len ); READ_NUM_VALUE( sets->way_count_leaving_road ); - READ_BOOL_VALUE( sets->advance_to_end ); + READ_BOOL_VALUE( sets->stop_halt_as_scheduled ); } diff --git a/vehicle/rail_vehicle.cc b/vehicle/rail_vehicle.cc index 372537f208..5555ad57f2 100644 --- a/vehicle/rail_vehicle.cc +++ b/vehicle/rail_vehicle.cc @@ -140,7 +140,7 @@ bool rail_vehicle_t::calc_route(koord3d start, koord3d ziel, sint32 max_speed, r cnv->set_next_reservation_index( 0 ); // nothing to reserve target_halt = halthandle_t(); // no block reserved // use length 8888 tiles to advance to the end of all stations - const uint16 convoy_length = world()->get_settings().get_advance_to_end() ? 8888 : cnv->get_tile_length(); + const uint16 convoy_length = world()->get_settings().get_stop_halt_as_scheduled() ? cnv->get_tile_length() : 8888; return route->calc_route(welt, start, ziel, this, max_speed, convoy_length ); }