IOResult is a special variable
authornemo
Thu, 28 Jan 2010 20:36:24 +0000
changeset 2722 d891285e500f
parent 2721 87067dcc208b
child 2723 eaa6ac1e95ea
IOResult is a special variable
hedgewars/hwengine.pas
hedgewars/uLocale.pas
--- a/hedgewars/hwengine.pas	Thu Jan 28 19:01:57 2010 +0000
+++ b/hedgewars/hwengine.pas	Thu Jan 28 20:36:24 2010 +0000
@@ -280,7 +280,8 @@
 	if cLocaleFName <> 'en.txt' then
         begin
         // Try two letter locale first before trying specific locale overrides
-        if Length(cLocaleFName) <> 6 then LoadLocale(Pathz[ptLocale] + '/' + Copy(cLocaleFName,1,2)+'.txt');
+        if (Length(cLocaleFName) > 6) and (Copy(cLocaleFName,1,2)+'.txt' <> 'en.txt') then 
+            LoadLocale(Pathz[ptLocale] + '/' + Copy(cLocaleFName,1,2)+'.txt');
 	    LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName);
         end;
 
--- a/hedgewars/uLocale.pas	Thu Jan 28 19:01:57 2010 +0000
+++ b/hedgewars/uLocale.pas	Thu Jan 28 20:36:24 2010 +0000
@@ -58,7 +58,9 @@
     a, b, c: LongInt;
 	first: array[TEventId] of boolean;
 	e: TEventId;
+    loaded: boolean;
 begin
+loaded:= false;
 trammo[sidNothing]:= ' ';
 for e:= Low(TEventId) to High(TEventId) do first[e]:= true;
 
@@ -66,36 +68,40 @@
 filemode:= 0; // readonly
 Assign(f, FileName);
 reset(f);
-TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', false);
-while not eof(f) do
-    begin
-    readln(f, s);
-    if Length(s) = 0 then continue;
-    if not (s[1] in ['0'..'9']) then continue;
-    TryDo(Length(s) > 6, 'Load locale: empty string', true);
-    val(s[1]+s[2], a, c);
-    TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true);
-    TryDo(s[3] = ':', 'Load locale: ":" expected', true);
-    val(s[4]+s[5], b, c);
-    TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true);
-    TryDo(s[6] = '=', 'Load locale: "=" expected', true);
-    Delete(s, 1, 6);
-    case a of
-        0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b+1)]:= s;
-        1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
-        2: if (b >=0) and (b <= ord(High(TEventId))) then begin
-            TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + inttostr(a) + ':' + inttostr(b), false);
-            if first[TEventId(b)] then
-                begin
-                trevt_n[TEventId(b)]:= 0;
-                first[TEventId(b)]:= false;
-                end;
-            trevt[TEventId(b)][trevt_n[TEventId(b)]]:= s;
-            inc(trevt_n[TEventId(b)]);
-            end;
-        end;
-    end;
-Close(f)
+if IOResult = 0 then loaded:= true;
+TryDo(loaded, 'Cannot load locale "' + FileName + '"', false);
+if loaded then
+   begin
+   while not eof(f) do
+       begin
+       readln(f, s);
+       if Length(s) = 0 then continue;
+       if not (s[1] in ['0'..'9']) then continue;
+       TryDo(Length(s) > 6, 'Load locale: empty string', true);
+       val(s[1]+s[2], a, c);
+       TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true);
+       TryDo(s[3] = ':', 'Load locale: ":" expected', true);
+       val(s[4]+s[5], b, c);
+       TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true);
+       TryDo(s[6] = '=', 'Load locale: "=" expected', true);
+       Delete(s, 1, 6);
+       case a of
+           0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b+1)]:= s;
+           1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
+           2: if (b >=0) and (b <= ord(High(TEventId))) then begin
+               TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + inttostr(a) + ':' + inttostr(b), false);
+               if first[TEventId(b)] then
+                   begin
+                   trevt_n[TEventId(b)]:= 0;
+                   first[TEventId(b)]:= false;
+                   end;
+               trevt[TEventId(b)][trevt_n[TEventId(b)]]:= s;
+               inc(trevt_n[TEventId(b)]);
+               end;
+           end;
+       end;
+   Close(f)
+   end;
 {$I+}
 end;