Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool __fastcall Handlers::WriteUsercmdDeltaToBuffer_h(IBaseClientDLL *ECX, void *EDX, int nSlot, bf_write *buf, int from, int to, bool isNewCmd)
- {
- static DWORD WriteUsercmdDeltaToBufferReturn = (DWORD)Utils::PatternScan(GetModuleHandle("engine.dll"), "84 C0 74 04 B0 01 EB 02 32 C0 8B FE 46 3B F3 7E C9 84 C0 0F 84 ? ? ? ?");
- if (nTickBaseShift <= 0 || _ReturnAddress() != &WriteUsercmdDeltaToBufferReturn)
- return o_WriteUsercmdDeltaToBuffer(ECX, nSlot, buf, from, to, isNewCmd);
- if (from != -1)
- return true;
- // CL_SendMove function
- auto CL_SendMove = []()
- {
- using CL_SendMove_t = void(__fastcall*)(void);
- static CL_SendMove_t CL_SendMoveF = (CL_SendMove_t)Utils::PatternScan(GetModuleHandle("engine.dll"), ("55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? B9 ? ? ? ? 53 8B 98"));
- CL_SendMoveF();
- };
- // WriteUsercmd function
- auto WriteUsercmd = [](bf_write *buf, CUserCmd *in, CUserCmd *out)
- {
- using WriteUsercmd_t = void(__fastcall*)(bf_write*, CUserCmd*, CUserCmd*);
- static WriteUsercmd_t WriteUsercmdF = (WriteUsercmd_t)Utils::PatternScan(GetModuleHandle("client.dll"), ("55 8B EC 83 E4 F8 51 53 56 8B D9 8B 0D"));
- WriteUsercmdF(buf, in, out);
- };
- uintptr_t *framePtr;
- __asm mov framePtr, ebp;
- auto msg = reinterpret_cast<CCLCMsg_Move_t*>(*framePtr + 0xFCC);
- auto net_channel = g_ClientState->m_NetChannel;
- int32_t new_commands = msg->numNewCommands;
- if (!bInSendMove)
- {
- if (new_commands <= 0)
- return false;
- bInSendMove = true;
- bFirstSendMovePack = true;
- nTickBaseShift += new_commands;
- while (nTickBaseShift > 0)
- {
- CL_SendMove();
- net_channel->Transmit(false);
- bFirstSendMovePack = false;
- }
- bInSendMove = false;
- return false;
- }
- if (!bFirstSendMovePack)
- {
- int32_t loss = min(nTickBaseShift, 10);
- nTickBaseShift -= loss;
- net_channel->m_nOutSequenceNr += loss;
- }
- int32_t next_cmdnr = g_ClientState->lastoutgoingcommand + g_ClientState->chokedcommands + 1;
- int32_t total_new_commands = min(nTickBaseShift, 62);
- nTickBaseShift -= total_new_commands;
- from = -1;
- msg->numNewCommands = total_new_commands;
- msg->numBackupCommands = 0;
- for (to = next_cmdnr - new_commands + 1; to <= next_cmdnr; to++)
- {
- if (!o_WriteUsercmdDeltaToBuffer(ECX, nSlot, buf, from, to, true))
- return false;
- from = to;
- }
- CUserCmd *last_realCmd = g_Input->GetUserCmd(nSlot, from);
- CUserCmd fromCmd;
- if (last_realCmd)
- fromCmd = *last_realCmd;
- CUserCmd toCmd = fromCmd;
- toCmd.command_number++;
- toCmd.tick_count += 200;
- for (int i = new_commands; i <= total_new_commands; i++)
- {
- WriteUsercmd(buf, &toCmd, &fromCmd);
- fromCmd = toCmd;
- toCmd.command_number++;
- toCmd.tick_count++;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement