diff --git a/OpenRA.FileFormats/InstallUtils.cs b/OpenRA.FileFormats/InstallUtils.cs index 2ccb26e6b5..439e4ce737 100644 --- a/OpenRA.FileFormats/InstallUtils.cs +++ b/OpenRA.FileFormats/InstallUtils.cs @@ -28,15 +28,15 @@ namespace OpenRA.FileFormats } } - public static string GetMountedDisk(string[] volumeNames) + public static string GetMountedDisk(Func isValidDisk) { var volumes = DriveInfo.GetDrives() .Where(v => v.DriveType == DriveType.CDRom && v.IsReady) .Select(v => v.RootDirectory.FullName); - return volumes.FirstOrDefault(v => volumeNames.Contains(Path.GetFileName(v))); + return volumes.FirstOrDefault(v => isValidDisk(v)); } - + // TODO: The package should be mounted into its own context to avoid name collisions with installed files public static bool ExtractFromPackage(string srcPath, string package, string[] files, string destPath, Action onProgress, Action onError) { diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs index aba73ab5b6..174b5b48d8 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs @@ -49,7 +49,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic void CheckForDisk() { - var path = InstallUtils.GetMountedDisk(new [] { "GDI95", "NOD95" }); + Func ValidDiskFilter = diskRoot => File.Exists(diskRoot+Path.DirectorySeparatorChar+"CONQUER.MIX") && + File.Exists(diskRoot+Path.DirectorySeparatorChar+"DESERT.MIX") && + File.Exists(new string[] { diskRoot, "INSTALL", "SETUP.Z" }.Aggregate(Path.Combine)); + + var path = InstallUtils.GetMountedDisk(ValidDiskFilter); if (path != null) Install(path); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs index 61caf9ce10..bb03199bca 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var installButton = panel.GetWidget("INSTALL_BUTTON"); installButton.OnClick = () => Widget.OpenWindow("INSTALL_MUSIC_PANEL", new WidgetArgs() {{ "afterInstall", afterInstall }}); - installButton.IsVisible = () => music.Length < 2; // Hack around ra shipping (only) hellmarch by default + installButton.IsVisible = () => music.Length < 3; // Hack around music being split between transit.mix and scores.mix panel.GetWidget("NO_MUSIC_LABEL").IsVisible = noMusic; @@ -216,7 +216,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic void CheckForDisk() { - var path = InstallUtils.GetMountedDisk(new [] { "GDI95", "NOD95" }); + Func ValidDiskFilter = diskRoot => File.Exists(diskRoot+Path.DirectorySeparatorChar+"CONQUER.MIX") && + File.Exists(diskRoot+Path.DirectorySeparatorChar+"DESERT.MIX") && + File.Exists(new string[] { diskRoot, "INSTALL", "SETUP.Z" }.Aggregate(Path.Combine)); + + var path = InstallUtils.GetMountedDisk(ValidDiskFilter); if (path != null) Install(path); diff --git a/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs index 8570177fb0..9a5dd5c288 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs @@ -49,7 +49,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic void CheckForDisk() { - var path = InstallUtils.GetMountedDisk(new [] { "CD1", "CD2" }); + Func ValidDiskFilter = diskRoot => File.Exists(diskRoot+Path.DirectorySeparatorChar+"MAIN.MIX") && + File.Exists(new string[] { diskRoot, "INSTALL", "REDALERT.MIX" }.Aggregate(Path.Combine)); + + var path = InstallUtils.GetMountedDisk(ValidDiskFilter); if (path != null) Install(path);