OpenRCT2/src/openrct2/ride/thrill/Enterprise.cpp

174 lines
6.4 KiB
C++
Raw Normal View History

#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
2016-05-20 21:24:43 +02:00
#include "../../common.h"
#include "../../interface/viewport.h"
#include "../../paint/paint.h"
2017-10-08 22:40:16 +02:00
#include "../../paint/supports.h"
2017-10-17 13:51:47 +02:00
#include "../Track.h"
2017-10-08 22:40:16 +02:00
#include "../track_paint.h"
2016-05-20 21:24:43 +02:00
/** rct2: 0x008A2ABC */
2017-10-08 22:40:16 +02:00
static void paint_enterprise_structure(paint_session * session, Ride * ride, sint8 xOffset, sint8 yOffset, uint16 height,
rct_map_element * mapElement)
2016-05-20 21:24:43 +02:00
{
height += 7;
2017-10-08 22:20:46 +02:00
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
2017-10-08 22:40:16 +02:00
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);
rct_vehicle * vehicle = NULL;
2017-07-18 18:07:43 +02:00
uint32 baseImageId = rideEntry->vehicles[0].base_image_id;
2017-10-08 22:40:16 +02:00
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && ride->vehicles[0] != SPRITE_INDEX_NULL)
{
session->InteractionType = VIEWPORT_INTERACTION_ITEM_SPRITE;
vehicle = GET_VEHICLE(ride->vehicles[0]);
session->CurrentlyDrawnItem = vehicle;
}
uint32 imageOffset = map_element_get_direction_with_offset(mapElement, get_current_rotation());
2017-10-08 22:40:16 +02:00
if (vehicle != NULL)
{
imageOffset = (vehicle->vehicle_sprite_type << 2) + (((vehicle->sprite_direction >> 3) + get_current_rotation()) % 4);
}
2017-09-12 20:48:18 +02:00
uint32 imageColourFlags = session->TrackColours[SCHEME_MISC];
2017-10-08 22:40:16 +02:00
if (imageColourFlags == IMAGE_TYPE_REMAP)
{
imageColourFlags =
SPRITE_ID_PALETTE_COLOUR_2(ride->vehicle_colours[0].body_colour, ride->vehicle_colours[0].trim_colour);
}
uint32 imageId = (baseImageId + imageOffset) | imageColourFlags;
2017-09-03 03:27:07 +02:00
sub_98197C(session, imageId, xOffset, yOffset, 24, 24, 48, height, 0, 0, height, get_current_rotation());
rct_drawpixelinfo * dpi = session->Unk140E9A8;
2017-10-08 22:40:16 +02:00
if (dpi->zoom_level == 0 && imageOffset < 12 && ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != NULL)
{
for (sint32 i = 0; i < 15; i++)
{
if (vehicle->num_peeps <= i)
{
break;
}
uint32 peepFrameOffset = ((imageOffset % 4) * 4 + (i * 4) % 15) & 0x0F;
2017-10-08 22:40:16 +02:00
uint32 ax = (imageOffset & 0xFFFFFFFC) << 2;
imageId = (baseImageId + 196 + peepFrameOffset + ax) | SPRITE_ID_PALETTE_COLOUR_1(vehicle->peep_tshirt_colours[i]);
2017-09-03 03:27:07 +02:00
sub_98199C(session, imageId, xOffset, yOffset, 24, 24, 48, height, 0, 0, height, get_current_rotation());
}
}
session->CurrentlyDrawnItem = savedMapElement;
2017-10-08 22:40:16 +02:00
session->InteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
2016-05-20 21:24:43 +02:00
}
/** rct2: 0x008A1584 */
2017-10-08 22:40:16 +02:00
static void paint_enterprise(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height,
rct_map_element * mapElement)
2016-05-20 21:24:43 +02:00
{
trackSequence = track_map_4x4[direction][trackSequence];
2017-10-08 22:40:16 +02:00
sint32 edges = edges_4x4[trackSequence];
Ride * ride = get_ride(rideIndex);
LocationXY16 position = session->MapPosition;
2017-09-12 20:48:18 +02:00
wooden_a_supports_paint_setup(session, direction & 1, 0, height, session->TrackColours[SCHEME_MISC], NULL);
2017-10-08 22:40:16 +02:00
track_paint_util_paint_floor(session, edges, session->TrackColours[SCHEME_TRACK], height, floorSpritesCork,
get_current_rotation());
track_paint_util_paint_fences(session, edges, position, mapElement, ride, session->TrackColours[SCHEME_TRACK], height,
fenceSpritesRope, get_current_rotation());
switch (trackSequence)
{
case 5:
paint_enterprise_structure(session, ride, 16, 16, height, mapElement);
break;
case 6:
paint_enterprise_structure(session, ride, 16, -16, height, mapElement);
break;
case 10:
paint_enterprise_structure(session, ride, -16, -16, height, mapElement);
break;
case 9:
paint_enterprise_structure(session, ride, -16, 16, height, mapElement);
break;
case 0:
paint_enterprise_structure(session, ride, 48, 48, height, mapElement);
break;
case 3:
paint_enterprise_structure(session, ride, 48, -48, height, mapElement);
break;
case 15:
paint_enterprise_structure(session, ride, -48, -48, height, mapElement);
break;
case 12:
paint_enterprise_structure(session, ride, -48, 48, height, mapElement);
break;
case 7:
paint_enterprise_structure(session, ride, 16, -48, height, mapElement);
break;
case 11:
paint_enterprise_structure(session, ride, -16, -48, height, mapElement);
break;
case 14:
paint_enterprise_structure(session, ride, -48, -16, height, mapElement);
break;
case 13:
paint_enterprise_structure(session, ride, -48, 16, height, mapElement);
break;
}
sint32 cornerSegments = 0;
2017-10-08 22:40:16 +02:00
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(session, cornerSegments, height + 2, 0x20);
paint_util_set_segment_support_height(session, SEGMENTS_ALL & ~cornerSegments, 0xFFFF, 0);
paint_util_set_general_support_height(session, height + 160, 0x20);
2016-05-20 21:24:43 +02:00
}
/**
* rct2: 0x008A13B4
*/
2017-01-04 22:17:08 +01:00
TRACK_PAINT_FUNCTION get_track_paint_function_enterprise(sint32 trackType, sint32 direction)
2016-05-20 21:24:43 +02:00
{
2017-10-08 22:40:16 +02:00
if (trackType != FLAT_TRACK_ELEM_4_X_4)
{
return NULL;
}
2016-05-20 21:24:43 +02:00
return paint_enterprise;
2016-05-20 21:24:43 +02:00
}