From 1c1db75c2846c9ced119ecc5839a59751a029dc2 Mon Sep 17 00:00:00 2001 From: King_Hual Date: Mon, 15 Sep 2014 22:50:34 +0300 Subject: [PATCH 01/12] Added rct_peep struct union (staff_id and guest_peep_varC5) --- src/marketing.c | 4 ++-- src/peep.c | 16 ++++++++-------- src/peep.h | 6 +++++- src/staff.c | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/marketing.c b/src/marketing.c index af6179fc1c..3a2ac192d2 100644 --- a/src/marketing.c +++ b/src/marketing.c @@ -113,7 +113,7 @@ void marketing_set_guest_campaign(rct_peep *peep, int campaign) peep->item_standard_flags |= PEEP_ITEM_VOUCHER; peep->var_F0 = 1; peep->var_F1 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; - peep->staff_id = RCT2_ADDRESS(0x01358116, uint8)[campaign]; + peep->guest_peep_varC5 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; peep->var_C6 = 240; break; case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: @@ -128,7 +128,7 @@ void marketing_set_guest_campaign(rct_peep *peep, int campaign) case ADVERTISING_CAMPAIGN_PARK: break; case ADVERTISING_CAMPAIGN_RIDE: - peep->staff_id = RCT2_ADDRESS(0x01358116, uint8)[campaign]; + peep->guest_peep_varC5 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; peep->var_C6 = 240; break; } diff --git a/src/peep.c b/src/peep.c index 629426280a..83e77f44bf 100644 --- a/src/peep.c +++ b/src/peep.c @@ -177,31 +177,31 @@ void peep_problem_warnings_update() break; case PEEP_THOUGHT_TYPE_HUNGRY: // 0x14 - if (peep->staff_id == -1){ + if (peep->guest_peep_varC5 == -1){ hunger_counter++; break; } - ride = &g_ride_list[peep->staff_id]; + ride = &g_ride_list[peep->guest_peep_varC5]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x80000)) hunger_counter++; break; case PEEP_THOUGHT_TYPE_THIRSTY: - if (peep->staff_id == -1){ + if (peep->guest_peep_varC5 == -1){ thirst_counter++; break; } - ride = &g_ride_list[peep->staff_id]; + ride = &g_ride_list[peep->guest_peep_varC5]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x1000000)) thirst_counter++; break; case PEEP_THOUGHT_TYPE_BATHROOM: - if (peep->staff_id == -1){ + if (peep->guest_peep_varC5 == -1){ bathroom_counter++; break; } - ride = &g_ride_list[peep->staff_id]; + ride = &g_ride_list[peep->guest_peep_varC5]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x2000000)) bathroom_counter++; break; @@ -447,8 +447,8 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum break; case PEEP_STATE_WALKING: case 0x14: - if (peep->staff_id != 0xFF){ - ride = g_ride_list[peep->staff_id]; + if (peep->guest_peep_varC5 != 0xFF){ + ride = g_ride_list[peep->guest_peep_varC5]; *argument_1 = STR_HEADING_FOR | (ride.name << 16); *argument_2 = ride.name_arguments; } diff --git a/src/peep.h b/src/peep.h index a938440268..25ee1583b7 100644 --- a/src/peep.h +++ b/src/peep.h @@ -386,7 +386,11 @@ typedef struct { uint16 var_AE; rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 uint8 var_C4; // 0xC4 - uint8 staff_id; + union + { + uint8 staff_id; + uint8 guest_peep_varC5; + }; uint8 var_C6; uint8 photo1_ride_ref; // 0xC7 uint32 flags; // 0xC8 diff --git a/src/staff.c b/src/staff.c index 3871dfb080..d0bc47c04e 100644 --- a/src/staff.c +++ b/src/staff.c @@ -290,4 +290,4 @@ void sub_6C0C3F() } } } -} \ No newline at end of file +} From d17091f16b485b95f84840d7942c62a7b2bee110 Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Tue, 16 Sep 2014 16:32:12 +0200 Subject: [PATCH 02/12] Fix disabled widgets being clickable and reenable third tab of Cheats --- src/input.c | 6 ++++-- src/window_cheats.c | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/input.c b/src/input.c index 67bee3606e..429c5c3d2e 100644 --- a/src/input.c +++ b/src/input.c @@ -531,8 +531,10 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) } break; default: - if (!widget_is_enabled(w, widgetIndex)) - break; + if (!widget_is_enabled(w, widgetIndex)) + break; + if (widget_is_disabled(w, widgetIndex)) + break; sound_play_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2); diff --git a/src/window_cheats.c b/src/window_cheats.c index 585388ee29..e0975ef90d 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -238,9 +238,9 @@ static void* window_cheats_page_events[] = { }; static uint32 window_cheats_page_enabled_widgets[] = { - (1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_HIGH_MONEY) | (1 << WIDX_PARK_ENTRANCE_FEE), - (1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_HAPPY_GUESTS) | (1 << WIDX_TRAM_GUESTS), - (1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_FREEZE_CLIMATE) | (1 << WIDX_OPEN_CLOSE_PARK) | (1 << WIDX_DECREASE_GAME_SPEED) | (1 << WIDX_INCREASE_GAME_SPEED), + (1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_TAB_3) | (1 << WIDX_HIGH_MONEY) | (1 << WIDX_PARK_ENTRANCE_FEE), + (1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_TAB_3) | (1 << WIDX_HAPPY_GUESTS) | (1 << WIDX_TRAM_GUESTS), + (1 << WIDX_CLOSE) | (1 << WIDX_TAB_1) | (1 << WIDX_TAB_2) | (1 << WIDX_TAB_3) | (1 << WIDX_FREEZE_CLIMATE) | (1 << WIDX_OPEN_CLOSE_PARK) | (1 << WIDX_DECREASE_GAME_SPEED) | (1 << WIDX_INCREASE_GAME_SPEED), }; static void window_cheats_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w); From 3afafe4f6b80727e069feb686988ac8cbaa3d407 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 16 Sep 2014 17:59:22 +0100 Subject: [PATCH 03/12] Fix #432. Mistake was caused by oppacity bit in colour --- src/widget.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widget.c b/src/widget.c index 003e86597a..0e4038d337 100644 --- a/src/widget.c +++ b/src/widget.c @@ -442,6 +442,7 @@ static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widge widget->right - widget->left - 2 ); } else { + colour &= ~(1 << 7); if (widget_is_disabled(w, widgetIndex)) colour |= 0x40; gfx_draw_string_centred_clipped( From 722eac949acb4435b72811412081a581bf87d52c Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 16 Sep 2014 18:13:18 +0100 Subject: [PATCH 04/12] Labelled a few peep variables. Added voucher type enum --- src/marketing.c | 16 ++++++++-------- src/marketing.h | 7 +++++++ src/peep.c | 16 ++++++++-------- src/peep.h | 13 ++++++++----- src/window_peep.c | 11 ++++++----- 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/src/marketing.c b/src/marketing.c index 3a2ac192d2..c8a1f6e991 100644 --- a/src/marketing.c +++ b/src/marketing.c @@ -107,28 +107,28 @@ void marketing_set_guest_campaign(rct_peep *peep, int campaign) switch (campaign) { case ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE: peep->item_standard_flags |= PEEP_ITEM_VOUCHER; - peep->var_F0 = 0; + peep->voucher_type = VOUCHER_TYPE_PARK_ENTRY_FREE; break; case ADVERTISING_CAMPAIGN_RIDE_FREE: peep->item_standard_flags |= PEEP_ITEM_VOUCHER; - peep->var_F0 = 1; - peep->var_F1 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; - peep->guest_peep_varC5 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; + peep->voucher_type = VOUCHER_TYPE_RIDE_FREE; + peep->voucher_arguments = RCT2_ADDRESS(0x01358116, uint8)[campaign]; + peep->guest_heading_to_ride_id = RCT2_ADDRESS(0x01358116, uint8)[campaign]; peep->var_C6 = 240; break; case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: peep->item_standard_flags |= PEEP_ITEM_VOUCHER; - peep->var_F0 = 2; + peep->voucher_type = VOUCHER_TYPE_PARK_ENTRY_HALF_PRICE; break; case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE: peep->item_standard_flags |= PEEP_ITEM_VOUCHER; - peep->var_F0 = 3; - peep->var_F1 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; + peep->voucher_type = VOUCHER_TYPE_FOOD_OR_DRINK_FREE; + peep->voucher_arguments = RCT2_ADDRESS(0x01358116, uint8)[campaign]; break; case ADVERTISING_CAMPAIGN_PARK: break; case ADVERTISING_CAMPAIGN_RIDE: - peep->guest_peep_varC5 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; + peep->guest_heading_to_ride_id = RCT2_ADDRESS(0x01358116, uint8)[campaign]; peep->var_C6 = 240; break; } diff --git a/src/marketing.h b/src/marketing.h index f5ee816d3d..f94f27664d 100644 --- a/src/marketing.h +++ b/src/marketing.h @@ -33,6 +33,13 @@ enum { ADVERTISING_CAMPAIGN_COUNT }; +enum{ + VOUCHER_TYPE_PARK_ENTRY_FREE, + VOUCHER_TYPE_RIDE_FREE, + VOUCHER_TYPE_PARK_ENTRY_HALF_PRICE, + VOUCHER_TYPE_FOOD_OR_DRINK_FREE, +}; + extern const money16 AdvertisingCampaignPricePerWeek[6]; int marketing_get_campaign_guest_generation_probability(int campaign); diff --git a/src/peep.c b/src/peep.c index ee693bbd2e..24841b5f25 100644 --- a/src/peep.c +++ b/src/peep.c @@ -178,31 +178,31 @@ void peep_problem_warnings_update() break; case PEEP_THOUGHT_TYPE_HUNGRY: // 0x14 - if (peep->guest_peep_varC5 == -1){ + if (peep->guest_heading_to_ride_id == -1){ hunger_counter++; break; } - ride = &g_ride_list[peep->guest_peep_varC5]; + ride = &g_ride_list[peep->guest_heading_to_ride_id]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x80000)) hunger_counter++; break; case PEEP_THOUGHT_TYPE_THIRSTY: - if (peep->guest_peep_varC5 == -1){ + if (peep->guest_heading_to_ride_id == -1){ thirst_counter++; break; } - ride = &g_ride_list[peep->guest_peep_varC5]; + ride = &g_ride_list[peep->guest_heading_to_ride_id]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x1000000)) thirst_counter++; break; case PEEP_THOUGHT_TYPE_BATHROOM: - if (peep->guest_peep_varC5 == -1){ + if (peep->guest_heading_to_ride_id == -1){ bathroom_counter++; break; } - ride = &g_ride_list[peep->guest_peep_varC5]; + ride = &g_ride_list[peep->guest_heading_to_ride_id]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x2000000)) bathroom_counter++; break; @@ -448,8 +448,8 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum break; case PEEP_STATE_WALKING: case 0x14: - if (peep->guest_peep_varC5 != 0xFF){ - ride = g_ride_list[peep->guest_peep_varC5]; + if (peep->guest_heading_to_ride_id != 0xFF){ + ride = g_ride_list[peep->guest_heading_to_ride_id]; *argument_1 = STR_HEADING_FOR | (ride.name << 16); *argument_2 = ride.name_arguments; } diff --git a/src/peep.h b/src/peep.h index 095efa364a..c090f67001 100644 --- a/src/peep.h +++ b/src/peep.h @@ -332,7 +332,10 @@ typedef struct { uint8 pad_2C; uint8 sprite_type; // 0x2D uint8 type; // 0x2E - uint8 staff_type; // 0x2F Also used for no_of_rides + union{ // 0x2F + uint8 staff_type; + uint8 no_of_rides; + }; uint8 tshirt_colour; // 0x30 uint8 trousers_colour; // 0x31 uint16 var_32; @@ -388,10 +391,10 @@ typedef struct { uint16 var_AE; rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 uint8 var_C4; // 0xC4 - union + union // 0xC5 { uint8 staff_id; - uint8 guest_peep_varC5; + uint8 guest_heading_to_ride_id; }; uint8 var_C6; uint8 photo1_ride_ref; // 0xC7 @@ -410,8 +413,8 @@ typedef struct { uint8 no_of_drinks; // 0xED uint8 no_of_souvenirs; // 0xEE uint8 pad_EF; - uint8 var_F0; //voucher_type - uint8 var_F1; //voucher_type arguments i.e. ride_id + uint8 voucher_type; // 0xF0 + uint8 voucher_arguments; // 0xF1 ride_id or string_offset_id uint8 pad_F2; uint8 var_F3; uint8 pad_F4[0x02]; diff --git a/src/window_peep.c b/src/window_peep.c index a43fc2e5e1..926d972944 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -21,6 +21,7 @@ #include "addresses.h" #include "game.h" #include "map.h" +#include "marketing.h" #include "ride.h" #include "peep.h" #include "scenario.h" @@ -2105,19 +2106,19 @@ void window_peep_inventory_paint(){ RCT2_GLOBAL(0x13CE95A, uint32) = ride->name_arguments; break; case PEEP_ITEM_VOUCHER: - RCT2_GLOBAL(0x13CE958, uint16) = peep->var_F0 + 2418; + RCT2_GLOBAL(0x13CE958, uint16) = peep->voucher_type + 2418; RCT2_GLOBAL(0x13CE95A, uint16) = RCT2_GLOBAL(0x13573D4, uint16); RCT2_GLOBAL(0x13CE95C, uint32) = RCT2_GLOBAL(0x13573D8, uint32); - if (peep->var_F0 == 0 || peep->var_F0 == 2)break; + if (peep->voucher_type == VOUCHER_TYPE_PARK_ENTRY_FREE || peep->voucher_type == VOUCHER_TYPE_PARK_ENTRY_HALF_PRICE)break; - int voucher_id = peep->var_F1 + 1988; + int voucher_id = peep->voucher_arguments + 1988; if (voucher_id >= 2020) voucher_id += 102; RCT2_GLOBAL(0x13CE95A, uint16) = voucher_id; - if (peep->var_F0 == 3)break; - ride = GET_RIDE(peep->var_F1); + if (peep->voucher_type == VOUCHER_TYPE_FOOD_OR_DRINK_FREE)break; + ride = GET_RIDE(peep->voucher_arguments); RCT2_GLOBAL(0x13CE95A, uint16) = ride->name; RCT2_GLOBAL(0x13CE95C, uint32) = ride->name_arguments; break; From f2f69bb7883bab8adcab987e1aa30844e0177f27 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 16 Sep 2014 18:16:32 +0100 Subject: [PATCH 05/12] Switched to no_of_rides instead of staff_type --- src/window_peep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index 926d972944..ee168a8d80 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -1840,8 +1840,8 @@ void window_peep_finance_paint(){ // Paid on rides y += 10; RCT2_GLOBAL(0x13CE952, money32) = peep->paid_on_rides; - RCT2_GLOBAL(0x13CE956, uint16) = peep->staff_type; - if (peep->staff_type != 1){ + RCT2_GLOBAL(0x13CE956, uint16) = peep->no_of_rides; + if (peep->no_of_rides != 1){ gfx_draw_string_left(dpi, 2298, (void*)0x13CE952, 0, x, y); } else{ From f37928c06a86fef7fdf55e494c9e8dfe3a95422f Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 16 Sep 2014 21:06:47 +0100 Subject: [PATCH 06/12] Fix #455. Since there is no reason to show both quit windows may as well just close the previous one. --- src/window_save_prompt.c | 66 +++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/window_save_prompt.c b/src/window_save_prompt.c index 5ab0081bb5..185ef5f7b2 100644 --- a/src/window_save_prompt.c +++ b/src/window_save_prompt.c @@ -125,46 +125,48 @@ void window_save_prompt_open() // Check if window is already open window = window_bring_to_front_by_id(WC_SAVE_PROMPT, 0); - if (window == NULL) { - if (prompt_mode == PM_QUIT) { - widgets = window_quit_prompt_widgets; - enabled_widgets = - (1 << WQIDX_CLOSE) | - (1 << WQIDX_OK) | - (1 << WQIDX_CANCEL); - x = 177; - y = 34; - } else { - widgets = window_save_prompt_widgets; - enabled_widgets = - (1 << WIDX_CLOSE) | - (1 << WIDX_SAVE) | - (1 << WIDX_DONT_SAVE) | - (1 << WIDX_CANCEL); - x = 260; - y = 50; - } + if (window){ + window_close(window); + } - window = window_create( - (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - x/2, - max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - y/2), + if (prompt_mode == PM_QUIT) { + widgets = window_quit_prompt_widgets; + enabled_widgets = + (1 << WQIDX_CLOSE) | + (1 << WQIDX_OK) | + (1 << WQIDX_CANCEL); + x = 177; + y = 34; + } else { + widgets = window_save_prompt_widgets; + enabled_widgets = + (1 << WIDX_CLOSE) | + (1 << WIDX_SAVE) | + (1 << WIDX_DONT_SAVE) | + (1 << WIDX_CANCEL); + x = 260; + y = 50; + } + + window = window_create( + (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - x / 2, + max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - y / 2), x, y, (uint32*)window_save_prompt_events, WC_SAVE_PROMPT, WF_TRANSPARENT | WF_STICK_TO_FRONT - ); + ); - window->widgets = widgets; - window->enabled_widgets = enabled_widgets; - window_init_scroll_widgets(window); - window->colours[0] = 154; + window->widgets = widgets; + window->enabled_widgets = enabled_widgets; + window_init_scroll_widgets(window); + window->colours[0] = 154; - // Pause the game - RCT2_GLOBAL(0x009DEA6E, uint8) |= 2; - pause_sounds(); - window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0); - } + // Pause the game + RCT2_GLOBAL(0x009DEA6E, uint8) |= 2; + pause_sounds(); + window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0); stringId = prompt_mode + STR_LOAD_GAME; if (stringId == STR_LOAD_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) From bcfe5026472e504b0e6f68dc4af8586541f406bd Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 16 Sep 2014 22:09:47 +0100 Subject: [PATCH 07/12] Fixes half drawn doors in scenery window --- src/window_scenery.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/window_scenery.c b/src/window_scenery.c index 886fd5b083..3ed8744b9e 100644 --- a/src/window_scenery.c +++ b/src/window_scenery.c @@ -1088,6 +1088,12 @@ void window_scenery_scrollpaint() if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { imageId |= (window_scenery_secondary_colour << 24) | 0x80000000; } + gfx_draw_sprite(clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, + tertiaryColour); + + imageId = (sceneryEntry->image + 0x40000006) | (window_scenery_primary_colour << 19); + gfx_draw_sprite(clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, + tertiaryColour); } else { imageId |= (window_scenery_primary_colour << 19) | 0x20000000; @@ -1100,11 +1106,17 @@ void window_scenery_scrollpaint() tertiaryColour = window_scenery_tertiary_colour; } + } + gfx_draw_sprite(clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, + tertiaryColour); + + if (sceneryEntry->wall.flags & WALL_SCENERY_FLAG5){ + gfx_draw_sprite(clipdpi, imageId + 1, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, + tertiaryColour); } } - gfx_draw_sprite(clipdpi, imageId, 0x2F, (sceneryEntry->wall.height * 2) + 0x32, - tertiaryColour); + rct2_free(clipdpi); } } From eded73c5fbece27e811d9c3c9f6617804a1bc6bd Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Thu, 18 Sep 2014 00:05:28 +0200 Subject: [PATCH 08/12] Fix footpath construction arrow not showing up --- src/window_footpath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window_footpath.c b/src/window_footpath.c index 1e70c75998..b2f06656d9 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -391,7 +391,7 @@ static void window_footpath_toolupdate() if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { window_footpath_set_provisional_path_at_point(x, y); } else if (widgetIndex == WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL) { - RCT2_CALLPROC_X(0x006A8388, 0, 0, 0, 0, (int)w, 0, 0); + RCT2_CALLPROC_X(0x006A8388, x, y, 0, 0, (int)w, 0, 0); } } From 3430e4da6f5bad7f535a5f1bcc37338e322bd880 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 17 Sep 2014 23:21:51 +0100 Subject: [PATCH 09/12] add swedish.txt to VS filters --- projects/openrct2.vcxproj.filters | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 4e10931727..9063f53269 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -426,5 +426,8 @@ Data\Language + + Data\Language + \ No newline at end of file From 7002720f24d369e17494a131bfcb6e2097e8f4b5 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 17 Sep 2014 23:42:18 +0100 Subject: [PATCH 10/12] add and fix terrain get/set functions --- src/map.c | 20 ++++++++++++++++++-- src/map.h | 4 ++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/map.c b/src/map.c index f654935c4a..3db145ec96 100644 --- a/src/map.c +++ b/src/map.c @@ -25,6 +25,22 @@ static void tiles_init(); +int map_element_get_terrain(rct_map_element *element) +{ + int terrain = (element->properties.surface.terrain >> 5) & 7; + if (element->type & 1) + terrain |= (1 << 3); + return terrain; +} + +int map_element_get_terrain_edge(rct_map_element *element) +{ + int terrain_edge = (element->properties.surface.slope >> 5) & 7; + if (element->type & 128) + terrain_edge |= (1 << 3); + return terrain_edge; +} + void map_element_set_terrain(rct_map_element *element, int terrain) { // Bit 3 for terrain is stored in element.type bit 0 @@ -40,7 +56,7 @@ void map_element_set_terrain(rct_map_element *element, int terrain) void map_element_set_terrain_edge(rct_map_element *element, int terrain) { - // Bit 3 for terrain is stored in element.type bit 0 + // Bit 3 for terrain is stored in element.type bit 7 if (terrain & 8) element->type |= 128; else @@ -48,7 +64,7 @@ void map_element_set_terrain_edge(rct_map_element *element, int terrain) // Bits 0, 1, 2 for terrain are stored in element.slope bit 5, 6, 7 element->properties.surface.slope &= ~0xE0; - element->properties.surface.slope = (terrain & 7) << 5; + element->properties.surface.slope |= (terrain & 7) << 5; } rct_map_element *map_get_surface_element_at(int x, int y) diff --git a/src/map.h b/src/map.h index 1546d9e3fe..8b0073eaa0 100644 --- a/src/map.h +++ b/src/map.h @@ -195,6 +195,10 @@ typedef struct { void map_init(); void map_update_tile_pointers(); +int map_element_get_terrain(rct_map_element *element); +int map_element_get_terrain_edge(rct_map_element *element); +void map_element_set_terrain(rct_map_element *element, int terrain); +void map_element_set_terrain_edge(rct_map_element *element, int terrain); rct_map_element *map_get_surface_element_at(int x, int y); int map_element_height(int x, int y); void sub_68B089(); From b40ebfe7a2c999c284a1f059c0a5338096c51783 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 18 Sep 2014 16:52:56 +0100 Subject: [PATCH 11/12] Fixed dropdown location after pickup. Labbeld variables to make it easier to read --- src/window_peep.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/window_peep.c b/src/window_peep.c index ee168a8d80..e061b4ccf4 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -1179,7 +1179,7 @@ void window_peep_overview_tool_update(){ } /* rct2: 0x664F72 */ -int sub_664F72(int x, int y, int edx){ +int sub_664F72(int x, int y, int z){ if (x > 0x1FFF || y > 0x1FFF){ RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0x6C1; return 1; @@ -1192,10 +1192,10 @@ int sub_664F72(int x, int y, int edx){ return 1; } - edx >>= 3; - if ((edx & 0xFF) < map_element->base_height)return 0; - edx = (edx & 0xFF) - 2; - if (edx > map_element->base_height)return 0; + z >>= 3; + if ((z & 0xFF) < map_element->base_height)return 0; + z = (z & 0xFF) - 2; + if (z > map_element->base_height)return 0; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0x6C1; return 1; @@ -1211,25 +1211,32 @@ void window_peep_overview_tool_down(){ if (widgetIndex != WIDX_PICKUP) return; - int eax = x, ebx = y, ecx = 0, edx = widgetIndex, edi = 0, esi = (int)w, ebp = 0; - ebx += 16; - RCT2_CALLFUNC_X(0x689726, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + int dest_x = x, dest_y = y, ecx = 0, edx = widgetIndex, edi = 0, esi = (int)w, ebp = 0; + dest_y += 16; + RCT2_CALLFUNC_X(0x689726, &dest_x, &dest_y, &ecx, &edx, &esi, &edi, &ebp); - if (eax == 0x8000)return; + if (dest_x == 0x8000)return; - eax += 16; - ecx = ebx + 16; - edx = ((uint8*)edx)[2] * 8 + 16; - int _eax = eax & 0xFFE0, _ebx = ebx & 0xFFE0; - if (sub_664F72(eax & 0xFFE0, ebx & 0xFFE0, edx)){ + // Set the coordinate of destination to be exactly + // in the middle of a tile. + dest_x += 16; + dest_y += 16; + // Set the tile coordinate to top left of tile + int tile_y = dest_y & 0xFFE0; + int tile_x = dest_x & 0xFFE0; + + int dest_z = ((uint8*)edx)[2] * 8 + 16; + + if (sub_664F72(tile_x, tile_y, dest_z)){ window_error_open(0x785,-1); return; } - int _edx = edx>>3; + + int _edx = dest_z >> 3; _edx &= 0xFFFF00FF; - _edx |= edx << 8; + _edx |= dest_z << 8; _edx += 0x100; - int flags = RCT2_CALLPROC_X(0x68B93A, eax & 0xFFE0, 0xF, ebx & 0xFFE0, _edx, (int)w, 0, 0); + int flags = RCT2_CALLPROC_X(0x68B93A, tile_x, 0xF, tile_y, _edx, (int)w, 0, 0); if (flags & 0x100){ if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) != 0x3A5 ){ @@ -1241,7 +1248,7 @@ void window_peep_overview_tool_down(){ } rct_peep* peep = GET_PEEP(w->number); - RCT2_CALLPROC_X(0x0069E9D3, eax, 0, ebx, edx, (int)peep, 0, 0); + RCT2_CALLPROC_X(0x0069E9D3, dest_x, 0, dest_y, dest_z, (int)peep, 0, 0); RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)peep, 0, 0); RCT2_CALLPROC_X(0x0069A409, 0, 0, 0, 0, (int)peep, 0, 0); peep->state = 0; From f25b6e2ba2b5493e242cd98e93344d6bdff9fdc1 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 18 Sep 2014 17:18:39 +0100 Subject: [PATCH 12/12] Fixed incorrectly assuming peep was underground if on water --- src/map.c | 3 ++- src/viewport.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/map.c b/src/map.c index 3db145ec96..cc749f604a 100644 --- a/src/map.c +++ b/src/map.c @@ -154,9 +154,10 @@ void map_update_tile_pointers() /** * Return the absolute height of an element, given its (x,y) coordinates + * * ax: x * cx: y - * dx: return + * dx: return remember to & with 0xFFFF if you don't want water affecting results * rct2: 0x00662783 */ int map_element_height(int x, int y) diff --git a/src/viewport.c b/src/viewport.c index d39bf92a8d..f1aa777363 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -281,7 +281,7 @@ void viewport_update_position(rct_window *window) if (window->viewport_target_sprite != -1){ rct_sprite* sprite = &g_sprite_list[window->viewport_target_sprite]; - int height = map_element_height(0xFFFF & sprite->unknown.x, 0xFFFF & sprite->unknown.y) - 16; + int height = map_element_height(0xFFFF & sprite->unknown.x, 0xFFFF & sprite->unknown.y) & 0xFFFF - 16; int underground = sprite->unknown.z < height; RCT2_CALLPROC_X(0x6E7A15, sprite->unknown.x, sprite->unknown.y, sprite->unknown.z, underground, (int)window, (int)viewport, 0);