* Correct serverProcessReplacement code.

* Remove the python.lib dependency from TSExtension.
This commit is contained in:
Robert MacGregor 2019-07-13 17:54:20 -07:00
parent 6cff6d2dda
commit a104302468
4 changed files with 39 additions and 42 deletions

View file

@ -20,12 +20,14 @@
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

View file

@ -1430,15 +1430,15 @@ __declspec(dllexport) void ServerProcess(unsigned int deltaTime)
}
static unsigned int gboaptr =(unsigned int ) &GameBaseOnAddHook;
extern "C"
{
TSEXTENSION_API unsigned int getModLoaderVersion(void)
{
return 0;
}
TSEXTENSION_API void ModInitialize(void)
{
extern "C"
{
TSEXTENSION_API unsigned int getModLoaderVersion(void)
{
return 0;
}
TSEXTENSION_API void ModInitialize(void)
{
// Init WSA
WSADATA wsadata;
WSAStartup(0x0202, &wsadata);
@ -1457,8 +1457,8 @@ extern "C"
//Con::addMethodB(NULL,"setAITrigger", &consetTrigger, "setAITrigger(%aicon,triggerid,value);",2,6);
Con::addMethodS("GrenadeProjectile", "getposition", &conGrenadeProjectileGetPosition,"Accurately gets the position of the GrenadeProjectile", 2, 2);
Con::addMethodS("GrenadeProjectile", "getvelocity", &conGrenadeProjectileGetVelocity,"Gets the velocity of the GrenadeProjectile", 2, 2);
Con::addMethodB("Projectile", "makeNerf", &conProjectileMakeNerf,"Makes the Projectile deal no damage", 2, 2);
Con::addMethodB("Projectile", "makeNerf", &conProjectileMakeNerf,"Makes the Projectile deal no damage", 2, 2);
// TCPObject
#ifdef ENABLE_TCPOBJECT
/*
@ -1540,22 +1540,22 @@ extern "C"
DX::memPatch(0x438415,(unsigned char *)dbpatch3,7);
DX::memPatch(0x5E29F0,(unsigned char *)gboaonadd,7);
#endif
return;
}
TSEXTENSION_API const char* getManagementName(void)
{
return "TSExtension";
}
TSEXTENSION_API ModLoader::ModLoaderCallables* getModCallables(void)
{
ModLoader::ModLoaderCallables* result = new ModLoader::ModLoaderCallables();
result->mInitializeModPointer = ModInitialize;
result->mGetManagementName = getManagementName;
return result;
}
return;
}
TSEXTENSION_API const char* getManagementName(void)
{
return "TSExtension";
}
TSEXTENSION_API ModLoader::ModLoaderCallables* getModCallables(void)
{
ModLoader::ModLoaderCallables* result = new ModLoader::ModLoaderCallables();
result->mInitializeModPointer = ModInitialize;
result->mGetManagementName = getManagementName;
return result;
}
}

View file

@ -23,8 +23,6 @@ void serverProcessReplacement(unsigned int timeDelta)
currentCallables->mServerProcessPointer(timeDelta);
}
Con::errorf(0, "Bla -bla blallaaa");
__asm
{
mov ecx,serverthisptr

View file

@ -67,8 +67,8 @@ const char* congetInterpreterAddr(Linker::SimObject *obj, S32 argc, const char *
void initializeHooks()
{
// Replicates:
// memPatch("5BBBDC",getServPAddr());
// sprintf(test2,"B8 FFD089EC5DC3",endian(spr));
// memPatch("5240FD", "B00190");
// memPatch("5BBBDC", getServPAddr());
unsigned char serverProcessBytes[] = {
0xB8,
@ -91,6 +91,13 @@ void initializeHooks()
unsigned int* serverProcessOffset = reinterpret_cast<unsigned int*>(&serverProcessBytes[1]);
*serverProcessOffset = reinterpret_cast<unsigned int>(*serverProcessReplacement);
unsigned char addressBytes[] = {
0xB0,
0x01,
0x90
};
DX::memPatch(0x5240FD, addressBytes, sizeof(addressBytes));
DX::memPatch(0x5BBBDC, serverProcessBytes, sizeof(serverProcessBytes));
}
@ -125,16 +132,6 @@ class CImmDevice
LPINITT2DLL lpinitT2DLL = NULL;
hDLL = LoadLibrary(L"tribesnext.dll"); // AfxLoadLibrary is probably better.
if (hDLL == NULL)
return 0; // The DLL doesn't exist
else
lpinitT2DLL = (LPINITT2DLL)GetProcAddress(hDLL, "_Z9initT2Dllv"); // Attempt to load our entry point
if (lpinitT2DLL == NULL)
return 0; // Unable to load entry point
else
lpinitT2DLL(); // The function was loaded, call TribesNext and move on to postTN Startup
// Initialize all engine hooks
initializeHooks();