Validate interaction NPCs for refine and cube
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 12:43:34 +02:00
parent f79d5134c4
commit bdfdef8411
4 changed files with 183 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "char.h"
#include "utils.h"
#include "item.h"
#include "desc.h"
#include "DragonSoul.h"
@@ -150,5 +151,41 @@ bool CHARACTER::DragonSoul_RefineWindow_Close()
bool CHARACTER::DragonSoul_RefineWindow_CanRefine()
{
return NULL != m_pointsInstant.m_pDragonSoulRefineWindowOpener;
}
if (NULL == m_pointsInstant.m_pDragonSoulRefineWindowOpener)
return false;
LPENTITY pOpener = m_pointsInstant.m_pDragonSoulRefineWindowOpener;
if (!pOpener->IsType(ENTITY_CHARACTER))
{
RecordAntiCheatViolation("DRAGON_SOUL_REFINE", 6, "state=invalid_opener", true);
m_pointsInstant.m_pDragonSoulRefineWindowOpener = NULL;
return false;
}
LPCHARACTER npc = (LPCHARACTER)pOpener;
if (!npc->IsNPC() || npc == this || npc->GetMapIndex() != GetMapIndex())
{
char szDetail[160];
snprintf(szDetail,
sizeof(szDetail),
"npc=%u map=%ld npc_map=%ld",
npc->GetVID(),
static_cast<long>(GetMapIndex()),
static_cast<long>(npc->GetMapIndex()));
RecordAntiCheatViolation("DRAGON_SOUL_REFINE", 8, szDetail, true);
m_pointsInstant.m_pDragonSoulRefineWindowOpener = NULL;
return false;
}
const int iDistance = DISTANCE_APPROX(GetX() - npc->GetX(), GetY() - npc->GetY());
if (iDistance > 2000)
{
char szDetail[160];
snprintf(szDetail, sizeof(szDetail), "npc=%u distance=%d max=%d", npc->GetVID(), iDistance, 2000);
RecordAntiCheatViolation("DRAGON_SOUL_REFINE", iDistance > 2800 ? 12 : 4, szDetail, iDistance > 2800);
m_pointsInstant.m_pDragonSoulRefineWindowOpener = NULL;
return false;
}
return true;
}