diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-01-12 22:42:45 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-01-12 22:42:45 +0000 |
commit | b11259674b78bc872c08d3f2d554ede56543e954 (patch) | |
tree | c089a8ea445aaf12b62d0779b83a4cf65fb3e00c /unicode/src/base | |
parent | 2e66e4bb6719e92c53bcbf40c82bf5d7644719cb (diff) | |
download | usdx-b11259674b78bc872c08d3f2d554ede56543e954.tar.gz usdx-b11259674b78bc872c08d3f2d554ede56543e954.tar.xz usdx-b11259674b78bc872c08d3f2d554ede56543e954.zip |
patch from hannibal218bc:
- DEBUG: fix program hang on empty Value in header of TXT song; now log an ERROR about it
- COSMETIC: output full song path when reporting errors while reading TXT songs
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1568 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'unicode/src/base')
-rw-r--r-- | unicode/src/base/USong.pas | 252 |
1 files changed, 130 insertions, 122 deletions
diff --git a/unicode/src/base/USong.pas b/unicode/src/base/USong.pas index ac134350..69c6615d 100644 --- a/unicode/src/base/USong.pas +++ b/unicode/src/base/USong.pas @@ -725,7 +725,8 @@ begin if (Length(Line) <= 0) then begin - Log.LogError('File Starts with Empty Line: ' + aFileName); + Log.LogError('File Starts with Empty Line: ' + Path + PathDelim + aFileName, + 'TSong.ReadTXTHeader'); Result := False; Exit; end; @@ -752,154 +753,161 @@ begin //Check the Identifier (If Value is given) if (Length(Value) = 0) then - Continue; - - //----------- - //Required Attributes - //----------- - - if (Identifier = 'TITLE') then begin - self.Title := RecodeStringUTF8(Value, Encoding); - - //Add Title Flag to Done - Done := Done or 1; + Log.LogError('Empty field "'+Identifier+'" in file ' + Path + PathDelim + aFileName, + 'TSong.ReadTXTHeader'); end - - else if (Identifier = 'ARTIST') then + else begin - self.Artist := RecodeStringUTF8(Value, Encoding); + + //----------- + //Required Attributes + //----------- - //Add Artist Flag to Done - Done := Done or 2; - end + if (Identifier = 'TITLE') then + begin + self.Title := RecodeStringUTF8(Value, Encoding); - //MP3 File - else if (Identifier = 'MP3') then - begin - EncFile := EncodeFilename(Value); - if (FileExists(self.Path + EncFile)) then + //Add Title Flag to Done + Done := Done or 1; + end + + else if (Identifier = 'ARTIST') then begin - self.Mp3 := EncFile; + self.Artist := RecodeStringUTF8(Value, Encoding); - //Add Mp3 Flag to Done - Done := Done or 4; - end; - end + //Add Artist Flag to Done + Done := Done or 2; + end - //Beats per Minute - else if (Identifier = 'BPM') then - begin - SetLength(self.BPM, 1); - self.BPM[0].StartBeat := 0; + //MP3 File + else if (Identifier = 'MP3') then + begin + EncFile := EncodeFilename(Value); + if (FileExists(self.Path + EncFile)) then + begin + self.Mp3 := EncFile; - self.BPM[0].BPM := StrToFloatI18n( Value ) * Mult * MultBPM; + //Add Mp3 Flag to Done + Done := Done or 4; + end; + end - if self.BPM[0].BPM <> 0 then + //Beats per Minute + else if (Identifier = 'BPM') then begin - //Add BPM Flag to Done - Done := Done or 8; - end; - end + SetLength(self.BPM, 1); + self.BPM[0].StartBeat := 0; - //--------- - //Additional Header Information - //--------- + self.BPM[0].BPM := StrToFloatI18n( Value ) * Mult * MultBPM; - // Gap - else if (Identifier = 'GAP') then - begin - self.GAP := StrToFloatI18n(Value); - end + if self.BPM[0].BPM <> 0 then + begin + //Add BPM Flag to Done + Done := Done or 8; + end; + end - //Cover Picture - else if (Identifier = 'COVER') then - begin - self.Cover := EncodeFilename(Value); - end + //--------- + //Additional Header Information + //--------- - //Background Picture - else if (Identifier = 'BACKGROUND') then - begin - self.Background := EncodeFilename(Value); - end + // Gap + else if (Identifier = 'GAP') then + begin + self.GAP := StrToFloatI18n(Value); + end - // Video File - else if (Identifier = 'VIDEO') then - begin - EncFile := EncodeFilename(Value); - if (FileExists(self.Path + EncFile)) then - self.Video := EncFile - else - Log.LogError('Can''t find Video File in Song: ' + aFileName); - end + //Cover Picture + else if (Identifier = 'COVER') then + begin + self.Cover := EncodeFilename(Value); + end - // Video Gap - else if (Identifier = 'VIDEOGAP') then - begin - self.VideoGAP := StrToFloatI18n( Value ) - end + //Background Picture + else if (Identifier = 'BACKGROUND') then + begin + self.Background := EncodeFilename(Value); + end - //Genre Sorting - else if (Identifier = 'GENRE') then - begin - self.Genre := RecodeStringUTF8(Value, Encoding) - end + // Video File + else if (Identifier = 'VIDEO') then + begin + EncFile := EncodeFilename(Value); + if (FileExists(self.Path + EncFile)) then + self.Video := EncFile + else + Log.LogError('Can''t find Video File in Song: ' + aFileName); + end - //Edition Sorting - else if (Identifier = 'EDITION') then - begin - self.Edition := RecodeStringUTF8(Value, Encoding) - end + // Video Gap + else if (Identifier = 'VIDEOGAP') then + begin + self.VideoGAP := StrToFloatI18n( Value ) + end - //Creator Tag - else if (Identifier = 'CREATOR') then - begin - self.Creator := RecodeStringUTF8(Value, Encoding) - end + //Genre Sorting + else if (Identifier = 'GENRE') then + begin + self.Genre := RecodeStringUTF8(Value, Encoding) + end - //Language Sorting - else if (Identifier = 'LANGUAGE') then - begin - self.Language := RecodeStringUTF8(Value, Encoding) - end + //Edition Sorting + else if (Identifier = 'EDITION') then + begin + self.Edition := RecodeStringUTF8(Value, Encoding) + end - // Song Start - else if (Identifier = 'START') then - begin - self.Start := StrToFloatI18n( Value ) - end + //Creator Tag + else if (Identifier = 'CREATOR') then + begin + self.Creator := RecodeStringUTF8(Value, Encoding) + end - // Song Ending - else if (Identifier = 'END') then - begin - TryStrtoInt(Value, self.Finish) - end + //Language Sorting + else if (Identifier = 'LANGUAGE') then + begin + self.Language := RecodeStringUTF8(Value, Encoding) + end - // Resolution - else if (Identifier = 'RESOLUTION') then - begin - TryStrtoInt(Value, self.Resolution) - end + // Song Start + else if (Identifier = 'START') then + begin + self.Start := StrToFloatI18n( Value ) + end - // Notes Gap - else if (Identifier = 'NOTESGAP') then - begin - TryStrtoInt(Value, self.NotesGAP) - end + // Song Ending + else if (Identifier = 'END') then + begin + TryStrtoInt(Value, self.Finish) + end - // Relative Notes - else if (Identifier = 'RELATIVE') then - begin - if (UpperCase(Value) = 'YES') then - self.Relative := True; - end + // Resolution + else if (Identifier = 'RESOLUTION') then + begin + TryStrtoInt(Value, self.Resolution) + end - // File encoding - else if (Identifier = 'ENCODING') then - begin - self.Encoding := ParseEncoding(Value, Ini.EncodingDefault); - end; + // Notes Gap + else if (Identifier = 'NOTESGAP') then + begin + TryStrtoInt(Value, self.NotesGAP) + end + + // Relative Notes + else if (Identifier = 'RELATIVE') then + begin + if (UpperCase(Value) = 'YES') then + self.Relative := True; + end + + // File encoding + else if (Identifier = 'ENCODING') then + begin + self.Encoding := ParseEncoding(Value, Ini.EncodingDefault); + end; + + end; // End check for non-empty Value // check for end of file if Eof(SongFile) then |