diff --git a/CHANGELOG.md b/CHANGELOG.md
index e66d37a..f58138b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+- The handling of Intralism maps with config v3, encrypted data, and/or Unlock Conditions.
+- A game crash when converting invalid maps.
+
## [1.4.0-alpha] - 2020-02-24
### Added
diff --git a/Pulsarc/Beatmaps/BeatmapHelper.cs b/Pulsarc/Beatmaps/BeatmapHelper.cs
index e0504f5..115ff63 100644
--- a/Pulsarc/Beatmaps/BeatmapHelper.cs
+++ b/Pulsarc/Beatmaps/BeatmapHelper.cs
@@ -224,14 +224,18 @@ static public void Save(Beatmap beatmap, string file_path)
file.WriteLine("Events:");
foreach (Event evt in beatmap.Events)
+ {
file.WriteLine(evt.ToString());
+ }
// Write Timing Points
file.WriteLine("");
file.WriteLine("TimingPoints:");
foreach (TimingPoint timingPoint in beatmap.TimingPoints)
+ {
file.WriteLine(timingPoint.ToString());
+ }
// Write Speed Variations
file.WriteLine("");
@@ -242,7 +246,9 @@ static public void Save(Beatmap beatmap, string file_path)
file.WriteLine("Arcs:");
foreach (Arc arc in beatmap.Arcs)
+ {
file.WriteLine(arc.ToString());
+ }
}
}
@@ -271,10 +277,7 @@ static private void WriteProperty(StreamWriter file, Beatmap beatmap, string pro
/// The arc to check
/// The column to check in (in binary format)
///
- static public bool IsColumn(Arc arc, int column)
- {
- return ((arc.Type >> column) & 1) != 0;
- }
+ static public bool IsColumn(Arc arc, int column) => ((arc.Type >> column) & 1) != 0;
///
/// Makes a new Event based on the data found in line
diff --git a/Pulsarc/Pulsarc.cs b/Pulsarc/Pulsarc.cs
index 9f8e81f..e35a46c 100644
--- a/Pulsarc/Pulsarc.cs
+++ b/Pulsarc/Pulsarc.cs
@@ -259,14 +259,27 @@ private async void ConvertMaps()
{
for (int i = 0; i < directories.Length; i++)
{
- converter.Save(directories[i]);
+ try
+ {
+ converter.Save(directories[i]);
+ }
+ catch
+ {
+ PulsarcLogger.Warning($"Couldn't convert {directories[i]}");
+ }
}
}
-
// Otherwise convert one map
else
{
- converter.Save(toConvert);
+ try
+ {
+ converter.Save(toConvert);
+ }
+ catch
+ {
+ PulsarcLogger.Warning($"Couldn't convert {toConvert}");
+ }
}
((SongSelection)ScreenManager.Screens.Peek()).RescanBeatmaps();
diff --git a/Pulsarc/Pulsarc.csproj b/Pulsarc/Pulsarc.csproj
index 8c604a2..6b03e7a 100644
--- a/Pulsarc/Pulsarc.csproj
+++ b/Pulsarc/Pulsarc.csproj
@@ -9,8 +9,8 @@
Pulsarc
Icon.ico
- 1.4.0.0
- 1.4.0.0
+ 1.4.1.0
+ 1.4.1.0
diff --git a/Pulsarc/Utils/BeatmapConversion/IntralismBeatmap.cs b/Pulsarc/Utils/BeatmapConversion/IntralismBeatmap.cs
index e592a2f..1146466 100644
--- a/Pulsarc/Utils/BeatmapConversion/IntralismBeatmap.cs
+++ b/Pulsarc/Utils/BeatmapConversion/IntralismBeatmap.cs
@@ -47,7 +47,7 @@ class IntralismBeatmap
// ¯\_(ツ)_/¯
// Seemed to be used to "unlock" maps in an earlier version of Intralism
- public List> UnlockConditions { get; set; }
+ public List UnlockConditions { get; set; }
// Probably related to above
public bool Hidden { get; set; }
@@ -56,6 +56,9 @@ class IntralismBeatmap
// A list of all the Events in the map
public List Events { get; set; }
+
+ // The encryted data of a map
+ public string e { get; set; }
}
///
diff --git a/Pulsarc/Utils/BeatmapConversion/IntralismToPulsarc.cs b/Pulsarc/Utils/BeatmapConversion/IntralismToPulsarc.cs
index cd94ecd..f550741 100644
--- a/Pulsarc/Utils/BeatmapConversion/IntralismToPulsarc.cs
+++ b/Pulsarc/Utils/BeatmapConversion/IntralismToPulsarc.cs
@@ -34,56 +34,64 @@ public List Convert(string folder_path)
string backgroundImage = Config.Get["Converting"]["BGImage"];
// See if the provided path exists
- if (Directory.Exists(folder_path))
+ if (!Directory.Exists(folder_path)) { return null; }
+
+ string configPath = $"{folder_path}/config.txt";
+
+ // See if the a "config.txt" file exists
+ if (!File.Exists(configPath)) { return null; }
+
+ // Convert the config file to an IntrlaismBeatmap
+ IntralismBeatmap beatmap = JsonConvert.DeserializeObject(File.ReadAllText(configPath, Encoding.UTF8));
+
+ // If there are no arc events (either from v3 or bad mapping), stop converting.
+ if (beatmap.Events.Where(x => x.Data[0].Equals("SpawnObj")).Count() <= 0)
+ { return null; }
+
+ string name = "";
+
+ // If the user specified an image path to use, use that path.
+ if (backgroundImage != null && !backgroundImage.Equals(""))
{
- string configPath = $"{folder_path}/config.txt";
+ name = backgroundImage;
+ }
- // See if the a "config.txt" file exists
- if (File.Exists(configPath))
+ // If there's an average of 1 image per 10 seconds of map time or less
+ // and the user-defined path doesn't exist, grab the first image path in
+ // the beatmap.
+ if (!File.Exists($"{folder_path}/{name}") && beatmap.LevelResources.Count > 0 && beatmap.LevelResources.Count < Math.Ceiling(beatmap.MusicTime / 10))
+ {
+ beatmap.LevelResources[0].TryGetValue("path", out name);
+ }
+
+ result.Background = name;
+
+ // Fill in the missing metadata
+ result.FormatVersion = "1";
+ result.Mapper = "Intralism";
+ result.Artist = "Unknown";
+ result.Title = beatmap.Name;
+ result.Version = "Converted";
+ result.Audio = beatmap.MusicFile;
+ result.TimingPoints.Add(new TimingPoint(0, 120));
+ result.PreviewTime = 0;
+
+ // Go through each Intralism Event
+ foreach (Event evt in beatmap.Events)
+ {
+ // If the current event is an Arc, convert it to a Pulsarc Arc.
+ switch (evt.Data[0])
{
- // Convert the config file to an IntrlaismBeatmap
- IntralismBeatmap beatmap = JsonConvert.DeserializeObject(File.ReadAllText(configPath, Encoding.UTF8));
-
- string name = "";
-
- // If the user specified an image path to use, use that path.
- if (backgroundImage != null && !backgroundImage.Equals(""))
- name = backgroundImage;
-
- // If there's an average of 1 image per 10 seconds of map time or less
- // and the user-defined path doesn't exist, grab the first image path in
- // the beatmap.
- if (!File.Exists($"{folder_path}/{name}") && beatmap.LevelResources.Count > 0 && beatmap.LevelResources.Count < Math.Ceiling(beatmap.MusicTime / 10))
- beatmap.LevelResources[0].TryGetValue("path", out name);
-
- result.Background = name;
-
- // Fill in the missing metadata
- result.FormatVersion = "1";
- result.Mapper = "Intralism";
- result.Artist = "Unknown";
- result.Title = beatmap.Name;
- result.Version = "Converted";
- result.Audio = beatmap.MusicFile;
- result.TimingPoints.Add(new TimingPoint(0, 120));
- result.PreviewTime = 0;
-
- // Go through each Intralism Event
- foreach (Event evt in beatmap.Events)
- // If the current event is an Arc, convert it to a Pulsarc Arc.
- switch (evt.Data[0])
- {
- case "SpawnObj":
- // Add the converted arc to the Beatmap
- result.Arcs.Add(HandleSpawnObj(evt));
- break;
- case "SetPlayerDistance":
- // Add the converted zoom to the Beatmap
- result.Events.Add(HandleSetPlayerDistance(evt));
- break;
- default:
- break;
- }
+ case "SpawnObj":
+ // Add the converted arc to the Beatmap
+ result.Arcs.Add(HandleSpawnObj(evt));
+ break;
+ case "SetPlayerDistance":
+ // Add the converted zoom to the Beatmap
+ result.Events.Add(HandleSetPlayerDistance(evt));
+ break;
+ default:
+ break;
}
}
@@ -151,45 +159,52 @@ public void Save(string folder_path)
{
Beatmap map = Convert(folder_path).First();
- if (map.Audio != null)
- {
- string audioPath = $"{folder_path}/{map.Audio}";
-
- if (File.Exists(audioPath))
- {
- int id = 0;
- // The folder name will look like "0 - Unknown - MapTitle - (Mapper)"
- string folderName = string.Join("_", ($"{id} - {map.Artist} - {map.Title} ({map.Mapper})").Split(Path.GetInvalidFileNameChars()));
- string dirName = $"Songs/{folderName}";
+ // If the map is null, or audio is null, stop saving.
+ if (map == null || map.Audio == null) { return; }
- if (!Directory.Exists(dirName))
- Directory.CreateDirectory(dirName);
+ string audioPath = $"{folder_path}/{map.Audio}";
- // Copy Audio File
- File.Copy(audioPath, $"{dirName}/{map.Audio}", true);
+ // If the path doesn't exist, stop saving.
+ if (!File.Exists(audioPath)) { return; }
- // Copy Background Image
- string backgroundPath = $"{folder_path}/{map.Background}";
+ int id = 0;
+ // The folder name will look like "0 - Unknown - MapTitle - (Mapper)"
+ string folderName = string.Join("_", ($"{id} - {map.Artist} - {map.Title} ({map.Mapper})").Split(Path.GetInvalidFileNameChars()));
+ string dirName = $"Songs/{folderName}";
- if (File.Exists(backgroundPath))
- try
- {
- File.Copy(backgroundPath, $"{dirName}/{map.Background}", true);
- }
- catch
- {
- PulsarcLogger.Debug("Converting the background failed! Converting wtihout background.", LogType.Runtime);
- }
- else
- map.Background = "";
+ if (!Directory.Exists(dirName))
+ {
+ Directory.CreateDirectory(dirName);
+ }
+ // Copy Audio File
+ File.Copy(audioPath, $"{dirName}/{map.Audio}", true);
- // The file name will look like "Unknown - MapTitle [Converted] (Mapper).psc"
- string difficultyFileName = string.Join("_", ($"{map.Artist} - {map.Title} [{map.Version}] ({map.Mapper})").Split(Path.GetInvalidFileNameChars()));
+ // Copy Background Image
+ string backgroundPath = $"{folder_path}/{map.Background}";
- BeatmapHelper.Save(map, $"{dirName}/{difficultyFileName}.psc");
+ // Find if the background exists and copy it.
+ if (File.Exists(backgroundPath))
+ {
+ try
+ {
+ File.Copy(backgroundPath, $"{dirName}/{map.Background}", true);
}
+ catch
+ {
+ PulsarcLogger.Debug("Converting the background failed! Converting wtihout background.", LogType.Runtime);
+ }
+ }
+ else
+ {
+ map.Background = "";
}
+
+
+ // The file name will look like "Unknown - MapTitle [Converted] (Mapper).psc"
+ string difficultyFileName = string.Join("_", ($"{map.Artist} - {map.Title} [{map.Version}] ({map.Mapper})").Split(Path.GetInvalidFileNameChars()));
+
+ BeatmapHelper.Save(map, $"{dirName}/{difficultyFileName}.psc");
}
}
}