From d5ff2f27818fc35023fa25ffcce274db906db6f9 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 1 May 2014 13:16:41 +0200 Subject: [PATCH] Fix finding peep on ride news items Peep's current_* variables were offset by 1. Also fixed comparison between 32-bit and 16-bit ints. --- src/news_item.c | 6 ++++-- src/peep.h | 8 +++++--- src/window_game_bottom_toolbar.c | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index 42ba491aee..f23bdf7408 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -200,7 +200,7 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * *x = sprite->unknown.x; *y = sprite->unknown.y; *z = sprite->unknown.z; - if (*x != SPRITE_LOCATION_NULL) + if (*((uint16*)x) != SPRITE_LOCATION_NULL) break; if (sprite->peep.state != 3 && sprite->peep.state != 7) { @@ -208,8 +208,10 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * break; } + // Find which ride peep is on ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[sprite->peep.current_ride]); - if (ride->var_1D0 & 1) { + // Check if there are trains on the track (first bit of var_1D0) + if (!(ride->var_1D0 & 1)) { *x = SPRITE_LOCATION_NULL; break; } diff --git a/src/peep.h b/src/peep.h index b2574bec2b..40beea32d5 100644 --- a/src/peep.h +++ b/src/peep.h @@ -72,9 +72,11 @@ typedef struct { uint8 happiness; // 0x3A uint8 pad_03B[0x2D]; uint8 current_ride; // 0x68 - uint8 current_train; // 0x6A - uint8 current_car; // 0x6B - uint8 pad_6C[0x30]; + uint8 pad_6a; // 0x6A Part of current_ride? + uint8 current_train; // 0x6B + uint8 current_car; // 0x6c + uint8 current_seat; // 0x6d + uint8 pad_6C[0x2e]; uint32 id; // 0x9C uint8 pad_A0[0x10]; rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index d24152414d..721b189ee6 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -185,7 +185,7 @@ static void window_game_bottom_toolbar_mouseup() news_item_get_subject_location(newsItem->type, subject, &x, &y, &z); - if (x == SPRITE_LOCATION_NULL) + if ((uint16)x == SPRITE_LOCATION_NULL) break; if ((mainWindow = window_get_main()) != NULL)