implement game_command_set_research_funding

This commit is contained in:
IntelOrca 2015-01-24 18:41:55 +00:00
parent eec7e2e458
commit 475c98c540
5 changed files with 50 additions and 7 deletions

View File

@ -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,

View File

@ -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;
}

View File

@ -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

View File

@ -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);
}
/**

View File

@ -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);
}