Changeset - r26751:8d0601e69444
[Not reviewed]
master
0 1 0
Rubidium - 23 months ago 2023-01-07 09:16:52
rubidium@openttd.org
Fix: check for the existence of shadow and rotor vehicles for aircraft

Instead of just assuming that it exists in the savegame that got loaded.
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -454,13 +454,17 @@ void AfterLoadVehicles(bool part_of_load
 
				if (Aircraft::From(v)->IsNormalAircraft()) {
 
					v->GetImage(v->direction, EIT_ON_MAP, &v->sprite_cache.sprite_seq);
 

	
 
					/* The plane's shadow will have the same image as the plane, but no colour */
 
					/* The aircraft's shadow will have the same image as the aircraft, but no colour */
 
					Vehicle *shadow = v->Next();
 
					if (shadow == nullptr) SlErrorCorrupt("Missing shadow for aircraft");
 

	
 
					shadow->sprite_cache.sprite_seq.CopyWithoutPalette(v->sprite_cache.sprite_seq);
 

	
 
					/* In the case of a helicopter we will update the rotor sprites */
 
					if (v->subtype == AIR_HELICOPTER) {
 
						Vehicle *rotor = shadow->Next();
 
						if (rotor == nullptr) SlErrorCorrupt("Missing rotor for helicopter");
 

	
 
						GetRotorImage(Aircraft::From(v), EIT_ON_MAP, &rotor->sprite_cache.sprite_seq);
 
					}
 

	
0 comments (0 inline, 0 general)