SHARE
TWEET

Untitled

a guest Sep 16th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     bool __fastcall WriteUsercmdDeltaToBuffer_h(IBaseClientDLL* ECX, void* EDX, int nSlot, bf_write* buf, int from, int to, bool isNewCmd)
  2.     {
  3.         static auto o_WriteUsercmdDeltaToBuffer = best_hook.get_original< WriteUsercmdDeltaToBuffer_t>(23);
  4.         static DWORD WriteUsercmdDeltaToBufferReturn = (DWORD)Utils::PatternScan(GetModuleHandleA("engine.dll"), "84 C0 74 04 B0 01 EB 02 32 C0 8B FE 46 3B F3 7E C9 84 C0 0F 84 ? ? ? ?");
  5.  
  6.         if ( nTickBaseShift <= 0 || (DWORD)_ReturnAddress() != WriteUsercmdDeltaToBufferReturn )
  7.             return o_WriteUsercmdDeltaToBuffer(ECX, nSlot, buf, from, to, isNewCmd);
  8.  
  9.         if ( from != -1 )
  10.             return true;
  11.  
  12.         auto CL_SendMove = []()
  13.         {
  14.             using CL_SendMove_t = void(__fastcall*)(void);
  15.             static CL_SendMove_t CL_SendMoveF = (CL_SendMove_t)Utils::PatternScan(GetModuleHandleA("engine.dll"), "55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? B9 ? ? ? ? 53 8B 98");
  16.  
  17.             CL_SendMoveF();
  18.         };
  19.  
  20.         auto WriteUsercmd = [](bf_write* buf, CUserCmd* in, CUserCmd* out)
  21.         {
  22.             using WriteUsercmd_t = void(__fastcall*)(bf_write*, CUserCmd*, CUserCmd*);
  23.             static WriteUsercmd_t WriteUsercmdF = (WriteUsercmd_t)Utils::PatternScan(GetModuleHandleA("client_panorama.dll"), "55 8B EC 83 E4 F8 51 53 56 8B D9 8B 0D");
  24.             WriteUsercmdF(buf, in, out);
  25.  
  26.         };
  27.  
  28.         int* pNumBackupCommands = (int*)(reinterpret_cast<uintptr_t>(buf) - 0x30);
  29.         int* pNumNewCommands = (int*)(reinterpret_cast<uintptr_t>(buf) - 0x2C);
  30.         auto net_channel = g_ClientState->net_channel;
  31.  
  32.         int32_t new_commands = *pNumNewCommands;
  33.  
  34.         if ( !bInSendMove )
  35.         {
  36.             if ( new_commands <= 0 )
  37.                 return false;
  38.  
  39.             bInSendMove = true;
  40.             bFirstSendMovePack = true;
  41.             nTickBaseShift += new_commands;
  42.  
  43.             while ( nTickBaseShift > 0 )
  44.             {
  45.                 CL_SendMove();
  46.                 net_channel->Transmit(false);
  47.                 bFirstSendMovePack = false;
  48.             }
  49.  
  50.             bInSendMove = false;
  51.             return false;
  52.         }
  53.  
  54.         if ( !bFirstSendMovePack )
  55.         {
  56.             int32_t loss = min(nTickBaseShift, 10);
  57.  
  58.             nTickBaseShift -= loss;
  59.             net_channel->m_nOutSequenceNr += loss;
  60.         }
  61.  
  62.         int32_t next_cmdnr = g_ClientState->last_outgoing_command + g_ClientState->choked_commands + 1;
  63.         int32_t total_new_commands = min(nTickBaseShift, 62);
  64.         nTickBaseShift -= total_new_commands;
  65.  
  66.         from = -1;
  67.         *pNumNewCommands = total_new_commands;
  68.         *pNumBackupCommands = 0;
  69.  
  70.         for ( to = next_cmdnr - new_commands + 1; to <= next_cmdnr; to++ )
  71.         {
  72.             if ( !o_WriteUsercmdDeltaToBuffer(ECX, nSlot, buf, from, to, true) )
  73.                 return false;
  74.  
  75.             from = to;
  76.         }
  77.  
  78.         CUserCmd* last_realCmd = g_Input->GetUserCmd(nSlot, from);
  79.         CUserCmd fromCmd;
  80.  
  81.         if ( last_realCmd )
  82.             fromCmd = *last_realCmd;
  83.  
  84.         CUserCmd toCmd = fromCmd;
  85.         toCmd.command_number++;
  86.         toCmd.tick_count += 200;
  87.  
  88.         for ( int i = new_commands; i <= total_new_commands; i++ )
  89.         {
  90.             WriteUsercmd(buf, &toCmd, &fromCmd);
  91.             fromCmd = toCmd;
  92.             toCmd.command_number++;
  93.             toCmd.tick_count++;
  94.         }
  95.        
  96.         return o_WriteUsercmdDeltaToBuffer(ECX, nSlot, buf, from, to, isNewCmd);
  97.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top