From 52c2756e5c37555523d5668f930ef57d15680e22 Mon Sep 17 00:00:00 2001 From: Calvin Balke Date: Fri, 16 Jan 2015 14:54:32 -0800 Subject: [PATCH] Added More Commands and Stuff for T2-Bullet Added commands for forcing network updates, converting ghost ids and object ids, and a command for replacing the serverProcess routine using "memPatch("5BBBDC",getServPAddr());" --- .../TSExtension/include/DXAPI/NetConnection.h | 17 ++- .../TSExtension/include/DXConCmds.h | 10 +- .../source/DXAPI/NetConnection.cpp | 34 ++++- .../TSExtension/source/DXConCmds.cpp | 139 ++++++++++++++++-- .../TSExtension/source/dllmain.cpp | 14 +- 5 files changed, 188 insertions(+), 26 deletions(-) diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetConnection.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetConnection.h index 73fe542..b9490a3 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetConnection.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetConnection.h @@ -4,37 +4,40 @@ #include #include #include - struct GhostInfo; - namespace DX { class NetConnection : public SimObject { public: NetConnection(unsigned int obj); - S32 getGhostIndex(NetObject *obj); + S32 getGhostIndex(NetObject obj); + unsigned char getGhostFrom(); + unsigned char getGhostTo(); + NetObject resolveGhostParent(S32 id); + NetObject resolveGhost(S32 id); + unsigned int actualbaseptr; GhostInfo * mGhostRefs; + NetObject **mLocalGhosts; }; } // End NameSpace DX - struct GhostRef; struct GhostInfo { - public: // required for MSVC + // public: // required for MSVC // NOTE: // if the size of this structure changes, the // NetConnection::getGhostIndex function MUST be changed // to reflect. - DX::NetObject *obj; // the real object + U32 *obj; // the real object U32 updateMask; // 32 bits of object info GhostRef *updateChain; // chain of updates for this object in packets GhostInfo *nextObjectRef; // next ghost ref for this object (another connection) GhostInfo *prevObjectRef; // prev ghost ref for this object - DX::NetConnection *connection; + U32 *connection; GhostInfo *nextLookupInfo; U32 updateSkipCount; diff --git a/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h b/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h index f82f343..33ce4c8 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h @@ -13,7 +13,8 @@ #pragma once #include - +void serverProcessReplacement(unsigned int timeDelta) ; +const char* congetServPAddr(Linker::SimObject *obj, S32 argc, const char *argv[]); // Returns the address of an object in memory const char* conGetAddress(Linker::SimObject *obj, S32 argc, const char *argv[]); @@ -23,6 +24,8 @@ bool conPlayerGetJettingState(Linker::SimObject *obj, S32 argc, const char* argv bool conGameConnectionSetHeatLevel(Linker::SimObject *obj, S32 argc, const char *argv[]); bool conSetProcessTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) ; +bool conclientCmdSetProcessTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) ; +bool conclientCmdSetGhostTicks(Linker::SimObject *obj, S32 argc, const char* argv[]); // GrenadeProjectile Commands ------------------------ const char* conGrenadeProjectileGetPosition(Linker::SimObject *obj, S32 argc, const char* argv[]); const char* conGrenadeProjectileGetVelocity(Linker::SimObject *obj, S32 argc, const char* argv[]); @@ -49,9 +52,10 @@ bool conBinaryObjectSetBufferPointer(Linker::SimObject *obj, S32 argc, const cha const char *conBinaryObjectGetBufferPointer(Linker::SimObject *obj, S32 argc, const char *argv[]); bool conBinaryObjectClose(Linker::SimObject *obj, S32 argc, const char *argv[]); bool conBinaryObjectSave(Linker::SimObject *obj, S32 argc, const char *argv[]); - +const char *conResolveGhostParent(Linker::SimObject *obj, S32 argc, const char* argv[]); +const char* conResolveGhost(Linker::SimObject *obj, S32 argc, const char* argv[]); // Network Commands --------------------------------- -S32 conGetGhostIndex(Linker::SimObject *obj, S32 argc, const char* argv[]); +const char *conGetGhostIndex(Linker::SimObject *obj, S32 argc, const char* argv[]); bool conForceUpdate(Linker::SimObject *obj, S32 argc, const char* argv[]); // General Commands --------------------------------- const char* conSprintf(Linker::SimObject *obj, S32 argc, const char* argv[]); diff --git a/Mod Sources/TSExtension/TSExtension/source/DXAPI/NetConnection.cpp b/Mod Sources/TSExtension/TSExtension/source/DXAPI/NetConnection.cpp index 698e21b..2da4596 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXAPI/NetConnection.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXAPI/NetConnection.cpp @@ -3,8 +3,14 @@ #include namespace DX { - S32 NetConnection::getGhostIndex(NetObject *obj) { - unsigned int object_ptr = (unsigned int)obj->base_pointer_value; + unsigned char NetConnection::getGhostFrom() { + return *(unsigned char *)((this->actualbaseptr)+0x8204); + } + unsigned char NetConnection::getGhostTo() { + return *(unsigned char *)((this->actualbaseptr)+0x8205); + } + S32 NetConnection::getGhostIndex(NetObject obj) { + unsigned int object_ptr = (unsigned int)obj.base_pointer_value; unsigned int my_ptr = this->base_pointer_value-0xA0; unsigned int ghostid=0; unsigned int function=0x584FB0; @@ -18,11 +24,31 @@ namespace DX } return ghostid; } - + NetObject NetConnection::resolveGhostParent(S32 id) { + if (this->getGhostFrom()) { + if (this->mGhostRefs[id].obj) + { + return NetObject((unsigned int)(this->mGhostRefs[id].obj)); + } + } + return NULL; + } + NetObject NetConnection::resolveGhost(S32 id) { + if (this->getGhostTo()) { + return NetObject((unsigned int)this->mLocalGhosts[id]); + } + return NULL; + } NetConnection::NetConnection(unsigned int obj) : SimObject(obj) { - this->mGhostRefs = (GhostInfo *)this->base_pointer_value-0xA0+0x8210; + unsigned int ptr=((this->base_pointer_value)-(0xA0)); + this->actualbaseptr=ptr; + unsigned int * ginfoptrptr=0; + ginfoptrptr=(unsigned int *) (this->actualbaseptr+(0x8210)); + this->mGhostRefs = (GhostInfo *) *ginfoptrptr; + this->mLocalGhosts = (NetObject **) *(unsigned int *) ((this->actualbaseptr+(0x820C))); + } } diff --git a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp index 60e46a6..a28fe34 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp @@ -1,10 +1,37 @@ /** * */ - +#define endian(hex) (((hex & 0x000000FF) << 24)+((hex & 0x0000FF00) << 8)+((hex & 0x00FF0000)>>8)+((hex & 0xFF000000) >> 24)) #include #include - +void serverProcessReplacement(unsigned int timeDelta) { + unsigned int servertickaddr=0x602350; + unsigned int serverthisptr=0x9E5EC0; + __asm + { + mov ecx,serverthisptr + push timeDelta + call servertickaddr + } + + return; +} +const char* congetServPAddr(Linker::SimObject *obj, S32 argc, const char *argv[]) { + char test[256] = ""; + char test2[256]=""; + int spr=(signed int)*serverProcessReplacement; + sprintf(test,"B8%8XFFD089EC5DC3",endian(spr)); + test2[0]=test[6]; + test2[1]=test[7]; + test2[2]=test[4]; + test2[3]=test[5]; + test2[4]=test[2]; + test2[5]=test[3]; + test2[6]=test[0]; + test2[7]=test[1]; + test2[8]=0; + return test2; +} const char *conGetAddress(Linker::SimObject *obj, S32 argc, const char *argv[]) { // Hmm... @@ -57,10 +84,11 @@ bool conProjectileMakeNerf(Linker::SimObject *obj, S32 argc, const char* argv[]) bool conForceUpdate(Linker::SimObject *obj, S32 argc, const char* argv[]) { DX::NetConnection conn = DX::NetConnection((unsigned int)obj); DX::NetObject netobj = DX::NetObject((unsigned int)Sim::findObjectc(argv[2])); + GhostInfo * mGhostRefs=conn.mGhostRefs; if (netobj.base_pointer_value!=0) { - S32 index = conn.getGhostIndex(&netobj); + S32 index = conn.getGhostIndex(netobj); if (index > 0) { - conn.mGhostRefs[index].updateMask=conn.mGhostRefs[index].updateMask | GameBaseMasks::InitialUpdateMask; + mGhostRefs[index].updateMask=mGhostRefs[index].updateMask | GameBaseMasks::InitialUpdateMask; } return 1; } @@ -69,16 +97,109 @@ bool conForceUpdate(Linker::SimObject *obj, S32 argc, const char* argv[]) { return 0; } } -S32 conGetGhostIndex(Linker::SimObject *obj, S32 argc, const char* argv[]) { +const char* conGetGhostIndex(Linker::SimObject *obj, S32 argc, const char* argv[]) { + char outint[20]=""; DX::NetConnection conn = DX::NetConnection((unsigned int)obj); DX::NetObject netobj = DX::NetObject((unsigned int)Sim::findObjectc(argv[2])); if (netobj.base_pointer_value!=0) { - S32 index = conn.getGhostIndex(&netobj); - return index; + S32 index = conn.getGhostIndex(netobj); + itoa(index,outint,10); + return outint; } else { - return (unsigned int)Sim::findObjectc(argv[1]); + return ""; } - //conn.mGhostRefs[index].updateMask=conn.mGhostRefs[index].updateMask | GameBaseMasks::InitialUpdateMask; +} +const char* conResolveGhost(Linker::SimObject *obj, S32 argc, const char* argv[]) { + char outint[20]=""; + DX::NetConnection conn = DX::NetConnection((unsigned int)obj); + S32 id = atoi(argv[2]); + DX::NetObject realobject = conn.resolveGhost(id); + if (realobject.base_pointer_value) { + return itoa(realobject.identifier,outint,10); + } + return ""; +} +const char* conResolveGhostParent(Linker::SimObject *obj, S32 argc, const char* argv[]) { + char outint[20]=""; + DX::NetConnection conn = DX::NetConnection((unsigned int)obj); + S32 ghostindex = atoi(argv[2]); + if (conn.base_pointer_value!=0) { + if (conn.resolveGhostParent(ghostindex).base_pointer_value) + { + S32 objid = conn.resolveGhostParent(ghostindex).identifier; + if (objid != 0) { + itoa(objid,outint,10); + return outint; + } + } + } + return ""; +} +bool conclientCmdSetGhostTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) { + unsigned int result_ptr = 0; + unsigned int my_ptr = 0; + unsigned int ghostindex=atoi(argv[1]); + DX::NetConnection conn = DX::NetConnection((unsigned int)Sim::findObjectc("ServerConnection")); + if (conn.base_pointer_value) { + DX::NetObject ghostobj = conn.resolveGhost(ghostindex); + if (ghostobj.base_pointer_value) + { + my_ptr=(unsigned int)ghostobj.base_pointer_value; + if (atoi(argv[2])==1) { + __asm + { + mov eax, my_ptr; + add eax, 0x264; + mov ebx,eax + mov al, 1 + mov [ebx],al + + } + } else { + __asm + { + mov eax, my_ptr; + add eax, 0x264; + mov ebx,eax + mov al, 0 + mov [ebx],al + + } + } + } + } + return 1; +} +bool conclientCmdSetProcessTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) { + unsigned int result_ptr = 0; + unsigned int my_ptr = 0; + DX::NetObject objptr=(unsigned int)Sim::findObjectc(argv[1]); + if (objptr.base_pointer_value) + { + my_ptr=objptr.base_pointer_value; + if (atoi(argv[2])==1) { + __asm + { + mov eax, my_ptr; + add eax, 0x264; + mov ebx,eax + mov al, 1 + mov [ebx],al + + } + } else { + __asm + { + mov eax, my_ptr; + add eax, 0x264; + mov ebx,eax + mov al, 0 + mov [ebx],al + + } + } + } + return 1; } bool conSetProcessTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) { diff --git a/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp b/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp index 6cf8522..1348061 100644 --- a/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/dllmain.cpp @@ -44,6 +44,7 @@ extern "C" Con::addMethodB("Projectile", "makeNerf", &conProjectileMakeNerf,"Makes the Projectile deal no damage", 2, 2); // TCPObject +#ifdef ENABLE_TCPOBJECT Con::addMethodS("TCPObject", "connect", &conTCPObjectConnect, "Connects to a remote server", 3, 3); Con::addMethodB("TCPObject", "send", &conTCPObjectSend, "Sends data to the remote server", 3, 3); Con::addMethodB("TCPObject", "disconnect", &conTCPObjectDisconnect, "Disconnects from the remote server", 2, 2); @@ -54,7 +55,7 @@ extern "C" Con::addMethodB("HTTPObject", "send", &conHTTPObjectDoNothing, "Disconnects from the remote server", 6, 6); Con::addMethodB("HTTPObject", "connect", &conHTTPObjectDoNothing, "Disconnects from the remote server", 6, 6); Con::addMethodB("HTTPObject", "listen", &conHTTPObjectDoNothing, "Disconnects from the remote server", 6, 6); - +#endif // BinaryObject Con::addMethodB("BinaryObject", "openforread", &conBinaryObjectOpenForRead, "Opens the input file for reading binary data", 3, 4); Con::addMethodB("BinaryObject", "save", &conBinaryObjectSave, "Saves the binary object data to a file", 3, 3); @@ -65,11 +66,18 @@ extern "C" Con::addMethodS("BinaryObject", "getbufferlength", &conBinaryObjectGetBufferLength, "Returns the length of the buffer", 2, 2); Con::addMethodS("BinaryObject", "getbufferpointer", &conBinaryObjectGetBufferPointer, "Returns the buffer pointer", 2, 2); Con::addMethodB("BinaryObject", "close", &conBinaryObjectClose, "Closes the binary object", 2, 2); - Con::addMethodI("NetConnection","getGhostIndex", &conGetGhostIndex, "Gets a ghost index for an object id", 3, 3); - Con::addMethodB("NetConnection","conForceUpdate", &conForceUpdate,"Forces an initial update for an object id", 3, 3); + Con::addMethodS("NetConnection","getGhostIndex", &conGetGhostIndex, "Gets a ghost index for an object id", 3, 3); + Con::addMethodB("NetConnection","forceUpdate", &conForceUpdate,"Forces an initial update for an object id", 3, 3); + Con::addMethodS("NetConnection","resolveGhostParent",&conResolveGhostParent,"Resolves a ghost index parent", 3, 3); + Con::addMethodS("NetConnection","resolveGhost",&conResolveGhost,"Resolves an object from a ghost ID for ServerConnection", 3, 3); + Con::addMethodB(NULL,"clientCmdSetGhostTicks",&conclientCmdSetGhostTicks,"Client Command for disabling tick processing on ghost index",2,10); + Con::addMethodB(NULL,"clientCmdsetProcessTicks",&conclientCmdSetProcessTicks,"Client Command for disabling tick processing on ghost object",2,10); // General Con::addMethodS(NULL, "sprintf", &conSprintf,"Formats a string. See the C sprintf.", 2, 20); Con::addMethodB(NULL, "tsExtensionUpdate", &conTSExtensionUpdate,"Updates the TSExtension.", 1, 1); + Con::addMethodS(NULL, "getServPAddr",&congetServPAddr,"Gets the memPatch data for ServerProcess",1,1); + + // Add this Gvar to signify that TSExtension is active static bool is_active = true;