From eee62bbf31fea96234bd712a2d56149d92886c6c Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Sun, 14 Jul 2019 18:39:37 -0700 Subject: [PATCH] * Minor cleanup removing unnecessary code. * Minor experimentation with unloadMod. --- ModLoader/Modloader/source/modLoader.cpp | 11 +++++++++++ ModLoader/Modloader/source/t2dll.cpp | 6 ------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ModLoader/Modloader/source/modLoader.cpp b/ModLoader/Modloader/source/modLoader.cpp index 5d5ed29..fb9e81b 100644 --- a/ModLoader/Modloader/source/modLoader.cpp +++ b/ModLoader/Modloader/source/modLoader.cpp @@ -9,6 +9,8 @@ //! A vector of mod callables. static std::vector sModCallables; +//! A vector of mod DLL handles. +static std::vector sModHandles; void serverProcessReplacement(unsigned int timeDelta) { @@ -38,6 +40,7 @@ bool conUnloadLoadMod(Linker::SimObject *obj,S32 argc, const char* argv[]) { const char* targetName = argv[1]; + unsigned int modIndex = 0; for (auto it = sModCallables.begin(); it != sModCallables.end(); it++) { ModLoader::ModLoaderCallables* currentMod = *it; @@ -46,9 +49,16 @@ bool conUnloadLoadMod(Linker::SimObject *obj,S32 argc, const char* argv[]) // Deinitialize the mod and remove it from the list. if (currentMod->mDeinitializeModPointer != NULL) currentMod->mDeinitializeModPointer(); + + // FIXME: Create a structure to track mod data runtime sModCallables.erase(it); + // FIXME: This will cause crashes because mods currently don't actually fully unload. + // FreeLibrary(sModHandles[modIndex]); + sModHandles.erase(sModHandles.begin() + modIndex); return true; } + + ++modIndex; } // Something weird happened. @@ -118,5 +128,6 @@ bool conLoadMod(Linker::SimObject *obj,S32 argc, const char* argv[]) callables->mInitializeModPointer(); sModCallables.push_back(callables); + sModHandles.push_back(hDLL); return true; } \ No newline at end of file diff --git a/ModLoader/Modloader/source/t2dll.cpp b/ModLoader/Modloader/source/t2dll.cpp index c609583..5bdacc2 100644 --- a/ModLoader/Modloader/source/t2dll.cpp +++ b/ModLoader/Modloader/source/t2dll.cpp @@ -126,12 +126,6 @@ class CImmDevice Con::addMethodS(NULL, "getModuAddr",&congetModuAddr,"Gets the memPatch data for the MODULO operator routine",1,1); // memPatch("42D89D",getModuAddr()); Con::addMethodS(NULL, "getInterAddr", &congetInterpreterAddr, "Gets the memPatch data for the interpreter switchtable",1,1); // memPatch("42CED1",getInterAddr()); - // Load the original TribesNext DLL if available - typedef void (*LPINITT2DLL)(void); - HINSTANCE hDLL = NULL; - LPINITT2DLL lpinitT2DLL = NULL; - hDLL = LoadLibrary(L"tribesnext.dll"); // AfxLoadLibrary is probably better. - // Initialize all engine hooks initializeHooks();