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

@@ -189,6 +189,7 @@ void CHARACTER::Initialize()
m_pkDestroyWhenIdleEvent = NULL;
m_pkChrSyncOwner = NULL;
m_dwSyncOwnerLockExpire = 0;
memset(&m_points, 0, sizeof(m_points));
memset(&m_pointsInstant, 0, sizeof(m_pointsInstant));
@@ -4317,6 +4318,7 @@ bool CHARACTER::SetSyncOwner(LPCHARACTER ch, bool bRemoveFromList)
// 리스트에서 제거하지 않더라도 포인터는 NULL로 셋팅되어야 한다.
m_pkChrSyncOwner = NULL;
m_dwSyncOwnerLockExpire = 0;
}
else
{
@@ -4345,6 +4347,7 @@ bool CHARACTER::SetSyncOwner(LPCHARACTER ch, bool bRemoveFromList)
m_pkChrSyncOwner = ch;
m_pkChrSyncOwner->m_kLst_pkChrSyncOwned.push_back(this);
m_dwSyncOwnerLockExpire = 0;
// SyncOwner가 바뀌면 LastSyncTime을 초기화한다.
static const timeval zero_tv = {0, 0};
@@ -4401,6 +4404,28 @@ bool CHARACTER::IsSyncOwner(LPCHARACTER ch) const
return false;
}
void CHARACTER::LockSyncOwner(DWORD dwDurationMs)
{
if (!m_pkChrSyncOwner || !dwDurationMs)
return;
const DWORD dwNow = get_dword_time();
const DWORD dwExpire = dwNow + dwDurationMs;
if (m_dwSyncOwnerLockExpire < dwExpire)
m_dwSyncOwnerLockExpire = dwExpire;
}
bool CHARACTER::IsSyncOwnerLocked() const
{
return m_pkChrSyncOwner && get_dword_time() < m_dwSyncOwnerLockExpire;
}
bool CHARACTER::IsSyncOwnerLockedFor(LPCHARACTER ch) const
{
return ch && m_pkChrSyncOwner == ch && get_dword_time() < m_dwSyncOwnerLockExpire;
}
void CHARACTER::SetParty(LPPARTY pkParty)
{
if (pkParty == m_pkParty)