예제 #1
0
        internal bool InvokeNetNameCollision(int who, string name)
        {
            NameCollisionEventArgs args = new NameCollisionEventArgs
            {
                Who  = who,
                Name = name
            };

            this.NetNameCollision.Invoke(args);
            return(args.Handled);
        }
예제 #2
0
		internal bool InvokeNetNameCollision(int who, string name)
		{
			NameCollisionEventArgs args = new NameCollisionEventArgs
			{
				Who = who,
				Name = name
			};

			this.NetNameCollision.Invoke(args);
			return args.Handled;
		}
예제 #3
0
파일: TShock.cs 프로젝트: B-BOB/TShock
        /// <summary>NetHooks_NameCollision - Internal hook fired when a name collision happens.</summary>
        /// <param name="args">args - The NameCollisionEventArgs object.</param>
        private void NetHooks_NameCollision(NameCollisionEventArgs args)
        {
            string ip = Utils.GetRealIP(Netplay.Clients[args.Who].Socket.GetRemoteAddress().ToString());

            var player = Players.First(p => p != null && p.Name == args.Name && p.Index != args.Who);
            if (player != null)
            {
                if (player.IP == ip)
                {
                    Netplay.Clients[player.Index].PendingTermination = true;
                    args.Handled = true;
                    return;
                }
                if (player.IsLoggedIn)
                {
                    var ips = JsonConvert.DeserializeObject<List<string>>(player.User.KnownIps);
                    if (ips.Contains(ip))
                    {
                        Netplay.Clients[player.Index].PendingTermination = true;
                        args.Handled = true;
                    }
                }
            }
        }
예제 #4
0
        private void NetHooks_NameCollision(NameCollisionEventArgs args)
        {
            string ip = TShock.Utils.GetRealIP(Netplay.serverSock[args.Who].tcpClient.Client.RemoteEndPoint.ToString());

            var player = TShock.Players.First(p => p != null && p.Name == args.Name && p.Index != args.Who);
            if (player != null)
            {
                if (player.IP == ip)
                {
                    Netplay.serverSock[player.Index].kill = true;
                    args.Handled = true;
                    return;
                }
                else if (player.IsLoggedIn)
                {
                    User user = TShock.Users.GetUserByName(player.UserAccountName);
                    var ips = JsonConvert.DeserializeObject<List<string>>(user.KnownIps);
                    if (ips.Contains(ip))
                    {
                        Netplay.serverSock[player.Index].kill = true;
                        args.Handled = true;
                        return;
                    }
                }
            }
        }
예제 #5
0
파일: TShock.cs 프로젝트: CoderCow/TShock
 private void NetHooks_NameCollision(NameCollisionEventArgs args)
 {
     string ip = TShock.Utils.GetRealIP(Netplay.serverSock[args.Who].tcpClient.Client.RemoteEndPoint.ToString());
     foreach (TSPlayer ply in TShock.Players)
     {
         if (ply == null)
         {
             continue;
         }
         if (ply.Name == args.Name && ply.Index != args.Who)
         {
             if (ply.IP == ip)
             {
                 if (ply.State < 2)
                 {
                     Utils.ForceKick(ply, "Name collision and this client has no world data.", true, false);
                     args.Handled = true;
                     return;
                 }
                 else
                 {
                     args.Handled = false;
                     return;
                 }
             }
         }
     }
     args.Handled = false;
     return;
 }
예제 #6
0
 /// <summary>
 /// NetNameCollision callback.
 /// </summary>
 /// <param name="args"></param>
 private void OnNetNameCollision(NameCollisionEventArgs args)
 {
     lock (this.m_AddonsLock)
     {
         this.m_Addons.ForEach(a =>
             {
                 var ret = a.Value.InvokeEvent("NetNameCollision", args);
                 if (ret != null && ret.Length >= 1)
                 {
                     bool result;
                     if (bool.TryParse(ret[0].ToString(), out result) && result)
                         args.Handled = true;
                 }
             });
     }
 }