hedgewars/uFLTeams.pas
branchqmlfrontend
changeset 10442 c58db813240b
parent 10440 b74a7bbe224e
child 10446 7ae44f42a689
equal deleted inserted replaced
10440:b74a7bbe224e 10442:c58db813240b
    94 var filesList, tmp: PPChar;
    94 var filesList, tmp: PPChar;
    95     team: PTeam;
    95     team: PTeam;
    96     s: shortstring;
    96     s: shortstring;
    97     l: Longword;
    97     l: Longword;
    98 begin
    98 begin
    99     filesList:= pfsEnumerateFiles('Teams');
    99     filesList:= pfsEnumerateFiles('/Config/Teams');
   100     teamsNumber:= 0;
   100     teamsNumber:= 0;
   101 
   101 
   102     tmp:= filesList;
   102     tmp:= filesList;
   103     while tmp^ <> nil do
   103     while tmp^ <> nil do
   104     begin
   104     begin
   105         s:= shortstring(tmp^);
   105         s:= shortstring(tmp^);
       
   106         writeln(stderr, '> ', s);
   106         l:= length(s);
   107         l:= length(s);
   107         if (l > 4) and (copy(s, l - 3, 4) = '.hwt') then inc(teamsNumber)
   108         if (l > 4) and (copy(s, l - 3, 4) = '.hwt') then inc(teamsNumber);
       
   109         inc(tmp)
   108     end;
   110     end;
   109 
   111 
   110     // TODO: no teams at all?
   112     // TODO: no teams at all?
   111     teamsList:= GetMem(sizeof(teamsList^) * teamsNumber);
   113     teamsList:= GetMem(sizeof(teamsList^) * teamsNumber);
   112 
   114 
   119         if (l > 4) and (copy(s, l - 3, 4) = '.hwt') then 
   121         if (l > 4) and (copy(s, l - 3, 4) = '.hwt') then 
   120             begin
   122             begin
   121                 loadTeam(team^, '/Config/Teams/' + s);
   123                 loadTeam(team^, '/Config/Teams/' + s);
   122                 inc(team)
   124                 inc(team)
   123             end;
   125             end;
       
   126         inc(tmp)
   124     end;
   127     end;
   125 
   128 
   126     pfsFreeList(filesList)
   129     pfsFreeList(filesList)
   127 end;
   130 end;
   128 
   131 
   142     for i:= 0 to Pred(t) do
   145     for i:= 0 to Pred(t) do
   143     begin
   146     begin
   144         l:= length(team^.teamName);
   147         l:= length(team^.teamName);
   145         if l >= 255 then l:= 254;
   148         if l >= 255 then l:= 254;
   146         team^.teamName[l + 1]:= #0;
   149         team^.teamName[l + 1]:= #0;
   147         listOfTeamNames[i]:= @team^.teamName[1]
   150         listOfTeamNames[i]:= @team^.teamName[1];
       
   151         inc(team)
   148     end;
   152     end;
   149 
   153 
   150     listOfTeamNames[t]:= nil;
   154     listOfTeamNames[t]:= nil;
   151 
   155 
   152     getTeamsList:= listOfTeamNames
   156     getTeamsList:= listOfTeamNames