internal static void HandleMapData(DataBuffer buffer) { var id = buffer.ReadInt32(); var temp = buffer.ReadBytes(); using (var fs = new MemoryStream()) { fs.Write(temp, 0, temp.Length); fs.Position = 0; using (var re = new BinaryReader(fs)) { Data.Map.Name = re.ReadString(); Data.Map.Music = re.ReadString(); Data.Map.Revision = re.ReadInt32(); Data.Map.SizeX = re.ReadInt32(); Data.Map.SizeY = re.ReadInt32(); var layers = re.ReadInt32(); Data.Map.Layers.Clear(); for (var l = 0; l < layers; l++) { Data.Map.Layers.Add(new LayerData(Data.Map.SizeX, Data.Map.SizeY)); Data.Map.Layers[l].Name = re.ReadString(); Data.Map.Layers[l].BelowPlayer = re.ReadBoolean(); for (var x = 0; x < Data.Map.SizeX; x++) { for (var y = 0; y < Data.Map.SizeY; y++) { Data.Map.Layers[l].Tiles[x, y].Tileset = re.ReadInt32(); Data.Map.Layers[l].Tiles[x, y].TileX = re.ReadInt32(); Data.Map.Layers[l].Tiles[x, y].TileY = re.ReadInt32(); } } } } } Data.SaveMap(id); Send.MapOK(); }