diff --git a/Fushigi/course/CourseArea.cs b/Fushigi/course/CourseArea.cs index abf310ef..d5ce402e 100644 --- a/Fushigi/course/CourseArea.cs +++ b/Fushigi/course/CourseArea.cs @@ -134,13 +134,21 @@ public void Save(RSTB resource_table, string folder) var decomp_size = (uint)mem.Length; - //Compress and save the course area - string levelPath = Path.Combine(folder, $"{mAreaName}.bcett.byml.zs"); - File.WriteAllBytes(levelPath, FileUtil.CompressData(mem.ToArray())); + try + { + //Compress and save the course area + string levelPath = Path.Combine(folder, $"{mAreaName}.bcett.byml.zs"); + File.WriteAllBytes(levelPath, FileUtil.CompressData(mem.ToArray())); - //Update resource table - // filePath is a key not an actual path so we cannot use Path.Combine - resource_table.SetResource($"BancMapUnit/{mAreaName}.bcett.byml", decomp_size); + //Update resource table + // filePath is a key not an actual path so we cannot use Path.Combine + resource_table.SetResource($"BancMapUnit/{mAreaName}.bcett.byml", decomp_size); + } + catch(IOException e) + { + //Likely due to the course being open in the game, caught to prevent crash + //TODO: notify the user + } } public string GetName() diff --git a/Fushigi/rstb/RSTB.cs b/Fushigi/rstb/RSTB.cs index 79df331f..5e00b4c6 100644 --- a/Fushigi/rstb/RSTB.cs +++ b/Fushigi/rstb/RSTB.cs @@ -88,11 +88,19 @@ public void Save() var mem = new MemoryStream(); Write(mem); - - File.WriteAllBytes( + + try + { + File.WriteAllBytes( Path.Combine(dir, "ResourceSizeTable.Product.100.rsizetable.zs"), FileUtil.CompressData(mem.ToArray()) ); + } + catch (IOException e) + { + //Likely due to the course being open in the game, caught to prevent crash + //TODO: notify the user + } } private void Read(Stream stream)