mirror of https://github.com/OpenRCT2/OpenRCT2.git
parent
0260633953
commit
f2c9fc58d5
|
@ -85,6 +85,12 @@ extern "C"
|
|||
|
||||
void editor_open_windows_for_current_step();
|
||||
|
||||
/**
|
||||
* Removes all unused objects from the object selection.
|
||||
* @return The number of removed objects.
|
||||
*/
|
||||
sint32 editor_remove_unused_objects();
|
||||
|
||||
void game_command_edit_scenario_options(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "../config/Config.h"
|
||||
#include "../Context.h"
|
||||
#include "../drawing/drawing.h"
|
||||
#include "../Editor.h"
|
||||
#include "../game.h"
|
||||
#include "../input.h"
|
||||
#include "../localisation/localisation.h"
|
||||
|
@ -1206,6 +1207,13 @@ static sint32 cc_open(const utf8 **argv, sint32 argc) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static sint32 cc_remove_unused_objects(const utf8 **argv, sint32 argc)
|
||||
{
|
||||
sint32 result = editor_remove_unused_objects();
|
||||
console_printf("%d unused object entries have been removed.", result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
typedef sint32 (*console_command_func)(const utf8 **argv, sint32 argc);
|
||||
typedef struct console_command {
|
||||
|
@ -1280,6 +1288,7 @@ console_command console_command_table[] = {
|
|||
{ "reset_user_strings", cc_reset_user_strings, "Resets all user-defined strings, to fix incorrectly occurring 'Chosen name in use already' errors.", "reset_user_strings" },
|
||||
{ "rides", cc_rides, "Ride management.", "rides <subcommand>" },
|
||||
{ "staff", cc_staff, "Staff management.", "staff <subcommand>"},
|
||||
{ "remove_unused_objects", cc_remove_unused_objects, "Removes all the unused objects from the object selection.", "remove_unused_objects" },
|
||||
};
|
||||
|
||||
static sint32 cc_windows(const utf8 **argv, sint32 argc) {
|
||||
|
|
|
@ -1877,3 +1877,44 @@ bool editor_check_object_group_at_least_one_selected(sint32 checkObjectType)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
sint32 editor_remove_unused_objects()
|
||||
{
|
||||
bool createSelectionFlags = (_objectSelectionFlags == nullptr);
|
||||
if (createSelectionFlags && !sub_6AB211())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
setup_in_use_selection_flags();
|
||||
|
||||
sint32 numObjects = (sint32)object_repository_get_items_count();
|
||||
const ObjectRepositoryItem * items = object_repository_get_items();
|
||||
|
||||
sint32 numUnselectedObjects = 0;
|
||||
for (sint32 i = 0; i < numObjects; i++)
|
||||
{
|
||||
if (!(_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_IN_USE) && !(_objectSelectionFlags[i] & OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED))
|
||||
{
|
||||
const ObjectRepositoryItem * item = &items[i];
|
||||
uint8 objectType = item->ObjectEntry.flags & 0xF;
|
||||
|
||||
if (objectType == OBJECT_TYPE_PARK_ENTRANCE || objectType == OBJECT_TYPE_SCENARIO_TEXT || objectType == OBJECT_TYPE_WATER || objectType == OBJECT_TYPE_SCENERY_SETS)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_numSelectedObjectsForType[objectType]--;
|
||||
_objectSelectionFlags[i] &= ~OBJECT_SELECTION_FLAG_SELECTED;
|
||||
numUnselectedObjects++;
|
||||
}
|
||||
}
|
||||
unload_unselected_objects();
|
||||
|
||||
if (createSelectionFlags)
|
||||
{
|
||||
editor_object_flags_free();
|
||||
}
|
||||
|
||||
return numUnselectedObjects;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue