prevent "laggy" angles from being tracked

This commit is contained in:
RaidMax 2019-09-10 17:50:23 -05:00
parent 483b7917ac
commit 082776aca5
2 changed files with 17 additions and 2 deletions

View File

@ -106,7 +106,12 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
lastHit = hit; lastHit = hit;
} }
if (lastHit == hit || lastHit.VictimId != hit.VictimId || (hit.TimeOffset - lastHit.TimeOffset) >= 1000) bool areAnglesInvalid = hit.AnglesList[0].Equals(hit.AnglesList[1]) && hit.AnglesList[3].Equals(hit.AnglesList[4]);
if ((lastHit == hit ||
lastHit.VictimId != hit.VictimId ||
(hit.TimeOffset - lastHit.TimeOffset) >= 1000) &&
!areAnglesInvalid)
{ {
ClientStats.SnapHitCount++; ClientStats.SnapHitCount++;
sessionSnapHits++; sessionSnapHits++;

View File

@ -34,6 +34,16 @@ namespace SharedLibraryCore.Helpers
return $"({X}, {Y}, {Z})"; return $"({X}, {Y}, {Z})";
} }
public override bool Equals(object obj)
{
if (obj is Vector3 vec)
{
return vec.X == X && vec.Y == Y && vec.Z == Z;
}
return false;
}
public static Vector3 Parse(string s) public static Vector3 Parse(string s)
{ {
bool valid = Regex.Match(s, @"\((-?[0-9]+\.?[0-9]*|-?[0-9]+\.?[0-9]*e-[0-9]+),\ (-?[0-9]+\.?[0-9]*|-?[0-9]+\.?[0-9]*e-[0-9]+),\ (-?[0-9]+\.?[0-9]*|-?[0-9]+\.?[0-9]*e-[0-9]+)\)").Success; bool valid = Regex.Match(s, @"\((-?[0-9]+\.?[0-9]*|-?[0-9]+\.?[0-9]*e-[0-9]+),\ (-?[0-9]+\.?[0-9]*|-?[0-9]+\.?[0-9]*e-[0-9]+),\ (-?[0-9]+\.?[0-9]*|-?[0-9]+\.?[0-9]*e-[0-9]+)\)").Success;