static FileStream OpenMapTileFile(string vmapPath, uint mapID, uint tileX, uint tileY, VMapManager vm) { string tilefile = vmapPath + GetTileFileName(mapID, tileX, tileY); if (!File.Exists(tilefile)) { int parentMapId = vm.GetParentMapId(mapID); while (parentMapId != -1) { tilefile = vmapPath + GetTileFileName((uint)parentMapId, tileX, tileY); if (File.Exists(tilefile)) { break; } parentMapId = vm.GetParentMapId((uint)parentMapId); } } if (!File.Exists(tilefile)) { return(null); } return(new FileStream(tilefile, FileMode.Open, FileAccess.Read)); }
static TileFileOpenResult OpenMapTileFile(string vmapPath, uint mapID, uint tileX, uint tileY, VMapManager vm) { TileFileOpenResult result = new TileFileOpenResult(); result.Name = vmapPath + GetTileFileName(mapID, tileX, tileY); if (File.Exists(result.Name)) { result.UsedMapId = mapID; result.File = new FileStream(result.Name, FileMode.Open, FileAccess.Read); return(result); } int parentMapId = vm.GetParentMapId(mapID); while (parentMapId != -1) { result.Name = vmapPath + GetTileFileName((uint)parentMapId, tileX, tileY); if (File.Exists(result.Name)) { result.File = new FileStream(result.Name, FileMode.Open, FileAccess.Read); result.UsedMapId = (uint)parentMapId; return(result); } parentMapId = vm.GetParentMapId((uint)parentMapId); } return(result); }