No re-randomisation (trains)

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

Moderator: Graphics Moderators

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

No re-randomisation (trains)

Post by michael blunck »

Again, I have a problem with re-randomisation. This time not with stations, but with vehicles/trains, using "multiple sprites". Apparently, the trigger bits are not updated, although randomisation should take place in the graphics chain, not in the callback chain (callback 2D):

Code: Select all

6442 * 0 02 00 00  01 01  00 00  00 00 // body sprite

6443 * 0 02 00 01  04 04  01 00 01 00  02 00 02 00  01 00 01 00  02 00 02 00 //freight sprites

// recolour body using CB 2D (default)
6444 * 0 02 00 02 89
1A 20 00 00 00 80 0E 1A 00 00 01 00 00 01
    00 00  00 00 00 00  00 00 00 00 
    00 00 // body

// recolour freight using allocated recolour maps 0xA8 .. 0xAB
6445 * 0 02 00 14 89 7F 03 20 FF FF FF FF 00
1A 20 A8 00 00 00 0E 1A 00 00 01 00 00  01
    01 00  00 00 00 00  00 00 00 00
    01 00

6446 * 0 02 00 15 89 7F 03 20 FF FF FF FF 00
1A 20 A9 00 00 00 0E 1A 00 00 01 00 00  01
    01 00  00 00 00 00  00 00 00 00
    01 00

6447 * 0 02 00 16 89 7F 03 20 FF FF FF FF 00
1A 20 AA 00 00 00 0E 1A 00 00 01 00 00  01
    01 00  00 00 00 00  00 00 00 00
    01 00

6448 * 0 02 00 17 89 7F 03 20 FF FF FF FF 00
1A 20 AB 00 00 00 0E 1A 00 00 01 00 00  01
    01 00  00 00 00 00  00 00 00 00
    01 00

// try randomising
6449 * 0 02 00 03  80 04 01 04  14 00 15 00 16 00 17 00

6450 * 0 02 00 04  81 10 08 FF 01
    02 00  00 00 // body
    03 00 // freight

6451 * 0 02 00 1E  85 0C 00 FF FF 01
    74 00  2D 00 2D 00 // recolour = box van
    04 00
There is no randomisation at all, i.e. on unloading. Am I really in the graphics chain when using multiple sprites with implicit  recolouring here?

And if not, how could I force re-randomisation in this context?

regards
Michael
Image
Eddi
Tycoon
Tycoon
Posts: 8254
Joined: 17 Jan 2007 00:14

Re: No re-randomisation (trains)

Post by Eddi »

i think technically rerandomization happens in the undocumented(?) callback 1
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: No re-randomisation (trains)

Post by michael blunck »

Eddi wrote: 14 Apr 2021 20:48 i think technically rerandomization happens in the undocumented(?) callback 1
Yeah, we had that discussion 7 years ago:
viewtopic.php?f=68&t=63818

Nevertheless, IMO this isn't the same context. I can even remove CB 2D from the above code and still randomisation doesn't work when using multiple sprites with its implicit recolouring.

regards
Michael
Image
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1728
Joined: 30 Mar 2005 09:43

Re: No re-randomisation (trains)

Post by peter1138 »

This sprite stack stuff is new to me, but from looking at the code only the default part of it is followed for randomizations. Triggers are only called at specific times, and not when actually looking up what graphics to use.

However due to how act 3/2/1 chains work, it probably does need to follow the sprite stack system in this case too.

EDIT: As a work around, you could try to put the same random action inside the chain for first sprite, just make all decisions go back to the same result. (Which is the same conclusion as for the station rerandomisation, although in that case it really wasn't possible to follow different CB chains.)

EDIT x2: I've opened a PR at https://github.com/OpenTTD/OpenTTD/pull/9195 to attempt to resolve this, but it is totally untested...!

EDIT x3: Closed it as a bad idea opening a potential rabbit hole.
He's like, some kind of OpenTTD developer.
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: No re-randomisation (trains)

Post by michael blunck »

Well. Since years I realize that randomAction is broken, maybe from the beginning. And now more so with that relatively novel feature of multiple/stacked sprites.

Are there plans to fix this? Or eventually develop a proper scheme for sprite (re-)randomisation?

Thanks for taking a look into it, Peter.

regards
Michael
Image
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests