From 0df43e29d3d12f93fd4ace638cfb60b65dd32262 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 23 May 2007 17:00:52 +0000 Subject: Fixed a Bug that can cause the application crashes, when Song Data is missing. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@226 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UFiles.pas | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'Game/Code') diff --git a/Game/Code/Classes/UFiles.pas b/Game/Code/Classes/UFiles.pas index aa336233..ee1935cd 100644 --- a/Game/Code/Classes/UFiles.pas +++ b/Game/Code/Classes/UFiles.pas @@ -239,9 +239,12 @@ begin end // Video File - else if (Identifier = 'VIDEO') AND (FileExists(Song.Path + Value)) then + else if (Identifier = 'VIDEO') then begin - Song.Video := Value; + if (FileExists(Song.Path + Value)) then + Song.Video := Value + else + Log.LogError('Can''t find Video File in Song: ' + Song.Path + Song.FileName); end // Video Gap @@ -579,6 +582,7 @@ begin Result := ReadTxTHeader(AktSong); if not Result then begin + CloseFile(SongFile); Log.LogError('Error Loading SongHeader, abort Song Loading'); Exit; end; @@ -594,6 +598,7 @@ begin if (EoF(SongFile)) then begin //Song File Corrupted - No Notes + CloseFile(SongFile); Log.LogError('Could not load txt File, no Notes found: ' + Name); Result := False; Exit; @@ -617,7 +622,6 @@ begin // TempC := Tekst[1]; // read from backup variable, don't use default ':' value while (TempC <> 'E') AND (not EOF(SongFile)) do begin - Inc(FileLineNo); if (TempC = ':') or (TempC = '*') or (TempC = 'F') then begin // wczytuje nute Read(SongFile, Param1); @@ -688,10 +692,17 @@ begin end; Read(SongFile, TempC); + Inc(FileLineNo); end; // while} CloseFile(SongFile); except + try + CloseFile(SongFile); + except + + end; + Log.LogError('Error Loading File: "' + Name + '" in Line ' + inttostr(FileLineNo)); exit; end; -- cgit v1.2.3