1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 12:03:07 +01:00

Add additional checks on input

This commit is contained in:
X7123M3-256
2016-06-04 20:19:31 +01:00
parent 4f6929edf6
commit 065ffa3e3c

View File

@@ -458,18 +458,26 @@ static int cc_rides(const utf8 **argv, int argc)
return 0;
}
if (strcmp(argv[1], "type") == 0) {
int int_val[3];
int subtype;
bool int_valid[3] = { 0 };
int_val[0] = console_parse_int(argv[2], &int_valid[0]);
int_val[1] = console_parse_int(argv[3], &int_valid[1]);
int ride_index = console_parse_int(argv[2], &int_valid[0]);
int type = console_parse_int(argv[3], &int_valid[1]);
if (argc > 4) {
int_val[2] = console_parse_int(argv[4], &int_valid[2]);
subtype = console_parse_int(argv[4], &int_valid[2]);
}
if (int_valid[0] && int_valid[1] && (get_ride(int_val[0])->type != RIDE_TYPE_NULL)) {
rct_ride *ride = get_ride(int_val[0]);
ride->type = int_val[1];
if (int_valid[2]) {
ride->subtype = int_val[2];
if (!int_valid[0] || !int_valid[1] || (argc > 4 && !int_valid[2])) {
console_printf("This command expects integer arguments");
} else if (ride_index < 0) {
console_printf("Ride index must not be negative");
} else {
rct_ride *ride = get_ride(ride_index);
if(ride->type != RIDE_TYPE_NULL) {
ride->type = type;
if (int_valid[2]) {
ride->subtype = subtype;
}
} else {
console_printf("No ride found with index %d",ride_index);
}
}
}