From cc00588cca664192be48181207938951478a66c9 Mon Sep 17 00:00:00 2001 From: Calvin Balke Date: Wed, 28 Jan 2015 00:57:28 -0800 Subject: [PATCH] Added some patches and fixed a bug. Increased speed of clientcmds, and fixed the collision bug with the original transform method. Also added a partially implemented Reverse TCP Connection method which may not be required now the clientcmds work so fast. --- Mod Sources/TSExtension/TSExtension.suo | Bin 32768 -> 32768 bytes .../TSExtension/TSExtension.vcxproj | 2 + .../TSExtension/TSExtension.vcxproj.filters | 6 + .../TSExtension/include/DXAPI/NetObject.h | 3 +- .../TSExtension/include/DXConCmds.h | 1 + .../TSExtension/include/LinkerAPI.h | 1 + .../include/ReverseTCPConnection.h | 6 + .../TSExtension/source/DXAPI/NetObject.cpp | 23 ++++ .../TSExtension/source/DXConCmds.cpp | 119 ++++++++++++++++-- .../TSExtension/source/LinkerAPI.cpp | 4 +- .../source/ReverseTCPConnection.cpp | 104 +++++++++++++++ .../TSExtension/source/dllmain.cpp | 3 +- Patches/autoexec.cs | 17 +++ Patches/clientautoexec.cs | 17 +++ Patches/server.cs | 12 ++ 15 files changed, 307 insertions(+), 11 deletions(-) create mode 100644 Mod Sources/TSExtension/TSExtension/include/ReverseTCPConnection.h create mode 100644 Mod Sources/TSExtension/TSExtension/source/ReverseTCPConnection.cpp create mode 100644 Patches/autoexec.cs create mode 100644 Patches/clientautoexec.cs create mode 100644 Patches/server.cs diff --git a/Mod Sources/TSExtension/TSExtension.suo b/Mod Sources/TSExtension/TSExtension.suo index 3c74cbef25807ff41900cd526b9e51c9129332e3..790c35d483e94b3104c2bd1c4d00810730077954 100644 GIT binary patch delta 1064 zcmY*YYe*DP6u#rm>a34^t@v6)*EGvFVQ%E=`hKMDT8pr1qHE^*S~nfdjg-|w`sd?N zp&0b1ACZJQM)o5}k{~k?66#l2LVps8S|TOd&K+mXW;k>2`OfQ}@7!@XJRA;>*$(!| z=J3qs7tJ~&BZTNGg=_4HEFd#S>o*Ycsp4UActg3S;t~w`qzO8X_2#tb<&6T-g$V*5 zbTf|o<8rx@7((VXB`ljMnSjsQU~>-qwEAEsy!D-Mdm}Ep!4d60k5$Q#16X8j#BPp+ zsAuY$jcLPf=p~{I*zg_BOKli^;9Z)PGdmlo9DO09 zb;lcg-DNZCNToegE#DJIS4|t8qzd+waT#n5pwa^K+bd_{Dy;@WDRK$|G?u OPDn32CoB(UF@FI8`9RJ9 delta 844 zcmZo@U}|V!+K|J-S0FRfLc;U{BQpa7gM07)~w;^k-$%1&i7%Og3QQVZ8$6yx9CRke!+F&}7Ew{>gD}LdH%E znGAUhi3~*yl??t2Neo#GsSL>sB@D$t6O$PVfbgiahWO3j&zZS3Z*Ke`%VW%tPjKnAo0lu)0BCw zfGleuwgHK34CH6rl;Og}VF`4qGt{}0OS1eq861E-R+z{apa|HjPEe7}CD|8PI6$^| zKt)(3fCj#qTv_17$>;(UvxSMv0L8ye{#oD!3ADlnUKOCo7oao<90P@lY5+qHFwQE0 zaa9D5rz7&#PMeeFmsDBonPZomdJ_~r>XY)eP2Q0qHu+5PmdOp7CX)*)*(O_*@Z9Hd2&@fWADqJFQgn*kxB;m984O2#~z|q%vnt z23Md{?0^`QS|^v3`A>G1Gi1{Nx|4}<@~^T}92P)1H< + @@ -56,6 +57,7 @@ + {2A498B2D-84B2-4BBF-9532-EA17E5BA51BB} diff --git a/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj.filters b/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj.filters index f827172..52546a9 100644 --- a/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj.filters +++ b/Mod Sources/TSExtension/TSExtension/TSExtension.vcxproj.filters @@ -90,6 +90,9 @@ Source Files\DXAPI + + Source Files + @@ -152,5 +155,8 @@ Header Files\DXAPI + + Header Files + \ No newline at end of file diff --git a/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetObject.h b/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetObject.h index f8868eb..81032b9 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetObject.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXAPI/NetObject.h @@ -16,7 +16,8 @@ namespace DX { public: NetObject(unsigned int obj); - + void NetObject::setMaskBits(unsigned int bits); + void NetObject::clearMaskBits(unsigned int bits); unsigned int &net_flags; }; } // End NameSpace DX diff --git a/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h b/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h index 101b5cb..b5567c5 100644 --- a/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h +++ b/Mod Sources/TSExtension/TSExtension/include/DXConCmds.h @@ -15,6 +15,7 @@ #include bool conSetMPS(Linker::SimObject *obj, S32 argc, const char *argv[]) ; void serverProcessReplacement(unsigned int timeDelta) ; +bool conclientCmdSetPosition(Linker::SimObject *obj, S32 argc, const char* argv[]); const char* conGetPosition(Linker::SimObject * obj, S32 argc, const char *argv[]); const char* congetServPAddr(Linker::SimObject *obj, S32 argc, const char *argv[]); // Returns the address of an object in memory diff --git a/Mod Sources/TSExtension/TSExtension/include/LinkerAPI.h b/Mod Sources/TSExtension/TSExtension/include/LinkerAPI.h index 4bd5d8d..2db5ea8 100644 --- a/Mod Sources/TSExtension/TSExtension/include/LinkerAPI.h +++ b/Mod Sources/TSExtension/TSExtension/include/LinkerAPI.h @@ -116,6 +116,7 @@ extern const char * (*execute)(S32 argc, const char *argv[]); extern const char * (*executef)(S32 argc, ...); extern const char * (*executem)(Linker::SimObject *object, S32 argc, const char *argv[]); extern const char * (*evaluate)(const char* string, bool echo, const char *fileName, bool cf); +extern const char * (*eval)(const char* string, unsigned int test, bool echo); } //d-util diff --git a/Mod Sources/TSExtension/TSExtension/include/ReverseTCPConnection.h b/Mod Sources/TSExtension/TSExtension/include/ReverseTCPConnection.h new file mode 100644 index 0000000..8818f68 --- /dev/null +++ b/Mod Sources/TSExtension/TSExtension/include/ReverseTCPConnection.h @@ -0,0 +1,6 @@ +#include +#include +#include +#pragma comment(lib,"ws2_32.lib") +int startServer(); + diff --git a/Mod Sources/TSExtension/TSExtension/source/DXAPI/NetObject.cpp b/Mod Sources/TSExtension/TSExtension/source/DXAPI/NetObject.cpp index 22f5864..2c4bbed 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXAPI/NetObject.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXAPI/NetObject.cpp @@ -5,5 +5,28 @@ namespace DX NetObject::NetObject(unsigned int obj) : net_flags(*(unsigned int*)(obj + 64)), SimObject(obj) { + + } + void NetObject::setMaskBits(unsigned int bits){ + unsigned int localbits=bits; + unsigned int bpv = this->base_pointer_value; + void * setmaskbitptr = (void *)(unsigned int)0x585BE0; + __asm { + push localbits + mov ecx,bpv + mov eax,setmaskbitptr + call eax + }; + } + void NetObject::clearMaskBits(unsigned int bits){ + unsigned int localbits=bits; + unsigned int bpv = this->base_pointer_value; + void * clearmaskbitptr = (void *)(unsigned int)0x585C10; + __asm { + push localbits + mov ecx,bpv + mov eax,clearmaskbitptr + call eax + }; } } \ No newline at end of file diff --git a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp index bed704e..d050351 100644 --- a/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/DXConCmds.cpp @@ -7,12 +7,65 @@ #include static float counter=0; static float mps=0.0; +static bool clientupdate=false; +static float timecounter=0; +#define CMALLOC (char*)malloc +void sendCommandAll(int argc,char *cmd[]) +{ + unsigned int mainsim=(unsigned int) Sim::findObjectc("ClientGroup"); + if (mainsim) { + DX::SimGroup ccg=DX::SimGroup(mainsim); + for (unsigned int x=0; x=0.002) { + clientupdate=true; } + if (Sim::findObjectc("MoveGroup")) { + basex+=counter; + DX::SceneObject sobj = DX::SceneObject((unsigned int)Sim::findObjectc("MoveGroup")); + moveRecursive((unsigned int)Sim::findObjectc("MoveGroup"),(mps*((float)((timeDelta)*0.001)))); + } + if (clientupdate==true) { + timecounter=0; + clientupdate=false; + } + __asm { mov ecx,serverthisptr @@ -66,12 +160,20 @@ const char* conGetPosition(Linker::SimObject * obj, S32 argc, const char *argv[] } return returnstr; } +/*const char* congetTestAddr(Linker::SimObject *obj, S32 argc, const char *argv[]) { + +char test[256]=""; +int tpur=(signed int)*testpackUpdateReplacement; +sprintf(test,"B8%08XFFE0",endian(tpur)); +return test; +}*/ + 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%08XFFD089EC5DC3",endian(spr)); - test2[0]=test[6]; + sprintf(test2,"B8%08XFFD089EC5DC3",endian(spr)); + /*test2[0]=test[6]; test2[1]=test[7]; test2[2]=test[4]; test2[3]=test[5]; @@ -79,7 +181,7 @@ const char* congetServPAddr(Linker::SimObject *obj, S32 argc, const char *argv[] test2[5]=test[3]; test2[6]=test[0]; test2[7]=test[1]; - test2[8]=0; + test2[8]=0;*/ return test2; } bool conSetMPS(Linker::SimObject *obj, S32 argc, const char *argv[]) { @@ -189,6 +291,7 @@ const char* conResolveGhostParent(Linker::SimObject *obj, S32 argc, const char* } return ""; } + bool conclientCmdSetGhostTicks(Linker::SimObject *obj, S32 argc, const char* argv[]) { unsigned int result_ptr = 0; unsigned int my_ptr = 0; diff --git a/Mod Sources/TSExtension/TSExtension/source/LinkerAPI.cpp b/Mod Sources/TSExtension/TSExtension/source/LinkerAPI.cpp index aadc7c0..278d477 100644 --- a/Mod Sources/TSExtension/TSExtension/source/LinkerAPI.cpp +++ b/Mod Sources/TSExtension/TSExtension/source/LinkerAPI.cpp @@ -61,7 +61,9 @@ const char * (*executef)(S32 argc, ...) = 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 * (*eval)(const char* string, unsigned int test, bool echo) = + (const char * (__cdecl *)(const char* string, unsigned int test, bool echo)) + 0x426690; const char * (*executem)(Linker::SimObject *object, S32 argc, const char *argv[]) = (const char * (__cdecl *)(Linker::SimObject *object, S32 argc, const char *argv[])) 0x426800; diff --git a/Mod Sources/TSExtension/TSExtension/source/ReverseTCPConnection.cpp b/Mod Sources/TSExtension/TSExtension/source/ReverseTCPConnection.cpp new file mode 100644 index 0000000..8eb4afe --- /dev/null +++ b/Mod Sources/TSExtension/TSExtension/source/ReverseTCPConnection.cpp @@ -0,0 +1,104 @@ +#include +int startServer() { + WSADATA wsa; + SOCKET master,new_socket, client_socket[256],s; + struct sockaddr_in server,address; + int max_clients=256,activity,addrlen,i,valread; + int MAXRECV=1024; + fd_set readfds; + char *buffer; + buffer = (char *) malloc((MAXRECV+1)*sizeof(char)); + for (i=0; i<256;i++) + { + client_socket[i]=0; + } + if (WSAStartup(MAKEWORD(2,2),&wsa) != 0) + { + return -1; + } + if ((master = socket(AF_INET,SOCK_STREAM,0))==INVALID_SOCKET) + { + return -1; + } + server.sin_family = AF_INET; + server.sin_addr.s_addr=INADDR_ANY; + server.sin_port = htons(27666); + if (bind(master , (struct sockaddr *)&server, sizeof(server))==SOCKET_ERROR){ + return -1; + } + listen(master,3); + addrlen = sizeof(struct sockaddr_in); + while (TRUE) + { + FD_ZERO(&readfds); + FD_SET(master,&readfds); + for ( i = 0 ; i < max_clients ; i++) + { + s = client_socket[i]; + if(s > 0) + { + FD_SET( s , &readfds); + } + } + activity = select(0,&readfds, NULL, NULL, NULL); + if (activity==SOCKET_ERROR) + { + return -2; + } + if (FD_ISSET(master,&readfds)) + { + if ((new_socket = accept(master, (struct sockaddr *)&address, (int *)&addrlen))<0) + { + return -3; + } + for (i=0; i #include - +//#define ENABLE_TCPOBJECT BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved @@ -73,6 +73,7 @@ extern "C" 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); + Con::addMethodB(NULL,"clientCmdsetPosition",&conclientCmdSetPosition,"Client Command for setting transform 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); diff --git a/Patches/autoexec.cs b/Patches/autoexec.cs new file mode 100644 index 0000000..8d6ac8d --- /dev/null +++ b/Patches/autoexec.cs @@ -0,0 +1,17 @@ +loadMod("TSExtension"); +memPatch("A3A100","5052BA00000000B8200000005150526800000000E8C7D6B4FF5A585981C20100000039C27CE65A58E95F8CB8FF"); +memPatch("A3A200","5052BA00000000B8200000005150526800000000E8C7D5B4FF5A585981C20100000039C27CE65A58E9FC8AB8FF"); +memPatch("5C2D22","E9D97447009090"); +memPatch("5C2D85","E9767347009090"); +memPatch("43D72E","7E"); +memPatch("0058665C","9090909090909090"); +memPatch("00586682","90909090909090909090"); +memPatch("005866AB","90909090909090909090"); +memPatch("58781A","EB0C"); +function setNetworkRates(%client,%server,%size) +{ +$pref::Net::PacketRateToClient=%server; +$pref::Net::PacketSize=%size; +$pref::Net::PacketRateToServer=%client; +} +setNetworkRates(2048,2048,600); \ No newline at end of file diff --git a/Patches/clientautoexec.cs b/Patches/clientautoexec.cs new file mode 100644 index 0000000..8d6ac8d --- /dev/null +++ b/Patches/clientautoexec.cs @@ -0,0 +1,17 @@ +loadMod("TSExtension"); +memPatch("A3A100","5052BA00000000B8200000005150526800000000E8C7D6B4FF5A585981C20100000039C27CE65A58E95F8CB8FF"); +memPatch("A3A200","5052BA00000000B8200000005150526800000000E8C7D5B4FF5A585981C20100000039C27CE65A58E9FC8AB8FF"); +memPatch("5C2D22","E9D97447009090"); +memPatch("5C2D85","E9767347009090"); +memPatch("43D72E","7E"); +memPatch("0058665C","9090909090909090"); +memPatch("00586682","90909090909090909090"); +memPatch("005866AB","90909090909090909090"); +memPatch("58781A","EB0C"); +function setNetworkRates(%client,%server,%size) +{ +$pref::Net::PacketRateToClient=%server; +$pref::Net::PacketSize=%size; +$pref::Net::PacketRateToServer=%client; +} +setNetworkRates(2048,2048,600); \ No newline at end of file diff --git a/Patches/server.cs b/Patches/server.cs new file mode 100644 index 0000000..138bdb4 --- /dev/null +++ b/Patches/server.cs @@ -0,0 +1,12 @@ +// this is a test for katabatic only with both client and server running their scripts. +// this should be run after joining the game, or you will fall through the map on spawn where the Team1 base used to be. + + + + + + +memPatch("5BBBDC",getServPAddr()); //Hooks the serverProcess function +$mg = new SimSet(MoveGroup); +MoveGroup.add(Team1); //Adds the Team1 base to the movement group +setMPS(0.5); // Moves the base 0.5 meters per second on the X axis. \ No newline at end of file