From 498810cc46c474653d608137ddf8fa8d2becfb3a Mon Sep 17 00:00:00 2001 From: Timmy Weerwag Date: Mon, 23 Mar 2015 22:28:44 +0100 Subject: [PATCH 01/12] Decompiled 0x006A8388 --- src/windows/footpath.c | 45 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/windows/footpath.c b/src/windows/footpath.c index 260bc289a1..3374cffb24 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -152,6 +152,7 @@ static void window_footpath_mousedown_direction(int direction); static void window_footpath_mousedown_slope(int slope); static void window_footpath_show_footpath_types_dialog(rct_window *w, rct_widget *widget, int showQueues); static void window_footpath_set_provisional_path_at_point(int x, int y); +static void window_footpath_set_selection_start_bridge_at_point(int screenX, int screenY); static void window_footpath_place_path_at_point(int x, int y); static void window_footpath_start_bridge_at_point(int screenX, int screenY); static void window_footpath_construct(); @@ -389,7 +390,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, x, y, 0, 0, (int)w, 0, 0); + window_footpath_set_selection_start_bridge_at_point(x, y); } } @@ -703,6 +704,48 @@ static void window_footpath_set_provisional_path_at_point(int x, int y) } } +/** +* +* rct2: 0x006A8388 +*/ +static void window_footpath_set_selection_start_bridge_at_point(int screenX, int screenY) +{ + int x, y, direction; + rct_map_element *mapElement; + + map_invalidate_selection_rect(); + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xfffa; + + sub_68A0C9(screenX, screenY, &x, &y, &direction, &mapElement); + if (x == 0x8000) + return; + + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 5; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = y; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = y; + + RCT2_GLOBAL(0x009DEA4E, uint8) = direction; + RCT2_GLOBAL(0x009DEA48, uint16) = x; + RCT2_GLOBAL(0x009DEA4A, uint16) = y; + + int z = mapElement->base_height; + + if ((mapElement->type & 0x3C) == 0) { + uint8 slope = mapElement->properties.surface.slope; + if (slope & 0xf) + z += 2; // Add 2 for a slope + if (slope & 0x10) + z += 2; // Add another 2 for a steep slope + } + + RCT2_GLOBAL(0x009DEA4C, uint16) = z << 3; + + map_invalidate_selection_rect(); +} + /** * * rct2: 0x006A82C5 From 66baebb2fc11c3033b26dfea93fa2db9402984ec Mon Sep 17 00:00:00 2001 From: Timmy Weerwag Date: Mon, 23 Mar 2015 22:46:10 +0100 Subject: [PATCH 02/12] Named map arrow globals --- src/addresses.h | 5 +++++ src/windows/footpath.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 94ab6853b4..02e5dbdb84 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -199,6 +199,11 @@ #define RCT2_ADDRESS_MAP_SELECTION_B_Y 0x009DE592 #define RCT2_ADDRESS_MAP_SELECTION_TYPE 0x009DE594 +#define RCT2_ADDRESS_MAP_ARROW_X 0x009DEA48 +#define RCT2_ADDRESS_MAP_ARROW_Y 0x009DEA4A +#define RCT2_ADDRESS_MAP_ARROW_Z 0x009DEA4C +#define RCT2_ADDRESS_MAP_ARROW_DIRECTION 0x009DEA4E + #define RCT2_ADDRESS_SCREEN_FLAGS 0x009DEA68 #define RCT2_ADDRESS_SCREENSHOT_COUNTDOWN 0x009DEA6D // Note: not only the zeroth bit can be set to control pause diff --git a/src/windows/footpath.c b/src/windows/footpath.c index 3374cffb24..0dc81edbc0 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -727,9 +727,9 @@ static void window_footpath_set_selection_start_bridge_at_point(int screenX, int RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = y; - RCT2_GLOBAL(0x009DEA4E, uint8) = direction; - RCT2_GLOBAL(0x009DEA48, uint16) = x; - RCT2_GLOBAL(0x009DEA4A, uint16) = y; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = direction; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16) = y; int z = mapElement->base_height; @@ -741,7 +741,7 @@ static void window_footpath_set_selection_start_bridge_at_point(int screenX, int z += 2; // Add another 2 for a steep slope } - RCT2_GLOBAL(0x009DEA4C, uint16) = z << 3; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = z << 3; map_invalidate_selection_rect(); } From 8bc40cd48cc38b10daafaf95845bdf3ed98474ae Mon Sep 17 00:00:00 2001 From: Timmy Weerwag Date: Mon, 23 Mar 2015 23:25:30 +0100 Subject: [PATCH 03/12] Documented selection globals a bit --- src/addresses.h | 11 +++++++++++ src/windows/footpath.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 02e5dbdb84..024430432b 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -192,11 +192,22 @@ #define RCT2_ADDRESS_PALETTE_EFFECT_FRAME_NO 0x009DE584 +// Flags: +// 0x1 Enable selection +// 0x2 Enable construct selection, see CONSTRUCT_PATH_* +// 0x4 Show yellow arrow, see MAP_ARROW_* +// 0x8 ? #define RCT2_ADDRESS_MAP_SELECTION_FLAGS 0x009DE58A #define RCT2_ADDRESS_MAP_SELECTION_A_X 0x009DE58C #define RCT2_ADDRESS_MAP_SELECTION_B_X 0x009DE58E #define RCT2_ADDRESS_MAP_SELECTION_A_Y 0x009DE590 #define RCT2_ADDRESS_MAP_SELECTION_B_Y 0x009DE592 +// Types: +// 0-3 Corners +// 4 Whole tile +// 5 ? +// 6-9 Quarters +// 10-13 Edges #define RCT2_ADDRESS_MAP_SELECTION_TYPE 0x009DE594 #define RCT2_ADDRESS_MAP_ARROW_X 0x009DEA48 diff --git a/src/windows/footpath.c b/src/windows/footpath.c index 0dc81edbc0..cb7cd79e01 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -714,13 +714,13 @@ static void window_footpath_set_selection_start_bridge_at_point(int screenX, int rct_map_element *mapElement; map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xfffa; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0) & (1 << 2); sub_68A0C9(screenX, screenY, &x, &y, &direction, &mapElement); if (x == 0x8000) return; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 5; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0) | (1 << 2); RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = x; From 6c264195ce6134108bb9c5dee3459214365bb372 Mon Sep 17 00:00:00 2001 From: Timmy Weerwag Date: Tue, 24 Mar 2015 15:12:09 +0100 Subject: [PATCH 04/12] Small typo; use map_element_get_type --- src/windows/footpath.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/windows/footpath.c b/src/windows/footpath.c index cb7cd79e01..a6755f6593 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -714,7 +714,7 @@ static void window_footpath_set_selection_start_bridge_at_point(int screenX, int rct_map_element *mapElement; map_invalidate_selection_rect(); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0) & (1 << 2); + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0) & ~(1 << 2); sub_68A0C9(screenX, screenY, &x, &y, &direction, &mapElement); if (x == 0x8000) @@ -733,7 +733,7 @@ static void window_footpath_set_selection_start_bridge_at_point(int screenX, int int z = mapElement->base_height; - if ((mapElement->type & 0x3C) == 0) { + if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_SURFACE) { uint8 slope = mapElement->properties.surface.slope; if (slope & 0xf) z += 2; // Add 2 for a slope From af8857dd325e21e64980120b397b79c78736242f Mon Sep 17 00:00:00 2001 From: Timmy Weerwag Date: Tue, 24 Mar 2015 22:04:22 +0100 Subject: [PATCH 05/12] Replace more occurrences of addresses with new name --- src/interface/viewport.c | 11 ++++++----- src/windows/footpath.c | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/interface/viewport.c b/src/interface/viewport.c index c7f2adb167..43166d5fc5 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -1073,21 +1073,22 @@ void sub_68B35F(int ax, int cx) break; } dx /= 2; + // Display little yellow arrow when building footpaths? if ((RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16_t) & 4) && - RCT2_GLOBAL(0x9DE56A, uint16_t) == RCT2_GLOBAL(0x9DEA48, uint16_t) && - RCT2_GLOBAL(0x9DE56E, uint16_t) == RCT2_GLOBAL(0x9DEA4A, uint16_t)) + RCT2_GLOBAL(0x9DE56A, uint16_t) == RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16_t) && + RCT2_GLOBAL(0x9DE56E, uint16_t) == RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16_t)) { int ebx = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32_t); RCT2_GLOBAL(0x9DE568, uint16_t) = ax; RCT2_GLOBAL(0x9DE56C, uint16_t) = cx; - int dl = RCT2_GLOBAL(0x009DEA4E, uint8_t) & 3; + int dl = RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8_t) & 3; ebx += dl; ebx &= 3; - dl = RCT2_GLOBAL(0x009DEA4E, uint8_t) & 0xFC; + dl = RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8_t) & 0xFC; ebx += dl; ebx += 0x20900C27; - int d = RCT2_GLOBAL(0x009DEA4C, uint16_t); + int d = RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16_t); RCT2_GLOBAL(0x9DE570, uint8_t) = 0; RCT2_GLOBAL(0x9DEA52, uint16_t) = 0; RCT2_GLOBAL(0x9DEA54, uint16_t) = 0; diff --git a/src/windows/footpath.c b/src/windows/footpath.c index a6755f6593..d2de3966f0 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -470,10 +470,10 @@ static void window_footpath_update_provisional_path_for_bridge_mode(rct_window * _window_footpath_provisional_path_arrow_timer = 5; RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_FLAGS, uint8) ^= PROVISIONAL_PATH_FLAG_SHOW_ARROW; footpath_get_next_path_info(&type, &x, &y, &z, &slope); - RCT2_GLOBAL(0x009DEA48, uint16) = x; - RCT2_GLOBAL(0x009DEA4A, uint16) = y; - RCT2_GLOBAL(0x009DEA4C, uint16) = z * 8; - RCT2_GLOBAL(0x009DEA4E, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8); + RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Y, uint16) = y; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_Z, uint16) = z * 8; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_ARROW_DIRECTION, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCT_PATH_DIRECTION, uint8); if (RCT2_GLOBAL(RCT2_ADDRESS_PROVISIONAL_PATH_FLAGS, uint8) & PROVISIONAL_PATH_FLAG_SHOW_ARROW) RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 2); else From 3e6a16ef4cde541431c441a699562cb80de2c60f Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 26 Mar 2015 20:48:42 +0000 Subject: [PATCH 06/12] Label known values --- src/ride/vehicle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 7d3070fe8b..4e8b969717 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -35,7 +35,7 @@ static void vehicle_update(rct_vehicle *vehicle); */ void vehicle_update_sound_params(rct_vehicle* vehicle) { - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) && (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 4) || RCT2_GLOBAL(0x0141F570, uint8) == 6)) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) || RCT2_GLOBAL(0x0141F570, uint8) == 6)) { if (vehicle->sound1_id != (uint8)-1 || vehicle->sound2_id != (uint8)-1) { if (vehicle->sprite_left != 0x8000) { RCT2_GLOBAL(0x009AF5A0, sint16) = vehicle->sprite_left; @@ -549,10 +549,10 @@ void vehicle_update_all() uint16 sprite_index; rct_vehicle *vehicle; - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) return; - if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 4) && RCT2_GLOBAL(0x0141F570, uint8) != 6) + if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_DESIGNER) && RCT2_GLOBAL(0x0141F570, uint8) != 6) return; From 112290ca0c19fbcc8716f70884c03933c5ce3be9 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 26 Mar 2015 21:37:45 +0000 Subject: [PATCH 07/12] Fix station lights for races and normal operation rides --- src/ride/station.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/ride/station.c b/src/ride/station.c index 33cf3e9d75..a35e050c26 100644 --- a/src/ride/station.c +++ b/src/ride/station.c @@ -89,7 +89,8 @@ static void ride_update_station_bumpercar(rct_ride *ride, int stationIndex) { int i, dx, dl, dh; rct_vehicle *vehicle; - + // Change of station depart flag should really call invalidate_station_start + // but since bumpercars do not have station lights there is no point. if ( ride->status == RIDE_STATUS_CLOSED || (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) @@ -142,21 +143,24 @@ static void ride_update_station_normal(rct_ride *ride, int stationIndex) time = ride->station_depart[stationIndex] & STATION_DEPART_MASK; if ( - (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) && + (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) || (ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0) ) { if (time != 0 && time != 127 && !(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 7)) time--; ride->station_depart[stationIndex] = time; + ride_invalidate_station_start(ride, stationIndex, 0); } else { if (time == 0) { ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; + ride_invalidate_station_start(ride, stationIndex, 1); } else { if (time != 127 && !(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 31)) time--; ride->station_depart[stationIndex] = time; + ride_invalidate_station_start(ride, stationIndex, 0); } } } @@ -175,7 +179,10 @@ static void ride_update_station_race(rct_ride *ride, int stationIndex) ride->status == RIDE_STATUS_CLOSED || (ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) ) { - ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG){ + ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + ride_invalidate_station_start(ride, stationIndex, 0); + } return; } @@ -193,7 +200,10 @@ static void ride_update_station_race(rct_ride *ride, int stationIndex) // Race is over ride->lifecycle_flags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; - ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG){ + ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + ride_invalidate_station_start(ride, stationIndex, 0); + } return; } } @@ -205,7 +215,10 @@ static void ride_update_station_race(rct_ride *ride, int stationIndex) for (i = 0; i < ride->num_vehicles; i++) { vehicle = &(g_sprite_list[ride->vehicles[i]].vehicle); if (vehicle->status != VEHICLE_STATUS_WAITING_TO_DEPART && vehicle->status != VEHICLE_STATUS_DEPARTING) { - ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + if (ride->station_depart[stationIndex] & STATION_DEPART_FLAG){ + ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG; + ride_invalidate_station_start(ride, stationIndex, 0); + } return; } } @@ -213,7 +226,10 @@ static void ride_update_station_race(rct_ride *ride, int stationIndex) // Begin the race ride_race_init_vehicle_speeds(ride); ride->lifecycle_flags |= RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; - ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; + if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG)){ + ride->station_depart[stationIndex] |= STATION_DEPART_FLAG; + ride_invalidate_station_start(ride, stationIndex, 1); + } ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAIN | RIDE_INVALIDATE_RIDE_LIST; } } From 0e041899512cb5f50061a858425d46cc56021279 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 26 Mar 2015 22:08:56 +0000 Subject: [PATCH 08/12] Fix potential future bug --- src/world/map_animation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/world/map_animation.c b/src/world/map_animation.c index 9ac1eee941..282cad529c 100644 --- a/src/world/map_animation.c +++ b/src/world/map_animation.c @@ -55,7 +55,8 @@ void map_animation_create(int type, int x, int y, int z) continue; if (aobj->baseZ != z) continue; - + if (aobj->type != type) + continue; // Animation already exists return; } From bba61bd8911772394d5a73dd106dc03be9b275aa Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 27 Mar 2015 08:47:47 +0000 Subject: [PATCH 09/12] Fix on ride photos staying flashed --- src/world/map_animation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/map_animation.c b/src/world/map_animation.c index 282cad529c..b481cb0029 100644 --- a/src/world/map_animation.c +++ b/src/world/map_animation.c @@ -83,7 +83,7 @@ void map_animation_invalidate_all() RCT2_GLOBAL(0x0138B580, uint16)--; numAnimatedObjects--; if (numAnimatedObjects > 0) - memmove(aobj, aobj + 1, numAnimatedObjects); + memmove(aobj, aobj + 1, numAnimatedObjects * sizeof(rct_map_animation)); } else { numAnimatedObjects--; aobj++; From ac23ef2787b46052b190f031a86201fa404775fe Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 28 Mar 2015 12:42:09 +0000 Subject: [PATCH 10/12] Research now resets funding when all rides finished. New string to indicate reasearch complete --- data/language/english_uk.txt | 2 +- src/management/research.c | 4 +- src/management/research.h | 3 +- src/ride/ride.c | 5 +-- src/windows/finances.c | 5 ++- src/windows/new_ride.c | 76 ++++++++++++++++++++-------------- src/windows/research.c | 79 +++++++++++++++++++++--------------- 7 files changed, 105 insertions(+), 69 deletions(-) diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index 787a3012ae..f14ec5dee5 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -2682,7 +2682,7 @@ STR_2676 :??? STR_2677 :??? STR_2678 :??? STR_2679 :??? -STR_2680 :??? +STR_2680 :All research complete STR_2681 :{MEDIUMFONT}{BLACK}Increases your money by 5,000 STR_2682 :{MEDIUMFONT}{BLACK}Toggle between Free and Paid Entry STR_2683 :{MEDIUMFONT}{BLACK}Increases every peeps happiness to max diff --git a/src/management/research.c b/src/management/research.c index 94436bab4a..f6413c5411 100644 --- a/src/management/research.c +++ b/src/management/research.c @@ -128,8 +128,10 @@ static void research_next_design() continue; } else { RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS, uint16) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) = RESEARCH_STAGE_INITIAL_RESEARCH; + RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) = RESEARCH_STAGE_FINISHED_ALL; research_invalidate_related_windows(); + // Reset funding to 0 if no more rides. + research_set_funding(0); return; } } else if (ignoreActiveResearchTypes || (activeResearchTypes & (1 << researchItem->category))) { diff --git a/src/management/research.h b/src/management/research.h index b62d84d4de..4ced61a8e4 100644 --- a/src/management/research.h +++ b/src/management/research.h @@ -44,7 +44,8 @@ enum { RESEARCH_STAGE_INITIAL_RESEARCH, RESEARCH_STAGE_DESIGNING, RESEARCH_STAGE_COMPLETING_DESIGN, - RESEARCH_STAGE_UNKNOWN + RESEARCH_STAGE_UNKNOWN, + RESEARCH_STAGE_FINISHED_ALL }; extern rct_research_item *gResearchItems; diff --git a/src/ride/ride.c b/src/ride/ride.c index 328a4ab704..d6aea2f4b7 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -1083,9 +1083,8 @@ void ride_update_all() rct_ride *ride; int i; - // Remove all rides if certain flags are set (possible scenario editor?) - int *esi = (int*)0x9DCE9E; - if (esi[0x1BCA] & 2) { + // Remove all rides if scenario editor + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) { if (s6Info->var_000 <= 2) FOR_ALL_RIDES(i, ride) ride->type = RIDE_TYPE_NULL; diff --git a/src/windows/finances.c b/src/windows/finances.c index fc47d3aefa..be5720f211 100644 --- a/src/windows/finances.c +++ b/src/windows/finances.c @@ -1430,7 +1430,10 @@ static void window_finances_research_invalidate() } window_finances_set_pressed_tab(w); - + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) == RESEARCH_STAGE_FINISHED_ALL) { + window_finances_research_widgets[WIDX_RESEARCH_FUNDING].type = WWT_EMPTY; + window_finances_research_widgets[WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON].type = WWT_EMPTY; + } int currentResearchLevel = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8); // Current funding diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index a4a3ab51b6..e234a19fcb 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -22,6 +22,7 @@ #include "../audio/audio.h" #include "../game.h" #include "../management/news_item.h" +#include "../management/research.h" #include "../ride/ride.h" #include "../localisation/localisation.h" #include "../world/scenery.h" @@ -759,43 +760,58 @@ static void window_new_ride_paint() int x = w->x + 10; int y = w->y + window_new_ride_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].top + 12; + rct_string_id stringId; - // Research type - rct_string_id stringId = STR_RESEARCH_UNKNOWN; - if (RCT2_GLOBAL(0x01357CF3, uint8) != 0) { - stringId = STR_TRANSPORT_RIDE + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_CATEGORY, uint8); - if (RCT2_GLOBAL(0x01357CF3, uint8) != 1) { - uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_ITEM, uint32); - if (typeId >= 0x10000) { - rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); - stringId = rideEntry->var_008 & 0x1000 ? - rideEntry->name : - (typeId & 0xFF00) + 2; - } else { - stringId = g_scenerySetEntries[typeId]->name; + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) == RESEARCH_STAGE_FINISHED_ALL){ + stringId = STR_RESEARCH_UNKNOWN; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); + y += 25; + // Progress + stringId = 2680; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); + y += 15; + + RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; + gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); + } + else{ + // Research type + stringId = STR_RESEARCH_UNKNOWN; + if (RCT2_GLOBAL(0x01357CF3, uint8) != 0) { + stringId = STR_TRANSPORT_RIDE + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_CATEGORY, uint8); + if (RCT2_GLOBAL(0x01357CF3, uint8) != 1) { + uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_ITEM, uint32); + if (typeId >= 0x10000) { + rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); + stringId = rideEntry->var_008 & 0x1000 ? + rideEntry->name : + (typeId & 0xFF00) + 2; + } + else { + stringId = g_scenerySetEntries[typeId]->name; + } } } - } - gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); - y += 25; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); + y += 25; - // Progress - stringId = 2285 + RCT2_GLOBAL(0x01357CF3, uint8); - gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); - y += 15; + // Progress + stringId = 2285 + RCT2_GLOBAL(0x01357CF3, uint8); + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); + y += 15; - // Expected - RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; - if (RCT2_GLOBAL(0x01357CF3, uint8) != 0) { - uint16 expectedDay = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY, uint8); - if (expectedDay != 255) { - RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_DATE_DAY_1 + expectedDay; - RCT2_GLOBAL(0x013CE952 + 4, uint16) = STR_MONTH_MARCH + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH, uint8); - RCT2_GLOBAL(0x013CE952, uint16) = 2289; + // Expected + RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; + if (RCT2_GLOBAL(0x01357CF3, uint8) != 0) { + uint16 expectedDay = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY, uint8); + if (expectedDay != 255) { + RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_DATE_DAY_1 + expectedDay; + RCT2_GLOBAL(0x013CE952 + 4, uint16) = STR_MONTH_MARCH + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH, uint8); + RCT2_GLOBAL(0x013CE952, uint16) = 2289; + } } + gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); } - gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); - // Last development x = w->x + 10; y = w->y + window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_GROUP].top + 12; diff --git a/src/windows/research.c b/src/windows/research.c index 9fc9f5c9da..0b2dd9d9bd 100644 --- a/src/windows/research.c +++ b/src/windows/research.c @@ -339,42 +339,56 @@ static void window_research_development_paint() x = w->x + 10; y = w->y + window_research_development_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].top + 12; - // Research type - stringId = STR_RESEARCH_UNKNOWN; - if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 0) { - stringId = STR_TRANSPORT_RIDE + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_CATEGORY, uint8); - if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 1) { - uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_ITEM, uint32); - if (typeId >= 0x10000) { - rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); - stringId = rideEntry->var_008 & 0x1000 ? - rideEntry->name : - ((typeId >> 8) & 0xFF) + 2; - } else { - stringId = g_scenerySetEntries[typeId]->name; + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) == RESEARCH_STAGE_FINISHED_ALL){ + stringId = STR_RESEARCH_UNKNOWN; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); + y += 25; + // Progress + stringId = 2680; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); + y += 15; + + RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; + gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); + } + else{ + // Research type + stringId = STR_RESEARCH_UNKNOWN; + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 0) { + stringId = STR_TRANSPORT_RIDE + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_CATEGORY, uint8); + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 1) { + uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_ITEM, uint32); + if (typeId >= 0x10000) { + rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); + stringId = rideEntry->var_008 & 0x1000 ? + rideEntry->name : + ((typeId >> 8) & 0xFF) + 2; + } + else { + stringId = g_scenerySetEntries[typeId]->name; + } } } - } - gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); - y += 25; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); + y += 25; - // Progress - stringId = 2285 + RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8); - gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); - y += 15; + // Progress + stringId = 2285 + RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8); + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); + y += 15; - // Expected - RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; - if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 0) { - uint16 expectedDay = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY, uint8); - if (expectedDay != 255) { - RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_DATE_DAY_1 + expectedDay; - RCT2_GLOBAL(0x013CE952 + 4, uint16) = STR_MONTH_MARCH + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH, uint8); - RCT2_GLOBAL(0x013CE952, uint16) = 2289; + // Expected + RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 0) { + uint16 expectedDay = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY, uint8); + if (expectedDay != 255) { + RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_DATE_DAY_1 + expectedDay; + RCT2_GLOBAL(0x013CE952 + 4, uint16) = STR_MONTH_MARCH + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH, uint8); + RCT2_GLOBAL(0x013CE952, uint16) = 2289; + } } + gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); } - gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); - // Last development x = w->x + 10; y = w->y + window_research_development_widgets[WIDX_LAST_DEVELOPMENT_GROUP].top + 12; @@ -515,8 +529,9 @@ static void window_research_funding_invalidate() window_research_set_pressed_tab(w); - if ((RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { - window_research_funding_widgets[WIDX_FUNDING_GROUP].type = WWT_EMPTY; + if ((RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) || + (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) == RESEARCH_STAGE_FINISHED_ALL)) { + //window_research_funding_widgets[WIDX_FUNDING_GROUP].type = WWT_EMPTY; window_research_funding_widgets[WIDX_RESEARCH_FUNDING].type = WWT_EMPTY; window_research_funding_widgets[WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON].type = WWT_EMPTY; } else { From ab038f434187779d51c333ae4f63f12cda45dcee Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 28 Mar 2015 13:37:43 +0000 Subject: [PATCH 11/12] Fix right click when track place is on --- src/windows/track_place.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/windows/track_place.c b/src/windows/track_place.c index 785cc66364..1023196bae 100644 --- a/src/windows/track_place.c +++ b/src/windows/track_place.c @@ -395,7 +395,7 @@ void window_track_place_open() w->colours[1] = 24; w->colours[2] = 24; tool_set(w, 6, 12); - RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) |= 6; + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) |= INPUT_FLAG_6; window_push_others_right(w); show_gridlines(); _window_track_place_last_cost = MONEY32_UNDEFINED; From 2248e8623db3da19483e8648471a4fdf8e7c5dee Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sat, 28 Mar 2015 17:20:19 +0000 Subject: [PATCH 12/12] fix cheat window tab images --- src/windows/cheats.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/windows/cheats.c b/src/windows/cheats.c index 4c9fb86647..a2008b9a58 100644 --- a/src/windows/cheats.c +++ b/src/windows/cheats.c @@ -715,13 +715,15 @@ static void window_cheats_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w) // Misc tab if (!(w->disabled_widgets & (1 << WIDX_TAB_3))) { - sprite_idx = SPR_TAB_QUESTION; + sprite_idx = STR_TAB_PARK; gfx_draw_sprite(dpi, sprite_idx, w->x + w->widgets[WIDX_TAB_3].left, w->y + w->widgets[WIDX_TAB_3].top, 0); } // Rides tab if (!(w->disabled_widgets & (1 << WIDX_TAB_4))) { - sprite_idx = SPR_RIDE; + sprite_idx = SPR_TAB_RIDE_0; + if (w->page == WINDOW_CHEATS_PAGE_RIDES) + sprite_idx += (w->frame_no / 4) % 16; gfx_draw_sprite(dpi, sprite_idx, w->x + w->widgets[WIDX_TAB_4].left, w->y + w->widgets[WIDX_TAB_4].top, 0); } } @@ -729,6 +731,7 @@ static void window_cheats_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w) static void window_cheats_set_page(rct_window *w, int page) { w->page = page; + w->frame_no = 0; w->enabled_widgets = window_cheats_page_enabled_widgets[page];