diff --git a/src/management/research.c b/src/management/research.c index 9d518a0e47..4aac4d1b3e 100644 --- a/src/management/research.c +++ b/src/management/research.c @@ -24,6 +24,7 @@ #include "../world/scenery.h" #include "news_item.h" #include "research.h" +#include "../scenario.h" const int _researchRate[] = { 0, 160, 250, 400 }; @@ -259,4 +260,61 @@ void research_update() break; } } +} + +/* rct2: 0x684AC3*/ +void sub_684AC3(){ + rct_research_item* research = gResearchItems; + for (; research->entryIndex != -2; research++); + + research++; + for (; research->entryIndex != -3; research += 2){ + if (scenario_rand() & 1) continue; + + + rct_research_item* edx; + rct_research_item* ebp; + for (rct_research_item* inner_research = gResearchItems; inner_research->entryIndex != -2; inner_research++){ + if (research->entryIndex == inner_research->entryIndex){ + edx = inner_research; + } + if ((research + 1)->entryIndex == inner_research->entryIndex){ + ebp = inner_research; + } + } + edx->entryIndex = research->entryIndex; + ebp->entryIndex = (research + 1)->entryIndex; + + uint8 cat = edx->category; + edx->category = ebp->category; + ebp->category = cat; + } + + for (int i = 0; i < 8; ++i){ + RCT2_ADDRESS(0x01357404, uint32)[i] = 0; + RCT2_ADDRESS(0x01357424, uint32)[i] = 0; + } + + for (int i = 0; i < 56; i++){ + RCT2_ADDRESS(0x01357BD0, uint32)[i] = -1; + } + + for (int i = 0; i < 19; ++i){ + rct_scenery_set_entry* scenery_set = g_scenerySetEntries[i]; + if ((int)scenery_set == -1)continue; + + for (int j = 0; j < scenery_set->entry_count; ++j){ + uint8 value = scenery_set->scenery_entries[j] & 0x1F; + RCT2_ADDRESS(0x01357BD0, uint32)[scenery_set->scenery_entries[j] >> 5] &= ~(1 << value); + } + } + + + for (research = gResearchItems; research->entryIndex != -1; research++){ + research_finish_item(research->entryIndex); + } + + RCT2_GLOBAL(RCT2_ADDRESS_LAST_RESEARCHED_ITEM_SUBJECT, sint32) = -1; + RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS, uint16) = 0; } \ No newline at end of file diff --git a/src/management/research.h b/src/management/research.h index 1194798dd8..f2789fd151 100644 --- a/src/management/research.h +++ b/src/management/research.h @@ -52,5 +52,6 @@ extern uint8 gResearchUncompletedCategories; void research_reset_items(); void research_update_uncompleted_types(); void research_update(); +void sub_684AC3(); #endif \ No newline at end of file diff --git a/src/scenario.c b/src/scenario.c index 0409a4aadf..547e8e66ee 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -26,6 +26,7 @@ #include "management/award.h" #include "management/finance.h" #include "management/marketing.h" +#include "management/research.h" #include "management/news_item.h" #include "object.h" #include "platform/platform.h" @@ -248,7 +249,7 @@ int scenario_load_and_play_from_path(const char *path) RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) &= 0xFFFFF7FF; if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) & PARK_FLAGS_NO_MONEY_SCENARIO) RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, sint32) |= PARK_FLAGS_NO_MONEY; - RCT2_CALLPROC_EBPSAFE(0x00684AC3); + sub_684AC3(); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); news_item_init_queue(); if (RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) != OBJECTIVE_NONE) @@ -1039,4 +1040,4 @@ void scenario_success_submit_name(const char *name) } RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) &= ~PARK_FLAGS_SCENARIO_COMPLETE_NAME_INPUT; -} \ No newline at end of file +} diff --git a/src/title.c b/src/title.c index 018277050d..fb5be0b882 100644 --- a/src/title.c +++ b/src/title.c @@ -31,6 +31,7 @@ #include "interface/viewport.h" #include "intro.h" #include "management/news_item.h" +#include "management/research.h" #include "ride/ride.h" #include "scenario.h" #include "world/climate.h" @@ -194,7 +195,7 @@ static void title_update_showcase() window_invalidate(w); sub_69E9A7(); window_new_ride_init_vars(); - RCT2_CALLPROC_EBPSAFE(0x00684AC3); + sub_684AC3(); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); news_item_init_queue(); gfx_invalidate_screen();