Page 1 of 1

Problems with using TTD sprites in station sprite layouts

Posted: 30 Apr 2008 22:28
by mart3p
While coding Industrial Stations Renewal, I have found a number of instances where it would be useful to use TTD sprites (either from trg1r.grf or loaded using Action A and GRM). I have encountered a problem each time I try this, with offsets that are added to the sprites by TTDPatch (or OpenTTD), when the selected rail type is monorail or maglev.

The offset added is 82 sprites for monorail and twice that for maglev. This offset corresponds to the number of rail sprites, for each rail type in trg1r.grf.

I was aware this happened with ground sprites, which is reasonable, as in most cases you want a ground sprite to suit the track type. It does not seem so useful that this offset is also added to other station sprites.

One example where I have the problem is the new truck parking tiles. These use TTD's truck sprites. In this case, I can work around the problem by making the tile unavailable for monorail or maglev. Players will have to switch back to normal rail to build truck parking next to their maglev stations.

There are other cases where this workaround is not possible. In the case of some of the animated stations, I would like to use sprites loaded once using Action A and GRM, rather than having to repeat them numerous times for each Action 1 sprite set. I have managed to make this work very successfully except for the problem with the sprite offset.

The only solution I can see in this case, is to use GRM to allocate enough space to have the sprites loaded 3 times, plus the required offsets between them. This works, but it means reserving 192 sprites rather than the 28 sprites that I actually need.

I have searched the NewGRF documentation for help on this, but I don't believe these sprite offsets are even mentioned.

Any suggestions would be welcome. :)

Re: Problems with using TTD sprites in station sprite layouts

Posted: 01 May 2008 03:04
by DaleStan
My best suggestion is multiple spritelayouts in prop 09, and then use var 42 in CB14 to get the right one.

Re: Problems with using TTD sprites in station sprite layouts

Posted: 01 May 2008 09:24
by mart3p
Thanks DaleStan.

Yes, I had considered doing it that way. It would mean subtracting the necessary offsets from the sprite IDs, so that when the offset is added again, the correct sprite will be used. This seemed a bit of a hack...

The main reason I'm reluctant to use this method for the animated cranes, is that the station already uses 284 sprite layouts. The Action 0 that sets prop 09 is 9700 bytes long. Each of these sprite layouts is modified by Action 6 to apply the sprite IDs returned by the GRM Action D. Multiplying all this by 3 seems like a lot of code and a lot of work, just to save on sprite usage a bit.

Re: Problems with using TTD sprites in station sprite layouts

Posted: 01 May 2008 14:49
by DaleStan
That reminds me, ... *pulls up the NFORenum sources*

Good thing I'm not teching today; I might actually manage to get something done here. Maybe. If I don't have to completely restructure NFORenum to make it happen.