From 8c6f248b41da268115aee08dcf4ceca8089562ef Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 20 May 2016 21:24:43 +0200 Subject: [PATCH] Paint Enterprise (#3680) --- src/ride/thrill/enterprise.c | 116 +++++++++++++++++++++++++++++++++++ src/ride/track_data.c | 4 +- src/ride/track_paint.h | 1 + 3 files changed, 119 insertions(+), 2 deletions(-) diff --git a/src/ride/thrill/enterprise.c b/src/ride/thrill/enterprise.c index 846fd9695d..c13a4f44bc 100644 --- a/src/ride/thrill/enterprise.c +++ b/src/ride/thrill/enterprise.c @@ -13,3 +13,119 @@ * 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: 0x008A2ABC */ +static void paint_enterprise_structure(rct_ride * ride, sint8 xOffset, sint8 yOffset, uint16 height, rct_map_element * mapElement) +{ + height += 7; + + rct_map_element * savedMapElement = RCT2_GLOBAL(0x009DE578, rct_map_element*); + rct_ride_entry * rideType = get_ride_entry(ride->subtype); + rct_vehicle * vehicle = NULL; + + uint32 baseImageId = rideType->vehicles[0].base_image_id; + + if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK + && ride->vehicles[0] != SPRITE_INDEX_NULL) { + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_SPRITE; + vehicle = GET_VEHICLE(ride->vehicles[0]); + RCT2_GLOBAL(0x009DE578, rct_vehicle*) = vehicle; + } + + uint32 imageOffset = (get_current_rotation() + map_element_get_direction(mapElement)) % 4; + if (vehicle != NULL) { + imageOffset = (vehicle->vehicle_sprite_type << 2) + (((vehicle->sprite_direction >> 3) + get_current_rotation()) % 4); + } + + 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 imageId = (baseImageId + imageOffset) | imageColourFlags; + sub_98197C(imageId, xOffset, yOffset, 24, 24, 48, height, 0, 0, height, get_current_rotation()); + + rct_drawpixelinfo * dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo *); + + if (dpi->zoom_level == 0 + && imageOffset < 12 + && ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK + && vehicle != NULL) { + for (int i = 0; i < 15; i++) { + if (vehicle->num_peeps <= i) { + break; + } + + uint32 peepFrameOffset = ((imageOffset % 4) * 4 + (i * 4) % 15) & 0x0F; + uint32 ax = (imageOffset & 0xFFFFFFFC) << 2; + imageId = (baseImageId + 196 + peepFrameOffset + ax) | vehicle->peep_tshirt_colours[i] << 19 | 0x20000000; + sub_98199C(imageId, xOffset, yOffset, 24, 24, 48, height, 0, 0, height, get_current_rotation()); + } + } + + RCT2_GLOBAL(0x009DE578, rct_map_element*) = savedMapElement; + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_RIDE; +} + +/** rct2: 0x008A1584 */ +static void paint_enterprise(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + trackSequence = track_map_4x4[direction][trackSequence]; + + int edges = edges_4x4[trackSequence]; + rct_ride * ride = get_ride(rideIndex); + rct_xy16 position = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; + + wooden_a_supports_paint_setup(direction & 1, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); + + track_paint_util_paint_floor(edges, RCT2_GLOBAL(0x00F44198, uint32), height, floorSpritesCork, get_current_rotation()); + + track_paint_util_paint_fences(edges, position, mapElement, ride, RCT2_GLOBAL(0x00F44198, uint32), height, fenceSpritesRope, get_current_rotation()); + + switch (trackSequence) { + case 5: paint_enterprise_structure(ride, 16, 16, height, mapElement); break; + case 6: paint_enterprise_structure(ride, 16, -16, height, mapElement); break; + case 10: paint_enterprise_structure(ride, -16, -16, height, mapElement); break; + case 9: paint_enterprise_structure(ride, -16, 16, height, mapElement); break; + + case 0: paint_enterprise_structure(ride, 48, 48, height, mapElement); break; + case 3: paint_enterprise_structure(ride, 48, -48, height, mapElement); break; + case 15: paint_enterprise_structure(ride, -48, -48, height, mapElement); break; + case 12: paint_enterprise_structure(ride, -48, 48, height, mapElement); break; + + case 7: paint_enterprise_structure(ride, 16, -48, height, mapElement); break; + case 11: paint_enterprise_structure(ride, -16, -48, height, mapElement); break; + case 14: paint_enterprise_structure(ride, -48, -16, height, mapElement); break; + case 13: paint_enterprise_structure(ride, -48, 16, height, mapElement); break; + } + + int cornerSegments = 0; + switch (trackSequence) { + case 0: cornerSegments = SEGMENT_B4 | SEGMENT_C8 | SEGMENT_CC; break; + case 3: cornerSegments = SEGMENT_CC | SEGMENT_BC | SEGMENT_D4; break; + case 12: cornerSegments = SEGMENT_C8 | SEGMENT_B8 | SEGMENT_D0; break; + case 15: 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 + 160, 0x20); + +} + +/** + * rct2: 0x008A13B4 + */ +TRACK_PAINT_FUNCTION get_track_paint_function_enterprise(int trackType, int direction) +{ + if (trackType != 111) { + return NULL; + } + + return paint_enterprise; +} diff --git a/src/ride/track_data.c b/src/ride/track_data.c index 2fd3e86aa0..ca2a636c63 100644 --- a/src/ride/track_data.c +++ b/src/ride/track_data.c @@ -5548,7 +5548,7 @@ const uint32 RideTypeTrackPaintFunctionsOld[91] = { 0/*x008995D4*/, // RIDE_TYPE_SUBMARINE_RIDE 0x0089B0C0, // RIDE_TYPE_RIVER_RAFTS 0, // RIDE_TYPE_50 - 0x008A13B4, // RIDE_TYPE_ENTERPRISE + 0, // RIDE_TYPE_ENTERPRISE 0, // RIDE_TYPE_52 0, // RIDE_TYPE_53 0, // RIDE_TYPE_54 @@ -5643,7 +5643,7 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = { get_track_paint_function_submarine_ride, // RIDE_TYPE_SUBMARINE_RIDE 0, // RIDE_TYPE_RIVER_RAFTS get_track_paint_function_shop, // RIDE_TYPE_50 - 0, // RIDE_TYPE_ENTERPRISE + get_track_paint_function_enterprise, // RIDE_TYPE_ENTERPRISE get_track_paint_function_shop, // RIDE_TYPE_52 get_track_paint_function_shop, // RIDE_TYPE_53 get_track_paint_function_shop, // RIDE_TYPE_54 diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 3a958b3b60..548ad69403 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -187,5 +187,6 @@ TRACK_PAINT_FUNCTION get_track_paint_function_roto_drop(int trackType, int direc 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_submarine_ride(int trackType, int direction); +TRACK_PAINT_FUNCTION get_track_paint_function_enterprise(int trackType, int direction); #endif