From ac23ef2787b46052b190f031a86201fa404775fe Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 28 Mar 2015 12:42:09 +0000 Subject: [PATCH] Research now resets funding when all rides finished. New string to indicate reasearch complete --- data/language/english_uk.txt | 2 +- src/management/research.c | 4 +- src/management/research.h | 3 +- src/ride/ride.c | 5 +-- src/windows/finances.c | 5 ++- src/windows/new_ride.c | 76 ++++++++++++++++++++-------------- src/windows/research.c | 79 +++++++++++++++++++++--------------- 7 files changed, 105 insertions(+), 69 deletions(-) diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index 787a3012ae..f14ec5dee5 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -2682,7 +2682,7 @@ STR_2676 :??? STR_2677 :??? STR_2678 :??? STR_2679 :??? -STR_2680 :??? +STR_2680 :All research complete STR_2681 :{MEDIUMFONT}{BLACK}Increases your money by 5,000 STR_2682 :{MEDIUMFONT}{BLACK}Toggle between Free and Paid Entry STR_2683 :{MEDIUMFONT}{BLACK}Increases every peeps happiness to max diff --git a/src/management/research.c b/src/management/research.c index 94436bab4a..f6413c5411 100644 --- a/src/management/research.c +++ b/src/management/research.c @@ -128,8 +128,10 @@ static void research_next_design() continue; } else { RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS, uint16) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) = RESEARCH_STAGE_INITIAL_RESEARCH; + RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) = RESEARCH_STAGE_FINISHED_ALL; research_invalidate_related_windows(); + // Reset funding to 0 if no more rides. + research_set_funding(0); return; } } else if (ignoreActiveResearchTypes || (activeResearchTypes & (1 << researchItem->category))) { diff --git a/src/management/research.h b/src/management/research.h index b62d84d4de..4ced61a8e4 100644 --- a/src/management/research.h +++ b/src/management/research.h @@ -44,7 +44,8 @@ enum { RESEARCH_STAGE_INITIAL_RESEARCH, RESEARCH_STAGE_DESIGNING, RESEARCH_STAGE_COMPLETING_DESIGN, - RESEARCH_STAGE_UNKNOWN + RESEARCH_STAGE_UNKNOWN, + RESEARCH_STAGE_FINISHED_ALL }; extern rct_research_item *gResearchItems; diff --git a/src/ride/ride.c b/src/ride/ride.c index 328a4ab704..d6aea2f4b7 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -1083,9 +1083,8 @@ void ride_update_all() rct_ride *ride; int i; - // Remove all rides if certain flags are set (possible scenario editor?) - int *esi = (int*)0x9DCE9E; - if (esi[0x1BCA] & 2) { + // Remove all rides if scenario editor + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) { if (s6Info->var_000 <= 2) FOR_ALL_RIDES(i, ride) ride->type = RIDE_TYPE_NULL; diff --git a/src/windows/finances.c b/src/windows/finances.c index fc47d3aefa..be5720f211 100644 --- a/src/windows/finances.c +++ b/src/windows/finances.c @@ -1430,7 +1430,10 @@ static void window_finances_research_invalidate() } window_finances_set_pressed_tab(w); - + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) == RESEARCH_STAGE_FINISHED_ALL) { + window_finances_research_widgets[WIDX_RESEARCH_FUNDING].type = WWT_EMPTY; + window_finances_research_widgets[WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON].type = WWT_EMPTY; + } int currentResearchLevel = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8); // Current funding diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index a4a3ab51b6..e234a19fcb 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -22,6 +22,7 @@ #include "../audio/audio.h" #include "../game.h" #include "../management/news_item.h" +#include "../management/research.h" #include "../ride/ride.h" #include "../localisation/localisation.h" #include "../world/scenery.h" @@ -759,43 +760,58 @@ static void window_new_ride_paint() int x = w->x + 10; int y = w->y + window_new_ride_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].top + 12; + rct_string_id stringId; - // Research type - rct_string_id stringId = STR_RESEARCH_UNKNOWN; - if (RCT2_GLOBAL(0x01357CF3, uint8) != 0) { - stringId = STR_TRANSPORT_RIDE + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_CATEGORY, uint8); - if (RCT2_GLOBAL(0x01357CF3, uint8) != 1) { - uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_ITEM, uint32); - if (typeId >= 0x10000) { - rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); - stringId = rideEntry->var_008 & 0x1000 ? - rideEntry->name : - (typeId & 0xFF00) + 2; - } else { - stringId = g_scenerySetEntries[typeId]->name; + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) == RESEARCH_STAGE_FINISHED_ALL){ + stringId = STR_RESEARCH_UNKNOWN; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); + y += 25; + // Progress + stringId = 2680; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); + y += 15; + + RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; + gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); + } + else{ + // Research type + stringId = STR_RESEARCH_UNKNOWN; + if (RCT2_GLOBAL(0x01357CF3, uint8) != 0) { + stringId = STR_TRANSPORT_RIDE + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_CATEGORY, uint8); + if (RCT2_GLOBAL(0x01357CF3, uint8) != 1) { + uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_ITEM, uint32); + if (typeId >= 0x10000) { + rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); + stringId = rideEntry->var_008 & 0x1000 ? + rideEntry->name : + (typeId & 0xFF00) + 2; + } + else { + stringId = g_scenerySetEntries[typeId]->name; + } } } - } - gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); - y += 25; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); + y += 25; - // Progress - stringId = 2285 + RCT2_GLOBAL(0x01357CF3, uint8); - gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); - y += 15; + // Progress + stringId = 2285 + RCT2_GLOBAL(0x01357CF3, uint8); + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); + y += 15; - // Expected - RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; - if (RCT2_GLOBAL(0x01357CF3, uint8) != 0) { - uint16 expectedDay = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY, uint8); - if (expectedDay != 255) { - RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_DATE_DAY_1 + expectedDay; - RCT2_GLOBAL(0x013CE952 + 4, uint16) = STR_MONTH_MARCH + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH, uint8); - RCT2_GLOBAL(0x013CE952, uint16) = 2289; + // Expected + RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; + if (RCT2_GLOBAL(0x01357CF3, uint8) != 0) { + uint16 expectedDay = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY, uint8); + if (expectedDay != 255) { + RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_DATE_DAY_1 + expectedDay; + RCT2_GLOBAL(0x013CE952 + 4, uint16) = STR_MONTH_MARCH + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH, uint8); + RCT2_GLOBAL(0x013CE952, uint16) = 2289; + } } + gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); } - gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); - // Last development x = w->x + 10; y = w->y + window_new_ride_widgets[WIDX_LAST_DEVELOPMENT_GROUP].top + 12; diff --git a/src/windows/research.c b/src/windows/research.c index 9fc9f5c9da..0b2dd9d9bd 100644 --- a/src/windows/research.c +++ b/src/windows/research.c @@ -339,42 +339,56 @@ static void window_research_development_paint() x = w->x + 10; y = w->y + window_research_development_widgets[WIDX_CURRENTLY_IN_DEVELOPMENT_GROUP].top + 12; - // Research type - stringId = STR_RESEARCH_UNKNOWN; - if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 0) { - stringId = STR_TRANSPORT_RIDE + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_CATEGORY, uint8); - if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 1) { - uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_ITEM, uint32); - if (typeId >= 0x10000) { - rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); - stringId = rideEntry->var_008 & 0x1000 ? - rideEntry->name : - ((typeId >> 8) & 0xFF) + 2; - } else { - stringId = g_scenerySetEntries[typeId]->name; + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) == RESEARCH_STAGE_FINISHED_ALL){ + stringId = STR_RESEARCH_UNKNOWN; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); + y += 25; + // Progress + stringId = 2680; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); + y += 15; + + RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; + gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); + } + else{ + // Research type + stringId = STR_RESEARCH_UNKNOWN; + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 0) { + stringId = STR_TRANSPORT_RIDE + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_CATEGORY, uint8); + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 1) { + uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_ITEM, uint32); + if (typeId >= 0x10000) { + rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); + stringId = rideEntry->var_008 & 0x1000 ? + rideEntry->name : + ((typeId >> 8) & 0xFF) + 2; + } + else { + stringId = g_scenerySetEntries[typeId]->name; + } } } - } - gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); - y += 25; + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_TYPE_LABEL, 0); + y += 25; - // Progress - stringId = 2285 + RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8); - gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); - y += 15; + // Progress + stringId = 2285 + RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8); + gfx_draw_string_left_wrapped(dpi, &stringId, x, y, 296, STR_RESEARCH_PROGRESS_LABEL, 0); + y += 15; - // Expected - RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; - if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 0) { - uint16 expectedDay = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY, uint8); - if (expectedDay != 255) { - RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_DATE_DAY_1 + expectedDay; - RCT2_GLOBAL(0x013CE952 + 4, uint16) = STR_MONTH_MARCH + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH, uint8); - RCT2_GLOBAL(0x013CE952, uint16) = 2289; + // Expected + RCT2_GLOBAL(0x013CE952, uint16) = STR_UNKNOWN; + if (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) != 0) { + uint16 expectedDay = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_DAY, uint8); + if (expectedDay != 255) { + RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_DATE_DAY_1 + expectedDay; + RCT2_GLOBAL(0x013CE952 + 4, uint16) = STR_MONTH_MARCH + RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH, uint8); + RCT2_GLOBAL(0x013CE952, uint16) = 2289; + } } + gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); } - gfx_draw_string_left(dpi, STR_RESEARCH_EXPECTED_LABEL, (void*)0x013CE952, 0, x, y); - // Last development x = w->x + 10; y = w->y + window_research_development_widgets[WIDX_LAST_DEVELOPMENT_GROUP].top + 12; @@ -515,8 +529,9 @@ static void window_research_funding_invalidate() window_research_set_pressed_tab(w); - if ((RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { - window_research_funding_widgets[WIDX_FUNDING_GROUP].type = WWT_EMPTY; + if ((RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY) || + (RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) == RESEARCH_STAGE_FINISHED_ALL)) { + //window_research_funding_widgets[WIDX_FUNDING_GROUP].type = WWT_EMPTY; window_research_funding_widgets[WIDX_RESEARCH_FUNDING].type = WWT_EMPTY; window_research_funding_widgets[WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON].type = WWT_EMPTY; } else {