From 816bf827abb81bbbedc4983b782d757314ac738f Mon Sep 17 00:00:00 2001 From: Duncan Date: Thu, 13 May 2021 07:56:24 +0100 Subject: [PATCH] Split off a number of entity files into separate headers (#14629) * Split off a number of entity files into seperate headers * Get compiling * Update copyright date --- src/openrct2/actions/BalloonPressAction.cpp | 3 +- src/openrct2/actions/GameAction.cpp | 2 +- src/openrct2/libopenrct2.vcxproj | 5 + src/openrct2/paint/sprite/Paint.Litter.cpp | 2 +- src/openrct2/world/Balloon.cpp | 7 +- src/openrct2/world/Balloon.h | 30 +++++ src/openrct2/world/Duck.cpp | 1 + src/openrct2/world/Duck.h | 48 +++++++ src/openrct2/world/Litter.h | 45 +++++++ src/openrct2/world/MoneyEffect.cpp | 1 + src/openrct2/world/MoneyEffect.h | 32 +++++ src/openrct2/world/Park.cpp | 2 +- src/openrct2/world/Particle.cpp | 1 + src/openrct2/world/Particle.h | 43 +++++++ src/openrct2/world/Sprite.h | 134 +------------------- 15 files changed, 218 insertions(+), 138 deletions(-) create mode 100644 src/openrct2/world/Balloon.h create mode 100644 src/openrct2/world/Duck.h create mode 100644 src/openrct2/world/Litter.h create mode 100644 src/openrct2/world/MoneyEffect.h create mode 100644 src/openrct2/world/Particle.h diff --git a/src/openrct2/actions/BalloonPressAction.cpp b/src/openrct2/actions/BalloonPressAction.cpp index 474722db35..85f5730295 100644 --- a/src/openrct2/actions/BalloonPressAction.cpp +++ b/src/openrct2/actions/BalloonPressAction.cpp @@ -9,7 +9,8 @@ #include "BalloonPressAction.h" -#include "../world/Sprite.h" +#include "../world/Balloon.h" +#include "../world/Entity.h" #include "GameAction.h" BalloonPressAction::BalloonPressAction(uint16_t spriteIndex) diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index ccad0e2543..adc8606a62 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -23,9 +23,9 @@ #include "../scripting/ScriptEngine.h" #include "../ui/UiContext.h" #include "../ui/WindowManager.h" +#include "../world/MoneyEffect.h" #include "../world/Park.h" #include "../world/Scenery.h" -#include "../world/Sprite.h" #include #include diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index af5d57dde2..932b7699c4 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -436,20 +436,25 @@ + + + + + diff --git a/src/openrct2/paint/sprite/Paint.Litter.cpp b/src/openrct2/paint/sprite/Paint.Litter.cpp index d1baf68e6d..6b35a5050e 100644 --- a/src/openrct2/paint/sprite/Paint.Litter.cpp +++ b/src/openrct2/paint/sprite/Paint.Litter.cpp @@ -8,7 +8,7 @@ *****************************************************************************/ #include "../../interface/Viewport.h" -#include "../../world/Sprite.h" +#include "../../world/Litter.h" #include "../Paint.h" #include "Paint.Sprite.h" diff --git a/src/openrct2/world/Balloon.cpp b/src/openrct2/world/Balloon.cpp index cb62540a30..0292601703 100644 --- a/src/openrct2/world/Balloon.cpp +++ b/src/openrct2/world/Balloon.cpp @@ -7,6 +7,8 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "Balloon.h" + #include "../Game.h" #include "../audio/audio.h" #include "../network/network.h" @@ -94,8 +96,3 @@ void create_balloon(const CoordsXYZ& balloonPos, int32_t colour, bool isPopped) balloon->colour = colour; balloon->popped = (isPopped ? 1 : 0); } - -void balloon_update(Balloon* balloon) -{ - balloon->Update(); -} diff --git a/src/openrct2/world/Balloon.h b/src/openrct2/world/Balloon.h new file mode 100644 index 0000000000..2154782d13 --- /dev/null +++ b/src/openrct2/world/Balloon.h @@ -0,0 +1,30 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "SpriteBase.h" + +class DataSerialiser; +struct CoordsXYZ; + +struct Balloon : MiscEntity +{ + static constexpr auto cEntityType = EntityType::Balloon; + uint16_t popped; + uint8_t time_to_move; + uint8_t colour; + + void Update(); + void Pop(); + void Press(); + void Serialise(DataSerialiser& stream); +}; + +void create_balloon(const CoordsXYZ& balloonPos, int32_t colour, bool isPopped); diff --git a/src/openrct2/world/Duck.cpp b/src/openrct2/world/Duck.cpp index bdab6ff7ba..6fe88bc38a 100644 --- a/src/openrct2/world/Duck.cpp +++ b/src/openrct2/world/Duck.cpp @@ -6,6 +6,7 @@ * * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "Duck.h" #include "../Game.h" #include "../audio/audio.h" diff --git a/src/openrct2/world/Duck.h b/src/openrct2/world/Duck.h new file mode 100644 index 0000000000..c6bfe66b78 --- /dev/null +++ b/src/openrct2/world/Duck.h @@ -0,0 +1,48 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "SpriteBase.h" + +class DataSerialiser; +struct CoordsXY; + +struct Duck : MiscEntity +{ + static constexpr auto cEntityType = EntityType::Duck; + enum class DuckState : uint8_t + { + FlyToWater, + Swim, + Drink, + DoubleDrink, + FlyAway, + }; + int16_t target_x; + int16_t target_y; + DuckState state; + + void Update(); + uint32_t GetFrameImage(int32_t direction) const; + bool IsFlying(); + void Remove(); + void Serialise(DataSerialiser& stream); + +private: + void UpdateFlyToWater(); + void UpdateSwim(); + void UpdateDrink(); + void UpdateDoubleDrink(); + void UpdateFlyAway(); +}; + +void create_duck(const CoordsXY& pos); +void duck_press(Duck* duck); +void duck_remove_all(); diff --git a/src/openrct2/world/Litter.h b/src/openrct2/world/Litter.h new file mode 100644 index 0000000000..d1e9f83883 --- /dev/null +++ b/src/openrct2/world/Litter.h @@ -0,0 +1,45 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "SpriteBase.h" + +class DataSerialiser; +struct CoordsXYZ; +struct CoordsXYZD; + +enum LitterType : uint8_t +{ + LITTER_TYPE_SICK, + LITTER_TYPE_SICK_ALT, + LITTER_TYPE_EMPTY_CAN, + LITTER_TYPE_RUBBISH, + LITTER_TYPE_EMPTY_BURGER_BOX, + LITTER_TYPE_EMPTY_CUP, + LITTER_TYPE_EMPTY_BOX, + LITTER_TYPE_EMPTY_BOTTLE, + LITTER_TYPE_EMPTY_BOWL_RED, + LITTER_TYPE_EMPTY_DRINK_CARTON, + LITTER_TYPE_EMPTY_JUICE_CUP, + LITTER_TYPE_EMPTY_BOWL_BLUE, +}; + +struct Litter : SpriteBase +{ + static constexpr auto cEntityType = EntityType::Litter; + LitterType SubType; + uint32_t creationTick; + void Serialise(DataSerialiser& stream); +}; + +extern const rct_string_id litterNames[12]; + +void litter_create(const CoordsXYZD& litterPos, LitterType type); +void litter_remove_at(const CoordsXYZ& litterPos); diff --git a/src/openrct2/world/MoneyEffect.cpp b/src/openrct2/world/MoneyEffect.cpp index ac4eb97400..6d85aa32e2 100644 --- a/src/openrct2/world/MoneyEffect.cpp +++ b/src/openrct2/world/MoneyEffect.cpp @@ -6,6 +6,7 @@ * * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "MoneyEffect.h" #include "../OpenRCT2.h" #include "../drawing/Drawing.h" diff --git a/src/openrct2/world/MoneyEffect.h b/src/openrct2/world/MoneyEffect.h new file mode 100644 index 0000000000..ba6aa34c81 --- /dev/null +++ b/src/openrct2/world/MoneyEffect.h @@ -0,0 +1,32 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "SpriteBase.h" + +class DataSerialiser; +struct CoordsXYZ; + +struct MoneyEffect : MiscEntity +{ + static constexpr auto cEntityType = EntityType::MoneyEffect; + uint16_t MoveDelay; + uint8_t NumMovements; + uint8_t Vertical; + money32 Value; + int16_t OffsetX; + uint16_t Wiggle; + + static void CreateAt(money32 value, const CoordsXYZ& effectPos, bool vertical); + static void Create(money32 value, const CoordsXYZ& loc); + void Update(); + std::pair GetStringId() const; + void Serialise(DataSerialiser& stream); +}; diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index 896f4205f0..b8731c1ff3 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -36,8 +36,8 @@ #include "../util/Util.h" #include "../windows/Intent.h" #include "Entrance.h" +#include "Litter.h" #include "Map.h" -#include "Sprite.h" #include "Surface.h" #include diff --git a/src/openrct2/world/Particle.cpp b/src/openrct2/world/Particle.cpp index 03a7ebc906..56796c8134 100644 --- a/src/openrct2/world/Particle.cpp +++ b/src/openrct2/world/Particle.cpp @@ -6,6 +6,7 @@ * * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "Particle.h" #include "../audio/audio.h" #include "../paint/sprite/Paint.Sprite.h" diff --git a/src/openrct2/world/Particle.h b/src/openrct2/world/Particle.h new file mode 100644 index 0000000000..68b71cffc4 --- /dev/null +++ b/src/openrct2/world/Particle.h @@ -0,0 +1,43 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../ride/VehicleColour.h" +#include "SpriteBase.h" + +class DataSerialiser; +struct CoordsXYZ; + +struct VehicleCrashParticle : MiscEntity +{ + static constexpr auto cEntityType = EntityType::CrashedVehicleParticle; + uint16_t time_to_live; + uint8_t colour[2]; + uint16_t crashed_sprite_base; + int16_t velocity_x; + int16_t velocity_y; + int16_t velocity_z; + int32_t acceleration_x; + int32_t acceleration_y; + int32_t acceleration_z; + + void Update(); + void Serialise(DataSerialiser& stream); +}; + +struct CrashSplashParticle : MiscEntity +{ + static constexpr auto cEntityType = EntityType::CrashSplash; + void Update(); + void Serialise(DataSerialiser& stream); +}; + +void crashed_vehicle_particle_create(rct_vehicle_colour colours, const CoordsXYZ& vehiclePos); +void crash_splash_create(const CoordsXYZ& splashPos); diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index 7e25723e56..6eb7491ded 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -13,97 +13,17 @@ #include "../common.h" #include "../peep/Peep.h" #include "../ride/Vehicle.h" +#include "Balloon.h" +#include "Duck.h" #include "Entity.h" #include "Fountain.h" +#include "Litter.h" +#include "MoneyEffect.h" +#include "Particle.h" #include "SpriteBase.h" -enum LitterType : uint8_t; class DataSerialiser; -struct Litter : SpriteBase -{ - static constexpr auto cEntityType = EntityType::Litter; - LitterType SubType; - uint32_t creationTick; - void Serialise(DataSerialiser& stream); -}; - -struct Balloon : MiscEntity -{ - static constexpr auto cEntityType = EntityType::Balloon; - uint16_t popped; - uint8_t time_to_move; - uint8_t colour; - - void Update(); - void Pop(); - void Press(); - void Serialise(DataSerialiser& stream); -}; - -struct Duck : MiscEntity -{ - static constexpr auto cEntityType = EntityType::Duck; - enum class DuckState : uint8_t - { - FlyToWater, - Swim, - Drink, - DoubleDrink, - FlyAway, - }; - int16_t target_x; - int16_t target_y; - DuckState state; - - void Update(); - uint32_t GetFrameImage(int32_t direction) const; - bool IsFlying(); - void Remove(); - void Serialise(DataSerialiser& stream); - -private: - void UpdateFlyToWater(); - void UpdateSwim(); - void UpdateDrink(); - void UpdateDoubleDrink(); - void UpdateFlyAway(); -}; - -struct MoneyEffect : MiscEntity -{ - static constexpr auto cEntityType = EntityType::MoneyEffect; - uint16_t MoveDelay; - uint8_t NumMovements; - uint8_t Vertical; - money32 Value; - int16_t OffsetX; - uint16_t Wiggle; - - static void CreateAt(money32 value, const CoordsXYZ& effectPos, bool vertical); - static void Create(money32 value, const CoordsXYZ& loc); - void Update(); - std::pair GetStringId() const; - void Serialise(DataSerialiser& stream); -}; - -struct VehicleCrashParticle : MiscEntity -{ - static constexpr auto cEntityType = EntityType::CrashedVehicleParticle; - uint16_t time_to_live; - uint8_t colour[2]; - uint16_t crashed_sprite_base; - int16_t velocity_x; - int16_t velocity_y; - int16_t velocity_z; - int32_t acceleration_x; - int32_t acceleration_y; - int32_t acceleration_z; - - void Update(); - void Serialise(DataSerialiser& stream); -}; - struct ExplosionFlare : MiscEntity { static constexpr auto cEntityType = EntityType::ExplosionFlare; @@ -118,13 +38,6 @@ struct ExplosionCloud : MiscEntity void Serialise(DataSerialiser& stream); }; -struct CrashSplashParticle : MiscEntity -{ - static constexpr auto cEntityType = EntityType::CrashSplash; - void Update(); - void Serialise(DataSerialiser& stream); -}; - struct SteamParticle : MiscEntity { static constexpr auto cEntityType = EntityType::SteamParticle; @@ -178,22 +91,6 @@ enum SPRITE_FLAGS_PEEP_FLASHING = 1 << 9, // Deprecated: Use sprite_set_flashing/sprite_get_flashing instead. }; -enum LitterType : uint8_t -{ - LITTER_TYPE_SICK, - LITTER_TYPE_SICK_ALT, - LITTER_TYPE_EMPTY_CAN, - LITTER_TYPE_RUBBISH, - LITTER_TYPE_EMPTY_BURGER_BOX, - LITTER_TYPE_EMPTY_CUP, - LITTER_TYPE_EMPTY_BOX, - LITTER_TYPE_EMPTY_BOTTLE, - LITTER_TYPE_EMPTY_BOWL_RED, - LITTER_TYPE_EMPTY_DRINK_CARTON, - LITTER_TYPE_EMPTY_JUICE_CUP, - LITTER_TYPE_EMPTY_BOWL_BLUE, -}; - constexpr const uint32_t SPATIAL_INDEX_SIZE = (MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL) + 1; constexpr const uint32_t SPATIAL_INDEX_LOCATION_NULL = SPATIAL_INDEX_SIZE - 1; @@ -218,31 +115,10 @@ void sprite_clear_all_unused(); void sprite_misc_update_all(); void sprite_set_coordinates(const CoordsXYZ& spritePos, SpriteBase* sprite); void sprite_remove(SpriteBase* sprite); -void litter_create(const CoordsXYZD& litterPos, LitterType type); -void litter_remove_at(const CoordsXYZ& litterPos); uint16_t remove_floating_sprites(); void sprite_misc_explosion_cloud_create(const CoordsXYZ& cloudPos); void sprite_misc_explosion_flare_create(const CoordsXYZ& flarePos); -/////////////////////////////////////////////////////////////// -// Balloon -/////////////////////////////////////////////////////////////// -void create_balloon(const CoordsXYZ& balloonPos, int32_t colour, bool isPopped); -void balloon_update(Balloon* balloon); - -/////////////////////////////////////////////////////////////// -// Duck -/////////////////////////////////////////////////////////////// -void create_duck(const CoordsXY& pos); -void duck_press(Duck* duck); -void duck_remove_all(); - -/////////////////////////////////////////////////////////////// -// Crash particles -/////////////////////////////////////////////////////////////// -void crashed_vehicle_particle_create(rct_vehicle_colour colours, const CoordsXYZ& vehiclePos); -void crash_splash_create(const CoordsXYZ& splashPos); - rct_sprite_checksum sprite_checksum(); void sprite_set_flashing(SpriteBase* sprite, bool flashing);