Add constants for max stations per ride (#4979)

This commit is contained in:
Michael Steenbeek 2017-01-03 16:25:17 +01:00 committed by GitHub
parent a19b477c8e
commit 7312d81e17
5 changed files with 17 additions and 10 deletions

View File

@ -977,6 +977,8 @@ enum {
RCT1_PARK_FLAGS_LOCK_REAL_NAMES_OPTION = (1 << 15),
};
#define RCT1_MAX_STATIONS 4
extern const uint8 gRideCategories[0x60];
bool rct1_read_sc4(const char *path, rct1_s4 *s4);

View File

@ -583,7 +583,7 @@ private:
// Station
dst->overall_view = src->overall_view;
for (int i = 0; i < 4; i++)
for (int i = 0; i < RCT1_MAX_STATIONS; i++)
{
dst->station_starts[i] = src->station_starts[i];
dst->station_heights[i] = src->station_height[i] / 2;
@ -702,7 +702,7 @@ private:
dst->max_speed = src->max_speed;
dst->average_speed = src->average_speed;
for (int i = 0; i < 4; i++) {
for (int i = 0; i < RCT1_MAX_STATIONS; i++) {
dst->time[i] = src->time[i];
dst->length[i] = src->length[i];
}
@ -740,7 +740,7 @@ private:
rct_ride *ride;
FOR_ALL_RIDES(i, ride)
{
for (int stationIndex = 0; stationIndex < 4; stationIndex++)
for (int stationIndex = 0; stationIndex < RCT1_MAX_STATIONS; stationIndex++)
{
ride->queue_length[stationIndex] = 0;
}

View File

@ -111,6 +111,8 @@ enum {
extern "C" {
#endif
#define RCT2_MAX_STATIONS 4
extern const char * const RCT2FilePaths[PATH_ID_END];
extern uint32 gCurrentDrawCount;

View File

@ -21,6 +21,8 @@
#include "../world/map.h"
#include "ride.h"
#define MAX_STATIONS 4
void ride_update_station(rct_ride *ride, int stationIndex);
rct_map_element *ride_get_station_start_track_element(rct_ride *ride, int stationIndex);
rct_map_element *ride_get_station_exit_element(rct_ride *ride, int x, int y, int z);

View File

@ -34,6 +34,7 @@
#include "ride.h"
#include "ride_data.h"
#include "ride_ratings.h"
#include "station.h"
#include "track.h"
#include "track_data.h"
@ -616,7 +617,7 @@ static rct_map_element *find_station_element(int x, int y, int z, int direction,
static void ride_remove_station(rct_ride *ride, int x, int y, int z)
{
uint16 xy = (x >> 5) | ((y >> 5) << 8);
for (int i = 0; i < 4; i++) {
for (int i = 0; i < MAX_STATIONS; i++) {
if (ride->station_starts[i] == xy && ride->station_heights[i] == z) {
ride->station_starts[i] = 0xFFFF;
ride->num_stations--;
@ -639,13 +640,13 @@ static bool track_add_station_element(int x, int y, int z, int direction, int ri
rct_ride *ride = get_ride(rideIndex);
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_3)) {
if (ride->num_stations >= 4) {
if (ride->num_stations >= MAX_STATIONS) {
gGameCommandErrorText = STR_NO_MORE_STATIONS_ALLOWED_ON_THIS_RIDE;
return false;
}
if (flags & GAME_COMMAND_FLAG_APPLY) {
int stationIndex = -1;
for (int i = 0; i < 4; i++) {
for (int i = 0; i < MAX_STATIONS; i++) {
if (ride->station_starts[i] == 0xFFFF) {
stationIndex = i;
break;
@ -707,7 +708,7 @@ static bool track_add_station_element(int x, int y, int z, int direction, int ri
}
} while (stationElement != NULL);
if (stationX0 == stationX1 && stationY0 == stationY1 && ride->num_stations >= 4) {
if (stationX0 == stationX1 && stationY0 == stationY1 && ride->num_stations >= MAX_STATIONS) {
gGameCommandErrorText = STR_NO_MORE_STATIONS_ALLOWED_ON_THIS_RIDE;
return false;
}
@ -730,7 +731,7 @@ static bool track_add_station_element(int x, int y, int z, int direction, int ri
int targetTrackType;
if (x == stationX1 && y == stationY1) {
int stationIndex = -1;
for (int i = 0; i < 4; i++) {
for (int i = 0; i < MAX_STATIONS; i++) {
if (ride->station_starts[i] == 0xFFFF) {
stationIndex = i;
break;
@ -837,7 +838,7 @@ static bool track_remove_station_element(int x, int y, int z, int direction, int
if (!(flags & GAME_COMMAND_FLAG_APPLY)) {
if ((removeX != stationX0 || removeY != stationY0) &&
(removeX != stationX1 || removeY != stationY1) &&
ride->num_stations >= 4
ride->num_stations >= MAX_STATIONS
) {
gGameCommandErrorText = STR_NO_MORE_STATIONS_ALLOWED_ON_THIS_RIDE;
return false;
@ -859,7 +860,7 @@ static bool track_remove_station_element(int x, int y, int z, int direction, int
if (x == stationX1 && y == stationY1) {
loc_6C4BF5:;
int stationIndex = -1;
for (int i = 0; i < 4; i++) {
for (int i = 0; i < MAX_STATIONS; i++) {
if (ride->station_starts[i] == 0xFFFF) {
stationIndex = i;
break;