Skip to content

Commit

Permalink
Fixed year display for songs from The Beatles Rock Band (#449)
Browse files Browse the repository at this point in the history
* Removed outdated todo comment

* Update SongEntry.cs

* Used different method for year truncation

* Minor cleanup
  • Loading branch information
EscapeNumber001 authored Jun 9, 2023
1 parent 2f5067a commit 684f145
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Assets/Script/Song/Types/SongEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 684f145

Please sign in to comment.