Fix previous commit, clean up helpers

This commit is contained in:
Matt Nadareski
2023-06-12 13:42:13 -04:00
parent f43aafc00d
commit 6ceffce63d
4 changed files with 28 additions and 36 deletions

View File

@@ -67,6 +67,7 @@
- Fix VSCode build
- Fix Redumper DAT/layer parsing
- Update Redumper PS1 output parsing
- Fix previous commit, clean up helpers
### 2.5 (2023-03-12)

View File

@@ -779,14 +779,8 @@ namespace MPF.Modules.DiscImageCreator
else if (File.Exists($"{basePath}.img_EccEdc.txt"))
psEdcStatus = GetPlayStationEDCStatus($"{basePath}.img_EccEdc.txt");
if (psEdcStatus == true)
info.EDC.EDC = YesNo.Yes;
else if (psEdcStatus == false)
info.EDC.EDC = YesNo.No;
else
info.EDC.EDC = YesNo.NULL;
info.CopyProtection.AntiModchip = GetPlayStationAntiModchipDetected($"{basePath}_disc.txt") ? YesNo.Yes : YesNo.No;
info.EDC.EDC = psEdcStatus.ToYesNo();
info.CopyProtection.AntiModchip = GetPlayStationAntiModchipDetected($"{basePath}_disc.txt").ToYesNo();
break;
case RedumpSystem.SonyPlayStation2:
@@ -3149,11 +3143,11 @@ namespace MPF.Modules.DiscImageCreator
/// </summary>
/// <param name="disc">_disc.txt file location</param>
/// <returns>Anti-modchip existence if possible, false on error</returns>
private static bool GetPlayStationAntiModchipDetected(string disc)
private static bool? GetPlayStationAntiModchipDetected(string disc)
{
// If the file doesn't exist, we can't get info from it
if (!File.Exists(disc))
return false;
return null;
using (StreamReader sr = File.OpenText(disc))
{
@@ -3176,7 +3170,7 @@ namespace MPF.Modules.DiscImageCreator
catch
{
// We don't care what the exception is right now
return false;
return null;
}
}
}

View File

@@ -383,30 +383,9 @@ namespace MPF.Modules.Redumper
info.CommonDiscInfo.EXEDateBuildDate = playstationDate;
}
bool? psAntiModchipStatus = GetPlayStationAntiModchipDetected($"{basePath}.log");
if (psAntiModchipStatus == true)
info.CopyProtection.AntiModchip = YesNo.Yes;
else if (psAntiModchipStatus == false)
info.CopyProtection.AntiModchip = YesNo.No;
else
info.CopyProtection.AntiModchip = YesNo.NULL;
bool? psEdcStatus = GetPlayStationEDCStatus($"{basePath}.log");
if (psEdcStatus == true)
info.EDC.EDC = YesNo.Yes;
else if (psEdcStatus == false)
info.EDC.EDC = YesNo.No;
else
info.EDC.EDC = YesNo.NULL;
bool? psLibCryptStatus = GetPlayStationLibCryptStatus($"{basePath}.log");
if (psLibCryptStatus == true)
info.CopyProtection.LibCrypt = YesNo.Yes;
else if (psLibCryptStatus == false)
info.CopyProtection.LibCrypt = YesNo.No;
else
info.CopyProtection.LibCrypt = YesNo.NULL;
info.CopyProtection.AntiModchip = GetPlayStationAntiModchipDetected($"{basePath}.log").ToYesNo();
info.EDC.EDC = GetPlayStationEDCStatus($"{basePath}.log").ToYesNo();
info.CopyProtection.LibCrypt = GetPlayStationLibCryptStatus($"{basePath}.log").ToYesNo();
break;
case RedumpSystem.SonyPlayStation2:
@@ -1420,7 +1399,7 @@ namespace MPF.Modules.Redumper
if (line.StartsWith("libcrypt: no"))
return false;
else if (line.StartsWith("libcrypt: yes))
else if (line.StartsWith("libcrypt: yes"))
return true;
line = sr.ReadLine().Trim();

View File

@@ -2135,6 +2135,24 @@ namespace RedumpLib.Data
/// <returns></returns>
public static string LongName(this YesNo? yesno) => AttributeHelper<YesNo?>.GetAttribute(yesno)?.LongName ?? "Yes/No";
/// <summary>
/// Get the YesNo enum value for a given nullable boolean
/// </summary>
/// <param name="yesno">Nullable boolean value to convert</param>
/// <returns>YesNo represented by the nullable boolean, if possible</returns>
public static YesNo? ToYesNo(this bool? yesno)
{
switch (yesno)
{
case false:
return YesNo.No;
case true:
return YesNo.Yes;
default:
return YesNo.NULL;
}
}
/// <summary>
/// Get the YesNo enum value for a given string
/// </summary>