diff --git a/src/addresses.h b/src/addresses.h index 347adaccfd..403ec3f966 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -121,7 +121,7 @@ #define RCT2_ADDRESS_G1_ELEMENTS 0x009EBD28 #define RCT2_ADDRESS_CURRENT_MONTH_YEAR 0x00F663A8 -#define RCT2_ADDRESS_CURRENT_DAY 0x00F663AA +#define RCT2_ADDRESS_CURRENT_MONTH_TICKS 0x00F663AA #define RCT2_ADDRESS_MAP_ELEMENTS 0x00F663B8 diff --git a/src/date.c b/src/date.c index e44d32c86e..11c7855ac1 100644 --- a/src/date.c +++ b/src/date.c @@ -48,6 +48,6 @@ int date_get_total_months(int month, int year) void date_reset() { RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) = MONTH_MARCH; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_DAY, sint16) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, sint16) = 0; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, sint32) = 0; } diff --git a/src/news_item.c b/src/news_item.c index 71067660fb..f09f7f19c8 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -174,7 +174,8 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * { int i; rct_ride *ride; - rct_sprite *sprite, *sprite_2; + rct_peep *peep; + rct_car *car; switch (type) { case NEWS_ITEM_RIDE: @@ -195,37 +196,41 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * *z = edx; } break; - case NEWS_ITEM_PEEP_1: - sprite = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); - *x = sprite->unknown.x; - *y = sprite->unknown.y; - *z = sprite->unknown.z; - if (*x != SPRITE_LOCATION_NULL) + case NEWS_ITEM_PEEP_ON_RIDE: + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); + *x = peep->x; + *y = peep->y; + *z = peep->z; + if (*((uint16*)x) != SPRITE_LOCATION_NULL) break; - if (sprite->peep.state != 3 && sprite->peep.state != 7) { + if (peep->state != 3 && peep->state != 7) { *x = SPRITE_LOCATION_NULL; break; } - ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[sprite->peep.current_ride]); - if (ride->var_1D0 & 1) { + // Find which ride peep is on + ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[peep->current_ride]); + // Check if there are trains on the track (first bit of var_1D0) + if (!(ride->var_1D0 & 1)) { *x = SPRITE_LOCATION_NULL; break; } - sprite_2 = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->var_086[sprite->peep.var_6A]]); - for (i = 0; i < sprite->peep.var_6B; i++) - sprite_2 = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[*((uint16*)&sprite_2->pad_00[0x3E])]); - *x = sprite_2->unknown.x; - *y = sprite_2->unknown.y; - *z = sprite_2->unknown.z; + // Find the first car of the train peep is on + car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->train_car_map[peep->current_train]]); + // Find the actual car peep is on + for (i = 0; i < peep->current_car; i++) + car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[car->next_car]); + *x = car->x; + *y = car->y; + *z = car->z; break; - case NEWS_ITEM_PEEP_2: - sprite = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); - *x = sprite->unknown.x; - *y = sprite->unknown.y; - *z = sprite->unknown.z; + case NEWS_ITEM_PEEP: + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); + *x = peep->x; + *y = peep->y; + *z = peep->z; break; case NEWS_ITEM_BLANK: { diff --git a/src/news_item.h b/src/news_item.h index 547b85e293..be8dd55e42 100644 --- a/src/news_item.h +++ b/src/news_item.h @@ -26,8 +26,8 @@ enum { NEWS_ITEM_NULL, NEWS_ITEM_RIDE, - NEWS_ITEM_PEEP_1, - NEWS_ITEM_PEEP_2, + NEWS_ITEM_PEEP_ON_RIDE, + NEWS_ITEM_PEEP, NEWS_ITEM_MONEY, NEWS_ITEM_BLANK, NEWS_ITEM_SCENERY, diff --git a/src/peep.h b/src/peep.h index a13e7b2894..c55273febf 100644 --- a/src/peep.h +++ b/src/peep.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 Ted John + * Copyright (c) 2014 Ted John, Peter Hill * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. @@ -62,7 +62,10 @@ typedef struct { uint8 pad_09; sint16 var_0A; uint16 var_0C; - uint8 var_0E[0x14]; + sint16 x; // 0x0E + sint16 y; // 0x10 + sint16 z; // 0x12 + uint8 pad_14[0x0E]; uint16 name_string_idx; // 0x22 uint16 next_x; // 0x24 uint16 next_y; // 0x26 @@ -79,9 +82,11 @@ typedef struct { uint8 happiness; // 0x3A uint8 pad_03B[0x2D]; uint8 current_ride; // 0x68 - uint8 var_6A; - uint8 var_6B; - 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/ride.h b/src/ride.h index 8d7294bfd3..d7a251dbeb 100644 --- a/src/ride.h +++ b/src/ride.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 Ted John + * Copyright (c) 2014 Ted John, Peter Hill * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. @@ -38,7 +38,7 @@ typedef struct { uint8 pad_052[0x18]; uint16 var_06A[4]; // probably entrance map coordinates uint8 pad_072[0x14]; - uint16 var_086[1]; + uint16 train_car_map[1]; // 0x86 Points to the first car in the train uint8 pad_088[0x68]; sint16 excitement; // 0x0F0 sint16 intensity; // 0x0F2 diff --git a/src/sprite.h b/src/sprite.h index eea99b11b3..5a3a071ba0 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 Ted John + * Copyright (c) 2014 Ted John, Peter Hill * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. @@ -46,6 +46,16 @@ typedef struct { sint32 var_24; } rct_litter; +typedef struct { + uint8 sprite_idetifier; // 0x00 + uint8 pad_01[0x0D]; + sint16 x; // 0x0E + sint16 y; // 0x10 + sint16 z; // 0x12 + uint8 pad_14[0x2a]; + uint16 next_car; // 0x3E +} rct_car; + /** * Sprite structure. * size: 0x0100 @@ -55,6 +65,7 @@ typedef union { rct_unk_sprite unknown; rct_peep peep; rct_litter litter; + rct_car car; } rct_sprite; #endif diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 2b5f31f644..389a36e6bc 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -20,7 +20,6 @@ #include "addresses.h" #include "climate.h" -#include "date.h" #include "news_item.h" #include "park.h" #include "peep.h" @@ -186,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) @@ -222,7 +221,7 @@ static void window_game_bottom_toolbar_tooltip() break; case WIDX_DATE: month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7; - day = ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_DAY, sint16) * days_in_month[month]) >> 16) & 0xFF; + day = ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, sint16) * ((short*)0x00993988)[month]) >> 16) & 0xFF; *((short*)0x013CE952) = STR_DATE_DAY_1 + day; *((short*)0x013CE954) = STR_MONTH_MARCH + month; widgetIndex = 0; @@ -534,8 +533,8 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc case NEWS_ITEM_RIDE: gfx_draw_sprite(dpi, SPR_RIDE, x, y); break; - case NEWS_ITEM_PEEP_1: - case NEWS_ITEM_PEEP_2: + case NEWS_ITEM_PEEP_ON_RIDE: + case NEWS_ITEM_PEEP: if (newsItem->flags & 1) break; diff --git a/src/window_park.c b/src/window_park.c index 5decd55290..7474a6f3d2 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -2029,7 +2029,7 @@ static void window_park_graph_draw_months(rct_drawpixelinfo *dpi, uint8 *history int i, x, y, yearOver32, currentMonth, currentDay; currentMonth = date_get_month(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16)); - currentDay = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_DAY, uint16); + currentDay = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16); yearOver32 = (currentMonth * 4) + (currentDay >> 14) - 31; x = baseX; y = baseY;