mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-07-06 06:26:50 +00:00
Some checks are pending
this fixes the giant memory leak that happens due to not freeing custom level data when closing a lobby. `DynOS_Lvl_ModShutdown` was not freeing the data nodes for the level data, it was only freeing the surface data. To fix this, I have made it use `DynOS_Gfx_Free` to free the `GfxData` correctly. I found that the level script VM will still be trying to warp from the custom level after `DynOS_Lvl_ModShutdown` is executed, so I added a schedule to simply free it the next frame. I've made it force the level script to change to a vanilla level during mod shutdown. This is critical to ensure the VM doesn't continue to read from a freed level script. Removed the explicit deletion of data nodes in `DynOS_MovtexQC_ModShutdown` because `DynOS_Gfx_Free` already frees that, and it's actually data owned by the data node, so it's more appropriate in `DynOS_Gfx_Free`
58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
#include "dynos.cpp.h"
|
|
extern "C" {
|
|
#include "level_commands.h"
|
|
#include "game/level_update.h"
|
|
#include "game/object_list_processor.h"
|
|
}
|
|
|
|
//
|
|
// Update
|
|
//
|
|
|
|
static bool sDynosIsLevelEntry = false;
|
|
void *DynOS_SwapCmd(void *aCmd) {
|
|
return DynOS_Lvl_Override(aCmd);
|
|
}
|
|
|
|
void *DynOS_UpdateCmd(void *aCmd) {
|
|
if (!aCmd) { return NULL; }
|
|
|
|
static const uintptr_t sCmdLevelEntry[] = { CALL(0, lvl_init_or_update) };
|
|
sDynosIsLevelEntry |= (((uintptr_t*)aCmd)[0] == sCmdLevelEntry[0] && ((uintptr_t*)aCmd)[1] == sCmdLevelEntry[1]);
|
|
return DynOS_Warp_Update(aCmd, sDynosIsLevelEntry);
|
|
}
|
|
|
|
void DynOS_UpdateGfx() {
|
|
DynOS_Mod_Update();
|
|
DynOS_Tex_Update();
|
|
}
|
|
|
|
bool DynOS_IsTransitionActive() {
|
|
return gWarpTransition.isActive;
|
|
}
|
|
|
|
//
|
|
// Misc
|
|
//
|
|
static bool sDynosModShutdown = false;
|
|
|
|
void DynOS_Mod_Update() {
|
|
if (sDynosModShutdown) {
|
|
sDynosModShutdown = false;
|
|
DynOS_Actor_ModShutdown();
|
|
DynOS_Col_ModShutdown();
|
|
DynOS_Lvl_ModShutdown();
|
|
DynOS_Bhv_ModShutdown();
|
|
DynOS_MovtexQC_ModShutdown();
|
|
DynOS_Tex_ModShutdown();
|
|
DynOS_Gfx_ModShutdown();
|
|
}
|
|
}
|
|
|
|
void DynOS_Mod_Shutdown() {
|
|
sDynosModShutdown = true;
|
|
}
|
|
|
|
bool DynOS_Mod_IsShuttingDown() {
|
|
return sDynosModShutdown;
|
|
}
|