Auto-rail tool mis-displays buildability on foundations

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Auto-rail tool mis-displays buildability on foundations

Post by DaleStan »

Once a foundation has been constructed, the auto-rail tool seems to check buildability on the basis of the foundation, not the underlying land. This happens regardless of land shape over which the foundation was built, and regardless of the track-piece that caused the foundation to be built.
When actually building, the check is done properly[0], but the colors are incorrect when using the auto-rail tool.

[0] It should, therefore, be a simple matter of reusing that function, instead of using a re-invented square wheel.
Attachments
autorail.png
autorail.png (6.07 KiB) Viewed 1657 times
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

The top images are correct, no? Only the bottom ones are wrong. Or you mean the colours are wrong?

Unfortunately however this is unfixable for the time being. The reason is that those foundations don't exist anywhere actually. They are just drawn calculated by the type of slope and the existing rails on it. It could be fixed by checking EVERY tile under the autorail cursor on every draw event but this is imho way too CPU-intensive for this.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

I mean that the colors are wrong. All six of those should be red, IMO. (Again with the not-posting-necessary-iinformation. :oops:)

If the foundations don't exist, then what *is* the auto-rail tool checking when deciding whether or not to apply the white->red colormap? That was the only thing that seemed reasonable, especially given the top-center and top-right clips.

In terms of sprite-choice, the bottom-left one is also correct.
I'm not exactly sure which sprites the bottom-center and bottom-right ones should use, but those seem as reasonable as anything. Except, of course, for the fact that they're white instead of red.

The problem exhibited in the bottom row also happens if the sloped rail is not shored up by a foundation, but is built as was permitted before buildonslopes came about.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Autorail works statically as said before. Look at all the images. Would the highlighting be correct if there was no foundation? Yes. It doesn't know about the foundations.

Here's a small patch that make autorail ultra-aware. Note however that to achieve this it actually needs to try and test if it can build the given track on the drawn tile, and this on every redraw. This makes that section of the code 10x!!!! as slow. But have fun if you want :).
Attachments
ultra-autorail.diff
(1.25 KiB) Downloaded 46 times
In action
In action
Franley Transport, 19th Feb 2000.png (51.22 KiB) Viewed 1553 times
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Darkvater wrote:Look at all the images. Would the highlighting be correct if there was no foundation? Yes.
I'm afraid I disagree. If the foundations weren't there, we have:

Code: Select all

Wrong sprite -- Wrong sprite and color --  Wrong sprite and color

   Correct   -- Wrong sprite and color --      Wrong sprite
Here are shots of the same auto-rail positioning, on the same land-shapes, except without the foundations.
Attachments
autorail2.png
autorail2.png (5.23 KiB) Viewed 1547 times
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Hmm, you are right about that...donnu what causes it.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Ah I see what you mean and I had a little tracing done. I was true in my assumption the drawing code doesn't know anything about foundations. The following happens:

1. The tile's slope is calculated (without any foundations)
2. The tile is drawn and in the case of foundations its slope is updated to reflect the correct foundation slope
3. The red/white autorail is drawn based on the new slope but without knowledge of a foundation.

So all it sees is a normal slope with foundation like how you would think it works but without knowing there are tracks on it. And indeed, building on such a slope (without tracks) is indeed possible. It will just raise the tile with a foundation and add the rail to it. My initial assumption was correct that this is not really solvable without a lot of extra checks.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Darkvater wrote:2. The tile is drawn and in the case of foundations its slope is updated to reflect the correct foundation slope
What happens if you remove the slope update there?

I would expect that to cause the highlighting for the TTD tools to reflect the un-foundationed shape, but that's (1) what I expect, having played entirely too much TTDPatch, and (2) often more useful. I can *see* the shape after foundations, but if lots of adjacent tiles have foundations, I can't determine the true shape under the foundations without either experimental bulding or remove-and-rebuild. Both are a potential waste of time.

I'm not sure if this is relevant, but some things, for example industry tile variable 60, require the unfoundationed shape, not the foundationed shape.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

If I remove that check autorail will show up for the unfoundationed tiles and things will look weird in other circumstances :)
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
Post Reply

Return to “OpenTTD Problems”

Who is online

Users browsing this forum: Google Adsense [Bot] and 7 guests