diff --git a/CMakeLists.txt b/CMakeLists.txt index 65584a8008..ecaef976f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,8 +48,8 @@ set(TITLE_SEQUENCE_SHA1 "304d13a126c15bf2c86ff13b81a2f2cc1856ac8d") set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v1.0.21/objects.zip") set(OBJECTS_SHA1 "c38af45d51a6e440386180feacf76c64720b6ac5") -set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.33/replays.zip") -set(REPLAYS_SHA1 "6D600B756B49461CEA4F8206EA18C17AA6F2AF7B") +set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.34/replays.zip") +set(REPLAYS_SHA1 "1EEC4382EB8D4CDCC3530E0F983D4412DFC77F6E") 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 9bb0780e8d..f5e79ca09c 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.33/replays.zip - 6D600B756B49461CEA4F8206EA18C17AA6F2AF7B + https://github.com/OpenRCT2/replays/releases/download/v0.0.34/replays.zip + 1EEC4382EB8D4CDCC3530E0F983D4412DFC77F6E diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 7d3808f392..333ab342d2 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -464,12 +464,12 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(JumpingFountain, TargetX); COMPARE_FIELD(JumpingFountain, TargetY); COMPARE_FIELD(JumpingFountain, Iteration); + COMPARE_FIELD(JumpingFountain, FountainType); } void CompareSpriteDataMisc( const MiscEntity& spriteBase, const MiscEntity& spriteCmp, GameStateSpriteChange_t& changeData) const { - COMPARE_FIELD(MiscEntity, SubType); COMPARE_FIELD(MiscEntity, frame); } diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index ff26bfdd3f..a0061addd6 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 "4" +#define NETWORK_STREAM_VERSION "5" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; diff --git a/src/openrct2/paint/sprite/Paint.Misc.cpp b/src/openrct2/paint/sprite/Paint.Misc.cpp index 07e676671b..0a08c7b78a 100644 --- a/src/openrct2/paint/sprite/Paint.Misc.cpp +++ b/src/openrct2/paint/sprite/Paint.Misc.cpp @@ -88,6 +88,9 @@ template<> void PaintEntity(paint_session* session, const ExplosionFlare* flare, PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 0, flare->z); } +constexpr uint32_t JumpingFountainSnowBaseImage = 23037; +constexpr uint32_t JumpingFountainWaterBaseImage = 22973; + template<> void PaintEntity(paint_session* session, const JumpingFountain* jumpingFountain, int32_t imageDirection) { rct_drawpixelinfo* dpi = &session->DPI; @@ -113,7 +116,8 @@ template<> void PaintEntity(paint_session* session, const JumpingFountain* jumpi isAntiClockwise = !isAntiClockwise; } - uint32_t baseImageId = (jumpingFountain->SubType == MiscEntityType::JumpingFountainSnow) ? 23037 : 22973; + uint32_t baseImageId = (jumpingFountain->FountainType == JumpingFountainType::Snow) ? JumpingFountainSnowBaseImage + : JumpingFountainWaterBaseImage; uint32_t imageId = baseImageId + ebx * 16 + jumpingFountain->frame; constexpr std::array antiClockWiseBoundingBoxes = { CoordsXY{ -COORDS_XY_STEP, -3 }, CoordsXY{ 0, -3 } }; constexpr std::array clockWiseBoundingBoxes = { CoordsXY{ -COORDS_XY_STEP, 3 }, CoordsXY{ 0, 3 } }; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index e049646206..4fb8986037 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1132,7 +1132,7 @@ private: for (int i = 0; i < RCT1_MAX_SPRITES; i++) { spriteIndexMap[i] = SPRITE_INDEX_NULL; - if (_s4.sprites[i].unknown.sprite_identifier == SpriteIdentifier::Vehicle) + if (_s4.sprites[i].unknown.sprite_identifier == RCT12SpriteIdentifier::Vehicle) { rct1_vehicle* srcVehicle = &_s4.sprites[i].vehicle; if (srcVehicle->x != LOCATION_NULL) @@ -1343,7 +1343,7 @@ private: for (size_t i = 0; i < RCT1_MAX_SPRITES; i++) { spriteIndexMap[i] = SPRITE_INDEX_NULL; - if (_s4.sprites[i].unknown.sprite_identifier == SpriteIdentifier::Peep) + if (_s4.sprites[i].unknown.sprite_identifier == RCT12SpriteIdentifier::Peep) { rct1_peep* srcPeep = &_s4.sprites[i].peep; Peep* peep = nullptr; @@ -1651,7 +1651,7 @@ private: { for (auto& sprite : _s4.sprites) { - if (sprite.unknown.sprite_identifier == SpriteIdentifier::Litter) + if (sprite.unknown.sprite_identifier == RCT12SpriteIdentifier::Litter) { const auto* srcLitter = &sprite.litter; @@ -1671,37 +1671,37 @@ private: } } - MiscEntity* CreateMiscFromType(MiscEntityType type) + MiscEntity* CreateMiscFromType(RCT12MiscEntityType type) { MiscEntity* misc = nullptr; switch (type) { - case MiscEntityType::SteamParticle: + case RCT12MiscEntityType::SteamParticle: misc = CreateEntity(); break; - case MiscEntityType::MoneyEffect: + case RCT12MiscEntityType::MoneyEffect: misc = CreateEntity(); break; - case MiscEntityType::CrashedVehicleParticle: + case RCT12MiscEntityType::CrashedVehicleParticle: misc = CreateEntity(); break; - case MiscEntityType::ExplosionCloud: + case RCT12MiscEntityType::ExplosionCloud: misc = CreateEntity(); break; - case MiscEntityType::CrashSplash: + case RCT12MiscEntityType::CrashSplash: misc = CreateEntity(); break; - case MiscEntityType::ExplosionFlare: + case RCT12MiscEntityType::ExplosionFlare: misc = CreateEntity(); break; - case MiscEntityType::JumpingFountainWater: - case MiscEntityType::JumpingFountainSnow: + case RCT12MiscEntityType::JumpingFountainWater: + case RCT12MiscEntityType::JumpingFountainSnow: misc = CreateEntity(); break; - case MiscEntityType::Balloon: + case RCT12MiscEntityType::Balloon: misc = CreateEntity(); break; - case MiscEntityType::Duck: + case RCT12MiscEntityType::Duck: misc = CreateEntity(); break; default: @@ -1714,16 +1714,15 @@ private: { for (auto& sprite : _s4.sprites) { - if (sprite.unknown.sprite_identifier == SpriteIdentifier::Misc) + if (sprite.unknown.sprite_identifier == RCT12SpriteIdentifier::Misc) { rct1_unk_sprite* src = &sprite.unknown; - MiscEntity* dst = CreateMiscFromType(MiscEntityType(src->type)); + MiscEntity* dst = CreateMiscFromType(RCT12MiscEntityType(src->type)); if (dst == nullptr) { log_warning("SV4 has too many misc entities. No more misc entities will be imported!"); break; } - dst->SubType = MiscEntityType(src->type); dst->flags = src->flags; dst->sprite_direction = src->sprite_direction; dst->sprite_width = src->sprite_width; @@ -1732,30 +1731,30 @@ private: dst->MoveTo({ src->x, src->y, src->z }); - switch (static_cast(src->type)) + switch (static_cast(src->type)) { - case MiscEntityType::SteamParticle: + case RCT12MiscEntityType::SteamParticle: ImportSteamParticle(dst->As(), reinterpret_cast(src)); break; - case MiscEntityType::MoneyEffect: + case RCT12MiscEntityType::MoneyEffect: ImportMoneyEffect(dst->As(), reinterpret_cast(src)); break; - case MiscEntityType::CrashedVehicleParticle: + case RCT12MiscEntityType::CrashedVehicleParticle: break; - case MiscEntityType::ExplosionCloud: + case RCT12MiscEntityType::ExplosionCloud: break; - case MiscEntityType::CrashSplash: + case RCT12MiscEntityType::CrashSplash: break; - case MiscEntityType::ExplosionFlare: + case RCT12MiscEntityType::ExplosionFlare: break; - case MiscEntityType::JumpingFountainWater: + case RCT12MiscEntityType::JumpingFountainWater: ImportJumpingFountainWater( dst->As(), reinterpret_cast(src)); break; - case MiscEntityType::Balloon: + case RCT12MiscEntityType::Balloon: ImportBalloon(dst->As(), reinterpret_cast(src)); break; - case MiscEntityType::Duck: + case RCT12MiscEntityType::Duck: ImportDuck(dst->As(), reinterpret_cast(src)); break; default: @@ -1793,6 +1792,7 @@ private: dst->Iteration = src->iteration; dst->NumTicksAlive = src->num_ticks_alive; dst->frame = src->frame; + dst->FountainType = JumpingFountainType::Water; } void ImportBalloon(Balloon* dst, RCT12SpriteBalloon* src) diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index a42485c035..06f79b65d4 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -85,8 +85,6 @@ constexpr const uint16_t RCT12_PEEP_SPAWN_UNDEFINED = 0xFFFF; constexpr const uint16_t RCT12VehicleTrackDirectionMask = 0b0000000000000011; constexpr const uint16_t RCT12VehicleTrackTypeMask = 0b1111111111111100; -enum class SpriteIdentifier : uint8_t; - enum class RCT12TrackDesignVersion : uint8_t { TD4, @@ -692,9 +690,32 @@ enum class RCT12EntityLinkListOffset : uint8_t Vehicle = 5 * sizeof(uint16_t), }; +enum class RCT12SpriteIdentifier : uint8_t +{ + Vehicle = 0, + Peep = 1, + Misc = 2, + Litter = 3, + Null = 255 +}; + +enum class RCT12MiscEntityType : uint8_t +{ + SteamParticle, + MoneyEffect, + CrashedVehicleParticle, + ExplosionCloud, + CrashSplash, + ExplosionFlare, + JumpingFountainWater, + Balloon, + Duck, + JumpingFountainSnow +}; + struct RCT12SpriteBase { - SpriteIdentifier sprite_identifier; // 0x00 + RCT12SpriteIdentifier sprite_identifier; // 0x00 uint8_t type; // 0x01 uint16_t next_in_quadrant; // 0x02 uint16_t next; // 0x04 diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 0c7bb0af68..fa4670ceab 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1029,17 +1029,17 @@ constexpr RCT12EntityLinkListOffset GetRCT2LinkListOffset(const SpriteBase* src) return output; } -constexpr SpriteIdentifier GetRCT2SpriteIdentifier(const SpriteBase* src) +constexpr RCT12SpriteIdentifier GetRCT2SpriteIdentifier(const SpriteBase* src) { - SpriteIdentifier output = SpriteIdentifier::Null; + RCT12SpriteIdentifier output = RCT12SpriteIdentifier::Null; switch (src->Type) { case EntityType::Vehicle: - output = SpriteIdentifier::Vehicle; + output = RCT12SpriteIdentifier::Vehicle; break; case EntityType::Guest: case EntityType::Staff: - output = SpriteIdentifier::Peep; + output = RCT12SpriteIdentifier::Peep; break; case EntityType::SteamParticle: case EntityType::MoneyEffect: @@ -1050,10 +1050,10 @@ constexpr SpriteIdentifier GetRCT2SpriteIdentifier(const SpriteBase* src) case EntityType::JumpingFountain: case EntityType::Balloon: case EntityType::Duck: - output = SpriteIdentifier::Misc; + output = RCT12SpriteIdentifier::Misc; break; case EntityType::Litter: - output = SpriteIdentifier::Litter; + output = RCT12SpriteIdentifier::Litter; break; default: break; @@ -1333,14 +1333,14 @@ void S6Exporter::ExportEntityPeep(RCT2SpritePeep* dst, const Peep* src) template<> void S6Exporter::ExportEntity(RCT12SpriteSteamParticle* dst, const SteamParticle* src) { ExportEntityCommonProperties(dst, src); - dst->type = EnumValue(src->SubType); + dst->type = EnumValue(RCT12MiscEntityType::SteamParticle); dst->time_to_move = src->time_to_move; dst->frame = src->frame; } template<> void S6Exporter::ExportEntity(RCT12SpriteMoneyEffect* dst, const MoneyEffect* src) { ExportEntityCommonProperties(dst, src); - dst->type = EnumValue(src->SubType); + dst->type = EnumValue(RCT12MiscEntityType::MoneyEffect); dst->move_delay = src->MoveDelay; dst->num_movements = src->NumMovements; dst->vertical = src->Vertical; @@ -1351,7 +1351,7 @@ template<> void S6Exporter::ExportEntity(RCT12SpriteMoneyEffect* dst, const Mone template<> void S6Exporter::ExportEntity(RCT12SpriteCrashedVehicleParticle* dst, const VehicleCrashParticle* src) { ExportEntityCommonProperties(dst, src); - dst->type = EnumValue(src->SubType); + dst->type = EnumValue(RCT12MiscEntityType::CrashedVehicleParticle); dst->frame = src->frame; dst->time_to_live = src->time_to_live; dst->frame = src->frame; @@ -1368,7 +1368,9 @@ template<> void S6Exporter::ExportEntity(RCT12SpriteCrashedVehicleParticle* dst, template<> void S6Exporter::ExportEntity(RCT12SpriteJumpingFountain* dst, const JumpingFountain* src) { ExportEntityCommonProperties(dst, src); - dst->type = EnumValue(src->SubType); + dst->type = EnumValue( + src->FountainType == JumpingFountainType::Snow ? RCT12MiscEntityType::JumpingFountainSnow + : RCT12MiscEntityType::JumpingFountainWater); dst->num_ticks_alive = src->NumTicksAlive; dst->frame = src->frame; dst->fountain_flags = src->FountainFlags; @@ -1380,7 +1382,7 @@ template<> void S6Exporter::ExportEntity(RCT12SpriteJumpingFountain* dst, const template<> void S6Exporter::ExportEntity(RCT12SpriteBalloon* dst, const Balloon* src) { ExportEntityCommonProperties(dst, src); - dst->type = EnumValue(src->SubType); + dst->type = EnumValue(RCT12MiscEntityType::Balloon); dst->popped = src->popped; dst->time_to_move = src->time_to_move; dst->frame = src->frame; @@ -1389,7 +1391,7 @@ template<> void S6Exporter::ExportEntity(RCT12SpriteBalloon* dst, const Balloon* template<> void S6Exporter::ExportEntity(RCT12SpriteDuck* dst, const Duck* src) { ExportEntityCommonProperties(dst, src); - dst->type = EnumValue(src->SubType); + dst->type = EnumValue(RCT12MiscEntityType::Duck); dst->frame = src->frame; dst->target_x = src->target_x; dst->target_y = src->target_y; @@ -1398,19 +1400,19 @@ template<> void S6Exporter::ExportEntity(RCT12SpriteDuck* dst, const Duck* src) template<> void S6Exporter::ExportEntity(RCT12SpriteParticle* dst, const ExplosionCloud* src) { ExportEntityCommonProperties(dst, src); - dst->type = EnumValue(src->SubType); + dst->type = EnumValue(RCT12MiscEntityType::ExplosionCloud); dst->frame = src->frame; } template<> void S6Exporter::ExportEntity(RCT12SpriteParticle* dst, const ExplosionFlare* src) { ExportEntityCommonProperties(dst, src); - dst->type = EnumValue(src->SubType); + dst->type = EnumValue(RCT12MiscEntityType::ExplosionFlare); dst->frame = src->frame; } template<> void S6Exporter::ExportEntity(RCT12SpriteParticle* dst, const CrashSplashParticle* src) { ExportEntityCommonProperties(dst, src); - dst->type = EnumValue(src->SubType); + dst->type = EnumValue(RCT12MiscEntityType::CrashSplash); dst->frame = src->frame; } @@ -1428,7 +1430,7 @@ void S6Exporter::ExportEntities() { auto& entity = _s6.sprites[i]; std::memset(&entity, 0, sizeof(entity)); - entity.unknown.sprite_identifier = SpriteIdentifier::Null; + entity.unknown.sprite_identifier = RCT12SpriteIdentifier::Null; entity.unknown.sprite_index = i; entity.unknown.linked_list_type_offset = RCT12EntityLinkListOffset::Free; } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 2f73fea4c1..602d4b4dde 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1012,7 +1012,7 @@ public: uint16_t numRiders = 0; for (const auto& sprite : _s6.sprites) { - if (sprite.unknown.sprite_identifier == SpriteIdentifier::Peep) + if (sprite.unknown.sprite_identifier == RCT12SpriteIdentifier::Peep) { if (sprite.peep.current_ride == rideIndex && (static_cast(sprite.peep.state) == PeepState::OnRide @@ -1337,19 +1337,19 @@ public: std::memset(&dst->pad_00, 0, sizeof(rct_sprite)); switch (src->unknown.sprite_identifier) { - case SpriteIdentifier::Null: + case RCT12SpriteIdentifier::Null: ImportSpriteCommonProperties(reinterpret_cast(dst), &src->unknown); break; - case SpriteIdentifier::Vehicle: + case RCT12SpriteIdentifier::Vehicle: ImportSpriteVehicle(&dst->vehicle, &src->vehicle); break; - case SpriteIdentifier::Peep: + case RCT12SpriteIdentifier::Peep: ImportSpritePeep(&dst->peep, &src->peep); break; - case SpriteIdentifier::Misc: + case RCT12SpriteIdentifier::Misc: ImportSpriteMisc(&dst->misc, &src->unknown); break; - case SpriteIdentifier::Litter: + case RCT12SpriteIdentifier::Litter: ImportSpriteLitter(&dst->litter, &src->litter); break; default: @@ -1582,10 +1582,9 @@ public: void ImportSpriteMisc(MiscEntity* cdst, const RCT12SpriteBase* csrc) { ImportSpriteCommonProperties(cdst, csrc); - cdst->SubType = MiscEntityType(csrc->type); - switch (cdst->SubType) + switch (RCT12MiscEntityType(csrc->type)) { - case MiscEntityType::SteamParticle: + case RCT12MiscEntityType::SteamParticle: { auto src = static_cast(csrc); auto dst = static_cast(cdst); @@ -1593,7 +1592,7 @@ public: dst->frame = src->frame; break; } - case MiscEntityType::MoneyEffect: + case RCT12MiscEntityType::MoneyEffect: { auto src = static_cast(csrc); auto dst = static_cast(cdst); @@ -1605,7 +1604,7 @@ public: dst->Wiggle = src->wiggle; break; } - case MiscEntityType::CrashedVehicleParticle: + case RCT12MiscEntityType::CrashedVehicleParticle: { auto src = static_cast(csrc); auto dst = static_cast(cdst); @@ -1623,17 +1622,17 @@ public: dst->acceleration_z = src->acceleration_z; break; } - case MiscEntityType::ExplosionCloud: - case MiscEntityType::ExplosionFlare: - case MiscEntityType::CrashSplash: + case RCT12MiscEntityType::ExplosionCloud: + case RCT12MiscEntityType::ExplosionFlare: + case RCT12MiscEntityType::CrashSplash: { auto src = static_cast(csrc); auto dst = static_cast(cdst); dst->frame = src->frame; break; } - case MiscEntityType::JumpingFountainWater: - case MiscEntityType::JumpingFountainSnow: + case RCT12MiscEntityType::JumpingFountainWater: + case RCT12MiscEntityType::JumpingFountainSnow: { auto* src = static_cast(csrc); auto* dst = static_cast(cdst); @@ -1643,9 +1642,12 @@ public: dst->TargetX = src->target_x; dst->TargetY = src->target_y; dst->Iteration = src->iteration; + dst->FountainType = RCT12MiscEntityType(src->type) == RCT12MiscEntityType::JumpingFountainSnow + ? JumpingFountainType::Snow + : JumpingFountainType::Water; break; } - case MiscEntityType::Balloon: + case RCT12MiscEntityType::Balloon: { auto src = static_cast(csrc); auto dst = static_cast(cdst); @@ -1655,7 +1657,7 @@ public: dst->colour = src->colour; break; } - case MiscEntityType::Duck: + case RCT12MiscEntityType::Duck: { auto src = static_cast(csrc); auto dst = static_cast(cdst); @@ -1666,7 +1668,7 @@ public: break; } default: - log_warning("Misc. sprite type %d can not be imported.", cdst->SubType); + log_warning("Misc. sprite type %d can not be imported.", csrc->type); break; } } @@ -1683,10 +1685,10 @@ public: EntityType output = EntityType::Null; switch (src->sprite_identifier) { - case SpriteIdentifier::Vehicle: + case RCT12SpriteIdentifier::Vehicle: output = EntityType::Vehicle; break; - case SpriteIdentifier::Peep: + case RCT12SpriteIdentifier::Peep: if (PeepType(static_cast(src)->peep_type) == PeepType::Guest) { output = EntityType::Guest; @@ -1696,43 +1698,43 @@ public: output = EntityType::Staff; } break; - case SpriteIdentifier::Misc: + case RCT12SpriteIdentifier::Misc: - switch (MiscEntityType(src->type)) + switch (RCT12MiscEntityType(src->type)) { - case MiscEntityType::SteamParticle: + case RCT12MiscEntityType::SteamParticle: output = EntityType::SteamParticle; break; - case MiscEntityType::MoneyEffect: + case RCT12MiscEntityType::MoneyEffect: output = EntityType::MoneyEffect; break; - case MiscEntityType::CrashedVehicleParticle: + case RCT12MiscEntityType::CrashedVehicleParticle: output = EntityType::CrashedVehicleParticle; break; - case MiscEntityType::ExplosionCloud: + case RCT12MiscEntityType::ExplosionCloud: output = EntityType::ExplosionCloud; break; - case MiscEntityType::CrashSplash: + case RCT12MiscEntityType::CrashSplash: output = EntityType::CrashSplash; break; - case MiscEntityType::ExplosionFlare: + case RCT12MiscEntityType::ExplosionFlare: output = EntityType::ExplosionFlare; break; - case MiscEntityType::JumpingFountainWater: - case MiscEntityType::JumpingFountainSnow: + case RCT12MiscEntityType::JumpingFountainWater: + case RCT12MiscEntityType::JumpingFountainSnow: output = EntityType::JumpingFountain; break; - case MiscEntityType::Balloon: + case RCT12MiscEntityType::Balloon: output = EntityType::Balloon; break; - case MiscEntityType::Duck: + case RCT12MiscEntityType::Duck: output = EntityType::Duck; break; default: break; } break; - case SpriteIdentifier::Litter: + case RCT12SpriteIdentifier::Litter: output = EntityType::Litter; break; default: diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index ed8680f580..c5be97c9db 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -7244,7 +7244,6 @@ static void steam_particle_create(const CoordsXYZ& coords) steam->sprite_width = 20; steam->sprite_height_negative = 18; steam->sprite_height_positive = 16; - steam->SubType = MiscEntityType::SteamParticle; steam->frame = 256; steam->time_to_move = 0; steam->MoveTo(coords); diff --git a/src/openrct2/world/Balloon.cpp b/src/openrct2/world/Balloon.cpp index d2fe6239a7..cb62540a30 100644 --- a/src/openrct2/world/Balloon.cpp +++ b/src/openrct2/world/Balloon.cpp @@ -81,13 +81,9 @@ void Balloon::Pop() void create_balloon(const CoordsXYZ& balloonPos, int32_t colour, bool isPopped) { - auto* sprite = CreateEntity(); - if (sprite == nullptr) - return; - sprite->SubType = MiscEntityType::Balloon; - auto balloon = sprite->As(); + auto* balloon = CreateEntity(); if (balloon == nullptr) - return; // can never happen + return; balloon->sprite_width = 13; balloon->sprite_height_negative = 22; diff --git a/src/openrct2/world/Duck.cpp b/src/openrct2/world/Duck.cpp index 034a025f82..bdab6ff7ba 100644 --- a/src/openrct2/world/Duck.cpp +++ b/src/openrct2/world/Duck.cpp @@ -280,8 +280,8 @@ uint32_t Duck::GetFrameImage(int32_t direction) const void create_duck(const CoordsXY& pos) { - auto* sprite = CreateEntity(); - if (sprite == nullptr) + auto* duck = CreateEntity(); + if (duck == nullptr) return; CoordsXY targetPos = pos; @@ -290,10 +290,6 @@ void create_duck(const CoordsXY& pos) targetPos.x += offsetXY; targetPos.y += offsetXY; - sprite->SubType = MiscEntityType::Duck; - auto duck = sprite->As(); - if (duck == nullptr) - return; // can never happen duck->sprite_width = 9; duck->sprite_height_negative = 12; duck->sprite_height_positive = 9; diff --git a/src/openrct2/world/Fountain.cpp b/src/openrct2/world/Fountain.cpp index 01b7f65d66..c72c7cac78 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -75,7 +75,7 @@ template<> bool SpriteBase::Is() const return Type == EntityType::JumpingFountain; } -void JumpingFountain::StartAnimation(const int32_t newType, const CoordsXY& newLoc, const TileElement* tileElement) +void JumpingFountain::StartAnimation(const JumpingFountainType newType, const CoordsXY& newLoc, const TileElement* tileElement) { int32_t randomIndex; auto newZ = tileElement->GetBaseZ(); @@ -125,7 +125,8 @@ void JumpingFountain::StartAnimation(const int32_t newType, const CoordsXY& newL } void JumpingFountain::Create( - const int32_t newType, const CoordsXYZ& newLoc, const int32_t direction, const int32_t newFlags, const int32_t iteration) + const JumpingFountainType newType, const CoordsXYZ& newLoc, const int32_t direction, const int32_t newFlags, + const int32_t iteration) { auto* jumpingFountain = CreateEntity(); if (jumpingFountain != nullptr) @@ -137,8 +138,7 @@ void JumpingFountain::Create( jumpingFountain->sprite_height_negative = 36; jumpingFountain->sprite_height_positive = 12; jumpingFountain->MoveTo(newLoc); - jumpingFountain->SubType = newType == JUMPING_FOUNTAIN_TYPE_SNOW ? MiscEntityType::JumpingFountainSnow - : MiscEntityType::JumpingFountainWater; + jumpingFountain->FountainType = newType; jumpingFountain->NumTicksAlive = 0; jumpingFountain->frame = 0; } @@ -159,9 +159,9 @@ void JumpingFountain::Update() Invalidate(); frame++; - switch (SubType) + switch (FountainType) { - case MiscEntityType::JumpingFountainWater: + case JumpingFountainType::Water: if (frame == 11 && (FountainFlags & FOUNTAIN_FLAG::FAST)) { AdvanceAnimation(); @@ -171,7 +171,7 @@ void JumpingFountain::Update() AdvanceAnimation(); } break; - case MiscEntityType::JumpingFountainSnow: + case JumpingFountainType::Snow: if (frame == 16) { AdvanceAnimation(); @@ -187,16 +187,14 @@ void JumpingFountain::Update() } } -int32_t JumpingFountain::GetType() const +JumpingFountainType JumpingFountain::GetType() const { - const int32_t fountainType = SubType == MiscEntityType::JumpingFountainSnow ? JUMPING_FOUNTAIN_TYPE_SNOW - : JUMPING_FOUNTAIN_TYPE_WATER; - return fountainType; + return FountainType; } void JumpingFountain::AdvanceAnimation() { - const int32_t newType = GetType(); + const JumpingFountainType newType = GetType(); const int32_t direction = (sprite_direction >> 3) & 7; const CoordsXY newLoc = CoordsXY{ x, y } + CoordsDirectionDelta[direction]; @@ -240,10 +238,10 @@ void JumpingFountain::AdvanceAnimation() Random({ newLoc, z }, availableDirections); } -bool JumpingFountain::IsJumpingFountain(const int32_t newType, const CoordsXYZ& newLoc) +bool JumpingFountain::IsJumpingFountain(const JumpingFountainType newType, const CoordsXYZ& newLoc) { - const int32_t pathBitFlagMask = newType == JUMPING_FOUNTAIN_TYPE_SNOW ? PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW - : PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER; + const int32_t pathBitFlagMask = newType == JumpingFountainType::Snow ? PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW + : PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER; TileElement* tileElement = map_get_first_element_at(newLoc); if (tileElement == nullptr) @@ -332,7 +330,7 @@ void JumpingFountain::Split(const CoordsXYZ& newLoc, int32_t availableDirections { if (Iteration < 3) { - const int32_t newType = GetType(); + const auto newType = GetType(); int32_t direction = ((sprite_direction >> 3) ^ 2) << 1; availableDirections &= ~(1 << direction); availableDirections &= ~(1 << (direction + 1)); @@ -370,7 +368,7 @@ void JumpingFountain::Random(const CoordsXYZ& newLoc, int32_t availableDirection void JumpingFountain::CreateNext(const CoordsXYZ& newLoc, int32_t direction) const { - const int32_t newType = GetType(); + const auto newType = GetType(); int32_t newFlags = FountainFlags & ~FOUNTAIN_FLAG::DIRECTION; if (direction & 1) { diff --git a/src/openrct2/world/Fountain.h b/src/openrct2/world/Fountain.h index 2454272282..5744817d89 100644 --- a/src/openrct2/world/Fountain.h +++ b/src/openrct2/world/Fountain.h @@ -13,35 +13,36 @@ #include "Map.h" #include "SpriteBase.h" +enum class JumpingFountainType : uint8_t +{ + Water, + Snow +}; + struct JumpingFountain : MiscEntity { static constexpr auto cEntityType = EntityType::JumpingFountain; + JumpingFountainType FountainType; uint8_t NumTicksAlive; uint8_t FountainFlags; int16_t TargetX; int16_t TargetY; uint16_t Iteration; - void Update(); - static void StartAnimation(int32_t newType, const CoordsXY& newLoc, const TileElement* tileElement); + static void StartAnimation(JumpingFountainType newType, const CoordsXY& newLoc, const TileElement* tileElement); private: - int32_t GetType() const; + JumpingFountainType GetType() const; void AdvanceAnimation(); void GoToEdge(const CoordsXYZ& newLoc, int32_t availableDirections) const; void Bounce(const CoordsXYZ& newLoc, int32_t availableDirections); void Split(const CoordsXYZ& newLoc, int32_t availableDirections) const; void Random(const CoordsXYZ& newLoc, int32_t availableDirections) const; void CreateNext(const CoordsXYZ& newLoc, int32_t direction) const; - static void Create(int32_t newType, const CoordsXYZ& newLoc, int32_t direction, int32_t newFlags, int32_t iteration); - static bool IsJumpingFountain(int32_t newType, const CoordsXYZ& newLoc); -}; - -enum -{ - JUMPING_FOUNTAIN_TYPE_WATER, - JUMPING_FOUNTAIN_TYPE_SNOW + static void Create( + JumpingFountainType newType, const CoordsXYZ& newLoc, int32_t direction, int32_t newFlags, int32_t iteration); + static bool IsJumpingFountain(JumpingFountainType newType, const CoordsXYZ& newLoc); }; namespace FOUNTAIN_FLAG diff --git a/src/openrct2/world/MoneyEffect.cpp b/src/openrct2/world/MoneyEffect.cpp index fca0c2a082..ac4eb97400 100644 --- a/src/openrct2/world/MoneyEffect.cpp +++ b/src/openrct2/world/MoneyEffect.cpp @@ -42,7 +42,6 @@ void MoneyEffect::CreateAt(money32 value, const CoordsXYZ& effectPos, bool verti moneyEffect->sprite_height_negative = 20; moneyEffect->sprite_height_positive = 30; moneyEffect->MoveTo(effectPos); - moneyEffect->SubType = MiscEntityType::MoneyEffect; moneyEffect->NumMovements = 0; moneyEffect->MoveDelay = 0; diff --git a/src/openrct2/world/Particle.cpp b/src/openrct2/world/Particle.cpp index 420eb13afc..03a7ebc906 100644 --- a/src/openrct2/world/Particle.cpp +++ b/src/openrct2/world/Particle.cpp @@ -38,7 +38,6 @@ void crashed_vehicle_particle_create(rct_vehicle_colour colours, const CoordsXYZ sprite->sprite_height_negative = 8; sprite->sprite_height_positive = 8; sprite->MoveTo(vehiclePos); - sprite->SubType = MiscEntityType::CrashedVehicleParticle; sprite->frame = (scenario_rand() & 0xFF) * 12; sprite->time_to_live = (scenario_rand() & 0x7F) + 140; @@ -126,7 +125,6 @@ void crash_splash_create(const CoordsXYZ& splashPos) sprite->sprite_height_negative = 51; sprite->sprite_height_positive = 16; sprite->MoveTo(splashPos + CoordsXYZ{ 0, 0, 3 }); - sprite->SubType = MiscEntityType::CrashSplash; sprite->frame = 0; } } diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 5240a7fdff..9d898ea5e1 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -85,11 +85,11 @@ void scenery_update_tile(const CoordsXY& sceneryPos) { if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER) { - JumpingFountain::StartAnimation(JUMPING_FOUNTAIN_TYPE_WATER, sceneryPos, tileElement); + JumpingFountain::StartAnimation(JumpingFountainType::Water, sceneryPos, tileElement); } else if (sceneryEntry->path_bit.flags & PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW) { - JumpingFountain::StartAnimation(JUMPING_FOUNTAIN_TYPE_SNOW, sceneryPos, tileElement); + JumpingFountain::StartAnimation(JumpingFountainType::Snow, sceneryPos, tileElement); } } } diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index f0747d4c95..74e5114d7f 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -78,9 +78,9 @@ template<> bool SpriteBase::Is() const return Type == EntityType::Litter; } -template<> bool SpriteBase::Is() const +constexpr bool EntityTypeIsMiscEntity(const EntityType type) { - switch (Type) + switch (type) { case EntityType::SteamParticle: case EntityType::MoneyEffect: @@ -97,6 +97,11 @@ template<> bool SpriteBase::Is() const } } +template<> bool SpriteBase::Is() const +{ + return EntityTypeIsMiscEntity(Type); +} + template<> bool SpriteBase::Is() const { return Type == EntityType::SteamParticle; @@ -195,35 +200,6 @@ void SpriteBase::Invalidate() viewports_invalidate(sprite_left, sprite_top, sprite_right, sprite_bottom, maxZoom); } -constexpr SpriteIdentifier EntityTypeToSpriteIdentifier(const EntityType type) -{ - switch (type) - { - case EntityType::Vehicle: - return SpriteIdentifier::Vehicle; - case EntityType::Guest: - return SpriteIdentifier::Peep; - case EntityType::Staff: - return SpriteIdentifier::Peep; - case EntityType::Litter: - return SpriteIdentifier::Litter; - case EntityType::SteamParticle: - case EntityType::MoneyEffect: - case EntityType::CrashedVehicleParticle: - case EntityType::ExplosionCloud: - case EntityType::CrashSplash: - case EntityType::ExplosionFlare: - case EntityType::JumpingFountain: - case EntityType::Balloon: - case EntityType::Duck: - return SpriteIdentifier::Misc; - case EntityType::Null: - case EntityType::Count: - return SpriteIdentifier::Null; - } - return SpriteIdentifier::Null; -} - void RebuildEntityLists() { for (auto& list : gEntityLists) @@ -444,8 +420,7 @@ rct_sprite* create_sprite(EntityType type) return nullptr; } - auto spriteIdentifier = EntityTypeToSpriteIdentifier(type); - if (spriteIdentifier == SpriteIdentifier::Misc) + if (EntityTypeIsMiscEntity(type)) { // Misc sprites are commonly used for effects, if there are less than MAX_MISC_SPRITES // free it will fail to keep slots for more relevant sprites. @@ -519,7 +494,6 @@ void sprite_misc_explosion_cloud_create(const CoordsXYZ& cloudPos) sprite->sprite_height_negative = 32; sprite->sprite_height_positive = 34; sprite->MoveTo(cloudPos + CoordsXYZ{ 0, 0, 4 }); - sprite->SubType = MiscEntityType::ExplosionCloud; sprite->frame = 0; } } @@ -551,7 +525,6 @@ void sprite_misc_explosion_flare_create(const CoordsXYZ& flarePos) sprite->sprite_height_negative = 85; sprite->sprite_height_positive = 8; sprite->MoveTo(flarePos + CoordsXYZ{ 0, 0, 4 }); - sprite->SubType = MiscEntityType::ExplosionFlare; sprite->frame = 0; } } diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index b53f96b62a..406b83f0e8 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -17,15 +17,6 @@ #include "Fountain.h" #include "SpriteBase.h" -enum class SpriteIdentifier : uint8_t -{ - Vehicle = 0, - Peep = 1, - Misc = 2, - Litter = 3, - Null = 255 -}; - enum LitterType : uint8_t; struct Litter : SpriteBase @@ -170,20 +161,6 @@ struct rct_sprite_checksum #pragma pack(pop) -enum class MiscEntityType : uint8_t -{ - SteamParticle, - MoneyEffect, - CrashedVehicleParticle, - ExplosionCloud, - CrashSplash, - ExplosionFlare, - JumpingFountainWater, - Balloon, - Duck, - JumpingFountainSnow -}; - enum { SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE = 1 << 7, diff --git a/src/openrct2/world/SpriteBase.h b/src/openrct2/world/SpriteBase.h index 75231355ec..a6ce07253c 100644 --- a/src/openrct2/world/SpriteBase.h +++ b/src/openrct2/world/SpriteBase.h @@ -75,9 +75,7 @@ struct SpriteBase } }; -enum class MiscEntityType : uint8_t; struct MiscEntity : SpriteBase { - MiscEntityType SubType; uint16_t frame; }; diff --git a/test/tests/S6ImportExportTests.cpp b/test/tests/S6ImportExportTests.cpp index a3e9ab94f7..cad5605a65 100644 --- a/test/tests/S6ImportExportTests.cpp +++ b/test/tests/S6ImportExportTests.cpp @@ -347,13 +347,13 @@ static void CompareSpriteDataLitter(const Litter& left, const Litter& right) static void CompareSpriteDataSteamParticle(const SteamParticle& left, const SteamParticle& right) { - COMPARE_FIELD(SubType); + COMPARE_FIELD(frame); COMPARE_FIELD(time_to_move); } static void CompareSpriteDataMoneyEffect(const MoneyEffect& left, const MoneyEffect& right) { - COMPARE_FIELD(SubType); + COMPARE_FIELD(frame); COMPARE_FIELD(MoveDelay); COMPARE_FIELD(NumMovements); COMPARE_FIELD(Vertical); @@ -364,7 +364,7 @@ static void CompareSpriteDataMoneyEffect(const MoneyEffect& left, const MoneyEff static void CompareSpriteDataCrashedVehicleParticle(const VehicleCrashParticle& left, const VehicleCrashParticle& right) { - COMPARE_FIELD(SubType); + COMPARE_FIELD(frame); COMPARE_FIELD(time_to_live); for (size_t i = 0; i < std::size(left.colour); i++) { @@ -381,17 +381,18 @@ static void CompareSpriteDataCrashedVehicleParticle(const VehicleCrashParticle& static void CompareSpriteDataJumpingFountain(const JumpingFountain& left, const JumpingFountain& right) { - COMPARE_FIELD(SubType); + COMPARE_FIELD(frame); COMPARE_FIELD(NumTicksAlive); COMPARE_FIELD(FountainFlags); COMPARE_FIELD(TargetX); COMPARE_FIELD(TargetY); COMPARE_FIELD(Iteration); + COMPARE_FIELD(FountainType); } static void CompareSpriteDataBalloon(const Balloon& left, const Balloon& right) { - COMPARE_FIELD(SubType); + COMPARE_FIELD(frame); COMPARE_FIELD(popped); COMPARE_FIELD(time_to_move); COMPARE_FIELD(colour); @@ -399,7 +400,7 @@ static void CompareSpriteDataBalloon(const Balloon& left, const Balloon& right) static void CompareSpriteDataDuck(const Duck& left, const Duck& right) { - COMPARE_FIELD(SubType); + COMPARE_FIELD(frame); COMPARE_FIELD(target_x); COMPARE_FIELD(target_y); COMPARE_FIELD(state); @@ -443,7 +444,7 @@ static void CompareSpriteData(const rct_sprite& left, const rct_sprite& right) case EntityType::ExplosionCloud: case EntityType::CrashSplash: case EntityType::ExplosionFlare: - COMPARE_FIELD(misc.SubType); + COMPARE_FIELD(misc.frame); break; case EntityType::Null: break;