1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Merge pull request #2803 from janisozaur/fixes

Game commands' argument validation
This commit is contained in:
Ted John
2016-01-24 19:37:20 +00:00
4 changed files with 24 additions and 2 deletions

View File

@@ -149,7 +149,7 @@ namespace String
const utf8 * SkipBOM(const utf8 * buffer) const utf8 * SkipBOM(const utf8 * buffer)
{ {
if (buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) if ((unsigned char)buffer[0] == 0xEF && (unsigned char)buffer[1] == 0xBB && (unsigned char)buffer[2] == 0xBF)
{ {
return buffer + 3; return buffer + 3;
} }

View File

@@ -559,8 +559,14 @@ void game_command_set_research_funding(int* eax, int* ebx, int* ecx, int* edx, i
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_RESEARCH * 4; RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_RESEARCH * 4;
if (*ebx & GAME_COMMAND_FLAG_APPLY) { if (*ebx & GAME_COMMAND_FLAG_APPLY) {
if (!setPriorities) if (!setPriorities) {
if (fundingAmount < 0 || fundingAmount >= countof(_researchRate)) {
*ebx = MONEY32_UNDEFINED;
log_warning("Invalid research rate %d", fundingAmount);
return;
}
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8) = fundingAmount; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8) = fundingAmount;
}
else else
RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint8) = activeCategories; RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint8) = activeCategories;

View File

@@ -4082,7 +4082,17 @@ static bool sub_6C4D89(int x, int y, int z, int direction, int rideIndex, int fl
static money32 track_place(int rideIndex, int type, int originX, int originY, int originZ, int direction, int properties_1, int properties_2, int properties_3, int edx_flags, int flags) static money32 track_place(int rideIndex, int type, int originX, int originY, int originZ, int direction, int properties_1, int properties_2, int properties_3, int edx_flags, int flags)
{ {
rct_ride *ride = get_ride(rideIndex); rct_ride *ride = get_ride(rideIndex);
if (ride == NULL)
{
log_warning("Invalid ride for track placement, rideIndex = %d", rideIndex);
return MONEY32_UNDEFINED;
}
rct_ride_type *rideEntry = get_ride_entry(ride->subtype); rct_ride_type *rideEntry = get_ride_entry(ride->subtype);
if (rideEntry == (rct_ride_type *)0xFFFFFFFF)
{
log_warning("Invalid ride type for track placement, rideIndex = %d", rideIndex);
return MONEY32_UNDEFINED;
}
rct_map_element *mapElement; rct_map_element *mapElement;
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION * 4; RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION * 4;

View File

@@ -1801,6 +1801,12 @@ money32 raise_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b
{ {
money32 cost = 0; money32 cost = 0;
if (selectionType < 0 || selectionType >= countof(map_element_raise_styles))
{
log_warning("Invalid selection type %d for raising land", selectionType);
return MONEY32_UNDEFINED;
}
if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) { if ((flags & GAME_COMMAND_FLAG_APPLY) && RCT2_GLOBAL(0x009A8C28, uint8) == 1) {
audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z); audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z);
} }