private static unsafe int PatchLand(TileMatrix matrix, string dataPath, string indexPath) { using (FileStream fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read)) using (FileStream fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryReader indexReader = new BinaryReader(fsIndex); int count = (int)(indexReader.BaseStream.Length / 4); for (int i = 0; i < count; ++i) { int blockID = indexReader.ReadInt32(); int x = blockID / matrix.BlockHeight; int y = blockID % matrix.BlockHeight; fsData.Seek(4, SeekOrigin.Current); Tile[] tiles = new Tile[64]; fixed (Tile* pTiles = tiles) { NativeMethods._lread(fsData.SafeFileHandle, pTiles, 192); } //matrix.SetLandBlock(x, y, tiles); } return count; } }
public Tile[] GetLandBlock(int x, int y) { if (x < 0 || y < 0 || x >= _blockWidth || y >= _blockHeight || _map == null) return _invalidLandBlock; if (_landTiles[x] == null) _landTiles[x] = new Tile[_blockHeight][]; Tile[] tiles = _landTiles[x][y] ?? (_landTiles[x][y] = ReadLandBlock(x, y)); return tiles; }
private unsafe Tile[] ReadLandBlock(int x, int y) { int offset = ((x * _blockHeight) + y) * 196 + 4; if (_install.IsUOPFormat) { int block = offset / 0xC4000; offset += 0xD88 + (0xD54 * (block / 100)) + (12 * block); } _map.Seek(offset, SeekOrigin.Begin); Tile[] tiles = new Tile[64]; fixed (Tile* pTiles = tiles) { NativeMethods._lread(_map.SafeFileHandle, pTiles, 192); } return tiles; }
public void SetLandBlock(int x, int y, Tile[] value) { if (x < 0 || y < 0 || x >= _blockWidth || y >= _blockHeight) return; if (_landTiles[x] == null) _landTiles[x] = new Tile[_blockHeight][]; _landTiles[x][y] = value; }