1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 04:23:20 +01:00

Compile ride drawing code as C++

This commit is contained in:
Michał Janiszewski
2017-10-08 22:20:46 +02:00
committed by Michael Steenbeek
parent ebb4bbe5d5
commit a8c8f726ee
76 changed files with 53 additions and 38 deletions

View File

@@ -27,6 +27,7 @@
#include "../ride_data.h"
#include "../track_data.h"
#include "../track_paint.h"
#include "../../core/Math.hpp"
enum {
SPR_JUNIOR_RC_FLAT_SW_NE = 27807,
@@ -3776,7 +3777,7 @@ void junior_rc_paint_track_diag_flat_to_25_deg_up(paint_session * session, uint8
void junior_rc_paint_track_diag_flat_to_60_deg_up(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, uint16 height, rct_map_element* mapElement, JUNIOR_RC_CHAINTYPE chainType)
{
// There is no specific chain for the Water Coaster, use the Junior RC chain instead
chainType = min(1, chainType);
chainType = Math::Min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
track_paint_util_diag_tiles_paint(session, 1, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK], junior_rc_track_pieces_diag_flat_to_60_deg_up[chainType], defaultDiagTileOffsets, defaultDiagBoundLengths, 0, get_current_rotation());
@@ -3805,7 +3806,7 @@ void junior_rc_paint_track_diag_25_deg_up_to_flat(paint_session * session, uint8
void junior_rc_paint_track_diag_60_deg_up_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, uint16 height, rct_map_element* mapElement, JUNIOR_RC_CHAINTYPE chainType)
{
// There is no specific chain for the Water Coaster, use the Junior RC chain instead
chainType = min(1, chainType);
chainType = Math::Min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
track_paint_util_diag_tiles_paint(session, 1, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK], junior_rc_track_pieces_diag_60_deg_up_to_flat[chainType], defaultDiagTileOffsets, defaultDiagBoundLengths, 0, get_current_rotation());
@@ -3848,7 +3849,7 @@ void junior_rc_paint_track_diag_flat_to_25_deg_down(paint_session * session, uin
void junior_rc_paint_track_diag_flat_to_60_deg_down(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, uint16 height, rct_map_element* mapElement, JUNIOR_RC_CHAINTYPE chainType)
{
// There is no specific chain for the Water Coaster, use the Junior RC chain instead
chainType = min(1, chainType);
chainType = Math::Min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
track_paint_util_diag_tiles_paint(session, 1, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK], junior_rc_track_pieces_diag_flat_to_60_deg_down[chainType], defaultDiagTileOffsets, defaultDiagBoundLengths, 0, get_current_rotation());
@@ -3877,7 +3878,7 @@ void junior_rc_paint_track_diag_25_deg_down_to_flat(paint_session * session, uin
void junior_rc_paint_track_diag_60_deg_down_to_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, uint16 height, rct_map_element* mapElement, JUNIOR_RC_CHAINTYPE chainType)
{
// There is no specific chain for the Water Coaster, use the Junior RC chain instead
chainType = min(1, chainType);
chainType = Math::Min(JUNIOR_RC_CHAIN_FRICTION_WHEELS, chainType);
track_paint_util_diag_tiles_paint(session, 1, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK], junior_rc_track_pieces_diag_60_deg_down_to_flat[chainType], defaultDiagTileOffsets, defaultDiagBoundLengths, 0, get_current_rotation());

View File

@@ -21,6 +21,7 @@
#include "../../interface/viewport.h"
#include "../../paint/paint.h"
#include "../../paint/supports.h"
#include "../../core/Util.hpp"
// 0x009927E6:
static const vehicle_boundbox _virginiaReelBoundbox[] = {
@@ -218,7 +219,7 @@ void vehicle_visual_virginia_reel(paint_session * session, sint32 x, sint32 imag
riding_peep_sprites[((ecx / 8) + i) & 3] = vehicle->peep_tshirt_colours[i];
}
sint32 draw_order[4] = {0, 1, 3, 2};
for (sint32 i = 0; i < countof(draw_order); i++) {
for (uint32 i = 0; i < Util::CountOf(draw_order); i++) {
if (riding_peep_sprites[draw_order[i]] != 0xFF) {
image_id = (baseImage_id + ((draw_order[i] + 1) * 72)) | SPRITE_ID_PALETTE_COLOUR_1(riding_peep_sprites[draw_order[i]]);
sub_98199C(session, image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, rotation);

View File

@@ -25,7 +25,7 @@
*/
static void paint_circus_show_tent(paint_session * session, uint8 rideIndex, uint8 direction, sint8 al, sint8 cl, uint16 height)
{
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
Ride * ride = get_ride(rideIndex);
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);

View File

@@ -44,7 +44,7 @@ rct_crooked_house_bound_box crooked_house_data[] = {
* @param (edx) height
*/
static void paint_crooked_house_structure(paint_session * session, uint8 direction, uint8 x_offset, uint8 y_offset, uint32 segment, sint32 height) {
rct_map_element *original_map_element = session->CurrentlyDrawnItem;
rct_map_element *original_map_element = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
Ride *ride = get_ride(original_map_element->properties.track.ride_index);

View File

@@ -58,7 +58,7 @@ static void paint_ferris_wheel_structure(paint_session * session, uint8 rideInde
{
uint32 imageId, baseImageId;
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
Ride * ride = get_ride(rideIndex);
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);

View File

@@ -44,7 +44,7 @@ static haunted_house_bound_box haunted_house_data[] = {
*/
static void paint_haunted_house_structure(paint_session * session, uint8 rideIndex, uint8 direction, sint8 xOffset, sint8 yOffset, uint8 part, uint16 height)
{
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
uint8 frameNum = 0;

View File

@@ -35,7 +35,7 @@ static const uint16 merry_go_round_breakdown_vibration[] = {
*/
static void paint_merry_go_round_structure(paint_session * session, uint8 rideIndex, uint8 direction, sint8 xOffset, sint8 yOffset, uint16 height)
{
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
height += 7;
Ride * ride = get_ride(rideIndex);

View File

@@ -23,6 +23,7 @@
#include "../track_paint.h"
#include "../../world/map.h"
#include "../vehicle_paint.h"
#include "../../core/Util.hpp"
enum {
SPR_MINI_GOLF_FLAT_SW_NE = 14404,
@@ -413,15 +414,15 @@ static const uint8 * mini_golf_peep_animation_frames[] = {
};
const uint8 mini_golf_peep_animation_lengths[] = {
countof(mini_golf_peep_animation_frames_walk),
countof(mini_golf_peep_animation_frames_place_ball_downwards),
countof(mini_golf_peep_animation_frames_swing_left),
countof(mini_golf_peep_animation_frames_place_ball_upwards),
countof(mini_golf_peep_animation_frames_jump),
countof(mini_golf_peep_animation_frames_pickup_ball),
countof(mini_golf_peep_animation_frames_put_left),
countof(mini_golf_peep_animation_frames_swing),
countof(mini_golf_peep_animation_frames_put),
Util::CountOf(mini_golf_peep_animation_frames_walk),
Util::CountOf(mini_golf_peep_animation_frames_place_ball_downwards),
Util::CountOf(mini_golf_peep_animation_frames_swing_left),
Util::CountOf(mini_golf_peep_animation_frames_place_ball_upwards),
Util::CountOf(mini_golf_peep_animation_frames_jump),
Util::CountOf(mini_golf_peep_animation_frames_pickup_ball),
Util::CountOf(mini_golf_peep_animation_frames_put_left),
Util::CountOf(mini_golf_peep_animation_frames_swing),
Util::CountOf(mini_golf_peep_animation_frames_put),
};
static paint_struct * mini_golf_paint_util_7c(

View File

@@ -39,7 +39,7 @@ static const uint32 space_rings_fence_sprites[] = {
/** rct2: 0x00768A3B */
static void paint_space_rings_structure(paint_session * session, Ride * ride, uint8 direction, uint32 segment, sint32 height)
{
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
uint32 vehicleIndex = (segment - direction) & 0x3;

View File

@@ -116,10 +116,14 @@ static void spiral_slide_paint_tile_front(paint_session * session, uint8 rideInd
sint32 offset = SPIRAL_SLIDE_PEEP + 46 * direction;
rct_xyz8 boundingBox = {
.x = 0,
.y = 0,
.z = 108
};
rct_xyz16 boundingBoxOffset = {
.z = height + 3
.x = 0,
.y = 0,
.z = static_cast<sint16>(height + 3)
};
if (direction == 0) {

View File

@@ -25,7 +25,7 @@
*/
static void paint_3d_cinema_structure(paint_session * session, uint8 rideIndex, uint8 direction, sint8 xOffset, sint8 yOffset, uint16 height)
{
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
Ride * ride = get_ride(rideIndex);
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);

View File

@@ -26,7 +26,7 @@ static void paint_enterprise_structure(paint_session * session, Ride * ride, sin
{
height += 7;
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);
rct_vehicle * vehicle = NULL;

View File

@@ -154,7 +154,7 @@ static void paint_magic_carpet_vehicle(paint_session * session, Ride *ride, uint
/** rct2: 0x00899104 */
static void paint_magic_carpet_structure(paint_session * session, Ride *ride, uint8 direction, sint8 axisOffset, uint16 height)
{
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
rct_vehicle *vehicle = get_first_vehicle(ride);
uint32 swingImageId = 0;

View File

@@ -40,7 +40,7 @@ static void paint_motionsimulator_vehicle(paint_session * session, sint8 offsetX
Ride *ride = get_ride(mapElement->properties.track.ride_index);
rct_ride_entry *rideEntry = get_ride_entry_by_ride(ride);
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
rct_vehicle *vehicle = NULL;
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK) {

View File

@@ -70,7 +70,7 @@ static void paint_pirate_ship_structure(paint_session * session, Ride * ride, ui
{
uint32 imageId, baseImageId;
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
rct_ride_entry * rideType = get_ride_entry(ride->subtype);
rct_vehicle * vehicle = NULL;

View File

@@ -62,7 +62,7 @@ static const uint32 swinging_inverter_ship_frame_sprites[] = {
static void paint_swinging_inverter_ship_structure(paint_session * session, Ride * ride, uint8 direction, sint8 axisOffset, uint16 height)
{
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
rct_ride_entry * rideType = get_ride_entry(ride->subtype);
rct_vehicle * vehicle = NULL;

View File

@@ -52,7 +52,7 @@ static void top_spin_paint_vehicle(paint_session * session, sint8 al, sint8 cl,
uint16 boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ;
// As we will be drawing a vehicle we need to backup the mapElement that
// is assigned to the drawings.
rct_map_element* curMapElement = session->CurrentlyDrawnItem;
rct_map_element* curMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
height += 3;
@@ -141,12 +141,12 @@ static void top_spin_paint_vehicle(paint_session * session, sint8 al, sint8 cl,
rct_xyz16 seatCoords = {
.x = al,
.y = cl,
.z = height
.z = static_cast<sint16>(height)
};
seatCoords.z += TopSpinSeatHeightOffset[armRotation];
assert(armRotation < sizeof(TopSpinSeatPositionOffset));
assert(armRotation < static_cast<sint8>(sizeof(TopSpinSeatPositionOffset)));
switch (direction) {
case 0:
seatCoords.x -= TopSpinSeatPositionOffset[armRotation];

View File

@@ -24,7 +24,7 @@
/** rct2: 0x0076E5C9 */
static void paint_twist_structure(paint_session * session, Ride * ride, uint8 direction, sint8 xOffset, sint8 yOffset, uint16 height)
{
rct_map_element * savedMapElement = session->CurrentlyDrawnItem;
rct_map_element * savedMapElement = static_cast<rct_map_element *>(session->CurrentlyDrawnItem);
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);
rct_vehicle * vehicle = NULL;

View File

@@ -265,6 +265,8 @@ extern const uint8 mapLeftEighthTurnToOrthogonal[5];
extern bool gUseOriginalRidePaint;
extern const uint8 mini_golf_peep_animation_lengths[9];
bool track_paint_util_has_fence(enum edge_t edge, rct_xy16 position, rct_map_element * mapElement, Ride * ride, uint8 rotation);
void track_paint_util_paint_floor(paint_session * session, uint8 edges, uint32 colourFlags, uint16 height, const uint32 floorSprites[4], uint8 rotation);
void track_paint_util_paint_fences(paint_session * session, uint8 edges, rct_xy16 position, rct_map_element * mapElement, Ride * ride, uint32 colourFlags, uint16 height, const uint32 fenceSprites[4], uint8 rotation);

View File

@@ -73,7 +73,7 @@ enum
SPR_CHAIRLIFT_STATION_END_CAP_SE,
SPR_CHAIRLIFT_STATION_END_CAP_SW,
SPR_CHAIRLIFT_STATION_END_CAP_NW,
} SPR_CHAIRLIFT;
};
const uint32 chairlift_bullwheel_frames[] = {
SPR_CHAIRLIFT_BULLWHEEL_FRAME_1,
@@ -138,8 +138,8 @@ static bool chairlift_paint_util_is_first_track(uint8 rideIndex, const rct_map_e
rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)];
rct_xy16 newPos = {
.x = pos.x - delta.x,
.y = pos.y - delta.y,
.x = static_cast<sint16>(pos.x - delta.x),
.y = static_cast<sint16>(pos.y - delta.y),
};
rct_map_element * nextTrack = chairlift_paint_util_map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex);
@@ -155,8 +155,8 @@ static bool chairlift_paint_util_is_last_track(uint8 rideIndex, const rct_map_el
rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)];
rct_xy16 newPos = {
.x = pos.x + delta.x,
.y = pos.y + delta.y,
.x = static_cast<sint16>(pos.x + delta.x),
.y = static_cast<sint16>(pos.y + delta.y),
};
rct_map_element * nextTrack = chairlift_paint_util_map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex);

View File

@@ -8076,8 +8076,6 @@ loc_6DBE7F:
return false;
}
extern const uint8 mini_golf_peep_animation_lengths[];
/**
* rct2: 0x006DC3A7
*

View File

@@ -19,6 +19,10 @@
#include "vehicle.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct vehicle_boundbox {
sint8 offset_x;
sint8 offset_y;
@@ -45,4 +49,8 @@ void vehicle_visual_submarine(paint_session * session, sint32 x, sint32 imageDir
void vehicle_visual_mini_golf_player(paint_session * session, sint32 x, sint32 imageDirection, sint32 y, sint32 z, rct_vehicle *vehicle);
void vehicle_visual_mini_golf_ball(paint_session * session, sint32 x, sint32 imageDirection, sint32 y, sint32 z, rct_vehicle *vehicle);
#ifdef __cplusplus
}
#endif
#endif