From da7563c7c92dbf9bb7c35fb4dfe01067e8ab79a1 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 4 May 2014 18:51:36 +0100 Subject: [PATCH] add unknown map element function --- src/game.c | 2 +- src/map.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/map.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index 43e55f9e25..c20491046e 100644 --- a/src/game.c +++ b/src/game.c @@ -140,7 +140,7 @@ void game_logic_update() if (RCT2_GLOBAL(0x009DEA66, sint16) == 0) RCT2_GLOBAL(0x009DEA66, sint16)--; - RCT2_CALLPROC_EBPSAFE(0x0068B089); + sub_68B089(); scenario_update(); climate_update(); RCT2_CALLPROC_EBPSAFE(0x006646E1); diff --git a/src/map.c b/src/map.c index 3a62c79253..581eabdf30 100644 --- a/src/map.c +++ b/src/map.c @@ -280,3 +280,53 @@ int map_element_height(int x, int y) return height; } + +/** + * + * rct2: 0x0068B089 + */ +void sub_68B089() +{ + int i; + rct_map_element *mapElementFirst, *mapElement; + + if (RCT2_GLOBAL(0x009DEA6F, uint8) & 1) + return; + + i = RCT2_GLOBAL(0x0010E63B8, uint32); + do { + i++; + if (i >= MAX_TILE_MAP_ELEMENT_POINTERS) + i = 0; + } while (TILE_MAP_ELEMENT_POINTER(i) == 0xFFFFFFFF); + RCT2_GLOBAL(0x0010E63B8, uint32) = i; + + mapElementFirst = mapElement = TILE_MAP_ELEMENT_POINTER(i); + do { + mapElement--; + if (mapElement < RCT2_ADDRESS_MAP_ELEMENTS) + break; + } while (mapElement->base_height == 255); + mapElement++; + + if (mapElement == mapElementFirst) + return; + + // + TILE_MAP_ELEMENT_POINTER(i) = mapElement; + do { + *mapElement = *mapElementFirst; + mapElementFirst->base_height = 255; + + mapElement++; + mapElementFirst++; + } while (!((mapElement - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE)); + + // Update next free element? + mapElement = RCT2_GLOBAL(0x0140E9A4, rct_map_element*); + do { + mapElement--; + } while (mapElement->base_height == 255); + mapElement++; + RCT2_GLOBAL(0x0140E9A4, rct_map_element*) = mapElement; +} \ No newline at end of file diff --git a/src/map.h b/src/map.h index 5d0f1a655b..88e76d7e11 100644 --- a/src/map.h +++ b/src/map.h @@ -185,5 +185,6 @@ enum { void map_init(); void map_update_tile_pointers(); int map_element_height(int x, int y); +void sub_68B089(); #endif