From 16b552270b87a15446ff6d88696560a5b6fcd554 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 24 Aug 2014 23:02:19 +0100 Subject: [PATCH] add rct_ride_type structure --- src/award.c | 34 +++++++++++++------------- src/ride.c | 1 + src/ride.h | 24 +++++++++++++++++++ src/ride_ratings.c | 15 ++++-------- src/scenario.c | 15 +++++------- src/window_new_campaign.c | 4 ++-- src/window_new_ride.c | 50 ++++++++++++++++++--------------------- src/window_research.c | 19 +++++++-------- 8 files changed, 87 insertions(+), 75 deletions(-) diff --git a/src/award.c b/src/award.c index 397af63a45..13b54ef5eb 100644 --- a/src/award.c +++ b/src/award.c @@ -131,12 +131,12 @@ static int award_is_deserved_best_rollercoasters(int awardType, int activeAwardT { int i, rollerCoasters; rct_ride *ride; - char *object; + rct_ride_type *rideType; rollerCoasters = 0; FOR_ALL_RIDES(i, ride) { - object = RCT2_ADDRESS(0x009ACFA4, char*)[ride->subtype]; - if (RCT2_GLOBAL(object + 0x1BE, uint8) != RIDE_GROUP_ROLLERCOASTER && RCT2_GLOBAL(object + 0x1BF, uint8) != RIDE_GROUP_ROLLERCOASTER) + rideType = gRideTypeList[ride->subtype]; + if (rideType->category[0] != RIDE_GROUP_ROLLERCOASTER && rideType->category[1] != RIDE_GROUP_ROLLERCOASTER) continue; if (ride->status != RIDE_STATUS_OPEN || (ride->lifecycle_flags & RIDE_LIFECYCLE_CRASHED)) @@ -274,7 +274,7 @@ static int award_is_deserved_best_food(int awardType, int activeAwardTypes) int i, hungryPeeps, shops, uniqueShops; uint64 shopTypes; rct_ride *ride; - char *object; + rct_ride_type *rideType; uint16 spriteIndex; rct_peep *peep; @@ -291,9 +291,9 @@ static int award_is_deserved_best_food(int awardType, int activeAwardTypes) continue; shops++; - object = RCT2_ADDRESS(0x009ACFA4, char*)[ride->subtype]; - if (!(shopTypes & (1ULL << RCT2_GLOBAL(object + 0x1C0, uint8)))) { - shopTypes |= (1ULL << RCT2_GLOBAL(object + 0x1C0, uint8)); + rideType = gRideTypeList[ride->subtype]; + if (!(shopTypes & (1ULL << rideType->shop_item))) { + shopTypes |= (1ULL << rideType->shop_item); uniqueShops++; } } @@ -320,7 +320,7 @@ static int award_is_deserved_worst_food(int awardType, int activeAwardTypes) int i, hungryPeeps, shops, uniqueShops; uint64 shopTypes; rct_ride *ride; - char *object; + rct_ride_type *rideType; uint16 spriteIndex; rct_peep *peep; @@ -337,9 +337,9 @@ static int award_is_deserved_worst_food(int awardType, int activeAwardTypes) continue; shops++; - object = RCT2_ADDRESS(0x009ACFA4, char*)[ride->subtype]; - if (!(shopTypes & (1ULL << RCT2_GLOBAL(object + 0x1C0, uint8)))) { - shopTypes |= (1ULL << RCT2_GLOBAL(object + 0x1C0, uint8)); + rideType = gRideTypeList[ride->subtype]; + if (!(shopTypes & (1ULL << rideType->shop_item))) { + shopTypes |= (1ULL << rideType->shop_item); uniqueShops++; } } @@ -430,12 +430,12 @@ static int award_is_deserved_best_water_rides(int awardType, int activeAwardType { int i, waterRides; rct_ride *ride; - char *object; + rct_ride_type *rideType; waterRides = 0; FOR_ALL_RIDES(i, ride) { - object = RCT2_ADDRESS(0x009ACFA4, char*)[ride->subtype]; - if (RCT2_GLOBAL(object + 0x1BE, uint8) != RIDE_GROUP_WATER && RCT2_GLOBAL(object + 0x1BF, uint8) != RIDE_GROUP_WATER) + rideType = gRideTypeList[ride->subtype]; + if (rideType->category[0] != RIDE_GROUP_WATER && rideType->category[1] != RIDE_GROUP_WATER) continue; if (ride->status != RIDE_STATUS_OPEN || (ride->lifecycle_flags & RIDE_LIFECYCLE_CRASHED)) @@ -522,12 +522,12 @@ static int award_is_deserved_best_gentle_rides(int awardType, int activeAwardTyp { int i, gentleRides; rct_ride *ride; - char *object; + rct_ride_type *rideType; gentleRides = 0; FOR_ALL_RIDES(i, ride) { - object = RCT2_ADDRESS(0x009ACFA4, char*)[ride->subtype]; - if (RCT2_GLOBAL(object + 0x1BE, uint8) != RIDE_GROUP_GENTLE && RCT2_GLOBAL(object + 0x1BF, uint8) != RIDE_GROUP_GENTLE) + rideType = gRideTypeList[ride->subtype]; + if (rideType->category[0] != RIDE_GROUP_GENTLE && rideType->category[1] != RIDE_GROUP_GENTLE) continue; if (ride->status != RIDE_STATUS_OPEN || (ride->lifecycle_flags & RIDE_LIFECYCLE_CRASHED)) diff --git a/src/ride.c b/src/ride.c index afb5901659..bc5ae32544 100644 --- a/src/ride.c +++ b/src/ride.c @@ -99,6 +99,7 @@ const uint8 gRideClassifications[255] = { #pragma endregion +rct_ride_type **gRideTypeList = RCT2_ADDRESS(0x009ACFA4, rct_ride_type*); rct_ride* g_ride_list = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride); int ride_get_count() diff --git a/src/ride.h b/src/ride.h index b88946dd59..77f4013831 100644 --- a/src/ride.h +++ b/src/ride.h @@ -22,6 +22,7 @@ #define _RIDE_H_ #include "rct2.h" +#include "string_ids.h" typedef fixed16_2dp ride_rating; @@ -36,6 +37,26 @@ typedef struct { ride_rating nausea; } rating_tuple; +/** + * Ride type structure. + * size: unknown + */ +typedef struct { + rct_string_id name; // 0x000 + rct_string_id description; // 0x002 + uint32 var_004; + uint32 var_008; + uint8 var_00C; + uint8 var_00D; + uint8 pad_00E[0x1A4]; + sint8 excitement_multipler; // 0x1B2 + sint8 intensity_multipler; // 0x1B3 + sint8 nausea_multipler; // 0x1B4 + uint8 pad_1B5[0x09]; + uint8 category[2]; // 0x1BE + uint8 shop_item; // 0x1C0 +} rct_ride_type; + /** * Ride structure. * size: 0x0260 @@ -334,6 +355,9 @@ enum { #define MAX_RIDE_MEASUREMENTS 8 #define RIDE_RELIABILITY_UNDEFINED 0xFFFF +// rct2: 0x009ACFA4 +rct_ride_type **gRideTypeList; + // rct2: 0x013628F8 extern rct_ride* g_ride_list; diff --git a/src/ride_ratings.c b/src/ride_ratings.c index 915c78a3e2..d18fef2753 100644 --- a/src/ride_ratings.c +++ b/src/ride_ratings.c @@ -172,17 +172,12 @@ rating_tuple per_ride_rating_adjustments(rct_ride *ride, ride_rating excitement, { // NB: The table here is allocated dynamically. Reading the exe will tell // you nothing - uint32 subtype_p = RCT2_GLOBAL(0x009ACFA4 + ride->subtype * 4, uint32); + rct_ride_type *rideType = gRideTypeList[ride->subtype]; // example value here: 12 (?) - sint16 ctr = RCT2_GLOBAL(subtype_p + 0x1b2, sint16); - excitement = excitement + ((excitement * ctr) >> 7); - - ctr = RCT2_GLOBAL(subtype_p + 0x1b3, sint16); - intensity = intensity + ((intensity * ctr) >> 7); - - ctr = RCT2_GLOBAL(subtype_p + 0x1b4, sint16); - nausea = nausea + ((nausea * ctr) >> 7); + excitement = excitement + ((excitement * rideType->excitement_multipler) >> 7); + intensity = intensity + ((intensity * rideType->intensity_multipler) >> 7); + nausea = nausea + ((nausea * rideType->nausea_multipler) >> 7); // As far as I can tell, this flag detects whether the ride is a roller // coaster, or a log flume or rapids. Everything else it's not set. @@ -190,7 +185,7 @@ rating_tuple per_ride_rating_adjustments(rct_ride *ride, ride_rating excitement, uint16 ridetype_var = RCT2_GLOBAL(0x0097D4F2 + ride->type * 8, uint16); if (ridetype_var & 0x80) { uint16 ax = ride->var_1F4; - if (RCT2_GLOBAL(subtype_p + 8, uint32) & 0x800) { + if (rideType->var_008 & 0x800) { // 65e86e ax = ax - 96; if (ax >= 0) { diff --git a/src/scenario.c b/src/scenario.c index 441d23f3e0..c566324890 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -381,12 +381,11 @@ void scenario_objective5_check() FOR_ALL_RIDES(i, ride) { uint8 subtype_id = ride->subtype; - uint32 subtype_p = RCT2_GLOBAL(0x009ACFA4 + subtype_id * 4, uint32); + rct_ride_type *rideType = gRideTypeList[subtype_id]; - if ((RCT2_GLOBAL(subtype_p + 0x1BE, sint8) == 2 || - RCT2_GLOBAL(subtype_p + 0x1BF, sint8) == 2) && + if ((rideType->category[0] == RIDE_GROUP_ROLLERCOASTER || rideType->category[1] == RIDE_GROUP_ROLLERCOASTER) && ride->status == RIDE_STATUS_OPEN && - ride->excitement >= 600 && type_already_counted[subtype_id] == 0){ + ride->excitement >= RIDE_RATING(6,00) && type_already_counted[subtype_id] == 0){ type_already_counted[subtype_id]++; rcs++; } @@ -412,12 +411,10 @@ void scenario_objective8_check() FOR_ALL_RIDES(i, ride) { uint8 subtype_id = ride->subtype; - uint32 subtype_p = RCT2_GLOBAL(0x009ACFA4 + subtype_id * 4, uint32); - - if ((RCT2_GLOBAL(subtype_p + 0x1BE, sint8) == 2 || - RCT2_GLOBAL(subtype_p + 0x1BF, sint8) == 2) && + rct_ride_type *rideType = gRideTypeList[subtype_id]; + if ((rideType->category[0] == RIDE_GROUP_ROLLERCOASTER || rideType->category[1] == RIDE_GROUP_ROLLERCOASTER) && ride->status == RIDE_STATUS_OPEN && - ride->excitement >= 600 && type_already_counted[subtype_id] == 0){ + ride->excitement >= RIDE_RATING(7,00) && type_already_counted[subtype_id] == 0){ // this calculates the length, no idea why it's done so complicated though. uint8 limit = ride->pad_088[63]; diff --git a/src/window_new_campaign.c b/src/window_new_campaign.c index 19f25f6595..16cd807000 100644 --- a/src/window_new_campaign.c +++ b/src/window_new_campaign.c @@ -200,8 +200,8 @@ static void window_new_campaign_get_shop_items() uint64 items = 0; FOR_ALL_RIDES(i, ride) { - uint8 *rideTypeInfo = RCT2_ADDRESS(0x009ACFA4, void*)[ride->subtype]; - uint8 itemType = RCT2_GLOBAL(rideTypeInfo + 0x1C0, uint8); + rct_ride_type *rideType = gRideTypeList[ride->subtype]; + uint8 itemType = rideType->shop_item; if (itemType != 255) items |= 1LL << itemType; } diff --git a/src/window_new_ride.c b/src/window_new_ride.c index 1269f7d395..296aea59ce 100644 --- a/src/window_new_ride.c +++ b/src/window_new_ride.c @@ -301,7 +301,7 @@ static void window_new_ride_populate_list() uint8 currentCategory = _window_new_ride_current_tab; ride_list_item *nextListItem = (ride_list_item*)0x00F43523; - uint8 **rideEntries = (uint8**)0x009ACFA4; + rct_ride_type **rideEntries = (rct_ride_type**)0x009ACFA4; // For each ride type in the view order list for (i = 0; i < countof(RideTypeViewOrder); i++) { @@ -325,15 +325,13 @@ static void window_new_ride_populate_list() continue; // Ride entries - uint8 *rideEntry = rideEntries[rideEntryIndex]; - uint8 categoryA = rideEntry[0x1BE]; - uint8 categoryB = rideEntry[0x1BF]; + rct_ride_type *rideEntry = rideEntries[rideEntryIndex]; // Check if ride is in this category - if (currentCategory != categoryA && currentCategory != categoryB) + if (currentCategory != rideEntry->category[0] && currentCategory != rideEntry->category[1]) continue; - if (RCT2_GLOBAL(rideEntry + 8, uint32) & 0x2000) { + if (rideEntry->var_008 & 0x2000) { dh &= ~4; nextListItem->type = rideType; nextListItem->entry_index = rideEntryIndex; @@ -344,7 +342,7 @@ static void window_new_ride_populate_list() nextListItem->entry_index = rideEntryIndex; nextListItem++; } else if (dh & 4) { - if (rideType == rideEntry[0x0C]) { + if (rideType == rideEntry->var_00C) { nextListItem--; nextListItem->type = rideType; nextListItem->entry_index = rideEntryIndex; @@ -758,11 +756,10 @@ static void window_new_ride_paint() if (RCT2_GLOBAL(0x01357CF3, uint8) != 1) { uint32 typeId = RCT2_GLOBAL(0x013580E0, uint32); if (typeId >= 0x10000) { - uint8 *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, uint8*); - if (RCT2_GLOBAL(rideEntry + 8, uint32) & 0x1000) - stringId = RCT2_GLOBAL(rideEntry, uint16); - else - stringId = (typeId & 0xFF00) + 2; + rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); + stringId = rideEntry->var_008 & 0x1000 ? + rideEntry->name : + (typeId & 0xFF00) + 2; } else { uint8 *sceneryEntry = RCT2_GLOBAL(0x009ADA90 + (typeId & 0xFFFF) * 4, uint8*); stringId = RCT2_GLOBAL(sceneryEntry, uint16); @@ -796,11 +793,10 @@ static void window_new_ride_paint() uint32 typeId = RCT2_GLOBAL(0x01357CF4, uint32); if (typeId != 0xFFFFFFFF) { if (typeId >= 0x10000) { - uint8 *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, uint8*); - if (RCT2_GLOBAL(rideEntry + 8, uint32) & 0x1000) - stringId = RCT2_GLOBAL(rideEntry, uint16); - else - stringId = (typeId & 0xFF00) + 2; + rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); + stringId = rideEntry->var_008 & 0x1000 ? + rideEntry->name : + (typeId & 0xFF00) + 2; } else { uint8 *sceneryEntry = RCT2_GLOBAL(0x009ADA90 + (typeId & 0xFFFF) * 4, uint8*); stringId = RCT2_GLOBAL(sceneryEntry, uint16); @@ -817,7 +813,7 @@ static void window_new_ride_scrollpaint() { rct_window *w; rct_drawpixelinfo *dpi; - uint8 **rideEntries = (uint8**)0x009ACFA4; + rct_ride_type **rideEntries = (rct_ride_type**)0x009ACFA4; window_paint_get_registers(w, dpi); @@ -830,7 +826,7 @@ static void window_new_ride_scrollpaint() int y = 1; ride_list_item *listItem = (ride_list_item*)0x00F43523; while (listItem->type != 255 || listItem->entry_index != 255) { - uint8 *rideEntry; + rct_ride_type *rideEntry; // Draw flat button rectangle int flags = 0; if (w->new_ride.selected_ride_id == *((sint16*)listItem)) @@ -840,10 +836,10 @@ static void window_new_ride_scrollpaint() // Draw ride image rideEntry = rideEntries[listItem->entry_index]; - int unk = RCT2_GLOBAL(rideEntry + 4, uint32); - if (listItem->type != RCT2_GLOBAL(rideEntry + 12, uint8)) { + int unk = rideEntry->var_004; + if (listItem->type != rideEntry->var_00C) { unk++; - if (listItem->type != RCT2_GLOBAL(rideEntry + 13, uint8)) + if (listItem->type != rideEntry->var_00D) unk++; } RCT2_CALLPROC_X(0x00681DE2, 0, 29013, x + 2, y + 2, 0xA0, (int)dpi, unk); @@ -909,13 +905,13 @@ static int get_num_track_designs(ride_list_item item) */ static void window_new_ride_paint_ride_information(rct_window *w, rct_drawpixelinfo *dpi, ride_list_item item, int x, int y, int width) { - uint8 **rideEntries = (uint8**)0x009ACFA4; - uint8 *rideEntry = rideEntries[item.entry_index]; + rct_ride_type **rideEntries = (rct_ride_type**)0x009ACFA4; + rct_ride_type *rideEntry = rideEntries[item.entry_index]; // Ride name and description - rct_string_id rideName = RCT2_GLOBAL(rideEntry + 0, uint16); - rct_string_id rideDescription = RCT2_GLOBAL(rideEntry + 2, uint16); - if (!(RCT2_GLOBAL(rideEntry + 8, uint32) & 0x1000)) { + rct_string_id rideName = rideEntry->name; + rct_string_id rideDescription = rideEntry->description; + if (!(rideEntry->var_008 & 0x1000)) { rideName = item.type + 2; rideDescription = item.type + 512; } diff --git a/src/window_research.c b/src/window_research.c index 11e6a86bc7..0417db1afa 100644 --- a/src/window_research.c +++ b/src/window_research.c @@ -22,6 +22,7 @@ #include "finance.h" #include "game.h" #include "news_item.h" +#include "ride.h" #include "string_ids.h" #include "sprites.h" #include "widget.h" @@ -342,11 +343,10 @@ static void window_research_development_paint() if (RCT2_GLOBAL(0x01357CF3, uint8) != 1) { uint32 typeId = RCT2_GLOBAL(0x013580E0, uint32); if (typeId >= 0x10000) { - uint8 *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, uint8*); - if (RCT2_GLOBAL(rideEntry + 8, uint32) & 0x1000) - stringId = RCT2_GLOBAL(rideEntry, uint16); - else - stringId = ((typeId >> 8) & 0xFF) + 2; + rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); + stringId = rideEntry->var_008 & 0x1000 ? + rideEntry->name : + ((typeId >> 8) & 0xFF) + 2; } else { uint8 *sceneryEntry = RCT2_GLOBAL(0x009ADA90 + (typeId & 0xFFFF) * 4, uint8*); stringId = RCT2_GLOBAL(sceneryEntry, uint16); @@ -381,11 +381,10 @@ static void window_research_development_paint() int lastDevelopmentFormat; if (typeId != 0xFFFFFFFF) { if (typeId >= 0x10000) { - uint8 *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, uint8*); - if (RCT2_GLOBAL(rideEntry + 8, uint32) & 0x1000) - stringId = RCT2_GLOBAL(rideEntry, uint16); - else - stringId = ((typeId >> 8) & 0xFF) + 2; + rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); + stringId = rideEntry->var_008 & 0x1000 ? + rideEntry->name : + ((typeId >> 8) & 0xFF) + 2; lastDevelopmentFormat = STR_RESEARCH_RIDE_LABEL; } else {