From c6c796ab065fe6bd6df469a7a40f25cab4f8f27b Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 25 Mar 2015 11:14:31 +0000 Subject: [PATCH] fix invalid park stats information when paused, fixes #957 --- src/interface/window.c | 48 +++++++++++++++++++++++------------------- src/interface/window.h | 1 + src/windows/park.c | 7 +++--- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/interface/window.c b/src/interface/window.c index 7613b0872a..a835793099 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -128,27 +128,7 @@ rct_widget *window_get_scroll_widget(rct_window *w, int scrollIndex) return NULL; } -static void RCT2_CALLPROC_WE_UPDATE(int address, rct_window* w) -{ - #ifdef _MSC_VER - __asm { - push address - push w - mov esi, w - call[esp + 4] - add esp, 8 - } - #else - __asm__ ( "\ - push %[address]\n\ - mov eax, %[w] \n\ - push eax \n\ - mov esi, %[w] \n\ - call [esp+4] \n\ - add esp, 8 \n\ - " : [address] "+m" (address), [w] "+m" (w) : : "eax", "esi" ); - #endif -} + /** * * rct2: 0x006ED7B0 @@ -160,7 +140,7 @@ void window_dispatch_update_all() RCT2_GLOBAL(0x01423604, sint32)++; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, sint16)++; for (w = RCT2_LAST_WINDOW; w >= g_window_list; w--) - RCT2_CALLPROC_WE_UPDATE(w->event_handlers[WE_UPDATE], w); + window_event_update_call(w); RCT2_CALLPROC_EBPSAFE(0x006EE411); // handle_text_input } @@ -1691,6 +1671,30 @@ void window_event_invalidate_call(rct_window* w) RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); } +void window_event_update_call(rct_window *w) +{ + int address = w->event_handlers[WE_UPDATE]; + + #ifdef _MSC_VER + __asm { + push address + push w + mov esi, w + call[esp + 4] + add esp, 8 + } + #else + __asm__ ( "\ + push %[address]\n\ + mov eax, %[w] \n\ + push eax \n\ + mov esi, %[w] \n\ + call [esp+4] \n\ + add esp, 8 \n\ + " : [address] "+m" (address), [w] "+m" (w) : : "eax", "esi" ); + #endif +} + /** * rct2: New function not from rct2 * Bubbles an item one position up in the window list. diff --git a/src/interface/window.h b/src/interface/window.h index a8f5320061..b586ea933c 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -579,6 +579,7 @@ void window_event_mouse_up_call(rct_window* w, int widgetIndex); void window_event_resize_call(rct_window* w); void window_event_mouse_down_call(rct_window* w, int widgetIndex); void window_event_invalidate_call(rct_window* w); +void window_event_update_call(rct_window *w); void sub_6EA73F(); diff --git a/src/windows/park.c b/src/windows/park.c index 1bb0664ffc..1f3cba798f 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -1568,7 +1568,7 @@ static void window_park_stats_paint() y += 10; // Draw number of rides / attractions - if (w->list_information_type != -1) { + if (w->list_information_type != (uint16)-1) { RCT2_GLOBAL(0x013CE952, uint32) = w->list_information_type; gfx_draw_string_left(dpi, STR_NUMBER_OF_RIDES_LABEL, (void*)0x013CE952, 0, x, y); } @@ -1941,8 +1941,9 @@ static void window_park_set_page(rct_window *w, int page) window_park_set_disabled_tabs(w); window_invalidate(w); - RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0); - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); + window_event_resize_call(w); + window_event_invalidate_call(w); + window_event_update_call(w); if (listen != 0 && w->viewport != NULL) w->viewport->flags |= VIEWPORT_FLAG_SOUND_ON; }