mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Get rid of player fire rate suspicion
This was super primitive & jank, and caused false positives. Will replace with a polished system later on.
This commit is contained in:
parent
ea61ed1aaa
commit
9f7c8a18df
@ -137,26 +137,6 @@ static void pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
|
|||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
auto targets = (int32_t*)data->trailers;
|
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();
|
|
||||||
if (currTime - plr->lastShot < plr->fireRate * 80)
|
|
||||||
plr->suspicionRating += plr->fireRate * 100 + plr->lastShot - currTime; // gain suspicion for rapid firing
|
|
||||||
else if (currTime - plr->lastShot < plr->fireRate * 180 && plr->suspicionRating > 0)
|
|
||||||
plr->suspicionRating += plr->fireRate * 100 + plr->lastShot - currTime; // lose suspicion for delayed firing
|
|
||||||
|
|
||||||
plr->lastShot = currTime;
|
|
||||||
|
|
||||||
if (pkt->iNPCCnt > 3) // 3+ targets should never be possible
|
|
||||||
plr->suspicionRating += 10000;
|
|
||||||
|
|
||||||
if (plr->suspicionRating > 10000) { // kill the socket when the player is too suspicious
|
|
||||||
sock->kill();
|
|
||||||
CNShardServer::_killConnection(sock);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IMPORTANT: This validates memory safety in addition to preventing
|
* IMPORTANT: This validates memory safety in addition to preventing
|
||||||
* ordinary cheating. If the client sends a very large number of trailing
|
* ordinary cheating. If the client sends a very large number of trailing
|
||||||
@ -581,21 +561,6 @@ static void projectileHit(CNSocket* sock, CNPacketData* data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rapid fire anti-cheat
|
|
||||||
time_t currTime = getTime();
|
|
||||||
if (currTime - plr->lastShot < plr->fireRate * 80)
|
|
||||||
plr->suspicionRating += plr->fireRate * 100 + plr->lastShot - currTime; // gain suspicion for rapid firing
|
|
||||||
else if (currTime - plr->lastShot < plr->fireRate * 180 && plr->suspicionRating > 0)
|
|
||||||
plr->suspicionRating += plr->fireRate * 100 + plr->lastShot - currTime; // lose suspicion for delayed firing
|
|
||||||
|
|
||||||
plr->lastShot = currTime;
|
|
||||||
|
|
||||||
if (plr->suspicionRating > 10000) { // kill the socket when the player is too suspicious
|
|
||||||
sock->kill();
|
|
||||||
CNShardServer::_killConnection(sock);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize response struct
|
* initialize response struct
|
||||||
* rocket style hit doesn't work properly, so we're always sending this one
|
* rocket style hit doesn't work properly, so we're always sending this one
|
||||||
|
@ -78,8 +78,6 @@ struct Player : public Entity, public ICombatant {
|
|||||||
uint64_t iFirstUseFlag[2] = {};
|
uint64_t iFirstUseFlag[2] = {};
|
||||||
time_t lastHeartbeat = 0;
|
time_t lastHeartbeat = 0;
|
||||||
|
|
||||||
int suspicionRating = 0;
|
|
||||||
time_t lastShot = 0;
|
|
||||||
std::vector<sItemBase> buyback = {};
|
std::vector<sItemBase> buyback = {};
|
||||||
|
|
||||||
Player() { kind = EntityKind::PLAYER; }
|
Player() { kind = EntityKind::PLAYER; }
|
||||||
|
Loading…
Reference in New Issue
Block a user