Paint Twist (#3694)

This commit is contained in:
Marijn van der Werf 2016-05-21 19:30:11 +02:00 committed by Ted John
parent d3b1254c22
commit 8442de943d
3 changed files with 142 additions and 2 deletions

View File

@ -13,3 +13,142 @@
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#include "../../common.h"
#include "../../interface/viewport.h"
#include "../track_paint.h"
#include "../../paint/supports.h"
#include "../../paint/paint.h"
/** rct2: 0x0076E5C9 */
static void paint_twist_structure(rct_ride * ride, uint8 direction, sint8 xOffset, sint8 yOffset, uint16 height)
{
rct_map_element * savedMapElement = RCT2_GLOBAL(0x009DE578, rct_map_element*);
rct_ride_entry * rideType = get_ride_entry(ride->subtype);
rct_vehicle * vehicle = NULL;
height += 7;
uint32 baseImageId = rideType->vehicles[0].base_image_id;
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK
&& ride->vehicles[0] != SPRITE_INDEX_NULL) {
vehicle = GET_VEHICLE(ride->vehicles[0]);
gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_SPRITE;
RCT2_GLOBAL(0x009DE578, rct_vehicle*) = vehicle;
}
uint32 frameNum = (direction * 88) % 216;
if (vehicle != NULL) {
frameNum += (vehicle->sprite_direction >> 3) << 4;
frameNum += vehicle->vehicle_sprite_type;
frameNum = frameNum % 216;
}
uint32 imageColourFlags = RCT2_GLOBAL(0x00F441A0, uint32);
if (imageColourFlags == 0x20000000) {
imageColourFlags = ride->vehicle_colours[0].body_colour << 19 | ride->vehicle_colours[0].trim_colour << 24 | 0xA0000000;
}
uint32 structureFrameNum = frameNum % 24;
uint32 imageId = (baseImageId + structureFrameNum) | imageColourFlags;
sub_98197C(imageId, xOffset, yOffset, 24, 24, 48, height, xOffset + 16, yOffset + 16, height, get_current_rotation());
rct_drawpixelinfo * dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*);
if (dpi->zoom_level < 1
&& ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK
&& vehicle != NULL) {
for (int i = 0; i < vehicle->num_peeps; i += 2) {
imageColourFlags = vehicle->peep_tshirt_colours[i] << 19 | vehicle->peep_tshirt_colours[i + 1] << 24 | 0xA0000000;
uint32 peepFrameNum = (frameNum + i * 12) % 216;
uint32 imageId = (baseImageId + 24 + peepFrameNum) | imageColourFlags;
sub_98199C(imageId, xOffset, yOffset, 24, 24, 48, height, xOffset + 16, yOffset + 16, height, get_current_rotation());
}
}
RCT2_GLOBAL(0x009DE578, rct_map_element*) = savedMapElement;
gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
}
/** rct2: 0x0076D858 */
static void paint_twist(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement)
{
trackSequence = track_map_3x3[direction][trackSequence];
const uint8 edges = edges_3x3[trackSequence];
rct_ride * ride = get_ride(rideIndex);
rct_xy16 position = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)};
uint32 imageId;
wooden_a_supports_paint_setup((direction & 1), 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL);
track_paint_util_paint_floor(edges, RCT2_GLOBAL(0x00F441A0, uint32), height, floorSpritesCork, get_current_rotation());
switch (trackSequence) {
case 7:
if (track_paint_util_has_fence(EDGE_SW, position, mapElement, ride, get_current_rotation())) {
imageId = SPR_FENCE_ROPE_SW | RCT2_GLOBAL(0x00F441A0, uint32);
sub_98197C(imageId, 0, 0, 1, 28, 7, height, 29, 0, height + 3, get_current_rotation());
}
if (track_paint_util_has_fence(EDGE_SE, position, mapElement, ride, get_current_rotation())) {
imageId = SPR_FENCE_ROPE_SE | RCT2_GLOBAL(0x00F441A0, uint32);
sub_98197C(imageId, 0, 0, 28, 1, 7, height, 0, 29, height + 3, get_current_rotation());
}
break;
default:
track_paint_util_paint_fences(edges, position, mapElement, ride, RCT2_GLOBAL(0x00F441A0, uint32), height, fenceSpritesRope, get_current_rotation());
break;
}
switch (trackSequence) {
case 1:
paint_twist_structure(ride, direction, 32, 32, height);
break;
case 3:
paint_twist_structure(ride, direction, 32, -32, height);
break;
case 5:
paint_twist_structure(ride, direction, 0, -32, height);
break;
case 6:
paint_twist_structure(ride, direction, -32, 32, height);
break;
case 7:
paint_twist_structure(ride, direction, -32, -32, height);
break;
case 8:
paint_twist_structure(ride, direction, -32, 0, height);
break;
}
int cornerSegments = 0;
switch (trackSequence) {
case 1: cornerSegments = SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC; break;
case 3: cornerSegments = SEGMENT_CC | SEGMENT_BC | SEGMENT_D4; break;
case 6: cornerSegments = SEGMENT_C8 | SEGMENT_B8 | SEGMENT_D0; break;
case 7: cornerSegments = SEGMENT_D0 | SEGMENT_C0 | SEGMENT_D4; break;
}
paint_util_set_segment_support_height(cornerSegments, height + 2, 0x20);
paint_util_set_segment_support_height(SEGMENTS_ALL & ~cornerSegments, 0xFFFF, 0);
paint_util_set_general_support_height(height + 64, 0x20);
}
/**
* rct2: 0x0076D658
*/
TRACK_PAINT_FUNCTION get_track_paint_function_twist(int trackType, int direction)
{
if (trackType != 123) {
return NULL;
}
return paint_twist;
}

View File

@ -5513,7 +5513,7 @@ const uint32 RideTypeTrackPaintFunctionsOld[91] = {
0, // RIDE_TYPE_LIFT
0x008A9C08, // RIDE_TYPE_VERTICAL_DROP_ROLLER_COASTER
0, // RIDE_TYPE_CASH_MACHINE
0x0076D658, // RIDE_TYPE_TWIST
0, // RIDE_TYPE_TWIST
0, // RIDE_TYPE_HAUNTED_HOUSE
0, // RIDE_TYPE_FIRST_AID
0, // RIDE_TYPE_CIRCUS_SHOW
@ -5608,7 +5608,7 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = {
get_track_paint_function_lift, // RIDE_TYPE_LIFT
0, // RIDE_TYPE_VERTICAL_DROP_ROLLER_COASTER
get_track_paint_function_shop, // RIDE_TYPE_CASH_MACHINE
0, // RIDE_TYPE_TWIST
get_track_paint_function_twist, // RIDE_TYPE_TWIST
get_track_paint_function_haunted_house, // RIDE_TYPE_HAUNTED_HOUSE
get_track_paint_function_facility, // RIDE_TYPE_FIRST_AID
get_track_paint_function_circus_show, // RIDE_TYPE_CIRCUS_SHOW

View File

@ -190,6 +190,7 @@ TRACK_PAINT_FUNCTION get_track_paint_function_lift(int trackType, int direction)
TRACK_PAINT_FUNCTION get_track_paint_function_shop(int trackType, int direction);
TRACK_PAINT_FUNCTION get_track_paint_function_merry_go_round(int trackType, int direction);
TRACK_PAINT_FUNCTION get_track_paint_function_facility(int trackType, int direction);
TRACK_PAINT_FUNCTION get_track_paint_function_twist(int trackType, int direction);
TRACK_PAINT_FUNCTION get_track_paint_function_haunted_house(int trackType, int direction);
TRACK_PAINT_FUNCTION get_track_paint_function_circus_show(int trackType, int direction);
TRACK_PAINT_FUNCTION get_track_paint_function_mini_helicopters(int trackType, int direction);