Page 1 of 1

Auto-rail tool mis-displays buildability on foundations

Posted: 10 Dec 2005 22:49
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.

Posted: 18 Dec 2005 22:55
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.

Posted: 18 Dec 2005 23:28
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.

Posted: 19 Dec 2005 00:00
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 :).

Posted: 19 Dec 2005 00:25
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.

Posted: 19 Dec 2005 12:13
by Darkvater
Hmm, you are right about that...donnu what causes it.

Posted: 19 Dec 2005 17:58
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.

Posted: 19 Dec 2005 22:33
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.

Posted: 19 Dec 2005 22:48
by Darkvater
If I remove that check autorail will show up for the unfoundationed tiles and things will look weird in other circumstances :)