From e1d74ab354b688277f6dab6454f69ca960582ab2 Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Sat, 15 Mar 2025 21:12:38 +0900 Subject: [PATCH] Add a dot to CD labels when longer than 8 characters --- src/dos/drives.cpp | 6 ++++-- tests/drives_tests.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dos/drives.cpp b/src/dos/drives.cpp index 3ab038664..c6841adcd 100644 --- a/src/dos/drives.cpp +++ b/src/dos/drives.cpp @@ -298,10 +298,12 @@ void Set_Label(char const * const input, char * const output, bool cdrom) { strncpy(upcasebuf, input, 11); //DBCS_upcase(upcasebuf); /* Another mscdex quirk. Label is not always uppercase. (Daggerfall) */ - (void)cdrom; - while (togo > 0) { if(upcasebuf[vnamePos] == 0) str_end = true; + else if(cdrom && vnamePos == 8 && !str_end && upcasebuf[vnamePos] != '.') { + output[labelPos] = '.'; // add a dot between 8th and 9th character (Descent 2 installer needs this) + labelPos++; + } output[labelPos] = !str_end ? upcasebuf[vnamePos] : 0x0; // Pad empty characters with 0x00 labelPos++; vnamePos++; diff --git a/tests/drives_tests.cpp b/tests/drives_tests.cpp index 60986c309..3b9d1728b 100644 --- a/tests/drives_tests.cpp +++ b/tests/drives_tests.cpp @@ -113,7 +113,7 @@ TEST(Set_Label, Daggerfall) TEST(Set_Label, DaggerfallCD) { std::string output = run_Set_Label("Daggerfall", true); - EXPECT_EQ("Daggerfall", output); + EXPECT_EQ("Daggerfa.ll", output); } TEST(Set_Label, LongerThan11) @@ -124,7 +124,7 @@ TEST(Set_Label, LongerThan11) TEST(Set_Label, LongerThan11CD) { std::string output = run_Set_Label("a123456789AAA", true); - EXPECT_EQ("a123456789A", output); + EXPECT_EQ("a1234567.89A", output); } TEST(Set_Label, ShorterThan8)