The International Simutrans Forum

Simutrans Extended => Simutrans-Extended bug reports => Simutrans-Extended development => Simutrans-Extended closed bug reports => Topic started by: Phystam on June 18, 2022, 09:42:20 AM

Title: One-way road is reversed in some case
Post by: Phystam on June 18, 2022, 09:42:20 AM
How to reproduce:
1. Construct piers and a slope like this picture:
(https://media.discordapp.net/attachments/665986412641779712/987650166960029726/unknown.png)

2. Pressing Ctrl key, build one-way road from non-pier tile via the slope to the piers. Then the ribi-arrows are reversed.
(https://media.discordapp.net/attachments/665986412641779712/987650628924895272/unknown.png)

3. This issue does not happen without pressing Ctrl key.
(https://media.discordapp.net/attachments/665986412641779712/987650394320699402/unknown.png)
Title: Re: One-way road is reversed in some case
Post by: zook2 on June 20, 2022, 05:44:11 AM
It has nothing to do with piers. I've seen it happen recently on flat ground, too, when building motorways.
Title: Re: One-way road is reversed in some case
Post by: Ranran(retired) on June 20, 2022, 10:05:15 AM
I believe this is a bug of this patch. (https://forum.simutrans.com/index.php/topic,18073.0.html)
Title: Re: One-way road is reversed in some case
Post by: PJMack on June 20, 2022, 05:59:38 PM
I think I know what may be going on.  When holding the control key when constructing a way, the path finder using the "calc_straight_route" function which constructs the route from start to finish by first going straight along a cardinal direction, then diagonal along an ordinal direction.  In the event that that fails (such as when there is an obstacle), a second attempt is made swapping the start and finish coordinates.  I suspect what is happening is that functions for applying the one-way road flags are not taking into account the reversal of start and finish.
Title: Re: One-way road is reversed in some case
Post by: Ranran(retired) on June 20, 2022, 10:38:55 PM
Yes. THleaderH, who brought this feature to extended, clearly knows the existence of this bug. Because he fixed it with his fork. But he didn't fix it with extended. (´・ω・`)

However, the related part of the code is slightly different between the standard and extended code.
I'm not familiar with the code in this part so I'm not sure if it's easy.

EDIT:
I may have fixed only the issue of one way reversing on flat land.
https://github.com/Ranran-the-JuicyPork/simutrans-extended/commit/ffdad8e9039c6bf4130794f1d54b8522a7a3f360
However, it seems that we have to distinguish between the case of flatness and the case of height difference. This can be a hassle so I wouldn't do it.

The following fixes may be relevant
https://github.com/teamhimeh/simutrans/commit/f1a436cfc4d322a0ef50866dd92df85c41fbb8e4
https://github.com/teamhimeh/simutrans/commit/203640fc649f5714d5c4bfdd130c81738fdad945
Title: Re: One-way road is reversed in some case
Post by: jamespetts on November 05, 2022, 03:52:02 PM
I have incorporated Ranran's fix - thank you for that.
Title: Re: One-way road is reversed in some case
Post by: Ranran(retired) on November 05, 2022, 04:12:58 PM
I think I have only partially fixed this bug.
Only fixed if all roads to be laid are flat.
THleaderH seems to have fixed it in his own fork, but from reading past posts 4 month ago, I gave up on fixing it because I didn't succeed in merging his fix.
Title: Re: One-way road is reversed in some case
Post by: jamespetts on November 05, 2022, 04:31:01 PM
Quote from: Ranran on November 05, 2022, 04:12:58 PMI think I have only partially fixed this bug.
Only fixed if all roads to be laid are flat.
THleaderH seems to have fixed it in his own fork, but from reading past posts 4 month ago, I gave up on fixing it because I didn't succeed in merging his fix.
Thank you - a partial fix is better than no fix, I think.