aboutsummaryrefslogtreecommitdiffstats
path: root/Lua/src/base/USong.pas
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-12-13 13:35:42 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-12-13 13:35:42 +0000
commite8ab3f4e919d31b51a44c1eb0248b2bac1f16e57 (patch)
tree2efbdd16be5a504a86c5af7fe1cf0fd9e6681f11 /Lua/src/base/USong.pas
parentd01178ee3ae797e07894434cbdeaae9e206e4d3b (diff)
downloadusdx-e8ab3f4e919d31b51a44c1eb0248b2bac1f16e57.tar.gz
usdx-e8ab3f4e919d31b51a44c1eb0248b2bac1f16e57.tar.xz
usdx-e8ab3f4e919d31b51a44c1eb0248b2bac1f16e57.zip
merged trunk r2026 into lua branch
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@2027 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Lua/src/base/USong.pas')
-rw-r--r--Lua/src/base/USong.pas28
1 files changed, 19 insertions, 9 deletions
diff --git a/Lua/src/base/USong.pas b/Lua/src/base/USong.pas
index c465f198..fccf2757 100644
--- a/Lua/src/base/USong.pas
+++ b/Lua/src/base/USong.pas
@@ -96,7 +96,7 @@ type
function ParseLyricStringParam(const Line: RawByteString; var LinePos: integer): RawByteString;
function ParseLyricIntParam(const Line: RawByteString; var LinePos: integer): integer;
- function ParseLyricFloatParam(const Line: RawByteString; var LinePos: integer): real;
+ function ParseLyricFloatParam(const Line: RawByteString; var LinePos: integer): extended;
function ParseLyricCharParam(const Line: RawByteString; var LinePos: integer): AnsiChar;
function ParseLyricText(const Line: RawByteString; var LinePos: integer): RawByteString;
@@ -346,24 +346,26 @@ var
begin
OldLinePos := LinePos;
Str := ParseLyricStringParam(Line, LinePos);
- try
- Result := StrToInt(Str);
- except // on EConvertError
+
+ if not TryStrToInt(Str, Result) then
+ begin // on convert error
+ Result := 0;
LinePos := OldLinePos;
raise EUSDXParseException.Create('Integer expected');
end;
end;
-function TSong.ParseLyricFloatParam(const Line: RawByteString; var LinePos: integer): real;
+function TSong.ParseLyricFloatParam(const Line: RawByteString; var LinePos: integer): extended;
var
Str: RawByteString;
OldLinePos: integer;
begin
OldLinePos := LinePos;
Str := ParseLyricStringParam(Line, LinePos);
- try
- Result := StrToFloat(Str);
- except // on EConvertError
+
+ if not TryStrToFloat(Str, Result) then
+ begin // on convert error
+ Result := 0;
LinePos := OldLinePos;
raise EUSDXParseException.Create('Float expected');
end;
@@ -378,6 +380,14 @@ begin
Str := ParseLyricStringParam(Line, LinePos);
if (Length(Str) <> 1) then
begin
+ { to-do : decide what to do here
+ usdx < 1.1 does not nead a whitespace after a char param
+ so we may just write a warning to error.log and use the
+ first non whitespace character instead of raising an
+ exception that causes the song not to load. So the more
+ error resistant code is:
+ LinePos := OldLinePos + 1;
+ // raise EUSDXParseException.Create('Character expected'); }
LinePos := OldLinePos;
raise EUSDXParseException.Create('Character expected');
end;
@@ -483,7 +493,7 @@ begin
while true do
begin
- LinePos := 0;
+ LinePos := 1;
Param0 := ParseLyricCharParam(CurLine, LinePos);
if (Param0 = 'E') then