private static void EnqueueEmptyBlock(Minimap.MinimapRequest minimapRequest) { string mapName = minimapRequest.mapName; MinimapData.MinimapBlockData blockData = new MinimapData.MinimapBlockData(); blockData.mapName = mapName; blockData.coords = minimapRequest.coords; blockData.minimapByteData = null; MinimapData.MinimapDataQueue.Enqueue(blockData); }
// Request BLP blocks // private static void RequestAvailableBLPs(string mapName) { int X = (int)(MinimapData.Min.x + ((MinimapData.Max.x - MinimapData.Min.x) / 2)); int Y = (int)(MinimapData.Min.x + ((MinimapData.Max.x - MinimapData.Min.x) / 2)); Debug.Log(X + " " + Y); int x, y, dx, dy; x = y = dx = 0; dx = 0; dy = -1; int t = 64; int maxI = t * t; for (int i = 0; i < maxI; i++) { if (((x + X) > 0) && ((x + X) < maxI) && ((y + Y) > 0) && ((y + Y) < maxI)) { if (MinimapData.mapAvailability[x + Y, y + Y].Minimap) { Minimap.MinimapRequest minimapRequest = new Minimap.MinimapRequest(); minimapRequest.mapName = mapName; minimapRequest.coords = new Vector2(x + X, y + Y); RequestBlock(minimapRequest); } else { if (MinimapData.mapAvailability[x + Y, y + Y].ADT) { Minimap.MinimapRequest minimapRequest = new Minimap.MinimapRequest(); minimapRequest.mapName = mapName; minimapRequest.coords = new Vector2(x + Y, y + Y); EnqueueEmptyBlock(minimapRequest); } } } if ((x == y) || ((x < 0) && (x == -y)) || ((x > 0) && (x == 1 - y))) { t = dx; dx = -dy; dy = t; } x += dx; y += dy; } }
// Request a minimap image from the parser // private static void RequestBlock(Minimap.MinimapRequest minimapRequest) { string mapName = minimapRequest.mapName; string fileName = "map" + minimapRequest.coords.x + "_" + minimapRequest.coords.y + ".blp"; string path = @"world\minimaps\" + mapName + @"\" + fileName; string extractedPath = Casc.GetFile(path); using (Stream stream = File.Open(extractedPath, FileMode.Open)) { BLP blp = new BLP(); byte[] data = blp.GetUncompressed(stream, true); BLPinfo info = blp.Info(); MinimapData.MinimapBlockData blockData = new MinimapData.MinimapBlockData(); blockData.mapName = mapName; blockData.coords = minimapRequest.coords; blockData.textureInfo = info; blockData.minimapByteData = data; MinimapData.MinimapDataQueue.Enqueue(blockData); } }