From a3a954b22f9b8fa1000f3a80ef8a734d46a6b436 Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Tue, 5 Aug 2014 18:31:30 -0400 Subject: [PATCH] Fixed up the ModLoader Project; replaced the old sources with the new --- ModLoader/CoreModSystem.v12.suo | Bin 28672 -> 35840 bytes ModLoader/ModLoader.vcxproj | 12 ++-- ModLoader/ModLoader.vcxproj.filters | 12 +--- ModLoader/include/config.h | 7 --- ModLoader/include/modLoader.h | 8 +++ ModLoader/include/stdafx.h | 32 ----------- ModLoader/include/t2ConCmds.h | 15 ----- ModLoader/include/t2api.h | 2 + ModLoader/source/modLoader.cpp | 39 +++++++++++++ ModLoader/source/t2ConCmds.cpp | 84 ---------------------------- ModLoader/source/t2api.cpp | 2 +- ModLoader/source/t2dll.cpp | 12 ++-- 12 files changed, 62 insertions(+), 163 deletions(-) delete mode 100755 ModLoader/include/config.h create mode 100644 ModLoader/include/modLoader.h delete mode 100755 ModLoader/include/stdafx.h delete mode 100755 ModLoader/include/t2ConCmds.h create mode 100644 ModLoader/source/modLoader.cpp delete mode 100755 ModLoader/source/t2ConCmds.cpp diff --git a/ModLoader/CoreModSystem.v12.suo b/ModLoader/CoreModSystem.v12.suo index 367220d135618a089705cec8c613c07f1fd92039..f54e6fedf90d94e73a8ac87dcb23be29e53522d6 100644 GIT binary patch delta 4814 zcmeHLT~J%c6~23sgoGs_5Lg6b{$n7<1h5c70VIKB#~83;C$W>t9)lp5f`Ni$yCgAp z5<1g1c5LgUuG1!tf6_R1C#@6ZArDE%p2_qlGo92g?Msq+I@3J$r89UsA$8L4T>Stt zBz7j__Mtoew7ch?y?f6&-=4Erxh|Ab^6^$t@@8ATYuTKtl3 z$lLVyV6Fk^6H7VO%UN_NFwLq}4W$On8h;jK z$@K<|@6<>W)+}RWe!7u<=w-(ZeLI?EZ+Jej7w>l>F(&jc06zgv0zU=#Ipb&4V6xSm zf#hsLdLI3&iScXbFC@kn(O;sgwu(3RIz`kR7A}gIzZA_B$?m02b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H{<8Rz~MIs%>8x5?cAriy^J)aB;~o!;Dq}WF*$CFT{`x0L|P9C zo+S269f9YpTWUzb3}S)Qs1)fC)@SY|#%f;7SULy_>}jaF#h1S?mCawC0GINEcvUoGq3cTrL#EufWC(_K}zz*WQH<|_tHiTZ+ qnBD6hIpy#a8;Vc)Mn@f9`-pRB)HfVXOEA0hpiG+vGoHz7PX1p(PCk?X diff --git a/ModLoader/ModLoader.vcxproj b/ModLoader/ModLoader.vcxproj index ff4a3cc..e4dde57 100755 --- a/ModLoader/ModLoader.vcxproj +++ b/ModLoader/ModLoader.vcxproj @@ -40,13 +40,13 @@ <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)$(Configuration)\ $(Configuration)\ - true + false $(SolutionDir)$(Configuration)\ $(Configuration)\ false - $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;include\;include\bullet\; + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;include $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;lib\; - $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;include\;include\bullet\; + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;include $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;lib\; t2dll t2dll @@ -121,15 +121,13 @@ + - - - + - diff --git a/ModLoader/ModLoader.vcxproj.filters b/ModLoader/ModLoader.vcxproj.filters index 0219ba4..5fe155e 100755 --- a/ModLoader/ModLoader.vcxproj.filters +++ b/ModLoader/ModLoader.vcxproj.filters @@ -9,16 +9,10 @@ - - Include - - - Include - Include - + Include @@ -26,10 +20,10 @@ Source - + Source - + Source diff --git a/ModLoader/include/config.h b/ModLoader/include/config.h deleted file mode 100755 index 712656a..0000000 --- a/ModLoader/include/config.h +++ /dev/null @@ -1,7 +0,0 @@ -/* - * config.h - * Contains configuration information for BulletDLL - * Copyright (c) 2013 Robert MacGregor -*/ - -#define MAXIMUM_BULLET_NODES 256 \ No newline at end of file diff --git a/ModLoader/include/modLoader.h b/ModLoader/include/modLoader.h new file mode 100644 index 0000000..ee8c045 --- /dev/null +++ b/ModLoader/include/modLoader.h @@ -0,0 +1,8 @@ +/* + * modLoader.h +*/ + +#include + +// Mod Loader Implementation +bool conLoadMod(SimObject *obj,S32 argc, const char* argv[]); \ No newline at end of file diff --git a/ModLoader/include/stdafx.h b/ModLoader/include/stdafx.h deleted file mode 100755 index 5d2427f..0000000 --- a/ModLoader/include/stdafx.h +++ /dev/null @@ -1,32 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Allow use of features specific to Windows XP or later. -#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. -#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. -#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. -#endif - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - -// TODO: reference additional headers your program requires here -#include "t2api.h" -#include "config.h" \ No newline at end of file diff --git a/ModLoader/include/t2ConCmds.h b/ModLoader/include/t2ConCmds.h deleted file mode 100755 index c291122..0000000 --- a/ModLoader/include/t2ConCmds.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * t2conCmds.h - * Original code by Linker - * Modified by Robert MacGregor -*/ - -#include "stdafx.h" - -// Linker's original functions -const char* conGuiTsCtrlProject(SimObject *obj,S32 argc, const char* argv[]); -bool conNetObjectSetGhostable(SimObject *obj,S32 argc, const char* argv[]); -const char* conGetVariable(SimObject *obj,S32 argc, const char* argv[]); - -// Mod Loader Implementation -bool conLoadMod(SimObject *obj,S32 argc, const char* argv[]); \ No newline at end of file diff --git a/ModLoader/include/t2api.h b/ModLoader/include/t2api.h index f18faec..f0aefc3 100755 --- a/ModLoader/include/t2api.h +++ b/ModLoader/include/t2api.h @@ -1,5 +1,7 @@ #pragma once +#include + void initT2Api(); diff --git a/ModLoader/source/modLoader.cpp b/ModLoader/source/modLoader.cpp new file mode 100644 index 0000000..3e00477 --- /dev/null +++ b/ModLoader/source/modLoader.cpp @@ -0,0 +1,39 @@ +/* + * modLoader.cpp +*/ + +#include "stdafx.h" +#include + +// Mod Loader Implementation +bool conLoadMod(SimObject *obj,S32 argc, const char* argv[]) +{ + typedef void (*LPMODINIT)(void); + HINSTANCE hDLL = NULL; + LPMODINIT lpInitMod = NULL; + + std::string raw = "mods\\"; + raw += argv[1]; + raw += ".dll"; + + std::wstring modification(raw.begin(), raw.end()); + + hDLL = LoadLibrary(modification.c_str()); + if (hDLL == NULL) + { + Con::errorf(0, "loadMod(): Failed to load DLL '%s'. Does it exist in GameData\mods? (%u)", raw.c_str(), GetLastError()); + return false; // The DLL doesn't exist + } + + lpInitMod = (LPMODINIT)GetProcAddress(hDLL, "ModInitialize"); // Attempt to load our entry point + + if (lpInitMod == NULL) + { + Con::errorf(0, "loadMod(): Failed to locate entry point 'ModInitialize' in mod DLL '%s'. Is it a good mod DLL? (%u)", raw.c_str(), GetLastError()); + return false; // Unable to load entry point + } + + lpInitMod(); + Con::errorf(0, "loadMod(): Loaded and executed entry point code for mod DLL '%s'", raw.c_str()); + return true; +} \ No newline at end of file diff --git a/ModLoader/source/t2ConCmds.cpp b/ModLoader/source/t2ConCmds.cpp deleted file mode 100755 index c420585..0000000 --- a/ModLoader/source/t2ConCmds.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * t2ConCmds.cpp - * Original code by Linker - * Modified by Robert MacGregor -*/ - -#include - -#include "stdafx.h" -#include "t2ConCmds.h" - -// Linker's implementations -const char* conGuiTsCtrlProject(SimObject *obj,S32 argc, const char* argv[]) { - Point3F pt; - Point3F rt; - dSscanf(argv[2],"%g %g %g",&pt.x,&pt.y,&pt.z); - GuiTSCtrl_project(reinterpret_cast(obj),pt,&rt); - - char* buffer = Con::getReturnBuffer(255); - dSprintf(buffer,255,"%g %g %g",rt.x,rt.y,rt.z); - - return buffer; -} - -bool conNetObjectSetGhostable(SimObject *obj,S32 argc, const char* argv[]) { - if (dAtob(argv[2])) { - __asm { - push ecx - mov ecx, [obj] - mov eax,[ecx+40h] - or eax, 100h - mov [ecx+40h], eax - pop ecx - } - } else { - __asm { - xor eax, eax - or eax, 100h - not eax - push ecx - mov ecx,[obj] - and eax, [ecx+40h] - mov [ecx+40h],eax - push 40h - mov eax, 0x585BE0 - call eax - pop ecx - } - } - return 1; -} - -const char* conGetVariable(SimObject *obj,S32 argc, const char* argv[]) { - return Con::getVariable(argv[1]); -} - -// Mod Loader Implementation -bool conLoadMod(SimObject *obj,S32 argc, const char* argv[]) -{ - typedef void (*LPMODINIT)(void); - HINSTANCE hDLL = NULL; - LPMODINIT lpInitMod = NULL; - - std::string raw = argv[1]; - - std::wstring input(raw.begin(), raw.end()); - std::wstring modification = L"mods/"; - modification += input; - modification += L".dll"; - - hDLL = LoadLibrary(modification.c_str()); // AfxLoadLibrary is probably better. - - if (hDLL == NULL) - return false; // The DLL doesn't exist - else - lpInitMod = (LPMODINIT)GetProcAddress(hDLL, "?ModInitialize@@YAXXZ"); // Attempt to load our entry point - - if (lpInitMod == NULL) - return false; // Unable to load entry point - else - lpInitMod(); // The function was loaded, call TribesNext and move on to postTN Startup - - return true; -} \ No newline at end of file diff --git a/ModLoader/source/t2api.cpp b/ModLoader/source/t2api.cpp index be583ab..137e2dc 100755 --- a/ModLoader/source/t2api.cpp +++ b/ModLoader/source/t2api.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include SimIdDictionary* gIdDictionary = reinterpret_cast(0x009E9194); diff --git a/ModLoader/source/t2dll.cpp b/ModLoader/source/t2dll.cpp index 94ba387..a0ae70a 100755 --- a/ModLoader/source/t2dll.cpp +++ b/ModLoader/source/t2dll.cpp @@ -4,11 +4,12 @@ * Modified by Robert MacGregor */ -#include "stdafx.h" -#include "t2ConCmds.h" -#include "t2api.h" +#include #include +#include +#include + BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved @@ -19,11 +20,6 @@ BOOL APIENTRY DllMain( HMODULE hModule, __declspec(dllexport) void initT2Dll(void) { - // Run Linker's old implementations ... - Con::addMethodS("GuiTSCtrl","project",&conGuiTsCtrlProject,"projects a world space vector to on-screen position",3,3); - Con::addMethodB("NetObject","SetGhostable",&conNetObjectSetGhostable,"set or unset object to be ghostable",3,3); - Con::addMethodS(NULL,"getVariable",&conGetVariable,"Get a variable without restrictions",2,2); - Con::addVariable("$cpuspeed",TypeS32,reinterpret_cast(0x8477F8)); //1 - S32, this is so i can set my cpu speed to 31337 or osmething =P Con::addVariable("$GameBase::showBoundingBox",TypeBool,reinterpret_cast(0x9ECF24));