hedgewars/uFLTeams.pas
author unc0rr
Thu, 10 Dec 2015 00:33:45 +0300
branchqmlfrontend
changeset 11455 0c75fa9ce340
parent 11451 321d0ce43568
child 11459 3c5d99013baf
permissions -rw-r--r--
- Use queues instead of single buffer to communicate between threads - Fix build
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     1
unit uFLTeams;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     2
interface
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     3
uses uFLTypes;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     4
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     5
function createRandomTeam: TTeam;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     6
procedure sendTeamConfig(var team: TTeam);
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
     7
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
     8
function getTeamsList: PPChar; cdecl;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
     9
procedure freeTeamsList;
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    10
10446
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
    11
function teamByName(s: shortstring): PTeam;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
    12
11449
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
    13
procedure sendTeam(var team: TTeam);
11451
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
    14
procedure removeTeam(teamName: shortstring);
11449
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
    15
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    16
implementation
11449
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
    17
uses uFLUtils, uFLIPC, uPhysFSLayer, uFLData, uFLNet;
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    18
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    19
const MAX_TEAM_NAMES = 128;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    20
var
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    21
    teamsList: PTeam;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    22
    teamsNumber: Longword;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    23
    listOfTeamNames: array[0..MAX_TEAM_NAMES] of PChar;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    24
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    25
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    26
function createRandomTeam: TTeam;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    27
var t: TTeam;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    28
    i: Longword;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    29
begin
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    30
    with t do
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    31
    begin
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    32
        teamName:= 'team' + inttostr(random(100));
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    33
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    34
        for i:= 0 to 7 do
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    35
            with hedgehogs[i] do
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    36
            begin
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    37
                name:= 'hedgehog ' + inttostr(i);
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    38
                hat:= 'NoHat'
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    39
            end;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    40
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    41
        botLevel:= 0;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    42
        hogsNumber:= 4
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    43
    end;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    44
    createRandomTeam:= t
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    45
end;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    46
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    47
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    48
procedure sendTeamConfig(var team: TTeam);
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    49
var i: Longword;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    50
begin
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    51
    with team do
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    52
    begin
10450
bf9e30b4ef9b - Store index of color instead of its value
unc0rr
parents: 10448
diff changeset
    53
        ipcToEngine('eaddteam <hash> ' + colorsSet[color] + ' ' + teamName);
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    54
        for i:= 0 to Pred(hogsNumber) do
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    55
        begin
10612
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10517
diff changeset
    56
            ipcToEngine('eaddhh ' + inttostr(botLevel) + ' 100 hog');// + hedgehogs[i].name);
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10517
diff changeset
    57
            //ipcToEngine('ehat ' + hedgehogs[i].hat);
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    58
        end;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    59
    end
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    60
end;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    61
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    62
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    63
procedure loadTeam(var team: TTeam; fileName: shortstring);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    64
var f: PFSFile;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    65
    section: LongInt;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    66
    l: shortstring;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    67
begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    68
    section:= -1;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    69
    f:= pfsOpenRead(fileName);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    70
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    71
    while (not pfsEOF(f)) do
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    72
    begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    73
        pfsReadLn(f, l);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    74
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    75
        if l = '' then
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    76
        else if l = '[Team]' then 
11450
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    77
            section:= -2
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    78
        else if copy(l, 1, 9) = '[Hedgehog' then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    79
            section:= StrToInt(copy(l, 10, 1))
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    80
        else if section = -2 then
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    81
        begin // [Team]
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    82
            if copy(l, 1, 5) = 'Name=' then
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    83
                team.teamName:= midStr(l, 6)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    84
            else if copy(l, 1, 6) = 'Grave=' then
11447
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11442
diff changeset
    85
                team.grave:= midStr(l, 7)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    86
            else if copy(l, 1, 5) = 'Fort=' then
11447
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11442
diff changeset
    87
                team.fort:= midStr(l, 6)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    88
            else if copy(l, 1, 5) = 'Flag=' then
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    89
                team.flag:= midStr(l, 6)
11450
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    90
            else if copy(l, 1, 10) = 'Voicepack=' then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    91
                team.voice:= midStr(l, 11)
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    92
            else if copy(l, 1, 11) = 'Difficulty=' then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    93
                team.botLevel:= StrToInt(midStr(l, 12))
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    94
        end else if (section >= 0) and (section <= 7) then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    95
        begin // [Hedgehog*]
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    96
            if copy(l, 1, 5) = 'Name=' then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    97
                team.hedgehogs[section].name:= midStr(l, 6)
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    98
            else if copy(l, 1, 4) = 'Hat=' then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    99
                team.hedgehogs[section].hat:= midStr(l, 5)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   100
        end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   101
    end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   102
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   103
    pfsClose(f)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   104
end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   105
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   106
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   107
procedure loadTeams;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   108
var filesList, tmp: PPChar;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   109
    team: PTeam;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   110
    s: shortstring;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   111
    l: Longword;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   112
begin
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   113
    filesList:= pfsEnumerateFiles('/Config/Teams');
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   114
    teamsNumber:= 0;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   115
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   116
    tmp:= filesList;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   117
    while tmp^ <> nil do
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   118
    begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   119
        s:= shortstring(tmp^);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   120
        l:= length(s);
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   121
        if (l > 4) and (copy(s, l - 3, 4) = '.hwt') then inc(teamsNumber);
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   122
        inc(tmp)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   123
    end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   124
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   125
    // TODO: no teams at all?
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   126
    teamsList:= GetMem(sizeof(teamsList^) * teamsNumber);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   127
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   128
    team:= teamsList;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   129
    tmp:= filesList;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   130
    while tmp^ <> nil do
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   131
    begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   132
        s:= shortstring(tmp^);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   133
        l:= length(s);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   134
        if (l > 4) and (copy(s, l - 3, 4) = '.hwt') then 
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   135
            begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   136
                loadTeam(team^, '/Config/Teams/' + s);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   137
                inc(team)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   138
            end;
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   139
        inc(tmp)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   140
    end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   141
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   142
    pfsFreeList(filesList)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   143
end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   144
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   145
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   146
function getTeamsList: PPChar; cdecl;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   147
var i, t, l: Longword;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   148
    team: PTeam;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   149
begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   150
    if teamsList = nil then
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   151
        loadTeams;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   152
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   153
    t:= teamsNumber;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   154
    if t >= MAX_TEAM_NAMES then 
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   155
        t:= MAX_TEAM_NAMES;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   156
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   157
    team:= teamsList;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   158
    for i:= 0 to Pred(t) do
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   159
    begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   160
        l:= length(team^.teamName);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   161
        if l >= 255 then l:= 254;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   162
        team^.teamName[l + 1]:= #0;
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   163
        listOfTeamNames[i]:= @team^.teamName[1];
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   164
        inc(team)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   165
    end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   166
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   167
    listOfTeamNames[t]:= nil;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   168
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   169
    getTeamsList:= listOfTeamNames
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   170
end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   171
10446
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   172
function teamByName(s: shortstring): PTeam;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   173
var i: Longword;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   174
    team: PTeam;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   175
begin
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   176
    team:= teamsList;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   177
    i:= 0;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   178
    while (i < teamsNumber) and (team^.teamName <> s) do
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   179
    begin
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   180
        inc(team);
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   181
        inc(i)
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   182
    end;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   183
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   184
    if i < teamsNumber then teamByName:= team else teamByName:= nil
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   185
end;
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   186
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   187
procedure freeTeamsList;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   188
begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   189
    if teamsList <> nil then
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   190
        FreeMem(teamsList, sizeof(teamsList^) * teamsNumber)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   191
end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   192
11449
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   193
procedure sendTeam(var team: TTeam);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   194
var i: Longword;
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   195
begin
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   196
    with team do
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   197
    begin
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   198
        sendNetLn('ADD_TEAM');
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   199
        sendNetLn(teamName);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   200
        sendNetLn(IntToStr(color));
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   201
        sendNetLn(grave);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   202
        sendNetLn(fort);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   203
        sendNetLn(voice);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   204
        sendNetLn(flag);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   205
        sendNetLn(IntToStr(botLevel));
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   206
        for i := 0 to 7 do
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   207
        begin
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   208
            sendNetLn(hedgehogs[i].name);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   209
            sendNetLn(hedgehogs[i].hat);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   210
        end;
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   211
        sendNetLn('')
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   212
    end;
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   213
end;
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   214
11451
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   215
procedure removeTeam(teamName: shortstring);
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   216
begin
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   217
    sendNetLn('REMOVE_TEAM');
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   218
    sendNet(teamName)
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   219
end;
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   220
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
   221
end.