MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / Osiris_FreeModule

Function Osiris_FreeModule

Descent3/OsirisLoadandBind.cpp:662–725  ·  view source on GitHub ↗

Osiris_FreeModule Purpose: Removes a currently loaded module from the OSIRIS system

Source from the content-addressed store, hash-verified

660// Purpose:
661// Removes a currently loaded module from the OSIRIS system
662void Osiris_FreeModule(int id) {
663 if (id < 0 || id >= MAX_LOADED_MODULES)
664 return;
665
666 if (OSIRIS_loaded_modules[id].flags & OSIMF_INUSE) {
667
668#ifdef OSIRISDEBUG
669 ASSERT(OSIRIS_loaded_modules[id].RefRoot == NULL); // not all objects freed
670#endif
671
672 if (OSIRIS_loaded_modules[id].flags & OSIMF_LEVEL) {
673 // we're freeing the level dll
674 tOSIRISCurrentLevel.level_loaded = false;
675 tOSIRISCurrentLevel.num_customs = 0;
676 tOSIRISCurrentLevel.dll_id = 0;
677 tOSIRISCurrentLevel.custom_ids = NULL;
678 tOSIRISCurrentLevel.custom_handles = NULL;
679 tOSIRISCurrentLevel.instance = NULL;
680 }
681
682 if (!(OSIRIS_loaded_modules[id].flags & OSIMF_DLLELSEWHERE)) {
683
684 // this is a DLL belonging to us
685 if (OSIRIS_loaded_modules[id].ShutdownDLL) {
686 // call the shutdown function so the DLL can perform what it needs
687 OSIRIS_loaded_modules[id].ShutdownDLL();
688 }
689
690 if (OSIRIS_loaded_modules[id].string_table != NULL) {
691 DestroyStringTable(OSIRIS_loaded_modules[id].string_table, OSIRIS_loaded_modules[id].strings_loaded);
692 }
693 mod_FreeModule(&OSIRIS_loaded_modules[id].mod);
694 }
695
696 if (tOSIRISCurrentMission.mission_loaded && id == tOSIRISCurrentMission.dll_id) {
697 // we're freeing the mission dll
698 tOSIRISCurrentMission.mission_loaded = false;
699 tOSIRISCurrentMission.dll_id = 0;
700 }
701
702 OSIRIS_loaded_modules[id].CallInstanceEvent = NULL;
703 OSIRIS_loaded_modules[id].CreateInstance = NULL;
704 OSIRIS_loaded_modules[id].DestroyInstance = NULL;
705 OSIRIS_loaded_modules[id].GetCOScriptList = NULL;
706 OSIRIS_loaded_modules[id].GetGOScriptID = NULL;
707 OSIRIS_loaded_modules[id].GetTriggerScriptID = NULL;
708 OSIRIS_loaded_modules[id].InitializeDLL = NULL;
709 OSIRIS_loaded_modules[id].SaveRestoreState = NULL;
710 OSIRIS_loaded_modules[id].string_table = NULL;
711 OSIRIS_loaded_modules[id].strings_loaded = 0;
712 OSIRIS_loaded_modules[id].flags = 0;
713 OSIRIS_loaded_modules[id].reference_count = 0;
714
715#ifdef OSIRISDEBUG
716 ASSERT(OSIRIS_loaded_modules[id].RefRoot == NULL);
717 OSIRIS_loaded_modules[id].RefRoot = NULL;
718#endif
719

Callers 5

Osiris_UnloadModuleFunction · 0.85
Osiris_UnloadLevelModuleFunction · 0.85

Calls 2

DestroyStringTableFunction · 0.85
mod_FreeModuleFunction · 0.85

Tested by

no test coverage detected