From c788f36787b2e3198b9c34f77dcb3c1724c2a5f3 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 1 May 2014 15:07:51 +0100 Subject: [PATCH 01/29] 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; From 38821f152a0b77f4846258528342f35c200ebcf7 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Thu, 1 May 2014 19:15:02 +0200 Subject: [PATCH 02/29] Start implementation of scenario_update. --- src/game.c | 2 ++ src/scenario.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/scenario.h | 1 + 3 files changed, 74 insertions(+) diff --git a/src/game.c b/src/game.c index d5f909d3b1..69b13b5894 100644 --- a/src/game.c +++ b/src/game.c @@ -27,6 +27,7 @@ #include "news_item.h" #include "osinterface.h" #include "peep.h" +#include "scenario.h" #include "screenshot.h" #include "strings.h" #include "tutorial.h" @@ -137,6 +138,7 @@ void game_logic_update() RCT2_CALLPROC_EBPSAFE(0x0068B089); RCT2_CALLPROC_EBPSAFE(0x006C44B1); // update_objective + scenario_update(); climate_update(); RCT2_CALLPROC_EBPSAFE(0x006646E1); RCT2_CALLPROC_EBPSAFE(0x006A876D); diff --git a/src/scenario.c b/src/scenario.c index 6eee3c4849..7cb0a59032 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -22,6 +22,7 @@ #include #include "addresses.h" +#include "date.h" #include "game.h" #include "map.h" #include "news_item.h" @@ -466,3 +467,73 @@ void scenario_load_and_play(rct_scenario_basic *scenario) RCT2_CALLPROC_EBPSAFE(0x00678461); } + + + +void scenario_update() +{ + uint8 screen_flags = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8); + uint32 current_day = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16); + uint8 month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7; + uint8 current_days_in_month = days_in_month[month]; + uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8); + + if (screen_flags & (~SCREEN_FLAGS_PLAYING)) // only in normal play mode + return; + + if ((current_days_in_month * (current_day + 4)) >> 16 != (current_days_in_month * current_day) >> 16) { + // daily checks + + RCT2_CALLPROC_EBPSAFE(0x0069E79A); // objective_finance_mystery1 + RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps update loop + RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time + RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 + if (objective_type == 10 || objective_type == 9 || objective_type == 8 || + objective_type == 6 || objective_type == 5) { + RCT2_CALLPROC_EBPSAFE(0x0066A4B2); // objective daily checks + } + } + + + if ( (unsigned int)((4 * current_day) & 0xFFFF) >= 0xFFEFu) { + // weekly checks + RCT2_CALLPROC_EBPSAFE(0x006C18A9); + RCT2_CALLPROC_EBPSAFE(0x00684DA5); + RCT2_CALLPROC_EBPSAFE(0x0069E092); + RCT2_CALLPROC_EBPSAFE(0x0069E0C1); + RCT2_CALLPROC_EBPSAFE(0x0069BF41); + RCT2_CALLPROC_EBPSAFE(0x006B7A5E); + RCT2_CALLPROC_EBPSAFE(0x006AC916); + + if (month <= 1 && RCT2_GLOBAL(0x009ADAE0, sint32) != -1 && RCT2_GLOBAL(0x009ADAE0 + 14, uint16) & 1) { + for (int i = 0; i < 100; ++i) { + int carry; + RCT2_CALLPROC_EBPSAFE(0x006744A9); // clears carry flag on failure -.- + __asm mov carry, 0; + __asm adc carry, 0; + if (!carry) + break; + } + } + RCT2_CALLPROC_EBPSAFE(0x0066A231); + RCT2_CALLPROC_EBPSAFE(0x0066A348); + } + + if ( (unsigned int)((2 * current_day) & 0xFFFF) + 8 >= 0x10000) { + // biweekly checks + RCT2_CALLPROC_EBPSAFE(0x006AC885); + } + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = current_day + 4; + if (current_day + 4 > 0x10000) { + // month ends actions + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; + RCT2_GLOBAL(0x009A9804, uint32) |= 2; + RCT2_CALLPROC_EBPSAFE(0x0069DEAD); + RCT2_CALLPROC_EBPSAFE(0x0066A4B2); // objective daily checks + RCT2_CALLPROC_EBPSAFE(0x0066A80E); + RCT2_CALLPROC_EBPSAFE(0x0066A86C); + } + +} + diff --git a/src/scenario.h b/src/scenario.h index 45eacf8a42..1589b7621f 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -110,5 +110,6 @@ enum { void scenario_load_list(); void scenario_load(char *path); void scenario_load_and_play(rct_scenario_basic *scenario); +void scenario_update(); #endif From c0f2b5f3838b1a54359ff0321c30473506a7d8e0 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Thu, 1 May 2014 19:27:42 +0200 Subject: [PATCH 03/29] Make scenario update timeframes clearer --- src/scenario.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index 7cb0a59032..7440f153f8 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -473,15 +473,16 @@ void scenario_load_and_play(rct_scenario_basic *scenario) void scenario_update() { uint8 screen_flags = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8); - uint32 current_day = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16); - uint8 month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7; - uint8 current_days_in_month = days_in_month[month]; - uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8); + uint32 month_tick = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16), + next_month_tick = month_tick + 4; + uint8 month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7, + current_days_in_month = days_in_month[month], + objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8); if (screen_flags & (~SCREEN_FLAGS_PLAYING)) // only in normal play mode return; - if ((current_days_in_month * (current_day + 4)) >> 16 != (current_days_in_month * current_day) >> 16) { + if ((current_days_in_month * next_month_tick) >> 16 != (current_days_in_month * month_tick) >> 16) { // daily checks RCT2_CALLPROC_EBPSAFE(0x0069E79A); // objective_finance_mystery1 @@ -495,7 +496,8 @@ void scenario_update() } - if ( (unsigned int)((4 * current_day) & 0xFFFF) >= 0xFFEFu) { + //if ( (unsigned int)((4 * current_day) & 0xFFFF) >= 0xFFEFu) { + if ( next_month_tick % 0x4000 == 0) { // weekly checks RCT2_CALLPROC_EBPSAFE(0x006C18A9); RCT2_CALLPROC_EBPSAFE(0x00684DA5); @@ -519,13 +521,14 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x0066A348); } - if ( (unsigned int)((2 * current_day) & 0xFFFF) + 8 >= 0x10000) { + //if ( (unsigned int)((2 * current_day) & 0xFFFF) >= 0xFFF8) { + if (next_month_tick % 0x8000 == 0) { // biweekly checks RCT2_CALLPROC_EBPSAFE(0x006AC885); } - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = current_day + 4; - if (current_day + 4 > 0x10000) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; + if (next_month_tick > 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; RCT2_GLOBAL(0x009A9804, uint32) |= 2; From e9e99b486998c5effc839d9934300974c0391036 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Thu, 1 May 2014 22:58:44 +0200 Subject: [PATCH 04/29] Implement simple objective checks --- src/scenario.c | 90 +++++++++++++++++++++++++++++++- src/window_game_bottom_toolbar.c | 1 + 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index 6cdeb06692..53a6d1e940 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -518,6 +518,92 @@ void scenario_load_and_play(rct_scenario_basic *scenario) } +void scenario_failure() +{ + RCT2_CALLPROC_EBPSAFE(0x0066A752); +} + + +void scenario_success() +{ + RCT2_CALLPROC_EBPSAFE(0x0066A75E); +} + + +void check_objectives() +{ + uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8), + objective_year = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8); + sint16 park_rating = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, sint16), + guests_in_park = RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16), + objective_guests = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS, uint16), + cur_month_year = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16); + uint32 scenario_completed_company_value = RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32); + sint32 objective_currency = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_CURRENCY, sint32), + park_value = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32); + + + if ( scenario_completed_company_value != 0x80000000) + return; + + switch (objective_type) { + case OBJECTIVE_GUESTS_BY: + + if (cur_month_year == 8 * objective_year){ + if (park_rating < 600 || guests_in_park < objective_guests) + scenario_failure(); + scenario_success(); + } + break; + + case OBJECTIVE_PARK_VALUE_BY://2 + + if (cur_month_year == 8 * objective_year) { + if (park_value < objective_currency) + scenario_failure(); + scenario_success(); + } + break; + + case OBJECTIVE_10_ROLLERCOASTERS://5 + break; + case OBJECTIVE_GUESTS_AND_RATING://6 + + if (park_rating >= 700 && guests_in_park > objective_guests) + scenario_success(); + break; + + case OBJECTIVE_MONTHLY_RIDE_INCOME://7 + { + sint32 monthly_ride_income = RCT2_GLOBAL(RCT2_ADDRESS_MONTHLY_RIDE_INCOME, sint32); + if (monthly_ride_income > objective_currency) + scenario_success(); + break; + } + case OBJECTIVE_10_ROLLERCOASTERS_LENGTH://8 + break; + case OBJECTIVE_FINISH_5_ROLLERCOASTERS://9 + break; + case OBJECTIVE_REPLAY_LOAN_AND_PARK_VALUE://A + { + sint32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32); + if (current_loan <= 0 && park_value > objective_currency) + scenario_success(); + break; + } + case OBJECTIVE_MONTHLY_FOOD_INCOME://B + { + sint32 income_sum = RCT2_GLOBAL(0x013578A4, sint32) + RCT2_GLOBAL(0x013578A0, sint32) + + RCT2_GLOBAL(0x0135789C, sint32) + RCT2_GLOBAL(0x01357898, sint32); + if (income_sum > objective_currency) + scenario_success(); + break; + } + default: + return; + } +} + void scenario_update() { @@ -540,7 +626,7 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 if (objective_type == 10 || objective_type == 9 || objective_type == 8 || objective_type == 6 || objective_type == 5) { - RCT2_CALLPROC_EBPSAFE(0x0066A4B2); // objective daily checks + check_objectives(); } } @@ -582,7 +668,7 @@ void scenario_update() RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; RCT2_GLOBAL(0x009A9804, uint32) |= 2; RCT2_CALLPROC_EBPSAFE(0x0069DEAD); - RCT2_CALLPROC_EBPSAFE(0x0066A4B2); // objective daily checks + check_objectives(); RCT2_CALLPROC_EBPSAFE(0x0066A80E); RCT2_CALLPROC_EBPSAFE(0x0066A86C); } diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 7900f38f24..19b4bfa581 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -20,6 +20,7 @@ #include "addresses.h" #include "climate.h" +#include "date.h" #include "news_item.h" #include "park.h" #include "peep.h" From 632708c6e8981c2fe1936475388ca2923b8b031d Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Thu, 1 May 2014 23:51:30 +0200 Subject: [PATCH 05/29] Implement scenario success and failure procedures. --- src/scenario.c | 58 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index 53a6d1e940..f5dd4c4298 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -518,18 +518,62 @@ void scenario_load_and_play(rct_scenario_basic *scenario) } +void scenario_end() +{ + rct_window* w; + window_close_by_id(6, 0); + + for (w = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++){ + if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) + window_close(w); + } + window_park_objective_open(); +} + +/* +* rct2: 0x0066A752 +**/ void scenario_failure() { - RCT2_CALLPROC_EBPSAFE(0x0066A752); + RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = 0x80000001; + scenario_end(); } - +/* + * rct2: 0x0066A75E + **/ void scenario_success() { - RCT2_CALLPROC_EBPSAFE(0x0066A75E); + int i; + rct_scenario_basic* scenario; + uint32 current_val = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, uint32); + + RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = current_val; + RCT2_CALLPROC_EBPSAFE(0x0069BE9B); // celebration + + for (i = 0; i < RCT2_GLOBAL(RCT2_ADDRESS_NUM_SCENARIOS, sint32); i++) { + char* cur_scenario_name = RCT2_ADDRESS(0x135936C, char*); + scenario = &(RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_LIST, rct_scenario_basic*)[i]); + + if (0 == strncmp(cur_scenario_name, scenario->path, 256)){ + if (scenario->flags & SCENARIO_FLAGS_COMPLETED && scenario->company_value < current_val) + break; // not a new high score -> no glory + + // bts game_flags, 1 happens here but I don't know what for + scenario->company_value = current_val; + scenario->flags |= SCENARIO_FLAGS_COMPLETED; + scenario->completed_by[0] = 0; + RCT2_GLOBAL(0x013587C0, uint32) = current_val; // value used in window for score? + scenario_scores_save(); + break; + } + } + scenario_end(); } - +/* + * rct2: 0x0066A4B2 + **/ void check_objectives() { uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8), @@ -552,7 +596,8 @@ void check_objectives() if (cur_month_year == 8 * objective_year){ if (park_rating < 600 || guests_in_park < objective_guests) scenario_failure(); - scenario_success(); + else + scenario_success(); } break; @@ -561,7 +606,8 @@ void check_objectives() if (cur_month_year == 8 * objective_year) { if (park_value < objective_currency) scenario_failure(); - scenario_success(); + else + scenario_success(); } break; From 0669525fdcc2d0a523c0c258e5d3f1506b82b41e Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 00:37:23 +0200 Subject: [PATCH 06/29] Added check for 10 rollercoaster objective --- src/scenario.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/scenario.c b/src/scenario.c index f5dd4c4298..bc836ca6ba 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -29,6 +29,7 @@ #include "object.h" #include "park.h" #include "rct2.h" +#include "ride.h" #include "sawyercoding.h" #include "scenario.h" #include "strings.h" @@ -571,6 +572,38 @@ void scenario_success() scenario_end(); } + +void objective_check_10_rollercoasters() +{ + int i, rcs = 0; + uint8 type_already_counted[256]; + rct_ride* ride; + + memset(type_already_counted, 0, 256); + + for (i = 0; i < 255; i++) { + uint8 rc_type; + uint32 rollercoaster_p; + ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); + if (ride->type == RIDE_TYPE_NULL) + continue; + rc_type = ride->var_001; + rollercoaster_p = RCT2_GLOBAL(0x009ACFA4 + rc_type*4, uint32); + + if ((RCT2_GLOBAL(rollercoaster_p + 0x1BE, sint8) == 2 || + RCT2_GLOBAL(rollercoaster_p + 0x1BF, sint8) == 2 )&& + ride->status == RIDE_STATUS_OPEN && + ride->var_140 >= 600 && type_already_counted[rc_type] == 0){ + type_already_counted[rc_type]++; + rcs++; + } + } + + if (rcs >= 10) + scenario_success(); +} + + /* * rct2: 0x0066A4B2 **/ @@ -612,7 +645,10 @@ void check_objectives() break; case OBJECTIVE_10_ROLLERCOASTERS://5 + + objective_check_10_rollercoasters(); break; + case OBJECTIVE_GUESTS_AND_RATING://6 if (park_rating >= 700 && guests_in_park > objective_guests) From 7403ef68d7c749a097a841f351fb06ff8cfc9cb9 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 00:46:27 +0200 Subject: [PATCH 07/29] Implement "Finish 5 rollercoaster..:" objective check and some fixups --- src/scenario.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index bc836ca6ba..c6261ce357 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -624,7 +624,7 @@ void check_objectives() return; switch (objective_type) { - case OBJECTIVE_GUESTS_BY: + case OBJECTIVE_GUESTS_BY://1 if (cur_month_year == 8 * objective_year){ if (park_rating < 600 || guests_in_park < objective_guests) @@ -665,7 +665,18 @@ void check_objectives() case OBJECTIVE_10_ROLLERCOASTERS_LENGTH://8 break; case OBJECTIVE_FINISH_5_ROLLERCOASTERS://9 + { + rct_ride* ride; + int rcs = 0; + for (int i = 0; i < 255; i++) { + ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); + if (ride->status && ride->intensity > objective_currency) + rcs++; + } + if (rcs >= 5) + scenario_success(); break; + } case OBJECTIVE_REPLAY_LOAN_AND_PARK_VALUE://A { sint32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32); @@ -686,7 +697,9 @@ void check_objectives() } } - +/* +* rct2: 0x006C44B1 +**/ void scenario_update() { uint8 screen_flags = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8); From 5c0bca3f1698bcc27eb0e2b7863afa2af2529b9a Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 11:04:05 +0200 Subject: [PATCH 08/29] Implement entrance fee too high check. Some refactoring. --- src/game.c | 1 - src/scenario.c | 39 +++++++++++++++++++++++++++++++++------ src/strings.h | 2 ++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/game.c b/src/game.c index 69b13b5894..5e7f8c2bf0 100644 --- a/src/game.c +++ b/src/game.c @@ -137,7 +137,6 @@ void game_logic_update() RCT2_GLOBAL(0x009DEA66, sint16)--; RCT2_CALLPROC_EBPSAFE(0x0068B089); - RCT2_CALLPROC_EBPSAFE(0x006C44B1); // update_objective scenario_update(); climate_update(); RCT2_CALLPROC_EBPSAFE(0x006646E1); diff --git a/src/scenario.c b/src/scenario.c index c6261ce357..318f6535dc 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -33,6 +33,7 @@ #include "sawyercoding.h" #include "scenario.h" #include "strings.h" +#include "sprite.h" #include "viewport.h" #define UNINITIALISED_SCENARIO_LIST ((rct_scenario_basic*)-1) @@ -607,7 +608,7 @@ void objective_check_10_rollercoasters() /* * rct2: 0x0066A4B2 **/ -void check_objectives() +void scenario_objectives_check() { uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8), objective_year = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8); @@ -663,7 +664,10 @@ void check_objectives() break; } case OBJECTIVE_10_ROLLERCOASTERS_LENGTH://8 + + RCT2_CALLPROC_EBPSAFE(0x0066A6B5); break; + case OBJECTIVE_FINISH_5_ROLLERCOASTERS://9 { rct_ride* ride; @@ -697,9 +701,32 @@ void check_objectives() } } + /* * rct2: 0x006C44B1 **/ +void scneario_entrance_fee_too_high_check() +{ + uint16 x, y; + uint16 magic = RCT2_GLOBAL(0x013580EE, uint16), + park_entrance_fee = RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16); + int max_fee = magic + (magic / 2); + uint32 game_flags = RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32), packed_xy; + + if (game_flags & GAME_FLAGS_PARK_OPEN && park_entrance_fee > max_fee) { + for (int i = 0; RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL; ++i) { + x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] + 16; + y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, uint16)[i] + 16; + } + } + + packed_xy = (y << 16) | x; + RCT2_CALLPROC_X(0x0066DF55, 5, STR_ENTRANCE_FEE_TOO_HI, packed_xy, 0, 0, 0, 0); +} + +/* + * rct2: 0x006C44B1 + **/ void scenario_update() { uint8 screen_flags = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8); @@ -714,9 +741,8 @@ void scenario_update() if ((current_days_in_month * next_month_tick) >> 16 != (current_days_in_month * month_tick) >> 16) { // daily checks - - RCT2_CALLPROC_EBPSAFE(0x0069E79A); // objective_finance_mystery1 - RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps update loop + RCT2_CALLPROC_EBPSAFE(0x0069E79A); // finance update + RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 if (objective_type == 10 || objective_type == 9 || objective_type == 8 || @@ -758,13 +784,14 @@ void scenario_update() } RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; + next_month_tick = next_month_tick * 8; if (next_month_tick > 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; RCT2_GLOBAL(0x009A9804, uint32) |= 2; RCT2_CALLPROC_EBPSAFE(0x0069DEAD); - check_objectives(); - RCT2_CALLPROC_EBPSAFE(0x0066A80E); + scenario_objectives_check(); + scneario_entrance_fee_too_high_check(); RCT2_CALLPROC_EBPSAFE(0x0066A86C); } diff --git a/src/strings.h b/src/strings.h index 583bc4738e..b8c6967e18 100644 --- a/src/strings.h +++ b/src/strings.h @@ -349,6 +349,8 @@ enum { STR_SHOW_GUESTS_ON_MAP_TIP = 2803, STR_SHOW_MAP_TIP = 2805, + STR_ENTRANCE_FEE_TOO_HI = 2813, + STR_AWARD_MOST_UNTIDY = 2814, STR_MOST_TIDY = STR_AWARD_MOST_UNTIDY + 1, STR_BEST_ROLLERCOASTERS = STR_AWARD_MOST_UNTIDY + 2, From 440a21b421a01792619f83dde7c6fc5cef19d594 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 12:30:39 +0200 Subject: [PATCH 09/29] Implement marketing campaign updating. --- src/scenario.c | 52 +++++++++++++++++++++++++++++++++++++++++++++----- src/strings.h | 8 ++++++++ 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index f4f38d97fc..726ef888ef 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -532,7 +532,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) void scenario_end() { rct_window* w; - window_close_by_id(6, 0); + window_close_by_id(WC_DROPDOWN, 0); for (w = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++){ if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) @@ -730,9 +730,51 @@ void scneario_entrance_fee_too_high_check() } packed_xy = (y << 16) | x; - RCT2_CALLPROC_X(0x0066DF55, 5, STR_ENTRANCE_FEE_TOO_HI, packed_xy, 0, 0, 0, 0); + RCT2_CALLPROC_X(0x0066DF55, 5, STR_ENTRANCE_FEE_TOO_HI, packed_xy, 0, 0, 0, 0); // dispatch news } + +/* +* rct2: 0x0069E0C1 +**/ +void scenario_marketing_finished() +{ + int base_str = STR_MARKETING_FINISHED_BASE; + + for (int i = 0; i < 6; ++i) { + uint8 campaign_weeks_left = RCT2_ADDRESS(0x01358102, uint8)[i]; + int campaign_item = 0; + + if (!campaign_weeks_left) + continue; + + window_invalidate_by_id(WC_FINANCES, 0); + RCT2_ADDRESS(0x01358102, uint8)[i] &= ~(1 << 7); + if (campaign_weeks_left & (1 << 7)) + continue; + + RCT2_ADDRESS(0x01358102, uint8)[i]--; + if (campaign_weeks_left - 1 != 0) + continue; + + campaign_item = RCT2_ADDRESS(0x01358116, uint8)[i]; + + // this sets the string parameters for the marketing types that have an argument. + if (i == 1 || i == 5) { // free RIDES oh yea + RCT2_GLOBAL(0x013CE952, uint16) = RCT2_GLOBAL(0x01362942 + 304 * campaign_item, uint16);; + RCT2_GLOBAL(0x013CE954, uint32) = RCT2_GLOBAL(0x01362944 + 152 * campaign_item, uint32); + } else if (i == 3) { // free food/merch + campaign_item += 2016; + if (campaign_item < 2048) + campaign_item += 96; + RCT2_GLOBAL(0x013CE952, uint16) = campaign_item; + } + + RCT2_CALLPROC_X(0x0066DF55, 4, base_str + i, 0, 0, 0, 0, 0); // dispatch news + } +} + + /* * rct2: 0x006C44B1 **/ @@ -754,9 +796,10 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 + scenario_marketing_finished(); if (objective_type == 10 || objective_type == 9 || objective_type == 8 || objective_type == 6 || objective_type == 5) { - check_objectives(); + scenario_objectives_check(); } } @@ -767,7 +810,7 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x006C18A9); RCT2_CALLPROC_EBPSAFE(0x00684DA5); RCT2_CALLPROC_EBPSAFE(0x0069E092); - RCT2_CALLPROC_EBPSAFE(0x0069E0C1); + scenario_marketing_finished(); RCT2_CALLPROC_EBPSAFE(0x0069BF41); RCT2_CALLPROC_EBPSAFE(0x006B7A5E); RCT2_CALLPROC_EBPSAFE(0x006AC916); @@ -793,7 +836,6 @@ void scenario_update() } RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; - next_month_tick = next_month_tick * 8; if (next_month_tick > 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; diff --git a/src/strings.h b/src/strings.h index b8c6967e18..a2bd30f427 100644 --- a/src/strings.h +++ b/src/strings.h @@ -327,6 +327,14 @@ enum { STR_OBJECTIVE_REPLAY_LOAN_AND_PARK_VALUE = STR_OBJECTIVE_NONE + 10, STR_OBJECTIVE_MONTHLY_FOOD_INCOME = STR_OBJECTIVE_NONE + 11, + STR_MARKETING_FINISHED_BASE = 2446, + STR_MARKETING_FINISHED_FREE_ENTRY = 2446, + STR_MARKETING_FINISHED_FREE_RIDES = 2447, + STR_MARKETING_FINISHED_HALF_PRICE_ENTRY = 2448, + STR_MARKETING_FINISHED_FREE_RIDE = 2449, + STR_MARKETING_FINISHED_PARK_ADS = 2450, + STR_MARKETING_FINISHED_RIDE_ADS = 2451, + STR_PARK_ENTRANCE_TAB_TIP = 2462, STR_PARK_RATING_TAB_TIP = 2463, STR_PARK_GUESTS_TAB_TIP = 2464, From ace1d2eabbbb3fbe110f52b5cfd5b470b502c3c0 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 12:31:24 +0200 Subject: [PATCH 10/29] Rename marketing_finished to marketing_update. --- src/scenario.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index 726ef888ef..db09baee10 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -737,7 +737,7 @@ void scneario_entrance_fee_too_high_check() /* * rct2: 0x0069E0C1 **/ -void scenario_marketing_finished() +void scenario_marketing_update() { int base_str = STR_MARKETING_FINISHED_BASE; @@ -810,7 +810,7 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x006C18A9); RCT2_CALLPROC_EBPSAFE(0x00684DA5); RCT2_CALLPROC_EBPSAFE(0x0069E092); - scenario_marketing_finished(); + scenario_marketing_update(); RCT2_CALLPROC_EBPSAFE(0x0069BF41); RCT2_CALLPROC_EBPSAFE(0x006B7A5E); RCT2_CALLPROC_EBPSAFE(0x006AC916); From 8915f5982c41adb4d743c7fddc19a912b2537644 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 15:06:58 +0200 Subject: [PATCH 11/29] Leftover debug call --- src/scenario.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index db09baee10..b7a870e628 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -712,7 +712,7 @@ void scenario_objectives_check() /* -* rct2: 0x006C44B1 +* rct2: 0x0066A80E **/ void scneario_entrance_fee_too_high_check() { @@ -796,7 +796,6 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 - scenario_marketing_finished(); if (objective_type == 10 || objective_type == 9 || objective_type == 8 || objective_type == 6 || objective_type == 5) { scenario_objectives_check(); From 039c398f2004dadee84560f82d377ae70f9a5d5c Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 16:09:07 +0200 Subject: [PATCH 12/29] Implement news_item_add_to_queue and some bugfixes. --- src/news_item.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/news_item.h | 2 ++ src/scenario.c | 12 ++++++------ 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index f09f7f19c8..02b559b082 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -20,9 +20,11 @@ #include "addresses.h" #include "audio.h" +#include "date.h" #include "news_item.h" #include "rct2.h" #include "ride.h" +#include "strings.h" #include "sprite.h" #include "window.h" @@ -248,3 +250,43 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * break; } } + + +/** + * rct2: 0x0066DF55 + * + * @param a (al) + * @param string_id (ebx) + * @param c (ecx) + **/ +void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc) +{ + int i = 0; + rct_news_item *newsItem = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item); + + // find first open slot + while (newsItem->type != NEWS_ITEM_NULL) { + if (newsItem + sizeof(newsItem) >= 0x13CB1CC) + news_item_close_current(); + else + newsItem++; + } + + //now we have found an item slot to place the new news in + newsItem->type = type; + newsItem->flags = 0; + newsItem->assoc = assoc; + newsItem->ticks = 0; + newsItem->month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); + newsItem->day = (days_in_month[(newsItem->month & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16; + + format_string(0x0141EF68, string_id, 0x013CE952); // overflows possible? + newsItem->colour = ((char*)0x0141EF68)[0]; + strncpy(newsItem->text, 0x0141EF68, 255); + newsItem->text[254] = 0; + + // blatant disregard for what happens on the last element. + // Change this when we implement the queue ourselves. + newsItem++; + newsItem->type = 0; +} \ No newline at end of file diff --git a/src/news_item.h b/src/news_item.h index be8dd55e42..1d399de805 100644 --- a/src/news_item.h +++ b/src/news_item.h @@ -22,6 +22,7 @@ #define _NEWS_ITEM_H_ #include "rct2.h" +#include "strings.h" enum { NEWS_ITEM_NULL, @@ -57,5 +58,6 @@ void news_item_init_queue(); void news_item_update_current(); void news_item_close_current(); void news_item_get_subject_location(int type, int subject, int *x, int *y, int *z); +void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc); #endif diff --git a/src/scenario.c b/src/scenario.c index b7a870e628..5898f56dc9 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -730,7 +730,7 @@ void scneario_entrance_fee_too_high_check() } packed_xy = (y << 16) | x; - RCT2_CALLPROC_X(0x0066DF55, 5, STR_ENTRANCE_FEE_TOO_HI, packed_xy, 0, 0, 0, 0); // dispatch news + news_item_add_to_queue(NEWS_ITEM_BLANK, STR_ENTRANCE_FEE_TOO_HI, packed_xy); } @@ -739,16 +739,16 @@ void scneario_entrance_fee_too_high_check() **/ void scenario_marketing_update() { - int base_str = STR_MARKETING_FINISHED_BASE; - for (int i = 0; i < 6; ++i) { uint8 campaign_weeks_left = RCT2_ADDRESS(0x01358102, uint8)[i]; int campaign_item = 0; if (!campaign_weeks_left) continue; - window_invalidate_by_id(WC_FINANCES, 0); + + // high bit marks the campaign as inactive, on first check the campaign is set actice + // this makes campaigns run a full x weeks even when started in the middle of a week RCT2_ADDRESS(0x01358102, uint8)[i] &= ~(1 << 7); if (campaign_weeks_left & (1 << 7)) continue; @@ -765,12 +765,12 @@ void scenario_marketing_update() RCT2_GLOBAL(0x013CE954, uint32) = RCT2_GLOBAL(0x01362944 + 152 * campaign_item, uint32); } else if (i == 3) { // free food/merch campaign_item += 2016; - if (campaign_item < 2048) + if (campaign_item >= 2048) campaign_item += 96; RCT2_GLOBAL(0x013CE952, uint16) = campaign_item; } - RCT2_CALLPROC_X(0x0066DF55, 4, base_str + i, 0, 0, 0, 0, 0); // dispatch news + news_item_add_to_queue(NEWS_ITEM_MONEY, STR_MARKETING_FINISHED_BASE + i, 0); } } From 002e914122886efc2a415b4ce9eff272262c4af0 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 16:16:32 +0200 Subject: [PATCH 13/29] Reset a accidental change to the project file during a merge. --- projects/openrct2.vcxproj.user | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/openrct2.vcxproj.user b/projects/openrct2.vcxproj.user index 9741a1a551..80981e45c6 100644 --- a/projects/openrct2.vcxproj.user +++ b/projects/openrct2.vcxproj.user @@ -1,7 +1,7 @@  - true + false $(TargetDir)\openrct2.exe From 30a5793ac1faa4b9f0452b591d31dfcf78e3846e Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 1 May 2014 15:07:51 +0100 Subject: [PATCH 14/29] rename current day to current month ticks --- src/window_game_bottom_toolbar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 53559bd86a..2ce92865ed 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -223,7 +223,7 @@ static void window_game_bottom_toolbar_tooltip() case WIDX_DATE: month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7; day = ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, sint16) * days_in_month[month]) >> 16) & 0xFF; - + *((short*)0x013CE952) = STR_DATE_DAY_1 + day; *((short*)0x013CE954) = STR_MONTH_MARCH + month; widgetIndex = 0; From ad0d77a49c3f76f89fca52c464fc9b04567a8efc Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Thu, 1 May 2014 19:15:02 +0200 Subject: [PATCH 15/29] Start implementation of scenario_update. --- src/game.c | 4 ++- src/scenario.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/scenario.h | 1 + 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index cf8fe6b6fc..e0cbd4cbec 100644 --- a/src/game.c +++ b/src/game.c @@ -27,6 +27,7 @@ #include "news_item.h" #include "osinterface.h" #include "peep.h" +#include "scenario.h" #include "screenshot.h" #include "strings.h" #include "title.h" @@ -138,6 +139,7 @@ void game_logic_update() RCT2_CALLPROC_EBPSAFE(0x0068B089); RCT2_CALLPROC_EBPSAFE(0x006C44B1); // update_objective + scenario_update(); climate_update(); RCT2_CALLPROC_EBPSAFE(0x006646E1); RCT2_CALLPROC_EBPSAFE(0x006A876D); @@ -1328,4 +1330,4 @@ static uint32 game_do_command_table[58] = { 0x0068DF91 }; -#pragma endregion \ No newline at end of file +#pragma endregion diff --git a/src/scenario.c b/src/scenario.c index a4aa7f3510..6acfbca0f1 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -527,3 +527,73 @@ void scenario_load_and_play(rct_scenario_basic *scenario) RCT2_GLOBAL(0x009DEA66, uint16) = 0; RCT2_GLOBAL(0x009DEA5C, uint16) = 62000; // (doesn't appear to ever be read) } + + + +void scenario_update() +{ + uint8 screen_flags = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8); + uint32 current_day = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16); + uint8 month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7; + uint8 current_days_in_month = days_in_month[month]; + uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8); + + if (screen_flags & (~SCREEN_FLAGS_PLAYING)) // only in normal play mode + return; + + if ((current_days_in_month * (current_day + 4)) >> 16 != (current_days_in_month * current_day) >> 16) { + // daily checks + + RCT2_CALLPROC_EBPSAFE(0x0069E79A); // objective_finance_mystery1 + RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps update loop + RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time + RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 + if (objective_type == 10 || objective_type == 9 || objective_type == 8 || + objective_type == 6 || objective_type == 5) { + RCT2_CALLPROC_EBPSAFE(0x0066A4B2); // objective daily checks + } + } + + + if ( (unsigned int)((4 * current_day) & 0xFFFF) >= 0xFFEFu) { + // weekly checks + RCT2_CALLPROC_EBPSAFE(0x006C18A9); + RCT2_CALLPROC_EBPSAFE(0x00684DA5); + RCT2_CALLPROC_EBPSAFE(0x0069E092); + RCT2_CALLPROC_EBPSAFE(0x0069E0C1); + RCT2_CALLPROC_EBPSAFE(0x0069BF41); + RCT2_CALLPROC_EBPSAFE(0x006B7A5E); + RCT2_CALLPROC_EBPSAFE(0x006AC916); + + if (month <= 1 && RCT2_GLOBAL(0x009ADAE0, sint32) != -1 && RCT2_GLOBAL(0x009ADAE0 + 14, uint16) & 1) { + for (int i = 0; i < 100; ++i) { + int carry; + RCT2_CALLPROC_EBPSAFE(0x006744A9); // clears carry flag on failure -.- + __asm mov carry, 0; + __asm adc carry, 0; + if (!carry) + break; + } + } + RCT2_CALLPROC_EBPSAFE(0x0066A231); + RCT2_CALLPROC_EBPSAFE(0x0066A348); + } + + if ( (unsigned int)((2 * current_day) & 0xFFFF) + 8 >= 0x10000) { + // biweekly checks + RCT2_CALLPROC_EBPSAFE(0x006AC885); + } + + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = current_day + 4; + if (current_day + 4 > 0x10000) { + // month ends actions + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; + RCT2_GLOBAL(0x009A9804, uint32) |= 2; + RCT2_CALLPROC_EBPSAFE(0x0069DEAD); + RCT2_CALLPROC_EBPSAFE(0x0066A4B2); // objective daily checks + RCT2_CALLPROC_EBPSAFE(0x0066A80E); + RCT2_CALLPROC_EBPSAFE(0x0066A86C); + } + +} + diff --git a/src/scenario.h b/src/scenario.h index 45eacf8a42..1589b7621f 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -110,5 +110,6 @@ enum { void scenario_load_list(); void scenario_load(char *path); void scenario_load_and_play(rct_scenario_basic *scenario); +void scenario_update(); #endif From c2965a4f9e8c363f8c4c1cf60e1edfb0fc0369d3 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Thu, 1 May 2014 19:27:42 +0200 Subject: [PATCH 16/29] Make scenario update timeframes clearer --- src/scenario.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index 6acfbca0f1..c3929284be 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -533,15 +533,16 @@ void scenario_load_and_play(rct_scenario_basic *scenario) void scenario_update() { uint8 screen_flags = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8); - uint32 current_day = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16); - uint8 month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7; - uint8 current_days_in_month = days_in_month[month]; - uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8); + uint32 month_tick = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16), + next_month_tick = month_tick + 4; + uint8 month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7, + current_days_in_month = days_in_month[month], + objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8); if (screen_flags & (~SCREEN_FLAGS_PLAYING)) // only in normal play mode return; - if ((current_days_in_month * (current_day + 4)) >> 16 != (current_days_in_month * current_day) >> 16) { + if ((current_days_in_month * next_month_tick) >> 16 != (current_days_in_month * month_tick) >> 16) { // daily checks RCT2_CALLPROC_EBPSAFE(0x0069E79A); // objective_finance_mystery1 @@ -555,7 +556,8 @@ void scenario_update() } - if ( (unsigned int)((4 * current_day) & 0xFFFF) >= 0xFFEFu) { + //if ( (unsigned int)((4 * current_day) & 0xFFFF) >= 0xFFEFu) { + if ( next_month_tick % 0x4000 == 0) { // weekly checks RCT2_CALLPROC_EBPSAFE(0x006C18A9); RCT2_CALLPROC_EBPSAFE(0x00684DA5); @@ -579,13 +581,14 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x0066A348); } - if ( (unsigned int)((2 * current_day) & 0xFFFF) + 8 >= 0x10000) { + //if ( (unsigned int)((2 * current_day) & 0xFFFF) >= 0xFFF8) { + if (next_month_tick % 0x8000 == 0) { // biweekly checks RCT2_CALLPROC_EBPSAFE(0x006AC885); } - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = current_day + 4; - if (current_day + 4 > 0x10000) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; + if (next_month_tick > 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; RCT2_GLOBAL(0x009A9804, uint32) |= 2; From fc02eef2a970b03e3bad50c075cac2703e0274a7 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Thu, 1 May 2014 22:58:44 +0200 Subject: [PATCH 17/29] Implement simple objective checks --- src/scenario.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 2 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index c3929284be..ab63c819f7 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -529,6 +529,92 @@ void scenario_load_and_play(rct_scenario_basic *scenario) } +void scenario_failure() +{ + RCT2_CALLPROC_EBPSAFE(0x0066A752); +} + + +void scenario_success() +{ + RCT2_CALLPROC_EBPSAFE(0x0066A75E); +} + + +void check_objectives() +{ + uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8), + objective_year = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8); + sint16 park_rating = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, sint16), + guests_in_park = RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16), + objective_guests = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS, uint16), + cur_month_year = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16); + uint32 scenario_completed_company_value = RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32); + sint32 objective_currency = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_CURRENCY, sint32), + park_value = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32); + + + if ( scenario_completed_company_value != 0x80000000) + return; + + switch (objective_type) { + case OBJECTIVE_GUESTS_BY: + + if (cur_month_year == 8 * objective_year){ + if (park_rating < 600 || guests_in_park < objective_guests) + scenario_failure(); + scenario_success(); + } + break; + + case OBJECTIVE_PARK_VALUE_BY://2 + + if (cur_month_year == 8 * objective_year) { + if (park_value < objective_currency) + scenario_failure(); + scenario_success(); + } + break; + + case OBJECTIVE_10_ROLLERCOASTERS://5 + break; + case OBJECTIVE_GUESTS_AND_RATING://6 + + if (park_rating >= 700 && guests_in_park > objective_guests) + scenario_success(); + break; + + case OBJECTIVE_MONTHLY_RIDE_INCOME://7 + { + sint32 monthly_ride_income = RCT2_GLOBAL(RCT2_ADDRESS_MONTHLY_RIDE_INCOME, sint32); + if (monthly_ride_income > objective_currency) + scenario_success(); + break; + } + case OBJECTIVE_10_ROLLERCOASTERS_LENGTH://8 + break; + case OBJECTIVE_FINISH_5_ROLLERCOASTERS://9 + break; + case OBJECTIVE_REPLAY_LOAN_AND_PARK_VALUE://A + { + sint32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32); + if (current_loan <= 0 && park_value > objective_currency) + scenario_success(); + break; + } + case OBJECTIVE_MONTHLY_FOOD_INCOME://B + { + sint32 income_sum = RCT2_GLOBAL(0x013578A4, sint32) + RCT2_GLOBAL(0x013578A0, sint32) + + RCT2_GLOBAL(0x0135789C, sint32) + RCT2_GLOBAL(0x01357898, sint32); + if (income_sum > objective_currency) + scenario_success(); + break; + } + default: + return; + } +} + void scenario_update() { @@ -551,7 +637,7 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 if (objective_type == 10 || objective_type == 9 || objective_type == 8 || objective_type == 6 || objective_type == 5) { - RCT2_CALLPROC_EBPSAFE(0x0066A4B2); // objective daily checks + check_objectives(); } } @@ -593,7 +679,7 @@ void scenario_update() RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; RCT2_GLOBAL(0x009A9804, uint32) |= 2; RCT2_CALLPROC_EBPSAFE(0x0069DEAD); - RCT2_CALLPROC_EBPSAFE(0x0066A4B2); // objective daily checks + check_objectives(); RCT2_CALLPROC_EBPSAFE(0x0066A80E); RCT2_CALLPROC_EBPSAFE(0x0066A86C); } From e1f5c62fcca0d4b67105b5f8ecfebc633e23b942 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Thu, 1 May 2014 23:51:30 +0200 Subject: [PATCH 18/29] Implement scenario success and failure procedures. --- src/scenario.c | 58 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index ab63c819f7..10765a8eb5 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -529,18 +529,62 @@ void scenario_load_and_play(rct_scenario_basic *scenario) } +void scenario_end() +{ + rct_window* w; + window_close_by_id(6, 0); + + for (w = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++){ + if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) + window_close(w); + } + window_park_objective_open(); +} + +/* +* rct2: 0x0066A752 +**/ void scenario_failure() { - RCT2_CALLPROC_EBPSAFE(0x0066A752); + RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = 0x80000001; + scenario_end(); } - +/* + * rct2: 0x0066A75E + **/ void scenario_success() { - RCT2_CALLPROC_EBPSAFE(0x0066A75E); + int i; + rct_scenario_basic* scenario; + uint32 current_val = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, uint32); + + RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32) = current_val; + RCT2_CALLPROC_EBPSAFE(0x0069BE9B); // celebration + + for (i = 0; i < RCT2_GLOBAL(RCT2_ADDRESS_NUM_SCENARIOS, sint32); i++) { + char* cur_scenario_name = RCT2_ADDRESS(0x135936C, char*); + scenario = &(RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_LIST, rct_scenario_basic*)[i]); + + if (0 == strncmp(cur_scenario_name, scenario->path, 256)){ + if (scenario->flags & SCENARIO_FLAGS_COMPLETED && scenario->company_value < current_val) + break; // not a new high score -> no glory + + // bts game_flags, 1 happens here but I don't know what for + scenario->company_value = current_val; + scenario->flags |= SCENARIO_FLAGS_COMPLETED; + scenario->completed_by[0] = 0; + RCT2_GLOBAL(0x013587C0, uint32) = current_val; // value used in window for score? + scenario_scores_save(); + break; + } + } + scenario_end(); } - +/* + * rct2: 0x0066A4B2 + **/ void check_objectives() { uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8), @@ -563,7 +607,8 @@ void check_objectives() if (cur_month_year == 8 * objective_year){ if (park_rating < 600 || guests_in_park < objective_guests) scenario_failure(); - scenario_success(); + else + scenario_success(); } break; @@ -572,7 +617,8 @@ void check_objectives() if (cur_month_year == 8 * objective_year) { if (park_value < objective_currency) scenario_failure(); - scenario_success(); + else + scenario_success(); } break; From efc4095d85229d147fe2f394b5d62bc8e207d52c Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 00:37:23 +0200 Subject: [PATCH 19/29] Added check for 10 rollercoaster objective --- src/scenario.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/scenario.c b/src/scenario.c index 10765a8eb5..cbd0eb8f0f 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -29,6 +29,7 @@ #include "object.h" #include "park.h" #include "rct2.h" +#include "ride.h" #include "sawyercoding.h" #include "scenario.h" #include "strings.h" @@ -582,6 +583,38 @@ void scenario_success() scenario_end(); } + +void objective_check_10_rollercoasters() +{ + int i, rcs = 0; + uint8 type_already_counted[256]; + rct_ride* ride; + + memset(type_already_counted, 0, 256); + + for (i = 0; i < 255; i++) { + uint8 rc_type; + uint32 rollercoaster_p; + ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); + if (ride->type == RIDE_TYPE_NULL) + continue; + rc_type = ride->var_001; + rollercoaster_p = RCT2_GLOBAL(0x009ACFA4 + rc_type*4, uint32); + + if ((RCT2_GLOBAL(rollercoaster_p + 0x1BE, sint8) == 2 || + RCT2_GLOBAL(rollercoaster_p + 0x1BF, sint8) == 2 )&& + ride->status == RIDE_STATUS_OPEN && + ride->var_140 >= 600 && type_already_counted[rc_type] == 0){ + type_already_counted[rc_type]++; + rcs++; + } + } + + if (rcs >= 10) + scenario_success(); +} + + /* * rct2: 0x0066A4B2 **/ @@ -623,7 +656,10 @@ void check_objectives() break; case OBJECTIVE_10_ROLLERCOASTERS://5 + + objective_check_10_rollercoasters(); break; + case OBJECTIVE_GUESTS_AND_RATING://6 if (park_rating >= 700 && guests_in_park > objective_guests) From ddce193f4aa12ce4fdf2cd9f72eadfb70c9763d6 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 00:46:27 +0200 Subject: [PATCH 20/29] Implement "Finish 5 rollercoaster..:" objective check and some fixups --- src/scenario.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index cbd0eb8f0f..b81900006d 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -635,7 +635,7 @@ void check_objectives() return; switch (objective_type) { - case OBJECTIVE_GUESTS_BY: + case OBJECTIVE_GUESTS_BY://1 if (cur_month_year == 8 * objective_year){ if (park_rating < 600 || guests_in_park < objective_guests) @@ -676,7 +676,18 @@ void check_objectives() case OBJECTIVE_10_ROLLERCOASTERS_LENGTH://8 break; case OBJECTIVE_FINISH_5_ROLLERCOASTERS://9 + { + rct_ride* ride; + int rcs = 0; + for (int i = 0; i < 255; i++) { + ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); + if (ride->status && ride->intensity > objective_currency) + rcs++; + } + if (rcs >= 5) + scenario_success(); break; + } case OBJECTIVE_REPLAY_LOAN_AND_PARK_VALUE://A { sint32 current_loan = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint32); @@ -697,7 +708,9 @@ void check_objectives() } } - +/* +* rct2: 0x006C44B1 +**/ void scenario_update() { uint8 screen_flags = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8); From bf03c21de9767197904c4a4a5e9ef4288b9db904 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 11:04:05 +0200 Subject: [PATCH 21/29] Implement entrance fee too high check. Some refactoring. --- src/game.c | 1 - src/scenario.c | 39 +++++++++++++++++++++++++++++++++------ src/strings.h | 2 ++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/game.c b/src/game.c index e0cbd4cbec..7a838c6c06 100644 --- a/src/game.c +++ b/src/game.c @@ -138,7 +138,6 @@ void game_logic_update() RCT2_GLOBAL(0x009DEA66, sint16)--; RCT2_CALLPROC_EBPSAFE(0x0068B089); - RCT2_CALLPROC_EBPSAFE(0x006C44B1); // update_objective scenario_update(); climate_update(); RCT2_CALLPROC_EBPSAFE(0x006646E1); diff --git a/src/scenario.c b/src/scenario.c index b81900006d..ed21bd4fe0 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -33,6 +33,7 @@ #include "sawyercoding.h" #include "scenario.h" #include "strings.h" +#include "sprite.h" #include "viewport.h" #define UNINITIALISED_SCENARIO_LIST ((rct_scenario_basic*)-1) @@ -618,7 +619,7 @@ void objective_check_10_rollercoasters() /* * rct2: 0x0066A4B2 **/ -void check_objectives() +void scenario_objectives_check() { uint8 objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8), objective_year = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8); @@ -674,7 +675,10 @@ void check_objectives() break; } case OBJECTIVE_10_ROLLERCOASTERS_LENGTH://8 + + RCT2_CALLPROC_EBPSAFE(0x0066A6B5); break; + case OBJECTIVE_FINISH_5_ROLLERCOASTERS://9 { rct_ride* ride; @@ -708,9 +712,32 @@ void check_objectives() } } + /* * rct2: 0x006C44B1 **/ +void scneario_entrance_fee_too_high_check() +{ + uint16 x, y; + uint16 magic = RCT2_GLOBAL(0x013580EE, uint16), + park_entrance_fee = RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16); + int max_fee = magic + (magic / 2); + uint32 game_flags = RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32), packed_xy; + + if (game_flags & GAME_FLAGS_PARK_OPEN && park_entrance_fee > max_fee) { + for (int i = 0; RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL; ++i) { + x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] + 16; + y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, uint16)[i] + 16; + } + } + + packed_xy = (y << 16) | x; + RCT2_CALLPROC_X(0x0066DF55, 5, STR_ENTRANCE_FEE_TOO_HI, packed_xy, 0, 0, 0, 0); +} + +/* + * rct2: 0x006C44B1 + **/ void scenario_update() { uint8 screen_flags = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8); @@ -725,9 +752,8 @@ void scenario_update() if ((current_days_in_month * next_month_tick) >> 16 != (current_days_in_month * month_tick) >> 16) { // daily checks - - RCT2_CALLPROC_EBPSAFE(0x0069E79A); // objective_finance_mystery1 - RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps update loop + RCT2_CALLPROC_EBPSAFE(0x0069E79A); // finance update + RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 if (objective_type == 10 || objective_type == 9 || objective_type == 8 || @@ -769,13 +795,14 @@ void scenario_update() } RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; + next_month_tick = next_month_tick * 8; if (next_month_tick > 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; RCT2_GLOBAL(0x009A9804, uint32) |= 2; RCT2_CALLPROC_EBPSAFE(0x0069DEAD); - check_objectives(); - RCT2_CALLPROC_EBPSAFE(0x0066A80E); + scenario_objectives_check(); + scneario_entrance_fee_too_high_check(); RCT2_CALLPROC_EBPSAFE(0x0066A86C); } diff --git a/src/strings.h b/src/strings.h index 1a990782d6..2208a5b42d 100644 --- a/src/strings.h +++ b/src/strings.h @@ -395,6 +395,8 @@ enum { STR_SHOW_GUESTS_ON_MAP_TIP = 2803, STR_SHOW_MAP_TIP = 2805, + STR_ENTRANCE_FEE_TOO_HI = 2813, + STR_AWARD_MOST_UNTIDY = 2814, STR_MOST_TIDY = STR_AWARD_MOST_UNTIDY + 1, STR_BEST_ROLLERCOASTERS = STR_AWARD_MOST_UNTIDY + 2, From 935284f53d545f3e5195c94399428aacf27f1005 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 12:30:39 +0200 Subject: [PATCH 22/29] Implement marketing campaign updating. --- src/scenario.c | 52 +++++++++++++++++++++++++++++++++++++++++++++----- src/strings.h | 8 ++++++++ 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index ed21bd4fe0..4909df28f2 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -534,7 +534,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) void scenario_end() { rct_window* w; - window_close_by_id(6, 0); + window_close_by_id(WC_DROPDOWN, 0); for (w = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++){ if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) @@ -732,9 +732,51 @@ void scneario_entrance_fee_too_high_check() } packed_xy = (y << 16) | x; - RCT2_CALLPROC_X(0x0066DF55, 5, STR_ENTRANCE_FEE_TOO_HI, packed_xy, 0, 0, 0, 0); + RCT2_CALLPROC_X(0x0066DF55, 5, STR_ENTRANCE_FEE_TOO_HI, packed_xy, 0, 0, 0, 0); // dispatch news } + +/* +* rct2: 0x0069E0C1 +**/ +void scenario_marketing_finished() +{ + int base_str = STR_MARKETING_FINISHED_BASE; + + for (int i = 0; i < 6; ++i) { + uint8 campaign_weeks_left = RCT2_ADDRESS(0x01358102, uint8)[i]; + int campaign_item = 0; + + if (!campaign_weeks_left) + continue; + + window_invalidate_by_id(WC_FINANCES, 0); + RCT2_ADDRESS(0x01358102, uint8)[i] &= ~(1 << 7); + if (campaign_weeks_left & (1 << 7)) + continue; + + RCT2_ADDRESS(0x01358102, uint8)[i]--; + if (campaign_weeks_left - 1 != 0) + continue; + + campaign_item = RCT2_ADDRESS(0x01358116, uint8)[i]; + + // this sets the string parameters for the marketing types that have an argument. + if (i == 1 || i == 5) { // free RIDES oh yea + RCT2_GLOBAL(0x013CE952, uint16) = RCT2_GLOBAL(0x01362942 + 304 * campaign_item, uint16);; + RCT2_GLOBAL(0x013CE954, uint32) = RCT2_GLOBAL(0x01362944 + 152 * campaign_item, uint32); + } else if (i == 3) { // free food/merch + campaign_item += 2016; + if (campaign_item < 2048) + campaign_item += 96; + RCT2_GLOBAL(0x013CE952, uint16) = campaign_item; + } + + RCT2_CALLPROC_X(0x0066DF55, 4, base_str + i, 0, 0, 0, 0, 0); // dispatch news + } +} + + /* * rct2: 0x006C44B1 **/ @@ -756,9 +798,10 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 + scenario_marketing_finished(); if (objective_type == 10 || objective_type == 9 || objective_type == 8 || objective_type == 6 || objective_type == 5) { - check_objectives(); + scenario_objectives_check(); } } @@ -769,7 +812,7 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x006C18A9); RCT2_CALLPROC_EBPSAFE(0x00684DA5); RCT2_CALLPROC_EBPSAFE(0x0069E092); - RCT2_CALLPROC_EBPSAFE(0x0069E0C1); + scenario_marketing_finished(); RCT2_CALLPROC_EBPSAFE(0x0069BF41); RCT2_CALLPROC_EBPSAFE(0x006B7A5E); RCT2_CALLPROC_EBPSAFE(0x006AC916); @@ -795,7 +838,6 @@ void scenario_update() } RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; - next_month_tick = next_month_tick * 8; if (next_month_tick > 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; diff --git a/src/strings.h b/src/strings.h index 2208a5b42d..a5432c8d99 100644 --- a/src/strings.h +++ b/src/strings.h @@ -373,6 +373,14 @@ enum { STR_OBJECTIVE_REPLAY_LOAN_AND_PARK_VALUE = STR_OBJECTIVE_NONE + 10, STR_OBJECTIVE_MONTHLY_FOOD_INCOME = STR_OBJECTIVE_NONE + 11, + STR_MARKETING_FINISHED_BASE = 2446, + STR_MARKETING_FINISHED_FREE_ENTRY = 2446, + STR_MARKETING_FINISHED_FREE_RIDES = 2447, + STR_MARKETING_FINISHED_HALF_PRICE_ENTRY = 2448, + STR_MARKETING_FINISHED_FREE_RIDE = 2449, + STR_MARKETING_FINISHED_PARK_ADS = 2450, + STR_MARKETING_FINISHED_RIDE_ADS = 2451, + STR_PARK_ENTRANCE_TAB_TIP = 2462, STR_PARK_RATING_TAB_TIP = 2463, STR_PARK_GUESTS_TAB_TIP = 2464, From 68ab1375719dea36244b99d2ac618ddc40a52fc9 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 12:31:24 +0200 Subject: [PATCH 23/29] Rename marketing_finished to marketing_update. --- src/scenario.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index 4909df28f2..6875834070 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -739,7 +739,7 @@ void scneario_entrance_fee_too_high_check() /* * rct2: 0x0069E0C1 **/ -void scenario_marketing_finished() +void scenario_marketing_update() { int base_str = STR_MARKETING_FINISHED_BASE; @@ -812,7 +812,7 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x006C18A9); RCT2_CALLPROC_EBPSAFE(0x00684DA5); RCT2_CALLPROC_EBPSAFE(0x0069E092); - scenario_marketing_finished(); + scenario_marketing_update(); RCT2_CALLPROC_EBPSAFE(0x0069BF41); RCT2_CALLPROC_EBPSAFE(0x006B7A5E); RCT2_CALLPROC_EBPSAFE(0x006AC916); From b3d36869efe387a0ddb48603c07af54609cf43f1 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 15:06:58 +0200 Subject: [PATCH 24/29] Leftover debug call --- src/scenario.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index 6875834070..4ab244b1bc 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -714,7 +714,7 @@ void scenario_objectives_check() /* -* rct2: 0x006C44B1 +* rct2: 0x0066A80E **/ void scneario_entrance_fee_too_high_check() { @@ -798,7 +798,6 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 - scenario_marketing_finished(); if (objective_type == 10 || objective_type == 9 || objective_type == 8 || objective_type == 6 || objective_type == 5) { scenario_objectives_check(); From 6c2a7a0a2952941f882f5f72a44646304ffe774c Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Fri, 2 May 2014 16:09:07 +0200 Subject: [PATCH 25/29] Implement news_item_add_to_queue and some bugfixes. --- src/news_item.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/news_item.h | 4 +++- src/scenario.c | 12 ++++++------ 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index 4e862d599b..8cffbc5456 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -20,9 +20,11 @@ #include "addresses.h" #include "audio.h" +#include "date.h" #include "news_item.h" #include "rct2.h" #include "ride.h" +#include "strings.h" #include "sprite.h" #include "window.h" @@ -234,3 +236,43 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * break; } } + + +/** + * rct2: 0x0066DF55 + * + * @param a (al) + * @param string_id (ebx) + * @param c (ecx) + **/ +void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc) +{ + int i = 0; + rct_news_item *newsItem = RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item); + + // find first open slot + while (newsItem->type != NEWS_ITEM_NULL) { + if (newsItem + sizeof(newsItem) >= 0x13CB1CC) + news_item_close_current(); + else + newsItem++; + } + + //now we have found an item slot to place the new news in + newsItem->type = type; + newsItem->flags = 0; + newsItem->assoc = assoc; + newsItem->ticks = 0; + newsItem->month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); + newsItem->day = (days_in_month[(newsItem->month & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16; + + format_string(0x0141EF68, string_id, 0x013CE952); // overflows possible? + newsItem->colour = ((char*)0x0141EF68)[0]; + strncpy(newsItem->text, 0x0141EF68, 255); + newsItem->text[254] = 0; + + // blatant disregard for what happens on the last element. + // Change this when we implement the queue ourselves. + newsItem++; + newsItem->type = 0; +} diff --git a/src/news_item.h b/src/news_item.h index de12b44e22..4b49fd123a 100644 --- a/src/news_item.h +++ b/src/news_item.h @@ -22,7 +22,8 @@ #define _NEWS_ITEM_H_ #include "rct2.h" -#include "map.h" +#include "strings.h" + enum { NEWS_ITEM_NULL, @@ -58,5 +59,6 @@ void news_item_init_queue(); void news_item_update_current(); void news_item_close_current(); void news_item_get_subject_location(int type, int subject, int *x, int *y, int *z); +void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc); #endif diff --git a/src/scenario.c b/src/scenario.c index 4ab244b1bc..81cabd6918 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -732,7 +732,7 @@ void scneario_entrance_fee_too_high_check() } packed_xy = (y << 16) | x; - RCT2_CALLPROC_X(0x0066DF55, 5, STR_ENTRANCE_FEE_TOO_HI, packed_xy, 0, 0, 0, 0); // dispatch news + news_item_add_to_queue(NEWS_ITEM_BLANK, STR_ENTRANCE_FEE_TOO_HI, packed_xy); } @@ -741,16 +741,16 @@ void scneario_entrance_fee_too_high_check() **/ void scenario_marketing_update() { - int base_str = STR_MARKETING_FINISHED_BASE; - for (int i = 0; i < 6; ++i) { uint8 campaign_weeks_left = RCT2_ADDRESS(0x01358102, uint8)[i]; int campaign_item = 0; if (!campaign_weeks_left) continue; - window_invalidate_by_id(WC_FINANCES, 0); + + // high bit marks the campaign as inactive, on first check the campaign is set actice + // this makes campaigns run a full x weeks even when started in the middle of a week RCT2_ADDRESS(0x01358102, uint8)[i] &= ~(1 << 7); if (campaign_weeks_left & (1 << 7)) continue; @@ -767,12 +767,12 @@ void scenario_marketing_update() RCT2_GLOBAL(0x013CE954, uint32) = RCT2_GLOBAL(0x01362944 + 152 * campaign_item, uint32); } else if (i == 3) { // free food/merch campaign_item += 2016; - if (campaign_item < 2048) + if (campaign_item >= 2048) campaign_item += 96; RCT2_GLOBAL(0x013CE952, uint16) = campaign_item; } - RCT2_CALLPROC_X(0x0066DF55, 4, base_str + i, 0, 0, 0, 0, 0); // dispatch news + news_item_add_to_queue(NEWS_ITEM_MONEY, STR_MARKETING_FINISHED_BASE + i, 0); } } From 15fc63eecb33906081058bc9f12834cb36fdf367 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Sat, 3 May 2014 13:43:57 +0200 Subject: [PATCH 26/29] Refactoring --- src/scenario.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index 81cabd6918..344e47bf17 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -594,19 +594,19 @@ void objective_check_10_rollercoasters() memset(type_already_counted, 0, 256); for (i = 0; i < 255; i++) { - uint8 rc_type; - uint32 rollercoaster_p; + uint8 subtype_id; + uint32 subtype_p; ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); if (ride->type == RIDE_TYPE_NULL) continue; - rc_type = ride->var_001; - rollercoaster_p = RCT2_GLOBAL(0x009ACFA4 + rc_type*4, uint32); + subtype_id = ride->var_001; + subtype_p = RCT2_GLOBAL(0x009ACFA4 + subtype_id * 4, uint32); - if ((RCT2_GLOBAL(rollercoaster_p + 0x1BE, sint8) == 2 || - RCT2_GLOBAL(rollercoaster_p + 0x1BF, sint8) == 2 )&& + if ((RCT2_GLOBAL(subtype_p + 0x1BE, sint8) == 2 || + RCT2_GLOBAL(subtype_p + 0x1BF, sint8) == 2) && ride->status == RIDE_STATUS_OPEN && - ride->var_140 >= 600 && type_already_counted[rc_type] == 0){ - type_already_counted[rc_type]++; + ride->var_140 >= 600 && type_already_counted[subtype_id] == 0){ + type_already_counted[subtype_id]++; rcs++; } } From 02ae959a850cd27a1c05287b0fe8502fcadc46fb Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Sat, 3 May 2014 14:31:23 +0200 Subject: [PATCH 27/29] Implemented check for objective 8 (10 rollercoasters, min excitement, min length) --- src/scenario.c | 56 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/src/scenario.c b/src/scenario.c index 344e47bf17..846bfd89a3 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -585,21 +585,21 @@ void scenario_success() } -void objective_check_10_rollercoasters() +void scenario_objective5_check() { - int i, rcs = 0; + int rcs = 0; uint8 type_already_counted[256]; rct_ride* ride; memset(type_already_counted, 0, 256); - for (i = 0; i < 255; i++) { + for (int i = 0; i < 255; i++) { uint8 subtype_id; uint32 subtype_p; ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); if (ride->type == RIDE_TYPE_NULL) continue; - subtype_id = ride->var_001; + subtype_id = (uint8)ride->var_001; subtype_p = RCT2_GLOBAL(0x009ACFA4 + subtype_id * 4, uint32); if ((RCT2_GLOBAL(subtype_p + 0x1BE, sint8) == 2 || @@ -616,6 +616,47 @@ void objective_check_10_rollercoasters() } +void scenario_objective8_check() +{ + int rcs = 0; + uint8 type_already_counted[256]; + rct_ride* ride; + sint16 objective_length = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS, uint16); + + memset(type_already_counted, 0, 256); + + for (int i = 0; i < 255; i++) { + uint8 subtype_id; + uint32 subtype_p; + ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); + if (ride->type == RIDE_TYPE_NULL) + continue; + subtype_id = (uint8)ride->var_001; + subtype_p = RCT2_GLOBAL(0x009ACFA4 + subtype_id * 4, uint32); + + if ((RCT2_GLOBAL(subtype_p + 0x1BE, sint8) == 2 || + RCT2_GLOBAL(subtype_p + 0x1BF, sint8) == 2) && + ride->status == RIDE_STATUS_OPEN && + ride->var_140 >= 600 && type_already_counted[subtype_id] == 0){ + + uint8 limit = ride->pad_088[63]; + uint32 sum = 0; + for (int j = 0; j < limit; ++j) { + sum += ((uint32*)&ride->pad_088[92])[j]; + } + if ((sum >> 16) > objective_length) { + type_already_counted[subtype_id]++; + rcs++; + } + } + } + + if (rcs >= 10) + scenario_success(); +} + + + /* * rct2: 0x0066A4B2 **/ @@ -658,7 +699,7 @@ void scenario_objectives_check() case OBJECTIVE_10_ROLLERCOASTERS://5 - objective_check_10_rollercoasters(); + scenario_objective5_check(); break; case OBJECTIVE_GUESTS_AND_RATING://6 @@ -676,7 +717,8 @@ void scenario_objectives_check() } case OBJECTIVE_10_ROLLERCOASTERS_LENGTH://8 - RCT2_CALLPROC_EBPSAFE(0x0066A6B5); + scenario_objective8_check(); + //RCT2_CALLPROC_EBPSAFE(0x0066A6B5); break; case OBJECTIVE_FINISH_5_ROLLERCOASTERS://9 @@ -685,7 +727,7 @@ void scenario_objectives_check() int rcs = 0; for (int i = 0; i < 255; i++) { ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); - if (ride->status && ride->intensity > objective_currency) + if (ride->status && ride->var_140 > objective_currency) rcs++; } if (rcs >= 5) From 97cab96ea6ba2127eee999d18c8f9289ad66fd77 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Sat, 3 May 2014 14:51:35 +0200 Subject: [PATCH 28/29] Renamed some ride values and some fixups from the merge. --- src/news_item.h | 1 + src/park.c | 12 ++++++------ src/ride.h | 16 +++++++++------- src/scenario.c | 28 ++++++++++++++++++---------- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/news_item.h b/src/news_item.h index 4b49fd123a..3de7ada5a5 100644 --- a/src/news_item.h +++ b/src/news_item.h @@ -22,6 +22,7 @@ #define _NEWS_ITEM_H_ #include "rct2.h" +#include "map.h" #include "strings.h" diff --git a/src/park.c b/src/park.c index 13f3728c2f..ede941b52a 100644 --- a/src/park.c +++ b/src/park.c @@ -157,10 +157,10 @@ int calculate_park_rating() if (ride->type == RIDE_TYPE_NULL) continue; - if (ride->var_140 == -1) + if (ride->excitement == -1) continue; - _ax += ride->var_140 / 8; - _bx += ride->var_142 / 8; + _ax += ride->excitement / 8; + _bx += ride->intensity / 8; } _ax = min(1000, _ax); _bx = min(1000, _bx); @@ -198,10 +198,10 @@ int calculate_park_rating() if (ride->type == RIDE_TYPE_NULL) continue; - if (ride->var_140 == -1) + if (ride->excitement == -1) continue; - _ax += ride->var_140 / 8; - _bx += ride->var_142 / 8; + _ax += ride->excitement / 8; + _bx += ride->intensity / 8; num_rides++; } diff --git a/src/ride.h b/src/ride.h index d7a251dbeb..2519125595 100644 --- a/src/ride.h +++ b/src/ride.h @@ -29,7 +29,9 @@ */ typedef struct { uint8 type; // 0x000 - uint32 var_001; + uint8 subtype; // 0x001 + uint16 pad_002; + uint8 var_004; uint8 pad_005[0x44]; uint8 status; // 0x049 uint16 var_04A; @@ -40,9 +42,9 @@ typedef struct { uint8 pad_072[0x14]; uint16 train_car_map[1]; // 0x86 Points to the first car in the train uint8 pad_088[0x68]; - sint16 excitement; // 0x0F0 - sint16 intensity; // 0x0F2 - sint16 nausea; // 0x0F4 + sint16 var_0F0; + sint16 var_0F2; + sint16 var_0F4; uint8 pad_0F6[0x2E]; sint16 var_124; sint16 var_126; @@ -55,9 +57,9 @@ typedef struct { sint16 var_134; sint16 var_136; uint8 pad_138[0x08]; - sint16 var_140; - sint16 var_142; - uint16 pad_144; + sint16 excitement; // 0x140 + sint16 intensity; // 0x142 + uint16 nausea; // 0x144 uint16 reliability; // 0x146 uint16 pad_148; uint16 var_14A; diff --git a/src/scenario.c b/src/scenario.c index 846bfd89a3..717cc27b35 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -584,7 +584,11 @@ void scenario_success() scenario_end(); } - +/** +* Checks if there are 10 rollercoasters of different subtype with +* excitement >= 600 . +* rct2: +**/ void scenario_objective5_check() { int rcs = 0; @@ -599,13 +603,13 @@ void scenario_objective5_check() ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); if (ride->type == RIDE_TYPE_NULL) continue; - subtype_id = (uint8)ride->var_001; + subtype_id = (uint8)ride->subtype; subtype_p = RCT2_GLOBAL(0x009ACFA4 + subtype_id * 4, uint32); if ((RCT2_GLOBAL(subtype_p + 0x1BE, sint8) == 2 || RCT2_GLOBAL(subtype_p + 0x1BF, sint8) == 2) && ride->status == RIDE_STATUS_OPEN && - ride->var_140 >= 600 && type_already_counted[subtype_id] == 0){ + ride->excitement >= 600 && type_already_counted[subtype_id] == 0){ type_already_counted[subtype_id]++; rcs++; } @@ -615,7 +619,11 @@ void scenario_objective5_check() scenario_success(); } - +/** + * Checks if there are 10 rollercoasters of different subtype with + * excitement > 700 and a minimum length; + * rct2: 0x0066A6B5 + **/ void scenario_objective8_check() { int rcs = 0; @@ -631,14 +639,15 @@ void scenario_objective8_check() ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); if (ride->type == RIDE_TYPE_NULL) continue; - subtype_id = (uint8)ride->var_001; + subtype_id = (uint8)ride->subtype; subtype_p = RCT2_GLOBAL(0x009ACFA4 + subtype_id * 4, uint32); if ((RCT2_GLOBAL(subtype_p + 0x1BE, sint8) == 2 || RCT2_GLOBAL(subtype_p + 0x1BF, sint8) == 2) && ride->status == RIDE_STATUS_OPEN && - ride->var_140 >= 600 && type_already_counted[subtype_id] == 0){ + ride->excitement >= 600 && 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]; uint32 sum = 0; for (int j = 0; j < limit; ++j) { @@ -718,7 +727,6 @@ void scenario_objectives_check() case OBJECTIVE_10_ROLLERCOASTERS_LENGTH://8 scenario_objective8_check(); - //RCT2_CALLPROC_EBPSAFE(0x0066A6B5); break; case OBJECTIVE_FINISH_5_ROLLERCOASTERS://9 @@ -727,7 +735,7 @@ void scenario_objectives_check() int rcs = 0; for (int i = 0; i < 255; i++) { ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); - if (ride->status && ride->var_140 > objective_currency) + if (ride->status && ride->excitement > objective_currency) rcs++; } if (rcs >= 5) @@ -764,9 +772,9 @@ void scneario_entrance_fee_too_high_check() uint16 magic = RCT2_GLOBAL(0x013580EE, uint16), park_entrance_fee = RCT2_GLOBAL(RCT2_ADDRESS_PARK_ENTRANCE_FEE, uint16); int max_fee = magic + (magic / 2); - uint32 game_flags = RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32), packed_xy; + uint32 game_flags = RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), packed_xy; - if (game_flags & GAME_FLAGS_PARK_OPEN && park_entrance_fee > max_fee) { + if (game_flags & PARK_FLAGS_PARK_OPEN && park_entrance_fee > max_fee) { for (int i = 0; RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL; ++i) { x = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] + 16; y = RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_Y, uint16)[i] + 16; From 72adb4d8bf7d05a3f4b0eab09ab19aacbd8bc948 Mon Sep 17 00:00:00 2001 From: Matthias Lanzinger Date: Sat, 3 May 2014 14:57:50 +0200 Subject: [PATCH 29/29] Documentation and copyright. --- src/news_item.c | 2 +- src/scenario.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/news_item.c b/src/news_item.c index 8cffbc5456..624c1b3aeb 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 Ted John, Peter Hill + * Copyright (c) 2014 Ted John, Peter Hill, Matthias Lanzinger * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. diff --git a/src/scenario.c b/src/scenario.c index 717cc27b35..cd725b82a6 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -667,6 +667,7 @@ void scenario_objective8_check() /* + * Checks the win/lose conditions of the current objective. * rct2: 0x0066A4B2 **/ void scenario_objectives_check() @@ -764,8 +765,9 @@ void scenario_objectives_check() /* -* rct2: 0x0066A80E -**/ + * Send a warning when entrance price is too high. + * rct2: 0x0066A80E + **/ void scneario_entrance_fee_too_high_check() { uint16 x, y; @@ -787,8 +789,9 @@ void scneario_entrance_fee_too_high_check() /* -* rct2: 0x0069E0C1 -**/ + * Update status of marketing campaigns and send a message when they are done. + * rct2: 0x0069E0C1 + **/ void scenario_marketing_update() { for (int i = 0; i < 6; ++i) { @@ -828,6 +831,7 @@ void scenario_marketing_update() /* + * Scenario and finance related update iteration. * rct2: 0x006C44B1 **/ void scenario_update() @@ -847,7 +851,7 @@ void scenario_update() RCT2_CALLPROC_EBPSAFE(0x0069E79A); // finance update RCT2_CALLPROC_EBPSAFE(0x0069C35E); // some kind of peeps days_visited update loop RCT2_CALLPROC_EBPSAFE(0x006C45E7); // get local time - RCT2_CALLPROC_EBPSAFE(0x0066A13C); // check_objective_6 + RCT2_CALLPROC_EBPSAFE(0x0066A13C); // objective 6 dragging if (objective_type == 10 || objective_type == 9 || objective_type == 8 || objective_type == 6 || objective_type == 5) { scenario_objectives_check();