unload some startup loaded objects

This commit is contained in:
Adam Jensen 2024-05-15 18:31:08 +01:00
parent edabc5d72c
commit 81ed2768a7
4 changed files with 45 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#include "cdcFile/FileSystem.h"
#include "cdcGameShell/cdcGameShell.h"
#include "rendering/Inspector.h"
#include "cdcResource/Resolve.h"
#include "cdcResource/ResolveObject.h"
#if ENABLE_IMGUI
@ -254,6 +255,13 @@ void requestObjectNormal(uint32_t id) {
requestObject(id, cdc::FileRequest::NORMAL);
}
void releaseObject(uint32_t id) {
// HACK
if (ObjectTracker *otr = getByObjectListIndex(id))
if (otr->resolveObject)
Resolve::Release(otr->resolveObject);
}
char *objectName(uint32_t objectListIndex) {
return g_objectManager->objectList->entries[objectListIndex-1].name;
}

View File

@ -76,6 +76,7 @@ void readAndParseObjectList();
uint32_t objectIdByName(const char *name);
void requestObjectHigh(uint32_t id);
void requestObjectNormal(uint32_t id);
void releaseObject(uint32_t id);
char *objectName(uint32_t objectListIndex);
void buildObjectsUI(UIActions& uiact);

View File

@ -101,6 +101,19 @@ void loadDatabases() {
globalPlayerInfo = (GlobalPlayerInfo*)ort_globalPlayerInfo->objBlob->data;
}
void unloadDatabases() {
// TODO
releaseObject(objectIdByName("GlobalPlayerInfo"));
if (true) // TODO
releaseObject(objectIdByName("GlobalDLCInfo"));
releaseObject(objectIdByName("GlobalScripting"));
releaseObject(objectIdByName("GlobalDatabase"));
releaseObject(objectIdByName("GlobalSmartScripts"));
// TODO
}
void Init_NativeScripts();
void MAIN_DoMainInit() {
@ -129,6 +142,7 @@ void MAIN_DoMainInit() {
// TODO
// MAIN_LoadGlobalObjects
uint32_t generalBankId = objectIdByName("generalbank");
uint32_t globalSoundInfoId = objectIdByName("globalsoundinfo");
uint32_t globalAnimInfoId = objectIdByName("globalaniminfo");
@ -150,6 +164,20 @@ void MAIN_DoMainInit() {
// TODO
}
void MAIN_DoMainUninit() { // ?
// TODO
unloadDatabases();
// TODO
releaseObject(objectIdByName("globalaniminfo"));
releaseObject(objectIdByName("globalsoundinfo"));
releaseObject(objectIdByName("generalbank"));
// TODO
}
void MAIN_Init() { // 2312
const char *prefix;
@ -177,6 +205,8 @@ void MAIN_Init() { // 2312
void MAIN_Uninit() { // 2573
// TODO
MAIN_DoMainUninit();
// TODO
Resolve::Destroy();
}

View File

@ -1846,6 +1846,12 @@ end:
#endif
ImGui::DestroyContext();
#endif
// maybe it's bad to bypass ObjectManager
obj5->Release();
obj4->Release();
obj3->Release();
return 0;
}