diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 9af8c93c1f..ae2b744392 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -45,6 +45,7 @@ + @@ -140,6 +141,7 @@ + diff --git a/src/addresses.h b/src/addresses.h index 98434ec0b9..19263023c3 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -184,6 +184,13 @@ #define RCT2_ADDRESS_G1_ELEMENTS 0x009EBD28 #define RCT2_ADDRESS_PATH_TYPES 0x009ADA14 + +#define RCT2_ADDRESS_SMALL_SCENERY_ENTRIES 0x009AD1A4 +#define RCT2_ADDRESS_LARGE_SCENERY_ENTRIES 0x009AD594 +#define RCT2_ADDRESS_WALL_SCENERY_ENTRIES 0x009AD794 +#define RCT2_ADDRESS_BANNER_SCENERY_ENTRIES 0x009AD994 +#define RCT2_ADDRESS_PATH_BIT_SCENERY_ENTRIES 0x009ADA54 +#define RCT2_ADDRESS_SCENERY_SET_ENTRIES 0x009ADA90 //Every pixel changed by rain is stored. //32bit (pixel_offset 24 bit)(pixel_colour 8 bit) diff --git a/src/game.h b/src/game.h index 1f87d944c0..b3d4f15adb 100644 --- a/src/game.h +++ b/src/game.h @@ -25,7 +25,7 @@ enum GAME_COMMAND { GAME_COMMAND_0, GAME_COMMAND_1, GAME_COMMAND_TOGGLE_PAUSE, // 2 - GAME_COMMAND_3, + GAME_COMMAND_3, //Has something to do with ride construction GAME_COMMAND_4, GAME_COMMAND_LOAD_OR_QUIT, // 5 GAME_COMMAND_6, diff --git a/src/gfx.c b/src/gfx.c index fae14f1a7e..ffdb445fdb 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -2265,14 +2265,13 @@ rct_drawpixelinfo* clip_drawpixelinfo(rct_drawpixelinfo* dpi, int left, int widt newDrawPixelInfo->height = dpi->height; newDrawPixelInfo->pitch = dpi->pitch; newDrawPixelInfo->zoom_level = 0; - newDrawPixelInfo->var_0F = dpi->var_0F; if (left > newDrawPixelInfo->x) { - uint16 newWidth = left - newDrawPixelInfo->x; - newDrawPixelInfo->width -= newWidth; + uint16 clippedFromLeft = left - newDrawPixelInfo->x; + newDrawPixelInfo->width -= clippedFromLeft; newDrawPixelInfo->x = left; - newDrawPixelInfo->pitch += newWidth; - newDrawPixelInfo->bits += newWidth; + newDrawPixelInfo->pitch += clippedFromLeft; + newDrawPixelInfo->bits += clippedFromLeft; } int stickOutWidth = newDrawPixelInfo->x + newDrawPixelInfo->width - right; @@ -2282,10 +2281,10 @@ rct_drawpixelinfo* clip_drawpixelinfo(rct_drawpixelinfo* dpi, int left, int widt } if (top > newDrawPixelInfo->y) { - uint16 newHeight = top - newDrawPixelInfo->y; - newDrawPixelInfo->height = newHeight; + uint16 clippedFromTop = top - newDrawPixelInfo->y; + newDrawPixelInfo->height -= clippedFromTop; newDrawPixelInfo->y = top; - int bitsPlus = (newDrawPixelInfo->pitch + newDrawPixelInfo->width) * newHeight; + uint32 bitsPlus = (newDrawPixelInfo->pitch + newDrawPixelInfo->width) * clippedFromTop; newDrawPixelInfo->bits += bitsPlus; } diff --git a/src/map.c b/src/map.c index ac086487e4..f654935c4a 100644 --- a/src/map.c +++ b/src/map.c @@ -138,7 +138,9 @@ void map_update_tile_pointers() /** * Return the absolute height of an element, given its (x,y) coordinates - * + * ax: x + * cx: y + * dx: return * rct2: 0x00662783 */ int map_element_height(int x, int y) diff --git a/src/peep.c b/src/peep.c index 447b7c08d1..da7c594544 100644 --- a/src/peep.c +++ b/src/peep.c @@ -437,20 +437,20 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum if (RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride.type * 8, uint32) & 0x400000){ *argument_1 = STR_IN_RIDE; } - *argument_1 |= (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 |= (ride.name << 16); + *argument_2 = ride.name_arguments; break; case PEEP_STATE_BUYING: ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_AT_RIDE | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_AT_RIDE | (ride.name << 16); + *argument_2 = ride.name_arguments; break; case PEEP_STATE_WALKING: case 0x14: if (peep->var_C5 != 0xFF){ ride = g_ride_list[peep->var_C5]; - *argument_1 = STR_HEADING_FOR | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_HEADING_FOR | (ride.name << 16); + *argument_2 = ride.name_arguments; } else{ *argument_1 = peep->flags & PEEP_FLAGS_LEAVING_PARK ? STR_LEAVING_PARK : STR_WALKING; @@ -460,8 +460,8 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum case PEEP_STATE_QUEUING_FRONT: case PEEP_STATE_QUEUING: ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_QUEUING_FOR | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_QUEUING_FOR | (ride.name << 16); + *argument_2 = ride.name_arguments; break; case PEEP_STATE_SITTING: *argument_1 = STR_SITTING; @@ -470,12 +470,12 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum case PEEP_STATE_WATCHING: if (peep->current_ride != 0xFF){ ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_WATCHING_RIDE | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_WATCHING_RIDE | (ride.name << 16); + *argument_2 = ride.name_arguments; if (peep->current_seat & 0x1) - *argument_1 = STR_WATCHING_CONSTRUCTION_OF | (ride.var_04A << 16); + *argument_1 = STR_WATCHING_CONSTRUCTION_OF | (ride.name << 16); else - *argument_1 = STR_WATCHING_RIDE | (ride.var_04A << 16); + *argument_1 = STR_WATCHING_RIDE | (ride.name << 16); } else{ *argument_1 = peep->current_seat & 0x1 ? STR_WATCHING_NEW_RIDE_BEING_CONSTRUCTED : STR_LOOKING_AT_SCENERY; @@ -519,24 +519,24 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum } else{ ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_RESPONDING_TO_RIDE_BREAKDOWN_CALL | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_RESPONDING_TO_RIDE_BREAKDOWN_CALL | (ride.name << 16); + *argument_2 = ride.name_arguments; } break; case PEEP_STATE_FIXING: ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_FIXING_RIDE | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_FIXING_RIDE | (ride.name << 16); + *argument_2 = ride.name_arguments; break; case PEEP_STATE_HEADING_TO_INSPECTION: ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_HEADING_TO_RIDE_FOR_INSPECTION | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_HEADING_TO_RIDE_FOR_INSPECTION | (ride.name << 16); + *argument_2 = ride.name_arguments; break; case PEEP_STATE_INSPECTING: ride = g_ride_list[peep->current_ride]; - *argument_1 = STR_INSPECTING_RIDE | (ride.var_04A << 16); - *argument_2 = ride.var_04C; + *argument_1 = STR_INSPECTING_RIDE | (ride.name << 16); + *argument_2 = ride.name_arguments; break; } @@ -554,7 +554,7 @@ void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, ui if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 1){ rct_ride* ride = &g_ride_list[thought.item]; - esi = (int)(&(ride->var_04A)); + esi = (int)(&(ride->name)); } else if ((RCT2_ADDRESS(0x981DB1, uint16)[thought.type] & 0xFF) & 2){ if (thought.item < 0x20){ diff --git a/src/ride.c b/src/ride.c index 546817e186..7637de70fb 100644 --- a/src/ride.c +++ b/src/ride.c @@ -20,6 +20,7 @@ #include #include "addresses.h" +#include "game.h" #include "map.h" #include "news_item.h" #include "sprite.h" @@ -241,16 +242,16 @@ void ride_entrance_exit_connected(rct_ride* ride, int ride_idx) continue; if (entrance != -1 && !ride_entrance_exit_is_reachable(entrance, ride, i)) { // name of ride is parameter of the format string - RCT2_GLOBAL(0x013CE952, uint16) = ride->var_04A; - RCT2_GLOBAL(0x013CE954, uint32) = ride->var_04C; + RCT2_GLOBAL(0x013CE952, uint16) = ride->name; + RCT2_GLOBAL(0x013CE954, uint32) = ride->name_arguments; news_item_add_to_queue(1, STR_ENTRANCE_NOT_CONNECTED, ride_idx); ride->connected_message_throttle = 3; } if (exit != -1 && !ride_entrance_exit_is_reachable(exit, ride, i)) { // name of ride is parameter of the format string - RCT2_GLOBAL(0x013CE952, uint16) = ride->var_04A; - RCT2_GLOBAL(0x013CE954, uint32) = ride->var_04C; + RCT2_GLOBAL(0x013CE952, uint16) = ride->name; + RCT2_GLOBAL(0x013CE954, uint32) = ride->name_arguments; news_item_add_to_queue(1, STR_EXIT_NOT_CONNECTED, ride_idx); ride->connected_message_throttle = 3; } @@ -314,8 +315,8 @@ void ride_shop_connected(rct_ride* ride, int ride_idx) } // name of ride is parameter of the format string - RCT2_GLOBAL(0x013CE952, uint16) = ride->var_04A; - RCT2_GLOBAL(0x013CE954, uint32) = ride->var_04C; + RCT2_GLOBAL(0x013CE952, uint16) = ride->name; + RCT2_GLOBAL(0x013CE954, uint32) = ride->name_arguments; news_item_add_to_queue(1, STR_ENTRANCE_NOT_CONNECTED, ride_idx); ride->connected_message_throttle = 3; @@ -422,6 +423,47 @@ rct_map_element *ride_find_track_gap(rct_map_element *startTrackElement, int *ou return (rct_map_element*)esi; } +/** + * + * rct2: 0x006B4800 + */ +void ride_construct_new(int list_item) +{ + int eax, ebx, ecx, edx, esi, edi, ebp; + edx = list_item; + eax = 0; + ecx = 0; + ebx = 1; + edi = 0; + esi = 0; + + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = 0x3DC; + + esi = GAME_COMMAND_6; + game_do_command_p(esi, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + if (ebx == 0x80000000) { + return; + } + + //Looks like edi became the ride index after the command. + eax = edi; + rct_window *w; + + //TODO: replace with window_ride_main_open(eax) + // window_ride_main_open(eax); + RCT2_CALLFUNC_X(0x006ACC28, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + window_get_register(w); + + ecx = w->classification; + edx = 0x13; + ebp = (int)w; + //TODO: replace with window_ride_main_mouseup() after ride-window_merge + // window_ride_main_mouseup(); + RCT2_CALLFUNC_X(0x006AF17E, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + rct_window *ride_window = window_find_by_id(w->classification, w->number); //class here + window_close(ride_window); +} + /** * * rct2: 0x006CC056 @@ -431,4 +473,4 @@ int ride_try_construct(rct_map_element *trackMapElement) // Success stored in carry flag which can't be accessed after call using is macro RCT2_CALLPROC_X(0x006CC056, 0, 0, 0, (int)trackMapElement, 0, 0, 0); return 1; -} \ No newline at end of file +} diff --git a/src/ride.h b/src/ride.h index dca498d637..d454020c92 100644 --- a/src/ride.h +++ b/src/ride.h @@ -49,7 +49,9 @@ typedef struct { uint32 var_008; uint8 var_00C; uint8 var_00D; - uint8 pad_00E[0x1A4]; + uint8 pad_00E[0x5]; + uint8 var_013; + uint8 pad_014[0x19E]; sint8 excitement_multipler; // 0x1B2 sint8 intensity_multipler; // 0x1B3 sint8 nausea_multipler; // 0x1B4 @@ -74,8 +76,8 @@ typedef struct { uint8 pad_046[0x03]; // 0 = closed, 1 = open, 2 = test uint8 status; // 0x049 - uint16 var_04A; - uint32 var_04C; + rct_string_id name; // 0x04A + uint32 name_arguments; // 0x04C probably just for when a ride hasn't been named (e.g. Crooked House 1) uint16 overall_view; // 0x050 00XX = X, XX00 = Y (* 32 + 16) uint16 station_starts[4]; // 0x052 uint8 station_heights[4]; // 0x05A @@ -149,7 +151,8 @@ typedef struct { uint8 var_1CD; uint16 guests_favourite; // 0x1CE uint32 lifecycle_flags; // 0x1D0 - uint8 pad_1D4[0x20]; + uint8 var_1D4; + uint8 pad_1D5[0x1F]; // Example value for wild mouse ride is d5 (before it's been constructed) // I tried searching the IDA file for "1F4" but couldn't find places where // this is written to. @@ -384,6 +387,7 @@ void ride_update_favourited_stat(); void ride_check_all_reachable(); rct_map_element *sub_6CAF80(int rideIndex, int *outX, int *outY); rct_map_element *ride_find_track_gap(rct_map_element *startTrackElement, int *outX, int *outY); +void ride_construct_new(int list_item); int ride_try_construct(rct_map_element *trackMapElement); #endif diff --git a/src/scenery.h b/src/scenery.h new file mode 100644 index 0000000000..59704d94c0 --- /dev/null +++ b/src/scenery.h @@ -0,0 +1,130 @@ +/***************************************************************************** +* Copyright (c) 2014 Dániel Tar +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef _SCENERY_H_ +#define _SCENERY_H_ + +#include "rct2.h" +#include "string_ids.h" + +typedef struct { + uint32 flags; // 0x06 + uint8 height; // 0x0A + uint8 tool_id; // 0x0B + uint16 price; // 0x0C + uint8 pad_0E[12]; + uint8 scenery_tab_id; // 0x1A +} rct_small_scenery_entry; + +typedef enum { + SMALL_SCENERY_FLAG1 = (1 << 0), // 0x1 + SMALL_SCENERY_FLAG2 = (1 << 1), // 0x2 + SMALL_SCENERY_FLAG3 = (1 << 2), // 0x4 + SMALL_SCENERY_FLAG4 = (1 << 3), // 0x8 + SMALL_SCENERY_FLAG5 = (1 << 4), // 0x10 + SMALL_SCENERY_FLAG6 = (1 << 5), // 0x20 + SMALL_SCENERY_FLAG7 = (1 << 6), // 0x40 + SMALL_SCENERY_FLAG8 = (1 << 7), // 0x80 + SMALL_SCENERY_FLAG9 = (1 << 8), // 0x100 + SMALL_SCENERY_FLAG10 = (1 << 9), // 0x200 + SMALL_SCENERY_HAS_PRIMARY_COLOUR = (1 << 10), // 0x400 + SMALL_SCENERY_FLAG12 = (1 << 11), // 0x800 + SMALL_SCENERY_FLAG13 = (1 << 12), // 0x1000 + SMALL_SCENERY_FLAG14 = (1 << 13), // 0x2000 + SMALL_SCENERY_FLAG15 = (1 << 14), // 0x4000 + SMALL_SCENERY_FLAG16 = (1 << 15), // 0x8000 + SMALL_SCENERY_FLAG17 = (1 << 16), // 0x10000 + SMALL_SCENERY_FLAG18 = (1 << 17), // 0x20000 + SMALL_SCENERY_FLAG19 = (1 << 18), // 0x40000 + SMALL_SCENERY_HAS_SECONDARY_COLOUR = (1 << 19), // 0x80000 +} SMALL_SCENERY_FLAGS; + +typedef struct { + uint8 tool_id; // 0x06 + uint8 flags; // 0x07 + uint16 price; // 0x08 + uint8 pad_0A[6]; + uint8 scenery_tab_id; // 0x10 +} rct_large_scenery_entry; + + +typedef struct { + uint8 tool_id; // 0x06 + uint8 flags; // 0x07 + uint8 height; // 0x08 + uint8 flags2; // 0x09 + uint16 price; // 0x0A + uint8 scenery_tab_id; // 0x0C +} rct_wall_scenery_entry; + +typedef enum { + WALL_SCENERY_FLAG1 = (1 << 0), // 0x1 + WALL_SCENERY_FLAG2 = (1 << 1), // 0x2 + WALL_SCENERY_FLAG3 = (1 << 2), // 0x4 + WALL_SCENERY_FLAG4 = (1 << 3), // 0x8 + WALL_SCENERY_FLAG5 = (1 << 4), // 0x10 + WALL_SCENERY_FLAG6 = (1 << 5), // 0x20 + WALL_SCENERY_HAS_SECONDARY_COLOUR = (1 << 6), // 0x40 + WALL_SCENERY_HAS_TERNARY_COLOUR = (1 << 7), // 0x80 +} WALL_SCENERY_FLAGS; + +typedef struct { + uint8 pad_02[3]; + uint8 tool_id; // 0x09 + uint16 price; // 0x0A + uint8 scenery_tab_id; // 0x0C +} rct_path_bit_scenery_entry; + +typedef struct { + uint8 var_06; + uint8 flags; // 0x07 + uint16 price; // 0x08 + uint8 scenery_tab_id; // 0x0A +} rct_banner_scenery_entry; + +typedef struct { + rct_string_id name; // 0x00 + uint32 image; // 0x02 + union { + rct_small_scenery_entry small_scenery; + rct_large_scenery_entry large_scenery; + rct_wall_scenery_entry wall; + rct_path_bit_scenery_entry path_bit; + rct_banner_scenery_entry banner; + }; +} rct_scenery_entry; + +typedef struct { + rct_string_id name; // 0x00 + uint32 image; // 0x02 + uint16 scenery_entries[0x80]; // 0x06 + uint8 entry_count; // 0x106 + uint8 pad_107; + uint8 var_108; // 0x108, order? +} rct_scenery_set_entry; + +#define g_smallSceneryEntries RCT2_ADDRESS(RCT2_ADDRESS_SMALL_SCENERY_ENTRIES, rct_scenery_entry*) +#define g_largeSceneryEntries RCT2_ADDRESS(RCT2_ADDRESS_LARGE_SCENERY_ENTRIES, rct_scenery_entry*) +#define g_wallSceneryEntries RCT2_ADDRESS(RCT2_ADDRESS_WALL_SCENERY_ENTRIES, rct_scenery_entry*) +#define g_bannerSceneryEntries RCT2_ADDRESS(RCT2_ADDRESS_BANNER_SCENERY_ENTRIES, rct_scenery_entry*) +#define g_pathBitSceneryEntries RCT2_ADDRESS(RCT2_ADDRESS_PATH_BIT_SCENERY_ENTRIES, rct_scenery_entry*) +#define g_scenerySetEntries RCT2_ADDRESS(RCT2_ADDRESS_SCENERY_SET_ENTRIES, rct_scenery_set_entry*) + +#endif \ No newline at end of file diff --git a/src/sprite.c b/src/sprite.c index c2c80cb5dd..ec511dfaeb 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -104,4 +104,48 @@ void reset_0x69EBE4(){ spr->unknown.var_02 = ax; } } +} + +/* +* rct2: 0x0069EC6B +* bl: unclear what this does +*/ +rct_sprite *create_sprite(uint8 bl) +{ + int ecx = 0xA; + + if ((bl & 2) != 0) + { + // 69EC96; + uint16 cx = 0x12C - RCT2_GLOBAL(0x13573CE, uint16); + if (cx >= RCT2_GLOBAL(0x13573C8, uint16)) + { + return NULL; + } + + ecx = 6; + } + else if (RCT2_GLOBAL(0x13573C8, uint16) <= 0) + { + return NULL; + } + + rct_unk_sprite *sprite = &(g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)]).unknown; + + RCT2_CALLPROC_X(0x0069ED0B, 0, 0, ecx, 0, (int)sprite, 0, 0); + + sprite->x = SPRITE_LOCATION_NULL; + sprite->y = SPRITE_LOCATION_NULL; + sprite->z = 0; + sprite->name_string_idx = 0; + sprite->var_14 = 0x10; + sprite->pad_09 = 0x14; + sprite->var_15 = 0x8; + sprite->pad_0C[0] = 0x0; + sprite->var_16 = SPRITE_LOCATION_NULL; + + sprite->var_02 = RCT2_GLOBAL(0xF3EF60, uint16); + RCT2_GLOBAL(0xF3EF60, uint16) = sprite->sprite_index; + + return (rct_sprite*)sprite; } \ No newline at end of file diff --git a/src/sprite.h b/src/sprite.h index 701d448cbc..81f6955956 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -49,12 +49,15 @@ typedef struct { sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 - uint16 pad_14; + uint8 var_14; // 0x14 + uint8 var_15; // 0x15 sint16 var_16; //x related sint16 var_18; //y related sint16 var_1A; //x related sint16 var_1C; //y related - uint8 sprite_direction; //direction of sprite? + uint8 sprite_direction; //direction of sprite? 0x1e + uint8 pad_1F[3]; // 0x1f + uint16 name_string_idx; // 0x22 } rct_unk_sprite; typedef struct { @@ -86,6 +89,7 @@ typedef union { extern rct_sprite* g_sprite_list; void create_balloon(int x, int y, int z, int colour); +rct_sprite *create_sprite(uint8 bl); void reset_sprite_list(); void reset_0x69EBE4(); diff --git a/src/staff.c b/src/staff.c index 1e0bc041cb..cead4581e3 100644 --- a/src/staff.c +++ b/src/staff.c @@ -111,14 +111,12 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int newStaffId = i; - int _eax, _ebx, _ecx = _cx, _edx, _esi, _edi, _ebp; - _esi = 0; + int _eax, _ebx, _ecx = _cx, _edx; _ebx = _bl; - RCT2_CALLFUNC_X(0x0069EC6B, &_eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp); - rct_peep* newPeep = (rct_peep*)_esi; - //if ((newPeep = create_peep_sprite(_bl)) == NULL) - if (_esi == 0) + rct_peep* newPeep = &(create_sprite(_bl)->peep); + + if (newPeep == NULL) { *ebx = 0x80000000; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; diff --git a/src/string_ids.h b/src/string_ids.h index 142e9494ae..91d2b031f9 100644 --- a/src/string_ids.h +++ b/src/string_ids.h @@ -820,6 +820,10 @@ enum { STR_REAL_PARKS = STR_BEGINNER_PARKS + 3, STR_OTHER_PARKS = STR_BEGINNER_PARKS + 4, + STR_SELECT_COLOUR = 3099, + STR_SELECT_SECONDARY_COLOUR = 3100, + STR_SELECT_TERNARY_COLOUR = 3101, + STR_LIST_RIDES_TIP = 3104, STR_LIST_SHOPS_AND_STALLS_TIP = 3105, STR_LIST_KIOSKS_AND_FACILITIES_TIP = 3106, diff --git a/src/viewport.c b/src/viewport.c index 4697b57df3..d39bf92a8d 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -113,19 +113,19 @@ void center_2d_coordinates(int x, int y, int z, int* out_x, int* out_y, rct_view switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)){ case 0: x = y - x; - y = y / 2 + start_x / 2 - z; + y = (y + start_x) / 2 - z; break; case 1: x = -y - x; - y = y / 2 - start_x / 2 - z; + y = (y - start_x) / 2 - z; break; case 2: x = -y + x; - y = -y / 2 - start_x / 2 - z; + y = (-y - start_x) / 2 - z; break; case 3: x = y + x; - y = -y / 2 + start_x / 2 - z; + y = (-y + start_x) / 2 - z; break; } @@ -221,8 +221,8 @@ void viewport_update_pointers() *vp = NULL; } -void sub_689174(sint16* x, sint16* y, uint8 curr_rotation){ - //RCT2_CALLFUNC_X(0x00689174, (int*)&x, (int*)&y, &ecx, &curr_rotation, (int*)&window, (int*)&viewport, &ebp); +void sub_689174(sint16* x, sint16* y, sint16 *z, uint8 curr_rotation){ + //RCT2_CALLFUNC_X(0x00689174, (int*)&x, (int*)&y, (int*)&z, &curr_rotation, (int*)&window, (int*)&viewport, &ebp); sint16 start_x = *x; sint16 start_y = *y; @@ -262,6 +262,7 @@ void sub_689174(sint16* x, sint16* y, uint8 curr_rotation){ } break; } + *z = height; } /** @@ -296,11 +297,12 @@ void viewport_update_position(rct_window *window) sint16 x = viewport->view_width / 2 + window->saved_view_x; sint16 y = viewport->view_height / 2 + window->saved_view_y; + sint16 z; int curr_rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); - sub_689174(&x, &y, curr_rotation); + sub_689174(&x, &y, &z, curr_rotation); - RCT2_CALLPROC_X(0x006E7A15, x, y, 0, 0, (int)window, (int)viewport, 0); + RCT2_CALLPROC_X(0x006E7A15, x, y, z, 0, (int)window, (int)viewport, 0); //Clamp to the map minimum value int at_map_edge = 0; @@ -1039,3 +1041,50 @@ void hide_construction_rights() } } } + +/** + * + * rct2: 0x006CB70A + */ +void viewport_set_visibility(uint8 mode) +{ + rct_window* window = window_get_main(); + + if(window != NULL) { + rct_viewport* edi = window->viewport; + uint32 invalidate = 0; + + switch(mode) { + case 0: { //Set all these flags to 0, and invalidate if any were active + uint16 mask = VIEWPORT_FLAG_UNDERGROUND_INSIDE | VIEWPORT_FLAG_SEETHROUGH_RIDES | + VIEWPORT_FLAG_SEETHROUGH_SCENERY | VIEWPORT_FLAG_INVISIBLE_SUPPORTS | + VIEWPORT_FLAG_LAND_HEIGHTS | VIEWPORT_FLAG_TRACK_HEIGHTS | + VIEWPORT_FLAG_PATH_HEIGHTS | VIEWPORT_FLAG_INVISIBLE_PEEPS | + VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_VERTICAL; + + invalidate += edi->flags & mask; + edi->flags &= ~mask; + break; + } + case 1: //6CB79D + case 4: //6CB7C4 + //Set underground on, invalidate if it was off + invalidate += !(edi->flags & VIEWPORT_FLAG_UNDERGROUND_INSIDE); + edi->flags |= VIEWPORT_FLAG_UNDERGROUND_INSIDE; + break; + case 2: //6CB7EB + //Set track heights on, invalidate if off + invalidate += !(edi->flags & VIEWPORT_FLAG_TRACK_HEIGHTS); + edi->flags |= VIEWPORT_FLAG_TRACK_HEIGHTS; + break; + case 3: //6CB7B1 + case 5: //6CB7D8 + //Set underground off, invalidate if it was on + invalidate += edi->flags & VIEWPORT_FLAG_UNDERGROUND_INSIDE; + edi->flags &= ~((uint16)VIEWPORT_FLAG_UNDERGROUND_INSIDE); + break; + } + if (invalidate != 0) + window_invalidate(window); + } +} diff --git a/src/viewport.h b/src/viewport.h index 19c436d0e6..dfbcfb8c5c 100644 --- a/src/viewport.h +++ b/src/viewport.h @@ -47,11 +47,14 @@ enum { extern rct_viewport* g_viewport_list; void viewport_init_all(); +void center_2d_coordinates(int x, int y, int z, int* out_x, int* out_y, rct_viewport* viewport); void viewport_create(rct_window *w, int x, int y, int width, int height, int zoom, int center_x, int center_y, int center_z, char flags, sint16 sprite); void viewport_update_pointers(); void viewport_update_position(rct_window *window); void viewport_render(rct_drawpixelinfo *dpi, rct_viewport *viewport, int left, int top, int right, int bottom); +void sub_689174(sint16* x, sint16* y, sint16 *z, uint8 curr_rotation); + void screen_pos_to_map_pos(short *x, short *y); void show_gridlines(); @@ -60,5 +63,6 @@ void show_land_rights(); void hide_land_rights(); void show_construction_rights(); void hide_construction_rights(); +void viewport_set_visibility(uint8 mode); #endif diff --git a/src/widget.c b/src/widget.c index 22226cd78f..003e86597a 100644 --- a/src/widget.c +++ b/src/widget.c @@ -736,13 +736,15 @@ static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg // Get the colour colour = w->colours[widget->colour]; - // checkbox - gfx_fill_rect_inset(dpi, l, t, l + 9, b - 1, colour, 0x60); + if (widget->type != WWT_24) { + // checkbox + gfx_fill_rect_inset(dpi, l, t, l + 9, b - 1, colour, 0x60); - // fill it when checkbox is pressed - if (widget_is_pressed(w, widgetIndex)) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; - gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, t); + // fill it when checkbox is pressed + if (widget_is_pressed(w, widgetIndex)) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; + gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, t); + } } // draw the text diff --git a/src/window.c b/src/window.c index 4351d90d1a..af22ebfc4a 100644 --- a/src/window.c +++ b/src/window.c @@ -21,7 +21,9 @@ #include #include "addresses.h" #include "audio.h" +#include "game.h" #include "gfx.h" +#include "map.h" #include "osinterface.h" #include "rct2.h" #include "widget.h" @@ -963,7 +965,49 @@ void window_scroll_to_location(rct_window *w, int x, int y, int z) */ void window_rotate_camera(rct_window *w) { - RCT2_CALLPROC_X(0x0068881A, 0, 0, 0, 0, (int)w, 0, 0); + //RCT2_CALLPROC_X(0x0068881A, 0, 0, 0, 0, (int)w, 0, 0); + + rct_viewport *viewport = w->viewport; + if (viewport == NULL) + return; + + sint16 x = (viewport->width >> 1) + viewport->x; + sint16 y = (viewport->height >> 1) + viewport->y; + sint16 z; + + uint8 rot = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8); + + int ecx, edx, esi, edi = (int)viewport, ebp; + //has something to do with checking if middle of the viewport is obstructed + RCT2_CALLFUNC_X(0x00688972, (int*)&x, (int*)&y, &ecx, &edx, &esi, &edi, &ebp); + rct_viewport *other = (rct_viewport*)edi; + + // other != viewport probably triggers on viewports in ride or guest window? + // x is 0x8000 if middle of viewport is obstructed by another window? + if (x == (sint16)SPRITE_LOCATION_NULL || other != viewport){ + x = (viewport->view_width >> 1) + viewport->view_x; + y = (viewport->view_height >> 1) + viewport->view_y; + + sub_689174(&x, &y, &z, rot); + } else { + z = map_element_height(x, y); + } + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) = (rot + 1) % 4; + + int new_x, new_y; + center_2d_coordinates(x, y, z, &new_x, &new_y, viewport); + + w->saved_view_x = new_x; + w->saved_view_y = new_y; + viewport->view_x = new_x; + viewport->view_y = new_y; + + window_invalidate(w); + + RCT2_CALLPROC_EBPSAFE(0x00688956); + + sub_0x0069E9A7(); } /** diff --git a/src/window.h b/src/window.h index 86aa034349..0270e5cdc3 100644 --- a/src/window.h +++ b/src/window.h @@ -162,6 +162,11 @@ typedef struct { sint32 var_482; } ride_variables; +typedef struct { + sint16 selected_scenery_id; + sint16 hover_counter; +} scenery_variables; + /** * Window structure * size: 0x4C0 @@ -199,6 +204,7 @@ typedef struct rct_window { news_variables news; map_variables map; ride_variables ride; + scenery_variables scenery; }; sint16 page; // 0x48A sint16 var_48C; @@ -457,6 +463,7 @@ void window_new_ride_open(); void window_banner_open(); void window_cheats_open(); void window_research_open(); +void window_scenery_open(); void window_guest_list_init_vars_a(); void window_guest_list_init_vars_b(); diff --git a/src/window_finances.c b/src/window_finances.c index e8500fc84b..56f7072898 100644 --- a/src/window_finances.c +++ b/src/window_finances.c @@ -1250,8 +1250,8 @@ static void window_finances_marketing_paint() case ADVERTISING_CAMPAIGN_RIDE_FREE: case ADVERTISING_CAMPAIGN_RIDE: ride = GET_RIDE(campaignRideIndex[i]); - RCT2_GLOBAL(0x013CE952, uint16) = ride->var_04A; - RCT2_GLOBAL(0x013CE952 + 2, uint32) = ride->var_04C; + RCT2_GLOBAL(0x013CE952, uint16) = ride->name; + RCT2_GLOBAL(0x013CE952 + 2, uint32) = ride->name_arguments; break; case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE: shopString = campaignRideIndex[i] + 2016; // STR_BALLOONS+ diff --git a/src/window_footpath.c b/src/window_footpath.c index 01e4db3cb5..1e70c75998 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -226,7 +226,7 @@ static void window_footpath_close() window_get_register(w); RCT2_CALLPROC_EBPSAFE(0x006A7831); - RCT2_CALLPROC_X(0x006CB70A, 0, 0, 0, 0, 0, 0, 0); + viewport_set_visibility(0); RCT2_CALLPROC_EBPSAFE(0x0068AB1B); RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2; window_invalidate_by_id(WC_TOP_TOOLBAR, 0); @@ -677,7 +677,7 @@ static int window_footpath_set_provisional_path(int type, int x, int y, int z, i eax = 3; if (RCT2_GLOBAL(0x00F3EFA4, uint8) & 2) eax = 1; - RCT2_CALLPROC_X(0x006CB70A, eax, 0, 0, 0, 0, 0, 0); + viewport_set_visibility((uint8)eax); } return cost; diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c index 4825f55128..a81eaf85df 100644 --- a/src/window_game_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -259,7 +259,8 @@ static void window_game_top_toolbar_mouseup() case WIDX_SCENERY: if (!tool_set(w, WIDX_SCENERY, 0)) { RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6); - RCT2_CALLPROC_EBPSAFE(0x006E0FEF); + window_scenery_open(); + //RCT2_CALLPROC_EBPSAFE(0x006E0FEF); } break; case WIDX_PATH: diff --git a/src/window_new_campaign.c b/src/window_new_campaign.c index efe6ad5afd..39ad693d98 100644 --- a/src/window_new_campaign.c +++ b/src/window_new_campaign.c @@ -118,8 +118,8 @@ int ride_name_compare(const void *a, const void *b) rideA = GET_RIDE(*((uint8*)a)); rideB = GET_RIDE(*((uint8*)b)); - format_string(rideAName, rideA->var_04A, &rideA->var_04C); - format_string(rideBName, rideB->var_04A, &rideB->var_04C); + format_string(rideAName, rideA->name, &rideA->name_arguments); + format_string(rideBName, rideB->name, &rideB->name_arguments); return _strcmpi(rideAName, rideBName); } @@ -288,7 +288,7 @@ static void window_new_campaign_mousedown(int widgetIndex, rct_window *w, rct_wi rct_ride *ride = GET_RIDE(window_new_campaign_rides[i]); gDropdownItemsFormat[i] = 1142; - gDropdownItemsArgs[i] = (ride->var_04C << 16) | ride->var_04A; + gDropdownItemsArgs[i] = (ride->name_arguments << 16) | ride->name; numItems++; } @@ -364,8 +364,8 @@ static void window_new_campaign_invalidate() window_new_campaign_widgets[WIDX_RIDE_LABEL].image = STR_MARKETING_RIDE; if (w->campaign.ride_id != SELECTED_RIDE_UNDEFINED) { rct_ride *ride = GET_RIDE(w->campaign.ride_id); - window_new_campaign_widgets[WIDX_RIDE_DROPDOWN].image = ride->var_04A; - RCT2_GLOBAL(0x013CE952, uint32) = ride->var_04C; + window_new_campaign_widgets[WIDX_RIDE_DROPDOWN].image = ride->name; + RCT2_GLOBAL(0x013CE952, uint32) = ride->name_arguments; } break; case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE: diff --git a/src/window_new_ride.c b/src/window_new_ride.c index 9b061810f0..0c8585f1ab 100644 --- a/src/window_new_ride.c +++ b/src/window_new_ride.c @@ -25,6 +25,7 @@ #include "news_item.h" #include "ride.h" #include "string_ids.h" +#include "scenery.h" #include "track.h" #include "widget.h" #include "window.h" @@ -761,8 +762,7 @@ static void window_new_ride_paint() rideEntry->name : (typeId & 0xFF00) + 2; } else { - uint8 *sceneryEntry = RCT2_GLOBAL(0x009ADA90 + (typeId & 0xFFFF) * 4, uint8*); - stringId = RCT2_GLOBAL(sceneryEntry, uint16); + stringId = g_scenerySetEntries[typeId]->name; } } } @@ -798,8 +798,7 @@ static void window_new_ride_paint() rideEntry->name : (typeId & 0xFF00) + 2; } else { - uint8 *sceneryEntry = RCT2_GLOBAL(0x009ADA90 + (typeId & 0xFFFF) * 4, uint8*); - stringId = RCT2_GLOBAL(sceneryEntry, uint16); + stringId = g_scenerySetEntries[typeId]->name; } gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 266, STR_RESEARCH_RIDE_LABEL, 0); } @@ -989,5 +988,6 @@ static void window_new_ride_select(rct_window *w) } // Show ride construction window - RCT2_CALLPROC_X(0x006B4800, *((sint16*)&item), 0, 0, 0, 0, 0, 0); -} \ No newline at end of file + //RCT2_CALLPROC_X(0x006B4800, *((sint16*)&item), 0, 0, 0, 0, 0, 0); + ride_construct_new(*((sint16*)&item)); +} diff --git a/src/window_research.c b/src/window_research.c index b65fc7dba4..5685c80da1 100644 --- a/src/window_research.c +++ b/src/window_research.c @@ -23,6 +23,7 @@ #include "game.h" #include "news_item.h" #include "ride.h" +#include "scenery.h" #include "string_ids.h" #include "sprites.h" #include "widget.h" @@ -348,8 +349,7 @@ static void window_research_development_paint() rideEntry->name : ((typeId >> 8) & 0xFF) + 2; } else { - uint8 *sceneryEntry = RCT2_GLOBAL(0x009ADA90 + (typeId & 0xFFFF) * 4, uint8*); - stringId = RCT2_GLOBAL(sceneryEntry, uint16); + stringId = g_scenerySetEntries[typeId]->name; } } } @@ -388,8 +388,7 @@ static void window_research_development_paint() lastDevelopmentFormat = STR_RESEARCH_RIDE_LABEL; } else { - uint8 *sceneryEntry = RCT2_GLOBAL(0x009ADA90 + (typeId & 0xFFFF) * 4, uint8*); - stringId = RCT2_GLOBAL(sceneryEntry, uint16); + stringId = g_scenerySetEntries[typeId]->name; lastDevelopmentFormat = STR_RESEARCH_SCENERY_LABEL; } gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 266, lastDevelopmentFormat, 0); diff --git a/src/window_ride_list.c b/src/window_ride_list.c index 1a876b8457..0298a93c9e 100644 --- a/src/window_ride_list.c +++ b/src/window_ride_list.c @@ -507,7 +507,7 @@ static void window_ride_list_scrollpaint() ride = &g_ride_list[w->list_item_positions[i]]; // Ride name - gfx_draw_string_left_clipped(dpi, format, &ride->var_04A, 0, 0, y - 1, 159); + gfx_draw_string_left_clipped(dpi, format, &ride->name, 0, 0, y - 1, 159); // Ride information formatSecondary = 0; @@ -648,12 +648,12 @@ static void window_ride_list_refresh_list(rct_window *w) int current_list_position = list_index; switch (w->list_information_type) { case INFORMATION_TYPE_STATUS: - RCT2_GLOBAL(0x013CE952, uint32) = ride->var_04C; - RCT2_CALLPROC_X(0x006C2538, ride->var_04A, 0, 0x013CE952, 0, 0, RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, 0); + RCT2_GLOBAL(0x013CE952, uint32) = ride->name_arguments; + RCT2_CALLPROC_X(0x006C2538, ride->name, 0, 0x013CE952, 0, 0, RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, 0); while (--current_list_position >= 0) { otherRide = &g_ride_list[w->list_item_positions[current_list_position]]; - RCT2_GLOBAL(0x013CE952, uint32) = otherRide->var_04C; - RCT2_CALLPROC_X(0x006C2538, otherRide->var_04A, 0, 0x013CE952, 0, 0, 0x0141EF68, 0); + RCT2_GLOBAL(0x013CE952, uint32) = otherRide->name_arguments; + RCT2_CALLPROC_X(0x006C2538, otherRide->name, 0, 0x013CE952, 0, 0, 0x0141EF68, 0); if (strcmp((char*)RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, (char*)0x0141EF68) >= 0) break; diff --git a/src/window_scenery.c b/src/window_scenery.c new file mode 100644 index 0000000000..17c8ee2b2b --- /dev/null +++ b/src/window_scenery.c @@ -0,0 +1,1166 @@ +/***************************************************************************** +* Copyright (c) 2014 Dániel Tar +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include +#include +#include "addresses.h" +#include "audio.h" +#include "game.h" +#include "map.h" +#include "gfx.h" +#include "peep.h" +#include "sprite.h" +#include "scenery.h" +#include "string_ids.h" +#include "viewport.h" +#include "widget.h" +#include "window.h" + +#define WINDOW_SCENERY_WIDTH 0x27A +#define WINDOW_SCENERY_HEIGHT 0x8E +#define SCENERY_BUTTON_WIDTH 66 +#define SCENERY_BUTTON_HEIGHT 80 +#define SCENERY_ENTRIES_BY_TAB 128 + +enum { + WINDOW_SCENERY_TAB_1, + WINDOW_SCENERY_TAB_2, + WINDOW_SCENERY_TAB_3, + WINDOW_SCENERY_TAB_4, + WINDOW_SCENERY_TAB_5, + WINDOW_SCENERY_TAB_6, + WINDOW_SCENERY_TAB_7, + WINDOW_SCENERY_TAB_8, + WINDOW_SCENERY_TAB_9, + WINDOW_SCENERY_TAB_10, + WINDOW_SCENERY_TAB_11, + WINDOW_SCENERY_TAB_12, + WINDOW_SCENERY_TAB_13, + WINDOW_SCENERY_TAB_14, + WINDOW_SCENERY_TAB_15, + WINDOW_SCENERY_TAB_16, + WINDOW_SCENERY_TAB_17, + WINDOW_SCENERY_TAB_18, + WINDOW_SCENERY_TAB_19, + WINDOW_SCENERY_TAB_20 +} WINDOW_SCENERY_LIST_TAB; + +static void window_scenery_emptysub() { } +static void window_scenery_close(); +static void window_scenery_mouseup(); +static void window_scenery_resize(); +static void window_scenery_mousedown(int widgetIndex, rct_window* w, rct_widget* widget); +static void window_scenery_dropdown(); +static void window_scenery_update(rct_window *w); +static void window_scenery_event_07(); +static void window_scenery_scrollgetsize(); +static void window_scenery_scrollmousedown(); +static void window_scenery_scrollmouseover(); +static void window_scenery_tooltip(); +static void window_scenery_invalidate(); +static void window_scenery_paint(); +static void window_scenery_scrollpaint(); + +static void* window_scenery_events[] = { + window_scenery_close, + window_scenery_mouseup, + window_scenery_resize, + window_scenery_mousedown, + window_scenery_dropdown, + window_scenery_emptysub, + window_scenery_update, + window_scenery_event_07, + window_scenery_emptysub, + window_scenery_emptysub, + window_scenery_emptysub, + window_scenery_emptysub, + window_scenery_emptysub, + window_scenery_emptysub, + window_scenery_emptysub, + window_scenery_scrollgetsize, + window_scenery_scrollmousedown, + window_scenery_emptysub, + window_scenery_scrollmouseover, + window_scenery_emptysub, + window_scenery_emptysub, + window_scenery_emptysub, + window_scenery_tooltip, + window_scenery_emptysub, + window_scenery_emptysub, + window_scenery_invalidate, + window_scenery_paint, + window_scenery_scrollpaint, +}; + + +enum WINDOW_SCENERY_LIST_WIDGET_IDX { + WIDX_SCENERY_BACKGROUND, // 1 + WIDX_SCENERY_TITLE, // 2 + WIDX_SCENERY_CLOSE, // 4 + WIDX_SCENERY_TAB_CONTENT_PANEL, // 8 + WIDX_SCENERY_TAB_1, // 10 + WIDX_SCENERY_TAB_2, // 20 + WIDX_SCENERY_TAB_3, // 40 + WIDX_SCENERY_TAB_4, // 80 + WIDX_SCENERY_TAB_5, // 100 + WIDX_SCENERY_TAB_6, // 200 + WIDX_SCENERY_TAB_7, // 400 + WIDX_SCENERY_TAB_8, // 800 + WIDX_SCENERY_TAB_9, // 1000 + WIDX_SCENERY_TAB_10, // 2000 + WIDX_SCENERY_TAB_11, // 4000 + WIDX_SCENERY_TAB_12, // 8000 + WIDX_SCENERY_TAB_13, // 10000 + WIDX_SCENERY_TAB_14, // 20000 + WIDX_SCENERY_TAB_15, // 40000 + WIDX_SCENERY_TAB_16, // 80000 + WIDX_SCENERY_TAB_17, // 100000 + WIDX_SCENERY_TAB_18, // 200000 + WIDX_SCENERY_TAB_19, // 400000 + WIDX_SCENERY_TAB_20, // 800000 + WIDX_SCENERY_LIST, // 1000000 + WIDX_SCENERY_ROTATE_OBJECTS_BUTTON, // 2000000 + WIDX_SCENERY_REPAINT_SCENERY_BUTTON, // 4000000 + WIDX_SCENERY_PRIMARY_COLOUR_BUTTON, // 8000000 + WIDX_SCENERY_SECONDARY_COLOUR_BUTTON, // 10000000 + WIDX_SCENERY_TERTIARY_COLOUR_BUTTON, // 20000000 + WIDX_SCENERY_BUILD_CLUSTER_BUTTON, // 40000000 +}; + +static rct_widget window_scenery_widgets[] = { + { WWT_FRAME, 0, 0, 633, 0, 141, 0xFFFFFFFF, STR_NONE }, // 1 0x009DE298 + { WWT_CAPTION, 0, 1, 632, 1, 14, 0xFFFFFFFF, STR_WINDOW_TITLE_TIP }, // 2 0x009DE2A8 + { WWT_CLOSEBOX, 0, 621, 631, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // 4 0x009DE2B8 + { WWT_RESIZE, 1, 0, 633, 43, 141, 0xFFFFFFFF, STR_NONE }, // 8 0x009DE2C8 + { WWT_TAB, 1, 3, 33, 17, 43, 0xFFFFFFFF, 1812 }, // 10 0x009DE2D8 + { WWT_TAB, 1, 34, 64, 17, 43, 0xFFFFFFFF, 1812 }, // 20 0x009DE2E8 + { WWT_TAB, 1, 65, 95, 17, 43, 0xFFFFFFFF, 1812 }, // 40 0x009DE2F8 + { WWT_TAB, 1, 96, 126, 17, 43, 0xFFFFFFFF, 1812 }, // 80 0x009DE308 + { WWT_TAB, 1, 127, 157, 17, 43, 0xFFFFFFFF, 1812 }, // 100 0x009DE318 + { WWT_TAB, 1, 158, 188, 17, 43, 0xFFFFFFFF, 1812 }, // 200 0x009DE328 + { WWT_TAB, 1, 189, 219, 17, 43, 0xFFFFFFFF, 1812 }, // 400 0x009DE338 + { WWT_TAB, 1, 220, 250, 17, 43, 0xFFFFFFFF, 1812 }, // 800 0x009DE348 + { WWT_TAB, 1, 251, 281, 17, 43, 0xFFFFFFFF, 1812 }, // 1000 0x009DE358 + { WWT_TAB, 1, 282, 312, 17, 43, 0xFFFFFFFF, 1812 }, // 2000 0x009DE368 + { WWT_TAB, 1, 313, 343, 17, 43, 0xFFFFFFFF, 1812 }, // 4000 0x009DE378 + { WWT_TAB, 1, 344, 374, 17, 43, 0xFFFFFFFF, 1812 }, // 8000 0x009DE388 + { WWT_TAB, 1, 375, 405, 17, 43, 0xFFFFFFFF, 1812 }, // 10000 0x009DE398 + { WWT_TAB, 1, 406, 436, 17, 43, 0xFFFFFFFF, 1812 }, // 20000 0x009DE3A8 + { WWT_TAB, 1, 437, 467, 17, 43, 0xFFFFFFFF, 1812 }, // 40000 0x009DE3B8 + { WWT_TAB, 1, 468, 498, 17, 43, 0xFFFFFFFF, 1812 }, // 80000 0x009DE3C8 + { WWT_TAB, 1, 468, 498, 17, 43, 0xFFFFFFFF, 1812 }, // 100000 0x009DE3D8 + { WWT_TAB, 1, 468, 498, 17, 43, 0xFFFFFFFF, 1812 }, // 200000 0x009DE3E8 + { WWT_TAB, 1, 468, 498, 17, 43, 0xFFFFFFFF, 1812 }, // 400000 0x009DE3F8 + { WWT_TAB, 1, 468, 498, 17, 43, 0x20001598, 1812 }, // 800000 0x009DE408 + { WWT_SCROLL, 1, 2, 608, 47, 126, 2, STR_NONE }, // 1000000 0x009DE418 + { WWT_FLATBTN, 1, 609, 632, 44, 67, 5169, STR_ROTATE_OBJECTS_90 }, // 2000000 0x009DE428 + { WWT_FLATBTN, 1, 609, 632, 68, 91, 5173, 3102 }, // 4000000 0x009DE438 + { WWT_COLORBTN, 1, 615, 626, 93, 104, 0xFFFFFFFF, STR_SELECT_COLOUR }, // 8000000 0x009DE448 + { WWT_COLORBTN, 1, 615, 626, 105, 116, 0xFFFFFFFF, STR_SELECT_SECONDARY_COLOUR }, // 10000000 0x009DE458 + { WWT_COLORBTN, 1, 615, 626, 117, 128, 0xFFFFFFFF, STR_SELECT_TERNARY_COLOUR }, // 20000000 0x009DE468 + { WWT_FLATBTN, 1, 609, 632, 117, 140, 5172, 3225 }, // 40000000 0x009DE478 + { WIDGETS_END }, +}; + +static sint16 window_scenery_tab_entries[0x13][SCENERY_ENTRIES_BY_TAB + 1]; + +void init_scenery_entry(rct_scenery_entry *sceneryEntry, int index, uint8 sceneryTabId) { + if (RCT2_ADDRESS(0x01357BD0, sint32)[index >> 5] & (1 << (index & 0x1F))) { + if (sceneryTabId != 0xFF) { + for (int i = 0; i < SCENERY_ENTRIES_BY_TAB; i++) { + if (window_scenery_tab_entries[sceneryTabId][i] == -1) + { + window_scenery_tab_entries[sceneryTabId][i] = index; + window_scenery_tab_entries[sceneryTabId][i + 1] = -1; + return; + } + } + } + + for (int i = 0; i < 0x13; i++) { + int counter = 0; + + while (window_scenery_tab_entries[i][counter] != -1) + { + if (window_scenery_tab_entries[i][counter] == index) { + return; + } + + counter++; + } + } + + for (int i = 0; i < SCENERY_ENTRIES_BY_TAB; i++) { + if (window_scenery_tab_entries[0x13][i] == -1) + { + window_scenery_tab_entries[0x13][i] = index; + window_scenery_tab_entries[0x13][i + 1] = -1; + break; + } + } + } +} + +/* +* rct2: 0x006DFA00 +**/ +void init_scenery() { + bool enabledScenerySets[0x13] = { false }; + + for (int scenerySetIndex = 0; scenerySetIndex < 0x14; scenerySetIndex++) { + window_scenery_tab_entries[scenerySetIndex][0] = -1; + if (scenerySetIndex == 0x13) + continue; + + rct_scenery_set_entry* scenerySetEntry = g_scenerySetEntries[scenerySetIndex]; + if ((uint32)scenerySetEntry == 0xFFFFFFFF) + continue; + + int sceneryTabEntryCount = 0; + + for (int i = 0; i < scenerySetEntry->entry_count; i++) { + uint16 sceneryEntryId = scenerySetEntry->scenery_entries[i]; + uint32 ecx = RCT2_ADDRESS(0x01357BD0, uint32)[sceneryEntryId >> 5]; + uint32 edx = 1 << (sceneryEntryId & 0x1F); + if (ecx & edx) { + window_scenery_tab_entries[scenerySetIndex][sceneryTabEntryCount] = sceneryEntryId; + window_scenery_tab_entries[scenerySetIndex][++sceneryTabEntryCount] = -1; + } else { + enabledScenerySets[scenerySetIndex] = true; + } + } + } + + // small scenery + for (uint16 sceneryId = 0; sceneryId < 0xFC; sceneryId++) { + if ((uint32)g_smallSceneryEntries[sceneryId] == 0xFFFFFFFF) + continue; + + rct_scenery_entry* sceneryEntry = g_smallSceneryEntries[sceneryId]; + init_scenery_entry(sceneryEntry, sceneryId, sceneryEntry->small_scenery.scenery_tab_id); + } + + // large scenery + for (int sceneryId = 0x300; sceneryId < 0x380; sceneryId++) { + int largeSceneryIndex = sceneryId - 0x300; + + if ((uint32)g_largeSceneryEntries[largeSceneryIndex] == 0xFFFFFFFF) + continue; + + rct_scenery_entry* sceneryEntry = g_largeSceneryEntries[largeSceneryIndex]; + init_scenery_entry(sceneryEntry, sceneryId, sceneryEntry->large_scenery.scenery_tab_id); + } + + // walls + for (int sceneryId = 0x200; sceneryId < 0x280; sceneryId++) { + int wallSceneryIndex = sceneryId - 0x200; + + if ((uint32)g_wallSceneryEntries[wallSceneryIndex] == 0xFFFFFFFF) + continue; + + rct_scenery_entry* sceneryEntry = g_wallSceneryEntries[wallSceneryIndex]; + init_scenery_entry(sceneryEntry, sceneryId, sceneryEntry->wall.scenery_tab_id); + } + + // banners + for (int sceneryId = 0x400; sceneryId < 0x420; sceneryId++) { + int bannerIndex = sceneryId - 0x400; + + if ((uint32)g_bannerSceneryEntries[bannerIndex] == 0xFFFFFFFF) + continue; + + rct_scenery_entry* sceneryEntry = g_bannerSceneryEntries[bannerIndex]; + init_scenery_entry(sceneryEntry, sceneryId, sceneryEntry->banner.scenery_tab_id); + } + + // path bits + for (int sceneryId = 0x100; sceneryId < 0x10F; sceneryId++) { + int pathBitIndex = sceneryId - 0x100; + + if ((uint32)g_pathBitSceneryEntries[pathBitIndex] == 0xFFFFFFFF) + continue; + + rct_scenery_entry* sceneryEntry = g_pathBitSceneryEntries[pathBitIndex]; + init_scenery_entry(sceneryEntry, sceneryId, sceneryEntry->path_bit.scenery_tab_id); + } + + for (int widgetIndex = WIDX_SCENERY_TAB_1; widgetIndex < WIDX_SCENERY_LIST; widgetIndex++) + window_scenery_widgets[widgetIndex].type = 0; + + uint8 tabIndexes[0x13]; + uint8 order[0x13]; + int usedValues = 0; + + for (int scenerySetId = 0; scenerySetId < 0x13; scenerySetId++) { + rct_scenery_set_entry* sceneryEntry = g_scenerySetEntries[scenerySetId]; + if ((uint32)sceneryEntry == 0xFFFFFFFF) + continue; + + tabIndexes[usedValues] = scenerySetId; + order[usedValues] = sceneryEntry->var_108; + + usedValues++; + } + + while (true) { + bool finished = true; + for (int i = 1; i < usedValues; i++) { + if (order[i - 1] > order[i]) { + uint8 tmp = tabIndexes[i - 1]; + tabIndexes[i - 1] = tabIndexes[i]; + tabIndexes[i] = tmp; + tmp = order[i - 1]; + order[i - 1] = order[i]; + order[i] = tmp; + finished = false; + } + } + + if (finished) + break; + } + + tabIndexes[usedValues] = 0x13; + usedValues++; + + uint16 left = 3; + for (int i = 0; i < usedValues; i ++) { + uint32 tabIndex = tabIndexes[i]; + rct_widget* tabWidget = &window_scenery_widgets[tabIndex + WIDX_SCENERY_TAB_1]; + + if (left != 3 || tabIndex == 0x13) { + if (window_scenery_tab_entries[tabIndex][0] == -1) + continue; + + if (enabledScenerySets[tabIndex]) + continue; + } + + tabWidget->type = WWT_TAB; + tabWidget->left = left; + tabWidget->right = left + 0x1E; + left += 0x1F; + + if (tabIndex >= 0x13) + continue; + + tabWidget->image = g_scenerySetEntries[tabIndex]->image | 0x20000000; + } + + window_invalidate_by_id(WC_SCENERY, 0); +} + +/* +* rct2: 0x006E0FEF +**/ +void window_scenery_open() +{ + rct_window* window; + + // Check if window is already open + window = window_bring_to_front_by_id(WC_SCENERY, 0); + if (window != NULL) + return; + + init_scenery(); + + window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - WINDOW_SCENERY_WIDTH, 0x1D, WINDOW_SCENERY_WIDTH, WINDOW_SCENERY_HEIGHT, + (uint32*)window_scenery_events, WC_SCENERY, WF_2); + window->widgets = window_scenery_widgets; + + window->enabled_widgets = + (1 << WIDX_SCENERY_CLOSE) | + (1 << WIDX_SCENERY_ROTATE_OBJECTS_BUTTON) | + (1 << WIDX_SCENERY_TAB_1) | + (1 << WIDX_SCENERY_TAB_2) | + (1 << WIDX_SCENERY_TAB_3) | + (1 << WIDX_SCENERY_TAB_4) | + (1 << WIDX_SCENERY_TAB_5) | + (1 << WIDX_SCENERY_TAB_6) | + (1 << WIDX_SCENERY_TAB_7) | + (1 << WIDX_SCENERY_TAB_8) | + (1 << WIDX_SCENERY_TAB_9) | + (1 << WIDX_SCENERY_TAB_10) | + (1 << WIDX_SCENERY_TAB_11) | + (1 << WIDX_SCENERY_TAB_12) | + (1 << WIDX_SCENERY_TAB_13) | + (1 << WIDX_SCENERY_TAB_14) | + (1 << WIDX_SCENERY_TAB_15) | + (1 << WIDX_SCENERY_TAB_16) | + (1 << WIDX_SCENERY_TAB_17) | + (1 << WIDX_SCENERY_TAB_18) | + (1 << WIDX_SCENERY_TAB_19) | + (1 << WIDX_SCENERY_TAB_20) | + (1 << WIDX_SCENERY_PRIMARY_COLOUR_BUTTON) | + (1 << WIDX_SCENERY_SECONDARY_COLOUR_BUTTON) | + (1 << WIDX_SCENERY_REPAINT_SCENERY_BUTTON) | + (1 << WIDX_SCENERY_TERTIARY_COLOUR_BUTTON) | + (1 << WIDX_SCENERY_BUILD_CLUSTER_BUTTON); + + window_init_scroll_widgets(window); + RCT2_CALLPROC_X(0x006E1EB4, 0, 0, 0, 0, (int)window, 0, 0); + show_gridlines(); + RCT2_GLOBAL(0x00F64F05, uint8) = 3; // scenery rotation + RCT2_GLOBAL(0x00F64F12, uint8) = 0; + RCT2_GLOBAL(0x00F64F13, uint8) = 0; + window->scenery.selected_scenery_id = -1; + window->scenery.hover_counter = 0; + window_push_others_below(window); + RCT2_GLOBAL(0x00F64F0D, uint8) = 0; + RCT2_GLOBAL(0x00F64EB4, uint32) = 0x80000000; + RCT2_GLOBAL(0x00F64EC0, uint16) = 0; + RCT2_GLOBAL(0x00F64F19, uint8) = 0; // repaint colored scenery tool state + RCT2_GLOBAL(0x00F64F1A, uint8) = 0; // build cluster tool state + + window->min_width = WINDOW_SCENERY_WIDTH; + window->max_width = WINDOW_SCENERY_WIDTH; + window->min_height = WINDOW_SCENERY_HEIGHT; + window->max_height = WINDOW_SCENERY_HEIGHT; + window->colours[0] = 0x18; + window->colours[1] = 0x0C; + window->colours[2] = 0x0C; +} + +/* + * rct2: 0x0066DB3D +*/ +bool window_scenery_is_tool_active() { + int toolWindowClassification = RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass); + int toolWidgetIndex = RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, rct_windownumber); + + if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) + if (toolWindowClassification == WC_TOP_TOOLBAR && toolWidgetIndex == 9) + return true; + + return false; +} + + +/* +* rct2: 0x006E1A73 +**/ +void window_scenery_close() { + rct_window *w; + + window_get_register(w); + + RCT2_CALLPROC_EBPSAFE(0x006E2712); + hide_gridlines(); + RCT2_CALLPROC_X(0x006CB70A, 0, 0, 0, 0, 0, 0, 0); + + if (window_scenery_is_tool_active()) + tool_cancel(); +} + +int window_scenery_scrollgetsize_num() { + int items = 0; + while (window_scenery_tab_entries[RCT2_GLOBAL(0x00F64EDC, uint8)][items] != -1) + items++; + + items += 8; + int rows = items / 9; + if (rows == 0) + rows++; + + return rows * SCENERY_BUTTON_HEIGHT; +} + +/** +* +* rct2: 0x006BD94C +*/ +static void window_scenery_mouseup() +{ + short widgetIndex; + rct_window *w; + + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex) { + case WIDX_SCENERY_CLOSE: + window_close(w); + break; + case WIDX_SCENERY_ROTATE_OBJECTS_BUTTON: + RCT2_GLOBAL(0x00F64F05, uint8)++; + RCT2_GLOBAL(0x00F64F05, uint8) = RCT2_GLOBAL(0x00F64F05, uint8) % 4; + RCT2_CALLPROC_EBPSAFE(0x006E2712); + window_invalidate(w); + break; + case WIDX_SCENERY_REPAINT_SCENERY_BUTTON: + RCT2_GLOBAL(0x00F64F19, uint8) ^= 1; + window_invalidate(w); + break; + case WIDX_SCENERY_BUILD_CLUSTER_BUTTON: + RCT2_GLOBAL(0x00F64F1A, uint8) ^= 1; + window_invalidate(w); + break; + } +} + +/* +* +* rct2: 0x006E1EB4 +*/ +void window_scenery_update_scroll(rct_window *w) { + int scrollsize = window_scenery_scrollgetsize_num(); + w->scrolls[0].v_bottom = scrollsize; + + int tabIndex = RCT2_GLOBAL(0x00F64EDC, uint8); + + int itemIndex = 0; + sint16 sceneryId; + while ((sceneryId = window_scenery_tab_entries[tabIndex][itemIndex]) != -1) { + if (sceneryId == RCT2_ADDRESS(0x00F64EDD, sint16)[tabIndex]) + break; + itemIndex++; + } + + if (sceneryId == -1) { + itemIndex = 0; + sint16 sceneryId = window_scenery_tab_entries[tabIndex][itemIndex]; + if (sceneryId != -1) + RCT2_ADDRESS(0x00F64EDD, sint16)[tabIndex] = sceneryId; + } + + w->scrolls[0].v_top = (itemIndex / 9) * SCENERY_BUTTON_HEIGHT; + widget_scroll_update_thumbs(w, WIDX_SCENERY_LIST); +} + +/** +* +* rct2: 0x006E1E48 +*/ +static void window_scenery_resize() +{ + rct_window *w; + + window_get_register(w); + + if (w->width < w->min_width) { + w->width = w->min_width; + window_invalidate(w); + } + + if (w->width > w->max_width) { + w->width = w->max_width; + window_invalidate(w); + } + + if (w->height < w->min_height) { + w->height = w->min_height; + window_invalidate(w); + window_scenery_update_scroll(w); + } + + if (w->height > w->max_height) { + w->height = w->max_height; + window_invalidate(w); + window_scenery_update_scroll(w); + } +} + +/** +* +* rct2: 0x006E1A25 +*/ +static void window_scenery_mousedown(int widgetIndex, rct_window* w, rct_widget* widget) { + int eax; + + switch (widgetIndex) { + case WIDX_SCENERY_PRIMARY_COLOUR_BUTTON: + eax = (RCT2_GLOBAL(0xF64F06, uint8) << 8) + 0x80 + w->colours[1]; + RCT2_CALLPROC_X(0x006ED43D, eax, 0, 0, widgetIndex, (int)w, (int)widget, 0xFFFFFFFF); + break; + case WIDX_SCENERY_SECONDARY_COLOUR_BUTTON: + eax = (RCT2_GLOBAL(0xF64F07, uint8) << 8) + 0x80 + w->colours[1]; + RCT2_CALLPROC_X(0x006ED43D, eax, 0, 0, widgetIndex, (int)w, (int)widget, 0xFFFFFFFF); + break; + case WIDX_SCENERY_TERTIARY_COLOUR_BUTTON: + eax = (RCT2_GLOBAL(0xF64F08, uint8) << 8) + 0x80 + w->colours[1]; + RCT2_CALLPROC_X(0x006ED43D, eax, 0, 0, widgetIndex, (int)w, (int)widget, 0xFFFFFFFF); + break; + } + + if (widgetIndex >= WIDX_SCENERY_TAB_1 && widgetIndex <= WIDX_SCENERY_TAB_20) { + RCT2_GLOBAL(0x00F64EDC, uint8) = widgetIndex - WIDX_SCENERY_TAB_1; + window_invalidate(w); + RCT2_GLOBAL(0x00F64EB4, uint32) = 0x80000000; + window_scenery_update_scroll(w); + } +} + +/** +* +* rct2: 0x006E1A54 +*/ +static void window_scenery_dropdown() { + rct_window* w; + short widgetIndex, dropdownIndex; + window_dropdown_get_registers(w, widgetIndex, dropdownIndex); + + if (dropdownIndex == -1) + return; + + if (widgetIndex == WIDX_SCENERY_PRIMARY_COLOUR_BUTTON) { + RCT2_GLOBAL(0x00F64F06, uint8) = (uint8)dropdownIndex; + } + else if (widgetIndex == WIDX_SCENERY_SECONDARY_COLOUR_BUTTON) { + RCT2_GLOBAL(0x00F64F07, uint8) = (uint8)dropdownIndex; + } + else if (widgetIndex == WIDX_SCENERY_TERTIARY_COLOUR_BUTTON) { + RCT2_GLOBAL(0x00F64F08, uint8) = (uint8)dropdownIndex; + } + + window_invalidate(w); +} + +/** +* +* rct2: 0x006E1B9F +*/ +static void window_scenery_event_07() { + rct_window *w; + + window_get_register(w); + + if (w->scenery.selected_scenery_id != -1) { + w->scenery.selected_scenery_id = -1; + } +} + +/** +* +* rct2: 0x006E1CD3 +*/ +static void window_scenery_update(rct_window *w) +{ + rct_window* other = window_find_from_point(RCT2_GLOBAL(0x0142406C, int), RCT2_GLOBAL(0x01424070, int)); + if (other == w) { + int window_x = RCT2_GLOBAL(0x0142406C, int) - w->x + 0x1A; + int window_y = RCT2_GLOBAL(0x01424070, int) - w->y; + + if (window_y < 0x2C || window_x <= w->width) { + int widgetIndex = window_find_widget_from_point(w, + RCT2_GLOBAL(0x0142406C, int), RCT2_GLOBAL(0x01424070, int)); + + if (widgetIndex >= 3) { + w->scenery.hover_counter++; + if (w->scenery.hover_counter < 8) { + if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) != INPUT_STATE_SCROLL_LEFT) { + w->min_width = WINDOW_SCENERY_WIDTH; + w->max_width = WINDOW_SCENERY_WIDTH; + w->min_height = WINDOW_SCENERY_HEIGHT; + w->max_height = WINDOW_SCENERY_HEIGHT; + } + } else { + int windowHeight = w->scrolls[0].v_bottom + 0x3E; + if (windowHeight > 0x1C6) + windowHeight = 0x1C6; + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) < 0x258){ + if (windowHeight > 0x176) + windowHeight = 0x176; + } + + w->min_width = WINDOW_SCENERY_WIDTH; + w->max_width = WINDOW_SCENERY_WIDTH; + w->min_height = windowHeight; + w->max_height = windowHeight; + } + } + } + } else { + w->scenery.hover_counter = 0; + if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) != INPUT_STATE_SCROLL_LEFT) { + w->min_width = WINDOW_SCENERY_WIDTH; + w->max_width = WINDOW_SCENERY_WIDTH; + w->min_height = WINDOW_SCENERY_HEIGHT; + w->max_height = WINDOW_SCENERY_HEIGHT; + } + } + + gfx_invalidate_screen(); + + // todo + //if (window_scenery_is_tool_active()) + //window_close(w); + + if (RCT2_GLOBAL(0x00F64F19, uint8) != 1) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8) = 0x17; + return; + } + + uint16 tabIndex = RCT2_GLOBAL(0x00F64EDC, uint8); + sint16 tabSelectedSceneryId = RCT2_ADDRESS(0x00F64EDD, sint16)[tabIndex]; + if (tabSelectedSceneryId == -1) + return; + + if (tabSelectedSceneryId > 0x400) { // banner + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8) = 0x18; + } else if (tabSelectedSceneryId > 0x300) { // large scenery + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8) = + g_largeSceneryEntries[tabSelectedSceneryId - 0x300]->large_scenery.tool_id; + } else if (tabSelectedSceneryId > 0x200) { // wall + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8) = + g_wallSceneryEntries[tabSelectedSceneryId - 0x200]->wall.tool_id; + } else if (tabSelectedSceneryId > 0x100) { // path bit + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8) = + g_pathBitSceneryEntries[tabSelectedSceneryId - 0x100]->path_bit.tool_id; + } else { // small scenery + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8) = + g_smallSceneryEntries[tabSelectedSceneryId]->small_scenery.tool_id; + } +} + +/** +* +* rct2: 0x006E1A91 +*/ +void window_scenery_scrollgetsize() { + int scrollHeight = window_scenery_scrollgetsize_num(); + +#ifdef _MSC_VER + __asm mov edx, scrollHeight +#else + __asm__("mov edx, %[scrollHeight] " : [scrollHeight] "+m" (scrollHeight)); +#endif +} + +short get_scenery_id_by_cursor_pos(short x, short y) { + int tabSceneryIndex = x / SCENERY_BUTTON_WIDTH + (y / SCENERY_BUTTON_HEIGHT) * 9; + uint8 tabIndex = RCT2_GLOBAL(0x00F64EDC, uint8); + + int itemCounter = 0; + sint16 sceneryId = 0; + while (itemCounter <= tabSceneryIndex) { + sceneryId = window_scenery_tab_entries[tabIndex][itemCounter]; + if (sceneryId == -1) + return -1; + + itemCounter++; + } + + return sceneryId; +} + +/** +* +* rct2: 0x006E1C4A +*/ +void window_scenery_scrollmousedown() { + short x, y; + rct_window *w; + + window_scrollmouse_get_registers(w, x, y); + + short sceneryId = get_scenery_id_by_cursor_pos(x, y); + if (sceneryId == -1) + return; + + uint8 tabIndex = RCT2_GLOBAL(0x00F64EDC, uint8); + RCT2_ADDRESS(0x00F64EDD, sint16)[tabIndex] = sceneryId; + + RCT2_GLOBAL(0x00F64F19, uint8) &= 0xFE; + sound_play_panned(4, (w->width >> 1) + w->x); + w->scenery.hover_counter = -16; + RCT2_GLOBAL(0x00F64EB4, uint32) = 0x80000000; + window_invalidate(w); +} + +/** +* +* rct2: 0x006E1BB8 +*/ +void window_scenery_scrollmouseover() { + short x, y; + rct_window *w; + + window_scrollmouse_get_registers(w, x, y); + short sceneryId = get_scenery_id_by_cursor_pos(x, y); + if (sceneryId != -1) { + w->scenery.selected_scenery_id = sceneryId; + window_invalidate(w); + } +} + +/** +* +* rct2: 0x006E1C05 +*/ +void window_scenery_tooltip() { + uint16 tooltipIndex; + + #ifdef _MSC_VER + __asm mov tooltipIndex, ax + #else + __asm__("mov %[tooltipIndex], ax " : [tooltipIndex] "+m" (tooltipIndex)); + #endif + + if (tooltipIndex == 0x18) + { + RCT2_GLOBAL(0x013CE952, uint16) = 3159; + } + else if (tooltipIndex >= 4 && tooltipIndex < 0x17) + { + RCT2_GLOBAL(0x013CE952, uint16) = g_scenerySetEntries[tooltipIndex - 4]->name; + } +} + +/** +* +* rct2: 0x006E118B +*/ +void window_scenery_invalidate() { + rct_window* w; + + window_get_register(w); + + uint16 tabIndex = RCT2_GLOBAL(0x00F64EDC, uint8); + uint32 titleStringId = 0x715; + if (tabIndex <= 0x13) { + titleStringId = g_scenerySetEntries[tabIndex]->name; + } + window_scenery_widgets[WIDX_SCENERY_TITLE].image = titleStringId; + + w->pressed_widgets = (((uint32)w->pressed_widgets & 0xFF00000F) | (1 << (tabIndex + 4))) & 0xBBFFFFFF; + + if (RCT2_GLOBAL(0x00F64F19, uint8) == 1) { // repaint colored scenery tool is on + w->pressed_widgets |= 0x04000000; + } + + if (RCT2_GLOBAL(0x00F64F1A, uint8) == 1) { // build cluster tool is on + w->pressed_widgets |= 0x040000000; + } + + window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type = WWT_EMPTY; + window_scenery_widgets[WIDX_SCENERY_BUILD_CLUSTER_BUTTON].type = WWT_EMPTY; + + sint16 tabSelectedSceneryId = RCT2_ADDRESS(0x00F64EDD, sint16)[tabIndex]; + if (tabSelectedSceneryId != -1) { + if (tabSelectedSceneryId < 0x100) { + if (!(RCT2_GLOBAL(0x00F64F19, uint8) & 1)) + window_scenery_widgets[WIDX_SCENERY_BUILD_CLUSTER_BUTTON].type = WWT_FLATBTN; + + rct_scenery_entry* sceneryEntry = g_smallSceneryEntries[tabSelectedSceneryId]; + if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG4) { + window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type = WWT_FLATBTN; + } + } + else if (tabSelectedSceneryId > 0x300) { + window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type = WWT_FLATBTN; + } + } + + window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].image = + (RCT2_GLOBAL(0x00F64F06, uint8) << 19) + 0x600013C3; + window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].image = + (RCT2_GLOBAL(0x00F64F07, uint8) << 19) + 0x600013C3; + window_scenery_widgets[WIDX_SCENERY_TERTIARY_COLOUR_BUTTON].image = + (RCT2_GLOBAL(0x00F64F08, uint8) << 19) + 0x600013C3; + + window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_EMPTY; + window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].type = WWT_EMPTY; + window_scenery_widgets[WIDX_SCENERY_TERTIARY_COLOUR_BUTTON].type = WWT_EMPTY; + + if (RCT2_GLOBAL(0x00F64F19, uint8) & 1) { // repaint colored scenery tool is on + window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLORBTN; + window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].type = WWT_COLORBTN; + window_scenery_widgets[WIDX_SCENERY_TERTIARY_COLOUR_BUTTON].type = WWT_COLORBTN; + window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type = WWT_EMPTY; + } + else if (tabSelectedSceneryId != -1) { + rct_scenery_entry* sceneryEntry = NULL; + + if (tabSelectedSceneryId >= 0x400) { + sceneryEntry = g_bannerSceneryEntries[tabSelectedSceneryId - 0x400]; + + if (sceneryEntry->banner.flags & 1) + window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLORBTN; + } + else if (tabSelectedSceneryId >= 0x300) { + sceneryEntry = g_largeSceneryEntries[tabSelectedSceneryId - 0x300]; + + if (sceneryEntry->large_scenery.flags & 1) + window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLORBTN; + if (sceneryEntry->large_scenery.flags & 2) + window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].type = WWT_COLORBTN; + } + else if (tabSelectedSceneryId >= 0x200) { + sceneryEntry = g_wallSceneryEntries[tabSelectedSceneryId - 0x200]; + if (sceneryEntry->wall.flags & (WALL_SCENERY_FLAG1 | WALL_SCENERY_FLAG2)) { + window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLORBTN; + + if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { + window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].type = WWT_COLORBTN; + + if (sceneryEntry->wall.flags2 & WALL_SCENERY_FLAG1) + window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_EMPTY; + if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) + window_scenery_widgets[WIDX_SCENERY_TERTIARY_COLOUR_BUTTON].type = WWT_COLORBTN; + } + } + } + else if (tabSelectedSceneryId < 0x100) { + sceneryEntry = g_smallSceneryEntries[tabSelectedSceneryId]; + + if (sceneryEntry->small_scenery.flags & (SMALL_SCENERY_HAS_PRIMARY_COLOUR | SMALL_SCENERY_FLAG10)) { + window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLORBTN; + + if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_HAS_SECONDARY_COLOUR) + window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].type = WWT_COLORBTN; + } + } + } + + window_scenery_widgets[WIDX_SCENERY_BACKGROUND].right = w->width - 1; + window_scenery_widgets[WIDX_SCENERY_BACKGROUND].bottom = w->height - 1; + window_scenery_widgets[WIDX_SCENERY_TAB_CONTENT_PANEL].right = w->width - 1; + window_scenery_widgets[WIDX_SCENERY_TAB_CONTENT_PANEL].bottom = w->height - 1; + window_scenery_widgets[WIDX_SCENERY_TITLE].right = w->width - 2; + window_scenery_widgets[WIDX_SCENERY_CLOSE].left = w->width - 13; + window_scenery_widgets[WIDX_SCENERY_CLOSE].right = window_scenery_widgets[WIDX_SCENERY_CLOSE].left + 10; + window_scenery_widgets[WIDX_SCENERY_LIST].right = w->width - 0x1A; + window_scenery_widgets[WIDX_SCENERY_LIST].bottom = w->height - 0x0E; + + window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].left = w->width - 25; + window_scenery_widgets[WIDX_SCENERY_REPAINT_SCENERY_BUTTON].left = w->width - 25; + window_scenery_widgets[WIDX_SCENERY_BUILD_CLUSTER_BUTTON].left = w->width - 25; + window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].right = w->width - 2; + window_scenery_widgets[WIDX_SCENERY_REPAINT_SCENERY_BUTTON].right = w->width - 2; + window_scenery_widgets[WIDX_SCENERY_BUILD_CLUSTER_BUTTON].right = w->width - 2; + + window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].left = w->width - 19; + window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].left = w->width - 19; + window_scenery_widgets[WIDX_SCENERY_TERTIARY_COLOUR_BUTTON].left = w->width - 19; + window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].right = w->width - 8; + window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].right = w->width - 8; + window_scenery_widgets[WIDX_SCENERY_TERTIARY_COLOUR_BUTTON].right = w->width - 8; +} + +/** +* +* rct2: 0x006E1462 +*/ +void window_scenery_paint() { + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + + uint16 tabIndex = RCT2_GLOBAL(0x00F64EDC, uint8); + uint16 selectedWidgetId = tabIndex + 4; + uint32 imageId = ((w->colours[1] << 19) | window_scenery_widgets[selectedWidgetId].image) + 1ul; + + gfx_draw_sprite(dpi, imageId, + w->x + window_scenery_widgets[selectedWidgetId].left, + w->y + window_scenery_widgets[selectedWidgetId].top, + selectedWidgetId); + + sint16 selectedSceneryEntryId = w->scenery.selected_scenery_id; + if (selectedSceneryEntryId == -1) { + if (RCT2_GLOBAL(0x00F64F19, uint8) & 1) // repaint colored scenery tool is on + return; + + selectedSceneryEntryId = RCT2_ADDRESS(0x00F64EDD, sint16)[tabIndex]; + + if (selectedSceneryEntryId == -1) + return; + } + + uint32 price = 0; + + rct_scenery_entry* sceneryEntry = NULL; + if (selectedSceneryEntryId >= 0x400) { + sceneryEntry = g_bannerSceneryEntries[selectedSceneryEntryId - 0x400]; + price = sceneryEntry->banner.price; + } else if (selectedSceneryEntryId >= 0x300) { + sceneryEntry = g_largeSceneryEntries[selectedSceneryEntryId - 0x300]; + price = sceneryEntry->large_scenery.price * 10; + } else if (selectedSceneryEntryId >= 0x200) { + sceneryEntry = g_wallSceneryEntries[selectedSceneryEntryId - 0x200]; + price = sceneryEntry->wall.price; + } else if (selectedSceneryEntryId >= 0x100) { + sceneryEntry = g_pathBitSceneryEntries[selectedSceneryEntryId - 0x100]; + price = sceneryEntry->path_bit.price; + } else { + sceneryEntry = g_smallSceneryEntries[selectedSceneryEntryId]; + price = sceneryEntry->small_scenery.price * 10; + } + + if (w->scenery.selected_scenery_id == -1 && RCT2_GLOBAL(0x00F64EB4, uint32) != 0x80000000) { + price = RCT2_GLOBAL(0x00F64EB4, uint32); + } + + RCT2_GLOBAL(0x013CE952, uint32) = price; + + if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { + // -14 + gfx_draw_string_right(dpi, STR_COST_LABEL, (void*)0x013CE952, 0, + w->x + w->width - 0x1A, w->y + w->height - 13); + } + + RCT2_GLOBAL(0x013CE952, uint16) = sceneryEntry->name; + gfx_draw_string_left_clipped(dpi, 0x4A7, (void*)0x013CE952, 0, + w->x + 3, w->y + w->height - 13, w->width - 19); +} + +/** +* +* rct2: 0x006E15ED +*/ +void window_scenery_scrollpaint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + gfx_clear(dpi, ((char*)0x0141FC48)[w->colours[1] * 8] * 0x1010101); + + uint8 tabIndex = RCT2_GLOBAL(0x00F64EDC, uint8); + + int sceneryTabItemIndex = 0; + sint16 currentSceneryGlobalId = -1; + sint16 left = 0, top = 0; + uint8 sceneryRotation = RCT2_GLOBAL(0x00F64F05, uint8); + while ((currentSceneryGlobalId = window_scenery_tab_entries[tabIndex][sceneryTabItemIndex]) != -1) { + uint16 tabSelectedSceneryId = RCT2_ADDRESS(0x00F64EDD, uint16)[tabIndex]; + + if (RCT2_GLOBAL(0x00F64F19, uint8) == 1) + { + if (w->scenery.selected_scenery_id == currentSceneryGlobalId) { + gfx_fill_rect_inset(dpi, left, top, left + SCENERY_BUTTON_WIDTH - 1, + top + SCENERY_BUTTON_HEIGHT - 1, w->colours[1], 0x80); + } + } else { + if (tabSelectedSceneryId == currentSceneryGlobalId) { + gfx_fill_rect_inset(dpi, left, top, left + SCENERY_BUTTON_WIDTH - 1, + top + SCENERY_BUTTON_HEIGHT - 1, w->colours[1], 0xA0); + } + else if (w->scenery.selected_scenery_id == currentSceneryGlobalId) { + gfx_fill_rect_inset(dpi, left, top, left + SCENERY_BUTTON_WIDTH - 1, + top + SCENERY_BUTTON_HEIGHT - 1, w->colours[1], 0x80); + } + } + + rct_scenery_entry* sceneryEntry; + if (currentSceneryGlobalId >= 0x400) { + sceneryEntry = g_bannerSceneryEntries[currentSceneryGlobalId - 0x400]; + uint32 imageId = sceneryEntry->image + sceneryRotation * 2; + imageId |= (RCT2_GLOBAL(0x00F64F06, uint8) << 19) | 0x20000000; + + gfx_draw_sprite(dpi, imageId, left + 0x21, top + 0x28, w->colours[1]); + gfx_draw_sprite(dpi, imageId + 1, left + 0x21, top + 0x28, w->colours[1]); + } + else if (currentSceneryGlobalId >= 0x300) { + sceneryEntry = g_largeSceneryEntries[currentSceneryGlobalId - 0x300]; + uint32 imageId = sceneryEntry->image + sceneryRotation; + imageId |= (RCT2_GLOBAL(0x00F64F06, uint8) << 19) | 0x20000000; + imageId |= (RCT2_GLOBAL(0x00F64F07, uint8) << 24) | 0x80000000; + + gfx_draw_sprite(dpi, imageId, left + 0x21, top, w->colours[1]); + } + else if (currentSceneryGlobalId >= 0x200) { + sceneryEntry = g_wallSceneryEntries[currentSceneryGlobalId - 0x200]; + rct_drawpixelinfo* clipdpi = clip_drawpixelinfo(dpi, left + 1, 64, top + 1, 78); + if (clipdpi != NULL) { + uint32 imageId = sceneryEntry->image; + uint8 tertiaryColour = w->colours[1]; + + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG2) { + imageId |= (RCT2_GLOBAL(0x00F64F06, uint8) << 19) | 0x20000000; + + if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { + imageId |= (RCT2_GLOBAL(0x00F64F07, uint8) << 24) | 0x80000000; + } + } + else { + imageId |= (RCT2_GLOBAL(0x00F64F06, uint8) << 19) | 0x20000000; + + if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { + imageId |= (RCT2_GLOBAL(0x00F64F07, uint8) << 24) | 0x80000000; + + if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) { + imageId &= 0xDFFFFFFF; + tertiaryColour = RCT2_GLOBAL(0x00F64F08, uint8); + } + + } + } + + gfx_draw_sprite(clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, + tertiaryColour); + rct2_free(clipdpi); + } + } + else if (currentSceneryGlobalId >= 0x100) { + sceneryEntry = g_pathBitSceneryEntries[currentSceneryGlobalId - 0x100]; + uint32 imageId = sceneryEntry->image; + + gfx_draw_sprite(dpi, imageId, left + 0x0B, top + 0x10, w->colours[1]); + } else { + sceneryEntry = g_smallSceneryEntries[currentSceneryGlobalId]; + rct_drawpixelinfo* clipdpi = clip_drawpixelinfo(dpi, left + 1, SCENERY_BUTTON_WIDTH - 2, top + 1, SCENERY_BUTTON_HEIGHT - 2); + if (clipdpi != NULL) { + + uint32 imageId = sceneryEntry->image + sceneryRotation; + + if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_HAS_PRIMARY_COLOUR) { + imageId |= (RCT2_GLOBAL(0x00F64F06, uint8) << 19) | 0x20000000; + + if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_HAS_SECONDARY_COLOUR) { + imageId |= (RCT2_GLOBAL(0x00F64F07, uint8) << 24) | 0x80000000; + } + } + + uint16 spriteTop = (sceneryEntry->small_scenery.height / 4) + 0x2B; + + if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG1 && + sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG2) { + spriteTop -= 0x0C; + } + + gfx_draw_sprite(clipdpi, imageId, 0x20, spriteTop, w->colours[1]); + + if (sceneryEntry->small_scenery.flags & 0x200) { + imageId = ((sceneryEntry->image + sceneryRotation) + 0x40000004) + + ((RCT2_GLOBAL(0x00F64F06, uint8) + 0x70) << 19); + + gfx_draw_sprite(clipdpi, imageId, 0x20, spriteTop, w->colours[1]); + } + + if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG8) { + imageId = (sceneryEntry->image + sceneryRotation) + 4; + gfx_draw_sprite(clipdpi, imageId, 0x20, spriteTop, w->colours[1]); + } + + rct2_free(clipdpi); + } + } + + left += SCENERY_BUTTON_WIDTH; + if (left >= 594) { + top += SCENERY_BUTTON_HEIGHT; + left = 0; + } + sceneryTabItemIndex++; + } +} \ No newline at end of file diff --git a/src/window_staff.c b/src/window_staff.c index 217b58dc12..eed1574ee7 100644 --- a/src/window_staff.c +++ b/src/window_staff.c @@ -1,5 +1,5 @@ -/***************************************************************************** -* Copyright (c) 2014 Maciek Baron, Daniel Tar +/***************************************************************************** +* Copyright (c) 2014 Maciek Baron, Dániel Tar * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. @@ -171,11 +171,7 @@ void window_staff_open() window->colours[2] = 4; } -void window_staff_cancel_tools() { - rct_window *w; - - window_get_register(w); - +void window_staff_cancel_tools(rct_window *w) { int toolWindowClassification = RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass); int toolWindowNumber = RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber); if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) @@ -264,7 +260,7 @@ static void window_staff_resize() * * rct2: 0x006BD971 */ -static void window_staff_mousedown(int widgetIndex, rct_window*w, rct_widget* widget) +static void window_staff_mousedown(int widgetIndex, rct_window* w, rct_widget* widget) { short newSelectedTab; int eax;