internal void SendLevel(Level level) { if (status != OnlineStatus.Identified) { return; } this.level = level; status = OnlineStatus.Loading; new Thread( delegate() { Protocol.MapBeginPacket().Send(this); byte[] gzipped = Utility.GZipper.GZip( BitConverter.GetBytes( IPAddress.HostToNetworkOrder(level.Mapdata.Length) ), level.Mapdata); for (int i = 0; i < gzipped.Length; i += 1024) { byte progress = (byte)((i / 1024 + 1) / Math.Ceiling(gzipped.Length / 1024d) * 100); Protocol.MapPartPacket(gzipped, i, progress).Send(this); } Protocol.MapEndPacket(level.Width, level.Depth, level.Height).Send(this); ReadyEvent.Raise(server, this); Spawn(level.Spawn); foreach (Body b in level.Bodies) { Protocol.SpawnPacket(b).Send(this); } Position.Set(level.Spawn); Visible = true; status = OnlineStatus.Ready; level.players.Add(this); }).Start(); }