Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore invalid #RESOLUTION #868

Merged
merged 2 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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