/** * @brief Reset and free the UI data hunk * @note Even called in case of an error when CL_Shutdown was called - maybe even * before CL_InitLocal (and thus UI_Init) was called * @sa CL_Shutdown * @sa UI_Init */ void UI_Shutdown (void) { /* MN is not yet initialized */ if (ui_global.adata == nullptr) return; const uiBehaviour_t* confunc = UI_GetNodeBehaviour("confunc"); /* remove all confunc commands */ uiNode_t** nodes[] = {ui_global.windows, ui_global.components}; for (int nodeType = 0; nodeType < 2; ++nodeType) { for (int i = 0; i < ui_global.numWindows; i++) { uiNode_t* node = nodes[nodeType][i]; while (node) { /* remove the command */ if (node->behaviour == confunc) { /* many nodes to one command is allowed */ if (Cmd_Exists(node->name)) { Cmd_RemoveCommand(node->name); } } /* recursive next */ if (node->firstChild != nullptr) { node = node->firstChild; continue; } while (node) { if (node->next != nullptr) { node = node->next; break; } node = node->parent; } } } } UI_ShutdownLua(); UI_FontShutdown(); UI_ResetInput(); UI_ResetTimers(); #ifdef DEBUG Cmd_RemoveCommand("debug_uimemory"); #endif Cmd_RemoveCommand("ui_restart"); Mem_Free(ui_global.adata); OBJZERO(ui_global); /* release pools */ Mem_FreePool(ui_sysPool); Mem_FreePool(ui_dynStringPool); Mem_FreePool(ui_dynPool); ui_sysPool = nullptr; ui_dynStringPool = nullptr; ui_dynPool = nullptr; }
/** * @brief Reset and free the UI data hunk * @note Even called in case of an error when CL_Shutdown was called - maybe even * before CL_InitLocal (and thus UI_Init) was called * @sa CL_Shutdown * @sa UI_Init */ void UI_Shutdown (void) { /* MN is not yet initialized */ if (ui_global.adata == nullptr) return; const uiBehaviour_t* confunc = UI_GetNodeBehaviour("confunc"); /* remove all confunc commands */ for (int i = 0; i < ui_global.numWindows; i++) { uiNode_t* node = ui_global.windows[i]; while (node) { /* remove the command */ if (node->behaviour == confunc) { /* many nodes to one command is allowed */ if (Cmd_Exists(node->name)) Cmd_RemoveCommand(node->name); } /* recursive next */ if (node->firstChild != nullptr) node = node->firstChild; else { while (node) { if (node->next != nullptr) { node = node->next; break; } node = node->parent; } } } } UI_FontShutdown(); UI_ResetInput(); UI_ResetTimers(); Mem_Free(ui_global.adata); OBJZERO(ui_global); /* release pools */ Mem_FreePool(ui_sysPool); Mem_FreePool(ui_dynStringPool); Mem_FreePool(ui_dynPool); ui_sysPool = nullptr; ui_dynStringPool = nullptr; ui_dynPool = nullptr; }