mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 21:13:05 +01:00
Implement 'missing objects' window
Implement 'missing objects' window Basic implementation of 'bad objects' window Add new object_load_error.c Add object_load_error.c Faffing about String stuff Stuff Get window basically displaying Proper col header for object Display object types Display file name and explanatory message Probably about time I added myself to the dev list Cleanup and comments Make bad object window work with SC6 Fix whitespace, string IDs, flip core function sense Fix spacing in string_ids.h Fix string ID snafu Fix HasNoInvalidObjects() sense Attempt to refactor this to pass data properly Move typedefs to separate header Fix up signatures Add park_load_result_types.h Clean up includes and remnants of prev implementation Split duplication into function, free invalid entries list on close Use pointer for object_validity_result param Fixup string IDs Use LoadObject() directly Use dependency injection, fix string termination Xcode fix, make helper function static Fix buffer overrun and memory leak Use SDL for clipboard functionality Fix function & variable declarations Rework editor_read_s6() to use new park load result type Update changelog for #5624 [ci skip] Fix mem leak, function signature and whitespace
This commit is contained in:
@@ -36,8 +36,8 @@ extern "C"
|
||||
class ObjectManager final : public IObjectManager
|
||||
{
|
||||
private:
|
||||
IObjectRepository * _objectRepository;
|
||||
Object * * _loadedObjects = nullptr;
|
||||
IObjectRepository * _objectRepository;
|
||||
Object * * _loadedObjects = nullptr;
|
||||
|
||||
public:
|
||||
explicit ObjectManager(IObjectRepository * objectRepository)
|
||||
@@ -438,6 +438,51 @@ private:
|
||||
return entryIndex;
|
||||
}
|
||||
|
||||
rct_object_entry* DuplicateObjectEntry(const rct_object_entry* original)
|
||||
{
|
||||
rct_object_entry * duplicate = Memory::Allocate<rct_object_entry>(sizeof(rct_object_entry));
|
||||
duplicate->checksum = original->checksum;
|
||||
strncpy(duplicate->name, original->name, 8);
|
||||
duplicate->flags = original->flags;
|
||||
return duplicate;
|
||||
}
|
||||
|
||||
object_validity_result* GetInvalidObjects(const rct_object_entry * entries) override
|
||||
{
|
||||
uint16 invalidObjectCount = 0;
|
||||
rct_object_entry * * invalidEntries = Memory::AllocateArray<rct_object_entry *>(OBJECT_ENTRY_COUNT);
|
||||
for (sint32 i = 0; i < OBJECT_ENTRY_COUNT; i++)
|
||||
{
|
||||
const rct_object_entry * entry = &entries[i];
|
||||
const ObjectRepositoryItem * ori = nullptr;
|
||||
if (!object_entry_is_empty(entry))
|
||||
{
|
||||
ori = _objectRepository->FindObject(entry);
|
||||
if (ori == nullptr)
|
||||
{
|
||||
invalidEntries[invalidObjectCount++] = DuplicateObjectEntry(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
Object * loadedObject = nullptr;
|
||||
loadedObject = ori->LoadedObject;
|
||||
if (loadedObject == nullptr)
|
||||
{
|
||||
loadedObject = _objectRepository->LoadObject(ori);
|
||||
if (loadedObject == nullptr)
|
||||
{
|
||||
invalidEntries[invalidObjectCount++] = DuplicateObjectEntry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
object_validity_result* result = Memory::Allocate<object_validity_result>(sizeof(object_validity_result));
|
||||
result->invalid_object_count = invalidObjectCount;
|
||||
result->invalid_objects = invalidEntries;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GetRequiredObjects(const rct_object_entry * entries,
|
||||
const ObjectRepositoryItem * * requiredObjects,
|
||||
size_t * outNumRequiredObjects)
|
||||
@@ -519,14 +564,14 @@ private:
|
||||
return loadedObject;
|
||||
}
|
||||
|
||||
static void ReportMissingObject(const rct_object_entry * entry)
|
||||
void ReportMissingObject(const rct_object_entry * entry)
|
||||
{
|
||||
utf8 objName[9] = { 0 };
|
||||
Memory::Copy(objName, entry->name, 8);
|
||||
Console::Error::WriteLine("[%s] Object not found.", objName);
|
||||
}
|
||||
|
||||
static void ReportObjectLoadProblem(const rct_object_entry * entry)
|
||||
void ReportObjectLoadProblem(const rct_object_entry * entry)
|
||||
{
|
||||
utf8 objName[9] = { 0 };
|
||||
Memory::Copy(objName, entry->name, 8);
|
||||
|
||||
Reference in New Issue
Block a user