News:

Congratulations!
 You've won the News Item Lottery! Your prize? Reading this news item! :)

River gradient speed limits seem to be broken

Started by jamespetts, January 06, 2023, 10:38:34 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamespetts

I am posting this as I am away from my IDE and I need a reminder of this issue for when I am able to look into it.

It seems that the maximum speed for gradients for river types (which allowed the creation of unnavigable rapids and slow to navigate locks) is not working. As an example, at 953,1376 on the current Bridgewater-Brunel server game is a river tile that is shown as comprising rapids and should not be navigable (having a maximum speed of 0km/h in the .dat file) but boats in fact navigate it (although I note also that the locks at 932,1392 do appear to restrict speed correctly, so the problem may be confined to tiles with a 0km/h maximum speed - although this was progressing at 2km/h, so this may have been due to the steepness of the gradient rather than the maximum speed feature).
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ranran

Quote from: jamespetts on January 06, 2023, 10:38:34 PMso the problem may be confined to tiles with a 0km/h maximum speed
in vehicle_t::calc_speed_limit()
const bool slope_specific_speed = w->get_desc()->get_topspeed_gradient_1() < w->get_desc()->get_topspeed() || w->get_desc()->get_topspeed_gradient_2() < w->get_desc()->get_topspeed();

const sint32 base_limit = desc->get_override_way_speed() && !(slope_specific_speed && is_slope) ? SINT32_MAX_VALUE : kmh_to_speed(w->get_max_speed(desc->get_engine_type()==vehicle_desc_t::electric));
I wonder if these are related.
I'm not familiar with this part of the code though.

Is it possible to see such speed constraints in the UI?

jamespetts

Quote from: (N)Ranran (Hibernating) on January 06, 2023, 11:50:52 PMin vehicle_t::calc_speed_limit()
const bool slope_specific_speed = w->get_desc()->get_topspeed_gradient_1() < w->get_desc()->get_topspeed() || w->get_desc()->get_topspeed_gradient_2() < w->get_desc()->get_topspeed();

const sint32 base_limit = desc->get_override_way_speed() && !(slope_specific_speed && is_slope) ? SINT32_MAX_VALUE : kmh_to_speed(w->get_max_speed(desc->get_engine_type()==vehicle_desc_t::electric));
I wonder if these are related.
I'm not familiar with this part of the code though.

Is it possible to see such speed constraints in the UI?
I will have to look at the code in operation with a graphical debugger in some detail to be able to make sense of what is happening here. I know that it did work at one time - I am not sure what has changed. I think that this is probably the relevant part of the code, but I would need to check carefully to be sure.

As to the UI - I do not think that this is currently indicated in the UI. The visual indication is intended to be the appearance of rapids on unnavigable river gradients in otherwise navigable rivers. Ideally, one would have some indication in the information window, too. Currently, "(navigable)" and "(not navigable)" are appended as part of each river type's name, but this is potentially misleading on rapids - having a navigability display in the UI (i.e, whether the speed and weight limits are > 0, including, where the tile is a slope, the slope specific speed limits) would be preferable.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

jamespetts

I have now got home and I am having trouble reproducing this on a single player map, which is very odd.

Edit: Re-testing this, the issue seems to be that the feature works correctly on a Visual Studio debug build, but, very bizarrely, does not work on the GCC optimised build.

Edit 2: Further testing shows that the problem occurs in a game that has been loaded from a saved game.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

jamespetts

I believe that I have now fixed this - I should be grateful if anyone could confirm with to-morrow's nightly build.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.