From 8c28dbaaeffc1cf55f7c097daa96e5ea478f0cf0 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 1 May 2014 09:18:29 +0200 Subject: [PATCH 1/7] Name peep variables for current train and car --- src/news_item.c | 8 +++++--- src/peep.h | 4 ++-- src/ride.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index 71067660fb..42ba491aee 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -214,9 +214,11 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * 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])]); + // Find the train peep is on + sprite_2 = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->train_car_map[sprite->peep.current_train]]); + // Find the car peep is on + for (i = 0; i < sprite->peep.current_car; 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; diff --git a/src/peep.h b/src/peep.h index 335cbedf0b..b2574bec2b 100644 --- a/src/peep.h +++ b/src/peep.h @@ -72,8 +72,8 @@ typedef struct { uint8 happiness; // 0x3A uint8 pad_03B[0x2D]; uint8 current_ride; // 0x68 - uint8 var_6A; - uint8 var_6B; + uint8 current_train; // 0x6A + uint8 current_car; // 0x6B uint8 pad_6C[0x30]; uint32 id; // 0x9C uint8 pad_A0[0x10]; diff --git a/src/ride.h b/src/ride.h index 8d7294bfd3..ff90abd0e8 100644 --- a/src/ride.h +++ b/src/ride.h @@ -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 From d5ff2f27818fc35023fa25ffcce274db906db6f9 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 1 May 2014 13:16:41 +0200 Subject: [PATCH 2/7] 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) From 6c550cbdd65f799c7ceb1183f7b4e57fe4ac79a1 Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 1 May 2014 13:23:18 +0200 Subject: [PATCH 3/7] Change peep news item enum names --- src/news_item.c | 4 ++-- src/news_item.h | 4 ++-- src/window_game_bottom_toolbar.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index f23bdf7408..bbb0be3386 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -195,7 +195,7 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * *z = edx; } break; - case NEWS_ITEM_PEEP_1: + case NEWS_ITEM_PEEP_ON_RIDE: sprite = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); *x = sprite->unknown.x; *y = sprite->unknown.y; @@ -225,7 +225,7 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * *y = sprite_2->unknown.y; *z = sprite_2->unknown.z; break; - case NEWS_ITEM_PEEP_2: + case NEWS_ITEM_PEEP: sprite = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); *x = sprite->unknown.x; *y = sprite->unknown.y; 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/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 721b189ee6..2df493d1da 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -533,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; From 63df868422c9744fd6d4536316712051a3513b5e Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 1 May 2014 14:02:28 +0200 Subject: [PATCH 4/7] Add rct_car sprite and tidy up news locator Also add (x,y,z) coordinate variables for rct_peep --- src/news_item.c | 35 ++++++++++++++++++----------------- src/peep.h | 5 ++++- src/sprite.h | 11 +++++++++++ 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index bbb0be3386..0ddf9aa137 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: @@ -196,20 +197,20 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * } break; case NEWS_ITEM_PEEP_ON_RIDE: - sprite = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); - *x = sprite->unknown.x; - *y = sprite->unknown.y; - *z = sprite->unknown.z; + 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; } // Find which ride peep is on - ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[sprite->peep.current_ride]); + 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; @@ -217,19 +218,19 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * } // Find the train peep is on - sprite_2 = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->train_car_map[sprite->peep.current_train]]); + car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->train_car_map[peep->current_train]]); // Find the car peep is on - for (i = 0; i < sprite->peep.current_car; 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; + 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: - sprite = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); - *x = sprite->unknown.x; - *y = sprite->unknown.y; - *z = sprite->unknown.z; + 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/peep.h b/src/peep.h index 40beea32d5..2e071d3c1e 100644 --- a/src/peep.h +++ b/src/peep.h @@ -55,7 +55,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 diff --git a/src/sprite.h b/src/sprite.h index eea99b11b3..57efead6cb 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -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 From a5c85f0cbecfd8c4a14baaef91a086fb2ec5490e Mon Sep 17 00:00:00 2001 From: ZedThree Date: Thu, 1 May 2014 14:12:30 +0200 Subject: [PATCH 5/7] Fix comments --- src/news_item.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index 0ddf9aa137..f09f7f19c8 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -217,9 +217,9 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * break; } - // Find the train peep is on + // 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 car peep is on + // 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; From ae637f62913ef9d8491a52730fc25a92c7579d8f Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 1 May 2014 14:13:31 +0100 Subject: [PATCH 6/7] fix case and add author to source code header --- src/peep.h | 4 ++-- src/ride.h | 2 +- src/sprite.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/peep.h b/src/peep.h index 2e071d3c1e..62f8b75602 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. @@ -77,7 +77,7 @@ typedef struct { uint8 current_ride; // 0x68 uint8 pad_6a; // 0x6A Part of current_ride? uint8 current_train; // 0x6B - uint8 current_car; // 0x6c + uint8 current_car; // 0x6C uint8 current_seat; // 0x6d uint8 pad_6C[0x2e]; uint32 id; // 0x9C diff --git a/src/ride.h b/src/ride.h index ff90abd0e8..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. diff --git a/src/sprite.h b/src/sprite.h index 57efead6cb..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. From c788f36787b2e3198b9c34f77dcb3c1724c2a5f3 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 1 May 2014 15:07:51 +0100 Subject: [PATCH 7/7] rename current day to current month ticks --- src/addresses.h | 2 +- src/date.c | 2 +- src/window_game_bottom_toolbar.c | 2 +- src/window_park.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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 012e556327..335aac73f4 100644 --- a/src/date.c +++ b/src/date.c @@ -44,6 +44,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/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 2df493d1da..389a36e6bc 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -221,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) * ((short*)0x00993988)[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; 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;