mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-18 12:33:17 +01:00
implement research_update_uncompleted_types and refactor research
This commit is contained in:
@@ -24,8 +24,33 @@
|
||||
#include "rct2.h"
|
||||
#include "window.h"
|
||||
|
||||
typedef struct {
|
||||
sint32 var_0;
|
||||
uint8 category;
|
||||
} rct_research_item;
|
||||
|
||||
const int _researchRate[] = { 0, 160, 250, 400 };
|
||||
|
||||
// 0x00EE787C
|
||||
uint8 gResearchUncompletedCategories;
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00684BAE
|
||||
*/
|
||||
void research_update_uncompleted_types()
|
||||
{
|
||||
int uncompletedResearchTypes = 0;
|
||||
rct_research_item *researchItem = (rct_research_item*)0x001358844;
|
||||
while (researchItem->var_0 != -1)
|
||||
researchItem++;
|
||||
researchItem++;
|
||||
for (; researchItem->var_0 != -2; researchItem++)
|
||||
uncompletedResearchTypes |= (1 << researchItem->category);
|
||||
|
||||
gResearchUncompletedCategories = uncompletedResearchTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00684D2A
|
||||
@@ -94,11 +119,10 @@ void research_update()
|
||||
break;
|
||||
case RESEARCH_STAGE_COMPLETING_DESIGN:
|
||||
RCT2_CALLPROC_X(0x006848D4, RCT2_GLOBAL(0x013580E0, uint32), 0, 0, 0, 0, 0, 0);
|
||||
RCT2_CALLPROC_EBPSAFE(0x006848D4);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_RESEARH_PROGRESS_STAGE, uint8) = 0;
|
||||
research_calculate_expected_date();
|
||||
RCT2_CALLPROC_EBPSAFE(0x00684BAE);
|
||||
research_update_uncompleted_types();
|
||||
window_invalidate_by_id(WC_CONSTRUCT_RIDE, 0);
|
||||
window_invalidate_by_id(WC_RESEARCH, 0);
|
||||
break;
|
||||
|
||||
@@ -35,6 +35,9 @@ enum {
|
||||
RESEARCH_STAGE_UNKNOWN
|
||||
};
|
||||
|
||||
extern uint8 gResearchUncompletedCategories;
|
||||
|
||||
void research_update_uncompleted_types();
|
||||
void research_update();
|
||||
|
||||
#endif
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "game.h"
|
||||
#include "graph.h"
|
||||
#include "marketing.h"
|
||||
#include "research.h"
|
||||
#include "ride.h"
|
||||
#include "scenario.h"
|
||||
#include "string_ids.h"
|
||||
@@ -535,7 +536,7 @@ void window_finances_open()
|
||||
w->colours[0] = 1;
|
||||
w->colours[1] = 19;
|
||||
w->colours[2] = 19;
|
||||
RCT2_CALLPROC_EBPSAFE(0x00684BAE);
|
||||
research_update_uncompleted_types();
|
||||
}
|
||||
|
||||
w->page = 0;
|
||||
@@ -1434,7 +1435,7 @@ static void window_finances_research_invalidate()
|
||||
|
||||
// Checkboxes
|
||||
int activeResearchTypes = RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint16);
|
||||
int uncompletedResearchTypes = RCT2_GLOBAL(RCT2_ADDRESS_UNCOMPLETED_RESEARCH_TYPES, uint16);
|
||||
int uncompletedResearchTypes = gResearchUncompletedCategories;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int mask = 1 << i;
|
||||
int widgetMask = 1 << (i + WIDX_TRANSPORT_RIDES);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "finance.h"
|
||||
#include "game.h"
|
||||
#include "news_item.h"
|
||||
#include "research.h"
|
||||
#include "ride.h"
|
||||
#include "scenery.h"
|
||||
#include "string_ids.h"
|
||||
@@ -236,7 +237,7 @@ void window_research_open()
|
||||
w->colours[0] = 1;
|
||||
w->colours[1] = 19;
|
||||
w->colours[2] = 19;
|
||||
RCT2_CALLPROC_EBPSAFE(0x00684BAE);
|
||||
research_update_uncompleted_types();
|
||||
}
|
||||
|
||||
w->page = 0;
|
||||
@@ -529,13 +530,13 @@ static void window_research_funding_invalidate()
|
||||
|
||||
// Checkboxes
|
||||
int activeResearchTypes = RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_RESEARCH_TYPES, uint16);
|
||||
int uncompletedResearchTypes = RCT2_GLOBAL(RCT2_ADDRESS_UNCOMPLETED_RESEARCH_TYPES, uint16);
|
||||
int uncompletedResearchTypes = gResearchUncompletedCategories;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int mask = 1 << i;
|
||||
int widgetMask = 1 << (i + WIDX_TRANSPORT_RIDES);
|
||||
|
||||
// Set checkbox disabled if research type is complete
|
||||
if (uncompletedResearchTypes & mask) {
|
||||
if (gResearchUncompletedCategories & mask) {
|
||||
w->disabled_widgets &= ~widgetMask;
|
||||
|
||||
// Set checkbox ticked if research type is active
|
||||
|
||||
Reference in New Issue
Block a user