From a9e1f2e89cb995845ae7e48a08393a3b94e73993 Mon Sep 17 00:00:00 2001 From: Duncan Date: Sun, 11 Apr 2021 18:02:19 +0100 Subject: [PATCH] Remove SpriteBase::flags (#14460) * Remove SpriteBase::flags * Increment network version * update replays --- CMakeLists.txt | 4 ++-- openrct2.proj | 4 ++-- src/openrct2/GameStateSnapshots.cpp | 2 +- src/openrct2/network/NetworkBase.cpp | 2 +- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct12/RCT12.h | 5 +++++ src/openrct2/rct2/S6Exporter.cpp | 3 ++- src/openrct2/rct2/S6Importer.cpp | 2 +- src/openrct2/ride/CableLift.cpp | 1 + src/openrct2/ride/Ride.cpp | 1 + src/openrct2/ride/Vehicle.cpp | 6 +++--- src/openrct2/ride/Vehicle.h | 1 + src/openrct2/ride/VehiclePaint.cpp | 2 +- src/openrct2/world/Sprite.cpp | 1 - src/openrct2/world/SpriteBase.h | 1 - test/tests/S6ImportExportTests.cpp | 2 +- 16 files changed, 23 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5c4a7d6cf..0a2114bd2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,9 +50,9 @@ set(OBJECTS_VERSION "1.0.21") set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v${OBJECTS_VERSION}/objects.zip") set(OBJECTS_SHA1 "c38af45d51a6e440386180feacf76c64720b6ac5") -set(REPLAYS_VERSION "0.0.37") +set(REPLAYS_VERSION "0.0.38") set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v${REPLAYS_VERSION}/replays.zip") -set(REPLAYS_SHA1 "C31C299539EB86DA013AEE47C9B2B2F4609F52C4") +set(REPLAYS_SHA1 "8940FE7B3F86772214C8CF265E6CEA5A25B49FC1") option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.") option(WITH_TESTS "Build tests") diff --git a/openrct2.proj b/openrct2.proj index 365a794c31..02db22bdb3 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -48,8 +48,8 @@ 304d13a126c15bf2c86ff13b81a2f2cc1856ac8d https://github.com/OpenRCT2/objects/releases/download/v1.0.21/objects.zip c38af45d51a6e440386180feacf76c64720b6ac5 - https://github.com/OpenRCT2/replays/releases/download/v0.0.37/replays.zip - C31C299539EB86DA013AEE47C9B2B2F4609F52C4 + https://github.com/OpenRCT2/replays/releases/download/v0.0.38/replays.zip + 8940FE7B3F86772214C8CF265E6CEA5A25B49FC1 diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 1c3a142530..68056cffc0 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -197,7 +197,6 @@ struct GameStateSnapshots final : public IGameStateSnapshots { COMPARE_FIELD(SpriteBase, Type); COMPARE_FIELD(SpriteBase, sprite_index); - COMPARE_FIELD(SpriteBase, flags); COMPARE_FIELD(SpriteBase, x); COMPARE_FIELD(SpriteBase, y); COMPARE_FIELD(SpriteBase, z); @@ -392,6 +391,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(Vehicle, target_seat_rotation); COMPARE_FIELD(Vehicle, BoatLocation.x); COMPARE_FIELD(Vehicle, BoatLocation.y); + COMPARE_FIELD(Vehicle, IsCrashedVehicle); } void CompareSpriteDataLitter(const Litter& spriteBase, const Litter& spriteCmp, GameStateSpriteChange_t& changeData) const diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 2358beb336..d3cc97aba8 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -36,7 +36,7 @@ // This string specifies which version of network stream current build uses. // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "10" +#define NETWORK_STREAM_VERSION "11" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index f8b60a8d72..05f7b47134 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1401,7 +1401,6 @@ private: void ImportEntityCommonProperties(SpriteBase* dst, const RCT12SpriteBase* src) { - dst->flags = src->flags; dst->sprite_direction = src->sprite_direction; dst->sprite_width = src->sprite_width; dst->sprite_height_negative = src->sprite_height_negative; @@ -2877,6 +2876,7 @@ template<> void S4Importer::ImportEntity(const RCT12SpriteBase& srcBase dst->num_peeps = src->num_peeps; dst->next_free_seat = src->next_free_seat; + dst->IsCrashedVehicle = src->flags & RCT12_SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE; } template<> void S4Importer::ImportEntity(const RCT12SpriteBase& srcBase) diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index fe0ff85f2f..7d25590af7 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -173,6 +173,11 @@ enum RCT12_STATION_STYLE_INVISIBLE, // Added by OpenRCT2 }; +enum +{ + RCT12_SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE = 1 << 7, +}; + #pragma pack(push, 1) struct RCT12xy8 diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 6a1301a925..c75e8d4fd6 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1068,7 +1068,7 @@ void S6Exporter::ExportEntityCommonProperties(RCT12SpriteBase* dst, const Sprite dst->next_in_quadrant = SPRITE_INDEX_NULL; dst->sprite_height_negative = src->sprite_height_negative; dst->sprite_index = src->sprite_index; - dst->flags = src->flags; + dst->flags = 0; dst->x = src->x; dst->y = src->y; dst->z = src->z; @@ -1167,6 +1167,7 @@ template<> void S6Exporter::ExportEntity(RCT2SpriteVehicle* dst, const Vehicle* dst->colours_extended = src->colours_extended; dst->seat_rotation = src->seat_rotation; dst->target_seat_rotation = src->target_seat_rotation; + dst->flags = src->IsCrashedVehicle ? RCT12_SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE : 0; } template<> void S6Exporter::ExportEntity(RCT2SpritePeep* dst, const Guest* src) diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 2ac8390f39..db710bbe12 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1512,7 +1512,6 @@ public: dst->Type = GetEntityTypeFromRCT2Sprite(src); dst->sprite_height_negative = src->sprite_height_negative; dst->sprite_index = src->sprite_index; - dst->flags = src->flags; dst->x = src->x; dst->y = src->y; dst->z = src->z; @@ -1666,6 +1665,7 @@ template<> void S6Importer::ImportEntity(const RCT12SpriteBase& baseSrc dst->colours_extended = src->colours_extended; dst->seat_rotation = src->seat_rotation; dst->target_seat_rotation = src->target_seat_rotation; + dst->IsCrashedVehicle = src->flags & RCT12_SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE; } template<> void S6Importer::ImportEntity(const RCT12SpriteBase& baseSrc) diff --git a/src/openrct2/ride/CableLift.cpp b/src/openrct2/ride/CableLift.cpp index 5d9791d242..c1dfc7d154 100644 --- a/src/openrct2/ride/CableLift.cpp +++ b/src/openrct2/ride/CableLift.cpp @@ -79,6 +79,7 @@ Vehicle* cable_lift_segment_create( current->num_peeps = 0; current->next_free_seat = 0; current->BoatLocation.setNull(); + current->IsCrashedVehicle = false; return current; } diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index bdd9c158a1..444cd3ab86 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -4270,6 +4270,7 @@ static Vehicle* vehicle_create_car( vehicle->num_peeps = 0; vehicle->next_free_seat = 0; vehicle->BoatLocation.setNull(); + vehicle->IsCrashedVehicle = false; return vehicle; } diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index a059201492..3b855eeaba 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -3606,7 +3606,7 @@ void Vehicle::UpdateCollisionSetup() crashed_vehicle_particle_create(train->colours, { train->x, train->y, train->z }); } - train->flags |= SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE; + train->IsCrashedVehicle = true; train->var_C8 = scenario_rand(); train->var_CA = scenario_rand(); @@ -5365,7 +5365,7 @@ void Vehicle::CrashOnLand() while (numParticles-- != 0) crashed_vehicle_particle_create(colours, { x, y, z }); - flags |= SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE; + IsCrashedVehicle = true; animation_frame = 0; var_C8 = 0; sprite_width = 13; @@ -5428,7 +5428,7 @@ void Vehicle::CrashOnWater() for (int32_t i = 0; i < 10; ++i) crashed_vehicle_particle_create(colours, { x - 4, y + 8, z }); - flags |= SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE; + IsCrashedVehicle = true; animation_frame = 0; var_C8 = 0; sprite_width = 13; diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index 455e759687..a21814b8b4 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -204,6 +204,7 @@ struct Vehicle : SpriteBase uint8_t seat_rotation; uint8_t target_seat_rotation; CoordsXY BoatLocation; + bool IsCrashedVehicle; constexpr bool IsHead() const { diff --git a/src/openrct2/ride/VehiclePaint.cpp b/src/openrct2/ride/VehiclePaint.cpp index 9183704028..92d57a506b 100644 --- a/src/openrct2/ride/VehiclePaint.cpp +++ b/src/openrct2/ride/VehiclePaint.cpp @@ -3140,7 +3140,7 @@ template<> void PaintEntity(paint_session* session, const Vehicle* vehicle, int3 int32_t y = vehicle->y; int32_t z = vehicle->z; - if (vehicle->flags & SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE) + if (vehicle->IsCrashedVehicle) { uint32_t ebx = 22965 + vehicle->animation_frame; PaintAddImageAsParent(session, ebx, 0, 0, 1, 1, 0, z, 0, 0, z + 2); diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index 7d6f5e40b7..233c015fbc 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -427,7 +427,6 @@ static void PrepareNewEntity(SpriteBase* base, const EntityType type) base->sprite_width = 0x10; base->sprite_height_negative = 0x14; base->sprite_height_positive = 0x8; - base->flags = 0; base->sprite_left = LOCATION_NULL; SpriteSpatialInsert(base, { LOCATION_NULL, 0 }); diff --git a/src/openrct2/world/SpriteBase.h b/src/openrct2/world/SpriteBase.h index a6ce07253c..d46bc7eac5 100644 --- a/src/openrct2/world/SpriteBase.h +++ b/src/openrct2/world/SpriteBase.h @@ -29,7 +29,6 @@ struct SpriteBase // Height from centre of sprite to bottom uint8_t sprite_height_negative; uint16_t sprite_index; - uint16_t flags; int16_t x; int16_t y; int16_t z; diff --git a/test/tests/S6ImportExportTests.cpp b/test/tests/S6ImportExportTests.cpp index f3ee073f7d..bb2cee2455 100644 --- a/test/tests/S6ImportExportTests.cpp +++ b/test/tests/S6ImportExportTests.cpp @@ -132,7 +132,6 @@ static void CompareSpriteDataCommon(const SpriteBase& left, const SpriteBase& ri { COMPARE_FIELD(Type); COMPARE_FIELD(sprite_index); - COMPARE_FIELD(flags); COMPARE_FIELD(x); COMPARE_FIELD(y); COMPARE_FIELD(z); @@ -336,6 +335,7 @@ static void CompareSpriteDataVehicle(const Vehicle& left, const Vehicle& right) COMPARE_FIELD(colours_extended); COMPARE_FIELD(seat_rotation); COMPARE_FIELD(target_seat_rotation); + COMPARE_FIELD(IsCrashedVehicle); } static void CompareSpriteDataLitter(const Litter& left, const Litter& right)