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

Harden console command error checking, reduce command array sizes

This commit is contained in:
Richard Jenkins
2017-04-21 16:51:07 +01:00
committed by Michał Janiszewski
parent e51ee316b9
commit 7a50a52582
2 changed files with 6 additions and 4 deletions

View File

@@ -484,7 +484,7 @@ static sint32 cc_rides(const utf8 **argv, sint32 argc)
}
}
else if (strcmp(argv[1], "mode") == 0) {
bool int_valid[3] = { 0 };
bool int_valid[2] = { 0 };
sint32 ride_index = console_parse_int(argv[2], &int_valid[0]);
sint32 mode = console_parse_int(argv[3], &int_valid[1]);
if (!int_valid[0] || !int_valid[1]) {
@@ -493,10 +493,10 @@ static sint32 cc_rides(const utf8 **argv, sint32 argc)
console_printf("Ride index must not be negative");
} else {
rct_ride *ride = get_ride(ride_index);
if (mode <= 0) {
console_printf("Ride mode must be strictly positive");
if (mode <= 0 || mode > RIDE_MODE_COUNT) {
console_printf("Invalid ride mode.");
}
else if (ride->type == RIDE_TYPE_NULL) {
else if (ride == NULL || ride->type == RIDE_TYPE_NULL) {
console_printf("No ride found with index %d", ride_index);
}
else {

View File

@@ -902,6 +902,8 @@ extern const rct_ride_properties RideProperties[RIDE_TYPE_COUNT];
#define MAX_RIDES 255
#define RIDE_MODE_COUNT 36
#define MAX_RIDE_MEASUREMENTS 8
#define RIDE_VALUE_UNDEFINED 0xFFFF
#define RIDE_INITIAL_RELIABILITY ((100 << 8) - 1)