Исходник WriteUsercmdDeltaToBuffer for legendware

Пользователь
Пользователь
Статус
Оффлайн
Регистрация
12 Июн 2020
Сообщения
465
Реакции
103
Код:
Expand Collapse Copy
void WriteUserÑmd(void* buf, CUserCmd* incmd, CUserCmd* outcmd);
int32_t nTickBaseShift = 0;
int32_t nSinceUse = 0;
bool bInSendMove = false, bFirstSendMovePack = false;
bool __fastcall hooks::hooked_writeusercmddeltatobuffer(void* ecx, void*edx, int slot, bf_write* buf, int from, int to, bool isnewcommand)
{
    static auto original_fn = client_hook->get_func_address <WriteUsercmdDeltaToBuffer_t>(24);

  
    if (!g_ctx.globals.tickbase_shift)
        return original_fn(ecx, slot, buf, from, to, isnewcommand);

    if (from != -1)
        return true;



    //signatures
    auto CL_SendMove = []() {
        using CL_SendMove_t = void(__fastcall*)(void);
        static CL_SendMove_t CL_SendMoveF = (CL_SendMove_t)util::FindSignature(crypt_str("engine.dll"), crypt_str("55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? B9 ? ? ? ? 53 8B 98"));
      
        //Utils::FindSignature("engine.dll", "55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? B9 ? ? ? ? 53 8B 98");

        CL_SendMoveF();
    };


    int* pNumBackupCommands = (int*)(reinterpret_cast <uintptr_t> (buf) - 0x30);
    int* pNumNewCommands = (int*)(reinterpret_cast <uintptr_t> (buf) - 0x2C);
    auto net_channel = *reinterpret_cast <INetChannel**> (reinterpret_cast <uintptr_t> (m_clientstate()) + 0x9C);
    int32_t new_commands = *pNumNewCommands;

    //if (!g::bInSendMove) {
    //    if (new_commands <= 0)
        //    return false;
    if (!bInSendMove) {
        if (new_commands <= 0)
            return false;

        bInSendMove = true;
        bFirstSendMovePack = true;
        nTickBaseShift += new_commands;

        while (nTickBaseShift > 0) {
            CL_SendMove();
            bFirstSendMovePack = false;
        }

        bInSendMove = false;
        return false;
    }

    if (!bFirstSendMovePack) {
        int32_t loss = min(nTickBaseShift, 16);

        nTickBaseShift -= loss;
        net_channel->m_nOutSequenceNr += loss;
    }
 
    int32_t next_cmdnr = m_clientstate()->nLastOutgoingCommand + m_clientstate()->iChokedCommands + 1;
    int32_t total_new_commands = min(nTickBaseShift, 64);
    nTickBaseShift -= total_new_commands;

    from = -1;
    *pNumNewCommands = total_new_commands;
    *pNumBackupCommands = 0;

    for (to = next_cmdnr - new_commands + 1; to <= next_cmdnr; to++) {
        if (!original_fn(ecx, slot, buf, from, to, isnewcommand))
            return false;

        from = to;
    }

    CUserCmd* last_realCmd = m_input()->GetUserCmd( slot , from);//g_GameInput->GetUserCmd(slot, from);P
    CUserCmd fromCmd;

    if (last_realCmd)
        fromCmd = *last_realCmd;

    CUserCmd toCmd = fromCmd;
    toCmd.m_command_number++;
    toCmd.m_tickcount += 200;
    //run
    for (int i = new_commands; i <= total_new_commands; i++)
    {

        int m_shift = total_new_commands - new_commands + 1;
        do
        {
            WriteUserÑmd(buf, &toCmd, &fromCmd);
        
            fromCmd = toCmd;
            toCmd.m_command_number++;
            toCmd.m_tickcount++;
            --m_shift;
        } while (m_shift);
        
    }
    return true;
}

void WriteUserÑmd(void* buf, CUserCmd* incmd, CUserCmd* outcmd)
{
    using WriteUserCmd_t = void(__fastcall*)(void*, CUserCmd*, CUserCmd*);
    static auto Fn = (WriteUserCmd_t)util::FindSignature(crypt_str("client.dll"), crypt_str("55 8B EC 83 E4 F8 51 53 56 8B D9 8B 0D"));

    __asm
    {
        mov     ecx, buf
        mov     edx, incmd
        push    outcmd
        call    Fn
        add     esp, 4
    }
}
Cinput.hpp
Код:
Expand Collapse Copy
CUserCmd* CInput::GetUserCmd(int slot ,int sequence_number)//ignore error
    {
        //typedef CUserCmd* (__thiscall* GetUserCmd_t) (void*, int, int);
        return &m_pCommands[slot ,sequence_number % MULTIPLAYER_BACKUP];
 
      
    }
last ill not post lw anymore
 
1614489505475.png
 
Код:
Expand Collapse Copy
    //if (!g::bInSendMove) {
    //    if (new_commands <= 0)
        //    return false;
    if (!bInSendMove) {
        if (new_commands <= 0)
            return false;

        bInSendMove = true;
        bFirstSendMovePack = true;
        nTickBaseShift += new_commands;

        while (nTickBaseShift > 0) {
            CL_SendMove();
            bFirstSendMovePack = false;
        }

        bInSendMove = false;
        return false;
    }

    if (!bFirstSendMovePack) {
        int32_t loss = min(nTickBaseShift, 16);

        nTickBaseShift -= loss;
        net_channel->m_nOutSequenceNr += loss;
    }
}
nice superior code, stop, /del
 
Код:
Expand Collapse Copy
void WriteUserÑmd(void* buf, CUserCmd* incmd, CUserCmd* outcmd);
int32_t nTickBaseShift = 0;
int32_t nSinceUse = 0;
bool bInSendMove = false, bFirstSendMovePack = false;
bool __fastcall hooks::hooked_writeusercmddeltatobuffer(void* ecx, void*edx, int slot, bf_write* buf, int from, int to, bool isnewcommand)
{
    static auto original_fn = client_hook->get_func_address <WriteUsercmdDeltaToBuffer_t>(24);

 
    if (!g_ctx.globals.tickbase_shift)
        return original_fn(ecx, slot, buf, from, to, isnewcommand);

    if (from != -1)
        return true;



    //signatures
    auto CL_SendMove = []() {
        using CL_SendMove_t = void(__fastcall*)(void);
        static CL_SendMove_t CL_SendMoveF = (CL_SendMove_t)util::FindSignature(crypt_str("engine.dll"), crypt_str("55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? B9 ? ? ? ? 53 8B 98"));
     
        //Utils::FindSignature("engine.dll", "55 8B EC A1 ? ? ? ? 81 EC ? ? ? ? B9 ? ? ? ? 53 8B 98");

        CL_SendMoveF();
    };


    int* pNumBackupCommands = (int*)(reinterpret_cast <uintptr_t> (buf) - 0x30);
    int* pNumNewCommands = (int*)(reinterpret_cast <uintptr_t> (buf) - 0x2C);
    auto net_channel = *reinterpret_cast <INetChannel**> (reinterpret_cast <uintptr_t> (m_clientstate()) + 0x9C);
    int32_t new_commands = *pNumNewCommands;

    //if (!g::bInSendMove) {
    //    if (new_commands <= 0)
        //    return false;
    if (!bInSendMove) {
        if (new_commands <= 0)
            return false;

        bInSendMove = true;
        bFirstSendMovePack = true;
        nTickBaseShift += new_commands;

        while (nTickBaseShift > 0) {
            CL_SendMove();
            bFirstSendMovePack = false;
        }

        bInSendMove = false;
        return false;
    }

    if (!bFirstSendMovePack) {
        int32_t loss = min(nTickBaseShift, 16);

        nTickBaseShift -= loss;
        net_channel->m_nOutSequenceNr += loss;
    }

    int32_t next_cmdnr = m_clientstate()->nLastOutgoingCommand + m_clientstate()->iChokedCommands + 1;
    int32_t total_new_commands = min(nTickBaseShift, 64);
    nTickBaseShift -= total_new_commands;

    from = -1;
    *pNumNewCommands = total_new_commands;
    *pNumBackupCommands = 0;

    for (to = next_cmdnr - new_commands + 1; to <= next_cmdnr; to++) {
        if (!original_fn(ecx, slot, buf, from, to, isnewcommand))
            return false;

        from = to;
    }

    CUserCmd* last_realCmd = m_input()->GetUserCmd( slot , from);//g_GameInput->GetUserCmd(slot, from);P
    CUserCmd fromCmd;

    if (last_realCmd)
        fromCmd = *last_realCmd;

    CUserCmd toCmd = fromCmd;
    toCmd.m_command_number++;
    toCmd.m_tickcount += 200;
    //run
    for (int i = new_commands; i <= total_new_commands; i++)
    {

        int m_shift = total_new_commands - new_commands + 1;
        do
        {
            WriteUserÑmd(buf, &toCmd, &fromCmd);
       
            fromCmd = toCmd;
            toCmd.m_command_number++;
            toCmd.m_tickcount++;
            --m_shift;
        } while (m_shift);
       
    }
    return true;
}

void WriteUserÑmd(void* buf, CUserCmd* incmd, CUserCmd* outcmd)
{
    using WriteUserCmd_t = void(__fastcall*)(void*, CUserCmd*, CUserCmd*);
    static auto Fn = (WriteUserCmd_t)util::FindSignature(crypt_str("client.dll"), crypt_str("55 8B EC 83 E4 F8 51 53 56 8B D9 8B 0D"));

    __asm
    {
        mov     ecx, buf
        mov     edx, incmd
        push    outcmd
        call    Fn
        add     esp, 4
    }
}
Cinput.hpp
Код:
Expand Collapse Copy
CUserCmd* CInput::GetUserCmd(int slot ,int sequence_number)//ignore error
    {
        //typedef CUserCmd* (__thiscall* GetUserCmd_t) (void*, int, int);
        return &m_pCommands[slot ,sequence_number % MULTIPLAYER_BACKUP];

     
    }
last ill not post lw anymore
хоть не солянки из резольверов.
 
Назад
Сверху Снизу