change speechfix implementation (no "continue" anymore
authorsheepluva
Wed, 17 Dec 2014 21:01:44 +0100
changeset 10691 97f45f1374be
parent 10690 c3b73dc33294
child 10692 a88647ead05c
change speechfix implementation (no "continue" anymore
hedgewars/uRenderUtils.pas
--- a/hedgewars/uRenderUtils.pas	Wed Dec 17 19:23:57 2014 +0100
+++ b/hedgewars/uRenderUtils.pas	Wed Dec 17 21:01:44 2014 +0100
@@ -306,7 +306,7 @@
 
 function GetNextSpeechLine(s: ansistring; ldelim: char; var startFrom: LongInt; out substr: ansistring): boolean;
 var p, l, m, r: Integer;
-    newl      : boolean;
+    newl, skip: boolean;
     c         : char;
 begin
     m:= Length(s);
@@ -325,19 +325,26 @@
 
     for p:= max(1, startFrom) to m do
         begin
+
         inc(r);
+        // read char from source string
         c:= s[p];
 
         // strip empty lines, spaces and newlines on beginnings of line
-        if (newl or (p = m)) and ((c = ' ') or (c = ldelim)) then
-            continue;
+        skip:= ((newl or (p = m)) and ((c = ' ') or (c = ldelim)));
 
-        newl:= (c = ldelim);
-        if newl then
-            break;
+        if (not skip) then
+            begin
+            newl:= (c = ldelim);
+            // stop if we went past the end of the line
+            if newl then
+                break;
 
-        inc(l);
-        substr[l]:= c;
+            // copy current char to output substring
+            inc(l);
+            substr[l]:= c;
+            end;
+
         end;
 
     inc(startFrom, r);