public override void Disconnect() { if (Connected) { SendData.LogActivity(Character_ID, Activity.LOGIN, SessionID); Username = ""; Version = ""; Email = ""; SessionID = ""; Player player = null; if (World.instance.players.ContainsKey(Character_ID)) { World.instance.players[Character_ID].InWorld = false; player = World.instance.players[Character_ID]; } if (player != null) { for (int i = 0; i < Network.instance.Clients.Length; i++) { if (Network.instance.Clients[i] != null && Network.instance.Clients[i].Connected && Network.instance.Clients[i].InGame()) { SendData.PlayerStateChange(i, player, PlayerState.Logout); } } World.instance.playersInWorld.Remove(player); } Character_ID = -1; LoggedIn = false; LoggedInTime = default(DateTime); Network.instance.RemoveWhiteList(IP.Substring(0, IP.IndexOf(':'))); Log.log("Removed IP " + IP.Substring(0, IP.IndexOf(':')) + " from whitelist.", Log.LogType.SYSTEM); base.Disconnect(); } }
private static void EnterWorld(ConnectionType type, int index, byte[] data) { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); buffer.WriteBytes(data); ReadHeader(ref buffer); Network.instance.Clients[index].Username = buffer.ReadString(); string Character_Name = buffer.ReadString(); Log.log("Account " + Network.instance.Clients[index].Username + " is entering the world with " + Character_Name + "..", Log.LogType.SUCCESS); Player player = World.instance.GetPlayer(Character_Name); player.InWorld = true; Network.instance.Clients[index].Character_ID = player.Character_ID; SendData.CharacterDetails(index, player); Thread.Sleep(100); SendData.LogActivity(Network.instance.Clients[index].Character_ID, Activity.LOGIN, Network.instance.Clients[index].SessionID); }