From c788f36787b2e3198b9c34f77dcb3c1724c2a5f3 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Thu, 1 May 2014 15:07:51 +0100 Subject: [PATCH 01/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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