mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2024-09-10 11:32:47 +02:00
Merge pull request #3701 from IntelOrca/paint/magic-carpet
Paint Magic Carpet ride
This commit is contained in:
commit
1e4a8d6fba
3 changed files with 216 additions and 1 deletions
|
@ -13,3 +13,217 @@
|
||||||
* A full copy of the GNU General Public License can be found in licence.txt
|
* A full copy of the GNU General Public License can be found in licence.txt
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#include "../../interface/viewport.h"
|
||||||
|
#include "../../paint/paint.h"
|
||||||
|
#include "../../paint/supports.h"
|
||||||
|
#include "../track_paint.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PLANE_BACK,
|
||||||
|
PLANE_FRONT,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SPR_MAGIC_CARPET_FRAME_NW = 22002,
|
||||||
|
SPR_MAGIC_CARPET_FRAME_SE = 22003,
|
||||||
|
SPR_MAGIC_CARPET_FRAME_NE = 22004,
|
||||||
|
SPR_MAGIC_CARPET_FRAME_SW = 22005,
|
||||||
|
SPR_MAGIC_CARPET_PENDULUM_NW = 22006,
|
||||||
|
SPR_MAGIC_CARPET_PENDULUM_NE = 22038,
|
||||||
|
SPR_MAGIC_CARPET_PENDULUM_SE = 22070,
|
||||||
|
SPR_MAGIC_CARPET_PENDULUM_SW = 22102,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct bound_box {
|
||||||
|
sint16 x;
|
||||||
|
sint16 y;
|
||||||
|
sint16 width;
|
||||||
|
sint16 height;
|
||||||
|
} bound_box;
|
||||||
|
|
||||||
|
/** rct2: 0x01428220 */
|
||||||
|
static const sint16 MagicCarpetOscillationZ[] = {
|
||||||
|
-2, -1, 1, 5, 10, 16, 23, 30, 37, 45, 52, 59, 65, 70, 74, 76, 77,
|
||||||
|
76, 74, 70, 65, 59, 52, 45, 37, 30, 23, 16, 10, 5, 1, -1
|
||||||
|
};
|
||||||
|
|
||||||
|
/** rct2: 0x01428260 */
|
||||||
|
static const sint8 MagicCarpetOscillationXY[] = {
|
||||||
|
0, 6, 12, 18, 23, 27, 30, 31, 32, 31, 30, 27, 23, 18, 12, 6, 0,
|
||||||
|
-5, -11, -17, -22, -26, -29, -30, -31, -30, -29, -26, -22, -17, -11, -5
|
||||||
|
};
|
||||||
|
|
||||||
|
/** rct2: 0x014281F0 */
|
||||||
|
static const bound_box MagicCarpetBounds[] = {
|
||||||
|
{ 0, 8, 32, 16 },
|
||||||
|
{ 8, 0, 16, 32 },
|
||||||
|
{ 0, 8, 32, 16 },
|
||||||
|
{ 8, 0, 16, 32 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static rct_vehicle *get_first_vehicle(rct_ride *ride)
|
||||||
|
{
|
||||||
|
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK) {
|
||||||
|
uint16 vehicleSpriteIndex = ride->vehicles[0];
|
||||||
|
if (vehicleSpriteIndex != SPRITE_INDEX_NULL) {
|
||||||
|
return GET_VEHICLE(vehicleSpriteIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void paint_magic_carpet_frame(uint8 plane, uint8 direction,
|
||||||
|
rct_xyz16 offset, rct_xyz16 bbOffset, rct_xyz16 bbSize)
|
||||||
|
{
|
||||||
|
uint32 imageId;
|
||||||
|
if (direction & 1) {
|
||||||
|
imageId = plane == PLANE_BACK ? SPR_MAGIC_CARPET_FRAME_NE :
|
||||||
|
SPR_MAGIC_CARPET_FRAME_SW;
|
||||||
|
} else {
|
||||||
|
imageId = plane == PLANE_BACK ? SPR_MAGIC_CARPET_FRAME_NW :
|
||||||
|
SPR_MAGIC_CARPET_FRAME_SE;
|
||||||
|
}
|
||||||
|
imageId |= RCT2_GLOBAL(0x00F44198, uint32);
|
||||||
|
if (plane == PLANE_BACK) {
|
||||||
|
sub_98197C(imageId, (sint8)offset.x, (sint8)offset.y, bbSize.x, bbSize.y, 127, offset.z, bbOffset.x, bbOffset.y, bbOffset.z, get_current_rotation());
|
||||||
|
} else {
|
||||||
|
sub_98199C(imageId, (sint8)offset.x, (sint8)offset.y, bbSize.x, bbSize.y, 127, offset.z, bbOffset.x, bbOffset.y, bbOffset.z, get_current_rotation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void paint_magic_carpet_pendulum(uint8 plane, uint32 swingImageId, uint8 direction,
|
||||||
|
rct_xyz16 offset, rct_xyz16 bbOffset, rct_xyz16 bbSize)
|
||||||
|
{
|
||||||
|
uint32 imageId = swingImageId;
|
||||||
|
if (direction & 2) {
|
||||||
|
imageId = (0 - ((sint32)imageId)) & 31;
|
||||||
|
}
|
||||||
|
if (direction & 1) {
|
||||||
|
imageId += plane == PLANE_BACK ? SPR_MAGIC_CARPET_PENDULUM_NE :
|
||||||
|
SPR_MAGIC_CARPET_PENDULUM_SW;
|
||||||
|
} else {
|
||||||
|
imageId += plane == PLANE_BACK ? SPR_MAGIC_CARPET_PENDULUM_NW :
|
||||||
|
SPR_MAGIC_CARPET_PENDULUM_SE;
|
||||||
|
}
|
||||||
|
imageId |= RCT2_GLOBAL(0x00F44198, uint32);
|
||||||
|
sub_98199C(imageId, (sint8)offset.x, (sint8)offset.y, bbSize.x, bbSize.y, 127, offset.z, bbOffset.x, bbOffset.y, bbOffset.z, get_current_rotation());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void paint_magic_carpet_vehicle(rct_ride *ride, uint8 direction, uint32 swingImageId,
|
||||||
|
rct_xyz16 offset, rct_xyz16 bbOffset, rct_xyz16 bbSize)
|
||||||
|
{
|
||||||
|
rct_ride_entry *rideEntry = get_ride_entry_by_ride(ride);
|
||||||
|
uint32 vehicleImageId = rideEntry->vehicles[0].base_image_id + direction;
|
||||||
|
|
||||||
|
// Vehicle
|
||||||
|
uint32 imageColourFlags = RCT2_GLOBAL(0x00F441A0, uint32);
|
||||||
|
if (imageColourFlags == 0x20000000) {
|
||||||
|
imageColourFlags = 0xA0000000 |
|
||||||
|
(ride->vehicle_colours[0].trim_colour << 24) |
|
||||||
|
(ride->vehicle_colours[0].body_colour << 19);
|
||||||
|
}
|
||||||
|
|
||||||
|
sint8 directionalOffset = MagicCarpetOscillationXY[swingImageId];
|
||||||
|
switch (direction) {
|
||||||
|
case 0: offset.x -= directionalOffset; break;
|
||||||
|
case 1: offset.y += directionalOffset; break;
|
||||||
|
case 2: offset.x += directionalOffset; break;
|
||||||
|
case 3: offset.y -= directionalOffset; break;
|
||||||
|
}
|
||||||
|
offset.z += MagicCarpetOscillationZ[swingImageId];
|
||||||
|
|
||||||
|
sub_98199C(vehicleImageId | imageColourFlags, (sint8)offset.x, (sint8)offset.y, bbSize.x, bbSize.y, 127, offset.z, bbOffset.x, bbOffset.y, bbOffset.z, get_current_rotation());
|
||||||
|
|
||||||
|
// Riders
|
||||||
|
rct_drawpixelinfo *dpi = RCT2_GLOBAL(0x0140E9A8, rct_drawpixelinfo*);
|
||||||
|
if (dpi->zoom_level <= 1 && (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)) {
|
||||||
|
rct_vehicle *vehicle = get_first_vehicle(ride);
|
||||||
|
if (vehicle != NULL) {
|
||||||
|
uint32 baseImageId = 0xA0000000 | (vehicleImageId + 4);
|
||||||
|
for (uint8 peepIndex = 0; peepIndex < vehicle->num_peeps; peepIndex += 2) {
|
||||||
|
uint32 imageId = baseImageId + (peepIndex * 2);
|
||||||
|
imageId |= (vehicle->peep_tshirt_colours[peepIndex + 0] << 19);
|
||||||
|
imageId |= (vehicle->peep_tshirt_colours[peepIndex + 1] << 24);
|
||||||
|
sub_98199C(imageId, (sint8)offset.x, (sint8)offset.y, bbSize.x, bbSize.y, 127, offset.z, bbOffset.x, bbOffset.y, bbOffset.z, get_current_rotation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** rct2: 0x00899104 */
|
||||||
|
static void paint_magic_carpet_structure(rct_ride *ride, uint8 direction, sint8 axisOffset, uint16 height)
|
||||||
|
{
|
||||||
|
rct_vehicle *vehicle = get_first_vehicle(ride);
|
||||||
|
|
||||||
|
uint32 swingImageId = 0;
|
||||||
|
if (vehicle != NULL) {
|
||||||
|
swingImageId = vehicle->vehicle_sprite_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
bound_box bb = MagicCarpetBounds[direction];
|
||||||
|
rct_xyz16 offset, bbOffset, bbSize;
|
||||||
|
offset.x = (direction & 1) ? 0 : axisOffset;
|
||||||
|
offset.y = (direction & 1) ? axisOffset : 0;
|
||||||
|
offset.z = height + 7;
|
||||||
|
bbOffset.x = bb.x;
|
||||||
|
bbOffset.y = bb.y;
|
||||||
|
bbOffset.z = height + 7;
|
||||||
|
bbSize.x = bb.width;
|
||||||
|
bbSize.y = bb.height;
|
||||||
|
bbSize.z = 127;
|
||||||
|
|
||||||
|
paint_magic_carpet_frame(PLANE_BACK, direction, offset, bbOffset, bbSize);
|
||||||
|
paint_magic_carpet_pendulum(PLANE_BACK, swingImageId, direction, offset, bbOffset, bbSize);
|
||||||
|
paint_magic_carpet_vehicle(ride, direction, swingImageId, offset, bbOffset, bbSize);
|
||||||
|
paint_magic_carpet_pendulum(PLANE_FRONT, swingImageId, direction, offset, bbOffset, bbSize);
|
||||||
|
paint_magic_carpet_frame(PLANE_FRONT, direction, offset, bbOffset, bbSize);
|
||||||
|
|
||||||
|
gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** rct2: 0x00898514 */
|
||||||
|
static void paint_magic_carpet(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement)
|
||||||
|
{
|
||||||
|
uint8 relativeTrackSequence = track_map_1x4[direction][trackSequence];
|
||||||
|
|
||||||
|
// The end tiles do not have a platform
|
||||||
|
switch (relativeTrackSequence) {
|
||||||
|
case 0:
|
||||||
|
case 2:
|
||||||
|
if (direction & 1) {
|
||||||
|
metal_a_supports_paint_setup(0, 6, 0, height, RCT2_GLOBAL(0x00F4419C, uint32));
|
||||||
|
metal_a_supports_paint_setup(0, 7, 0, height, RCT2_GLOBAL(0x00F4419C, uint32));
|
||||||
|
} else {
|
||||||
|
metal_a_supports_paint_setup(0, 5, 0, height, RCT2_GLOBAL(0x00F4419C, uint32));
|
||||||
|
metal_a_supports_paint_setup(0, 8, 0, height, RCT2_GLOBAL(0x00F4419C, uint32));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 imageId = SPR_STATION_BASE_D | RCT2_GLOBAL(0x00F4419C, uint32);
|
||||||
|
sub_98196C(imageId, 0, 0, 32, 32, 1, height, get_current_rotation());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
rct_ride *ride = get_ride(rideIndex);
|
||||||
|
switch (relativeTrackSequence) {
|
||||||
|
case 3: paint_magic_carpet_structure(ride, direction, -48, height); break;
|
||||||
|
case 0: paint_magic_carpet_structure(ride, direction, -16, height); break;
|
||||||
|
case 2: paint_magic_carpet_structure(ride, direction, 16, height); break;
|
||||||
|
case 1: paint_magic_carpet_structure(ride, direction, 48, height); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0);
|
||||||
|
paint_util_set_general_support_height(height + 176, 0x20);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* rct2: 0x00898384
|
||||||
|
*/
|
||||||
|
TRACK_PAINT_FUNCTION get_track_paint_function_magic_carpet(int trackType, int direction)
|
||||||
|
{
|
||||||
|
switch (trackType) {
|
||||||
|
case 95: return paint_magic_carpet;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -5639,7 +5639,7 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = {
|
||||||
0, // RIDE_TYPE_WATER_COASTER
|
0, // RIDE_TYPE_WATER_COASTER
|
||||||
0, // RIDE_TYPE_AIR_POWERED_VERTICAL_COASTER
|
0, // RIDE_TYPE_AIR_POWERED_VERTICAL_COASTER
|
||||||
0, // RIDE_TYPE_INVERTED_HAIRPIN_COASTER
|
0, // RIDE_TYPE_INVERTED_HAIRPIN_COASTER
|
||||||
0, // RIDE_TYPE_MAGIC_CARPET
|
get_track_paint_function_magic_carpet, // RIDE_TYPE_MAGIC_CARPET
|
||||||
get_track_paint_function_submarine_ride, // RIDE_TYPE_SUBMARINE_RIDE
|
get_track_paint_function_submarine_ride, // RIDE_TYPE_SUBMARINE_RIDE
|
||||||
0, // RIDE_TYPE_RIVER_RAFTS
|
0, // RIDE_TYPE_RIVER_RAFTS
|
||||||
get_track_paint_function_shop, // RIDE_TYPE_50
|
get_track_paint_function_shop, // RIDE_TYPE_50
|
||||||
|
|
|
@ -205,6 +205,7 @@ TRACK_PAINT_FUNCTION get_track_paint_function_mini_golf(int trackType, int direc
|
||||||
TRACK_PAINT_FUNCTION get_track_paint_function_roto_drop(int trackType, int direction);
|
TRACK_PAINT_FUNCTION get_track_paint_function_roto_drop(int trackType, int direction);
|
||||||
TRACK_PAINT_FUNCTION get_track_paint_function_flying_saucers(int trackType, int direction);
|
TRACK_PAINT_FUNCTION get_track_paint_function_flying_saucers(int trackType, int direction);
|
||||||
TRACK_PAINT_FUNCTION get_track_paint_function_crooked_house(int trackType, int direction);
|
TRACK_PAINT_FUNCTION get_track_paint_function_crooked_house(int trackType, int direction);
|
||||||
|
TRACK_PAINT_FUNCTION get_track_paint_function_magic_carpet(int trackType, int direction);
|
||||||
TRACK_PAINT_FUNCTION get_track_paint_function_submarine_ride(int trackType, int direction);
|
TRACK_PAINT_FUNCTION get_track_paint_function_submarine_ride(int trackType, int direction);
|
||||||
TRACK_PAINT_FUNCTION get_track_paint_function_enterprise(int trackType, int direction);
|
TRACK_PAINT_FUNCTION get_track_paint_function_enterprise(int trackType, int direction);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue