private void _setupMap() { if (_map == null) { bool hasWater = _rsw != null; int waterHeight = _rsw != null ? (int)BitConverter.ToSingle(_rsw, 166) : -1; _map = new MapInfo(_name); _map.Xs = BitConverter.ToUInt16(_gat, 6); _map.Ys = BitConverter.ToUInt16(_gat, 10); _map.Data = new byte[_map.Xs * _map.Ys]; int offset = 14; for (int i = 0; i < _map.Len; i++) { float height = BitConverter.ToSingle(_gat, offset); int cellType = BitConverter.ToInt32(_gat, offset + 16); offset += 20; if (hasWater && cellType == 0 && height > waterHeight) { cellType = 3; } _map.Data[i] = (byte)cellType; } _map.Data = Compression.CompressZlib(_map.Data); _map.Added = true; _gat = null; _rsw = null; } }