Skip to content

Commit

Permalink
ignore invalid #RESOLUTION. fixes #859
Browse files Browse the repository at this point in the history
  • Loading branch information
barbeque-squared committed Jul 14, 2024
1 parent f6d812c commit 33d4ac7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/base/UFiles.pas
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +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));
// TODO: this default also appears in USong.ReadTXTHeader and USong.Clear
if Song.Resolution <> 4 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));
Expand Down
8 changes: 7 additions & 1 deletion src/base/USong.pas
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,12 @@ 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
// TODO: this hardcoded default also appears in Clear and UFiles.SaveSong
Log.LogError('Ignoring invalid resolution in song: ' + FullFileName);
self.Resolution := 4;
end
end

// Notes Gap
Expand Down Expand Up @@ -1472,6 +1477,7 @@ procedure TSong.Clear();
Video := PATH_NONE;
VideoGAP := 0;
NotesGAP := 0;
// TODO: this default also appears in ReadTXTHeader and UFiles.SaveSong
Resolution := 4;
Creator := '';
PreviewStart := 0;
Expand Down

0 comments on commit 33d4ac7

Please sign in to comment.