public async Task ValidateClientHandler(SessionInfoPacket packet, IRakConnection connection) { Logger.Information($"{connection.EndPoint}'s validating client for world!"); if (!Server.SessionCache.IsKey(packet.SessionKey)) { await connection.CloseAsync(); Logger.Warning($"{connection} attempted to connect with an invalid session key"); return; } Server.SessionCache.RegisterKey(connection.EndPoint, packet.SessionKey); var session = Server.SessionCache.GetSession(connection.EndPoint); await using var ctx = new UchuContext(); // Try to find the player, disconnect if the player is invalid var character = await ctx.Characters.FindAsync(session.CharacterId); if (character == null) { Logger.Warning( $"{connection} attempted to connect to world with an invalid character {session.CharacterId}" ); connection.Send(new DisconnectNotifyPacket { DisconnectId = DisconnectId.CharacterNotFound }); return; } // Initialize zone for player var zoneId = (ZoneId)character.LastZone; if (zoneId == ZoneId.VentureExplorerCinematic) { zoneId = ZoneId.VentureExplorer; } var worldServer = (WorldServer)Server; var zone = await worldServer.GetZoneAsync(zoneId); Server.SessionCache.SetZone(connection.EndPoint, zoneId); connection.Send(new WorldInfoPacket { ZoneId = zoneId, Checksum = zone.Checksum, SpawnPosition = zone.ZoneInfo.LuzFile.SpawnPoint }); }