Beispiel #1
0
    public static bool IsSpeeding(BasePlayer ply, TickInterpolator ticks, float deltaTime)
    {
        ply.speedhackPauseTime = Mathf.Max(0.0f, ply.speedhackPauseTime - deltaTime);
        if ((double)ply.speedhackPauseTime > 0.0 || ConVar.AntiHack.speedhack_protection <= 0)
        {
            return(false);
        }
        int       num1      = Object.op_Equality((Object)((Component)ply).get_transform().get_parent(), (Object)null) ? 1 : 0;
        Matrix4x4 matrix4x4 = num1 != 0 ? Matrix4x4.get_identity() : ((Component)ply).get_transform().get_parent().get_localToWorldMatrix();
        Vector3   worldPos  = num1 != 0 ? ticks.StartPoint : ((Matrix4x4) ref matrix4x4).MultiplyPoint3x4(ticks.StartPoint);
        Vector3   vector3   = Vector3.op_Subtraction(num1 != 0 ? ticks.EndPoint : ((Matrix4x4) ref matrix4x4).MultiplyPoint3x4(ticks.EndPoint), worldPos);
        float     num2      = Vector3Ex.Magnitude2D(vector3);

        if ((double)num2 > 0.0)
        {
            float num3 = Mathf.Max(0.0f, Vector3.Dot(Vector3Ex.XZ3D(Object.op_Implicit((Object)TerrainMeta.HeightMap) ? TerrainMeta.HeightMap.GetNormal(worldPos) : Vector3.get_up()), Vector3Ex.XZ3D(vector3))) * ConVar.AntiHack.speedhack_slopespeed * deltaTime;
            num2 = Mathf.Max(0.0f, num2 - num3);
        }
        float running = 1f;
        float ducking = 0.0f;

        if (ConVar.AntiHack.speedhack_protection >= 2)
        {
            running = ply.IsRunning() ? 1f : 0.0f;
            ducking = ply.IsDucked() || ply.IsSwimming() ? 1f : 0.0f;
        }
        float num4 = Mathf.Max(ConVar.AntiHack.speedhack_forgiveness, 0.1f);
        float num5 = 2f * num4;

        ply.speedhackDistance = Mathf.Clamp((float)((double)ply.speedhackDistance + (double)num2 - (double)deltaTime * (double)ply.GetSpeed(running, ducking)), -num5, num5);
        return((double)ply.speedhackDistance > (double)num4);
    }
Beispiel #2
0
 public static bool IsSpeeding(BasePlayer ply, TickInterpolator ticks, float deltaTime)
 {
     using (TimeWarning.New("AntiHack.IsSpeeding"))
     {
         ply.speedhackPauseTime = Mathf.Max(0f, ply.speedhackPauseTime - deltaTime);
         if (ConVar.AntiHack.speedhack_protection <= 0)
         {
             return(false);
         }
         bool      num      = ply.transform.parent == null;
         Matrix4x4 matrix4x = (num ? Matrix4x4.identity : ply.transform.parent.localToWorldMatrix);
         Vector3   vector   = (num ? ticks.StartPoint : matrix4x.MultiplyPoint3x4(ticks.StartPoint));
         Vector3   obj      = (num ? ticks.EndPoint : matrix4x.MultiplyPoint3x4(ticks.EndPoint));
         float     running  = 1f;
         float     ducking  = 0f;
         float     crawling = 0f;
         if (ConVar.AntiHack.speedhack_protection >= 2)
         {
             bool flag  = ply.IsRunning();
             bool flag2 = ply.IsDucked();
             bool flag3 = ply.IsSwimming();
             bool num2  = ply.IsCrawling();
             running  = (flag ? 1f : 0f);
             ducking  = ((flag2 || flag3) ? 1f : 0f);
             crawling = (num2 ? 1f : 0f);
         }
         float   speed = ply.GetSpeed(running, ducking, crawling);
         Vector3 v     = obj - vector;
         float   num3  = v.Magnitude2D();
         float   num4  = deltaTime * speed;
         if (num3 > num4)
         {
             Vector3 v2   = (TerrainMeta.HeightMap ? TerrainMeta.HeightMap.GetNormal(vector) : Vector3.up);
             float   num5 = Mathf.Max(0f, Vector3.Dot(v2.XZ3D(), v.XZ3D())) * ConVar.AntiHack.speedhack_slopespeed * deltaTime;
             num3 = Mathf.Max(0f, num3 - num5);
         }
         float num6 = Mathf.Max((ply.speedhackPauseTime > 0f) ? ConVar.AntiHack.speedhack_forgiveness_inertia : ConVar.AntiHack.speedhack_forgiveness, 0.1f);
         float num7 = num6 + Mathf.Max(ConVar.AntiHack.speedhack_forgiveness, 0.1f);
         ply.speedhackDistance = Mathf.Clamp(ply.speedhackDistance, 0f - num7, num7);
         ply.speedhackDistance = Mathf.Clamp(ply.speedhackDistance - num4, 0f - num7, num7);
         if (ply.speedhackDistance > num6)
         {
             return(true);
         }
         ply.speedhackDistance = Mathf.Clamp(ply.speedhackDistance + num3, 0f - num7, num7);
         if (ply.speedhackDistance > num6)
         {
             return(true);
         }
         return(false);
     }
 }
    public static bool IsFlying(BasePlayer ply, TickInterpolator ticks, float deltaTime)
    {
        ply.flyhackPauseTime = Mathf.Max(0f, ply.flyhackPauseTime - deltaTime);
        if (ply.flyhackPauseTime > 0f)
        {
            return(false);
        }
        if (ConVar.AntiHack.flyhack_protection <= 0)
        {
            return(false);
        }
        ticks.Reset();
        if (!ticks.HasNext())
        {
            return(false);
        }
        bool      flag      = ply.transform.parent == null;
        Matrix4x4 matrix4x4 = (flag ? Matrix4x4.identity : ply.transform.parent.localToWorldMatrix);
        Vector3   vector3   = (flag ? ticks.StartPoint : matrix4x4.MultiplyPoint3x4(ticks.StartPoint));
        Vector3   vector31  = (flag ? ticks.EndPoint : matrix4x4.MultiplyPoint3x4(ticks.EndPoint));

        if (ConVar.AntiHack.flyhack_protection >= 3)
        {
            float single = Mathf.Max(ConVar.AntiHack.flyhack_stepsize, 0.1f);
            int   num    = Mathf.Max(ConVar.AntiHack.flyhack_maxsteps, 1);
            single = Mathf.Max(ticks.Length / (float)num, single);
            while (ticks.MoveNext(single))
            {
                vector31 = (flag ? ticks.CurrentPoint : matrix4x4.MultiplyPoint3x4(ticks.CurrentPoint));
                if (AntiHack.TestFlying(ply, vector3, vector31, true))
                {
                    return(true);
                }
                vector3 = vector31;
            }
        }
        else if (ConVar.AntiHack.flyhack_protection >= 2)
        {
            if (AntiHack.TestFlying(ply, vector3, vector31, true))
            {
                return(true);
            }
        }
        else if (AntiHack.TestFlying(ply, vector3, vector31, false))
        {
            return(true);
        }
        return(false);
    }
Beispiel #4
0
 public static bool ValidateMove(BasePlayer ply, TickInterpolator ticks, float deltaTime)
 {
     using (TimeWarning.New("AntiHack.ValidateMove"))
     {
         if (ShouldIgnore(ply))
         {
             return(true);
         }
         bool flag = deltaTime > ConVar.AntiHack.maxdeltatime;
         if (IsNoClipping(ply, ticks, deltaTime))
         {
             if (flag)
             {
                 return(false);
             }
             AddViolation(ply, AntiHackType.NoClip, ConVar.AntiHack.noclip_penalty * ticks.Length);
             if (ConVar.AntiHack.noclip_reject)
             {
                 return(false);
             }
         }
         if (IsSpeeding(ply, ticks, deltaTime))
         {
             if (flag)
             {
                 return(false);
             }
             AddViolation(ply, AntiHackType.SpeedHack, ConVar.AntiHack.speedhack_penalty * ticks.Length);
             if (ConVar.AntiHack.speedhack_reject)
             {
                 return(false);
             }
         }
         if (IsFlying(ply, ticks, deltaTime))
         {
             if (flag)
             {
                 return(false);
             }
             AddViolation(ply, AntiHackType.FlyHack, ConVar.AntiHack.flyhack_penalty * ticks.Length);
             if (ConVar.AntiHack.flyhack_reject)
             {
                 return(false);
             }
         }
         return(true);
     }
 }
Beispiel #5
0
 public static bool IsFlying(BasePlayer ply, TickInterpolator ticks, float deltaTime)
 {
     using (TimeWarning.New("AntiHack.IsFlying"))
     {
         ply.flyhackPauseTime = Mathf.Max(0f, ply.flyhackPauseTime - deltaTime);
         if (ConVar.AntiHack.flyhack_protection <= 0)
         {
             return(false);
         }
         ticks.Reset();
         if (!ticks.HasNext())
         {
             return(false);
         }
         bool      flag     = ply.transform.parent == null;
         Matrix4x4 matrix4x = (flag ? Matrix4x4.identity : ply.transform.parent.localToWorldMatrix);
         Vector3   oldPos   = (flag ? ticks.StartPoint : matrix4x.MultiplyPoint3x4(ticks.StartPoint));
         Vector3   newPos   = (flag ? ticks.EndPoint : matrix4x.MultiplyPoint3x4(ticks.EndPoint));
         if (ConVar.AntiHack.flyhack_protection >= 3)
         {
             float b   = Mathf.Max(ConVar.AntiHack.flyhack_stepsize, 0.1f);
             int   num = Mathf.Max(ConVar.AntiHack.flyhack_maxsteps, 1);
             b = Mathf.Max(ticks.Length / (float)num, b);
             while (ticks.MoveNext(b))
             {
                 newPos = (flag ? ticks.CurrentPoint : matrix4x.MultiplyPoint3x4(ticks.CurrentPoint));
                 if (TestFlying(ply, oldPos, newPos, true))
                 {
                     return(true);
                 }
                 oldPos = newPos;
             }
         }
         else if (ConVar.AntiHack.flyhack_protection >= 2)
         {
             if (TestFlying(ply, oldPos, newPos, true))
             {
                 return(true);
             }
         }
         else if (TestFlying(ply, oldPos, newPos, false))
         {
             return(true);
         }
         return(false);
     }
 }
Beispiel #6
0
    public static bool IsFlying(BasePlayer ply, TickInterpolator ticks, float deltaTime)
    {
        ply.flyhackPauseTime = Mathf.Max(0.0f, ply.flyhackPauseTime - deltaTime);
        if ((double)ply.flyhackPauseTime > 0.0 || ConVar.AntiHack.flyhack_protection <= 0)
        {
            return(false);
        }
        ticks.Reset();
        if (!ticks.HasNext())
        {
            return(false);
        }
        bool      flag      = Object.op_Equality((Object)((Component)ply).get_transform().get_parent(), (Object)null);
        Matrix4x4 matrix4x4 = flag ? Matrix4x4.get_identity() : ((Component)ply).get_transform().get_parent().get_localToWorldMatrix();
        Vector3   oldPos    = flag ? ticks.StartPoint : ((Matrix4x4) ref matrix4x4).MultiplyPoint3x4(ticks.StartPoint);
        Vector3   newPos1   = flag ? ticks.EndPoint : ((Matrix4x4) ref matrix4x4).MultiplyPoint3x4(ticks.EndPoint);

        if (ConVar.AntiHack.flyhack_protection >= 3)
        {
            float num1     = Mathf.Max(ConVar.AntiHack.flyhack_stepsize, 0.1f);
            int   num2     = Mathf.Max(ConVar.AntiHack.flyhack_maxsteps, 1);
            float distance = Mathf.Max(ticks.Length / (float)num2, num1);
            while (ticks.MoveNext(distance))
            {
                Vector3 newPos2 = flag ? ticks.CurrentPoint : ((Matrix4x4) ref matrix4x4).MultiplyPoint3x4(ticks.CurrentPoint);
                if (AntiHack.TestFlying(ply, oldPos, newPos2, true))
                {
                    return(true);
                }
                oldPos = newPos2;
            }
        }
        else if (ConVar.AntiHack.flyhack_protection >= 2)
        {
            if (AntiHack.TestFlying(ply, oldPos, newPos1, true))
            {
                return(true);
            }
        }
        else if (AntiHack.TestFlying(ply, oldPos, newPos1, false))
        {
            return(true);
        }
        return(false);
    }
    public static bool IsSpeeding(BasePlayer ply, TickInterpolator ticks, float deltaTime)
    {
        ply.speedhackPauseTime = Mathf.Max(0f, ply.speedhackPauseTime - deltaTime);
        if (ply.speedhackPauseTime > 0f)
        {
            return(false);
        }
        if (ConVar.AntiHack.speedhack_protection <= 0)
        {
            return(false);
        }
        bool      flag      = ply.transform.parent == null;
        Matrix4x4 matrix4x4 = (flag ? Matrix4x4.identity : ply.transform.parent.localToWorldMatrix);
        Vector3   vector3   = (flag ? ticks.StartPoint : matrix4x4.MultiplyPoint3x4(ticks.StartPoint));
        Vector3   vector31  = (flag ? ticks.EndPoint : matrix4x4.MultiplyPoint3x4(ticks.EndPoint)) - vector3;
        float     single    = vector31.Magnitude2D();

        if (single > 0f)
        {
            Vector3 vector32 = (TerrainMeta.HeightMap ? TerrainMeta.HeightMap.GetNormal(vector3) : Vector3.up);
            float   single1  = Mathf.Max(0f, Vector3.Dot(vector32.XZ3D(), vector31.XZ3D())) * ConVar.AntiHack.speedhack_slopespeed * deltaTime;
            single = Mathf.Max(0f, single - single1);
        }
        float single2 = 1f;
        float single3 = 0f;

        if (ConVar.AntiHack.speedhack_protection >= 2)
        {
            single2 = (ply.IsRunning() ? 1f : 0f);
            single3 = (ply.IsDucked() || ply.IsSwimming() ? 1f : 0f);
        }
        float single4 = Mathf.Max(ConVar.AntiHack.speedhack_forgiveness, 0.1f);
        float single5 = 2f * single4;

        ply.speedhackDistance = Mathf.Clamp(ply.speedhackDistance + single - deltaTime * ply.GetSpeed(single2, single3), -single5, single5);
        if (ply.speedhackDistance > single4)
        {
            return(true);
        }
        return(false);
    }
    public static bool ValidateMove(BasePlayer ply, TickInterpolator ticks, float deltaTime)
    {
        bool flag;

        using (TimeWarning timeWarning = TimeWarning.New("AntiHack.ValidateMove", 0.1f))
        {
            if (ply.IsFlying)
            {
                ply.lastAdminCheatTime = UnityEngine.Time.realtimeSinceStartup;
            }
            if (ply.IsAdmin)
            {
                if (ConVar.AntiHack.userlevel < 1)
                {
                    flag = true;
                    return(flag);
                }
                else if (ConVar.AntiHack.admincheat && ply.UsedAdminCheat(1f))
                {
                    flag = true;
                    return(flag);
                }
            }
            if (ply.IsDeveloper)
            {
                if (ConVar.AntiHack.userlevel < 2)
                {
                    flag = true;
                    return(flag);
                }
                else if (ConVar.AntiHack.admincheat && ply.UsedAdminCheat(1f))
                {
                    flag = true;
                    return(flag);
                }
            }
            if (ply.IsSleeping())
            {
                flag = true;
            }
            else if (ply.IsWounded())
            {
                flag = true;
            }
            else if (ply.IsSpectating())
            {
                flag = true;
            }
            else if (!ply.IsDead())
            {
                bool flag1 = deltaTime > ConVar.AntiHack.maxdeltatime;
                using (TimeWarning timeWarning1 = TimeWarning.New("IsNoClipping", 0.1f))
                {
                    if (AntiHack.IsNoClipping(ply, ticks, deltaTime))
                    {
                        if (!flag1)
                        {
                            AntiHack.AddViolation(ply, AntiHackType.NoClip, ConVar.AntiHack.noclip_penalty * ticks.Length);
                            if (ConVar.AntiHack.noclip_reject)
                            {
                                flag = false;
                                return(flag);
                            }
                        }
                        else
                        {
                            flag = false;
                            return(flag);
                        }
                    }
                }
                using (timeWarning1 = TimeWarning.New("IsSpeeding", 0.1f))
                {
                    if (AntiHack.IsSpeeding(ply, ticks, deltaTime))
                    {
                        if (!flag1)
                        {
                            AntiHack.AddViolation(ply, AntiHackType.SpeedHack, ConVar.AntiHack.speedhack_penalty * ticks.Length);
                            if (ConVar.AntiHack.speedhack_reject)
                            {
                                flag = false;
                                return(flag);
                            }
                        }
                        else
                        {
                            flag = false;
                            return(flag);
                        }
                    }
                }
                using (timeWarning1 = TimeWarning.New("IsFlying", 0.1f))
                {
                    if (AntiHack.IsFlying(ply, ticks, deltaTime))
                    {
                        if (!flag1)
                        {
                            AntiHack.AddViolation(ply, AntiHackType.FlyHack, ConVar.AntiHack.flyhack_penalty * ticks.Length);
                            if (ConVar.AntiHack.flyhack_reject)
                            {
                                flag = false;
                                return(flag);
                            }
                        }
                        else
                        {
                            flag = false;
                            return(flag);
                        }
                    }
                }
                flag = true;
            }
            else
            {
                flag = true;
            }
        }
        return(flag);
    }
Beispiel #9
0
 public static bool ValidateMove(BasePlayer ply, TickInterpolator ticks, float deltaTime)
 {
     using (TimeWarning.New("AntiHack.ValidateMove", 0.1f))
     {
         if (ply.IsFlying)
         {
             ply.lastAdminCheatTime = Time.get_realtimeSinceStartup();
         }
         if (ply.IsAdmin && (ConVar.AntiHack.userlevel < 1 || ConVar.AntiHack.admincheat && ply.UsedAdminCheat(1f)) || ply.IsDeveloper && (ConVar.AntiHack.userlevel < 2 || ConVar.AntiHack.admincheat && ply.UsedAdminCheat(1f)) || (ply.IsSleeping() || ply.IsWounded() || (ply.IsSpectating() || ply.IsDead())))
         {
             return(true);
         }
         bool flag = (double)deltaTime > (double)ConVar.AntiHack.maxdeltatime;
         using (TimeWarning.New("IsNoClipping", 0.1f))
         {
             if (AntiHack.IsNoClipping(ply, ticks, deltaTime))
             {
                 if (flag)
                 {
                     return(false);
                 }
                 AntiHack.AddViolation(ply, AntiHackType.NoClip, ConVar.AntiHack.noclip_penalty * ticks.Length);
                 if (ConVar.AntiHack.noclip_reject)
                 {
                     return(false);
                 }
             }
         }
         using (TimeWarning.New("IsSpeeding", 0.1f))
         {
             if (AntiHack.IsSpeeding(ply, ticks, deltaTime))
             {
                 if (flag)
                 {
                     return(false);
                 }
                 AntiHack.AddViolation(ply, AntiHackType.SpeedHack, ConVar.AntiHack.speedhack_penalty * ticks.Length);
                 if (ConVar.AntiHack.speedhack_reject)
                 {
                     return(false);
                 }
             }
         }
         using (TimeWarning.New("IsFlying", 0.1f))
         {
             if (AntiHack.IsFlying(ply, ticks, deltaTime))
             {
                 if (flag)
                 {
                     return(false);
                 }
                 AntiHack.AddViolation(ply, AntiHackType.FlyHack, ConVar.AntiHack.flyhack_penalty * ticks.Length);
                 if (ConVar.AntiHack.flyhack_reject)
                 {
                     return(false);
                 }
             }
         }
         return(true);
     }
 }