From 102acb9ebf57e0be71d9e8ae2df8a6dd178599ff Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 4 Sep 2025 21:27:13 +0900 Subject: [PATCH] Fix UIC processing logic (#885) * Fix UIC title field * the sabre approved way * Better UIC test_disc.txt * Fix UIC category logic * Fix GetUMDCategoryTest * Final test tweak --- CHANGELIST.md | 1 + MPF.Processors.Test/ProcessingToolTests.cs | 9 ++---- .../UmdImageCreator/UMD-zip/test_logs.zip | Bin 1167 -> 1356 bytes .../UmdImageCreator/UMD/test_disc.txt | 26 ++++++++++++++---- MPF.Processors.Test/UmdImageCreatorTests.cs | 8 +++--- MPF.Processors/ProcessingTool.cs | 6 ++-- MPF.Processors/UmdImageCreator.cs | 4 +-- 7 files changed, 33 insertions(+), 21 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 5e72ce0c..99ae0d3f 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -20,6 +20,7 @@ - Update RedumpLib to 1.7.1 - Support multisession cache files - Update DIC to 20250901 (Windows/Linux only) +- Fix UIC processing logic ### 3.3.3 (2025-07-18) diff --git a/MPF.Processors.Test/ProcessingToolTests.cs b/MPF.Processors.Test/ProcessingToolTests.cs index d6efb2d4..337bf408 100644 --- a/MPF.Processors.Test/ProcessingToolTests.cs +++ b/MPF.Processors.Test/ProcessingToolTests.cs @@ -471,12 +471,9 @@ namespace MPF.Processors.Test [Theory] [InlineData(null, null)] [InlineData("", null)] - [InlineData("GAME", DiscCategory.Games)] - [InlineData("game", DiscCategory.Games)] - [InlineData("VIDEO", DiscCategory.Video)] - [InlineData("video", DiscCategory.Video)] - [InlineData("AUDIO", DiscCategory.Audio)] - [InlineData("audio", DiscCategory.Audio)] + [InlineData("(GAME)", DiscCategory.Games)] + [InlineData("(VIDEO)", DiscCategory.Video)] + [InlineData("(AUDIO)", DiscCategory.Audio)] [InlineData("INVALID", null)] public void GetUMDCategoryTest(string? category, DiscCategory? expected) { diff --git a/MPF.Processors.Test/TestData/UmdImageCreator/UMD-zip/test_logs.zip b/MPF.Processors.Test/TestData/UmdImageCreator/UMD-zip/test_logs.zip index a84e00ef7741bb8f2da5fa2727b03eaed96356d7..c28388304ac0b558e0cd4b6b9ff84addddb1fb9b 100644 GIT binary patch delta 470 zcmeC@Ji|4?w%&EAO0@ac&y%$n85s65GBEHmFff#)7MH}QWELmul~k0J_Iu|y8wj+V zcYS34a*+Ryt!ArzndA~zp;C>Bv)v- z3ghn`Zp;5lo_)S-Op> zQaPvb+vN}=`)3IaQ3fXuo7@iwX;EnQ(AgH~Aoy9l(R8NJ@9Qz5o##IwtmW*=17Z$PMdNW7#K;TtwT=K9FK45tTN}HxhDW3*=<_9SBN3k79)4e+op+3igPM(32d!OD z!?3x7F^7@Ko_X>?MzP5}%x-G-%pwd73>*xY?o?rb0ELDvjgu>wEkU|^7$qj3X69i! z%`o{Uvjs@xAfv=&Z5AFzhRGHzwjhCW78ORz$#Yn2K%9Ce2|i?V_AyRkbz?JT0+|c| DkV0MY diff --git a/MPF.Processors.Test/TestData/UmdImageCreator/UMD/test_disc.txt b/MPF.Processors.Test/TestData/UmdImageCreator/UMD/test_disc.txt index bcea7b94..258ce697 100644 --- a/MPF.Processors.Test/TestData/UmdImageCreator/UMD/test_disc.txt +++ b/MPF.Processors.Test/TestData/UmdImageCreator/UMD/test_disc.txt @@ -1,7 +1,21 @@ << GetUMDAuxInfo >> -TITLE title -DISC_ID serial -DISC_VERSION version -pspUmdTypes GAME -L0 length 12345 -FileSize: 12345 +disc0:/PSP_GAME/PARAM.SFO + magic: PSF + version: 1.01 + BOOTABLE: 1 + CATEGORY: UG + DISC_ID: ABCD12345 + DISC_NUMBER: 1 + DISC_TOTAL: 1 + DISC_VERSION: 1.01 + PARENTAL_LEVEL: 1 + PSP_SYSTEM_VER: 1.00 + REGION: 32768 + TITLE: title + +pspUmdTypes: 0x10 (GAME) + L0 length: 442560 (0x6c0c0) + L1 length: 276096 (0x43680) + --------------------------- + Total: 718656 (0xaf740) + FileSize: 1471807488 (0x57ba0000) diff --git a/MPF.Processors.Test/UmdImageCreatorTests.cs b/MPF.Processors.Test/UmdImageCreatorTests.cs index a7de6bea..ae7735b4 100644 --- a/MPF.Processors.Test/UmdImageCreatorTests.cs +++ b/MPF.Processors.Test/UmdImageCreatorTests.cs @@ -291,10 +291,10 @@ namespace MPF.Processors.Test { string? expectedTitle = "title"; DiscCategory? expectedCategory = DiscCategory.Games; - string? expectedSerial = "seri-al"; - string? expectedVersion = "version"; - string? expectedLayer = "12345"; - long expectedSize = 12345; + string? expectedSerial = "ABCD-12345"; + string? expectedVersion = "1.01"; + string? expectedLayer = "442560"; + long expectedSize = 1471807488; string disc = Path.Combine(Environment.CurrentDirectory, "TestData", "UmdImageCreator", "UMD", "test_disc.txt"); bool actual = UmdImageCreator.GetUMDAuxInfo(disc, diff --git a/MPF.Processors/ProcessingTool.cs b/MPF.Processors/ProcessingTool.cs index c5f6bc9f..e62fe985 100644 --- a/MPF.Processors/ProcessingTool.cs +++ b/MPF.Processors/ProcessingTool.cs @@ -375,9 +375,9 @@ namespace MPF.Processors { return category?.ToLowerInvariant() switch { - "game" => DiscCategory.Games, - "video" => DiscCategory.Video, - "audio" => DiscCategory.Audio, + "(game)" => DiscCategory.Games, + "(video)" => DiscCategory.Video, + "(audio)" => DiscCategory.Audio, _ => null, }; } diff --git a/MPF.Processors/UmdImageCreator.cs b/MPF.Processors/UmdImageCreator.cs index c2b743c9..2cd37b13 100644 --- a/MPF.Processors/UmdImageCreator.cs +++ b/MPF.Processors/UmdImageCreator.cs @@ -184,13 +184,13 @@ namespace MPF.Processors break; if (line.StartsWith("TITLE") && title == null) - title = line.Split(' ')[1]; + title = line.Substring("TITLE: ".Length); else if (line.StartsWith("DISC_ID") && version == null) serial = line.Split(' ')[1]; else if (line.StartsWith("DISC_VERSION") && version == null) version = line.Split(' ')[1]; else if (line.StartsWith("pspUmdTypes")) - category = ProcessingTool.GetUMDCategory(line.Split(' ')[1]); + category = ProcessingTool.GetUMDCategory(line.Split(' ')[2]); else if (line.StartsWith("L0 length")) layer = line.Split(' ')[2]; else if (line.StartsWith("FileSize:"))