News:

Want to praise Simutrans?
Your feedback is important for us ;D.

tool_wayremover_t can be used on 0km/h way

Started by poppo, January 16, 2026, 06:12:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

poppo

tool_wayremover_t does not work on 0km/h way (for all simutrans version).
I fix this problem with the attached patch. can_use_tool_wayremover_t_on_0kmh_way.patch

prissi

Since the 0km/h was meant for things like city walls and non-navigatable rivers, it was somewhat intended to not remove those.

There are other things around the wayremoval tool, like obeying the ribis of one way signs.

Also, I would rather add a flag to vehikel_t, "bool removal_driver:1;" which then could to all kind of action one deemed useful during removal like ignoring one way roads etc. That is much easier than handing down a parameter and also more efficient as that memory locations stays in the chache compared to a parameter on the stack.

poppo

OK, but I do not want to ignore one-way sign on them.
Also, my change allows decorating those 0kmh way with catenary (because we only watch the max-speed of testdriver).

poppo

I understand what run in 124.3.1.

In 124.3.1, wayremover_t also run on 0km/h way, because it use way_checker_t.
However, we cannot build wayobj on 0km/h way, because it use usual vehicle_t called in vehicle_builder_t::build().
So, I want to use way_checke_t in tool_build_wayobj_t.

poppo

#4
diff --git a/src/simutrans/tool/simtool.cc b/src/simutrans/tool/simtool.cc
index fdcfd8e5d..41e870b93 100644
--- a/src/simutrans/tool/simtool.cc
+++ b/src/simutrans/tool/simtool.cc
@@ -3826,24 +3826,13 @@ bool tool_build_wayobj_t::init( player_t *player )
 
 bool tool_build_wayobj_t::calc_route( route_t &verbindung, player_t *player, const koord3d& start, const koord3d& to )
 {
- waytype_t waytype = wt;
+ waytype_t waytype = wt==tram_wt? track_wt: wt;
  if(  waytype == decoration_wt  ) {
  waytype = welt->lookup(start)->get_weg(wt)->get_waytype();
  }
- // special treatment for deports, since track electrication cannot "drive" into tram depot
- if(  waytype == track_wt  ) {
- if(  depot_t  *dp = welt->lookup(start)->get_depot()  ) {
- waytype = dp->get_waytype();
- }
- else if(  depot_t  *dp = welt->lookup(to)->get_depot()  ) {
- waytype = dp->get_waytype();
- }
- }
+
  // get a default vehicle
- vehicle_desc_t remover_desc( waytype, 500, vehicle_desc_t::diesel );
- vehicle_t* test_vehicle = vehicle_builder_t::build(start, player, NULL, &remover_desc);
- test_vehicle->set_flag( obj_t::not_on_map );
- test_driver_t* test_driver = scenario_checker_t::apply(test_vehicle, player, this);
+ test_driver_t *test_driver = new way_checker_t(waytype);
 
  bool can_built;
  if( start != to ) {
@@ -5664,10 +5653,8 @@ built_sign:
 bool tool_build_roadsign_t::calc_route(route_t &route, player_t *player, const koord3d &from, const koord3d &to)
 {
  // get a default vehicle
- vehicle_desc_t rs_desc( desc->get_wtyp(), 500, vehicle_desc_t::diesel);
- vehicle_t *test_vehicle = vehicle_builder_t::build(from, player, NULL, &rs_desc);
- test_vehicle->set_flag(obj_t::not_on_map);
- test_driver_t *test_driver = scenario_checker_t::apply(test_vehicle, player, this);
+ waytype_t waytype = desc->get_waytype()==tram_wt? track_wt: desc->get_waytype();
+ test_driver_t *test_driver = new way_checker_t(waytype);
 
  bool can_build = false;
I write and debug it. When we use way_checker_t for build_wayobj, we do not need to care about the depot waytype(tram/track).

prissi

Before, there had been actually ways with waytype tram_wt. But I am ok with removing this old code, as now track get converted anyway on pak set loading time.

Using the same driver for removal and adding wayobj sounds sensible to me. But the scenario checker must not be removed.

I added this in r11872