From e5222f99929e0a893fca4ea0ffe08c3bb90fd5c3 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 28 Sep 2008 16:30:08 +0000 Subject: Songclass now reports an error if there is no linebreak in a txt file. Error is written to log. Added detailed error description to ERROR_CORRUPT_SONG Popup. Some translation may be added to this one git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1423 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/USong.pas | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/base/USong.pas') diff --git a/src/base/USong.pas b/src/base/USong.pas index 0f36662b..3679863b 100644 --- a/src/base/USong.pas +++ b/src/base/USong.pas @@ -129,6 +129,8 @@ type Mult : integer; MultBPM : integer; + LastError: String; + constructor Create (); overload; constructor Create ( const aFileName : WideString ); overload; function LoadSong: boolean; @@ -159,6 +161,8 @@ begin MultBPM := 4; fFileName := aFileName; + LastError := ''; + if fileexists( aFileName ) then begin self.Path := ExtractFilePath( aFileName ); @@ -195,9 +199,11 @@ var begin Result := false; + LastError := ''; if not FileExists(Path + PathDelim + FileName) then begin + LastError := 'File not found'; Log.LogError('File not found: "' + Path + PathDelim + FileName + '"', 'TSong.LoadSong()'); exit; end; @@ -240,7 +246,7 @@ begin begin //Song File Corrupted - No Notes CloseFile(SongFile); Log.LogError('Could not load txt File, no Notes found: ' + FileName); - Result := False; + LastError := 'Can''t find any notes'; Exit; end; Read(SongFile, TempC); @@ -361,6 +367,16 @@ begin end; CloseFile(SongFile); + + For I := 0 to High(Lines) do + begin + If ((Both) or (I = 0)) AND (Length(Lines[I].Line) < 2) then + begin + LastError := 'Can''t find any linebreaks'; + Log.LogError('Error Loading File, Can''t find any Linebreaks: "' + fFileName + '"'); + exit; + end; + end; except try CloseFile(SongFile); @@ -368,6 +384,7 @@ begin end; + LastError := 'Error reading line ' + inttostr(FileLineNo); Log.LogError('Error Loading File: "' + fFileName + '" in Line ' + inttostr(FileLineNo)); exit; end; -- cgit v1.2.3