From 684f14512c746dafb2f14cb4f029659da661dfef Mon Sep 17 00:00:00 2001 From: EscapeNumber001 <19634710+EscapeNumber001@users.noreply.github.com> Date: Fri, 9 Jun 2023 18:56:41 -0400 Subject: [PATCH] Fixed year display for songs from The Beatles Rock Band (#449) * Removed outdated todo comment * Update SongEntry.cs * Used different method for year truncation * Minor cleanup --- Assets/Script/Song/Types/SongEntry.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Assets/Script/Song/Types/SongEntry.cs b/Assets/Script/Song/Types/SongEntry.cs index ac48a9f68..528b2f5a8 100644 --- a/Assets/Script/Song/Types/SongEntry.cs +++ b/Assets/Script/Song/Types/SongEntry.cs @@ -103,6 +103,26 @@ protected SongEntry(BinaryReader reader, string folder) { AvailableParts = (ulong) reader.ReadInt64(); VocalParts = reader.ReadInt32(); CacheRoot = folder; + + // Some songs may include their full date within the Year field. This code removes the month and day from those fields. + if (Year.Length > 4) { + int yearFirstIndex = 0; + int contiguousNumCount = 0; + for (int i = 0; i < Year.Length; i++) { + if (contiguousNumCount >= 4) { + break; + } + + if (char.IsDigit(Year[i])) { + contiguousNumCount++; + } else { + contiguousNumCount = 0; + yearFirstIndex = i + 1; + } + } + int yearLastIndex = yearFirstIndex + contiguousNumCount; + Year = Year[yearFirstIndex..yearLastIndex]; + } } public void ReadCacheEnding(BinaryReader reader) {