diff --git a/src/openrct2/object/RideObject.cpp b/src/openrct2/object/RideObject.cpp index f41ac370e1..738e1c9400 100644 --- a/src/openrct2/object/RideObject.cpp +++ b/src/openrct2/object/RideObject.cpp @@ -217,19 +217,15 @@ void RideObject::Load() if (vehicleEntry->car_visual != VEHICLE_VISUAL_RIVER_RAPIDS) { - int32_t b = vehicleEntry->base_num_frames * 32; - - if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES) - b /= 2; - if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_USE_4_ROTATION_FRAMES) - b /= 8; + const uint8_t numRotationFrames = vehicleEntry->GetNumRotationFrames(); + int32_t b = vehicleEntry->base_num_frames * numRotationFrames; image_index += b; if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_GENTLE_SLOPES) { vehicleEntry->gentle_slope_image_id = image_index; - b = vehicleEntry->base_num_frames * 72; + b = vehicleEntry->base_num_frames * ((2 * numRotationFrames) + (2 * NumOrthogonalDirections)); if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES) { b = vehicleEntry->base_num_frames * 16; @@ -240,14 +236,14 @@ void RideObject::Load() if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_STEEP_SLOPES) { vehicleEntry->steep_slope_image_id = image_index; - b = vehicleEntry->base_num_frames * 80; + b = vehicleEntry->base_num_frames * ((2 * numRotationFrames) + (4 * NumOrthogonalDirections)); image_index += b; } if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES) { vehicleEntry->vertical_slope_image_id = image_index; - b = vehicleEntry->base_num_frames * 116; + b = vehicleEntry->base_num_frames * ((3 * numRotationFrames) + (5 * NumOrthogonalDirections)); image_index += b; } @@ -261,7 +257,7 @@ void RideObject::Load() if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_FLAT_BANKED) { vehicleEntry->banked_image_id = image_index; - b = vehicleEntry->base_num_frames * 80; + b = vehicleEntry->base_num_frames * ((2 * numRotationFrames) + (4 * NumOrthogonalDirections)); image_index += b; } @@ -275,7 +271,7 @@ void RideObject::Load() if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS) { vehicleEntry->flat_to_gentle_bank_image_id = image_index; - b = vehicleEntry->base_num_frames * 128; + b = vehicleEntry->base_num_frames * (4 * numRotationFrames); image_index += b; } @@ -296,7 +292,7 @@ void RideObject::Load() if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS) { vehicleEntry->gentle_slope_bank_turn_image_id = image_index; - b = vehicleEntry->base_num_frames * 128; + b = vehicleEntry->base_num_frames * (4 * numRotationFrames); image_index += b; } @@ -325,7 +321,7 @@ void RideObject::Load() { // Same offset as corkscrew vehicleEntry->curved_lift_hill_image_id = image_index; - b = vehicleEntry->base_num_frames * 32; + b = vehicleEntry->base_num_frames * numRotationFrames; image_index += b; } } diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index bbbecea307..cac6fc8bc9 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -410,56 +410,6 @@ enum class MiniGolfAnimation : uint8_t Putt, }; -enum : uint32_t -{ - VEHICLE_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY = 1 - << 0, // Set on powered vehicles that do not slow down when going down a hill. - VEHICLE_ENTRY_FLAG_NO_UPSTOP_WHEELS = 1 << 1, - VEHICLE_ENTRY_FLAG_NO_UPSTOP_BOBSLEIGH = 1 << 2, - VEHICLE_ENTRY_FLAG_MINI_GOLF = 1 << 3, - VEHICLE_ENTRY_FLAG_REVERSER_BOGIE = 1 << 4, - VEHICLE_ENTRY_FLAG_REVERSER_PASSENGER_CAR = 1 << 5, - VEHICLE_ENTRY_FLAG_HAS_INVERTED_SPRITE_SET = 1 << 6, // Set on vehicles that support running inverted for extended periods - // of time, i.e. the Flying, Lay-down and Multi-dimension RCs. - VEHICLE_ENTRY_FLAG_DODGEM_INUSE_LIGHTS = 1 - << 7, // When set the vehicle has an additional frame for when in use. Used only by dodgems. - VEHICLE_ENTRY_FLAG_ALLOW_DOORS_DEPRECATED = 1 << 8, // Not used any more - every vehicle will now work with doors. - VEHICLE_ENTRY_FLAG_ENABLE_TERNARY_COLOUR = 1 << 9, - VEHICLE_ENTRY_FLAG_RECALCULATE_SPRITE_BOUNDS = 1 << 10, // Only used during loading of the objects. - VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES = 1 - << 11, // Instead of the default 32 rotation frames. Only used for boat hire and works only for non sloped sprites. - VEHICLE_ENTRY_FLAG_OVERRIDE_NUM_VERTICAL_FRAMES = 1 - << 12, // Setting this will cause the game to set vehicleEntry->num_vertical_frames to - // vehicleEntry->num_vertical_frames_override, rather than determining it itself. - VEHICLE_ENTRY_FLAG_SPRITE_BOUNDS_INCLUDE_INVERTED_SET = 1 - << 13, // Used together with HAS_INVERTED_SPRITE_SET and RECALCULATE_SPRITE_BOUNDS and includes the inverted sprites - // into the function that recalculates the sprite bounds. - VEHICLE_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES = 1 - << 14, // 16x additional frames for vehicle. A spinning item with additional frames must always face forward to - // load/unload. Spinning without can load/unload at 4 rotations. - VEHICLE_ENTRY_FLAG_LIFT = 1 << 15, - VEHICLE_ENTRY_FLAG_ENABLE_TRIM_COLOUR = 1 << 16, - VEHICLE_ENTRY_FLAG_SWINGING = 1 << 17, - VEHICLE_ENTRY_FLAG_SPINNING = 1 << 18, - VEHICLE_ENTRY_FLAG_POWERED = 1 << 19, - VEHICLE_ENTRY_FLAG_RIDERS_SCREAM = 1 << 20, - VEHICLE_ENTRY_FLAG_SUSPENDED_SWING = 1 << 21, // Suspended swinging coaster, or bobsleigh if SLIDE_SWING is also enabled. - VEHICLE_ENTRY_FLAG_BOAT_HIRE_COLLISION_DETECTION = 1 << 22, - VEHICLE_ENTRY_FLAG_VEHICLE_ANIMATION = 1 << 23, // Set on animated vehicles like the Multi-dimension coaster trains, - // Miniature Railway locomotives and Helicycles. - VEHICLE_ENTRY_FLAG_RIDER_ANIMATION = 1 << 24, // Set when the animation updates rider sprite positions. - VEHICLE_ENTRY_FLAG_WOODEN_WILD_MOUSE_SWING = 1 << 25, - VEHICLE_ENTRY_FLAG_LOADING_WAYPOINTS = 1 - << 26, // Peep loading positions have x and y coordinates. Normal rides just have offsets. - VEHICLE_ENTRY_FLAG_SLIDE_SWING = 1 - << 27, // Set on dingy slides. They have there own swing value calculations and have a different amount of images. - // Also set on bobsleighs together with the SUSPENDED_SWING flag. - VEHICLE_ENTRY_FLAG_CHAIRLIFT = 1 << 28, - VEHICLE_ENTRY_FLAG_WATER_RIDE = 1 << 29, // Set on rides where water would provide continuous propulsion. - VEHICLE_ENTRY_FLAG_GO_KART = 1 << 30, - VEHICLE_ENTRY_FLAG_DODGEM_CAR_PLACEMENT = 1u << 31, -}; - enum { VEHICLE_ENTRY_ANIMATION_NONE, @@ -496,27 +446,6 @@ enum : uint32_t // an individual car on a train }; -enum : uint32_t -{ - VEHICLE_SPRITE_FLAG_FLAT = (1 << 0), - VEHICLE_SPRITE_FLAG_GENTLE_SLOPES = (1 << 1), - VEHICLE_SPRITE_FLAG_STEEP_SLOPES = (1 << 2), - VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES = (1 << 3), - VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES = (1 << 4), - VEHICLE_SPRITE_FLAG_FLAT_BANKED = (1 << 5), - VEHICLE_SPRITE_FLAG_INLINE_TWISTS = (1 << 6), - VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS = (1 << 7), - VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS = (1 << 8), - VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS = (1 << 9), - VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS = (1 << 10), - VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS = (1 << 11), - VEHICLE_SPRITE_FLAG_CORKSCREWS = (1 << 12), - VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION = (1 << 13), - VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL = (1 << 14), - // Used only on lifts (the transport ride), to only use 4 rotation sprites instead of 32. - VEHICLE_SPRITE_FLAG_USE_4_ROTATION_FRAMES = (1 << 15), -}; - enum { VEHICLE_VISUAL_DEFAULT, diff --git a/src/openrct2/ride/VehicleEntry.h b/src/openrct2/ride/VehicleEntry.h index 507969b50a..65c39ca7e9 100644 --- a/src/openrct2/ride/VehicleEntry.h +++ b/src/openrct2/ride/VehicleEntry.h @@ -15,6 +15,77 @@ #include #include +enum : uint32_t +{ + VEHICLE_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY = 1 + << 0, // Set on powered vehicles that do not slow down when going down a hill. + VEHICLE_ENTRY_FLAG_NO_UPSTOP_WHEELS = 1 << 1, + VEHICLE_ENTRY_FLAG_NO_UPSTOP_BOBSLEIGH = 1 << 2, + VEHICLE_ENTRY_FLAG_MINI_GOLF = 1 << 3, + VEHICLE_ENTRY_FLAG_REVERSER_BOGIE = 1 << 4, + VEHICLE_ENTRY_FLAG_REVERSER_PASSENGER_CAR = 1 << 5, + VEHICLE_ENTRY_FLAG_HAS_INVERTED_SPRITE_SET = 1 << 6, // Set on vehicles that support running inverted for extended periods + // of time, i.e. the Flying, Lay-down and Multi-dimension RCs. + VEHICLE_ENTRY_FLAG_DODGEM_INUSE_LIGHTS = 1 + << 7, // When set the vehicle has an additional frame for when in use. Used only by dodgems. + VEHICLE_ENTRY_FLAG_ALLOW_DOORS_DEPRECATED = 1 << 8, // Not used any more - every vehicle will now work with doors. + VEHICLE_ENTRY_FLAG_ENABLE_TERNARY_COLOUR = 1 << 9, + VEHICLE_ENTRY_FLAG_RECALCULATE_SPRITE_BOUNDS = 1 << 10, // Only used during loading of the objects. + VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES = 1 + << 11, // Instead of the default 32 rotation frames. Only used for boat hire and works only for non sloped sprites. + VEHICLE_ENTRY_FLAG_OVERRIDE_NUM_VERTICAL_FRAMES = 1 + << 12, // Setting this will cause the game to set vehicleEntry->num_vertical_frames to + // vehicleEntry->num_vertical_frames_override, rather than determining it itself. + VEHICLE_ENTRY_FLAG_SPRITE_BOUNDS_INCLUDE_INVERTED_SET = 1 + << 13, // Used together with HAS_INVERTED_SPRITE_SET and RECALCULATE_SPRITE_BOUNDS and includes the inverted sprites + // into the function that recalculates the sprite bounds. + VEHICLE_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES = 1 + << 14, // 16x additional frames for vehicle. A spinning item with additional frames must always face forward to + // load/unload. Spinning without can load/unload at 4 rotations. + VEHICLE_ENTRY_FLAG_LIFT = 1 << 15, + VEHICLE_ENTRY_FLAG_ENABLE_TRIM_COLOUR = 1 << 16, + VEHICLE_ENTRY_FLAG_SWINGING = 1 << 17, + VEHICLE_ENTRY_FLAG_SPINNING = 1 << 18, + VEHICLE_ENTRY_FLAG_POWERED = 1 << 19, + VEHICLE_ENTRY_FLAG_RIDERS_SCREAM = 1 << 20, + VEHICLE_ENTRY_FLAG_SUSPENDED_SWING = 1 << 21, // Suspended swinging coaster, or bobsleigh if SLIDE_SWING is also enabled. + VEHICLE_ENTRY_FLAG_BOAT_HIRE_COLLISION_DETECTION = 1 << 22, + VEHICLE_ENTRY_FLAG_VEHICLE_ANIMATION = 1 << 23, // Set on animated vehicles like the Multi-dimension coaster trains, + // Miniature Railway locomotives and Helicycles. + VEHICLE_ENTRY_FLAG_RIDER_ANIMATION = 1 << 24, // Set when the animation updates rider sprite positions. + VEHICLE_ENTRY_FLAG_WOODEN_WILD_MOUSE_SWING = 1 << 25, + VEHICLE_ENTRY_FLAG_LOADING_WAYPOINTS = 1 + << 26, // Peep loading positions have x and y coordinates. Normal rides just have offsets. + VEHICLE_ENTRY_FLAG_SLIDE_SWING = 1 + << 27, // Set on dingy slides. They have there own swing value calculations and have a different amount of images. + // Also set on bobsleighs together with the SUSPENDED_SWING flag. + VEHICLE_ENTRY_FLAG_CHAIRLIFT = 1 << 28, + VEHICLE_ENTRY_FLAG_WATER_RIDE = 1 << 29, // Set on rides where water would provide continuous propulsion. + VEHICLE_ENTRY_FLAG_GO_KART = 1 << 30, + VEHICLE_ENTRY_FLAG_DODGEM_CAR_PLACEMENT = 1u << 31, +}; + +enum : uint32_t +{ + VEHICLE_SPRITE_FLAG_FLAT = (1 << 0), + VEHICLE_SPRITE_FLAG_GENTLE_SLOPES = (1 << 1), + VEHICLE_SPRITE_FLAG_STEEP_SLOPES = (1 << 2), + VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES = (1 << 3), + VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES = (1 << 4), + VEHICLE_SPRITE_FLAG_FLAT_BANKED = (1 << 5), + VEHICLE_SPRITE_FLAG_INLINE_TWISTS = (1 << 6), + VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS = (1 << 7), + VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS = (1 << 8), + VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS = (1 << 9), + VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS = (1 << 10), + VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS = (1 << 11), + VEHICLE_SPRITE_FLAG_CORKSCREWS = (1 << 12), + VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION = (1 << 13), + VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL = (1 << 14), + // Used only on lifts (the transport ride), to only use 4 rotation sprites instead of 32. + VEHICLE_SPRITE_FLAG_USE_4_ROTATION_FRAMES = (1 << 15), +}; + /** * Ride type vehicle structure. * size: 0x65 @@ -72,4 +143,14 @@ struct rct_ride_entry_vehicle uint8_t pad_62[6] = {}; std::vector> peep_loading_waypoints = {}; std::vector peep_loading_positions = {}; + + constexpr uint8_t GetNumRotationFrames() const + { + if (flags & VEHICLE_ENTRY_FLAG_USE_16_ROTATION_FRAMES) + return 16; + if (sprite_flags & VEHICLE_SPRITE_FLAG_USE_4_ROTATION_FRAMES) + return 4; + + return 32; + } };