FS#3060 - Vehicle::coord not update when sprite changes without the vehicle being moved

Attached to Project: OpenTTD
Opened by andythenorth (andythenorth) - Tuesday, 28 July 2009, 20:15 GMT
Last edited by frosch (frosch) - Saturday, 08 August 2009, 18:45 GMT
Type Bug
Category Vehicles
Status Closed
Assigned To No-one
Operating System All
Severity Medium
Priority Normal
Reported Version 0.7.2-RC2
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


Ach, this one might turn out to be bad nfo by me, but if so I'm unable to figure out why.

Issue: some HEQS road vehicle sprites disappear intermittently whilst loading. Sometimes artefacts of several pixels are left in the screen from the 'missing' sprite. Sprites reappear intermittently, or if a game window is moved over them, dropped, then picked up and moved again.

Easiest description is in the attached image: on the left the sprites for the rear trailer are missing. On the right, the sprites have reappeared. The only difference is that I moved the vehicle window as described above.

This vehicle is unusual in that it includes a transparent sprite, used when the vehicle is travelling unloaded. It could be a problem with my code, or perhaps it's a bug and hasn't been noticed because usually the difference would be visually hard to notice. Drop me a line for nfo etc. if that helps.

This is present in 0.7.2 RC2 and nightly 16762. To reproduce, try a full load of wood with the Cascade C16 logging truck in HEQS v0.5c (available on BaNaNas).



   weird.png (44.4 KiB)
This task depends upon

Closed by  frosch (frosch)
Saturday, 08 August 2009, 18:45 GMT
Reason for closing:  Fixed
Additional comments about closing:  in r17121
Comment by frosch (frosch) - Wednesday, 29 July 2009, 19:49 GMT
To simplify things, here is a testgame that shows the effect.

It is not related to spritesorting, so no  FS#119  :o

Activating bounding boxes (Ctrl-B) shows that even they glitch, so something is wrong with the vehicle display position hash or similiar.

On a side note: Andy, why are there more articulated parts than one would expect? (Edit: ok, the trailer is not really visible when not loaded)
Comment by Remko Bijker (Rubidium) - Sunday, 02 August 2009, 17:36 GMT
Could the following have something to do with the glitching?
dbg: [grf] [heqs__heavy_equipment_set_.0.5c/heqs.grf:2774] NewSpriteGroup (Deterministic): Invalid pseudo sprite length 12 (expected 14)!
Comment by frosch (frosch) - Monday, 03 August 2009, 20:14 GMT
Ok, the initial weirdness with the bounding boxes turned out as false alarm.

But now I guess I found the cause:
VehicleMove sets v->coord when the vehicle arrives at the stop. But the sprite of the unloaded vehicle is significantly smaller than the loaded one. So while the vehicle is loading it is not considered for drawing when it needs to. (Note for debugging: coord is not saved, so when a game with vehicle showing the glitch is saved and loaded again, it is gone :( )

So, attached is a better testgame for reproducing. Unpause the game. Let the vehicle load to 30%, pause the game. Scrolling will make the vehicle vanish. Forcing redraw by toggling Ctrl-B will make it appear again. A save/load cycle removes the glitch.