Вопрос Proper lag comp for at

  • Автор темы Автор темы lwpaster
  • Дата начала Дата начала
Начинающий
Начинающий
Статус
Оффлайн
Регистрация
20 Янв 2023
Сообщения
5
Реакции
1
I understand that this code is not good, but can you help me improve it? I'm not exactly sure what to do
specifically the "superpuper lagcomp" part is what I know is bad.
(def at)
arctictech default onnetupdate:
Expand Collapse Copy
void CLagCompensation::OnNetUpdate() {
    if (!Cheat.InGame)
        return;

    INetChannel* nc = ClientState->m_NetChannel;
    auto nci = EngineClient->GetNetChannelInfo();

    for (int i = 0; i < ClientState->m_nMaxClients; i++) {
        CBasePlayer* pl = (CBasePlayer*)EntityList->GetClientEntity(i);

        if (!pl || !pl->IsAlive() || pl == Cheat.LocalPlayer || pl->m_bDormant())
            continue;

        auto& records = lag_records[i];

        if (!records.empty() && pl->m_flSimulationTime() == pl->m_flOldSimulationTime())
            continue;

        LagRecord* prev_record = !records.empty() ? &records.back() : nullptr;

        if (prev_record && prev_record->player != pl) {
            records.clear();
            prev_record = nullptr;
        }

        if (prev_record && prev_record->animlayers[ANIMATION_LAYER_ALIVELOOP].m_flCycle == pl->GetAnimlayers()[ANIMATION_LAYER_ALIVELOOP].m_flCycle) {
            pl->m_flOldSimulationTime() = pl->m_flSimulationTime();
            continue;
        }

        LagRecord* new_record = &records.emplace_back();

        new_record->prev_record = prev_record;
        new_record->update_tick = GlobalVars->tickcount;           
        new_record->m_flSimulationTime = pl->m_flSimulationTime();
        new_record->m_flServerTime = EngineClient->GetLastTimeStamp();

        new_record->shifting_tickbase = max_simulation_time[i] >= new_record->m_flSimulationTime;

        if (new_record->m_flSimulationTime > max_simulation_time[i] || abs(max_simulation_time[i] - new_record->m_flSimulationTime) > 3.f)
            max_simulation_time[i] = new_record->m_flSimulationTime;

        last_update_tick[i] = GlobalVars->tickcount;

        AnimationSystem->UpdateAnimations(pl, new_record, records);
        RecordDataIntoTrack(pl, new_record);

        if (prev_record)
                new_record->breaking_lag_comp = (prev_record->m_vecOrigin - new_record->m_vecOrigin).LengthSqr() > 4096.f;

        if (config.visuals.esp.shared_esp->get() && !EngineClient->IsVoiceRecording() && nc) {
            if (config.visuals.esp.share_with_enemies->get() || !pl->IsTeammate()) {
                SharedESP_t msg;

                player_info_t pinfo;
                EngineClient->GetPlayerInfo(i, &pinfo);

                msg.m_iPlayer = pinfo.userId;
                msg.m_ActiveWeapon = pl->GetActiveWeapon() ? pl->GetActiveWeapon()->m_iItemDefinitionIndex() : 0;
                msg.m_iHealth = pl->m_iHealth();
                msg.m_vecOrigin = new_record->m_vecOrigin;

                NetMessages->SendNetMessage((SharedVoiceData_t*)&msg);
            }
        }

        while (records.size() > (pl->IsTeammate() ? 4 : (TIME_TO_TICKS(0.4f) + 13))) // super duper proper lagcomp
            records.pop_front();

        INetChannelInfo* nci = EngineClient->GetNetChannelInfo();
        if (config.visuals.esp.show_server_hitboxes->get() && nci && nci->IsLoopback())
            pl->DrawServerHitboxes(GlobalVars->interval_per_tick, true);
    }
}
 
  • Ахаха
Реакции: mj12
You can just set any number that will be higher than maximum possible backtrack ticks, there is nothing bad about that part
 
I understand that this code is not good, but can you help me improve it? I'm not exactly sure what to do
specifically the "superpuper lagcomp" part is what I know is bad.
(def at)
arctictech default onnetupdate:
Expand Collapse Copy
void CLagCompensation::OnNetUpdate() {
    if (!Cheat.InGame)
        return;

    INetChannel* nc = ClientState->m_NetChannel;
    auto nci = EngineClient->GetNetChannelInfo();

    for (int i = 0; i < ClientState->m_nMaxClients; i++) {
        CBasePlayer* pl = (CBasePlayer*)EntityList->GetClientEntity(i);

        if (!pl || !pl->IsAlive() || pl == Cheat.LocalPlayer || pl->m_bDormant())
            continue;

        auto& records = lag_records[i];

        if (!records.empty() && pl->m_flSimulationTime() == pl->m_flOldSimulationTime())
            continue;

        LagRecord* prev_record = !records.empty() ? &records.back() : nullptr;

        if (prev_record && prev_record->player != pl) {
            records.clear();
            prev_record = nullptr;
        }

        if (prev_record && prev_record->animlayers[ANIMATION_LAYER_ALIVELOOP].m_flCycle == pl->GetAnimlayers()[ANIMATION_LAYER_ALIVELOOP].m_flCycle) {
            pl->m_flOldSimulationTime() = pl->m_flSimulationTime();
            continue;
        }

        LagRecord* new_record = &records.emplace_back();

        new_record->prev_record = prev_record;
        new_record->update_tick = GlobalVars->tickcount;          
        new_record->m_flSimulationTime = pl->m_flSimulationTime();
        new_record->m_flServerTime = EngineClient->GetLastTimeStamp();

        new_record->shifting_tickbase = max_simulation_time[i] >= new_record->m_flSimulationTime;

        if (new_record->m_flSimulationTime > max_simulation_time[i] || abs(max_simulation_time[i] - new_record->m_flSimulationTime) > 3.f)
            max_simulation_time[i] = new_record->m_flSimulationTime;

        last_update_tick[i] = GlobalVars->tickcount;

        AnimationSystem->UpdateAnimations(pl, new_record, records);
        RecordDataIntoTrack(pl, new_record);

        if (prev_record)
                new_record->breaking_lag_comp = (prev_record->m_vecOrigin - new_record->m_vecOrigin).LengthSqr() > 4096.f;

        if (config.visuals.esp.shared_esp->get() && !EngineClient->IsVoiceRecording() && nc) {
            if (config.visuals.esp.share_with_enemies->get() || !pl->IsTeammate()) {
                SharedESP_t msg;

                player_info_t pinfo;
                EngineClient->GetPlayerInfo(i, &pinfo);

                msg.m_iPlayer = pinfo.userId;
                msg.m_ActiveWeapon = pl->GetActiveWeapon() ? pl->GetActiveWeapon()->m_iItemDefinitionIndex() : 0;
                msg.m_iHealth = pl->m_iHealth();
                msg.m_vecOrigin = new_record->m_vecOrigin;

                NetMessages->SendNetMessage((SharedVoiceData_t*)&msg);
            }
        }

        while (records.size() > (pl->IsTeammate() ? 4 : (TIME_TO_TICKS(0.4f) + 13))) // super duper proper lagcomp
            records.pop_front();

        INetChannelInfo* nci = EngineClient->GetNetChannelInfo();
        if (config.visuals.esp.show_server_hitboxes->get() && nci && nci->IsLoopback())
            pl->DrawServerHitboxes(GlobalVars->interval_per_tick, true);
    }
}
just make sure you detect defensive, add a check for it in the ragebots valids records and disable lagcomp
 
just make sure you detect defensively, add a check for it in the ragebots valids records and disable lagcomp
is checking for that as simple as checking for > 4096 ? i think AT does that by default if (!LagCompensation->ValidRecord(record)) { if (record->breaking_lag_comp || record->invalid) break; continue; } [/QUOTE]
 
Назад
Сверху Снизу