Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions dataobj/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ settings_t::settings_t() :
allow_higher_flight = true;

use_route_cache = false;

transit_by_foot = false;
foot_path_weight = 24;
foot_path_time_ticks = 1800;
walk_cost_to_halt = false;
}


Expand Down Expand Up @@ -1055,6 +1060,20 @@ void settings_t::rdwr(loadsave_t *file)
signal_reverse_front_back = false;
roadsign_reverse_front_back = false;
}
if( file->get_OTRP_version() > 55 ) {
file->rdwr_bool(transit_by_foot);
file->rdwr_long(foot_path_weight);
file->rdwr_long(foot_path_time_ticks);
} else {
transit_by_foot = false;
foot_path_weight = 24;
foot_path_time_ticks = 1800;
}
if( file->get_OTRP_version() > 56 ) {
file->rdwr_bool(walk_cost_to_halt);
} else {
walk_cost_to_halt = false;
}
if( file->is_version_atleast(122, 1) ) {
file->rdwr_enum(climate_generator);
file->rdwr_byte( wind_direction );
Expand Down Expand Up @@ -1888,6 +1907,11 @@ void settings_t::parse_simuconf( tabfile_t& simuconf, sint16& disp_width, sint16
base_waiting_ticks_for_ship_convoi = contents.get_int("base_waiting_ticks_for_ship_convoi", base_waiting_ticks_for_ship_convoi);
base_waiting_ticks_for_air_convoi = contents.get_int("base_waiting_ticks_for_air_convoi", base_waiting_ticks_for_air_convoi);

transit_by_foot = contents.get_int("transit_by_foot", transit_by_foot) != 0;
foot_path_weight = contents.get_int("foot_path_weight", foot_path_weight);
foot_path_time_ticks = contents.get_int("foot_path_time_ticks", foot_path_time_ticks);
walk_cost_to_halt = contents.get_int("walk_cost_to_halt", walk_cost_to_halt) != 0;

// Default pak file path
objfilename = ltrim(contents.get_string("pak_file_path", objfilename.c_str() ) );

Expand Down
18 changes: 18 additions & 0 deletions dataobj/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,15 @@ class settings_t
// can unload cargo even if stop length is too short
bool allow_unload_longer_convoy;

// transit by foot between overlapping pax stops
bool transit_by_foot;
uint32 foot_path_weight; // added to route cost for walking connection
uint32 foot_path_time_ticks; // added to journey time for time-based routing
// When true, the walking distance from a passenger's origin/destination tile to each
// candidate halt is included in the route cost so that nearer halts are preferred.
// When false, all halts within station coverage are treated as equidistant (old behaviour).
bool walk_cost_to_halt;

public:
/* the big cost section */
sint32 maint_building; // normal building
Expand Down Expand Up @@ -772,6 +781,15 @@ class settings_t
bool is_allow_unload_longer_convoy() const { return allow_unload_longer_convoy; }

bool is_using_route_cache() const { return use_route_cache; }

bool is_transit_by_foot() const { return transit_by_foot; }
void set_transit_by_foot(bool v) { transit_by_foot = v; }
uint32 get_foot_path_weight() const { return foot_path_weight; }
void set_foot_path_weight(uint32 v) { foot_path_weight = v; }
uint32 get_foot_path_time_ticks() const { return foot_path_time_ticks; }
void set_foot_path_time_ticks(uint32 v) { foot_path_time_ticks = v; }
bool is_walk_cost_to_halt() const { return walk_cost_to_halt; }
void set_walk_cost_to_halt(bool v) { walk_cost_to_halt = v; }
};

#endif
57 changes: 46 additions & 11 deletions gui/halt_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -794,11 +794,18 @@ void gui_halt_detail_t::update_connections( halthandle_t h )
for (uint i=0; i<goods_manager_t::get_max_catg_index(); i++){
vector_tpl<haltestelle_t::connection_t> const& connections = halt->get_connections(i);
if( !connections.empty() ) {
// Only show vehicle connections here; foot-paths are listed separately below.
vector_tpl<haltestelle_t::connection_t> sorted;
FOR(vector_tpl<haltestelle_t::connection_t>, const& conn, connections) {
if( conn.halt.is_bound() && !conn.is_foot_path ) {
sorted.insert_unique_ordered(conn, gui_halt_detail_t::compare_connection);
}
}
if( sorted.empty() ) { continue; }

gui_label_buf_t *lb = new_component_span<gui_label_buf_t>(2);
lb->buf().append(" \xC2\xB7");
const goods_desc_t* info = goods_manager_t::get_info_catg_index(i);
// If it is a special freight, we display the name of the good, otherwise the name of the category.
lb->buf().append(translator::translate(info->get_catg()==0 ? info->get_name() : info->get_catg_name() ) );
#if MSG_LEVEL>=4
if( halt->is_transfer(i) ) {
Expand All @@ -808,15 +815,8 @@ void gui_halt_detail_t::update_connections( halthandle_t h )
lb->buf().append(":\n");
lb->update();

vector_tpl<haltestelle_t::connection_t> sorted;
FOR(vector_tpl<haltestelle_t::connection_t>, const& conn, connections) {
if( conn.halt.is_bound() ) {
sorted.insert_unique_ordered(conn, gui_halt_detail_t::compare_connection);
}
}
const bool is_tgbr_enabled = world()->get_settings().get_time_based_routing_enabled(i);
FOR(vector_tpl<haltestelle_t::connection_t>, const& conn, sorted) {

has_stops = true;

button_t *pb = new_component<button_t>();
Expand All @@ -825,10 +825,9 @@ void gui_halt_detail_t::update_connections( halthandle_t h )

gui_label_buf_t *lb = new_component<gui_label_buf_t>();
if( is_tgbr_enabled ) {
// Show the estimated journey time in the divided time units
const uint16 weight = world()->tick_to_divided_time(conn.weight);
const uint16 weight = world()->tick_to_divided_time(conn.weight);
std::visit([&](const auto& t) {
lb->buf().printf("%s <%u> - %s", conn.halt->get_name(), weight, t.is_bound() ? t->get_name() : "Unavailable");
lb->buf().printf("%s <%u> - %s", conn.halt->get_name(), weight, t.is_bound() ? t->get_name() : "?");
}, conn.best_weight_traveler);
} else {
lb->buf().printf("%s <%u>", conn.halt->get_name(), conn.weight);
Expand All @@ -842,6 +841,42 @@ void gui_halt_detail_t::update_connections( halthandle_t h )
insert_show_nothing();
}

// Foot-path connections (transit by foot) — only shown when feature is enabled
if( world()->get_settings().is_transit_by_foot() ) {
vector_tpl<haltestelle_t::connection_t> const& pax_conns = halt->get_connections(goods_manager_t::INDEX_PAS);
vector_tpl<haltestelle_t::connection_t> foot_sorted;
FOR(vector_tpl<haltestelle_t::connection_t>, const& conn, pax_conns) {
if( conn.halt.is_bound() && conn.is_foot_path ) {
foot_sorted.insert_unique_ordered(conn, gui_halt_detail_t::compare_connection);
}
}
insert_empty_row();
new_component_span<gui_label_t>("Reachable on foot", 2);
if( !foot_sorted.empty() ) {
const bool is_tgbr_enabled = world()->get_settings().get_time_based_routing_enabled(goods_manager_t::INDEX_PAS);
const uint32 base_rc = world()->get_settings().get_foot_path_weight();
const uint32 base_jt = world()->get_settings().get_foot_path_time_ticks();
FOR(vector_tpl<haltestelle_t::connection_t>, const& conn, foot_sorted) {
button_t *pb = new_component<button_t>();
pb->init( button_t::posbutton_automatic, NULL);
pb->set_targetpos3d( conn.halt->get_basis_pos3d() );

gui_label_buf_t *lb = new_component<gui_label_buf_t>();
// Reverse-calculate tile distance from weight (weight = base * dist).
const uint32 base = is_tgbr_enabled ? base_jt : base_rc;
const uint32 dist = (base > 0) ? (conn.weight / base) : 0;
if( is_tgbr_enabled ) {
lb->buf().printf("%s (%u tiles) <%u>", conn.halt->get_name(), dist, world()->tick_to_divided_time(conn.weight));
} else {
lb->buf().printf("%s (%u tiles) <%u>", conn.halt->get_name(), dist, conn.weight);
}
lb->update();
}
} else {
insert_show_nothing();
}
}

// ok, we have now this counter for pending updates
destination_counter = halt->get_reconnect_counter();
last_connection_update_counter = halt->get_connection_update_counter();
Expand Down
Loading
Loading