Skip to content

Commit

Permalink
less hardcoding of default #RESOLUTION value
Browse files Browse the repository at this point in the history
  • Loading branch information
barbeque-squared committed Jul 14, 2024
1 parent 33d4ac7 commit a7b136b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/base/UFiles.pas
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +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.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
9 changes: 5 additions & 4 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 @@ -973,9 +976,8 @@ function TSong.ReadTXTHeader(SongFile: TTextFileStream; ReadCustomTags: Boolean)
begin
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;
self.Resolution := DEFAULT_RESOLUTION;
end
end

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

0 comments on commit a7b136b

Please sign in to comment.