Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool __fastcall WriteUsercmdDeltaToBuffer_h(IBaseClientDLL* ECX, void* EDX, int nSlot, bf_write* buf, int from, int to, bool isNewCmd)
- {
- static auto o_WriteUsercmdDeltaToBuffer = best_hook.get_original< WriteUsercmdDeltaToBuffer_t>(23);
- 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 ? ? ? ?");
- if ( nTickBaseShift <= 0 || (DWORD)_ReturnAddress() != WriteUsercmdDeltaToBufferReturn )
- return o_WriteUsercmdDeltaToBuffer(ECX, nSlot, buf, from, to, isNewCmd);
- if ( from != -1 )
- return true;
- auto CL_SendMove = []()
- {
- using CL_SendMove_t = void(__fastcall*)(void);
- static CL_SendMove_t CL_SendMoveF = (CL_SendMove_t)Utils::PatternScan(GetModuleHandleA("engine.dll"), "55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? B9 ? ? ? ? 53 8B 98");
- CL_SendMoveF();
- };
- 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(GetModuleHandleA("client_panorama.dll"), "55 8B EC 83 E4 F8 51 53 56 8B D9 8B 0D");
- WriteUsercmdF(buf, in, out);
- };
- int* pNumBackupCommands = (int*)(reinterpret_cast<uintptr_t>(buf) - 0x30);
- int* pNumNewCommands = (int*)(reinterpret_cast<uintptr_t>(buf) - 0x2C);
- auto net_channel = g_ClientState->net_channel;
- int32_t new_commands = *pNumNewCommands;
- 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->last_outgoing_command + g_ClientState->choked_commands + 1;
- int32_t total_new_commands = min(nTickBaseShift, 62);
- nTickBaseShift -= total_new_commands;
- from = -1;
- *pNumNewCommands = total_new_commands;
- *pNumBackupCommands = 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 o_WriteUsercmdDeltaToBuffer(ECX, nSlot, buf, from, to, isNewCmd);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement