Пользователь
-
Автор темы
- #1
Что более странно, так это то, что фейклаги откидывают только первые минуты 3 игры (именно игры, не времени нахождения на сервере!), потом мееньше, но все равно откидывают. Так же почти постоянно не регает вторую пулю даблтапа (этой проблемы на локалке нет, первая есть). Каждый раз когда откидывает в консоли появляется такое сообщение: Msg from loopback: CCLCMsg_CmdKeyValues rejected by msg bind (53 bytes).
Код предикта:
Меня сильно смущает то, что функция
Все нетвары я сверял с оригинальной функцией CPrediction::RunCommand, оффсеты по паттернам от туда же брал, вроде все верно.
Подскажите, что не так, пожалуйста.
Код предикта:
Prediction.cpp:
void CPrediction::StartCommand(CBasePlayer* player, CUserCmd* cmd) {
*Cheat.LocalPlayer->GetCurrentCommand() = cmd;
Cheat.LocalPlayer->GetLastCommand() = *cmd;
*predictionRandomSeed = cmd->random_seed;
*predictionEntity = Cheat.LocalPlayer;
}
void CPrediction::RunPreThink(CBasePlayer* player) {
if (!player->PhysicsRunThink(0))
return;
player->PreThink();
}
void CPrediction::RunThink(CBasePlayer* player, double frametime) {
static auto SetNextThink = reinterpret_cast<void(__thiscall*)(int)>(Utils::PatternScan("client.dll", "55 8B EC 56 57 8B F9 8B B7 ? ? ? ? 8B C6"));
int thinktick = player->m_nNextThinkTick();
if (thinktick <= 0 || thinktick > player->m_nTickBase())
return;
SetNextThink(0);
player->Think();
}
void CPrediction::BackupData() {
if (Cheat.LocalPlayer->GetActiveWeapon()) {
if (Cheat.LocalPlayer->GetActiveWeapon()->IsGrenade())
m_fThrowTime = Cheat.LocalPlayer->GetActiveWeapon()->m_flThrowTime();
m_flNextPrimaryAttack = Cheat.LocalPlayer->GetActiveWeapon()->m_flNextPrimaryAttack();
}
m_fFlags = Cheat.LocalPlayer->m_fFlags();
m_vecVelocity = Cheat.LocalPlayer->m_vecVelocity();
m_vecAbsVelocity = Cheat.LocalPlayer->m_vecAbsVelocity();
flOldCurrentTime = GlobalVars->curtime;
flOldFrameTime = GlobalVars->frametime;
iOldTickCount = GlobalVars->tickcount;
}
void CPrediction::Start(CUserCmd* cmd) {
if (!MoveHelper)
return;
BackupData();
StartCommand(Cheat.LocalPlayer, cmd);
const bool bOldIsFirstPrediction = Prediction->bIsFirstTimePredicted;
const bool bOldInPrediction = Prediction->bInPrediction;
GlobalVars->curtime = Cheat.ServerTime;
GlobalVars->frametime = Prediction->bEnginePaused ? 0.f : GlobalVars->interval_per_tick;
GlobalVars->tickcount = TIME_TO_TICKS(Cheat.ServerTime);
Prediction->bIsFirstTimePredicted = false;
Prediction->bInPrediction = true;
cmd->buttons |= Cheat.LocalPlayer->GetButtonForced();
cmd->buttons &= ~(Cheat.LocalPlayer->GetButtonDisabled());
GameMovement->StartTrackPredictionErrors(Cheat.LocalPlayer);
if (cmd->weaponselect)
{
if (CBaseCombatWeapon* weapon = reinterpret_cast<CBaseCombatWeapon*>(EntityList->GetClientEntity(cmd->weaponselect)))
{
if (CCSWeaponData* weapon_data = weapon->GetWeaponInfo())
Cheat.LocalPlayer->SelectItem(weapon_data->szWeaponName, cmd->weaponsubtype);
}
}
CBaseEntity* vehicle = reinterpret_cast<CBaseEntity*>(EntityList->GetClientEntityFromHandle(Cheat.LocalPlayer->m_hVehicle()));
if (cmd->impulse)
{
if (!vehicle || Cheat.LocalPlayer->UsingStandardWeaponsInVehicle())
Cheat.LocalPlayer->m_nImpulse() = cmd->impulse;
}
Cheat.LocalPlayer->UpdateButtonState(cmd->buttons);
Prediction->CheckMovingGround(Cheat.LocalPlayer, GlobalVars->frametime);
Prediction->SetLocalViewAngles(cmd->viewangles);
MoveHelper->SetHost(Cheat.LocalPlayer);
RunPreThink(Cheat.LocalPlayer);
RunThink(Cheat.LocalPlayer, GlobalVars->interval_per_tick);
Prediction->SetupMove(Cheat.LocalPlayer, cmd, MoveHelper, &moveData);
if (!vehicle)
GameMovement->ProcessMovement(Cheat.LocalPlayer, &moveData);
else
CallVFunction<void(__thiscall*)(void*, CBasePlayer*, CMoveData*)>(vehicle, 5)(vehicle, Cheat.LocalPlayer, &moveData);
Prediction->FinishMove(Cheat.LocalPlayer, cmd, &moveData);
MoveHelper->ProcessImpacts();
Cheat.LocalPlayer->PostThink();
GameMovement->FinishTrackPredictionErrors(Cheat.LocalPlayer);
MoveHelper->SetHost(nullptr);
GameMovement->Reset();
Prediction->bInPrediction = bOldInPrediction;
Prediction->bIsFirstTimePredicted = bOldIsFirstPrediction;
}
void CPrediction::End() {
if (!MoveHelper)
return;
GlobalVars->curtime = flOldCurrentTime;
GlobalVars->frametime = flOldFrameTime;
GlobalVars->tickcount = iOldTickCount;
if (GlobalVars->frametime > 0.f)
Cheat.LocalPlayer->m_nTickBase()++;
*Cheat.LocalPlayer->GetCurrentCommand() = nullptr;
*predictionRandomSeed = -1;
*predictionEntity = nullptr;
}
player->Think()
никогда не вызывается, все время не проходит проверка thinkticks <= 0 (23 строка).Все нетвары я сверял с оригинальной функцией CPrediction::RunCommand, оффсеты по паттернам от туда же брал, вроде все верно.
CBasePlayer.cpp:
int CBasePlayer::GetButtonForced() {
static const uint32_t m_afButtonsForced = *reinterpret_cast<uint32_t*>(Utils::PatternScan("client.dll", "8B 86 ? ? ? ? 09 47 30", 0x2));
return *(int*)(this + m_afButtonsForced);
}
int CBasePlayer::GetButtonDisabled() {
static const uint32_t m_afButtonsDisabled = *reinterpret_cast<uint32_t*>(Utils::PatternScan("client.dll", "8B 86 ? ? ? ? F7 D0 21 47 30", 0x2));
return *(int*)(this + m_afButtonsDisabled);
}
CUserCmd** CBasePlayer::GetCurrentCommand() {
static const uint32_t m_pCurrentCommand = *reinterpret_cast<uint32_t*>(Utils::PatternScan("client.dll", "89 BE ? ? ? ? E8 ? ? ? ? 85 FF", 0x2));
return (CUserCmd**)((uint32_t)this + m_pCurrentCommand);
}
CUserCmd& CBasePlayer::GetLastCommand() {
static const uint32_t m_LastCmd = *reinterpret_cast<uint32_t*>(Utils::PatternScan("client.dll", "8D 8E ? ? ? ? 89 5C 24 3C", 0x2));
return *(CUserCmd*)((uint32_t)this + m_LastCmd);
}
void CBasePlayer::Think() {
CallVFunction<void(__thiscall*)(CBasePlayer*)>(this, 139)(this);
}
bool CBasePlayer::PhysicsRunThink(int nThinkMetod) {
static auto __physicsRunThink = (bool(__thiscall*)(CBasePlayer*, int))Utils::PatternScan("client.dll", "55 8B EC 83 EC 10 53 56 57 8B F9 8B 87");
return __physicsRunThink(this, nThinkMetod);
}
void CBasePlayer::PostThink() {
CallVFunction<void(__thiscall*)(CBasePlayer*)>(this, 320)(this);
}
void CBasePlayer::SelectItem(const char* string, int subtype) {
static auto select_item_fn = reinterpret_cast<void(__thiscall*)(void*, const char*, int)>(Utils::PatternScan("client.dll", "55 8B EC 56 8B F1 ? ? ? 85 C9 74 71 8B 06"));
select_item_fn(this, string, subtype);
}
bool CBasePlayer::UsingStandardWeaponsInVehicle() {
static auto fn = reinterpret_cast<bool(__thiscall*)(CBasePlayer*)>(Utils::PatternScan("client.dll", "56 57 8B F9 8B 97 ? ? ? ? 83 FA FF 74 43"));
return fn(this);
}
void CBasePlayer::UpdateButtonState(int buttons) {
m_afButtonsLast() = *m_nButtons();
*m_nButtons() = buttons;
int buttonsChanged = m_afButtonsLast() ^ buttons;
m_afButtonsPressed() = buttonsChanged & buttons;
m_afButtonsReleased() = buttonsChanged & (~buttons);
}
int& CBasePlayer::m_nImpulse() {
static uint32_t _m_nImpulse = *reinterpret_cast<uint32_t*>(Utils::PatternScan("client.dll", "89 86 ? ? ? ? 8B 57 30", 0x2));
return *(int*)(this + _m_nImpulse);
}