From 8c608b6f6c579b494ff88f2861ea4184a6f37af9 Mon Sep 17 00:00:00 2001 From: zsilencer Date: Sat, 23 Jan 2016 17:33:08 -0700 Subject: [PATCH] fix issues with a few game commands --- src/game.c | 9 ++++++--- src/windows/top_toolbar.c | 18 +++++++++++------- src/world/map.c | 27 +++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/game.c b/src/game.c index c77e65faab..a691521574 100644 --- a/src/game.c +++ b/src/game.c @@ -64,6 +64,8 @@ int gGameSpeed = 1; float gDayNightCycle = 0; bool gInUpdateCode = false; +extern void game_command_callback_place_banner(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp); + GAME_COMMAND_CALLBACK_POINTER* game_command_callback = 0; GAME_COMMAND_CALLBACK_POINTER* game_command_callback_table[] = { 0, @@ -71,6 +73,7 @@ GAME_COMMAND_CALLBACK_POINTER* game_command_callback_table[] = { game_command_callback_ride_construct_placed_front, game_command_callback_ride_construct_placed_back, game_command_callback_ride_remove_track_piece, + game_command_callback_place_banner, }; int game_command_playerid = -1; @@ -514,13 +517,13 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int * // Second call to actually perform the operation new_game_command_table[command](eax, ebx, ecx, edx, esi, edi, ebp); - game_command_playerid = -1; - - if (game_command_callback) { + if (game_command_callback && !(flags & GAME_COMMAND_FLAG_GHOST)) { game_command_callback(*eax, *ebx, *ecx, *edx, *esi, *edi, *ebp); game_command_callback = 0; } + game_command_playerid = -1; + *edx = *ebx; if (*edx != MONEY32_UNDEFINED && *edx < cost) diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index c3ea83ec7d..3f42ff823a 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -1405,6 +1405,15 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin } } +void game_command_callback_place_banner(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp) +{ + if (ebx != MONEY32_UNDEFINED) { + int bannerId = edi; + + audio_play_sound_at_location(SOUND_PLACE_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); + window_banner_open(bannerId); + } +} /** * * rct2: 0x006E2CC6 @@ -1619,13 +1628,8 @@ static void window_top_toolbar_scenery_tool_down(short x, short y, rct_window *w .esi = GAME_COMMAND_PLACE_BANNER, .edi = parameter_3 }; - money32 cost = game_do_command_p(GAME_COMMAND_PLACE_BANNER, ®s.eax, ®s.ebx, ®s.ecx, ®s.edx, ®s.esi, ®s.edi, ®s.ebp); - if (cost != MONEY32_UNDEFINED) { - int bannerId = regs.edi; - - audio_play_sound_at_location(SOUND_PLACE_ITEM, RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_X, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Y, uint16), RCT2_GLOBAL(RCT2_ADDRESS_COMMAND_MAP_Z, uint16)); - window_banner_open(bannerId); - } + game_command_callback = game_command_callback_place_banner; + game_do_command_p(GAME_COMMAND_PLACE_BANNER, ®s.eax, ®s.ebx, ®s.ecx, ®s.edx, ®s.esi, ®s.edi, ®s.ebp); break; } } diff --git a/src/world/map.c b/src/world/map.c index b346908d3f..b8c63f2799 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -4850,6 +4850,11 @@ void game_command_set_banner_name(int* eax, int* ebx, int* ecx, int* edx, int* e return; } + if (!(*ebx & GAME_COMMAND_FLAG_APPLY)) { + *ebx = 0; + return; + } + utf8 *buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, utf8); utf8 *dst = buffer; dst = utf8_write_codepoint(dst, FORMAT_COLOUR_CODE_START + banner->text_colour); @@ -4903,6 +4908,11 @@ void game_command_set_sign_name(int* eax, int* ebx, int* ecx, int* edx, int* esi return; } + if (!(*ebx & GAME_COMMAND_FLAG_APPLY)) { + *ebx = 0; + return; + } + if (newName[0] != 0) { rct_string_id string_id = user_string_allocate(128, newName); if (string_id != 0) { @@ -4944,6 +4954,12 @@ void game_command_set_banner_style(int* eax, int* ebx, int* ecx, int* edx, int* *ebx = MONEY32_UNDEFINED; return; } + + if (!(*ebx & GAME_COMMAND_FLAG_APPLY)) { + *ebx = 0; + return; + } + rct_banner* banner = &gBanners[*ecx]; banner->colour = (uint8)*edx; @@ -5037,6 +5053,12 @@ void game_command_set_sign_style(int* eax, int* ebx, int* ecx, int* edx, int* es *ebx = MONEY32_UNDEFINED; return; } + + if (!(*ebx & GAME_COMMAND_FLAG_APPLY)) { + *ebx = 0; + return; + } + map_element->flags &= 0x9F; map_element->properties.fence.item[1] = mainColour | @@ -5052,6 +5074,11 @@ void game_command_set_sign_style(int* eax, int* ebx, int* ecx, int* edx, int* es return; } + if (!(*ebx & GAME_COMMAND_FLAG_APPLY)) { + *ebx = 0; + return; + } + if (!sign_set_colour( banner->x * 32, banner->y * 32,