News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

[BUG] Signalbox range view does not take account of meters_per_tile

Started by Matthew, January 19, 2020, 10:12:53 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Matthew

Ves kindly added a feature to display the range of signalboxes (using the $ key in pak128.Britain-Ex).

However, it appears to assume that meters_per_tile = 125. This is true for the Bridgewater-Brunel and Stephenson-Siemens games, but mpt is intended to be adjustable by players.

Steps to reproduce:
1. Copy your simuconf.tab to simutrans/addons/yourdesiredpakset/config/simuconf.tab
2. Change meters_per_tile to 235.
3. Start Sim-Ex with your desired pakset and addons loaded.
4. Start a new game in a year where there are signalboxes (1900+?).
5. Build a railway track and a signalbox.
6. Press $.
7. Try to build a stop signal just inside of the circle of black-and-yellow boxes. You will get an error message saying "Cannot build signal this far beyond any signalbox."

Phystam

It seems working correctly. I checked it using pak256, which has meters_per_tile=25, but I cannot reproduce the problem.

Matthew

Quote from: Phystam on January 19, 2020, 10:37:07 AM
It seems working correctly. I checked it using pak256, which has meters_per_tile=25, but I cannot reproduce the problem.

Hmm. I have seen it on 156, 235, and 625m. So maybe it's only noticeable if mpt > 125 ??

EDIT:
I believe that I have found the bug and how to fix it, thanks to Phystam's comment. It appears to be simple enough that it would be a good learning exercise in C++ for Simutrans. However, I am wary of the Dunning-Kruger effect (ja), so I will try to post the relevant code here as a gobbet in the next few days.

RESTRICTED ACCOUNT

I also tested it with pak128.britain-EX, but it seems to be working properly ...
Did the range display change after changing meters_per_tile? In my case it seems to be changing properly. That is, when meters_per_tile = 250, the size of the circle is halved.

jamespetts

Thank you for the report. I should be grateful for the offered more information and suggestion on how this might be fixed. I should note that I generally recommend against meters per tile settings that do not translate to a integral number of tiles for 1km.

Ves

The way I made the circle is in simplan.cc from line 673:

(gb = gebaeude = building, AKA the signalbox)


uint32 const radius = gb->get_tile()->get_desc()->get_radius();
uint16 const cov = radius / welt->get_settings().get_meters_per_tile();
if (shortest_distance(gb->get_pos().get_2d(), gr->get_pos().get_2d()) <= cov)
{
// Code that draws the cross and circle
}


Could it be an overflow from some of the uint's? Actually, I dont remember why those specific was used...