private void PacketHandler_0x10_ClientJoin(Object obj, ClientPacket packet) { var connectionId = (long) obj; var seed = packet.ReadByte(); var keyLength = packet.ReadByte(); var key = packet.Read(keyLength); var name = packet.ReadString8(); var id = packet.ReadUInt32(); var redirect = ExpectedConnections[id]; if (redirect.Matches(name, key, seed)) { ((IDictionary) ExpectedConnections).Remove(id); if (PlayerExists(name)) { var user = new User(this, connectionId, name); user.SetEncryptionParameters(key, seed, name); user.LoadDataFromEntityFramework(true); user.UpdateLoginTime(); user.UpdateAttributes(StatUpdateFlags.Full); Logger.DebugFormat("Elapsed time since login: {0}", user.SinceLastLogin); if (user.Citizenship.spawn_points.Count != 0 && user.SinceLastLogin > Hybrasyl.Constants.NATION_SPAWN_TIMEOUT) { Insert(user); var spawnpoint = user.Citizenship.spawn_points.First(); user.Teleport((ushort) spawnpoint.map_id, (byte) spawnpoint.map_x, (byte) spawnpoint.map_y); } else if (user.MapId != null && Maps.ContainsKey(user.MapId)) { Insert(user); user.Teleport(user.MapId, (byte) user.MapX, (byte) user.MapY); } else { // Handle any weird cases where a map someone exited on was deleted, etc // This "default" of Mileth should be set somewhere else Insert(user); user.Teleport((ushort) 500, (byte) 50, (byte) 50); } Logger.DebugFormat("Adding {0} to hash", user.Name); AddUser(user); ActiveUsers[connectionId] = user; ActiveUsersByName[user.Name] = connectionId; Logger.InfoFormat("cid {0}: {1} entering world", connectionId, user.Name); } } }