Harden fishing and mining action validation
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:18:48 +02:00
parent 819bf0b823
commit f79d5134c4
3 changed files with 171 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
#include "db.h"
#include "log.h"
#include "skill.h"
#include "utils.h"
namespace mining
{
@@ -16,6 +17,7 @@ namespace mining
MAX_ORE = 18,
MAX_FRACTION_COUNT = 9,
ORE_COUNT_FOR_REFINE = 100,
MINING_COMPLETE_MAX_DISTANCE = 1200,
};
struct SInfo
@@ -366,6 +368,42 @@ namespace mining
return 0;
}
if (load->GetMapIndex() != ch->GetMapIndex())
{
char szDetail[128];
snprintf(szDetail,
sizeof(szDetail),
"target=%u map=%ld target_map=%ld",
load->GetVID(),
static_cast<long>(ch->GetMapIndex()),
static_cast<long>(load->GetMapIndex()));
ch->RecordAntiCheatViolation("MINING_CONTEXT", 8, szDetail, true);
return 0;
}
if (!ch->CanMove() || !ch->CanHandleItem())
{
char szDetail[128];
snprintf(szDetail,
sizeof(szDetail),
"can_move=%d can_item=%d target=%u",
ch->CanMove() ? 1 : 0,
ch->CanHandleItem() ? 1 : 0,
load->GetVID());
ch->RecordAntiCheatViolation("MINING_CONTEXT", 4, szDetail);
return 0;
}
const int iDistance = DISTANCE_APPROX(ch->GetX() - load->GetX(), ch->GetY() - load->GetY());
if (iDistance > MINING_COMPLETE_MAX_DISTANCE)
{
char szDetail[128];
snprintf(szDetail, sizeof(szDetail), "target=%u distance=%d max=%d", load->GetVID(), iDistance, MINING_COMPLETE_MAX_DISTANCE);
ch->RecordAntiCheatViolation("MINING_DISTANCE", iDistance > MINING_COMPLETE_MAX_DISTANCE + 800 ? 12 : 4, szDetail, iDistance > MINING_COMPLETE_MAX_DISTANCE + 800);
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("너무 멀리 떨어져 있어 채광을 완료할 수 없습니다."));
return 0;
}
int iPct = GetOrePct(ch);
if (number(1, 100) <= iPct)
@@ -445,4 +483,3 @@ namespace mining
return false;
}
}