hedgewars/uFLTeams.pas
branchqmlfrontend
changeset 10446 7ae44f42a689
parent 10442 c58db813240b
child 10448 4cb727e029fa
equal deleted inserted replaced
10444:47a6231f1fc1 10446:7ae44f42a689
     5 function createRandomTeam: TTeam;
     5 function createRandomTeam: TTeam;
     6 procedure sendTeamConfig(var team: TTeam);
     6 procedure sendTeamConfig(var team: TTeam);
     7 
     7 
     8 function getTeamsList: PPChar; cdecl;
     8 function getTeamsList: PPChar; cdecl;
     9 procedure freeTeamsList;
     9 procedure freeTeamsList;
       
    10 
       
    11 function teamByName(s: shortstring): PTeam;
    10 
    12 
    11 implementation
    13 implementation
    12 uses uFLUtils, uFLIPC, uPhysFSLayer;
    14 uses uFLUtils, uFLIPC, uPhysFSLayer;
    13 
    15 
    14 const MAX_TEAM_NAMES = 128;
    16 const MAX_TEAM_NAMES = 128;
   154     listOfTeamNames[t]:= nil;
   156     listOfTeamNames[t]:= nil;
   155 
   157 
   156     getTeamsList:= listOfTeamNames
   158     getTeamsList:= listOfTeamNames
   157 end;
   159 end;
   158 
   160 
       
   161 function teamByName(s: shortstring): PTeam;
       
   162 var i: Longword;
       
   163     team: PTeam;
       
   164 begin
       
   165     team:= teamsList;
       
   166     i:= 0;
       
   167     while (i < teamsNumber) and (team^.teamName <> s) do
       
   168     begin
       
   169         inc(team);
       
   170         inc(i)
       
   171     end;
       
   172 
       
   173     if i < teamsNumber then teamByName:= team else teamByName:= nil
       
   174 end;
   159 
   175 
   160 procedure freeTeamsList;
   176 procedure freeTeamsList;
   161 begin
   177 begin
   162     if teamsList <> nil then
   178     if teamsList <> nil then
   163         FreeMem(teamsList, sizeof(teamsList^) * teamsNumber)
   179         FreeMem(teamsList, sizeof(teamsList^) * teamsNumber)