Add a dot to CD labels when longer than 8 characters

This commit is contained in:
maron2000 2025-03-15 21:12:38 +09:00
parent c6ef650655
commit e1d74ab354
2 changed files with 6 additions and 4 deletions

View File

@ -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++;

View File

@ -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)