Question about station tile orientation

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Question about station tile orientation

Post by michael blunck »

Question: Is there a trick to determine whether we´re on a station tile drawn in x- or y-direction? I´d need this info to override the tile type of certain tiles by CB24.

regards
Michael
Image
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Re: Question about station tile orientation

Post by Michi_cc »

In theory that would be the lowest bit of the T component of vars 4x. In CB 24, var 10 is supposed to contain the same info as 41 normally would, but unfortunately OTTD always sets the T components to 0 in this case. I guess it would be possible to change that to 0/1 according to axis, but I don't know if any NewGRF might depend on it being 0.

Basically:

Code: Select all

diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 180a25d..a1a62de 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1275,7 +1275,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32

                                if (statspec != NULL) {
                                        /* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */
-                                       uint32 platinfo = GetPlatformInfo(AXIS_X, 0, plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false);
+                                       uint32 platinfo = GetPlatformInfo(AXIS_X, axis, plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false);

                                        /* As the station is not yet completely finished, the station does not yet exist. */
                                        uint16 callback = GetStationCallback(CBID_STATION_TILE_LAYOUT, platinfo, 0, statspec, NULL, tile);
-- Michael Lutz
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: Question about station tile orientation

Post by michael blunck »

Michi_cc wrote: In theory that would be the lowest bit of the T component of vars 4x.
Thanks for the quick reply.

But not only in "theory", it´s in the specs:
nfo spec wrote: T Tile type: the current tile type; only valid for callback 14
I only wonder about that restriction?
Michi_cc wrote: In CB 24, var 10 is supposed to contain the same info as 41 normally would, but unfortunately OTTD always sets the T components to 0 in this case.
I guess it would be possible to change that to 0/1 according to axis,
I´d very much support this proposal.
Michi_cc wrote: but I don't know if any NewGRF might depend on it being 0.
Hm. I´ve never used it myself for this purpose. I have taken a look now into CanStations and ISR, and both are using CB24. CanStations only by returning fixed tile type numbers, and ISR using indeed CB24 accessing var10, but obviously not checking T.

regards
Michael
Image
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Re: Question about station tile orientation

Post by Michi_cc »

michael blunck wrote:I only wonder about that restriction?
No idea. I don't see anything in OTTD source code that would preclude using it anywhere a real station tile is present. It's obviously not usable for things that are called before construction. Unless TTDPatch is implemented vastly different I'd guess this is simply a stale sentence in the docs.

-- Michael Lutz
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: Question about station tile orientation

Post by frosch »

TTDP resolves the "T" part using a global variable "curstattiletype", not by accessing the map.
This variable is only assigned when resolving CB 14. So, yes, for TTDP it only works for CB 14, in other cases it returns the value from the last CB 14 to any station tile (probably some other tile). (though I have no idea why TTDP does it this way)

Anyway, TTDP CB 24 also fills the "T" part in var10 (with the value which would be used if the CB fails), so OTTD should do the same.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: Question about station tile orientation

Post by michael blunck »

For the records: Fixed in r24951.

regards
Michael
Image
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 16 guests