mirror of https://github.com/OpenRCT2/OpenRCT2.git
finish implementing remove_selected_objects_from_research
Fixed bug due to freeing rct2 memory.
This commit is contained in:
parent
15b2360e13
commit
895d4a81e4
|
@ -434,6 +434,18 @@ static void research_insert_researched(int entryIndex, int category)
|
|||
} while (entryIndex != (researchItem++)->entryIndex);
|
||||
}
|
||||
|
||||
/* rct2: 0x006857CF */
|
||||
void research_remove(sint32 entryIndex){
|
||||
for (rct_research_item *researchItem = gResearchItems; researchItem->entryIndex != RESEARCHED_ITEMS_END; researchItem++){
|
||||
if (researchItem->entryIndex == entryIndex){
|
||||
do{
|
||||
*researchItem = *(researchItem + 1);
|
||||
} while (researchItem++->entryIndex != RESEARCHED_ITEMS_END_2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void research_insert(int researched, int entryIndex, int category)
|
||||
{
|
||||
if (researched)
|
||||
|
|
|
@ -83,5 +83,6 @@ 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);
|
||||
void research_finish_item(sint32 entryIndex);
|
||||
void research_insert(int researched, int entryIndex, int category);
|
||||
void research_remove(sint32 entryIndex);
|
||||
|
||||
#endif
|
|
@ -579,33 +579,36 @@ static void editor_object_flags_free(){
|
|||
if (RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*) == NULL){
|
||||
return;
|
||||
}
|
||||
free(RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*));
|
||||
rct2_free(RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*));
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*) = NULL;
|
||||
}
|
||||
|
||||
/* rct2: 0x00685791 */
|
||||
void sub_685791(rct_object_entry* installedObject){
|
||||
void remove_selected_objects_from_research(rct_object_entry* installedObject){
|
||||
uint8 entry_type, entry_index;
|
||||
if (!find_object_in_entry_group(installedObject, entry_type, entry_index))
|
||||
if (!find_object_in_entry_group(installedObject, &entry_type, &entry_index))
|
||||
return;
|
||||
|
||||
if (entry_type == OBJECT_TYPE_RIDE){
|
||||
//6857af
|
||||
rct_ride_type* rideEntry = (rct_ride_type*)object_entry_groups[entry_type].chunks[entry_index];
|
||||
research_remove(entry_index | rideEntry->ride_type[0] << 8 | 0x10000);
|
||||
research_remove(entry_index | rideEntry->ride_type[1] << 8 | 0x10000);
|
||||
research_remove(entry_index | rideEntry->ride_type[2] << 8 | 0x10000);
|
||||
}
|
||||
else if (entry_type == OBJECT_TYPE_SCENERY_SETS){
|
||||
//6857a5
|
||||
research_remove(entry_index);
|
||||
}
|
||||
}
|
||||
|
||||
/* rct2: 0x006ABB66 */
|
||||
void sub_6ABB66(){
|
||||
void unload_selected_objects(){
|
||||
uint8* selection_flags = RCT2_GLOBAL(RCT2_ADDRESS_EDITOR_OBJECT_FLAGS_LIST, uint8*);
|
||||
rct_object_entry* installedObject = RCT2_GLOBAL(RCT2_ADDRESS_INSTALLED_OBJECT_LIST, rct_object_entry*);
|
||||
|
||||
for (int i = RCT2_GLOBAL(RCT2_ADDRESS_OBJECT_LIST_NO_ITEMS, uint32); i > 0; --i){
|
||||
if (*selection_flags & OBJECT_SELECTION_FLAG_SELECTED){
|
||||
sub_685791(installedObject);
|
||||
object_unload(0, installedObject);
|
||||
remove_selected_objects_from_research(installedObject);
|
||||
object_unload(0, (rct_object_entry_extended*)installedObject);
|
||||
}
|
||||
selection_flags++;
|
||||
installedObject = object_get_next(installedObject);
|
||||
|
@ -624,7 +627,7 @@ static void window_editor_object_selection_close()
|
|||
//if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_EDITOR))
|
||||
// return;
|
||||
|
||||
RCT2_CALLPROC_EBPSAFE(0x6ABB66);
|
||||
unload_selected_objects();
|
||||
editor_load_selected_objects();
|
||||
reset_loaded_objects();
|
||||
object_free_scenario_text();
|
||||
|
|
Loading…
Reference in New Issue