Harden melee sync authority
Some checks failed
build / Linux asan (push) Has been cancelled
build / Linux release (push) Has been cancelled
build / FreeBSD build (push) Has been cancelled

This commit is contained in:
server
2026-04-16 11:39:07 +02:00
parent 763d7a99b7
commit eea1875d62
4 changed files with 114 additions and 2 deletions

View File

@@ -1580,12 +1580,35 @@ void CInputMain::Move(LPCHARACTER ch, const char * data)
// FUNC_SKILL = 0x80,
//};
const float fDist = DISTANCE_SQRT((ch->GetX() - pinfo->lX) / 100, (ch->GetY() - pinfo->lY) / 100);
if (ch->IsPC() && ch->IsSyncOwnerLocked() && ch->GetSyncOwner() && ch->GetSyncOwner() != ch && fDist > 2.5f)
{
char szDetail[192];
snprintf(szDetail,
sizeof(szDetail),
"func=%u dist=%.1f owner=%s cur=(%ld,%ld) dst=(%ld,%ld)",
pinfo->bFunc,
fDist,
ch->GetSyncOwner()->GetName(),
static_cast<long>(ch->GetX()),
static_cast<long>(ch->GetY()),
static_cast<long>(pinfo->lX),
static_cast<long>(pinfo->lY));
if (fDist > 8.0f)
ch->RecordAntiCheatViolation("SYNC_LOCK_MOVE", 8, szDetail, true);
else
sys_log(1, "SYNC_LOCK_MOVE: %s %s", ch->GetName(), szDetail);
ch->Show(ch->GetMapIndex(), ch->GetX(), ch->GetY(), ch->GetZ());
ch->Stop();
return;
}
// 텔레포트 핵 체크
// if (!test_server) //2012.05.15 김용욱 : 테섭에서 (무적상태로) 다수 몬스터 상대로 다운되면서 공격시 콤보핵으로 죽는 문제가 있었다.
{
const float fDist = DISTANCE_SQRT((ch->GetX() - pinfo->lX) / 100, (ch->GetY() - pinfo->lY) / 100);
if (((false == ch->IsRiding() && fDist > 25) || fDist > 40) && OXEVENT_MAP_INDEX != ch->GetMapIndex())
{
char szDetail[160];
@@ -1916,6 +1939,21 @@ int CInputMain::SyncPosition(LPCHARACTER ch, const char * c_pcData, size_t uiByt
continue;
}
if (victim->IsSyncOwnerLocked() && !victim->IsSyncOwnerLockedFor(ch))
{
char szDetail[192];
snprintf(szDetail,
sizeof(szDetail),
"victim=%s owner=%s requester=%s sync=(%ld,%ld)",
victim->GetName(),
victim->GetSyncOwner() ? victim->GetSyncOwner()->GetName() : "-",
ch->GetName(),
static_cast<long>(e->lX),
static_cast<long>(e->lY));
ch->RecordAntiCheatViolation("SYNC_OWNER_STEAL", 4, szDetail);
continue;
}
// 소유권 검사
if (!victim->SetSyncOwner(ch))
continue;