mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor of research.
Fix bug that would cause a crash on a scenario that had rides with same base type
This commit is contained in:
parent
9ad775625a
commit
4f03b0c997
|
@ -57,10 +57,9 @@ void research_update_uncompleted_types()
|
|||
{
|
||||
int uncompletedResearchTypes = 0;
|
||||
rct_research_item *researchItem = gResearchItems;
|
||||
while (researchItem->entryIndex != -1)
|
||||
researchItem++;
|
||||
researchItem++;
|
||||
for (; researchItem->entryIndex != -2; researchItem++)
|
||||
while (researchItem++->entryIndex != RESEARCHED_ITEMS_SEPERATOR);
|
||||
|
||||
for (; researchItem->entryIndex != RESEARCHED_ITEMS_END; researchItem++)
|
||||
uncompletedResearchTypes |= (1 << researchItem->category);
|
||||
|
||||
gResearchUncompletedCategories = uncompletedResearchTypes;
|
||||
|
@ -163,7 +162,7 @@ static void research_next_design()
|
|||
*/
|
||||
void research_finish_item(sint32 entryIndex)
|
||||
{
|
||||
int i, ebx, ecx, rideEntryIndex, subSceneryEntryIndex;
|
||||
int i, ebx, base_ride_type, rideEntryIndex, subSceneryEntryIndex;
|
||||
rct_ride_type *rideEntry, *rideEntry2;
|
||||
rct_scenery_set_entry *scenerySetEntry;
|
||||
|
||||
|
@ -171,14 +170,14 @@ void research_finish_item(sint32 entryIndex)
|
|||
research_invalidate_related_windows();
|
||||
if (entryIndex >= 0x10000) {
|
||||
// Ride
|
||||
ecx = (entryIndex >> 8) & 0xFF;
|
||||
base_ride_type = (entryIndex >> 8) & 0xFF;
|
||||
rideEntryIndex = entryIndex & 0xFF;
|
||||
rideEntry = GET_RIDE_ENTRY(rideEntryIndex);
|
||||
RCT2_ADDRESS(0x01357404, uint32)[ecx >> 5] |= (1 << (ecx & 0x1F));
|
||||
RCT2_ADDRESS(0x01357444, uint32)[ecx] = RCT2_ADDRESS(0x0097C468, uint32)[ecx];
|
||||
RCT2_ADDRESS(0x01357644, uint32)[ecx] = RCT2_ADDRESS(0x0097C5D4, uint32)[ecx];
|
||||
if (RCT2_GLOBAL(0x0097D4F2 + (ecx * 8), uint16) & 8) {
|
||||
ebx = RCT2_GLOBAL(0x0097D4F5 + (ecx * 8), uint8);
|
||||
RCT2_ADDRESS(0x01357404, uint32)[base_ride_type >> 5] |= (1 << (base_ride_type & 0x1F));
|
||||
RCT2_ADDRESS(0x01357444, uint32)[base_ride_type] = RCT2_ADDRESS(0x0097C468, uint32)[base_ride_type];
|
||||
RCT2_ADDRESS(0x01357644, uint32)[base_ride_type] = RCT2_ADDRESS(0x0097C5D4, uint32)[base_ride_type];
|
||||
if (RCT2_GLOBAL(0x0097D4F2 + (base_ride_type * 8), uint16) & 8) {
|
||||
ebx = RCT2_GLOBAL(0x0097D4F5 + (base_ride_type * 8), uint8);
|
||||
RCT2_ADDRESS(0x01357444, uint32)[ebx] = RCT2_ADDRESS(0x0097C468, uint32)[ebx];
|
||||
RCT2_ADDRESS(0x01357644, uint32)[ebx] = RCT2_ADDRESS(0x0097C5D4, uint32)[ebx];
|
||||
}
|
||||
|
@ -191,7 +190,7 @@ void research_finish_item(sint32 entryIndex)
|
|||
if (rideEntry2->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE)
|
||||
continue;
|
||||
|
||||
if (rideEntry2->ride_type[0] == ecx || rideEntry2->ride_type[1] == ecx || rideEntry2->ride_type[2] == ecx)
|
||||
if (rideEntry2->ride_type[0] == base_ride_type || rideEntry2->ride_type[1] == base_ride_type || rideEntry2->ride_type[2] == base_ride_type)
|
||||
RCT2_ADDRESS(0x001357424, uint32)[i >> 5] |= 1 << (i & 0x1F);
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +198,7 @@ void research_finish_item(sint32 entryIndex)
|
|||
// I don't think 0x009AC06C is ever not 0, so probably redundant
|
||||
if (RCT2_GLOBAL(0x009AC06C, uint8) == 0) {
|
||||
RCT2_GLOBAL(0x013CE952, rct_string_id) = rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME ?
|
||||
rideEntry->name : ecx + 2;
|
||||
rideEntry->name : base_ride_type + 2;
|
||||
if (!gSilentResearch)
|
||||
news_item_add_to_queue(NEWS_ITEM_RESEARCH, 2249, entryIndex);
|
||||
}
|
||||
|
@ -292,7 +291,7 @@ void sub_684AC3(){
|
|||
if ((research + 1)->entryIndex == inner_research->entryIndex){
|
||||
ebp = inner_research;
|
||||
}
|
||||
} while ((inner_research++)->entryIndex != -2);
|
||||
} while ((inner_research++)->entryIndex != RESEARCHED_ITEMS_END);
|
||||
edx->entryIndex = research->entryIndex;
|
||||
ebp->entryIndex = (research + 1)->entryIndex;
|
||||
|
||||
|
@ -372,7 +371,7 @@ void research_remove_non_separate_vehicle_types()
|
|||
researchItem2 = researchItem;
|
||||
do {
|
||||
*researchItem2 = *(researchItem2 + 1);
|
||||
} while ((researchItem2++)->entryIndex != RESEARCHED_ITEMS_END);
|
||||
} while ((researchItem2++)->entryIndex != RESEARCHED_ITEMS_END_2);
|
||||
goto loopBeginning;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,11 @@ typedef struct {
|
|||
uint8 category;
|
||||
} rct_research_item;
|
||||
|
||||
enum{
|
||||
RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED = (1 << 29),
|
||||
RESEARCH_ENTRY_FLAG_RIDE_ALWAYS_RESEARCHED = (1 << 30),
|
||||
};
|
||||
|
||||
// Everything before this point has been researched
|
||||
#define RESEARCHED_ITEMS_SEPERATOR -1
|
||||
// Everything before this point and after seperator still requires research
|
||||
|
|
|
@ -162,7 +162,7 @@ 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;
|
||||
return (researchItem->entryIndex & (RESEARCH_ENTRY_FLAG_RIDE_ALWAYS_RESEARCHED | RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED)) != 0;
|
||||
}
|
||||
|
||||
/* rct2: 0x0068596F
|
||||
|
@ -185,7 +185,7 @@ static void research_rides_setup(){
|
|||
}
|
||||
|
||||
for (rct_research_item* research = gResearchItems; research->entryIndex != RESEARCHED_ITEMS_END; research++){
|
||||
if (research->entryIndex & (1 << 30))
|
||||
if (research->entryIndex & RESEARCH_ENTRY_FLAG_RIDE_ALWAYS_RESEARCHED)
|
||||
continue;
|
||||
|
||||
// If not a ride
|
||||
|
@ -232,7 +232,7 @@ static void research_rides_setup(){
|
|||
}
|
||||
}
|
||||
|
||||
research->entryIndex |= (1 << 30);
|
||||
research->entryIndex |= RESEARCH_ENTRY_FLAG_RIDE_ALWAYS_RESEARCHED;
|
||||
_editorInventionsListDraggedItem = research;
|
||||
move_research_item(gResearchItems);
|
||||
_editorInventionsListDraggedItem = NULL;
|
||||
|
@ -262,7 +262,7 @@ static void research_scenery_sets_setup(){
|
|||
if ((research->entryIndex & 0xFFFFFF) != entry_index)
|
||||
continue;
|
||||
|
||||
research->entryIndex |= (1 << 29);
|
||||
research->entryIndex |= RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED;
|
||||
_editorInventionsListDraggedItem = research;
|
||||
move_research_item(gResearchItems);
|
||||
_editorInventionsListDraggedItem = NULL;
|
||||
|
|
Loading…
Reference in New Issue