public void LoadStatics(TileMatrixData tileData, Map map) { // get data from the tile Matrix byte[] groundData = tileData.GetLandChunk(ChunkX, ChunkY); int staticLength; byte[] staticsData = tileData.GetStaticChunk(ChunkX, ChunkY, out staticLength); // load the ground data into the tiles. int groundDataIndex = 0; for (int i = 0; i < 64; i++) { int tileID = groundData[groundDataIndex++] + (groundData[groundDataIndex++] << 8); int tileZ = (sbyte)groundData[groundDataIndex++]; Ground ground = new Ground(tileID, map); ground.Position.Set((int)ChunkX * 8 + i % 8, (int)ChunkY * 8 + (i / 8), tileZ); } // load the statics data into the tiles int countStatics = staticLength / 7; int staticDataIndex = 0; for (int i = 0; i < countStatics; i++) { int iTileID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8); int iX = staticsData[staticDataIndex++]; int iY = staticsData[staticDataIndex++]; int iTileZ = (sbyte)staticsData[staticDataIndex++]; int hue = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256); StaticItem item = new StaticItem(iTileID, hue, i, map); item.Position.Set((int)ChunkX * 8 + iX, (int)ChunkY * 8 + iY, iTileZ); } }
private unsafe int LoadLandPatches(TileMatrixData tileMatrix, string landPath, string indexPath) { m_LandPatchPtrs = new Dictionary <uint, uint>(); m_LandPatchStream = FileManager.GetFile(landPath); using (FileStream fsIndex = FileManager.GetFile(indexPath)) { BinaryReader indexReader = new BinaryReader(fsIndex); int count = (int)(indexReader.BaseStream.Length / 4); uint ptr = 0; for (int i = 0; i < count; ++i) { uint blockID = indexReader.ReadUInt32(); uint x = blockID / tileMatrix.ChunkHeight; uint y = blockID % tileMatrix.ChunkHeight; uint key = MakeChunkKey(x, y); ptr += 4; m_LandPatchPtrs.Add(key, ptr); ptr += 192; } indexReader.Close(); return(count); } }
public void CreateSeasonalTileInfo() { m_StaticCounts = new Dictionary<int, int>(); TileMatrixData tileData = new TileMatrixData(0); Map map = new Map(0); for (uint y = 0; y < tileData.ChunkHeight; y++) { Tracer.Info("Map Parser: row {0}.", y); for (uint x = 0; x < tileData.ChunkWidth; x++) { ParseMapBlock(tileData, x, y); } } var items = from pair in m_StaticCounts orderby pair.Value descending select pair; using (FileStream file = new FileStream(@"AllTiles.txt", FileMode.Create)) { StreamWriter stream = new StreamWriter(file); foreach (KeyValuePair<int, int> pair in items) { ItemData itemData = TileData.ItemData[pair.Key]; if ((itemData.IsBackground || itemData.IsFoliage) && !itemData.IsWet && !itemData.IsSurface) stream.WriteLine(string.Format("{0},{1} ; {2}", pair.Key, pair.Value, itemData.Name)); } stream.Flush(); file.Flush(); } }
public TileMatrixDataPatch(TileMatrixData matrix, uint index) { if (!m_Enabled) { return; } LoadLandPatches(matrix, String.Format("mapdif{0}.mul", index), String.Format("mapdifl{0}.mul", index)); LoadStaticPatches(matrix, String.Format("stadif{0}.mul", index), String.Format("stadifl{0}.mul", index), String.Format("stadifi{0}.mul", index)); }
public Map(uint index) { Index = index; MapData = new TileMatrixData(Index); TileHeight = MapData.ChunkHeight * 8; TileWidth = MapData.ChunkWidth * 8; m_Chunks = new MapChunk[c_CellsInMemorySpan * c_CellsInMemorySpan]; }
unsafe int LoadStaticPatches(TileMatrixData tileMatrix, string dataPath, string indexPath, string lookupPath) { m_StaticPatchPtrs = new Dictionary <uint, StaticPatchData>(); m_StaticPatchStream = FileManager.GetFile(dataPath); if (m_StaticPatchStream == null) { return(0); } using (FileStream fsIndex = FileManager.GetFile(indexPath)) { using (FileStream fsLookup = FileManager.GetFile(lookupPath)) { BinaryReader indexReader = new BinaryReader(fsIndex); BinaryReader lookupReader = new BinaryReader(fsLookup); int count = (int)(indexReader.BaseStream.Length / 4); for (uint i = 0; i < count; ++i) { uint blockID = indexReader.ReadUInt32(); uint blockX = blockID / tileMatrix.ChunkHeight; uint blockY = blockID % tileMatrix.ChunkHeight; uint key = MakeChunkKey(blockX, blockY); uint offset = lookupReader.ReadUInt32(); int length = lookupReader.ReadInt32(); lookupReader.ReadInt32(); if (m_StaticPatchPtrs.ContainsKey(key)) { StaticPatchData current = m_StaticPatchPtrs[key]; while (current.Next != null) { current = current.Next; } current.Next = new StaticPatchData(i, offset, length); } else { m_StaticPatchPtrs.Add(key, new StaticPatchData(i, offset, length)); } } indexReader.Close(); lookupReader.Close(); return(count); } } }
private static sbyte[] m_Zs = new sbyte[64]; // shared between all instances of MiniMapChunk. public MiniMapChunk(uint x, uint y, TileMatrixData tileData) { X = x; Y = y; Colors = new uint[64]; // get data from the tile Matrix byte[] groundData = tileData.GetLandChunk(x, y); int staticLength; byte[] staticsData = tileData.GetStaticChunk(x, y, out staticLength); // get the ground colors int groundDataIndex = 0; for (int i = 0; i < 64; i++) { Colors[i] = RadarColorData.Colors[groundData[groundDataIndex++] + (groundData[groundDataIndex++] << 8)]; m_Zs[i]= (sbyte)groundData[groundDataIndex++]; } // get the static colors int countStatics = staticLength / 7; int staticDataIndex = 0; for (int i = 0; i < countStatics; i++) { int itemID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8); int tile = staticsData[staticDataIndex++] + staticsData[staticDataIndex++] * 8; sbyte z = (sbyte)staticsData[staticDataIndex++]; int hue = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256); // is this used? ItemData data = TileData.ItemData[itemID]; int iz = z + data.Height + (data.IsRoof || data.IsSurface ? 1 : 0); if ((x * 8 + (tile % 8) == 1480) && (y * 8 + (tile / 8) == 1608)) { if (iz > m_Zs[tile]) { Colors[tile] = RadarColorData.Colors[itemID + 0x4000]; m_Zs[tile] = (sbyte)iz; } } if (iz > m_Zs[tile]) { Colors[tile] = RadarColorData.Colors[itemID + 0x4000]; m_Zs[tile] = (sbyte)iz; } } }
unsafe int LoadLandPatches(TileMatrixData tileMatrix, string landPath, string indexPath) { m_LandPatchPtrs = new Dictionary <uint, LandPatchData>(); if (ClientVersion.InstallationIsUopFormat) { return(0); } m_LandPatchStream = FileManager.GetFile(landPath); if (m_LandPatchStream == null) { return(0); } using (FileStream fsIndex = FileManager.GetFile(indexPath)) { BinaryReader indexReader = new BinaryReader(fsIndex); int count = (int)(indexReader.BaseStream.Length / 4); uint ptr = 0; for (uint i = 0; i < count; ++i) { uint blockID = indexReader.ReadUInt32(); uint x = blockID / tileMatrix.ChunkHeight; uint y = blockID % tileMatrix.ChunkHeight; uint key = MakeChunkKey(x, y); ptr += 4; if (m_LandPatchPtrs.ContainsKey(key)) { LandPatchData current = m_LandPatchPtrs[key]; while (current.Next != null) { current = current.Next; } current.Next = new LandPatchData(i, ptr); } else { m_LandPatchPtrs.Add(key, new LandPatchData(i, ptr)); } ptr += 192; } indexReader.Close(); return(count); } }
private unsafe int LoadStaticPatches(TileMatrixData tileMatrix, string dataPath, string indexPath, string lookupPath) { m_StaticPatchPtrs = new Dictionary <uint, Tuple <int, int> >(); m_StaticPatchStream = FileManager.GetFile(dataPath); using (FileStream fsIndex = FileManager.GetFile(indexPath)) { using (FileStream fsLookup = FileManager.GetFile(lookupPath)) { BinaryReader indexReader = new BinaryReader(fsIndex); BinaryReader lookupReader = new BinaryReader(fsLookup); int count = (int)(indexReader.BaseStream.Length / 4); for (int i = 0; i < count; ++i) { uint blockID = indexReader.ReadUInt32(); uint blockX = blockID / tileMatrix.ChunkHeight; uint blockY = blockID % tileMatrix.ChunkHeight; uint key = MakeChunkKey(blockX, blockY); int offset = lookupReader.ReadInt32(); int length = lookupReader.ReadInt32(); lookupReader.ReadInt32(); if (m_StaticPatchPtrs.ContainsKey(key)) { // Tuple<int, int> old = m_StaticPatchPtrs[key]; m_StaticPatchPtrs[key] = new Tuple <int, int>(offset, length); } else { m_StaticPatchPtrs.Add(key, new Tuple <int, int>(offset, length)); } } indexReader.Close(); lookupReader.Close(); return(count); } } }
private unsafe int LoadLandPatches(TileMatrixData tileMatrix, string landPath, string indexPath) { m_LandPatchPtrs = new Dictionary<uint, uint>(); if (ClientVersion.IsUopFormat) return 0; m_LandPatchStream = FileManager.GetFile(landPath); if (m_LandPatchStream == null) return 0; using (FileStream fsIndex = FileManager.GetFile(indexPath)) { BinaryReader indexReader = new BinaryReader(fsIndex); int count = (int)(indexReader.BaseStream.Length / 4); uint ptr = 0; for (int i = 0; i < count; ++i) { uint blockID = indexReader.ReadUInt32(); uint x = blockID / tileMatrix.ChunkHeight; uint y = blockID % tileMatrix.ChunkHeight; uint key = MakeChunkKey(x, y); ptr += 4; m_LandPatchPtrs.Add(key, ptr); ptr += 192; } indexReader.Close(); return count; } }
private void ParseMapBlock(TileMatrixData tileData, uint x, uint y) { byte[] groundData = tileData.GetLandChunk(x, y); int staticLength; byte[] staticsData = tileData.GetStaticChunk(x, y, out staticLength); // load the statics data int countStatics = staticLength / 7; int staticDataIndex = 0; for (int i = 0; i < countStatics; i++) { int iTileID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8); int iX = staticsData[staticDataIndex++]; int iY = staticsData[staticDataIndex++]; int iTileZ = (sbyte)staticsData[staticDataIndex++]; int hue = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256); if (m_StaticCounts.ContainsKey(iTileID)) m_StaticCounts[iTileID]++; else m_StaticCounts.Add(iTileID, 1); } }
private unsafe int LoadStaticPatches(TileMatrixData tileMatrix, string dataPath, string indexPath, string lookupPath) { m_StaticPatchPtrs = new Dictionary<uint, Tuple<int, int>>(); m_StaticPatchStream = FileManager.GetFile(dataPath); if (m_StaticPatchStream == null) return 0; using (FileStream fsIndex = FileManager.GetFile(indexPath)) { using (FileStream fsLookup = FileManager.GetFile(lookupPath)) { BinaryReader indexReader = new BinaryReader(fsIndex); BinaryReader lookupReader = new BinaryReader(fsLookup); int count = (int)(indexReader.BaseStream.Length / 4); for (int i = 0; i < count; ++i) { uint blockID = indexReader.ReadUInt32(); uint blockX = blockID / tileMatrix.ChunkHeight; uint blockY = blockID % tileMatrix.ChunkHeight; uint key = MakeChunkKey(blockX, blockY); int offset = lookupReader.ReadInt32(); int length = lookupReader.ReadInt32(); lookupReader.ReadInt32(); if (m_StaticPatchPtrs.ContainsKey(key)) { // Tuple<int, int> old = m_StaticPatchPtrs[key]; m_StaticPatchPtrs[key] = new Tuple<int, int>(offset, length); } else { m_StaticPatchPtrs.Add(key, new Tuple<int, int>(offset, length)); } } indexReader.Close(); lookupReader.Close(); return count; } } }
unsafe int LoadLandPatches(TileMatrixData tileMatrix, string landPath, string indexPath) { m_LandPatchPtrs = new Dictionary<uint, LandPatchData>(); if (ClientVersion.InstallationIsUopFormat) return 0; m_LandPatchStream = FileManager.GetFile(landPath); if (m_LandPatchStream == null) { return 0; } using (FileStream fsIndex = FileManager.GetFile(indexPath)) { BinaryReader indexReader = new BinaryReader(fsIndex); int count = (int)(indexReader.BaseStream.Length / 4); uint ptr = 0; for (uint i = 0; i < count; ++i) { uint blockID = indexReader.ReadUInt32(); uint x = blockID / tileMatrix.ChunkHeight; uint y = blockID % tileMatrix.ChunkHeight; uint key = MakeChunkKey(x, y); ptr += 4; if (m_LandPatchPtrs.ContainsKey(key)) { LandPatchData current = m_LandPatchPtrs[key]; while (current.Next != null) current = current.Next; current.Next = new LandPatchData(i, ptr); } else { m_LandPatchPtrs.Add(key, new LandPatchData(i, ptr)); } ptr += 192; } indexReader.Close(); return count; } }