mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-23 10:51:58 -05:00
Game commands' argument validation
This commit is contained in:
parent
80550ca365
commit
95e3895b89
4 changed files with 24 additions and 2 deletions
|
@ -149,7 +149,7 @@ namespace String
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
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;
|
||||
}
|
||||
else
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint8) = activeCategories;
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
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);
|
||||
if (rideEntry == (rct_ride_type *)0xFFFFFFFF)
|
||||
{
|
||||
log_warning("Invalid ride type for track placement, rideIndex = %d", rideIndex);
|
||||
return MONEY32_UNDEFINED;
|
||||
}
|
||||
rct_map_element *mapElement;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION * 4;
|
||||
|
|
|
@ -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;
|
||||
|
||||
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) {
|
||||
audio_play_sound_at_location(SOUND_PLACE_ITEM, x, y, z);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue