Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2020
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1.     static auto original_fn = hlclient_hook.get_original<WriteUserCmd>(24);
  2.  
  3.         if (nTickbaseShift < 0)
  4.             return original_fn(g_CHLClient, nSlot, buffer, from, to, isNewCommand);
  5.  
  6.         if (from != -1)
  7.             return true;
  8.  
  9.  
  10.         auto pNumBackupCommands = (int*)(reinterpret_cast <uintptr_t> (buffer) - 0x30);
  11.         auto pNumNewCommands = (int*)(reinterpret_cast <uintptr_t> (buffer) - 0x2C);
  12.  
  13.         auto net_channel = *reinterpret_cast <INetChannel**> (reinterpret_cast <uintptr_t> (g_ClientState) + 0x9C);
  14.         auto new_commands = *pNumNewCommands;
  15.  
  16.         auto next_cmdnr = g_ClientState->m_nLastOutgoingCommand + g_ClientState->m_NetChannel->m_nChokedPackets + 1;
  17.         auto total_new_commands = std::min(nTickbaseShift, 17);
  18.  
  19.         nTickbaseShift -= total_new_commands;
  20.         from = -1;
  21.  
  22.         *pNumNewCommands = total_new_commands;
  23.         *pNumBackupCommands = 0;
  24.  
  25.         for (to = next_cmdnr - new_commands + 1; to <= next_cmdnr; to++)
  26.         {
  27.             if (!original_fn(g_CHLClient, nSlot, buffer, from, to, isNewCommand))
  28.                 return false;
  29.  
  30.             from = to;
  31.         }
  32.  
  33.         auto last_realCmd = g_Input->GetUserCmd(nSlot, from);
  34.         CUserCmd fromCmd;
  35.  
  36.         if (last_realCmd)
  37.             fromCmd = *last_realCmd;
  38.  
  39.         auto toCmd = fromCmd;
  40.         toCmd.command_number++;
  41.         toCmd.tick_count += 200;
  42.  
  43.         for (auto i = new_commands; i <= total_new_commands; i++)
  44.         {
  45.             Utils::WriteUsercmd(buffer, &toCmd, &fromCmd);
  46.             fromCmd = toCmd;
  47.             toCmd.command_number++;
  48.             toCmd.tick_count++;
  49.         }
  50.  
  51.         return true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement