Implement the reset ride research function

This commit is contained in:
Duncan Frost 2015-06-04 21:15:00 +01:00
parent f4a4df1cb5
commit cd22f9bd08
1 changed files with 79 additions and 1 deletions

View File

@ -158,19 +158,97 @@ rct_research_item *_editorInventionsListDraggedItem;
#define WindowHighlightedItem(w) *((rct_research_item**)&(w->var_494))
static void window_editor_inventions_list_drag_open(rct_research_item *researchItem);
static void move_research_item(rct_research_item *beforeItem);
static int research_item_is_always_researched(rct_research_item *researchItem)
{
return (researchItem->entryIndex & 0x60000000) != 0;
}
/* rct2: 0x0068596F */
static void sub_68596F(){
// Reset all objects to not required
for (uint8 object_type = OBJECT_TYPE_RIDE; object_type < 11; object_type++){
uint8* esi = RCT2_ADDRESS(0x0098DA38, uint8*)[object_type];
for (uint8 num_objects = object_entry_group_counts[object_type]; num_objects != 0; num_objects--){
*esi++ = 0;
}
}
// Set research required for rides in use
for (uint16 rideIndex = 0; rideIndex <= 0xFF; rideIndex++){
rct_ride* ride = &g_ride_list[rideIndex];
if (ride->type == RIDE_TYPE_NULL)continue;
RCT2_ADDRESS(0x0098DA38, uint8*)[OBJECT_TYPE_RIDE][ride->subtype] |= 1;
}
for (rct_research_item* research = gResearchItems; research->entryIndex != RESEARCHED_ITEMS_END; research++){
if (research->entryIndex & (1 << 30))
continue;
// If not a ride
if ((research->entryIndex & 0xFFFFFF) < 0x10000)
continue;
uint8 ah = (research->entryIndex >> 8) & 0xFF;
uint8 object_index = research->entryIndex & 0xFF;
rct_ride_type* ride_entry = GET_RIDE_ENTRY(object_index);
uint8 master_found = 0;
if (!(ride_entry->var_008 & (1 << 13))){
for (uint8 rideType = 0; rideType < object_entry_group_counts[OBJECT_TYPE_RIDE]; rideType++){
rct_ride_type* master_ride = GET_RIDE_ENTRY(rideType);
if (master_ride == NULL || (uint32)master_ride == 0xFFFFFFFF)
continue;
if (master_ride->var_008 & (1 << 13))
continue;
if (!(RCT2_ADDRESS(0x0098DA38, uint8*)[OBJECT_TYPE_RIDE][rideType] & (1 << 0)))
continue;
if (ah == master_ride->ride_type[0] ||
ah == master_ride->ride_type[1] ||
ah == master_ride->ride_type[2]){
master_found = 1;
break;
}
}
}
if (!master_found){
if (!(RCT2_ADDRESS(0x0098DA38, uint8*)[OBJECT_TYPE_RIDE][object_index] & (1 << 0)))
continue;
if (ah != ride_entry->ride_type[0] &&
ah != ride_entry->ride_type[1] &&
ah != ride_entry->ride_type[2]){
continue;
}
}
research->entryIndex |= (1 << 30);
_editorInventionsListDraggedItem = research;
move_research_item(gResearchItems);
_editorInventionsListDraggedItem = NULL;
research--;
}
}
/* rct2: 0x0068590C */
static void sub_68590C(){
RCT2_CALLPROC_EBPSAFE(0x0068590C);
}
/**
*
* rct2: 0x00685901
*/
static void sub_685901()
{
RCT2_CALLPROC_EBPSAFE(0x00685901);
sub_68596F();
sub_68590C();
}
/**