public static bool CanLoadMap(string vmapPath, uint mapID, uint tileX, uint tileY, VMapManager vm) { string fullname = vmapPath + VMapManager.getMapFileName(mapID); if (!File.Exists(fullname)) { return(false); } using (BinaryReader reader = new BinaryReader(new FileStream(fullname, FileMode.Open, FileAccess.Read))) { if (reader.ReadStringFromChars(8) != MapConst.VMapMagic) { return(false); } } FileStream stream = OpenMapTileFile(vmapPath, mapID, tileX, tileY, vm); if (stream == null) { return(false); } using (BinaryReader reader = new BinaryReader(stream)) { if (reader.ReadStringFromChars(8) != MapConst.VMapMagic) { return(false); } } return(true); }
public static bool CanLoadMap(string vmapPath, uint mapID, uint tileX, uint tileY) { string fullname = vmapPath + VMapManager.getMapFileName(mapID); bool success = true; if (!File.Exists(fullname)) { return(false); } using (BinaryReader reader = new BinaryReader(new FileStream(fullname, FileMode.Open, FileAccess.Read))) { if (reader.ReadStringFromChars(8) != MapConst.VMapMagic) { return(false); } char tiled = reader.ReadChar(); if (tiled == 1) { string tilefile = vmapPath + getTileFileName(mapID, tileX, tileY); if (!File.Exists(tilefile)) { return(false); } using (BinaryReader reader1 = new BinaryReader(new FileStream(tilefile, FileMode.Open, FileAccess.Read))) { if (reader1.ReadStringFromChars(8) != MapConst.VMapMagic) { success = false; } } } } return(success); }