2017-06-01 21:55:10 +02:00
|
|
|
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
2016-06-25 23:07:01 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* 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
|
|
|
|
|
|
|
|
#include "../core/IStream.hpp"
|
|
|
|
#include "../core/Memory.hpp"
|
2016-11-16 14:25:37 +01:00
|
|
|
#include "../core/String.hpp"
|
2017-06-08 00:17:19 +02:00
|
|
|
#include "../OpenRCT2.h"
|
2016-06-29 23:15:38 +02:00
|
|
|
#include "ObjectRepository.h"
|
2016-06-25 23:07:01 +02:00
|
|
|
#include "RideObject.h"
|
2017-06-14 13:31:27 +02:00
|
|
|
#include "../ride/RideGroupManager.h"
|
2016-06-25 23:07:01 +02:00
|
|
|
|
2018-01-05 22:17:33 +01:00
|
|
|
#include "../drawing/Drawing.h"
|
2018-01-06 18:32:25 +01:00
|
|
|
#include "../localisation/Language.h"
|
2018-01-09 10:40:42 +01:00
|
|
|
#include "../rct2/RCT2.h"
|
2017-12-31 13:21:34 +01:00
|
|
|
#include "../ride/Ride.h"
|
2017-10-17 13:51:47 +02:00
|
|
|
#include "../ride/Track.h"
|
2016-06-25 23:07:01 +02:00
|
|
|
|
|
|
|
RideObject::~RideObject()
|
|
|
|
{
|
2017-12-20 02:50:18 +01:00
|
|
|
for (auto &peepLoadingPosition : _peepLoadingPositions)
|
2016-06-26 23:01:43 +02:00
|
|
|
{
|
2017-12-20 02:50:18 +01:00
|
|
|
Memory::Free(peepLoadingPosition);
|
2016-06-26 23:01:43 +02:00
|
|
|
}
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
|
|
|
|
2016-07-01 22:01:06 +02:00
|
|
|
void RideObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
2016-07-06 21:19:33 +02:00
|
|
|
stream->Seek(8, STREAM_SEEK_CURRENT);
|
|
|
|
_legacyType.flags = stream->ReadValue<uint32>();
|
2017-12-20 02:50:18 +01:00
|
|
|
for (auto &rideType : _legacyType.ride_type)
|
2016-07-06 21:19:33 +02:00
|
|
|
{
|
2017-12-20 02:50:18 +01:00
|
|
|
rideType = stream->ReadValue<uint8>();
|
2016-07-06 21:19:33 +02:00
|
|
|
}
|
|
|
|
_legacyType.min_cars_in_train = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.max_cars_in_train = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.cars_per_flat_ride = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.zero_cars = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.tab_vehicle = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.default_vehicle = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.front_vehicle = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.second_vehicle = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.rear_vehicle = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.third_vehicle = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.pad_019 = stream->ReadValue<uint8>();
|
2017-12-20 02:50:18 +01:00
|
|
|
for (auto &vehicleEntry : _legacyType.vehicles)
|
2016-07-06 21:19:33 +02:00
|
|
|
{
|
2017-12-20 02:50:18 +01:00
|
|
|
ReadLegacyVehicle(context, stream, &vehicleEntry);
|
2016-07-06 21:19:33 +02:00
|
|
|
}
|
|
|
|
stream->Seek(4, STREAM_SEEK_CURRENT);
|
2017-11-13 16:22:36 +01:00
|
|
|
_legacyType.excitement_multiplier = stream->ReadValue<sint8>();
|
|
|
|
_legacyType.intensity_multiplier = stream->ReadValue<sint8>();
|
|
|
|
_legacyType.nausea_multiplier = stream->ReadValue<sint8>();
|
2016-07-06 21:19:33 +02:00
|
|
|
_legacyType.max_height = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.enabledTrackPieces = stream->ReadValue<uint64>();
|
|
|
|
_legacyType.category[0] = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.category[1] = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.shop_item = stream->ReadValue<uint8>();
|
|
|
|
_legacyType.shop_item_secondary = stream->ReadValue<uint8>();
|
2016-06-25 23:07:01 +02:00
|
|
|
|
2016-07-01 22:01:06 +02:00
|
|
|
GetStringTable()->Read(context, stream, OBJ_STRING_ID_NAME);
|
|
|
|
GetStringTable()->Read(context, stream, OBJ_STRING_ID_DESCRIPTION);
|
|
|
|
GetStringTable()->Read(context, stream, OBJ_STRING_ID_CAPACITY);
|
2016-06-25 23:07:01 +02:00
|
|
|
|
|
|
|
// Read preset colours, by default there are 32
|
|
|
|
_presetColours.count = stream->ReadValue<uint8>();
|
2016-11-13 13:37:30 +01:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 coloursCount = _presetColours.count;
|
2016-11-13 20:17:49 +01:00
|
|
|
// To indicate a ride has different colours each train the count
|
2016-09-12 21:11:43 +02:00
|
|
|
// is set to 255. There are only actually 32 colours though.
|
|
|
|
if (coloursCount == 255)
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
2016-09-12 21:11:43 +02:00
|
|
|
coloursCount = 32;
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
2016-09-12 21:11:43 +02:00
|
|
|
|
|
|
|
for (uint8 i = 0; i < coloursCount; i++)
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
|
|
|
_presetColours.list[i] = stream->ReadValue<vehicle_colour>();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read peep loading positions
|
2017-08-01 16:34:26 +02:00
|
|
|
for (sint32 i = 0; i < RCT2_MAX_VEHICLES_PER_RIDE_ENTRY; i++)
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
|
|
|
uint16 numPeepLoadingPositions = stream->ReadValue<uint8>();
|
|
|
|
if (numPeepLoadingPositions == 255)
|
|
|
|
{
|
|
|
|
numPeepLoadingPositions = stream->ReadValue<uint16>();
|
|
|
|
}
|
|
|
|
_peepLoadingPositions[i] = stream->ReadArray<sint8>(numPeepLoadingPositions);
|
2017-06-07 22:56:29 +02:00
|
|
|
_peepLoadingPositionsCount[i] = numPeepLoadingPositions;
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
|
|
|
|
2016-07-01 22:01:06 +02:00
|
|
|
GetImageTable()->Read(context, stream);
|
2016-07-02 18:23:06 +02:00
|
|
|
|
|
|
|
// Validate properties
|
2017-11-13 16:22:36 +01:00
|
|
|
if (_legacyType.excitement_multiplier > 75)
|
2016-07-02 18:23:06 +02:00
|
|
|
{
|
|
|
|
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Excitement multiplier too high.");
|
|
|
|
}
|
2017-11-13 16:22:36 +01:00
|
|
|
if (_legacyType.intensity_multiplier > 75)
|
2016-07-02 18:23:06 +02:00
|
|
|
{
|
|
|
|
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Intensity multiplier too high.");
|
|
|
|
}
|
2017-11-13 16:22:36 +01:00
|
|
|
if (_legacyType.nausea_multiplier > 75)
|
2016-07-02 18:23:06 +02:00
|
|
|
{
|
|
|
|
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Nausea multiplier too high.");
|
|
|
|
}
|
2016-11-16 14:25:37 +01:00
|
|
|
|
2017-06-23 17:29:51 +02:00
|
|
|
PerformFixes();
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RideObject::Load()
|
|
|
|
{
|
2016-07-11 23:50:55 +02:00
|
|
|
GetStringTable()->Sort();
|
2017-09-19 12:18:17 +02:00
|
|
|
_legacyType.naming.name = language_allocate_object_string(GetName());
|
|
|
|
_legacyType.naming.description = language_allocate_object_string(GetDescription());
|
2017-11-20 16:40:18 +01:00
|
|
|
_legacyType.capacity = language_allocate_object_string(GetCapacity());
|
2016-06-26 22:43:30 +02:00
|
|
|
_legacyType.images_offset = gfx_object_allocate_images(GetImageTable()->GetImages(), GetImageTable()->GetCount());
|
2016-07-02 22:52:17 +02:00
|
|
|
_legacyType.vehicle_preset_list = &_presetColours;
|
2016-06-25 23:07:01 +02:00
|
|
|
|
2017-12-04 14:04:32 +01:00
|
|
|
sint32 cur_vehicle_images_offset = _legacyType.images_offset + MAX_RIDE_TYPES_PER_RIDE_ENTRY;
|
2017-09-13 10:40:27 +02:00
|
|
|
for (sint32 i = 0; i < RCT2_MAX_VEHICLES_PER_RIDE_ENTRY; i++)
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
|
|
|
rct_ride_entry_vehicle * vehicleEntry = &_legacyType.vehicles[i];
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_FLAT)
|
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
// RCT2 calculates num_vertical_frames and num_horizontal_frames and overwrites these properties on the vehicle entry.
|
|
|
|
// Immediately afterwards, the two were multiplied in order to calculate base_num_frames and were never used again.
|
|
|
|
// This has been changed to use the calculation results directly -
|
|
|
|
// num_vertical_frames and num_horizontal_frames are no longer set on the vehicle entry.
|
2016-06-25 23:07:01 +02:00
|
|
|
// 0x6DE946
|
2017-09-15 17:50:38 +02:00
|
|
|
vehicleEntry->base_num_frames = CalculateNumVerticalFrames(vehicleEntry) * CalculateNumHorizontalFrames(vehicleEntry);
|
2016-06-25 23:07:01 +02:00
|
|
|
vehicleEntry->base_image_id = cur_vehicle_images_offset;
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 image_index = vehicleEntry->base_image_id;
|
2016-06-25 23:07:01 +02:00
|
|
|
|
|
|
|
if (vehicleEntry->car_visual != VEHICLE_VISUAL_RIVER_RAPIDS)
|
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
sint32 b = vehicleEntry->base_num_frames * 32;
|
2016-06-25 23:07:01 +02:00
|
|
|
|
2017-07-31 12:27:04 +02:00
|
|
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_11) b /= 2;
|
2016-06-25 23:07:01 +02:00
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_15) b /= 8;
|
|
|
|
|
|
|
|
image_index += b;
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_GENTLE_SLOPES)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->gentle_slope_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 72;
|
2018-01-06 10:45:44 +01:00
|
|
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES)
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 16;
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_STEEP_SLOPES)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->steep_slope_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 80;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->vertical_slope_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 116;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->diagonal_slope_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 24;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_FLAT_BANKED)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->banked_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 80;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_INLINE_TWISTS)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->inline_twist_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 40;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_BANKED_TRANSITIONS)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->flat_to_gentle_bank_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 128;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->diagonal_to_gentle_slope_bank_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 16;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->gentle_slope_to_bank_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 16;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TURNS)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->gentle_slope_bank_turn_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 128;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_FLAT_TO_GENTLE_SLOPE_WHILE_BANKED_TRANSITIONS)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->flat_bank_to_gentle_slope_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 16;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_CORKSCREWS)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->corkscrew_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 80;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION)
|
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicleEntry->restraint_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 12;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
|
2018-01-17 21:39:16 +01:00
|
|
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL)
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
2018-01-17 21:39:16 +01:00
|
|
|
// Same offset as corkscrew
|
|
|
|
vehicleEntry->curved_lift_hill_image_id = image_index;
|
2017-09-15 17:50:38 +02:00
|
|
|
b = vehicleEntry->base_num_frames * 32;
|
2016-06-25 23:07:01 +02:00
|
|
|
image_index += b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
image_index += vehicleEntry->base_num_frames * 36;
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// No vehicle images
|
|
|
|
vehicleEntry->no_vehicle_images = image_index - cur_vehicle_images_offset;
|
|
|
|
|
|
|
|
// Move the offset over this vehicles images. Including peeps
|
|
|
|
cur_vehicle_images_offset = image_index + vehicleEntry->no_seating_rows * vehicleEntry->no_vehicle_images;
|
|
|
|
// 0x6DEB0D
|
|
|
|
|
2017-07-31 12:27:04 +02:00
|
|
|
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_10))
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 num_images = cur_vehicle_images_offset - vehicleEntry->base_image_id;
|
2017-07-31 12:27:04 +02:00
|
|
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_13)
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
|
|
|
num_images *= 2;
|
|
|
|
}
|
|
|
|
|
2017-06-08 00:17:19 +02:00
|
|
|
if (!gOpenRCT2NoGraphics) {
|
|
|
|
set_vehicle_type_image_max_sizes(vehicleEntry, num_images);
|
|
|
|
}
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
|
|
|
vehicleEntry->peep_loading_positions = _peepLoadingPositions[i];
|
2017-06-07 22:56:29 +02:00
|
|
|
vehicleEntry->peep_loading_positions_count = _peepLoadingPositionsCount[i];
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RideObject::Unload()
|
|
|
|
{
|
2017-09-19 12:18:17 +02:00
|
|
|
language_free_object_string(_legacyType.naming.name);
|
|
|
|
language_free_object_string(_legacyType.naming.description);
|
2017-11-20 16:40:18 +01:00
|
|
|
language_free_object_string(_legacyType.capacity);
|
2016-06-26 22:43:30 +02:00
|
|
|
gfx_object_free_images(_legacyType.images_offset, GetImageTable()->GetCount());
|
2016-07-03 19:02:18 +02:00
|
|
|
|
2017-09-19 12:18:17 +02:00
|
|
|
_legacyType.naming.name = 0;
|
|
|
|
_legacyType.naming.description = 0;
|
2017-11-20 16:40:18 +01:00
|
|
|
_legacyType.capacity = 0;
|
2016-07-03 19:02:18 +02:00
|
|
|
_legacyType.images_offset = 0;
|
2016-07-02 13:06:29 +02:00
|
|
|
}
|
|
|
|
|
2016-07-11 23:09:15 +02:00
|
|
|
void RideObject::DrawPreview(rct_drawpixelinfo * dpi, sint32 width, sint32 height) const
|
2016-07-02 13:06:29 +02:00
|
|
|
{
|
|
|
|
uint32 imageId = _legacyType.images_offset;
|
2017-12-04 14:04:32 +01:00
|
|
|
|
2017-12-20 02:50:18 +01:00
|
|
|
for (auto rideType : _legacyType.ride_type)
|
2016-07-02 13:06:29 +02:00
|
|
|
{
|
2017-12-20 02:50:18 +01:00
|
|
|
if (rideType != RIDE_TYPE_NULL)
|
2017-12-04 14:04:32 +01:00
|
|
|
break;
|
|
|
|
else
|
2016-07-02 13:06:29 +02:00
|
|
|
imageId++;
|
|
|
|
}
|
2017-12-04 14:04:32 +01:00
|
|
|
|
2016-07-02 13:06:29 +02:00
|
|
|
gfx_draw_sprite(dpi, imageId, 0, 0, 0);
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
|
|
|
|
2017-12-05 13:55:33 +01:00
|
|
|
std::string RideObject::GetDescription() const
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
2016-07-04 19:53:35 +02:00
|
|
|
return GetString(OBJ_STRING_ID_DESCRIPTION);
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
|
|
|
|
2017-12-05 13:55:33 +01:00
|
|
|
std::string RideObject::GetCapacity() const
|
2016-06-25 23:07:01 +02:00
|
|
|
{
|
2016-07-04 19:53:35 +02:00
|
|
|
return GetString(OBJ_STRING_ID_CAPACITY);
|
2016-06-25 23:07:01 +02:00
|
|
|
}
|
2016-06-29 23:15:38 +02:00
|
|
|
|
|
|
|
void RideObject::SetRepositoryItem(ObjectRepositoryItem * item) const
|
|
|
|
{
|
2017-08-01 16:34:26 +02:00
|
|
|
for (sint32 i = 0; i < RCT2_MAX_RIDE_TYPES_PER_RIDE_ENTRY; i++)
|
2016-06-29 23:15:38 +02:00
|
|
|
{
|
|
|
|
item->RideType[i] = _legacyType.ride_type[i];
|
|
|
|
}
|
2017-08-01 16:34:26 +02:00
|
|
|
for (sint32 i = 0; i < RCT2_MAX_CATEGORIES_PER_RIDE; i++)
|
2016-06-29 23:15:38 +02:00
|
|
|
{
|
|
|
|
item->RideCategory[i] = _legacyType.category[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 flags = 0;
|
|
|
|
item->RideFlags = flags;
|
2017-06-14 13:31:27 +02:00
|
|
|
|
|
|
|
// Find the first non-null ride type, to be used when checking the ride group
|
|
|
|
uint8 rideTypeIdx = ride_entry_get_first_non_null_ride_type((rct_ride_entry *)&_legacyType);
|
|
|
|
|
|
|
|
// Determines the ride group. Will fall back to 0 if there is none found.
|
|
|
|
uint8 rideGroupIndex = 0;
|
|
|
|
|
2017-10-06 10:29:24 +02:00
|
|
|
const RideGroup * rideGroup = RideGroupManager::GetRideGroup(rideTypeIdx, (rct_ride_entry *)&_legacyType);
|
2017-06-17 13:41:40 +02:00
|
|
|
|
2017-08-15 10:07:44 +02:00
|
|
|
// If the ride group is nullptr, the track type does not have ride groups.
|
|
|
|
if (rideGroup != nullptr)
|
2017-06-14 13:31:27 +02:00
|
|
|
{
|
|
|
|
for (uint8 i = rideGroupIndex + 1; i < MAX_RIDE_GROUPS_PER_RIDE_TYPE; i++)
|
|
|
|
{
|
2017-10-06 10:29:24 +02:00
|
|
|
const RideGroup * irg = RideGroupManager::RideGroupFind(rideTypeIdx, i);
|
2017-06-17 13:41:40 +02:00
|
|
|
|
2017-08-15 10:07:44 +02:00
|
|
|
if (irg != nullptr)
|
2017-06-14 13:31:27 +02:00
|
|
|
{
|
2017-10-06 10:29:24 +02:00
|
|
|
if (RideGroupManager::RideGroupsAreEqual(irg, rideGroup))
|
2017-06-14 13:31:27 +02:00
|
|
|
{
|
|
|
|
rideGroupIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-17 13:41:40 +02:00
|
|
|
|
2017-06-14 13:31:27 +02:00
|
|
|
item->RideGroupIndex = rideGroupIndex;
|
2016-06-29 23:15:38 +02:00
|
|
|
}
|
2016-07-06 21:19:33 +02:00
|
|
|
|
|
|
|
void RideObject::ReadLegacyVehicle(IReadObjectContext * context, IStream * stream, rct_ride_entry_vehicle * vehicle)
|
|
|
|
{
|
|
|
|
vehicle->rotation_frame_mask = stream->ReadValue<uint16>();
|
2017-09-15 17:50:38 +02:00
|
|
|
vehicle->num_vertical_frames = stream->ReadValue<uint8>();
|
|
|
|
vehicle->num_horizontal_frames = stream->ReadValue<uint8>();
|
2016-07-06 21:19:33 +02:00
|
|
|
vehicle->spacing = stream->ReadValue<uint32>();
|
2017-12-17 18:00:42 +01:00
|
|
|
vehicle->car_mass = stream->ReadValue<uint16>();
|
2016-07-06 21:19:33 +02:00
|
|
|
vehicle->tab_height = stream->ReadValue<sint8>();
|
|
|
|
vehicle->num_seats = stream->ReadValue<uint8>();
|
|
|
|
vehicle->sprite_flags = stream->ReadValue<uint16>();
|
|
|
|
vehicle->sprite_width = stream->ReadValue<uint8>();
|
|
|
|
vehicle->sprite_height_negative = stream->ReadValue<uint8>();
|
|
|
|
vehicle->sprite_height_positive = stream->ReadValue<uint8>();
|
2018-01-17 22:05:19 +01:00
|
|
|
vehicle->animation = stream->ReadValue<uint8>();
|
2017-07-31 12:27:04 +02:00
|
|
|
vehicle->flags = stream->ReadValue<uint32>();
|
2017-09-15 17:50:38 +02:00
|
|
|
vehicle->base_num_frames = stream->ReadValue<uint16>();
|
2016-07-06 21:19:33 +02:00
|
|
|
stream->Seek(4, STREAM_SEEK_CURRENT);
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicle->restraint_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->gentle_slope_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->steep_slope_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->vertical_slope_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->diagonal_slope_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->banked_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->inline_twist_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->flat_to_gentle_bank_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->diagonal_to_gentle_slope_bank_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->gentle_slope_to_bank_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->gentle_slope_bank_turn_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->flat_bank_to_gentle_slope_image_id = stream->ReadValue<uint32>();
|
|
|
|
vehicle->corkscrew_image_id = stream->ReadValue<uint32>();
|
2016-07-06 21:19:33 +02:00
|
|
|
vehicle->no_vehicle_images = stream->ReadValue<uint32>();
|
|
|
|
vehicle->no_seating_rows = stream->ReadValue<uint8>();
|
|
|
|
vehicle->spinning_inertia = stream->ReadValue<uint8>();
|
|
|
|
vehicle->spinning_friction = stream->ReadValue<uint8>();
|
|
|
|
vehicle->friction_sound_id = stream->ReadValue<uint8>();
|
2018-01-17 21:39:16 +01:00
|
|
|
vehicle->log_flume_reverser_vehicle_type = stream->ReadValue<uint8>();
|
2016-07-06 21:19:33 +02:00
|
|
|
vehicle->sound_range = stream->ReadValue<uint8>();
|
2018-01-04 22:38:27 +01:00
|
|
|
vehicle->double_sound_frequency = stream->ReadValue<uint8>();
|
2016-07-06 21:19:33 +02:00
|
|
|
vehicle->powered_acceleration = stream->ReadValue<uint8>();
|
|
|
|
vehicle->powered_max_speed = stream->ReadValue<uint8>();
|
|
|
|
vehicle->car_visual = stream->ReadValue<uint8>();
|
|
|
|
vehicle->effect_visual = stream->ReadValue<uint8>();
|
|
|
|
vehicle->draw_order = stream->ReadValue<uint8>();
|
2017-09-15 17:50:38 +02:00
|
|
|
vehicle->num_vertical_frames_override = stream->ReadValue<uint8>();
|
2016-07-06 21:19:33 +02:00
|
|
|
stream->Seek(4, STREAM_SEEK_CURRENT);
|
|
|
|
}
|
2016-11-16 14:25:37 +01:00
|
|
|
|
2017-06-23 17:29:51 +02:00
|
|
|
void RideObject::PerformFixes()
|
2016-11-16 14:25:37 +01:00
|
|
|
{
|
2017-06-23 17:29:51 +02:00
|
|
|
std::string identifier = GetIdentifier();
|
|
|
|
|
|
|
|
// Add boosters if the track type is eligible
|
2017-12-20 02:50:18 +01:00
|
|
|
for (auto rideType : _legacyType.ride_type)
|
2017-06-23 17:29:51 +02:00
|
|
|
{
|
2017-12-20 02:50:18 +01:00
|
|
|
if (ride_type_supports_boosters(rideType))
|
2017-06-23 17:29:51 +02:00
|
|
|
{
|
|
|
|
_legacyType.enabledTrackPieces |= (1ULL << TRACK_BOOSTER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The rocket cars could take 3 cars per train in RCT1. Restore this.
|
|
|
|
if (String::Equals(identifier, "RCKC "))
|
|
|
|
{
|
2016-11-16 14:25:37 +01:00
|
|
|
_legacyType.max_cars_in_train = 3 + _legacyType.zero_cars;
|
|
|
|
}
|
2017-11-13 15:16:48 +01:00
|
|
|
// The Wooden Roller Coaster could take 7 cars per train in RCT1.
|
|
|
|
else if (String::Equals(identifier, "PTCT1 "))
|
|
|
|
{
|
|
|
|
_legacyType.max_cars_in_train = 7 + _legacyType.zero_cars;
|
|
|
|
}
|
|
|
|
// The Looping Roller Coaster could take 8 cars per train in RCT1.
|
|
|
|
else if (String::Equals(identifier, "SCHT1 "))
|
|
|
|
{
|
|
|
|
_legacyType.max_cars_in_train = 8 + _legacyType.zero_cars;
|
|
|
|
}
|
2017-11-13 20:37:13 +01:00
|
|
|
// The Steel Twister could take 8 cars per train in RCT1. (The other two vehicles are already correct.)
|
|
|
|
else if (String::Equals(identifier, "BMSD ") || String::Equals(identifier, "BMSU "))
|
2017-11-13 15:16:48 +01:00
|
|
|
{
|
|
|
|
_legacyType.max_cars_in_train = 8 + _legacyType.zero_cars;
|
|
|
|
}
|
2017-07-20 16:18:36 +02:00
|
|
|
// Wacky Worlds' Crocodile Ride (a log flume vehicle) is incorrectly locked to 5 cars.
|
2017-06-23 17:29:51 +02:00
|
|
|
else if (String::Equals(identifier, "CROCFLUM"))
|
|
|
|
{
|
|
|
|
_legacyType.cars_per_flat_ride = 0xFF;
|
|
|
|
}
|
2017-07-20 20:56:29 +02:00
|
|
|
// All vanilla/WW/OCC Junior RC vehicles incorrectly have this flag set
|
2017-07-15 10:52:21 +02:00
|
|
|
else if (String::Equals(identifier, "ZLDB ") ||
|
|
|
|
String::Equals(identifier, "ZLOG ") ||
|
|
|
|
String::Equals(identifier, "ZPANDA ") ||
|
|
|
|
String::Equals(identifier, "WHICGRUB"))
|
|
|
|
{
|
|
|
|
_legacyType.enabledTrackPieces &= ~(1ULL << TRACK_SLOPE_STEEP);
|
|
|
|
}
|
2016-11-16 14:25:37 +01:00
|
|
|
}
|
2017-09-14 14:30:09 +02:00
|
|
|
|
2017-09-15 17:50:38 +02:00
|
|
|
uint8 RideObject::CalculateNumVerticalFrames(const rct_ride_entry_vehicle * vehicleEntry)
|
2017-09-14 14:30:09 +02:00
|
|
|
{
|
|
|
|
// 0x6DE90B
|
2017-09-15 17:50:38 +02:00
|
|
|
uint8 numVerticalFrames;
|
|
|
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_OVERRIDE_NUM_VERTICAL_FRAMES)
|
2017-09-14 14:30:09 +02:00
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
numVerticalFrames = vehicleEntry->num_vertical_frames_override;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-06 10:45:44 +01:00
|
|
|
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES))
|
2017-09-14 14:30:09 +02:00
|
|
|
{
|
2018-01-17 22:56:22 +01:00
|
|
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_VEHICLE_ANIMATION && vehicleEntry->animation != VEHICLE_ENTRY_ANIMATION_OBSERVATION_TOWER)
|
2017-09-14 14:30:09 +02:00
|
|
|
{
|
2018-01-13 10:07:52 +01:00
|
|
|
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_DODGEM_INUSE_LIGHTS))
|
2017-09-14 14:30:09 +02:00
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
numVerticalFrames = 4;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
numVerticalFrames = 2;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
numVerticalFrames = 1;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
numVerticalFrames = 32;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-15 17:50:38 +02:00
|
|
|
return numVerticalFrames;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
|
2017-09-15 17:50:38 +02:00
|
|
|
uint8 RideObject::CalculateNumHorizontalFrames(const rct_ride_entry_vehicle * vehicleEntry)
|
2017-09-14 14:30:09 +02:00
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
uint8 numHorizontalFrames;
|
2017-09-14 14:30:09 +02:00
|
|
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SWINGING)
|
|
|
|
{
|
2018-01-17 22:49:38 +01:00
|
|
|
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_21) && !(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SLIDE_SWING))
|
2017-09-14 14:30:09 +02:00
|
|
|
{
|
|
|
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_25)
|
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
numHorizontalFrames = 3;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
numHorizontalFrames = 5;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
}
|
2018-01-17 22:49:38 +01:00
|
|
|
else if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_21) || !(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SLIDE_SWING))
|
2017-09-14 14:30:09 +02:00
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
numHorizontalFrames = 7;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
numHorizontalFrames = 13;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-15 17:50:38 +02:00
|
|
|
numHorizontalFrames = 1;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|
|
|
|
|
2017-09-15 17:50:38 +02:00
|
|
|
return numHorizontalFrames;
|
2017-09-14 14:30:09 +02:00
|
|
|
}
|