From da0236ef8443e8e80603415eb6b4ff76c89ff428 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 6 May 2014 21:09:08 +0100 Subject: [PATCH 1/5] Labeled init values for Shearwood Forest --- src/park.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/park.c b/src/park.c index 6beb551b6c..f80ca4839b 100644 --- a/src/park.c +++ b/src/park.c @@ -98,6 +98,8 @@ int calculate_park_rating() // -150 to +3 based on a range of guests from 0 to 2000 result -= 150 - (min(2000, RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)) / 13); + return result; + //1016 good // Guests, happiness, ? num_happy_peeps = 0; @@ -126,6 +128,8 @@ int calculate_park_rating() if (_bp >= 0) result -= _bp * 7; } + return result; + //998 980 // Rides { @@ -166,6 +170,7 @@ int calculate_park_rating() _bx = min(1000, _bx); result -= 200 - ((_ax + _bx) / 10); } + //826 // Litter { @@ -183,6 +188,7 @@ int calculate_park_rating() } result -= 600 - (4 * (150 - min(150, num_litter))); } + //826 // Rides { @@ -222,10 +228,10 @@ int calculate_park_rating() result += 100 - _ax - _bx; } } - + //809 result -= RCT2_GLOBAL(0x0135882E, sint16); result = clamp(0, result, 999); - + //809 return result; } From b52c5c0b2dea65171dbe3a2a4a9537fc82c93955 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 6 May 2014 21:54:42 +0100 Subject: [PATCH 2/5] Peeps part now working --- src/park.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/park.c b/src/park.c index 19d5adf40c..6fcc3bbbb7 100644 --- a/src/park.c +++ b/src/park.c @@ -78,8 +78,8 @@ int calculate_park_rating() { { int eax, ebx, ecx, edx, esi, edi, ebp; - RCT2_CALLFUNC_X(0x00669EAA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - return eax & 0xFFFF; + //RCT2_CALLFUNC_X(0x00669EAA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + //return eax & 0xFFFF; } @@ -98,7 +98,7 @@ int calculate_park_rating() // -150 to +3 based on a range of guests from 0 to 2000 result -= 150 - (min(2000, RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)) / 13); - return result; + //return result; //1016 good // Guests, happiness, ? @@ -117,19 +117,21 @@ int calculate_park_rating() if (peep->var_C6 <= 89) _bp++; } - + // Peep happiness -500 to +0 result -= 500; - if (num_happy_peeps > 0) - result += 2 * min(250, (RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) * 300) / num_happy_peeps); + //516 good + + if (RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) > 0) + result += 2 * min(250, (num_happy_peeps * 300) / RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)); // ? _bp -= 25; if (_bp >= 0) result -= _bp * 7; } - return result; - //998 980 + + //998 good // Rides { From 8ddfc136f6affc0e44220906def2790422791fa0 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Wed, 7 May 2014 18:57:50 +0100 Subject: [PATCH 3/5] Fixed bug in second ride related equations --- src/park.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/park.c b/src/park.c index 6fcc3bbbb7..e10c0a06fb 100644 --- a/src/park.c +++ b/src/park.c @@ -98,7 +98,6 @@ int calculate_park_rating() // -150 to +3 based on a range of guests from 0 to 2000 result -= 150 - (min(2000, RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)) / 13); - //return result; //1016 good // Guests, happiness, ? @@ -173,7 +172,7 @@ int calculate_park_rating() result -= 200 - ((_ax + _bx) / 10); } //826 - + // Litter { rct_litter* litter; @@ -215,13 +214,15 @@ int calculate_park_rating() result -= 100; if (num_rides > 0) { + short temp_bx; + temp_bx = _bx; _bx = _ax / num_rides; - _ax = _bx / num_rides; + _ax = temp_bx / num_rides; _bx -= 46; - if (_bx >= 0) + if (_bx < 0) _bx = -_bx; _ax -= 65; - if (_ax >= 0) + if (_ax < 0) _ax = -_ax; _bx /= 2; _ax /= 2; From 4e4fa93e14b6f669950ce99c9bca36e4c2260291 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Wed, 7 May 2014 19:44:13 +0100 Subject: [PATCH 4/5] Fixed litter bug. Removed debug notes. Made rides code more readable --- src/park.c | 108 +++++++++++++++++------------------------------------ 1 file changed, 34 insertions(+), 74 deletions(-) diff --git a/src/park.c b/src/park.c index e10c0a06fb..5b11ee4024 100644 --- a/src/park.c +++ b/src/park.c @@ -76,13 +76,6 @@ int park_calculate_size() */ int calculate_park_rating() { - { - int eax, ebx, ecx, edx, esi, edi, ebp; - //RCT2_CALLFUNC_X(0x00669EAA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - //return eax & 0xFFFF; - } - - int result; result = 1150; @@ -98,7 +91,6 @@ int calculate_park_rating() // -150 to +3 based on a range of guests from 0 to 2000 result -= 150 - (min(2000, RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)) / 13); - //1016 good // Guests, happiness, ? num_happy_peeps = 0; @@ -119,7 +111,6 @@ int calculate_park_rating() // Peep happiness -500 to +0 result -= 500; - //516 good if (RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) > 0) result += 2 * min(250, (num_happy_peeps * 300) / RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)); @@ -130,13 +121,11 @@ int calculate_park_rating() result -= _bp * 7; } - //998 good - // Rides { int i; - short _ax, _bx; - int num_rides; + short _ax, total_ride_intensity = 0, total_ride_excitement = 0, average_intensity, average_excitement; + int num_rides, num_exciting_rides = 0; rct_ride* ride; // @@ -148,31 +137,44 @@ int calculate_park_rating() if (ride->type == RIDE_TYPE_NULL) continue; _ax += 100 - ride->var_199; + + if (ride->excitement != -1){ + total_ride_excitement += ride->excitement / 8; + total_ride_intensity += ride->intensity / 8; + num_exciting_rides++; + } num_rides++; } result -= 200; if (num_rides > 0) result += (_ax / num_rides) * 2; - // - _ax = 0; - _bx = 0; - for (i = 0; i < 255; i++) { - ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); + result -= 100; - if (ride->type == RIDE_TYPE_NULL) - continue; - if (ride->excitement == -1) - continue; - _ax += ride->excitement / 8; - _bx += ride->intensity / 8; + if (num_exciting_rides>0){ + average_excitement = total_ride_excitement / num_exciting_rides; + average_intensity = total_ride_intensity / num_exciting_rides; + + average_excitement -= 46; + if (average_excitement < 0){ + average_excitement = -average_excitement; + } + + average_intensity -= 65; + if (average_intensity < 0){ + average_intensity = -average_intensity; + } + + average_excitement = min(average_excitement / 2, 50); + average_intensity = min(average_intensity / 2, 50); + result += 100 - average_excitement - average_intensity; } - _ax = min(1000, _ax); - _bx = min(1000, _bx); - result -= 200 - ((_ax + _bx) / 10); + + total_ride_excitement = min(1000, total_ride_excitement); + total_ride_intensity = min(1000, total_ride_intensity); + result -= 200 - ((total_ride_excitement + total_ride_intensity) / 10); } - //826 - + // Litter { rct_litter* litter; @@ -184,57 +186,15 @@ int calculate_park_rating() litter = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].litter); // Guessing this eliminates recently dropped litter - if (litter->var_24 - RCT2_GLOBAL(0x00F663AC, sint32) >= 7680) + if ((uint32)(litter->var_24 - RCT2_GLOBAL(0x00F663AC, sint32)) >= 7680) num_litter++; } result -= 600 - (4 * (150 - min(150, num_litter))); } - //826 - - // Rides - { - int i, num_rides; - short _ax, _bx; - rct_ride* ride; - - num_rides = 0; - _ax = 0; - _bx = 0; - for (i = 0; i < 255; i++) { - ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); - - if (ride->type == RIDE_TYPE_NULL) - continue; - if (ride->excitement == -1) - continue; - _ax += ride->excitement / 8; - _bx += ride->intensity / 8; - num_rides++; - } - - result -= 100; - if (num_rides > 0) { - short temp_bx; - temp_bx = _bx; - _bx = _ax / num_rides; - _ax = temp_bx / num_rides; - _bx -= 46; - if (_bx < 0) - _bx = -_bx; - _ax -= 65; - if (_ax < 0) - _ax = -_ax; - _bx /= 2; - _ax /= 2; - _bx = min(50, _bx); - _ax = min(50, _ax); - result += 100 - _ax - _bx; - } - } - //809 + result -= RCT2_GLOBAL(0x0135882E, sint16); result = clamp(0, result, 999); - //809 + //934 return result; } From bfd4dbcbe9ba7e0896a2775af78499f5ed65bea2 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Wed, 7 May 2014 19:46:30 +0100 Subject: [PATCH 5/5] Changed litter var_24 to unsigned --- src/park.c | 3 +-- src/sprite.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/park.c b/src/park.c index 5b11ee4024..54e49521e0 100644 --- a/src/park.c +++ b/src/park.c @@ -186,7 +186,7 @@ int calculate_park_rating() litter = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].litter); // Guessing this eliminates recently dropped litter - if ((uint32)(litter->var_24 - RCT2_GLOBAL(0x00F663AC, sint32)) >= 7680) + if (litter->var_24 - RCT2_GLOBAL(0x00F663AC, uint32) >= 7680) num_litter++; } result -= 600 - (4 * (150 - min(150, num_litter))); @@ -194,7 +194,6 @@ int calculate_park_rating() result -= RCT2_GLOBAL(0x0135882E, sint16); result = clamp(0, result, 999); - //934 return result; } diff --git a/src/sprite.h b/src/sprite.h index 5a3a071ba0..a51e448c41 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -43,7 +43,7 @@ typedef struct { uint32 pad_00; uint16 next; // 0x04 uint8 pad_06[0x1E]; - sint32 var_24; + uint32 var_24; } rct_litter; typedef struct {