From c40a6f4789c2d1569bfeec0ff14af8054562868b Mon Sep 17 00:00:00 2001 From: zsilencer Date: Wed, 22 Apr 2015 01:46:44 -0600 Subject: [PATCH] game_command_remove_banner --- src/game.c | 4 ++-- src/game.h | 2 +- src/windows/banner.c | 2 +- src/world/footpath.c | 2 +- src/world/map.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ src/world/map.h | 1 + 6 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/game.c b/src/game.c index 5093f8b287..16a1e44c3a 100644 --- a/src/game.c +++ b/src/game.c @@ -925,7 +925,7 @@ static uint32 game_do_command_table[58] = { 0, 0x006CDEE4, 0x006B9E6D, // 50 - 0x006BA058, + 0, 0, 0, 0, @@ -988,7 +988,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_start_campaign, game_command_emptysub, game_command_emptysub, // 50 - game_command_emptysub, + game_command_remove_banner, game_command_set_scenery_colour, game_command_set_fence_colour, game_command_set_large_scenery_colour, diff --git a/src/game.h b/src/game.h index 0feb19c63d..f7b09ca991 100644 --- a/src/game.h +++ b/src/game.h @@ -75,7 +75,7 @@ enum GAME_COMMAND { GAME_COMMAND_START_MARKETING_CAMPAIGN, // 48 GAME_COMMAND_49, GAME_COMMAND_50, // New banner? (possibly scenery) - GAME_COMMAND_51, // Remove banner + GAME_COMMAND_REMOVE_BANNER, // Remove banner GAME_COMMAND_52, GAME_COMMAND_53, GAME_COMMAND_54, diff --git a/src/windows/banner.c b/src/windows/banner.c index 8f0ac1605f..79100e79d4 100644 --- a/src/windows/banner.c +++ b/src/windows/banner.c @@ -201,7 +201,7 @@ static void window_banner_mouseup() window_close(w); break; case WIDX_BANNER_DEMOLISH: - game_do_command(x, 1, y, map_element->base_height | (map_element->properties.banner.position << 8), GAME_COMMAND_51, 0, 0); + game_do_command(x, 1, y, map_element->base_height | (map_element->properties.banner.position << 8), GAME_COMMAND_REMOVE_BANNER, 0, 0); break; case WIDX_BANNER_TEXT: window_text_input_open(w, WIDX_BANNER_TEXT, 2982, 2983, gBanners[w->number].string_idx, 0, 32); diff --git a/src/world/footpath.c b/src/world/footpath.c index 330cd02563..c811074f36 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -345,7 +345,7 @@ void remove_banners_at_element(int x, int y, rct_map_element* mapElement){ if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH)return; else if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_BANNER)continue; - game_do_command(x, 1, y, mapElement->base_height | mapElement->properties.banner.position << 8, GAME_COMMAND_51, 0, 0); + game_do_command(x, 1, y, mapElement->base_height | mapElement->properties.banner.position << 8, GAME_COMMAND_REMOVE_BANNER, 0, 0); mapElement--; } } diff --git a/src/world/map.c b/src/world/map.c index 919d2b5722..e80a6f12a2 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -768,6 +768,54 @@ void game_command_remove_large_scenery(int* eax, int* ebx, int* ecx, int* edx, i } } +/** + * + * rct2: 0x006BA058 + */ +void game_command_remove_banner(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) +{ + int x = *eax; + int y = *ecx; + uint8 base_height = *edx; + uint8 banner_position = *edx >> 8; + int z = base_height * 8; + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = 12; + RCT2_GLOBAL(0x009DEA5E, uint16) = x + 16; + RCT2_GLOBAL(0x009DEA60, uint16) = y + 16; + RCT2_GLOBAL(0x009DEA62, uint16) = z; + if(!(*ebx & 0x40) && RCT2_GLOBAL(0x009DEA6E, uint8) != 0){ + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + *ebx = MONEY32_UNDEFINED; + return; + } + if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_owned(x, y, z - 16)){ + *ebx = MONEY32_UNDEFINED; + return; + } + rct_map_element* map_element = map_get_first_element_at(x / 32, y / 32); + while(map_element->type != MAP_ELEMENT_TYPE_BANNER || + map_element->properties.banner.position != banner_position){ + map_element++; + if((map_element - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE){ + *ebx = 0; + return; + } + } + if(*ebx & GAME_COMMAND_FLAG_APPLY){ + window_close_by_number(WC_BANNER, map_element->properties.banner.index); + rct_banner *banner = &gBanners[map_element->properties.banner.index]; + user_string_free(banner->string_idx); + banner->type = BANNER_NULL; + map_invalidate_tile(x, y, z, z + 32); + map_element_remove(map_element); + } + rct_scenery_entry *scenery_entry = object_entry_groups[OBJECT_TYPE_BANNERS].chunks[map_element->properties.banner.index]; + *ebx = (scenery_entry->banner.price * -3) / 4; + if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY){ + *ebx = 0; + } +} + /** * * rct2: 0x006E0F26 diff --git a/src/world/map.h b/src/world/map.h index 9ddb688bd4..8d66ede404 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -276,6 +276,7 @@ int map_can_construct_at(int x, int y, int zLow, int zHigh, uint8 bl); void game_command_remove_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); void game_command_remove_large_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); +void game_command_remove_banner(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); void game_command_set_scenery_colour(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); void game_command_set_fence_colour(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); void game_command_set_large_scenery_colour(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp);