mirror of https://github.com/OpenTTD/OpenTTD
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.pull/10299/head
parent
5ddfd38de6
commit
9c70c38c5e
|
@ -454,13 +454,17 @@ void AfterLoadVehicles(bool part_of_load)
|
||||||
if (Aircraft::From(v)->IsNormalAircraft()) {
|
if (Aircraft::From(v)->IsNormalAircraft()) {
|
||||||
v->GetImage(v->direction, EIT_ON_MAP, &v->sprite_cache.sprite_seq);
|
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();
|
Vehicle *shadow = v->Next();
|
||||||
|
if (shadow == nullptr) SlErrorCorrupt("Missing shadow for aircraft");
|
||||||
|
|
||||||
shadow->sprite_cache.sprite_seq.CopyWithoutPalette(v->sprite_cache.sprite_seq);
|
shadow->sprite_cache.sprite_seq.CopyWithoutPalette(v->sprite_cache.sprite_seq);
|
||||||
|
|
||||||
/* In the case of a helicopter we will update the rotor sprites */
|
/* In the case of a helicopter we will update the rotor sprites */
|
||||||
if (v->subtype == AIR_HELICOPTER) {
|
if (v->subtype == AIR_HELICOPTER) {
|
||||||
Vehicle *rotor = shadow->Next();
|
Vehicle *rotor = shadow->Next();
|
||||||
|
if (rotor == nullptr) SlErrorCorrupt("Missing rotor for helicopter");
|
||||||
|
|
||||||
GetRotorImage(Aircraft::From(v), EIT_ON_MAP, &rotor->sprite_cache.sprite_seq);
|
GetRotorImage(Aircraft::From(v), EIT_ON_MAP, &rotor->sprite_cache.sprite_seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue