From 171388e9a3acf7657180b1accbd1f8e0de5d2e55 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 23 Apr 2016 01:21:00 +0100 Subject: [PATCH] integrate park entrance ghost variables --- src/addresses.h | 13 +++++++------ src/windows/map.c | 14 +++++++------- src/world/park.c | 25 +++++++++++++++---------- src/world/park.h | 6 ++++++ 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 6c966a87bc..810491d684 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -248,12 +248,6 @@ #define RCT2_ADDRESS_SELECTED_TERRAIN_EDGE 0x009E2E24 #define RCT2_ADDRESS_SELECTED_TERRAIN_SURFACE 0x009E2E25 -#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_X 0x009E32CC -#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_Y 0x009E32CE -#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_DIRECTION 0x009E32D1 -#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_EXISTS 0x009E32D2 -#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_PRICE 0x009E32D3 - #define RCT2_ADDRESS_G1_ELEMENTS 0x009EBD28 //Every pixel changed by rain is stored. @@ -602,6 +596,13 @@ #define RCT2_ADDRESS_CURRENT_TOOL 0x009DE545 #define RCT2_ADDRESS_TOOL_WIDGETINDEX 0x009DE546 +#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_X 0x009E32CC +#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_Y 0x009E32CE +#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_Z 0x009E32D0 +#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_DIRECTION 0x009E32D1 +#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_EXISTS 0x009E32D2 +#define RCT2_ADDRESS_PARK_ENTRANCE_GHOST_PRICE 0x009E32D3 + #define RCT2_ADDRESS_PROVISIONAL_PATH_FLAGS 0x00F3EF92 #define RCT2_ADDRESS_PROVISIONAL_PATH_X 0x00F3EF94 #define RCT2_ADDRESS_PROVISIONAL_PATH_Y 0x00F3EF96 diff --git a/src/windows/map.c b/src/windows/map.c index 2f81c74f05..d388bf0273 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -318,7 +318,7 @@ static void window_map_mouseup(rct_window *w, int widgetIndex) if (tool_set(w, widgetIndex, 2)) break; - RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_EXISTS, sint8) = 0; + gParkEntranceGhostExists = false; gInputFlags |= INPUT_FLAG_6; show_gridlines(); @@ -1166,7 +1166,7 @@ void sub_666EEF(int x, int y, sint16 *mapX, sint16 *mapY, sint16 *mapZ, int *dir return; mapElement = map_get_surface_element_at(*mapX >> 5, *mapY >> 5); - *mapZ = mapElement->properties.surface.slope & 0x1F; + *mapZ = mapElement->properties.surface.terrain & 0x1F; if (*mapZ == 0) { *mapZ = mapElement->base_height / 2; if ((mapElement->properties.surface.slope & 0x0F) != 0) { @@ -1211,16 +1211,16 @@ static void window_map_place_park_entrance_tool_update(int x, int y) RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 1); map_invalidate_map_selection_tiles(); if ( - (RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_EXISTS, uint8) & (1 << 0)) && - mapX == RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_X, uint16) && - mapY == RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_Y, uint16) && - direction == RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_DIRECTION, uint8) + gParkEntranceGhostExists && + mapX == gParkEntranceGhostPosition.x && + mapY == gParkEntranceGhostPosition.y && + direction == gParkEntranceGhostDirection ) { return; } park_remove_ghost_entrance(); - RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_PRICE, uint32) = park_place_ghost_entrance(mapX, mapY, mapZ, direction); + gParkEntranceGhostPrice = park_place_ghost_entrance(mapX, mapY, mapZ, direction); } /** diff --git a/src/world/park.c b/src/world/park.c index 23a23ab727..51b8d27603 100644 --- a/src/world/park.c +++ b/src/world/park.c @@ -57,6 +57,11 @@ int _suggestedGuestMaximum; */ int _guestGenerationProbability; +bool gParkEntranceGhostExists; +rct_xyz16 gParkEntranceGhostPosition; +uint8 gParkEntranceGhostDirection; +money32 gParkEntranceGhostPrice; + int park_is_open() { return (gParkFlags & PARK_FLAGS_PARK_OPEN) != 0; @@ -1121,13 +1126,13 @@ int get_forced_park_rating(){ */ void park_remove_ghost_entrance() { - if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_EXISTS, uint8) & (1 << 0)) { - RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_EXISTS, uint8) &= ~(1 << 0); + if (gParkEntranceGhostExists) { + gParkEntranceGhostExists = false; game_do_command( - RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_X, uint16), + gParkEntranceGhostPosition.x, 40 | GAME_COMMAND_FLAG_APPLY, - RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_Y, uint16), - RCT2_GLOBAL(0x009E32D0, uint8), + gParkEntranceGhostPosition.y, + gParkEntranceGhostPosition.z, GAME_COMMAND_REMOVE_PARK_ENTRANCE, 0, 0 @@ -1154,11 +1159,11 @@ money32 park_place_ghost_entrance(int x, int y, int z, int direction) 0 ); if (result != MONEY32_UNDEFINED) { - RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_X, uint16) = x; - RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_Y, uint16) = y; - RCT2_GLOBAL(0x009E32D0, uint8) = z; - RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_DIRECTION, uint8) = direction; - RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_GHOST_EXISTS, uint8) |= (1 << 0); + gParkEntranceGhostPosition.x = x; + gParkEntranceGhostPosition.y = y; + gParkEntranceGhostPosition.z = z; + gParkEntranceGhostDirection = direction; + gParkEntranceGhostExists = true; } return result; } diff --git a/src/world/park.h b/src/world/park.h index 3a9924e79c..7b477f3cad 100644 --- a/src/world/park.h +++ b/src/world/park.h @@ -22,6 +22,7 @@ #define _PARK_H_ #include "../common.h" +#include "map.h" #define DECRYPT_MONEY(money) rol32((money) ^ 0xF4EC9621, 13) #define ENCRYPT_MONEY(money) (ror32((money), 13) ^ 0xF4EC9621) @@ -57,6 +58,11 @@ extern uint8 *gGuestsInParkHistory; extern int _guestGenerationProbability; extern int _suggestedGuestMaximum; +extern bool gParkEntranceGhostExists; +extern rct_xyz16 gParkEntranceGhostPosition; +extern uint8 gParkEntranceGhostDirection; +extern money32 gParkEntranceGhostPrice; + void set_forced_park_rating(int rating); int get_forced_park_rating();