News:

SimuTranslator
Make Simutrans speak your language.

[BUG] bridgeheads can start in illegal locations

Started by Mariculous, July 28, 2020, 01:11:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mariculous

What happened?
On Bridgewater, a town forcefully built a bridge in a very strange way, causing a jam on Freddys railway line.

It is generally possible to force-build (ctrl-drag) a bridge to end on a through way.
This in independant of the involved waytype as long as both involved types are either the same or there is a level crossing defined in between those types.
Such bridges do not only look ugly, but those will also cut the route of the trough way, as just happened on bridgewater.

Another issue with this, I was not able to reproduce is a crash that can be caused by the construction of such bridges.
While building the crash setup, the game crashed twice, but I was not able to see the exact error message (the window closes immediately after showing it) nor was i able to get this reproduced.
I wll add instructions once I am able to reproduce the crash.

How to reproduce?
See the attached save, I have built any combination I could think of.
You can build any of these by
1. building the way on the ground
2. ctrl-dragging a bridge from a spare tile straight onto a flat way on the ground.

Thanks to Freddy, who noticed this behavior was not specific to towns constructing roads, but general to road construction. This made it much easier to provide a reproduction case.

jamespetts

Thank you for the report. The bridge building code is largely unchanged from Standard - does anyone know whether this issue is unique to Extended or whether it can be reproduced in Standard?
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.

kierongreen

Quote from: jamespetts on July 29, 2020, 01:10:56 PM
Thank you for the report. The bridge building code is largely unchanged from Standard - does anyone know whether this issue is unique to Extended or whether it can be reproduced in Standard?
I can't seem to reproduce this in Standard

jamespetts

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: this was very complex, and appears to arise in code from Standard: I was unable to find any divergence from Standard in the code in which this occurs.

Standard may well also suffer a crash, which I also fixed, when a three tile bridge was built with its far end immediately adjacent to a perpendicular way for which no crossing with the bridge's way was defined in the pakset.
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.

kierongreen

Have had a quick look at the fixes and I would be a bit wary of these - it seems like they might point to an underlying issue in the code elsewhere that differs from Standard and this could be leading to as yet unnoticed errors elsewhere in Extended. I'm suspecting that because Standard (and Extended) have managed so long without the checks in a section of code that goes back probably a decade. Also keeping code like this the same helps in keeping the versions as in sync with each other as possible.

jamespetts

Quote from: kierongreen on July 29, 2020, 08:06:45 PM
Have had a quick look at the fixes and I would be a bit wary of these - it seems like they might point to an underlying issue in the code elsewhere that differs from Standard and this could be leading to as yet unnoticed errors elsewhere in Extended. I'm suspecting that because Standard (and Extended) have managed so long without the checks in a section of code that goes back probably a decade. Also keeping code like this the same helps in keeping the versions as in sync with each other as possible.

I am afraid that I am at a loss as to what the relevant difference between the codebases is here; you may also want to check the specific case to which I refer above to see whether this does provoke a crash in Standard.
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.

kierongreen

Quote from: jamespetts on July 29, 2020, 08:20:16 PM
I am afraid that I am at a loss as to what the relevant difference between the codebases is here; you may also want to check the specific case to which I refer above to see whether this does provoke a crash in Standard.
I have without success in creating a crash in Standard unfortunately (or possibly fortunately)! Have tried to trace it a little in Extended but likewise can't see the obvious cause.

jamespetts

Quote from: kierongreen on July 29, 2020, 08:37:56 PM
I have without success in creating a crash in Standard unfortunately (or possibly fortunately)! Have tried to trace it a little in Extended but likewise can't see the obvious cause.

Very odd. If anyone is ever able to find the divergence, it would be helpful to know where it arises.

I have to say, I was mystified by the intent of the code in Standard: that I modified: it appeared to be designed to allow a crossing to be built on a bridge ramp when the ramp was on a perpendicular way, which is obviously absurd; but there appear to be lines of code specifically and only for this purpose, which is part of what I commented out. I cannot understand why they were there.
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.

kierongreen

#9
Bit of a prolonged process but currently seem to have identified that the error started occurring in August 2019 around time changes were happening to code to allow fords over some rivers but it's difficult to pinpoint exactly when

jamespetts

Quote from: kierongreen on July 30, 2020, 01:19:34 AM
Bit of a prolonged process but currently seem to have identified that the error started occurring in August 2019 around time changes were happening to code to allow fords over some rivers but it's difficult to pinpoint exactly when

Interesting, thank you. I was greatly hampered in my ability to look into this by not understanding the intent of the Standard code, as discussed in my previous post.
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.

kierongreen

Quote from: jamespetts on July 30, 2020, 10:32:13 AM
Interesting, thank you. I was greatly hampered in my ability to look into this by not understanding the intent of the Standard code, as discussed in my previous post.
I'm still investigating (when work allows) as to exactly what change is that's causing this - haven't managed to track down the exact commit yet - that I'm learning how to use GIT on the go is probably slowing me down a bit too!

Mariculous

The issue seems to be back.

As a player, it doesn't seem to be possible to build such ways, but the citygrowth can.

So I suspect the exact bug as reported above was fixed, but as kierongreen mentioned, the actual issue is located elsewhere in the code.

jamespetts

Thank you for your report. I will need a reliable reproduction case to be able to investigate this.
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.

Phystam


jamespetts

Thank you for that reproduction case: that is very helpful. This is actually an extremely complex problem. The system for building bridges does not seem to have any code for detecting the case where there is not enough space for start and end ramps for two successive bridges such that the only solution is to build one long bridge. In this case, it will simply assume that there is, in fact, sufficient space to build the start ramp for the second bridge and build it even if it ought not to be building it.

Initial experiments with checking for a way on the start tile in the bridge building code and not building the bridge if there be such a way does not work in that no bridges at all are built in such a case; I suspect that what is happening is that the road building code has already built a plain road in this location, so altering the bridge building code does not assist.

Unfortunately, I d not have time to investigate any further this evening.
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.

prissi

A bridge builds always a connecting way. So the bridge builder needs to check, whather there is a crossing on the start tile. If not, then it must fail. I will look into this in standard too.

freddyhayward

The player can't build bridges in this way, so why can towns? And why do they need to build successive bridges?

prissi

At least standard cannot cross railsway and checks for the end tile, if it is possible. I wonder if there needs to be unowned tracks for this.

Mariculous

Quote from: prissi on September 14, 2020, 06:57:58 AMI wonder if there needs to be unowned tracks for this.
Nope, I'm the owner of those tracks in the image.

The behavior of standard and extended in way construction is slightly different. I don't know when and why it diverged.
For example extended can build (useful but ugly looking) diagonal level crossings.
Further, new bridges in extended won't connect to existing ways right before or after the bride.
The latter was a fix to prevent the construction of some illegal level crossings, e.g. waterway-railway if none is defined.
It feels like in extended, there is an issue in the code that checks if a way can be built, which was then attempted to be fixed in many other locations.

Ranran

I was testing version 15.0 and found a bridge like this being built. Is this legal?

jamespetts

This ought not to be possible. I never did manage to get to the bottom of the problem with this, since I have never worked out how the code was supposed to work or where the checks were supposed to have been.
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.