Esempio n. 1
0
 public static void WriteLifeLogs(GameClient client)
 {
     try
     {
         ClientCmdCheck.WriteZhanLiLogs(client);
         List <string> list = null;
         lock (client.ClientData)
         {
             if (client.ClientData.AddLifeAlertList.Count == 0)
             {
                 return;
             }
             list = new List <string>();
             while (client.ClientData.AddLifeAlertList.Count > 0)
             {
                 list.Add(client.ClientData.AddLifeAlertList.Dequeue());
             }
         }
         foreach (string str in list)
         {
             LogManager.WriteLog(LogTypes.Trace, string.Format("#AlertLog#AddLifeAlert#rid={0},rname={1},userid={2},{3}", new object[]
             {
                 client.ClientData.RoleID,
                 client.ClientData.RoleName,
                 client.strUserID,
                 str
             }), null, true);
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteException(ex.ToString());
     }
 }
Esempio n. 2
0
 public static void MoveSpeedChange(GameClient client, double newMoveSpeed)
 {
     if (Data.CheckPositionCheatSpeed)
     {
         long          startMoveTicks = ClientCmdCheck.GetClientTicks(client, 0L);
         ClientExtData clientExtData  = client.ClientData.ClientExtData;
         lock (clientExtData)
         {
             if (client.ClientData.MapCode == clientExtData.MapCode)
             {
                 if (!clientExtData.RunStoryboard)
                 {
                     if (clientExtData.EndMoveTicks > clientExtData.StartMoveTicks)
                     {
                         long   elapseTicks = startMoveTicks - clientExtData.StartMoveTicks;
                         double factor      = (double)elapseTicks / (double)(clientExtData.EndMoveTicks - clientExtData.StartMoveTicks);
                         if (factor < ClientCmdCheck.MinDistanceFactor)
                         {
                             int dx = (int)((double)(clientExtData.ToX - clientExtData.FromX) * (1.0 - factor));
                             int dy = (int)((double)(clientExtData.ToY - clientExtData.FromY) * (1.0 - factor));
                             if (Math.Abs(dx) + Math.Abs(dy) > 50)
                             {
                                 clientExtData.FromX = (client.ClientData.PosX = clientExtData.ToX - dx);
                                 clientExtData.FromY = (client.ClientData.PosY = clientExtData.ToY - dy);
                                 dx = clientExtData.ToX - clientExtData.FromX;
                                 dy = clientExtData.ToY - clientExtData.FromY;
                                 clientExtData.MaxDistance2   = dx * dx + dy * dy;
                                 clientExtData.StartMoveTicks = startMoveTicks;
                                 clientExtData.ReservedTicks  = 0L;
                                 if (newMoveSpeed >= 0.05)
                                 {
                                     clientExtData.MoveSpeed    = newMoveSpeed;
                                     clientExtData.EndMoveTicks = startMoveTicks + (long)(Math.Pow((double)clientExtData.MaxDistance2, 0.5) / (ClientCmdCheck.MoveSpeedPerMS * clientExtData.MoveSpeed));
                                 }
                                 else
                                 {
                                     clientExtData.StartMoveTicks = startMoveTicks;
                                     clientExtData.FromX          = client.ClientData.PosX;
                                     clientExtData.FromY          = client.ClientData.PosY;
                                 }
                             }
                             else
                             {
                                 clientExtData.StartMoveTicks = startMoveTicks;
                                 clientExtData.ToX            = client.ClientData.PosX;
                                 clientExtData.ToY            = client.ClientData.PosY;
                             }
                         }
                         else
                         {
                             clientExtData.StartMoveTicks = startMoveTicks;
                             clientExtData.ToX            = client.ClientData.PosX;
                             clientExtData.ToY            = client.ClientData.PosY;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
        public static bool ClientPosition(GameClient client, int x, int y, long startMoveTicks = 0L)
        {
            bool result;

            if (!Data.CheckPositionCheat)
            {
                result = true;
            }
            else
            {
                bool          resetPos      = false;
                ClientExtData clientExtData = client.ClientData.ClientExtData;
                lock (clientExtData)
                {
                    if (client.ClientData.MapCode != clientExtData.MapCode)
                    {
                        return(false);
                    }
                    int dx = x - clientExtData.ToX;
                    int dy = y - clientExtData.ToY;
                    if (dx != 0 || dy != 0)
                    {
                        if (!clientExtData.RunStoryboard)
                        {
                            if (clientExtData.StartMoveTicks < clientExtData.EndMoveTicks)
                            {
                                if (startMoveTicks >= clientExtData.EndMoveTicks)
                                {
                                    clientExtData.StartMoveTicks = startMoveTicks;
                                    client.ClientData.PosX       = clientExtData.ToX;
                                    client.ClientData.PosY       = clientExtData.ToY;
                                }
                            }
                            else if (Math.Abs(dx) + Math.Abs(dy) >= 500)
                            {
                                LogManager.WriteLog(LogTypes.Check, string.Format("ClientPosition位置不匹配#rid={0}", client.ClientData.RoleID), null, true);
                                client.ClientData.PosX = clientExtData.ToX;
                                client.ClientData.PosY = clientExtData.ToY;
                                resetPos = true;
                                clientExtData.StartMoveTicks = startMoveTicks;
                            }
                        }
                    }
                }
                if (resetPos)
                {
                    ClientCmdCheck.ResetClientPosition(client, client.ClientData.PosX, client.ClientData.PosY);
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
Esempio n. 4
0
 public static void ClientStopMove(GameClient client, int x, int y, long startMoveTicks = 0L)
 {
     if (Data.CheckPositionCheat)
     {
         startMoveTicks = ClientCmdCheck.GetClientTicks(client, startMoveTicks);
         bool resetPos = ClientCmdCheck.MoveTo(client, x, y, startMoveTicks, true);
         if (resetPos)
         {
             ClientCmdCheck.ResetClientPosition(client, client.ClientData.PosX, client.ClientData.PosY);
         }
     }
 }
Esempio n. 5
0
        public static void ClientAction(GameClient client, long nowTicks, long reserveTicks)
        {
            ClientExtData clientExtData = client.ClientData.ClientExtData;

            lock (clientExtData)
            {
                if (client.ClientData.MapCode == clientExtData.MapCode)
                {
                    clientExtData.CanMoveTicks = ClientCmdCheck.GetClientTicks(client, 0L) + reserveTicks;
                }
            }
        }
Esempio n. 6
0
        public static bool SpriteMoveCmd(GameClient client, int fromX, int fromY, int toX, int toY, long startMoveTicks, double moveSpeed, List <Point> path, out bool stepMove)
        {
            stepMove = false;
            bool result;

            if (!Data.CheckPositionCheat)
            {
                ClientCmdCheck.SpritePreMove(client, fromX, fromY, toX, toY, startMoveTicks);
                result = true;
            }
            else
            {
                ClientExtData clientExtData = client.ClientData.ClientExtData;
                bool          resetPos;
                lock (clientExtData)
                {
                    if (client.ClientData.MapCode != clientExtData.MapCode)
                    {
                        return(false);
                    }
                    resetPos = ClientCmdCheck.MoveTo(client, fromX, fromY, startMoveTicks, false);
                    if (!resetPos)
                    {
                        ClientCmdCheck.SpritePreMove(client, fromX, fromY, toX, toY, startMoveTicks);
                        clientExtData.RunStoryboard = false;
                        if (moveSpeed < 0.05)
                        {
                            return(false);
                        }
                        if (path.Count < 2)
                        {
                            LogManager.WriteLog(LogTypes.Check, string.Format("SpriteMoveCmd路径点不足两个#rid={0}", client.ClientData.RoleID), null, true);
                            return(false);
                        }
                        if (path.Count == 2)
                        {
                            if (Math.Abs(path[0].X - path[1].X) > 1.0 || Math.Abs(path[0].Y - path[1].Y) > 1.0)
                            {
                                LogManager.WriteLog(LogTypes.Check, string.Format("SpriteMoveCmd,2点路径非法#rid={0}", client.ClientData.RoleID), null, true);
                                return(false);
                            }
                            toX = (int)path[1].X * 100 + 50;
                            toY = (int)path[1].Y * 100 + 50;
                        }
                        else if (path.Count == 3)
                        {
                            if (path[0].X == path[1].X && path[0].Y == path[1].Y)
                            {
                                if (Math.Abs(path[0].X - path[2].X) + Math.Abs(path[0].Y - path[2].Y) > 2.0)
                                {
                                    clientExtData.RunStoryboard = true;
                                }
                            }
                            else
                            {
                                if (path[0].X + path[2].X != path[1].X + path[1].X || path[0].Y + path[2].Y != path[1].Y + path[1].Y)
                                {
                                    LogManager.WriteLog(LogTypes.Check, string.Format("SpriteMoveCmd,3点路径非法#rid={0}", client.ClientData.RoleID), null, true);
                                    return(false);
                                }
                                if (Math.Abs(path[0].X - path[2].X) > 2.0 || Math.Abs(path[0].Y - path[2].Y) > 2.0)
                                {
                                    LogManager.WriteLog(LogTypes.Check, string.Format("SpriteMoveCmd,3点距离非法#rid={0}", client.ClientData.RoleID), null, true);
                                    return(false);
                                }
                            }
                            toX = (int)path[2].X * 100 + 50;
                            toY = (int)path[2].Y * 100 + 50;
                        }
                        else
                        {
                            clientExtData.RunStoryboard = true;
                        }
                        clientExtData.FromX          = fromX;
                        clientExtData.FromY          = fromY;
                        clientExtData.ToX            = toX;
                        clientExtData.ToY            = toY;
                        clientExtData.StartMoveTicks = startMoveTicks;
                        clientExtData.MaxDistance2   = (toX - fromX) * (toX - fromX) + (toY - fromY) * (toY - fromY);
                        clientExtData.MoveSpeed      = moveSpeed;
                        clientExtData.EndMoveTicks   = startMoveTicks + (long)(Math.Pow((double)clientExtData.MaxDistance2, 0.5) / (ClientCmdCheck.MoveSpeedPerMS * clientExtData.MoveSpeed));
                        stepMove = !clientExtData.RunStoryboard;
                    }
                }
                if (resetPos)
                {
                    ClientCmdCheck.ResetClientPosition(client, clientExtData.FromX, clientExtData.FromY);
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }