From 475c98c5404b65d6716bc42f34e3afe2bf43b0b6 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sat, 24 Jan 2015 18:41:55 +0000 Subject: [PATCH] implement game_command_set_research_funding --- src/game.c | 4 ++-- src/management/research.c | 41 ++++++++++++++++++++++++++++++++++++++- src/management/research.h | 4 ++++ src/windows/finances.c | 4 ++-- src/windows/research.c | 4 ++-- 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/game.c b/src/game.c index 594f6ca3a3..b8fbee2836 100644 --- a/src/game.c +++ b/src/game.c @@ -905,7 +905,7 @@ static uint32 game_do_command_table[58] = { 0x006B893C, 0x006B8E1B, 0x0069DFB3, - 0x00684A7F, + 0, 0x006D13FE, 0, 0x006CDEE4, @@ -968,7 +968,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_emptysub, game_command_emptysub, game_command_emptysub, - game_command_emptysub, + game_command_set_research_funding, game_command_emptysub, game_command_start_campaign, game_command_emptysub, diff --git a/src/management/research.c b/src/management/research.c index 4aac4d1b3e..6c309d7aa7 100644 --- a/src/management/research.c +++ b/src/management/research.c @@ -19,6 +19,7 @@ *****************************************************************************/ #include "../addresses.h" +#include "../game.h" #include "../interface/window.h" #include "../localisation/date.h" #include "../world/scenery.h" @@ -262,7 +263,10 @@ void research_update() } } -/* rct2: 0x684AC3*/ +/** + * + * rct2: 0x00684AC3 + */ void sub_684AC3(){ rct_research_item* research = gResearchItems; for (; research->entryIndex != -2; research++); @@ -317,4 +321,39 @@ void sub_684AC3(){ 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; +} + +void research_set_funding(int amount) +{ + game_do_command(0, GAME_COMMAND_FLAG_APPLY, 0, amount, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0); + +} + +void research_set_priority(int activeCategories) +{ + game_do_command(0, (1 << 8) | GAME_COMMAND_FLAG_APPLY, 0, activeCategories, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0); +} + +/** + * + * rct2: 0x00684A7F + */ +void game_command_set_research_funding(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) +{ + int setPriorities = (*ebx & (1 << 8)) != 0; + int fundingAmount = *edx; + int activeCategories = *edx; + + RCT2_GLOBAL(0x0141F56C, uint8) = 48; + if (*ebx & GAME_COMMAND_FLAG_APPLY) { + if (!setPriorities) + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RESEARCH_LEVEL, uint8) = fundingAmount; + else + RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint8) = activeCategories; + + window_invalidate_by_class(WC_FINANCES); + window_invalidate_by_class(WC_RESEARCH); + } + + *ebx = 0; } \ No newline at end of file diff --git a/src/management/research.h b/src/management/research.h index 0a07d36d1c..b62d84d4de 100644 --- a/src/management/research.h +++ b/src/management/research.h @@ -55,4 +55,8 @@ void research_update_uncompleted_types(); void research_update(); void sub_684AC3(); +void research_set_funding(int amount); +void research_set_priority(int activeCategories); +void game_command_set_research_funding(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); + #endif \ No newline at end of file diff --git a/src/windows/finances.c b/src/windows/finances.c index 3d20213bdc..84f8732025 100644 --- a/src/windows/finances.c +++ b/src/windows/finances.c @@ -1340,7 +1340,7 @@ static void window_finances_research_mouseup() case WIDX_SCENERY_AND_THEMING: activeResearchTypes = RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint16); activeResearchTypes ^= 1 << (widgetIndex - WIDX_TRANSPORT_RIDES); - game_do_command(0, (1 << 8) | 1, 0, activeResearchTypes, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0); + research_set_priority(activeResearchTypes); break; } } @@ -1392,7 +1392,7 @@ static void window_finances_research_dropdown() if (widgetIndex != WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON || dropdownIndex == -1) return; - game_do_command(0, 1, 0, dropdownIndex, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0); + research_set_funding(dropdownIndex); } /** diff --git a/src/windows/research.c b/src/windows/research.c index a06bc5a02c..22d808afa6 100644 --- a/src/windows/research.c +++ b/src/windows/research.c @@ -430,7 +430,7 @@ static void window_research_funding_mouseup() case WIDX_SCENERY_AND_THEMING: activeResearchTypes = RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint16); activeResearchTypes ^= 1 << (widgetIndex - WIDX_TRANSPORT_RIDES); - game_do_command(0, (1 << 8) | 1, 0, activeResearchTypes, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0); + research_set_priority(activeResearchTypes); break; } } @@ -482,7 +482,7 @@ static void window_research_funding_dropdown() if (widgetIndex != WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON || dropdownIndex == -1) return; - game_do_command(0, 1, 0, dropdownIndex, GAME_COMMAND_SET_RESEARCH_FUNDING, 0, 0); + research_set_funding(dropdownIndex); window_invalidate(w); }