diff --git a/src/park.c b/src/park.c index 7650795c54..7a80e0356d 100644 --- a/src/park.c +++ b/src/park.c @@ -19,10 +19,12 @@ *****************************************************************************/ #include "addresses.h" +#include "map.h" #include "park.h" #include "peep.h" #include "ride.h" #include "sprite.h" +#include "window.h" int park_is_open() { @@ -38,6 +40,36 @@ void park_init() RCT2_CALLPROC_EBPSAFE(0x00667132); } +/** + * + * rct2: 0x0066A348 + */ +int park_calculate_size() +{ + int tiles, x, y; + rct_map_element *mapElement; + + tiles = 0; + for (y = 0; y < 256; y++) { + for (x = 0; x < 256; x++) { + mapElement = RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*)[y * 256 + x]; + while (mapElement->type & MAP_ELEMENT_TYPE_MASK) { + mapElement++; + } + + if (mapElement->properties.surface.ownership & 0x30) + tiles++; + } + } + + if (tiles != RCT2_GLOBAL(0x013580EA, sint16)) { + RCT2_GLOBAL(0x013580EA, sint16) = tiles; + window_invalidate_by_id(WC_PARK_INFORMATION, 0); + } + + return tiles; +} + /** * * rct2: 0x00669EAA diff --git a/src/park.h b/src/park.h index 4ce74a3294..98b27d299f 100644 --- a/src/park.h +++ b/src/park.h @@ -53,6 +53,7 @@ enum { int park_is_open(); void park_init(); +int park_calculate_size(); int calculate_park_rating(); int calculate_park_value(); diff --git a/src/rct2.h b/src/rct2.h index cb13cb0d2a..c62e92e1d9 100644 --- a/src/rct2.h +++ b/src/rct2.h @@ -124,7 +124,8 @@ enum { GAME_FLAGS_PARK_OPEN = (1 << 0), GAME_FLAGS_BELOW_TREE_HEIGHT_ONLY = (1 << 5), GAME_FLAGS_NO_MONEY = (1 << 11), - GAME_FLAGS_PARK_FREE_ENTRY = (1 << 13) + GAME_FLAGS_PARK_FREE_ENTRY = (1 << 13), + GAME_FLAGS_18 = (1 << 18) }; void rct2_endupdate(); diff --git a/src/scenario.c b/src/scenario.c index 6eee3c4849..5c14bb9344 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -22,6 +22,7 @@ #include #include "addresses.h" +#include "date.h" #include "game.h" #include "map.h" #include "news_item.h" @@ -464,5 +465,54 @@ void scenario_load_and_play(rct_scenario_basic *scenario) strcpy(0x0135924A, s6Info->details); strcpy(0x0135920A, s6Info->name); - RCT2_CALLPROC_EBPSAFE(0x00678461); + // RCT2_CALLPROC_EBPSAFE(0x00678461); + + if (RCT2_GLOBAL(0x009ADAE4, sint32) != -1) { + char *ebp = RCT2_GLOBAL(0x009ADAE4, char*); + + format_string(0x0141ED68, RCT2_GLOBAL(ebp + 2, uint16), 0); + RCT2_GLOBAL(0x0141E9AE, uint16) = STR_CANT_RENAME_PARK; + + RCT2_CALLPROC_X(0x006677F2, 1, 1, 0, *((int*)(0x0141ED68 + 0)), 33, *((int*)(0x0141ED68 + 8)), *((int*)(0x0141ED68 + 4))); + RCT2_CALLPROC_X(0x006677F2, 2, 1, 0, *((int*)(0x0141ED68 + 12)), 33, *((int*)(0x0141ED68 + 20)), *((int*)(0x0141ED68 + 16))); + RCT2_CALLPROC_X(0x006677F2, 0, 1, 0, *((int*)(0x0141ED68 + 24)), 33, *((int*)(0x0141ED68 + 32)), *((int*)(0x0141ED68 + 28))); + + format_string(0x0141ED68, RCT2_GLOBAL(ebp + 0, uint16), 0); + strcpy_s(0x0135920A, 32, 0x0141ED68); + + format_string(0x0141ED68, RCT2_GLOBAL(ebp + 4, uint16), 0); + strcpy_s(RCT2_ADDRESS_SCENARIO_DETAILS, 256, 0x0141ED68); + } + + strcpy(0x009ABB37, 0x009AB5DA); + format_string(0x009ABB37 + strlen(0x009ABB37), RCT2_GLOBAL(0x0013573D4, uint16), 0x0013573D8); + strcat(0x009ABB37, ".SV6"); + memset(0x001357848, 0, 56); + RCT2_GLOBAL(0x0135832C, uint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32) = 0; + RCT2_GLOBAL(0x01358334, uint32) = 0; + RCT2_GLOBAL(0x01358338, uint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_TOTAL_ADMISSIONS, uint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, uint32) = 0; + RCT2_GLOBAL(0x013587D8, uint16) = 63; + RCT2_CALLPROC_EBPSAFE(0x0069E869); + RCT2_CALLPROC_EBPSAFE(0x0066729F); + RCT2_CALLPROC_EBPSAFE(0x006B7A38); + date_reset(); + RCT2_CALLPROC_EBPSAFE(0x00674576); + park_calculate_size(); + RCT2_CALLPROC_EBPSAFE(0x006C1955); + RCT2_GLOBAL(0x01358840, uint8) = 0; + memset(0x001358102, 0, 20); + RCT2_GLOBAL(0x00135882E, uint16) = 0; + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32) & GAME_FLAGS_NO_MONEY) { + RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32) |= GAME_FLAGS_PARK_OPEN; + RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16) = 0; + } + RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32) |= GAME_FLAGS_18; + RCT2_CALLPROC_EBPSAFE(0x006837E3); + gfx_invalidate_screen(); + RCT2_GLOBAL(0x009DEA66, uint16) = 0; + RCT2_GLOBAL(0x009DEA5C, uint16) = 62000; }