The International Simutrans Forum

 

Author Topic: [BUG] Signalbox range view does not take account of meters_per_tile  (Read 431 times)

0 Members and 1 Guest are viewing this topic.

Offline Matthew

  • Devotee
  • *
  • Posts: 612
    • Japan Railway Journal
  • Languages: EN, some ZH, DE & SQ
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."

Offline Phystam

  • Devotee
  • *
  • Posts: 524
  • Pak256.Ex developer
    • Pak256 wiki page
  • Languages: ja, en, eo
Re: [BUG] Signalbox range view does not take account of meters_per_tile
« Reply #1 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.

Offline Matthew

  • Devotee
  • *
  • Posts: 612
    • Japan Railway Journal
  • Languages: EN, some ZH, DE & SQ
Re: [BUG] Signalbox range view does not take account of meters_per_tile
« Reply #2 on: January 19, 2020, 10:48:01 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.
« Last Edit: January 19, 2020, 12:30:37 PM by Matthew »

Offline Ranran

  • Devotee
  • *
  • Posts: 1658
  • 今日は兎汁よー
  • Languages: ja
Re: [BUG] Signalbox range view does not take account of meters_per_tile
« Reply #3 on: January 19, 2020, 04:51:40 PM »
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.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20915
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [BUG] Signalbox range view does not take account of meters_per_tile
« Reply #4 on: January 19, 2020, 04:52:06 PM »
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.

Offline Ves

  • Devotee
  • *
  • Posts: 1820
  • Languages: EN, SV, DK
Re: [BUG] Signalbox range view does not take account of meters_per_tile
« Reply #5 on: January 21, 2020, 09:52:35 PM »
The way I made the circle is in simplan.cc from line 673:

(gb = gebaeude = building, AKA the signalbox)

Code: [Select]
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...