summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorMatt Kimber <github@mattkimber.org.uk>2021-01-03 13:32:58 +0000
committerPatric Stout <github@truebrain.nl>2021-01-05 11:42:25 +0100
commit9b28b15e677e0de64fde270f4223daeb401cfcac (patch)
tree879ebd9b98d9ce4e8a45dd38b9033f3da9349080 /src/saveload
parenteeb88e87d8c7b62e0bac94ede44cceee987b8d09 (diff)
downloadopenttd-9b28b15e677e0de64fde270f4223daeb401cfcac.tar.xz
Codechange: create MutableSpriteCache to remove the need to cast Vehicle to a mutable type in render methods
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/oldloader_sl.cpp6
-rw-r--r--src/saveload/vehicle_sl.cpp12
2 files changed, 9 insertions, 9 deletions
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index fa7685731..ff4e6191e 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -1153,7 +1153,7 @@ static const OldChunks vehicle_chunk[] = {
OCL_SVAR( OC_UINT8, Vehicle, owner ),
OCL_SVAR( OC_TILE, Vehicle, tile ),
- OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Vehicle, sprite_seq.seq[0].sprite ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, Vehicle, sprite_cache.sprite_seq.seq[0].sprite ),
OCL_NULL( 8 ), ///< Vehicle sprite box, calculated automatically
@@ -1246,7 +1246,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
if (v == nullptr) continue;
v->refit_cap = v->cargo_cap;
- SpriteID sprite = v->sprite_seq.seq[0].sprite;
+ SpriteID sprite = v->sprite_cache.sprite_seq.seq[0].sprite;
/* no need to override other sprites */
if (IsInsideMM(sprite, 1460, 1465)) {
sprite += 580; // aircraft smoke puff
@@ -1257,7 +1257,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
} else if (IsInsideMM(sprite, 2516, 2539)) {
sprite += 1385; // rotor or disaster-related vehicles
}
- v->sprite_seq.seq[0].sprite = sprite;
+ v->sprite_cache.sprite_seq.seq[0].sprite = sprite;
switch (v->type) {
case VEH_TRAIN: {
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index 321ad53a6..6715eb97d 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -445,21 +445,21 @@ void AfterLoadVehicles(bool part_of_load)
case VEH_ROAD:
case VEH_TRAIN:
case VEH_SHIP:
- v->GetImage(v->direction, EIT_ON_MAP, &v->sprite_seq);
+ v->GetImage(v->direction, EIT_ON_MAP, &v->sprite_cache.sprite_seq);
break;
case VEH_AIRCRAFT:
if (Aircraft::From(v)->IsNormalAircraft()) {
- v->GetImage(v->direction, EIT_ON_MAP, &v->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 */
Vehicle *shadow = v->Next();
- shadow->sprite_seq.CopyWithoutPalette(v->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 */
if (v->subtype == AIR_HELICOPTER) {
Vehicle *rotor = shadow->Next();
- GetRotorImage(Aircraft::From(v), EIT_ON_MAP, &rotor->sprite_seq);
+ GetRotorImage(Aircraft::From(v), EIT_ON_MAP, &rotor->sprite_cache.sprite_seq);
}
UpdateAircraftCache(Aircraft::From(v), true);
@@ -808,7 +808,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_CONDVAR(Vehicle, z_pos, SLE_FILE_U8 | SLE_VAR_I32, SL_MIN_VERSION, SLV_164),
SLE_CONDVAR(Vehicle, z_pos, SLE_INT32, SLV_164, SL_MAX_VERSION),
- SLE_VAR(Vehicle, sprite_seq.seq[0].sprite, SLE_FILE_U16 | SLE_VAR_U32),
+ SLE_VAR(Vehicle, sprite_cache.sprite_seq.seq[0].sprite, SLE_FILE_U16 | SLE_VAR_U32),
SLE_CONDNULL(5, SL_MIN_VERSION, SLV_59),
SLE_VAR(Vehicle, progress, SLE_UINT8),
SLE_VAR(Vehicle, vehstatus, SLE_UINT8),
@@ -848,7 +848,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_CONDVAR(Vehicle, current_order.dest, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_5),
SLE_CONDVAR(Vehicle, current_order.dest, SLE_UINT16, SLV_5, SL_MAX_VERSION),
- SLE_VAR(Vehicle, sprite_seq.seq[0].sprite, SLE_FILE_U16 | SLE_VAR_U32),
+ SLE_VAR(Vehicle, sprite_cache.sprite_seq.seq[0].sprite, SLE_FILE_U16 | SLE_VAR_U32),
SLE_CONDVAR(Vehicle, age, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
SLE_CONDVAR(Vehicle, age, SLE_INT32, SLV_31, SL_MAX_VERSION),
SLE_VAR(Vehicle, tick_counter, SLE_UINT8),