mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-24 05:51:05 +00:00
Add undocumented config option to disable rapid fire anticheat
This quick hack has been around for a while, so we might as well make it configurable. Also updated tdata reference.
This commit is contained in:
parent
b1eea6d4fe
commit
12dde394c0
@ -56,14 +56,10 @@ static std::pair<int,int> getDamage(int attackPower, int defensePower, bool shou
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
|
static bool checkRapidFire(CNSocket *sock, int targetCount) {
|
||||||
auto pkt = (sP_CL2FE_REQ_PC_ATTACK_NPCs*)data->buf;
|
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
auto targets = (int32_t*)data->trailers;
|
|
||||||
|
|
||||||
// rapid fire anti-cheat
|
|
||||||
// TODO: move this out of here, when generalizing packet frequency validation
|
|
||||||
time_t currTime = getTime();
|
time_t currTime = getTime();
|
||||||
|
|
||||||
if (currTime - plr->lastShot < plr->fireRate * 80)
|
if (currTime - plr->lastShot < plr->fireRate * 80)
|
||||||
plr->suspicionRating += plr->fireRate * 100 + plr->lastShot - currTime; // gain suspicion for rapid firing
|
plr->suspicionRating += plr->fireRate * 100 + plr->lastShot - currTime; // gain suspicion for rapid firing
|
||||||
else if (currTime - plr->lastShot < plr->fireRate * 180 && plr->suspicionRating > 0)
|
else if (currTime - plr->lastShot < plr->fireRate * 180 && plr->suspicionRating > 0)
|
||||||
@ -71,15 +67,28 @@ static void pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
|
|||||||
|
|
||||||
plr->lastShot = currTime;
|
plr->lastShot = currTime;
|
||||||
|
|
||||||
if (pkt->iNPCCnt > 3) // 3+ targets should never be possible
|
// 3+ targets should never be possible
|
||||||
|
if (targetCount > 3)
|
||||||
plr->suspicionRating += 10000;
|
plr->suspicionRating += 10000;
|
||||||
|
|
||||||
if (plr->suspicionRating > 10000) { // kill the socket when the player is too suspicious
|
// kill the socket when the player is too suspicious
|
||||||
|
if (plr->suspicionRating > 10000) {
|
||||||
sock->kill();
|
sock->kill();
|
||||||
CNShardServer::_killConnection(sock);
|
CNShardServer::_killConnection(sock);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
|
||||||
|
auto pkt = (sP_CL2FE_REQ_PC_ATTACK_NPCs*)data->buf;
|
||||||
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
auto targets = (int32_t*)data->trailers;
|
||||||
|
|
||||||
|
// kick the player if firing too rapidly
|
||||||
|
if (settings::ANTICHEAT && checkRapidFire(sock, pkt->iNPCCnt))
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IMPORTANT: This validates memory safety in addition to preventing
|
* IMPORTANT: This validates memory safety in addition to preventing
|
||||||
|
@ -20,6 +20,7 @@ bool settings::LOCALHOSTWORKAROUND = true;
|
|||||||
time_t settings::TIMEOUT = 60000;
|
time_t settings::TIMEOUT = 60000;
|
||||||
int settings::VIEWDISTANCE = 25600;
|
int settings::VIEWDISTANCE = 25600;
|
||||||
bool settings::SIMULATEMOBS = true;
|
bool settings::SIMULATEMOBS = true;
|
||||||
|
bool settings::ANTICHEAT = true;
|
||||||
|
|
||||||
// default spawn point
|
// default spawn point
|
||||||
#ifndef ACADEMY
|
#ifndef ACADEMY
|
||||||
@ -108,6 +109,7 @@ void settings::init() {
|
|||||||
ACCLEVEL = reader.GetInteger("shard", "accountlevel", ACCLEVEL);
|
ACCLEVEL = reader.GetInteger("shard", "accountlevel", ACCLEVEL);
|
||||||
EVENTMODE = reader.GetInteger("shard", "eventmode", EVENTMODE);
|
EVENTMODE = reader.GetInteger("shard", "eventmode", EVENTMODE);
|
||||||
DISABLEFIRSTUSEFLAG = reader.GetBoolean("shard", "disablefirstuseflag", DISABLEFIRSTUSEFLAG);
|
DISABLEFIRSTUSEFLAG = reader.GetBoolean("shard", "disablefirstuseflag", DISABLEFIRSTUSEFLAG);
|
||||||
|
ANTICHEAT = reader.GetBoolean("shard", "anticheat", ANTICHEAT);
|
||||||
MONITORENABLED = reader.GetBoolean("monitor", "enabled", MONITORENABLED);
|
MONITORENABLED = reader.GetBoolean("monitor", "enabled", MONITORENABLED);
|
||||||
MONITORPORT = reader.GetInteger("monitor", "port", MONITORPORT);
|
MONITORPORT = reader.GetInteger("monitor", "port", MONITORPORT);
|
||||||
MONITORINTERVAL = reader.GetInteger("monitor", "interval", MONITORINTERVAL);
|
MONITORINTERVAL = reader.GetInteger("monitor", "interval", MONITORINTERVAL);
|
||||||
|
@ -10,6 +10,7 @@ namespace settings {
|
|||||||
extern int SHARDPORT;
|
extern int SHARDPORT;
|
||||||
extern std::string SHARDSERVERIP;
|
extern std::string SHARDSERVERIP;
|
||||||
extern bool LOCALHOSTWORKAROUND;
|
extern bool LOCALHOSTWORKAROUND;
|
||||||
|
extern bool ANTICHEAT;
|
||||||
extern time_t TIMEOUT;
|
extern time_t TIMEOUT;
|
||||||
extern int VIEWDISTANCE;
|
extern int VIEWDISTANCE;
|
||||||
extern bool SIMULATEMOBS;
|
extern bool SIMULATEMOBS;
|
||||||
|
2
tdata
2
tdata
@ -1 +1 @@
|
|||||||
Subproject commit 8230fb8649d6da8de71e918c24efbb55d1c08a88
|
Subproject commit cc65dbb402b5baa2b604ed66132edd88cc82a52a
|
Loading…
Reference in New Issue
Block a user