Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. /*
  2. bool __fastcall Hooks::hkdWriteUsercmdDeltaToBuffer(void* ecx, void*, int slot, bf_write* buf, int from, int to, bool isnewcommand)
  3. {
  4. static auto ofunct = g_Hooks.pClientHook->GetOriginal<WriteUsercmdDeltaToBufferFn>(24);
  5.  
  6. if (Globals::m_nTickbaseShift <= 0)
  7. return ofunct(ecx, slot, buf, from, to, isnewcommand);
  8.  
  9. if (from != -1)
  10. return true;
  11.  
  12. auto CL_SendMove = []() {
  13. using CL_SendMove_t = void(__fastcall*)(void);
  14. static CL_SendMove_t CL_SendMoveF = (CL_SendMove_t)Utils::FindSignature("engine.dll", "55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? B9 ? ? ? ? 53 8B 98");
  15.  
  16. CL_SendMoveF();
  17. };
  18. auto WriteUsercmd = [](bf_write* buf, CUserCmd* in, CUserCmd* out) {
  19. using WriteUsercmd_t = void(__fastcall*)(bf_write*, CUserCmd*, CUserCmd*);
  20. static WriteUsercmd_t WriteUsercmdF = (WriteUsercmd_t)Utils::FindSignature("client_panorama.dll", "55 8B EC 83 E4 F8 51 53 56 8B D9 8B 0D");
  21. WriteUsercmdF(buf, in, out);
  22.  
  23. };
  24. int* pNumBackupCommands = (int*)(reinterpret_cast<uintptr_t>(buf) - 0x30);
  25. int* pNumNewCommands = (int*)(reinterpret_cast<uintptr_t>(buf) - 0x2C);
  26. auto net_channel = *reinterpret_cast<NetChannel**>(reinterpret_cast<uintptr_t>(g_pClientState) + 0x9C);
  27. int32_t new_commands = *pNumNewCommands;
  28.  
  29. if (!Globals::bInSendMove) {
  30. if (new_commands <= 0)
  31. return false;
  32.  
  33. Globals::bInSendMove = true;
  34. Globals::bFirstSendMovePack = true;
  35. Globals::m_nTickbaseShift += new_commands;
  36.  
  37. while (Globals::m_nTickbaseShift > 0) {
  38. CL_SendMove();
  39. Globals::bFirstSendMovePack = false;
  40. }
  41.  
  42. Globals::bInSendMove = false;
  43. return false;
  44. }
  45.  
  46. if (!Globals::bFirstSendMovePack) {
  47. int32_t loss = min(Globals::m_nTickbaseShift, 10);
  48.  
  49. Globals::m_nTickbaseShift -= loss;
  50. net_channel->m_nOutSequenceNr += loss;
  51. }
  52.  
  53. int32_t next_cmdnr = g_pClientState->m_nLastOutgoingCommand + g_pClientState->m_nChokedCommands + 1;
  54. int32_t total_new_commands = min(Globals::m_nTickbaseShift, 62);
  55. Globals::m_nTickbaseShift -= total_new_commands;
  56.  
  57. from = -1;
  58. *pNumNewCommands = total_new_commands;
  59. *pNumBackupCommands = 0;
  60.  
  61. for (to = next_cmdnr - new_commands + 1; to <= next_cmdnr; to++) {
  62. if (!ofunct(ecx, slot, buf, from, to, isnewcommand))
  63. return false;
  64.  
  65. from = to;
  66. }
  67.  
  68. CUserCmd* last_realCmd = g_GameInput->GetUserCmd(slot, from);
  69. CUserCmd fromCmd;
  70.  
  71. if (last_realCmd)
  72. fromCmd = *last_realCmd;
  73.  
  74. CUserCmd toCmd = fromCmd;
  75. toCmd.command_number++;
  76. toCmd.tick_count += 200;
  77.  
  78. for (int i = new_commands; i <= total_new_commands; i++) {
  79. WriteUsercmd(buf, &toCmd, &fromCmd);
  80. fromCmd = toCmd;
  81. toCmd.command_number++;
  82. toCmd.tick_count++;
  83. }
  84.  
  85. return true;
  86. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement