Пользователь
-
Автор темы
- #1
Onetap v4 writeusercmddeltatobuffer hook.
Возможно вронг.
Возможно вронг.
C++:
bool hkWriteUsercmdDeltaToBuffer(int m_pThis, int edx, int m_pBuf, int m_nFrom, int m_nTo, bool m_bIsNewCommand)
{
if (!g_pGlobals.Tickbase.ShiftAmount)
return oWriteusercmdDeltaToBuffer(m_pThis, m_pBuf, m_nFrom, m_nTo, m_bIsNewCommand);
if (m_nTo != -1)
return true;
int m_iFinalFrom = -1;
int m_iFinalTo = 0;
int m_iShiftTicks = g_pGlobals.Tickbase.ShiftAmount;
g_pGlobals.Tickbase.ShiftAmount = 0;
int* m_pnNewCmds = (int*)((uintptr_t)m_pBuf - 0x2C);
int* m_pnBackupCmds = (int*)((uintptr_t)m_pBuf - 0x30);
*m_pnBackupCmds = 0;
int m_nNewCmds = *m_pnNewCmds;
int m_nNextCmdNr = g_pClientState->m_nChokedCmds + g_pClientState->m_nLastOutgoingCmd + 1;
int m_nTotalNewCmds = std::min(m_nNewCmds + abs(m_iShiftTicks), 62);
m_nTo = m_nNewCmds;
m_iFinalFrom = -1;
*m_pnNewCmds = m_nTotalNewCmds;
m_iFinalTo = m_nNextCmdNr - m_nTo + 1;
if (m_iFinalTo > m_nNextCmdNr)
{
while (oWriteusercmdDeltaToBuffer(v51, m_pBuf, m_nFrom, m_iFinalFrom, m_iFinalTo))
{
m_iFinalFrom = m_iFinalTo++;
CUserCmd* cmd = g_pInput->GetUserCmd(m_nFrom);
CUserCmd* from_cmd, to_cmd;
if (cmd)
{
from_cmd = cmd;
to_cmd = cmd;
to_cmd->command_number++;
to_cmd->tickcount += g_pGlobals.Tickrate + 2 * g_pGlobals.Tickrate;
if (m_nTo <= m_nTotalNewCmds)
{
int m_iSukaSuka = m_nTotalNewCmds - m_nTo + 1;
do
{
WriteUserCmd(m_pBuf, &to_cmd, &from_cmd);
from_cmd = to_cmd;
to_cmd->command_number++;
to_cmd->tickcount++;
--m_iSukaSuka;
}
while (m_iSukaSuka > 0);
}
}
}
}
return true;
}