Skip to content

Instantly share code, notes, and snippets.

@w-flo
Created April 11, 2019 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save w-flo/f2699cb0ad94adb95595b63fa59013b7 to your computer and use it in GitHub Desktop.
Save w-flo/f2699cb0ad94adb95595b63fa59013b7 to your computer and use it in GitHub Desktop.
Dirty fix for OpenRCT2 failed assertion #5893 https://github.com/OpenRCT2/OpenRCT2/issues/5893 Assertion failed: (w->widgets[i].type != WWT_LAST)
diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp
index b294806ba..148e94c36 100644
--- a/src/openrct2/interface/Window.cpp
+++ b/src/openrct2/interface/Window.cpp
@@ -1773,6 +1773,11 @@ void window_align_tabs(rct_window* w, rct_widgetindex start_tab_id, rct_widgetin
}
}
+int32_t window_get_current_tab(rct_window* w)
+{
+ return w->page;
+}
+
/**
*
* rct2: 0x006CBCC3
diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h
index 6835f620c..ee2e1f4aa 100644
--- a/src/openrct2/interface/Window.h
+++ b/src/openrct2/interface/Window.h
@@ -671,6 +671,7 @@ void ride_construction_tooldown_construct(int32_t screenX, int32_t screenY);
void window_bubble_list_item(rct_window* w, int32_t item_position);
void window_align_tabs(rct_window* w, rct_widgetindex start_tab_id, rct_widgetindex end_tab_id);
+int32_t window_get_current_tab(rct_window* w);
void window_staff_list_init_vars();
diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp
index e952c3ada..f1af3c45c 100644
--- a/src/openrct2/peep/Guest.cpp
+++ b/src/openrct2/peep/Guest.cpp
@@ -38,6 +38,8 @@
#include <algorithm>
#include <iterator>
+#define WINDOW_GUEST_OVERVIEW 0
+
// Locations of the spiral slide platform that a peep walks from the entrance of the ride to the
// entrance of the slide. Up to 4 waypoints for each 4 sides that an ride entrance can be located
// and 4 different rotations of the ride. 4 * 4 * 4 = 64 locations.
@@ -1487,7 +1489,7 @@ void Guest::OnExitRide(ride_id_t rideIndex)
peep_reset_pathfind_goal(this);
rct_window* w = window_find_by_number(WC_PEEP, sprite_index);
- if (w != nullptr)
+ if (w != nullptr && window_get_current_tab(w) == WINDOW_GUEST_OVERVIEW)
{
window_event_invalidate_call(w);
widget_invalidate(w, WC_PEEP__WIDX_ACTION_LBL);
@@ -1553,7 +1555,7 @@ void Guest::PickRideToGoOn()
// Invalidate windows
auto w = window_find_by_number(WC_PEEP, sprite_index);
- if (w != nullptr)
+ if (w != nullptr && window_get_current_tab(w) == WINDOW_GUEST_OVERVIEW)
{
window_event_invalidate_call(w);
widget_invalidate(w, WC_PEEP__WIDX_ACTION_LBL);
@@ -2137,7 +2139,7 @@ static void peep_reset_ride_heading(Peep* peep)
peep->guest_heading_to_ride_id = RIDE_ID_NULL;
w = window_find_by_number(WC_PEEP, peep->sprite_index);
- if (w != nullptr)
+ if (w != nullptr && window_get_current_tab(w) == WINDOW_GUEST_OVERVIEW)
{
window_event_invalidate_call(w);
widget_invalidate(w, WC_PEEP__WIDX_ACTION_LBL);
@@ -2959,7 +2961,7 @@ static void peep_head_for_nearest_ride_type(Guest* peep, int32_t rideType)
// Invalidate windows
rct_window* w = window_find_by_number(WC_PEEP, peep->sprite_index);
- if (w != nullptr)
+ if (w != nullptr && window_get_current_tab(w) == WINDOW_GUEST_OVERVIEW)
{
window_event_invalidate_call(w);
widget_invalidate(w, WC_PEEP__WIDX_ACTION_LBL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment