From 9c70c38c5e9b4a299a08ed2790ff45ebbdf2d144 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sat, 7 Jan 2023 10:16:52 +0100 Subject: [PATCH] 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. --- src/saveload/vehicle_sl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 5254f94d21..86e3d83ada 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -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); }