mirror of
https://github.com/Ragora/T2-CPP.git
synced 2026-07-11 14:54:34 +00:00
ModLoader sources didn't add?
This commit is contained in:
parent
44e5f33ee7
commit
c1e04ef0a6
13 changed files with 582 additions and 1 deletions
84
ModLoader/source/t2ConCmds.cpp
Executable file
84
ModLoader/source/t2ConCmds.cpp
Executable file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* t2ConCmds.cpp
|
||||
* Original code by Linker
|
||||
* Modified by Robert MacGregor
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#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<GuiTSCtrl *>(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;
|
||||
}
|
||||
89
ModLoader/source/t2api.cpp
Executable file
89
ModLoader/source/t2api.cpp
Executable file
|
|
@ -0,0 +1,89 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
SimIdDictionary* gIdDictionary = reinterpret_cast<SimIdDictionary*>(0x009E9194);
|
||||
|
||||
//439550
|
||||
namespace Sim {
|
||||
SimObject* (*findObject)(U32 id) =
|
||||
(SimObject* (_cdecl *)(U32 id) )
|
||||
0x439550;
|
||||
}
|
||||
|
||||
//hackey way to do member functions, ....
|
||||
void GuiTSCtrl_project(GuiTSCtrl *obj, const Point3F &pt, Point3F *dest) {
|
||||
typedef void (__cdecl *projFunc)(const Point3F &pt, Point3F *dest);
|
||||
static projFunc p = (projFunc)0x4d0b40;
|
||||
|
||||
__asm {
|
||||
push dest;
|
||||
push pt;
|
||||
mov ecx,obj;
|
||||
lea eax, p;
|
||||
mov eax, [eax];
|
||||
call eax;
|
||||
}
|
||||
}
|
||||
|
||||
void (*someTest)(void) =
|
||||
(void (__cdecl *)(void))
|
||||
0x4FD9B3;
|
||||
|
||||
namespace Con {
|
||||
|
||||
char* (*getReturnBuffer)(U32 bufferSize) =
|
||||
(char *(__cdecl *)(U32))
|
||||
0x42caa0;
|
||||
|
||||
void (*addMethodB)(const char *nsName, const char *name, BoolCallback cb, const char *usage, S32 minArgs, S32 maxArgs) =
|
||||
(void (__cdecl *)(const char *, const char *,BoolCallback,const char *,S32,S32))
|
||||
0x426510;
|
||||
|
||||
void (*addMethodS)(const char *, const char *,StringCallback, const char *, S32, S32) =
|
||||
(void (__cdecl *)(const char *,const char *,StringCallback,const char *,S32,S32))
|
||||
0x426410;
|
||||
|
||||
bool (*addVariable)(const char *name, S32 t, void *dp) =
|
||||
(bool (__cdecl *)(const char *name, S32 t, void *dp))
|
||||
0x4263B0;
|
||||
|
||||
const char * (*execute)(S32 argc, const char *argv[]) =
|
||||
(const char * (__cdecl *)(S32 argc, const char *argv[]))
|
||||
0x4267A0;
|
||||
|
||||
const char * (*executef)(S32 argc, ...) =
|
||||
(const char * (__cdecl *)(S32 argc, ...))
|
||||
0x4269E0;
|
||||
|
||||
const char * (*evaluate)(const char* string, bool echo, const char *fileName, bool cf) =
|
||||
(const char * (__cdecl *)(const char* string, bool echo, const char *fileName, bool cf))
|
||||
0x426690;
|
||||
|
||||
const char * (*executem)(SimObject *object, S32 argc, const char *argv[]) =
|
||||
(const char * (__cdecl *)(SimObject *object, S32 argc, const char *argv[]))
|
||||
0x426800;
|
||||
|
||||
const char * (*getVariable)(const char *name) =
|
||||
(const char * (__cdecl *)(const char *name))
|
||||
0x4261F0;
|
||||
|
||||
void (*printf)(const char* fmt,...) =
|
||||
(void (__cdecl *)(const char* fmt,...))
|
||||
0x425F30;
|
||||
|
||||
void (*errorf)(U32 type, const char* fmt,...)=
|
||||
(void (__cdecl *)(U32, const char*,...))
|
||||
0x425FB0;
|
||||
|
||||
}
|
||||
|
||||
int (*dSscanf)(const char *buffer, const char *format, ...) =
|
||||
(int (__cdecl *)(const char *,const char *,...))
|
||||
0x55b640;
|
||||
|
||||
int (*dSprintf)(char *buffer, dsize_t bufferSize, const char *format, ...) =
|
||||
(int (__cdecl *)(char *,dsize_t,const char *,...))
|
||||
0x55b5e0;
|
||||
|
||||
bool (*dAtob)(const char *str) =
|
||||
(bool (__cdecl *)(const char *str))
|
||||
0x55B490;
|
||||
53
ModLoader/source/t2dll.cpp
Executable file
53
ModLoader/source/t2dll.cpp
Executable file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* t2dll.cpp
|
||||
* Original code by Linker
|
||||
* Modified by Robert MacGregor
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "t2ConCmds.h"
|
||||
#include "t2api.h"
|
||||
#include <Windows.h>
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
__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<void*>(0x8477F8)); //1 - S32, this is so i can set my cpu speed to 31337 or osmething =P
|
||||
Con::addVariable("$GameBase::showBoundingBox",TypeBool,reinterpret_cast<void*>(0x9ECF24));
|
||||
|
||||
// Mod Loader Function
|
||||
Con::addMethodB(NULL, "loadMod", &conLoadMod, "Loads a C++ modification.",2,2);
|
||||
|
||||
// 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.
|
||||
|
||||
if (hDLL == NULL)
|
||||
return; // The DLL doesn't exist
|
||||
else
|
||||
lpinitT2DLL = (LPINITT2DLL)GetProcAddress(hDLL, "_Z9initT2Dllv"); // Attempt to load our entry point
|
||||
|
||||
if (lpinitT2DLL == NULL)
|
||||
return; // Unable to load entry point
|
||||
else
|
||||
lpinitT2DLL(); // The function was loaded, call TribesNext and move on to postTN Startup
|
||||
}
|
||||
|
||||
#ifdef _MANAGED
|
||||
#pragma managed(pop)
|
||||
#endif
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue