diff --git a/ModLoader/CoreModSystem.v12.suo b/ModLoader/CoreModSystem.v12.suo index 367220d..f54e6fe 100644 Binary files a/ModLoader/CoreModSystem.v12.suo and b/ModLoader/CoreModSystem.v12.suo differ 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));