public override bool dataEquals(GeoReader reader) { if (getType() != GeoRegion.getType(reader, true)) { return(false); } // GeoCell[] cells1D; for (int cellX = 0, cellY, layer; cellX < GeoEngine.GEO_BLOCK_SHIFT; cellX++) { for (cellY = 0; cellY < GeoEngine.GEO_BLOCK_SHIFT; cellY++) { cells1D = _cells3D[cellX, cellY]; // if (cells1D.Length != reader.get()) { return(false); } // for (layer = cells1D.Length; layer-- > 0;) { if (cells1D[layer].getHeightAndNSWE() != reader.getShort()) { return(false); } } } } return(true); }
public void reloadGeo(int regionX, int regionY, bool l2j, string file) { if (file == null || !File.Exists(file)) { throw new GeoFileNotFoundException(file, l2j); } if (_activeRegion != null) { throw new Exception("Geo must be unloaded first"); } // try { using (FileStream stream = File.Open(file, FileMode.Open, FileAccess.Read)) { GeoReader reader = GeoStreamReader.wrap(stream); // if (!l2j) { for (int i = 18; i-- > 0;) { reader.get(); } } _activeRegion = new GeoRegion(regionX, regionY, reader, l2j, file); } } catch (Exception e) { Console.WriteLine(e); throw new GeoFileLoadException(file, l2j, e); } }
//============================= public GeoBlockMultiLayer(GeoReader reader, int geoX, int geoY, bool l2j) : base(geoX, geoY) { _cells3D = new GeoCell[GeoEngine.GEO_BLOCK_SHIFT, GeoEngine.GEO_BLOCK_SHIFT][]; // int layers, count = 0; for (int x = 0; x < GeoEngine.GEO_BLOCK_SHIFT; x++) { for (int y = 0; y < GeoEngine.GEO_BLOCK_SHIFT; y++) { layers = l2j ? reader.get() : reader.getShort(); if (!GeoEngine.layersValid(layers)) { throw new Exception("Invalid layer count " + layers); } // count += layers; _cells3D[x, y] = new GeoCell[layers]; for (int i = layers; i-- > 0;) { _cells3D[x, y][i] = new GeoCellCM(this, reader.getShort(), x, y); } //Util.quickSort(_cells3D[x,y], HeightComparator.Compare); } } // copyCells(count); calcMaxMinHeight(); }
public static byte getType(GeoReader reader, bool l2j) { if (l2j) { return(reader.get()); } switch (reader.getShort()) { case 0x0000: return(GeoEngine.GEO_BLOCK_TYPE_FLAT); case 0x0040: return(GeoEngine.GEO_BLOCK_TYPE_COMPLEX); default: return(GeoEngine.GEO_BLOCK_TYPE_MULTILAYER); } }