hedgewars/uLocale.pas
changeset 2721 87067dcc208b
parent 2717 2b75ef82676d
child 2722 d891285e500f
equal deleted inserted replaced
2720:a5111ec4d25f 2721:87067dcc208b
    65 {$I-} // iochecks off
    65 {$I-} // iochecks off
    66 filemode:= 0; // readonly
    66 filemode:= 0; // readonly
    67 Assign(f, FileName);
    67 Assign(f, FileName);
    68 reset(f);
    68 reset(f);
    69 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', false);
    69 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', false);
    70 if (IOResult <> 0) then
    70 while not eof(f) do
    71    begin
    71     begin
    72    while not eof(f) do
    72     readln(f, s);
    73        begin
    73     if Length(s) = 0 then continue;
    74        readln(f, s);
    74     if not (s[1] in ['0'..'9']) then continue;
    75        if Length(s) = 0 then continue;
    75     TryDo(Length(s) > 6, 'Load locale: empty string', true);
    76        if not (s[1] in ['0'..'9']) then continue;
    76     val(s[1]+s[2], a, c);
    77        TryDo(Length(s) > 6, 'Load locale: empty string', true);
    77     TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true);
    78        val(s[1]+s[2], a, c);
    78     TryDo(s[3] = ':', 'Load locale: ":" expected', true);
    79        TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true);
    79     val(s[4]+s[5], b, c);
    80        TryDo(s[3] = ':', 'Load locale: ":" expected', true);
    80     TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true);
    81        val(s[4]+s[5], b, c);
    81     TryDo(s[6] = '=', 'Load locale: "=" expected', true);
    82        TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true);
    82     Delete(s, 1, 6);
    83        TryDo(s[6] = '=', 'Load locale: "=" expected', true);
    83     case a of
    84        Delete(s, 1, 6);
    84         0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b+1)]:= s;
    85        case a of
    85         1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
    86            0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b+1)]:= s;
    86         2: if (b >=0) and (b <= ord(High(TEventId))) then begin
    87            1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s;
    87             TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + inttostr(a) + ':' + inttostr(b), false);
    88            2: if (b >=0) and (b <= ord(High(TEventId))) then begin
    88             if first[TEventId(b)] then
    89                TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + inttostr(a) + ':' + inttostr(b), false);
    89                 begin
    90                if first[TEventId(b)] then
    90                 trevt_n[TEventId(b)]:= 0;
    91                    begin
    91                 first[TEventId(b)]:= false;
    92                    trevt_n[TEventId(b)]:= 0;
    92                 end;
    93                    first[TEventId(b)]:= false;
    93             trevt[TEventId(b)][trevt_n[TEventId(b)]]:= s;
    94                    end;
    94             inc(trevt_n[TEventId(b)]);
    95                trevt[TEventId(b)][trevt_n[TEventId(b)]]:= s;
    95             end;
    96                inc(trevt_n[TEventId(b)]);
    96         end;
    97                end;
    97     end;
    98            end;
    98 Close(f)
    99        end;
       
   100    Close(f)
       
   101    end
       
   102 {$I+}
    99 {$I+}
   103 end;
   100 end;
   104 
   101 
   105 function GetEventString(e: TEventId): string;
   102 function GetEventString(e: TEventId): string;
   106 begin
   103 begin