From 5fbe85aded87fb05119f1590ffeb2cf98f9afd3c Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Wed, 21 May 2014 23:27:31 +0900 Subject: [PATCH 01/16] WIP: add ratings for crooked house --- src/finance.c | 4 +- src/news_item.c | 4 +- src/ride.h | 38 ++++++++++-- src/ride_ratings.c | 151 +++++++++++++++++++++++++++++++++++++++++++++ src/ride_ratings.h | 28 +++++++++ 5 files changed, 217 insertions(+), 8 deletions(-) create mode 100644 src/ride_ratings.c create mode 100644 src/ride_ratings.h diff --git a/src/finance.c b/src/finance.c index dc6276455d..10a00f67ea 100644 --- a/src/finance.c +++ b/src/finance.c @@ -115,7 +115,7 @@ void finance_pay_ride_upkeep() if (ride->type == RIDE_TYPE_NULL) continue; - if (!(ride->var_1D0 & 0x1000)) { + if (!(ride->lifecycle_flags & 0x1000)) { ride->build_date = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); ride->var_196 = 25855; // durability? @@ -179,4 +179,4 @@ void sub_69E869() { value += RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, sint32); value = ror32(value, 3); RCT2_GLOBAL(0x013587C4, sint32) = value; -} \ No newline at end of file +} diff --git a/src/news_item.c b/src/news_item.c index 4b5fa14e7c..8637c8eabd 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -205,8 +205,8 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * // 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)) { + // Check if there are trains on the track (first bit of history_flags) + if (!(ride->lifecycle_flags & 1)) { *x = SPRITE_LOCATION_NULL; break; } diff --git a/src/ride.h b/src/ride.h index 84eb778120..a5c48298db 100644 --- a/src/ride.h +++ b/src/ride.h @@ -29,6 +29,8 @@ */ typedef struct { uint8 type; // 0x000 + // pointer to static info. for example, wild mouse type is 0x36, subtype is + // 0x4c. uint8 subtype; // 0x001 uint16 pad_002; uint8 mode; // 0x004 @@ -77,15 +79,22 @@ typedef struct { sint16 upkeep_cost; // 0x182 uint8 pad_184[0x12]; uint16 var_196; - uint8 pad_198; + // used in computing excitement, nausea, etc + uint8 var_198; uint8 var_199; uint8 pad_19A[0x1A]; sint32 profit; // 0x1B4 uint8 queue_time[4]; // 0x1B8 - uint8 pad_1BC[0x12]; + uint8 pad_1BC[0x11]; + uint8 var_1CD; uint16 guests_favourite; // 0x1CE - uint32 var_1D0; - uint8 pad_1D4[0x2C]; + uint32 lifecycle_flags; + uint8 pad_1D4[0x20]; + // Example value for wild mouse ride is d5 (before it's been constructed) + // I tried searching the IDA file for "1F4" but couldn't find places where + // this is written to. + uint16 var_1F4; + uint8 pad_1F6[0x0a]; uint16 queue_length[4]; // 0x200 uint8 pad_208[0x58]; } rct_ride; @@ -105,6 +114,27 @@ enum { RIDE_CLASS_KIOSK_OR_FACILITY }; +// Constants used by the lifecycle_flags property at 0x1D0 +enum { + RIDE_LIFECYCLE_ON_TRACK = 1, + RIDE_LIFECYCLE_TESTED = 1 << 1, + RIDE_LIFECYCLE_TEST_IN_PROGRESS = 1 << 2, + RIDE_LIFECYCLE_NO_RAW_STATS = 1 << 3, + RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING = 1 << 4, + RIDE_LIFECYCLE_ON_RIDE_PHOTO = 1 << 5, + + RIDE_LIFECYCLE_BROKEN_DOWN = 1 << 7, + + RIDE_LIFECYCLE_CRASHED = 1 << 10, + + RIDE_LIFECYCLE_EVER_BEEN_OPENED = 1 << 12, + RIDE_LIFECYCLE_MUSIC = 1 << 13, + RIDE_LIFECYCLE_INDESTRUCTIBLE = 1 << 14, + RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK = 1 << 15, + + RIDE_LIFECYCLE_CABLE_LIFT = 1 << 17, +} + enum { RIDE_TYPE_NULL = 255, RIDE_TYPE_SPIRAL_ROLLER_COASTER = 0, diff --git a/src/ride_ratings.c b/src/ride_ratings.c new file mode 100644 index 0000000000..67e194a735 --- /dev/null +++ b/src/ride_ratings.c @@ -0,0 +1,151 @@ +/***************************************************************************** + * Copyright (c) 2014 Ted John + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * This file is part of OpenRCT2. + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *****************************************************************************/ + +#include "ride.h" + +/** + * rct2: 0x0065C4D4 + * + * Compute excitement, intensity, etc. for a crooked house ride. + */ +void crooked_house_excitement(rct_ride *ride) +{ + // Set lifecycle bits + ride->lifecycle_flags |= RIDE_LIFECYCLE_TESTED; + ride->lifecycle_flags |= RIDE_LIFECYCLE_NO_RAW_STATS; + ride->var_198 = 5; + sub_655FD6(ride); + + excitement = 215; + intensity = 62; + nausea = 34; + + // NB this should get marked out by the compiler, if it's smart. + excitement = apply_intensity_penalty(excitement, intensity); + rating_tuple tup = per_ride_rating_adjustments(ride, excitement, intensity, nausea); + excitement = tup.excitement; + intensity = tup.intensity; + nausea = tup.nausea; + + ride->excitement = excitement; + ride->intensity = intensity; + ride->nausea = nausea; +} + +/** + * rct2: 0x0065E7FB + * + * inputs + * - bx: excitement + * - cx: intensity + * - bp: nausea + * - edi: ride ptr + */ +rating_tuple per_ride_rating_adjustments(rct_ride *ride, sint16 excitement, + sint16 intensity, sint16 nausea) +{ + // NB: The table here is allocated dynamically. Reading the exe will tell + // you nothing + subtype_p = RCT2_GLOBAL(0x009ACFA4 + ride->subtype * 4, uint32); + + // example value here: 12 (?) + sint16 ctr = RCT2_GLOBAL(subtype_p + 0x1b2); + excitement = excitement + ((excitement * ctr) >> 7); + + sint16 ctr = RCT2_GLOBAL(subtype_p + 0x1b3); + intensity = intensity + ((intensity * ctr) >> 7); + + sint16 ctr = RCT2_GLOBAL(subtype_p + 0x1b4); + nausea = nausea + ((nausea * ctr) >> 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. + // more detail: https://gist.github.com/kevinburke/d951e74e678b235eef3e + uint16 ridetype_var = RCT2_GLOBAL(ride->type * 8, uint16); + if (ridetype_var & 0x80) { + uint16 ax = ride->var_1F4; + if (RCT2_GLOBAL(subtype_p + 8, uint32) & 0x800) { + // 65e86e + ax = ax - 96; + if (ax >= 0) { + ax = ax >> 3; + excitement = excitement - ax; + ax = ax >> 1; + nausea = nausea - ax; + } + } else { + ax = ax >> 3; + excitement = excitement + ax; + ax = ax >> 1; + nausea += ax; + } + } + rating_tuple tup = {excitement, intensity, nausea}; + return tup; +} + +/** + * rct2: 0x0065E7A3 + * + * inputs from x86 + * - bx: excitement + * - cx: intensity + * - bp: nausea + * + * returns: the excitement level, with intensity penalties applied + */ +sint16 apply_intensity_penalty(sint16 excitement, sint16 intensity) +{ + // intensity penalty + if (intensity >= 1000) { + excitement = excitement - (excitement >> 2); + } + if (intensity >= 1100) { + excitement = excitement - (excitement >> 2); + } + if (intensity >= 1200) { + excitement = excitement - (excitement >> 2); + } + if (intensity >= 1320) { + excitement = excitement - (excitement >> 2); + } + if (intensity >= 1450) { + excitement = excitement - (excitement >> 2); + } + return excitement; +} + +/** + * rct2: 0x00655FD6 + * + * Take ride property 1CD, make some modifications, store the modified value in + * property 198. + */ +void sub_655FD6(rct_ride *ride) +{ + uint8 al = ride->var_1CD; + // No idea what this address is; maybe like compensation of some kind? The + // maximum possible value? + // List of ride names/values is here: + // https://gist.github.com/kevinburke/5eebcda14d94e6ee99c0 + al -= RCT2_ADDRESS(0x0097D7C9, uint8)[4 * ride->type]; + al = al << 1; + ride->var198 += al; +} diff --git a/src/ride_ratings.h b/src/ride_ratings.h new file mode 100644 index 0000000000..fb6c922efd --- /dev/null +++ b/src/ride_ratings.h @@ -0,0 +1,28 @@ +/***************************************************************************** + * Copyright (c) 2014 Kevin Burke + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * This file is part of OpenRCT2. + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *****************************************************************************/ + +// Used for return values, for functions that modify all three. +typedef struct { + sint16 excitement; + sint16 intensity; + sint16 nausea; +} rating_tuple; + +void crooked_house_excitement(rct_ride *ride); From c374536cbbeae3a890cd39f3c8e010f97fbc7d82 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Thu, 22 May 2014 01:00:58 +0900 Subject: [PATCH 02/16] more work on crooked house --- src/ride.h | 26 +++++++++---- src/ride_ratings.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 7 deletions(-) diff --git a/src/ride.h b/src/ride.h index a5c48298db..9b8f01b9bb 100644 --- a/src/ride.h +++ b/src/ride.h @@ -47,11 +47,23 @@ typedef struct { uint16 exits[4]; // 0x072 uint8 pad_07A[0x0C]; uint16 train_car_map[1]; // 0x086 Points to the first car in the train - uint8 pad_088[0x68]; - sint16 var_0F0; - sint16 var_0F2; - sint16 var_0F4; - uint8 pad_0F6[0x2E]; + uint8 pad_088[0x3F]; + + // Not sure if these should be uint or sint. + uint8 var_0C7; + uint8 var_0C8; + uint8 var_0C9; + + uint8 pad_0CA[0x1B]; + + sint32 var_0E4; + sint32 var_0E8; + sint32 var_0EC; + sint32 var_0F0; + uint8 pad_0F4[0x20]; + uint8 var_114; + uint8 var_115; + uint8 pad_116[0x0F]; sint16 var_124; sint16 var_126; sint16 var_128; @@ -259,7 +271,7 @@ enum { RIDE_MODE_3D_FILM_MOUSE_TAILS, RIDE_MODE_SPACE_RINGS, RIDE_MODE_BEGINNERS, - RIDE_MODE_LIM_POWERED_LAUNCH, + RIDE_MODE_LIM_POWERED_LAUNCH, // 0x17 RIDE_MODE_FILM_THRILL_RIDERS, RIDE_MODE_3D_FILM_STORM_CHASERS, RIDE_MODE_3D_FILM_SPACE_RAIDERS, @@ -271,7 +283,7 @@ enum { RIDE_MODE_CROOKED_HOUSE, RIDE_MODE_FREEFALL_DROP, RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED, - RIDE_MODE_POWERED_LAUNCH2, // RCT2 style? + RIDE_MODE_POWERED_LAUNCH2, // 0x23. RCT2 style? RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED }; diff --git a/src/ride_ratings.c b/src/ride_ratings.c index 67e194a735..96d88fc058 100644 --- a/src/ride_ratings.c +++ b/src/ride_ratings.c @@ -47,6 +47,102 @@ void crooked_house_excitement(rct_ride *ride) ride->excitement = excitement; ride->intensity = intensity; ride->nausea = nausea; + + sub_65E621(ride, intensity); + + // clear all bits except lowest 5 + ride->var_114 &= 0x1f; + + // set 6th,7th,8th bits + ride->var_114 |= 7 << 5; +} + +/** + * rct2: sub_65E621 + * + * I think this function computes ride upkeep? Though it is weird that the + * starting input is the ride's intensity + * + * inputs + * - bx: excitement + * - cx: intensity + * - bp: nausea + * - edi: ride ptr + */ +void sub_65E621(rct_ride *ride, sint16 intensity) +{ + // data values here: https://gist.github.com/kevinburke/456fe478b1822580a449 + intensity += RCT2_GLOBAL(0x0097E3A8 + ride->type*12, uint16); + + uint16 eax = RCT2_GLOBAL(0x0097E3AA + ride->type*12, uint16); + // max speed? lateral G's? + uint8 dl = ride->var_115; + dl = dl >> 6; + dl = dl & 3; + eax = eax * dl; + intensity += dl; + + uint32 cuml = ride->var_0E4; + cuml += ride->var_0E8; + cuml += ride->var_0EC; + cuml += ride->var_0F0; + cuml = cuml >> 0x10; + + cuml = cuml * RCT2_GLOBAL(0x0097E3AC + ride->type*12, uint16); + cuml = cuml >> 0x0A; + intensity += cuml; + + // on ride photo adds to intensity ? + if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) { + // this value seems to be 40 for every ride. also, I tried measuring + // intensity on a dummy ride with/without on ride photo, and no change. + intensity += RCT2_GLOBAL(0x0097E3AE, ride->type*12, uint16); + } + + eax = RCT2_GLOBAL(0x0097E3B0+ride->type*12, uint16); + + // not sure what this value is; it's only written to in one place, where + // it's incremented. + sint16 dx = RCT2_GLOBAL(0x0138B5CC, sint16); + intensity += eax * dx; + + eax = RCT2_GLOBAL(0x0097E3B2 + ride->type*12, uint16); + dx = RCT2_GLOBAL(0x0138B5CA, sint16); + intensity += eax * dx; + + // these seem to be adhoc adjustments to a ride's intensity/cost, times + // various variables set on the ride itself. + + // https://gist.github.com/kevinburke/e19b803cd2769d96c540 + eax = RCT2_GLOBAL(0x0097E3B4 + ride->type*12, uint16); + intensity += eax * ride->var_0C8; + + // either set to 3 or 0, extra boosts for some rides including mini golf + eax = RCT2_GLOBAL(0x0097E3B6 + ride->type*12, uint16); + intensity += eax * ride->var_0C9; + + // slight intensity boosts for some rides - 5 for mini railroad, 10 for log + // flume/rapids, 10 for roller coaster, 28 for giga coaster + eax = RCT2_GLOBAL(0x0097E3B8 + ride->type*12, uint16); + intensity += eax * ride->var_0C7; + + if (ride->mode == RIDE_MODE_REVERSE_INCLINED_SHUTTLE) { + intensity += 30; + } else if (ride->mode == RIDE_MODE_POWERED_LAUNCH) { + intensity += 160; + } else if (ride->mode == RIDE_MODE_LIM_POWERED_LAUNCH) { + intensity += 320; + } else if (ride->mode == RIDE_MODE_POWERED_LAUNCH2 || + ride->mode == RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED) { + intensity += 220; + } + + intensity = intensity * 10; + intensity = intensity >> 4; + ride->upkeep_cost = intensity; // Which var here is named correctly? + + // Upkeep flag? or a dirtiness flag + ride->var_14D |= 2; } /** From cd414e98f654a573c5f8afcf570b206650a3b65a Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Wed, 21 May 2014 09:06:38 -0700 Subject: [PATCH 03/16] minor changes to get it to compile --- src/config.c | 3 +-- src/ride.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/config.c b/src/config.c index 09a67742ab..ffebd2c914 100644 --- a/src/config.c +++ b/src/config.c @@ -19,7 +19,7 @@ *****************************************************************************/ #include -#include +#include "shlobj.h" #include #include #include "addresses.h" @@ -614,4 +614,3 @@ static void config_error(char *msg){ } - diff --git a/src/ride.h b/src/ride.h index 9b8f01b9bb..eff128da65 100644 --- a/src/ride.h +++ b/src/ride.h @@ -144,8 +144,8 @@ enum { RIDE_LIFECYCLE_INDESTRUCTIBLE = 1 << 14, RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK = 1 << 15, - RIDE_LIFECYCLE_CABLE_LIFT = 1 << 17, -} + RIDE_LIFECYCLE_CABLE_LIFT = 1 << 17 +}; enum { RIDE_TYPE_NULL = 255, From 2c03908700cc10408814224016c513b1ed17971c Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Thu, 22 May 2014 08:59:58 +0900 Subject: [PATCH 04/16] revert change in config.c --- src/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index ffebd2c914..b7ca7b5389 100644 --- a/src/config.c +++ b/src/config.c @@ -19,7 +19,7 @@ *****************************************************************************/ #include -#include "shlobj.h" +#include #include #include #include "addresses.h" From 7483ac230703cea7f62edf6c1b15398179f5828e Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Thu, 22 May 2014 09:02:55 +0900 Subject: [PATCH 05/16] refactor, fix tabbing --- src/finance.c | 2 +- src/news_item.c | 3 +-- src/ride_ratings.c | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/finance.c b/src/finance.c index 10a00f67ea..77c66b1875 100644 --- a/src/finance.c +++ b/src/finance.c @@ -115,7 +115,7 @@ void finance_pay_ride_upkeep() if (ride->type == RIDE_TYPE_NULL) continue; - if (!(ride->lifecycle_flags & 0x1000)) { + if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED)) { ride->build_date = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); ride->var_196 = 25855; // durability? diff --git a/src/news_item.c b/src/news_item.c index 8637c8eabd..eb3f8d5ede 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -205,8 +205,7 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * // 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 history_flags) - if (!(ride->lifecycle_flags & 1)) { + if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)) { *x = SPRITE_LOCATION_NULL; break; } diff --git a/src/ride_ratings.c b/src/ride_ratings.c index 96d88fc058..67a3d76130 100644 --- a/src/ride_ratings.c +++ b/src/ride_ratings.c @@ -27,18 +27,18 @@ */ void crooked_house_excitement(rct_ride *ride) { - // Set lifecycle bits - ride->lifecycle_flags |= RIDE_LIFECYCLE_TESTED; - ride->lifecycle_flags |= RIDE_LIFECYCLE_NO_RAW_STATS; - ride->var_198 = 5; - sub_655FD6(ride); + // Set lifecycle bits + ride->lifecycle_flags |= RIDE_LIFECYCLE_TESTED; + ride->lifecycle_flags |= RIDE_LIFECYCLE_NO_RAW_STATS; + ride->var_198 = 5; + sub_655FD6(ride); - excitement = 215; - intensity = 62; - nausea = 34; + excitement = 215; + intensity = 62; + nausea = 34; - // NB this should get marked out by the compiler, if it's smart. - excitement = apply_intensity_penalty(excitement, intensity); + // NB this should get marked out by the compiler, if it's smart. + excitement = apply_intensity_penalty(excitement, intensity); rating_tuple tup = per_ride_rating_adjustments(ride, excitement, intensity, nausea); excitement = tup.excitement; intensity = tup.intensity; From 74b41b08ea87b6ff74af4f11a61f2e334322e67b Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Thu, 22 May 2014 09:13:53 +0900 Subject: [PATCH 06/16] it is used for upkeep --- src/ride_ratings.c | 57 +++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/src/ride_ratings.c b/src/ride_ratings.c index 67a3d76130..e2cf956427 100644 --- a/src/ride_ratings.c +++ b/src/ride_ratings.c @@ -48,11 +48,12 @@ void crooked_house_excitement(rct_ride *ride) ride->intensity = intensity; ride->nausea = nausea; - sub_65E621(ride, intensity); + ride->upkeep_cost = compute_upkeep(ride); + // Upkeep flag? or a dirtiness flag + ride->var_14D |= 2; // clear all bits except lowest 5 ride->var_114 &= 0x1f; - // set 6th,7th,8th bits ride->var_114 |= 7 << 5; } @@ -61,26 +62,21 @@ void crooked_house_excitement(rct_ride *ride) * rct2: sub_65E621 * * I think this function computes ride upkeep? Though it is weird that the - * starting input is the ride's intensity * * inputs - * - bx: excitement - * - cx: intensity - * - bp: nausea * - edi: ride ptr */ -void sub_65E621(rct_ride *ride, sint16 intensity) +uint16 compute_upkeep(rct_ride *ride) { // data values here: https://gist.github.com/kevinburke/456fe478b1822580a449 - intensity += RCT2_GLOBAL(0x0097E3A8 + ride->type*12, uint16); + uint16 upkeep += RCT2_GLOBAL(0x0097E3A8 + ride->type*12, uint16); uint16 eax = RCT2_GLOBAL(0x0097E3AA + ride->type*12, uint16); - // max speed? lateral G's? uint8 dl = ride->var_115; dl = dl >> 6; dl = dl & 3; eax = eax * dl; - intensity += dl; + upkeep += dl; uint32 cuml = ride->var_0E4; cuml += ride->var_0E8; @@ -90,13 +86,11 @@ void sub_65E621(rct_ride *ride, sint16 intensity) cuml = cuml * RCT2_GLOBAL(0x0097E3AC + ride->type*12, uint16); cuml = cuml >> 0x0A; - intensity += cuml; + upkeep += cuml; - // on ride photo adds to intensity ? if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) { - // this value seems to be 40 for every ride. also, I tried measuring - // intensity on a dummy ride with/without on ride photo, and no change. - intensity += RCT2_GLOBAL(0x0097E3AE, ride->type*12, uint16); + // this value seems to be 40 for every ride + upkeep += RCT2_GLOBAL(0x0097E3AE, ride->type*12, uint16); } eax = RCT2_GLOBAL(0x0097E3B0+ride->type*12, uint16); @@ -104,45 +98,42 @@ void sub_65E621(rct_ride *ride, sint16 intensity) // not sure what this value is; it's only written to in one place, where // it's incremented. sint16 dx = RCT2_GLOBAL(0x0138B5CC, sint16); - intensity += eax * dx; + upkeep += eax * dx; eax = RCT2_GLOBAL(0x0097E3B2 + ride->type*12, uint16); dx = RCT2_GLOBAL(0x0138B5CA, sint16); - intensity += eax * dx; + upkeep += eax * dx; - // these seem to be adhoc adjustments to a ride's intensity/cost, times + // these seem to be adhoc adjustments to a ride's upkeep/cost, times // various variables set on the ride itself. // https://gist.github.com/kevinburke/e19b803cd2769d96c540 eax = RCT2_GLOBAL(0x0097E3B4 + ride->type*12, uint16); - intensity += eax * ride->var_0C8; + upkeep += eax * ride->var_0C8; // either set to 3 or 0, extra boosts for some rides including mini golf eax = RCT2_GLOBAL(0x0097E3B6 + ride->type*12, uint16); - intensity += eax * ride->var_0C9; + upkeep += eax * ride->var_0C9; - // slight intensity boosts for some rides - 5 for mini railroad, 10 for log + // slight upkeep boosts for some rides - 5 for mini railroad, 10 for log // flume/rapids, 10 for roller coaster, 28 for giga coaster eax = RCT2_GLOBAL(0x0097E3B8 + ride->type*12, uint16); - intensity += eax * ride->var_0C7; + upkeep += eax * ride->var_0C7; if (ride->mode == RIDE_MODE_REVERSE_INCLINED_SHUTTLE) { - intensity += 30; + upkeep += 30; } else if (ride->mode == RIDE_MODE_POWERED_LAUNCH) { - intensity += 160; + upkeep += 160; } else if (ride->mode == RIDE_MODE_LIM_POWERED_LAUNCH) { - intensity += 320; + upkeep += 320; } else if (ride->mode == RIDE_MODE_POWERED_LAUNCH2 || ride->mode == RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED) { - intensity += 220; + upkeep += 220; } - intensity = intensity * 10; - intensity = intensity >> 4; - ride->upkeep_cost = intensity; // Which var here is named correctly? - - // Upkeep flag? or a dirtiness flag - ride->var_14D |= 2; + upkeep = upkeep * 10; + upkeep = upkeep >> 4; + return upkeep; } /** @@ -174,7 +165,7 @@ rating_tuple per_ride_rating_adjustments(rct_ride *ride, sint16 excitement, // 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. // more detail: https://gist.github.com/kevinburke/d951e74e678b235eef3e - uint16 ridetype_var = RCT2_GLOBAL(ride->type * 8, uint16); + 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) { From cf5556d2fe7e0f46b25c07e6670748c82b2ceb91 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Thu, 22 May 2014 21:16:22 +0900 Subject: [PATCH 07/16] feedback from code review --- src/ride_ratings.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/ride_ratings.c b/src/ride_ratings.c index e2cf956427..fa6ecb97aa 100644 --- a/src/ride_ratings.c +++ b/src/ride_ratings.c @@ -55,7 +55,7 @@ void crooked_house_excitement(rct_ride *ride) // clear all bits except lowest 5 ride->var_114 &= 0x1f; // set 6th,7th,8th bits - ride->var_114 |= 7 << 5; + ride->var_114 |= 0xE0; } /** @@ -68,10 +68,12 @@ void crooked_house_excitement(rct_ride *ride) */ uint16 compute_upkeep(rct_ride *ride) { - // data values here: https://gist.github.com/kevinburke/456fe478b1822580a449 - uint16 upkeep += RCT2_GLOBAL(0x0097E3A8 + ride->type*12, uint16); + uint8 type_idx = ride->type * 0x12; - uint16 eax = RCT2_GLOBAL(0x0097E3AA + ride->type*12, uint16); + // data values here: https://gist.github.com/kevinburke/456fe478b1822580a449 + uint16 upkeep = RCT2_GLOBAL(0x0097E3A8 + type_idx, uint16); + + uint16 eax = RCT2_GLOBAL(0x0097E3AA + type_idx, uint16); uint8 dl = ride->var_115; dl = dl >> 6; dl = dl & 3; @@ -84,23 +86,23 @@ uint16 compute_upkeep(rct_ride *ride) cuml += ride->var_0F0; cuml = cuml >> 0x10; - cuml = cuml * RCT2_GLOBAL(0x0097E3AC + ride->type*12, uint16); + cuml = cuml * RCT2_GLOBAL(0x0097E3AC + type_idx, uint16); cuml = cuml >> 0x0A; upkeep += cuml; if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) { // this value seems to be 40 for every ride - upkeep += RCT2_GLOBAL(0x0097E3AE, ride->type*12, uint16); + upkeep += RCT2_GLOBAL(0x0097E3AE, type_idx, uint16); } - eax = RCT2_GLOBAL(0x0097E3B0+ride->type*12, uint16); + eax = RCT2_GLOBAL(0x0097E3B0 + type_idx, uint16); // not sure what this value is; it's only written to in one place, where // it's incremented. sint16 dx = RCT2_GLOBAL(0x0138B5CC, sint16); upkeep += eax * dx; - eax = RCT2_GLOBAL(0x0097E3B2 + ride->type*12, uint16); + eax = RCT2_GLOBAL(0x0097E3B2 + type_idx, uint16); dx = RCT2_GLOBAL(0x0138B5CA, sint16); upkeep += eax * dx; @@ -108,16 +110,16 @@ uint16 compute_upkeep(rct_ride *ride) // various variables set on the ride itself. // https://gist.github.com/kevinburke/e19b803cd2769d96c540 - eax = RCT2_GLOBAL(0x0097E3B4 + ride->type*12, uint16); + eax = RCT2_GLOBAL(0x0097E3B4 + type_idx, uint16); upkeep += eax * ride->var_0C8; // either set to 3 or 0, extra boosts for some rides including mini golf - eax = RCT2_GLOBAL(0x0097E3B6 + ride->type*12, uint16); + eax = RCT2_GLOBAL(0x0097E3B6 + type_idx, uint16); upkeep += eax * ride->var_0C9; // slight upkeep boosts for some rides - 5 for mini railroad, 10 for log // flume/rapids, 10 for roller coaster, 28 for giga coaster - eax = RCT2_GLOBAL(0x0097E3B8 + ride->type*12, uint16); + eax = RCT2_GLOBAL(0x0097E3B8 + type_idx, uint16); upkeep += eax * ride->var_0C7; if (ride->mode == RIDE_MODE_REVERSE_INCLINED_SHUTTLE) { @@ -131,6 +133,7 @@ uint16 compute_upkeep(rct_ride *ride) upkeep += 220; } + // multiply by 5/8 upkeep = upkeep * 10; upkeep = upkeep >> 4; return upkeep; From eccb4af048cc8bde9a371facddd40bc2a8d59264 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 23 May 2014 07:45:19 +0900 Subject: [PATCH 08/16] Add new files to vcxproj, vcxproj +filters --- projects/openrct2.vcxproj | 4 +++- projects/openrct2.vcxproj.filters | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 95fe426232..66eca6faa9 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -33,6 +33,7 @@ + @@ -71,6 +72,7 @@ + @@ -193,4 +195,4 @@ - \ No newline at end of file + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index a37dff35ba..2fe5f4120e 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -78,6 +78,9 @@ Header Files + + Header Files + Header Files @@ -194,6 +197,9 @@ Source Files + + Source Files + Source Files @@ -302,4 +308,4 @@ Resource Files - \ No newline at end of file + From 1d0a24e419487a817bfc9025f89134f32d72fb93 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 23 May 2014 17:49:42 +0900 Subject: [PATCH 09/16] replace on ride photo value with simpler constant --- src/ride_ratings.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ride_ratings.c b/src/ride_ratings.c index fa6ecb97aa..5603120342 100644 --- a/src/ride_ratings.c +++ b/src/ride_ratings.c @@ -91,8 +91,11 @@ uint16 compute_upkeep(rct_ride *ride) upkeep += cuml; if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) { - // this value seems to be 40 for every ride - upkeep += RCT2_GLOBAL(0x0097E3AE, type_idx, uint16); + // The original code read from a table starting at 0x0097E3AE and + // incrementing by 0x12 bytes between values. However, all of these + // values were 40. I have replaced the table lookup with the constant + // 40 in this case. + upkeep += 40; } eax = RCT2_GLOBAL(0x0097E3B0 + type_idx, uint16); From 33e232607055048ac2e2f4ec96f0ffd78aefc459 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 23 May 2014 18:14:52 +0900 Subject: [PATCH 10/16] add data about moving track --- src/ride_ratings_data.c | 97 +++++++++++++++++++++++++++++++++++++++++ src/ride_ratings_data.h | 21 +++++++++ 2 files changed, 118 insertions(+) create mode 100644 src/ride_ratings_data.c create mode 100644 src/ride_ratings_data.h diff --git a/src/ride_ratings_data.c b/src/ride_ratings_data.c new file mode 100644 index 0000000000..37443cb3cd --- /dev/null +++ b/src/ride_ratings_data.c @@ -0,0 +1,97 @@ +/* + * Whether a particular ride has a running track or not. Will probably end up + * being used in various places in the game. + */ +const uint8 runningTrack[100] = { + 1, // 0 Spiral Roller coaster + 1, // 1 Stand Up Coaster + 1, // 2 Suspended Swinging + 1, // 3 Inverted + 1, // 4 Steel Mini Coaster + 1, // 5 Mini Railroad + 1, // 6 Monorail + 1, // 7 Mini Suspended Coaster + 0, // 8 Bumper Boats + 1, // 9 Wooden Wild Mine/Mouse + 1, // a Steeplechase/Motorbike/Soap Box Derby + 1, // b Car Ride + 1, // c Launched Freefall + 1, // d Bobsleigh Coaster + 1, // e Observation Tower + 1, // f Looping Roller Coaster + 1, // 10 Dinghy Slide + 1, // 11 Mine Train Coaster + 1, // 12 Chairlift + 1, // 13 Corkscrew Roller Coaster + 0, // 14 Maze + 0, // 15 Spiral Slide + 1, // 16 Go Karts + 1, // 17 Log Flume + 1, // 18 River Rapids + 0, // 19 Bumper Cars + 0, // 1a Pirate Ship + 0, // 1b Swinging Inverter Ship + 0, // 1c Food Stall + 0, // 1d (none) + 0, // 1e Drink Stall + 0, // 1f (none) + 0, // 20 Shop (all types) + 0, // 21 Merry Go Round + 0, // 22 Balloon Stall (maybe) + 0, // 23 Information Kiosk + 0, // 24 Bathroom + 0, // 25 Ferris Wheel + 0, // 26 Motion Simulator + 0, // 27 3D Cinema + 0, // 28 Gravitron + 0, // 29 Space Rings + 1, // 2a Reverse Freefall Coaster + 1, // 2b Elevator + 1, // 2c Vertical Drop Roller Coaster + 0, // 2d ATM + 0, // 2e Twist + 0, // 2f Haunted House + 0, // 30 First Aid + 0, // 31 Circus Show + 1, // 32 Ghost Train + 1, // 33 Twister Roller Coaster + 1, // 34 Wooden Roller Coaster + 1, // 35 Side-Friction Roller Coaster + 1, // 36 Wild Mouse + 1, // 37 Multi Dimension Coaster + 1, // 38 (none) + 1, // 39 Flying Roller Coaster + 1, // 3a (none) + 1, // 3b Virginia Reel + 1, // 3c Splash Boats + 1, // 3d Mini Helicopters + 1, // 3e Lay-down Roller Coaster + 1, // 3f Suspended Monorail + 1, // 40 (none) + 1, // 41 Reverser Roller Coaster + 1, // 42 Heartline Twister Roller Coaster + 1, // 43 Mini Golf + 1, // 44 Giga Coaster + 1, // 45 Roto-Drop + 0, // 46 Flying Saucers + 0, // 47 Crooked House + 1, // 48 Monorail Cycles + 1, // 49 Compact Inverted Coaster + 1, // 4a Water Coaster + 1, // 4b Air Powered Vertical Coaster + 1, // 4c Inverted Hairpin Coaster + 0, // 4d Magic Carpet + 0, // 4e Submarine Ride + 1, // 4f River Rafts + 0, // 50 (none) + 0, // 51 Enterprise + 0, // 52 (none) + 0, // 53 (none) + 0, // 54 (none) + 1, // 55 (none) + 1, // 56 Inverted Impulse Coaster + 1, // 57 Mini Roller Coaster + 1, // 58 Mine Ride + 1, // 59 LIM Launched Roller Coaster +} + diff --git a/src/ride_ratings_data.h b/src/ride_ratings_data.h new file mode 100644 index 0000000000..4ec9ff2973 --- /dev/null +++ b/src/ride_ratings_data.h @@ -0,0 +1,21 @@ +/***************************************************************************** + * Copyright (c) 2014 Kevin Burke + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * This file is part of OpenRCT2. + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *****************************************************************************/ + +extern const uint8 runningTrack[100]; From e701209282cafc3709eb1e06c67666051506f88a Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 23 May 2014 18:26:49 +0900 Subject: [PATCH 11/16] clean up upkeep function a little more --- src/ride_data.c | 99 ++++++++++++++++++++++++ src/{ride_ratings_data.h => ride_data.h} | 0 src/ride_ratings.c | 9 ++- src/ride_ratings_data.c | 97 ----------------------- 4 files changed, 107 insertions(+), 98 deletions(-) create mode 100644 src/ride_data.c rename src/{ride_ratings_data.h => ride_data.h} (100%) delete mode 100644 src/ride_ratings_data.c diff --git a/src/ride_data.c b/src/ride_data.c new file mode 100644 index 0000000000..92d70fcb37 --- /dev/null +++ b/src/ride_data.c @@ -0,0 +1,99 @@ +/* + * Whether a particular ride has a running track or not. Will probably end up + * being used in various places in the game. + * + * Data source is 0x0097E3AC + */ +const bool hasRunningTrack[0x59] = { + true, // 0 Spiral Roller coaster + true, // 1 Stand Up Coaster + true, // 2 Suspended Swinging + true, // 3 Inverted + true, // 4 Steel Mini Coaster + true, // 5 Mini Railroad + true, // 6 Monorail + true, // 7 Mini Suspended Coaster + false, // 8 Bumper Boats + true, // 9 Wooden Wild Mine/Mouse + true, // a Steeplechase/Motorbike/Soap Box Derby + true, // b Car Ride + true, // c Launched Freefall + true, // d Bobsleigh Coaster + true, // e Observation Tower + true, // f Looping Roller Coaster + true, // 10 Dinghy Slide + true, // 11 Mine Train Coaster + true, // 12 Chairlift + true, // 13 Corkscrew Roller Coaster + false, // 14 Maze + false, // 15 Spiral Slide + true, // 16 Go Karts + true, // 17 Log Flume + true, // 18 River Rapids + false, // 19 Bumper Cars + false, // 1a Pirate Ship + false, // 1b Swinging Inverter Ship + false, // 1c Food Stall + false, // 1d (none) + false, // 1e Drink Stall + false, // 1f (none) + false, // 20 Shop (all types) + false, // 21 Merry Go Round + false, // 22 Balloon Stall (maybe) + false, // 23 Information Kiosk + false, // 24 Bathroom + false, // 25 Ferris Wheel + false, // 26 Motion Simulator + false, // 27 3D Cinema + false, // 28 Gravitron + false, // 29 Space Rings + true, // 2a Reverse Freefall Coaster + true, // 2b Elevator + true, // 2c Vertical Drop Roller Coaster + false, // 2d ATM + false, // 2e Twist + false, // 2f Haunted House + false, // 30 First Aid + false, // 31 Circus Show + true, // 32 Ghost Train + true, // 33 Twister Roller Coaster + true, // 34 Wooden Roller Coaster + true, // 35 Side-Friction Roller Coaster + true, // 36 Wild Mouse + true, // 37 Multi Dimension Coaster + true, // 38 (none) + true, // 39 Flying Roller Coaster + true, // 3a (none) + true, // 3b Virginia Reel + true, // 3c Splash Boats + true, // 3d Mini Helicopters + true, // 3e Lay-down Roller Coaster + true, // 3f Suspended Monorail + true, // 40 (none) + true, // 41 Reverser Roller Coaster + true, // 42 Heartline Twister Roller Coaster + true, // 43 Mini Golf + true, // 44 Giga Coaster + true, // 45 Roto-Drop + false, // 46 Flying Saucers + false, // 47 Crooked House + true, // 48 Monorail Cycles + true, // 49 Compact Inverted Coaster + true, // 4a Water Coaster + true, // 4b Air Powered Vertical Coaster + true, // 4c Inverted Hairpin Coaster + false, // 4d Magic Carpet + false, // 4e Submarine Ride + true, // 4f River Rafts + false, // 50 (none) + false, // 51 Enterprise + false, // 52 (none) + false, // 53 (none) + false, // 54 (none) + true, // 55 (none) + true, // 56 Inverted Impulse Coaster + true, // 57 Mini Roller Coaster + true, // 58 Mine Ride + true, // 59 LIM Launched Roller Coaster +} + diff --git a/src/ride_ratings_data.h b/src/ride_data.h similarity index 100% rename from src/ride_ratings_data.h rename to src/ride_data.h diff --git a/src/ride_ratings.c b/src/ride_ratings.c index 5603120342..0b5c93f32c 100644 --- a/src/ride_ratings.c +++ b/src/ride_ratings.c @@ -19,6 +19,7 @@ *****************************************************************************/ #include "ride.h" +#include "ride_data.h" /** * rct2: 0x0065C4D4 @@ -86,7 +87,13 @@ uint16 compute_upkeep(rct_ride *ride) cuml += ride->var_0F0; cuml = cuml >> 0x10; - cuml = cuml * RCT2_GLOBAL(0x0097E3AC + type_idx, uint16); + // The data originally here was 20's and 0's. The 20's all represented + // rides that had tracks. The 0's were fixed rides like crooked house or + // bumper cars. + // Data source is 0x0097E3AC + if (hasRunningTrack[ride->type]) { + cuml = cuml * 20; + } cuml = cuml >> 0x0A; upkeep += cuml; diff --git a/src/ride_ratings_data.c b/src/ride_ratings_data.c deleted file mode 100644 index 37443cb3cd..0000000000 --- a/src/ride_ratings_data.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Whether a particular ride has a running track or not. Will probably end up - * being used in various places in the game. - */ -const uint8 runningTrack[100] = { - 1, // 0 Spiral Roller coaster - 1, // 1 Stand Up Coaster - 1, // 2 Suspended Swinging - 1, // 3 Inverted - 1, // 4 Steel Mini Coaster - 1, // 5 Mini Railroad - 1, // 6 Monorail - 1, // 7 Mini Suspended Coaster - 0, // 8 Bumper Boats - 1, // 9 Wooden Wild Mine/Mouse - 1, // a Steeplechase/Motorbike/Soap Box Derby - 1, // b Car Ride - 1, // c Launched Freefall - 1, // d Bobsleigh Coaster - 1, // e Observation Tower - 1, // f Looping Roller Coaster - 1, // 10 Dinghy Slide - 1, // 11 Mine Train Coaster - 1, // 12 Chairlift - 1, // 13 Corkscrew Roller Coaster - 0, // 14 Maze - 0, // 15 Spiral Slide - 1, // 16 Go Karts - 1, // 17 Log Flume - 1, // 18 River Rapids - 0, // 19 Bumper Cars - 0, // 1a Pirate Ship - 0, // 1b Swinging Inverter Ship - 0, // 1c Food Stall - 0, // 1d (none) - 0, // 1e Drink Stall - 0, // 1f (none) - 0, // 20 Shop (all types) - 0, // 21 Merry Go Round - 0, // 22 Balloon Stall (maybe) - 0, // 23 Information Kiosk - 0, // 24 Bathroom - 0, // 25 Ferris Wheel - 0, // 26 Motion Simulator - 0, // 27 3D Cinema - 0, // 28 Gravitron - 0, // 29 Space Rings - 1, // 2a Reverse Freefall Coaster - 1, // 2b Elevator - 1, // 2c Vertical Drop Roller Coaster - 0, // 2d ATM - 0, // 2e Twist - 0, // 2f Haunted House - 0, // 30 First Aid - 0, // 31 Circus Show - 1, // 32 Ghost Train - 1, // 33 Twister Roller Coaster - 1, // 34 Wooden Roller Coaster - 1, // 35 Side-Friction Roller Coaster - 1, // 36 Wild Mouse - 1, // 37 Multi Dimension Coaster - 1, // 38 (none) - 1, // 39 Flying Roller Coaster - 1, // 3a (none) - 1, // 3b Virginia Reel - 1, // 3c Splash Boats - 1, // 3d Mini Helicopters - 1, // 3e Lay-down Roller Coaster - 1, // 3f Suspended Monorail - 1, // 40 (none) - 1, // 41 Reverser Roller Coaster - 1, // 42 Heartline Twister Roller Coaster - 1, // 43 Mini Golf - 1, // 44 Giga Coaster - 1, // 45 Roto-Drop - 0, // 46 Flying Saucers - 0, // 47 Crooked House - 1, // 48 Monorail Cycles - 1, // 49 Compact Inverted Coaster - 1, // 4a Water Coaster - 1, // 4b Air Powered Vertical Coaster - 1, // 4c Inverted Hairpin Coaster - 0, // 4d Magic Carpet - 0, // 4e Submarine Ride - 1, // 4f River Rafts - 0, // 50 (none) - 0, // 51 Enterprise - 0, // 52 (none) - 0, // 53 (none) - 0, // 54 (none) - 1, // 55 (none) - 1, // 56 Inverted Impulse Coaster - 1, // 57 Mini Roller Coaster - 1, // 58 Mine Ride - 1, // 59 LIM Launched Roller Coaster -} - From e9751e00b65fd16d635f10f84ecbc29dc4c6b0f8 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 23 May 2014 19:09:16 +0900 Subject: [PATCH 12/16] move some data tables into C --- src/ride.h | 1 + src/ride_data.c | 195 +++++++++++++++++++++++++++++++++++++++++++++ src/ride_data.h | 4 +- src/ride_ratings.c | 25 ++++-- 4 files changed, 217 insertions(+), 8 deletions(-) diff --git a/src/ride.h b/src/ride.h index eff128da65..d098e8793c 100644 --- a/src/ride.h +++ b/src/ride.h @@ -62,6 +62,7 @@ typedef struct { sint32 var_0F0; uint8 pad_0F4[0x20]; uint8 var_114; + // Track length? Number of track segments? uint8 var_115; uint8 pad_116[0x0F]; sint16 var_124; diff --git a/src/ride_data.c b/src/ride_data.c index 92d70fcb37..f73d809013 100644 --- a/src/ride_data.c +++ b/src/ride_data.c @@ -3,6 +3,9 @@ * being used in various places in the game. * * Data source is 0x0097E3AC + * + * Generating function is here + * https://gist.github.com/kevinburke/eaeb1d8149a6eef0dcc1 */ const bool hasRunningTrack[0x59] = { true, // 0 Spiral Roller coaster @@ -97,3 +100,195 @@ const bool hasRunningTrack[0x59] = { true, // 59 LIM Launched Roller Coaster } +/** + * Data about ride running costs. This is widely adjusted by the upkeep + * function, so values that don't make much sense here (a roller coaster having + * cheaper upkeep than a car ride) are fixed later on. + * + * data generation script: https://gist.github.com/kevinburke/6bcf4a8fcc95faad7bac + */ +const uint8 initialUpkeepCosts[0x59] = { + 41, // 00 Spiral Roller coaster + 40, // 01 Stand Up Coaster + 40, // 02 Suspended Swinging + 40, // 03 Inverted + 40, // 04 Steel Mini Coaster + 60, // 05 Mini Railroad + 65, // 06 Monorail + 40, // 07 Mini Suspended Coaster + 50, // 08 Bumper Boats + 40, // 09 Wooden Wild Mine/Mouse + 40, // 0a Steeplechase/Motorbike/Soap Box Derby + 70, // 0b Car Ride + 50, // 0c Launched Freefall + 40, // 0d Bobsleigh Coaster + 50, // 0e Observation Tower + 40, // 0f Looping Roller Coaster + 40, // 10 Dinghy Slide + 40, // 11 Mine Train Coaster + 60, // 12 Chairlift + 40, // 13 Corkscrew Roller Coaster + 50, // 14 Maze + 50, // 15 Spiral Slide + 50, // 16 Go Karts + 80, // 17 Log Flume + 82, // 18 River Rapids + 50, // 19 Bumper Cars + 50, // 1a Pirate Ship + 50, // 1b Swinging Inverter Ship + 50, // 1c Food Stall + 50, // 1d (none) + 50, // 1e Drink Stall + 50, // 1f (none) + 50, // 20 Shop (all types) + 50, // 21 Merry Go Round + 50, // 22 Balloon Stall (maybe) + 50, // 23 Information Kiosk + 50, // 24 Bathroom + 50, // 25 Ferris Wheel + 50, // 26 Motion Simulator + 50, // 27 3D Cinema + 50, // 28 Gravitron + 50, // 29 Space Rings + 80, // 2a Reverse Freefall Coaster + 50, // 2b Elevator + 44, // 2c Vertical Drop Roller Coaster + 40, // 2d ATM + 50, // 2e Twist + 50, // 2f Haunted House + 45, // 30 First Aid + 50, // 31 Circus Show + 80, // 32 Ghost Train + 43, // 33 Twister Roller Coaster + 40, // 34 Wooden Roller Coaster + 39, // 35 Side-Friction Roller Coaster + 40, // 36 Wild Mouse + 75, // 37 Multi Dimension Coaster + 75, // 38 (none) + 49, // 39 Flying Roller Coaster + 49, // 3a (none) + 39, // 3b Virginia Reel + 70, // 3c Splash Boats + 70, // 3d Mini Helicopters + 49, // 3e Lay-down Roller Coaster + 70, // 3f Suspended Monorail + 49, // 40 (none) + 39, // 41 Reverser Roller Coaster + 47, // 42 Heartline Twister Roller Coaster + 30, // 43 Mini Golf + 10, // 44 Giga Coaster + 50, // 45 Roto-Drop + 90, // 46 Flying Saucers + 30, // 47 Crooked House + 47, // 48 Monorail Cycles + 40, // 49 Compact Inverted Coaster + 60, // 4a Water Coaster + 90, // 4b Air Powered Vertical Coaster + 40, // 4c Inverted Hairpin Coaster + 50, // 4d Magic Carpet + 50, // 4e Submarine Ride + 50, // 4f River Rafts + 50, // 50 (none) + 50, // 51 Enterprise + 50, // 52 (none) + 50, // 53 (none) + 50, // 54 (none) + 40, // 55 (none) + 180, // 56 Inverted Impulse Coaster + 35, // 57 Mini Roller Coaster + 50, // 58 Mine Ride + 42, // 59 LIM Launched Roller Coaster +} + +const uint8 costPerTrackPiece[0x59] = { + 80, // 00 Spiral Roller coaster + 80, // 01 Stand Up Coaster + 80, // 02 Suspended Swinging + 80, // 03 Inverted + 80, // 04 Steel Mini Coaster + 0, // 05 Mini Railroad + 0, // 06 Monorail + 80, // 07 Mini Suspended Coaster + 0, // 08 Bumper Boats + 80, // 09 Wooden Wild Mine/Mouse + 80, // 0a Steeplechase/Motorbike/Soap Box Derby + 0, // 0b Car Ride + 0, // 0c Launched Freefall + 80, // 0d Bobsleigh Coaster + 0, // 0e Observation Tower + 80, // 0f Looping Roller Coaster + 80, // 10 Dinghy Slide + 80, // 11 Mine Train Coaster + 0, // 12 Chairlift + 80, // 13 Corkscrew Roller Coaster + 0, // 14 Maze + 0, // 15 Spiral Slide + 0, // 16 Go Karts + 0, // 17 Log Flume + 0, // 18 River Rapids + 0, // 19 Bumper Cars + 0, // 1a Pirate Ship + 0, // 1b Swinging Inverter Ship + 0, // 1c Food Stall + 0, // 1d (none) + 0, // 1e Drink Stall + 0, // 1f (none) + 0, // 20 Shop (all types) + 0, // 21 Merry Go Round + 0, // 22 Balloon Stall (maybe) + 0, // 23 Information Kiosk + 0, // 24 Bathroom + 0, // 25 Ferris Wheel + 0, // 26 Motion Simulator + 0, // 27 3D Cinema + 0, // 28 Gravitron + 0, // 29 Space Rings + 0, // 2a Reverse Freefall Coaster + 0, // 2b Elevator + 80, // 2c Vertical Drop Roller Coaster + 0, // 2d ATM + 0, // 2e Twist + 0, // 2f Haunted House + 0, // 30 First Aid + 0, // 31 Circus Show + 0, // 32 Ghost Train + 80, // 33 Twister Roller Coaster + 80, // 34 Wooden Roller Coaster + 80, // 35 Side-Friction Roller Coaster + 80, // 36 Wild Mouse + 90, // 37 Multi Dimension Coaster + 90, // 38 (none) + 90, // 39 Flying Roller Coaster + 90, // 3a (none) + 80, // 3b Virginia Reel + 0, // 3c Splash Boats + 0, // 3d Mini Helicopters + 90, // 3e Lay-down Roller Coaster + 0, // 3f Suspended Monorail + 90, // 40 (none) + 80, // 41 Reverser Roller Coaster + 80, // 42 Heartline Twister Roller Coaster + 80, // 43 Mini Golf + 80, // 44 Giga Coaster + 0, // 45 Roto-Drop + 0, // 46 Flying Saucers + 0, // 47 Crooked House + 0, // 48 Monorail Cycles + 80, // 49 Compact Inverted Coaster + 80, // 4a Water Coaster + 0, // 4b Air Powered Vertical Coaster + 80, // 4c Inverted Hairpin Coaster + 0, // 4d Magic Carpet + 0, // 4e Submarine Ride + 0, // 4f River Rafts + 0, // 50 (none) + 0, // 51 Enterprise + 0, // 52 (none) + 0, // 53 (none) + 0, // 54 (none) + 80, // 55 (none) + 80, // 56 Inverted Impulse Coaster + 80, // 57 Mini Roller Coaster + 80, // 58 Mine Ride + 80, // 59 LIM Launched Roller Coaster +} diff --git a/src/ride_data.h b/src/ride_data.h index 4ec9ff2973..5d239a915c 100644 --- a/src/ride_data.h +++ b/src/ride_data.h @@ -18,4 +18,6 @@ * along with this program. If not, see . *****************************************************************************/ -extern const uint8 runningTrack[100]; +extern const uint8 hasRunningTrack[0x59]; +extern const uint8 initialUpkeepCosts[0x59]; +extern const uint8 costPerTrackPiece[0x59]; diff --git a/src/ride_ratings.c b/src/ride_ratings.c index 0b5c93f32c..3428663cb3 100644 --- a/src/ride_ratings.c +++ b/src/ride_ratings.c @@ -71,15 +71,16 @@ uint16 compute_upkeep(rct_ride *ride) { uint8 type_idx = ride->type * 0x12; - // data values here: https://gist.github.com/kevinburke/456fe478b1822580a449 - uint16 upkeep = RCT2_GLOBAL(0x0097E3A8 + type_idx, uint16); + // data stored at 0x0057E3A8, incrementing 18 bytes at a time + uint16 upkeep = initialUpkeepCosts[ride->type]; - uint16 eax = RCT2_GLOBAL(0x0097E3AA + type_idx, uint16); + uint16 trackCost = costPerTrackPiece[ride->type]; uint8 dl = ride->var_115; + dl = dl >> 6; dl = dl & 3; eax = eax * dl; - upkeep += dl; + upkeep += trackCost * dl; uint32 cuml = ride->var_0E4; cuml += ride->var_0E8; @@ -105,16 +106,26 @@ uint16 compute_upkeep(rct_ride *ride) upkeep += 40; } - eax = RCT2_GLOBAL(0x0097E3B0 + type_idx, uint16); + // Originally this data was at 0x0097E3B0 and incrementing in 18 byte + // offsets. The value here for every ride is 80, except for the reverser, + // which is 10 + uint16 eax; + if (ride->type == RIDE_TYPE_REVERSER_ROLLER_COASTER) { + eax = 10; + } else { + eax = 80; + } // not sure what this value is; it's only written to in one place, where // it's incremented. sint16 dx = RCT2_GLOBAL(0x0138B5CC, sint16); upkeep += eax * dx; - eax = RCT2_GLOBAL(0x0097E3B2 + type_idx, uint16); dx = RCT2_GLOBAL(0x0138B5CA, sint16); - upkeep += eax * dx; + // Originally there was a lookup into a table at 0x0097E3B0 and + // incrementing in 18 byte offsets. The value here for every ride was 20, + // so it's been replaced here by the constant. + upkeep += 20 * dx; // these seem to be adhoc adjustments to a ride's upkeep/cost, times // various variables set on the ride itself. From 9592ed0e53f4e982d40c9c22d6193b7097df58b8 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 23 May 2014 20:57:50 +0900 Subject: [PATCH 13/16] move the last bit of data into a table --- src/ride_data.c | 286 +++++++++++++++++++++++++++++++++++++++++++++ src/ride_data.h | 4 + src/ride_ratings.c | 14 +-- 3 files changed, 295 insertions(+), 9 deletions(-) diff --git a/src/ride_data.c b/src/ride_data.c index f73d809013..61b2419fbf 100644 --- a/src/ride_data.c +++ b/src/ride_data.c @@ -292,3 +292,289 @@ const uint8 costPerTrackPiece[0x59] = { 80, // 58 Mine Ride 80, // 59 LIM Launched Roller Coaster } + +/** + * Data initially at 0x0097E3B4 + */ +const uint8 rideUnknownData1[0x59] = { + 10, // 00 Spiral Roller coaster + 10, // 01 Stand Up Coaster + 20, // 02 Suspended Swinging + 13, // 03 Inverted + 8, // 04 Steel Mini Coaster + 10, // 05 Mini Railroad + 10, // 06 Monorail + 10, // 07 Mini Suspended Coaster + 4, // 08 Bumper Boats + 9, // 09 Wooden Wild Mine/Mouse + 10, // 0a Steeplechase/Motorbike/Soap Box Derby + 8, // 0b Car Ride + 10, // 0c Launched Freefall + 10, // 0d Bobsleigh Coaster + 10, // 0e Observation Tower + 10, // 0f Looping Roller Coaster + 4, // 10 Dinghy Slide + 10, // 11 Mine Train Coaster + 4, // 12 Chairlift + 11, // 13 Corkscrew Roller Coaster + 0, // 14 Maze + 0, // 15 Spiral Slide + 8, // 16 Go Karts + 9, // 17 Log Flume + 10, // 18 River Rapids + 5, // 19 Bumper Cars + 0, // 1a Pirate Ship + 0, // 1b Swinging Inverter Ship + 0, // 1c Food Stall + 0, // 1d (none) + 0, // 1e Drink Stall + 0, // 1f (none) + 0, // 20 Shop (all types) + 0, // 21 Merry Go Round + 0, // 22 Balloon Stall (maybe) + 0, // 23 Information Kiosk + 0, // 24 Bathroom + 0, // 25 Ferris Wheel + 0, // 26 Motion Simulator + 0, // 27 3D Cinema + 0, // 28 Gravitron + 0, // 29 Space Rings + 0, // 2a Reverse Freefall Coaster + 10, // 2b Elevator + 11, // 2c Vertical Drop Roller Coaster + 0, // 2d ATM + 0, // 2e Twist + 0, // 2f Haunted House + 0, // 30 First Aid + 0, // 31 Circus Show + 8, // 32 Ghost Train + 11, // 33 Twister Roller Coaster + 10, // 34 Wooden Roller Coaster + 10, // 35 Side-Friction Roller Coaster + 9, // 36 Wild Mouse + 11, // 37 Multi Dimension Coaster + 11, // 38 (none) + 11, // 39 Flying Roller Coaster + 11, // 3a (none) + 10, // 3b Virginia Reel + 9, // 3c Splash Boats + 8, // 3d Mini Helicopters + 11, // 3e Lay-down Roller Coaster + 10, // 3f Suspended Monorail + 11, // 40 (none) + 10, // 41 Reverser Roller Coaster + 11, // 42 Heartline Twister Roller Coaster + 11, // 43 Mini Golf + 12, // 44 Giga Coaster + 10, // 45 Roto-Drop + 5, // 46 Flying Saucers + 0, // 47 Crooked House + 8, // 48 Monorail Cycles + 13, // 49 Compact Inverted Coaster + 8, // 4a Water Coaster + 0, // 4b Air Powered Vertical Coaster + 9, // 4c Inverted Hairpin Coaster + 0, // 4d Magic Carpet + 4, // 4e Submarine Ride + 9, // 4f River Rafts + 0, // 50 (none) + 0, // 51 Enterprise + 0, // 52 (none) + 0, // 53 (none) + 0, // 54 (none) + 11, // 55 (none) + 11, // 56 Inverted Impulse Coaster + 8, // 57 Mini Roller Coaster + 10, // 58 Mine Ride + 9, // 59 LIM Launched Roller Coaster +} + +/** + * Data at 0x0097E3B6, originally set to either be 3 or 0 and replaced here by + * a boolean table. This may be exactly the same as hasRunningTrack above. + */ +const bool rideUnknownData2[0x59] = { + true, // 00 Spiral Roller coaster + true, // 01 Stand Up Coaster + true, // 02 Suspended Swinging + true, // 03 Inverted + true, // 04 Steel Mini Coaster + true, // 05 Mini Railroad + true, // 06 Monorail + true, // 07 Mini Suspended Coaster + false, // 08 Bumper Boats + true, // 09 Wooden Wild Mine/Mouse + true, // 0a Steeplechase/Motorbike/Soap Box Derby + true, // 0b Car Ride + false, // 0c Launched Freefall + true, // 0d Bobsleigh Coaster + false, // 0e Observation Tower + true, // 0f Looping Roller Coaster + true, // 10 Dinghy Slide + true, // 11 Mine Train Coaster + true, // 12 Chairlift + true, // 13 Corkscrew Roller Coaster + false, // 14 Maze + false, // 15 Spiral Slide + false, // 16 Go Karts + false, // 17 Log Flume + false, // 18 River Rapids + false, // 19 Bumper Cars + false, // 1a Pirate Ship + false, // 1b Swinging Inverter Ship + false, // 1c Food Stall + false, // 1d (none) + false, // 1e Drink Stall + false, // 1f (none) + false, // 20 Shop (all types) + false, // 21 Merry Go Round + false, // 22 Balloon Stall (maybe) + false, // 23 Information Kiosk + false, // 24 Bathroom + false, // 25 Ferris Wheel + false, // 26 Motion Simulator + false, // 27 3D Cinema + false, // 28 Gravitron + false, // 29 Space Rings + false, // 2a Reverse Freefall Coaster + false, // 2b Elevator + true, // 2c Vertical Drop Roller Coaster + false, // 2d ATM + false, // 2e Twist + false, // 2f Haunted House + false, // 30 First Aid + false, // 31 Circus Show + true, // 32 Ghost Train + true, // 33 Twister Roller Coaster + true, // 34 Wooden Roller Coaster + true, // 35 Side-Friction Roller Coaster + true, // 36 Wild Mouse + true, // 37 Multi Dimension Coaster + true, // 38 (none) + true, // 39 Flying Roller Coaster + true, // 3a (none) + true, // 3b Virginia Reel + false, // 3c Splash Boats + true, // 3d Mini Helicopters + true, // 3e Lay-down Roller Coaster + true, // 3f Suspended Monorail + true, // 40 (none) + true, // 41 Reverser Roller Coaster + true, // 42 Heartline Twister Roller Coaster + true, // 43 Mini Golf + true, // 44 Giga Coaster + false, // 45 Roto-Drop + false, // 46 Flying Saucers + false, // 47 Crooked House + true, // 48 Monorail Cycles + true, // 49 Compact Inverted Coaster + true, // 4a Water Coaster + false, // 4b Air Powered Vertical Coaster + true, // 4c Inverted Hairpin Coaster + false, // 4d Magic Carpet + false, // 4e Submarine Ride + false, // 4f River Rafts + false, // 50 (none) + false, // 51 Enterprise + false, // 52 (none) + false, // 53 (none) + false, // 54 (none) + true, // 55 (none) + true, // 56 Inverted Impulse Coaster + true, // 57 Mini Roller Coaster + true, // 58 Mine Ride + true, // 59 LIM Launched Roller Coaster +} + +const uint8 rideUnknownData3[0x59] = { + 10, // 00 Spiral Roller coaster + 10, // 01 Stand Up Coaster + 10, // 02 Suspended Swinging + 10, // 03 Inverted + 5, // 04 Steel Mini Coaster + 5, // 05 Mini Railroad + 10, // 06 Monorail + 10, // 07 Mini Suspended Coaster + 0, // 08 Bumper Boats + 10, // 09 Wooden Wild Mine/Mouse + 10, // 0a Steeplechase/Motorbike/Soap Box Derby + 5, // 0b Car Ride + 0, // 0c Launched Freefall + 10, // 0d Bobsleigh Coaster + 0, // 0e Observation Tower + 10, // 0f Looping Roller Coaster + 10, // 10 Dinghy Slide + 10, // 11 Mine Train Coaster + 10, // 12 Chairlift + 10, // 13 Corkscrew Roller Coaster + 0, // 14 Maze + 0, // 15 Spiral Slide + 0, // 16 Go Karts + 10, // 17 Log Flume + 10, // 18 River Rapids + 0, // 19 Bumper Cars + 0, // 1a Pirate Ship + 0, // 1b Swinging Inverter Ship + 0, // 1c Food Stall + 0, // 1d (none) + 0, // 1e Drink Stall + 0, // 1f (none) + 0, // 20 Shop (all types) + 0, // 21 Merry Go Round + 0, // 22 Balloon Stall (maybe) + 0, // 23 Information Kiosk + 0, // 24 Bathroom + 0, // 25 Ferris Wheel + 0, // 26 Motion Simulator + 0, // 27 3D Cinema + 0, // 28 Gravitron + 0, // 29 Space Rings + 10, // 2a Reverse Freefall Coaster + 0, // 2b Elevator + 10, // 2c Vertical Drop Roller Coaster + 0, // 2d ATM + 0, // 2e Twist + 0, // 2f Haunted House + 0, // 30 First Aid + 0, // 31 Circus Show + 5, // 32 Ghost Train + 10, // 33 Twister Roller Coaster + 10, // 34 Wooden Roller Coaster + 10, // 35 Side-Friction Roller Coaster + 10, // 36 Wild Mouse + 15, // 37 Multi Dimension Coaster + 15, // 38 (none) + 15, // 39 Flying Roller Coaster + 15, // 3a (none) + 10, // 3b Virginia Reel + 10, // 3c Splash Boats + 5, // 3d Mini Helicopters + 15, // 3e Lay-down Roller Coaster + 10, // 3f Suspended Monorail + 15, // 40 (none) + 10, // 41 Reverser Roller Coaster + 10, // 42 Heartline Twister Roller Coaster + 10, // 43 Mini Golf + 40, // 44 Giga Coaster + 0, // 45 Roto-Drop + 0, // 46 Flying Saucers + 0, // 47 Crooked House + 5, // 48 Monorail Cycles + 10, // 49 Compact Inverted Coaster + 10, // 4a Water Coaster + 10, // 4b Air Powered Vertical Coaster + 10, // 4c Inverted Hairpin Coaster + 0, // 4d Magic Carpet + 0, // 4e Submarine Ride + 10, // 4f River Rafts + 0, // 50 (none) + 0, // 51 Enterprise + 0, // 52 (none) + 0, // 53 (none) + 0, // 54 (none) + 10, // 55 (none) + 10, // 56 Inverted Impulse Coaster + 10, // 57 Mini Roller Coaster + 10, // 58 Mine Ride + 10, // 59 LIM Launched Roller Coaster +} diff --git a/src/ride_data.h b/src/ride_data.h index 5d239a915c..a6fcfcbd6c 100644 --- a/src/ride_data.h +++ b/src/ride_data.h @@ -21,3 +21,7 @@ extern const uint8 hasRunningTrack[0x59]; extern const uint8 initialUpkeepCosts[0x59]; extern const uint8 costPerTrackPiece[0x59]; + +extern const uint8 rideUnknownData1[0x59]; +extern const bool rideUnknownData2[0x59]; +extern const uint8 rideUnknownData3[0x59]; diff --git a/src/ride_ratings.c b/src/ride_ratings.c index 3428663cb3..7eea972220 100644 --- a/src/ride_ratings.c +++ b/src/ride_ratings.c @@ -69,8 +69,6 @@ void crooked_house_excitement(rct_ride *ride) */ uint16 compute_upkeep(rct_ride *ride) { - uint8 type_idx = ride->type * 0x12; - // data stored at 0x0057E3A8, incrementing 18 bytes at a time uint16 upkeep = initialUpkeepCosts[ride->type]; @@ -79,7 +77,6 @@ uint16 compute_upkeep(rct_ride *ride) dl = dl >> 6; dl = dl & 3; - eax = eax * dl; upkeep += trackCost * dl; uint32 cuml = ride->var_0E4; @@ -131,17 +128,16 @@ uint16 compute_upkeep(rct_ride *ride) // various variables set on the ride itself. // https://gist.github.com/kevinburke/e19b803cd2769d96c540 - eax = RCT2_GLOBAL(0x0097E3B4 + type_idx, uint16); - upkeep += eax * ride->var_0C8; + upkeep += rideUnknownData1[ride->type] * ride->var_0C8; // either set to 3 or 0, extra boosts for some rides including mini golf - eax = RCT2_GLOBAL(0x0097E3B6 + type_idx, uint16); - upkeep += eax * ride->var_0C9; + if (rideUnknownData2[ride->type]) { + upkeep += 3 * ride->var_0C9; + } // slight upkeep boosts for some rides - 5 for mini railroad, 10 for log // flume/rapids, 10 for roller coaster, 28 for giga coaster - eax = RCT2_GLOBAL(0x0097E3B8 + type_idx, uint16); - upkeep += eax * ride->var_0C7; + upkeep += rideUnknownData3[ride->type] * ride->var_0C7; if (ride->mode == RIDE_MODE_REVERSE_INCLINED_SHUTTLE) { upkeep += 30; From a35fc6bdefa4264e8b369198d122fa4b16a78789 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 23 May 2014 21:18:45 +0900 Subject: [PATCH 14/16] add new files to sln --- projects/openrct2.vcxproj | 2 ++ projects/openrct2.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 66eca6faa9..c7063f8a0c 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -33,6 +33,7 @@ + @@ -72,6 +73,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 2fe5f4120e..2c496cfa09 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -78,6 +78,9 @@ Header Files + + Header Files + Header Files @@ -197,6 +200,9 @@ Source Files + + Source Files + Source Files From 75f90559a544b2e628638908d186dafe59361406 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 23 May 2014 05:18:58 -0700 Subject: [PATCH 15/16] Fix build errors. --- src/ride_data.h | 2 ++ src/ride_ratings.c | 18 ++++++++++-------- src/ride_ratings.h | 5 +++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ride_data.h b/src/ride_data.h index a6fcfcbd6c..216d2ddea3 100644 --- a/src/ride_data.h +++ b/src/ride_data.h @@ -18,6 +18,8 @@ * along with this program. If not, see . *****************************************************************************/ +#include + extern const uint8 hasRunningTrack[0x59]; extern const uint8 initialUpkeepCosts[0x59]; extern const uint8 costPerTrackPiece[0x59]; diff --git a/src/ride_ratings.c b/src/ride_ratings.c index 7eea972220..48dafad27a 100644 --- a/src/ride_ratings.c +++ b/src/ride_ratings.c @@ -19,7 +19,9 @@ *****************************************************************************/ #include "ride.h" +#include "ride_ratings.h" #include "ride_data.h" +#include "addresses.h" /** * rct2: 0x0065C4D4 @@ -34,9 +36,9 @@ void crooked_house_excitement(rct_ride *ride) ride->var_198 = 5; sub_655FD6(ride); - excitement = 215; - intensity = 62; - nausea = 34; + sint16 excitement = 215; + sint16 intensity = 62; + sint16 nausea = 34; // NB this should get marked out by the compiler, if it's smart. excitement = apply_intensity_penalty(excitement, intensity); @@ -170,16 +172,16 @@ rating_tuple per_ride_rating_adjustments(rct_ride *ride, sint16 excitement, { // NB: The table here is allocated dynamically. Reading the exe will tell // you nothing - subtype_p = RCT2_GLOBAL(0x009ACFA4 + ride->subtype * 4, uint32); + uint32 subtype_p = RCT2_GLOBAL(0x009ACFA4 + ride->subtype * 4, uint32); // example value here: 12 (?) - sint16 ctr = RCT2_GLOBAL(subtype_p + 0x1b2); + sint16 ctr = RCT2_GLOBAL(subtype_p + 0x1b2, sint16); excitement = excitement + ((excitement * ctr) >> 7); - sint16 ctr = RCT2_GLOBAL(subtype_p + 0x1b3); + ctr = RCT2_GLOBAL(subtype_p + 0x1b3, sint16); intensity = intensity + ((intensity * ctr) >> 7); - sint16 ctr = RCT2_GLOBAL(subtype_p + 0x1b4); + ctr = RCT2_GLOBAL(subtype_p + 0x1b4, sint16); nausea = nausea + ((nausea * ctr) >> 7); // As far as I can tell, this flag detects whether the ride is a roller @@ -254,5 +256,5 @@ void sub_655FD6(rct_ride *ride) // https://gist.github.com/kevinburke/5eebcda14d94e6ee99c0 al -= RCT2_ADDRESS(0x0097D7C9, uint8)[4 * ride->type]; al = al << 1; - ride->var198 += al; + ride->var_198 += al; } diff --git a/src/ride_ratings.h b/src/ride_ratings.h index fb6c922efd..2b9316b581 100644 --- a/src/ride_ratings.h +++ b/src/ride_ratings.h @@ -26,3 +26,8 @@ typedef struct { } rating_tuple; void crooked_house_excitement(rct_ride *ride); +void sub_655FD6(rct_ride *ride); +sint16 apply_intensity_penalty(sint16 excitement, sint16 intensity); +rating_tuple per_ride_rating_adjustments(rct_ride *ride, sint16 excitement, + sint16 intensity, sint16 nausea); +uint16 compute_upkeep(rct_ride *ride); From de3ab24fa190a5966ac5c44deb3e031868640738 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 23 May 2014 05:37:52 -0700 Subject: [PATCH 16/16] fix more build errors --- src/ride_data.c | 29 +++++++++++++++++------------ src/ride_data.h | 13 +++++++------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/ride_data.c b/src/ride_data.c index 61b2419fbf..a25a244c7b 100644 --- a/src/ride_data.c +++ b/src/ride_data.c @@ -7,7 +7,12 @@ * Generating function is here * https://gist.github.com/kevinburke/eaeb1d8149a6eef0dcc1 */ -const bool hasRunningTrack[0x59] = { + +#include +#include "ride_data.h" +#include "rct2.h" + +const bool hasRunningTrack[0x60] = { true, // 0 Spiral Roller coaster true, // 1 Stand Up Coaster true, // 2 Suspended Swinging @@ -98,7 +103,7 @@ const bool hasRunningTrack[0x59] = { true, // 57 Mini Roller Coaster true, // 58 Mine Ride true, // 59 LIM Launched Roller Coaster -} +}; /** * Data about ride running costs. This is widely adjusted by the upkeep @@ -107,7 +112,7 @@ const bool hasRunningTrack[0x59] = { * * data generation script: https://gist.github.com/kevinburke/6bcf4a8fcc95faad7bac */ -const uint8 initialUpkeepCosts[0x59] = { +const uint8 initialUpkeepCosts[0x60] = { 41, // 00 Spiral Roller coaster 40, // 01 Stand Up Coaster 40, // 02 Suspended Swinging @@ -198,9 +203,9 @@ const uint8 initialUpkeepCosts[0x59] = { 35, // 57 Mini Roller Coaster 50, // 58 Mine Ride 42, // 59 LIM Launched Roller Coaster -} +}; -const uint8 costPerTrackPiece[0x59] = { +const uint8 costPerTrackPiece[0x60] = { 80, // 00 Spiral Roller coaster 80, // 01 Stand Up Coaster 80, // 02 Suspended Swinging @@ -291,12 +296,12 @@ const uint8 costPerTrackPiece[0x59] = { 80, // 57 Mini Roller Coaster 80, // 58 Mine Ride 80, // 59 LIM Launched Roller Coaster -} +}; /** * Data initially at 0x0097E3B4 */ -const uint8 rideUnknownData1[0x59] = { +const uint8 rideUnknownData1[0x60] = { 10, // 00 Spiral Roller coaster 10, // 01 Stand Up Coaster 20, // 02 Suspended Swinging @@ -387,13 +392,13 @@ const uint8 rideUnknownData1[0x59] = { 8, // 57 Mini Roller Coaster 10, // 58 Mine Ride 9, // 59 LIM Launched Roller Coaster -} +}; /** * Data at 0x0097E3B6, originally set to either be 3 or 0 and replaced here by * a boolean table. This may be exactly the same as hasRunningTrack above. */ -const bool rideUnknownData2[0x59] = { +const bool rideUnknownData2[0x60] = { true, // 00 Spiral Roller coaster true, // 01 Stand Up Coaster true, // 02 Suspended Swinging @@ -484,9 +489,9 @@ const bool rideUnknownData2[0x59] = { true, // 57 Mini Roller Coaster true, // 58 Mine Ride true, // 59 LIM Launched Roller Coaster -} +}; -const uint8 rideUnknownData3[0x59] = { +const uint8 rideUnknownData3[0x60] = { 10, // 00 Spiral Roller coaster 10, // 01 Stand Up Coaster 10, // 02 Suspended Swinging @@ -577,4 +582,4 @@ const uint8 rideUnknownData3[0x59] = { 10, // 57 Mini Roller Coaster 10, // 58 Mine Ride 10, // 59 LIM Launched Roller Coaster -} +}; \ No newline at end of file diff --git a/src/ride_data.h b/src/ride_data.h index 216d2ddea3..a3f35a171a 100644 --- a/src/ride_data.h +++ b/src/ride_data.h @@ -19,11 +19,12 @@ *****************************************************************************/ #include +#include "rct2.h" -extern const uint8 hasRunningTrack[0x59]; -extern const uint8 initialUpkeepCosts[0x59]; -extern const uint8 costPerTrackPiece[0x59]; +extern const uint8 hasRunningTrack[0x60]; +extern const uint8 initialUpkeepCosts[0x60]; +extern const uint8 costPerTrackPiece[0x60]; -extern const uint8 rideUnknownData1[0x59]; -extern const bool rideUnknownData2[0x59]; -extern const uint8 rideUnknownData3[0x59]; +extern const uint8 rideUnknownData1[0x60]; +extern const bool rideUnknownData2[0x60]; +extern const uint8 rideUnknownData3[0x60];