public static void Load(string filename) { if (filename.ToLowerInvariant() == _currentMap) { return; } _currentMap = filename.ToLowerInvariant(); ConVar.SetValue("mapname", Path.GetFileNameWithoutExtension(filename)); Stream mapFile = FileSystem.OpenCopy(filename); BinaryReader reader = new BinaryReader(mapFile); GBMPHeader header = new GBMPHeader(); header.Read(reader); if (header.Magic != 0x504D4247 || header.Version != 500) { throw new InvalidOperationException("this isn't a GBMP v.500"); } while (!mapFile.EndOfStream()) { GBMPChunk chunk = new GBMPChunk(); chunk.Read(reader); if (chunk.Type == 0x50414D44) // DMAP { LoadCompressedMap(mapFile); } else if (chunk.Type == 0x5448474C) // LGHT { LoadLights(mapFile, (chunk.Size / 16)); } else { mapFile.Position += chunk.Size; } } mapFile.Close(); CellManager.InitializeFromMap(); }
public static void Load(string filename) { Stream styleFile = FileSystem.OpenCopy(filename); BinaryReader reader = new BinaryReader(styleFile); GBMPHeader header = new GBMPHeader(); header.Read(reader); if (header.Magic != 0x54534247 || header.Version != 700) { throw new InvalidOperationException("this isn't a GBST v.700"); } while (!styleFile.EndOfStream()) { GBMPChunk chunk = new GBMPChunk(); chunk.Read(reader); Log.Write(LogLevel.Debug, "found a chunk of type " + Encoding.ASCII.GetString(BitConverter.GetBytes(chunk.Type))); var oldPosition = styleFile.Position; if (chunk.Type == 0x584C4150) // PALX { LoadPaletteIndex(styleFile); } else if (chunk.Type == 0x4C415050) // PPAL { LoadPalettes(styleFile, chunk.Size); } else if (chunk.Type == 0x454C4954) // TILE { LoadTiles(styleFile); } styleFile.Position = oldPosition + chunk.Size; } styleFile.Close(); }