Skip to content

Commit

Permalink
Merge pull request #868 from UltraStar-Deluxe/ignore-invalid-resolution
Browse files Browse the repository at this point in the history
Ignore invalid #RESOLUTION
  • Loading branch information
barbeque-squared authored Jul 21, 2024
2 parents 026983a + a7b136b commit 89f44e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/base/UFiles.pas
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function SaveSong(const Song: TSong; const Tracks: array of TLines; const Name:
if Song.Video.IsSet then SongFile.WriteLine('#VIDEO:' + EncodeToken(Song.Video.ToUTF8));

if Song.VideoGAP <> 0.0 then SongFile.WriteLine('#VIDEOGAP:' + FloatToStr(Song.VideoGAP));
if Song.Resolution <> 4 then SongFile.WriteLine('#RESOLUTION:' + IntToStr(Song.Resolution));
if Song.Resolution <> USong.DEFAULT_RESOLUTION then SongFile.WriteLine('#RESOLUTION:' + IntToStr(Song.Resolution));
if Song.NotesGAP <> 0 then SongFile.WriteLine('#NOTESGAP:' + IntToStr(Song.NotesGAP));
if Song.Start <> 0.0 then SongFile.WriteLine('#START:' + FloatToStr(Song.Start));
if Song.Finish <> 0 then SongFile.WriteLine('#END:' + IntToStr(Song.Finish));
Expand Down
11 changes: 9 additions & 2 deletions src/base/USong.pas
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ interface
UUnicodeStringHelper,
UUnicodeUtils;

const
DEFAULT_RESOLUTION = 4; // default #RESOLUTION

type

TSingMode = ( smNormal, smPartyClassic, smPartyFree, smPartyChallenge, smPartyTournament, smJukebox, smPlaylistRandom , smMedley );
Expand Down Expand Up @@ -971,7 +974,11 @@ function TSong.ReadTXTHeader(SongFile: TTextFileStream; ReadCustomTags: Boolean)
// Resolution
else if (Identifier = 'RESOLUTION') then
begin
TryStrtoInt(Value, self.Resolution)
TryStrtoInt(Value, self.Resolution);
if (self.Resolution < 1) then begin
Log.LogError('Ignoring invalid resolution in song: ' + FullFileName);
self.Resolution := DEFAULT_RESOLUTION;
end
end

// Notes Gap
Expand Down Expand Up @@ -1472,7 +1479,7 @@ procedure TSong.Clear();
Video := PATH_NONE;
VideoGAP := 0;
NotesGAP := 0;
Resolution := 4;
Resolution := DEFAULT_RESOLUTION;
Creator := '';
PreviewStart := 0;
CalcMedley := true;
Expand Down

0 comments on commit 89f44e7

Please sign in to comment.