hedgewars/uFLTeams.pas
author unc0rr
Thu, 11 Aug 2016 23:05:14 +0300
branchqmlfrontend
changeset 11848 01f88c3b7b66
parent 11463 8318e841648f
permissions -rw-r--r--
Make in-game chat work
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;
11463
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
     6
procedure sendTeamConfig(hp: LongInt; var team: TTeam);
10434
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
11461
ab77e2ea2f82 uFLData was renamed, update "uses"
sheepluva
parents: 11460
diff changeset
    17
uses uFLUtils, uFLIPC, uPhysFSLayer, uFLThemes, 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
11463
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    48
procedure sendTeamConfig(hp: LongInt; var team: TTeam);
10434
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);
11460
96decedd9400 Fix command sent to engine so it works for real
unc0rr
parents: 11459
diff changeset
    54
11459
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
    55
        if extDriven then
11460
96decedd9400 Fix command sent to engine so it works for real
unc0rr
parents: 11459
diff changeset
    56
            ipcToEngine('erdriven');
96decedd9400 Fix command sent to engine so it works for real
unc0rr
parents: 11459
diff changeset
    57
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    58
        for i:= 0 to Pred(hogsNumber) do
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    59
        begin
11463
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    60
            ipcToEngine('eaddhh ' + IntToStr(botLevel) + ' ' + IntToStr(hp) + ' ' + hedgehogs[i].name);
11459
3c5d99013baf - Improve IPC handling in engine
unc0rr
parents: 11451
diff changeset
    61
            ipcToEngine('ehat ' + hedgehogs[i].hat);
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    62
        end;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    63
    end
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    64
end;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
    65
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    66
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    67
procedure loadTeam(var team: TTeam; fileName: shortstring);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    68
var f: PFSFile;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    69
    section: LongInt;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    70
    l: shortstring;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    71
begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    72
    section:= -1;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    73
    f:= pfsOpenRead(fileName);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    74
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    75
    while (not pfsEOF(f)) do
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    76
    begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    77
        pfsReadLn(f, l);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    78
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    79
        if l = '' then
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    80
        else if l = '[Team]' then 
11450
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    81
            section:= -2
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    82
        else if copy(l, 1, 9) = '[Hedgehog' then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    83
            section:= StrToInt(copy(l, 10, 1))
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    84
        else if section = -2 then
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    85
        begin // [Team]
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    86
            if copy(l, 1, 5) = 'Name=' then
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    87
                team.teamName:= midStr(l, 6)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    88
            else if copy(l, 1, 6) = 'Grave=' then
11447
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11442
diff changeset
    89
                team.grave:= midStr(l, 7)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    90
            else if copy(l, 1, 5) = 'Fort=' then
11447
6b04a266feee - Accept team and team color from net
unc0rr
parents: 11442
diff changeset
    91
                team.fort:= midStr(l, 6)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    92
            else if copy(l, 1, 5) = 'Flag=' then
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
    93
                team.flag:= midStr(l, 6)
11450
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    94
            else if copy(l, 1, 10) = 'Voicepack=' then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    95
                team.voice:= midStr(l, 11)
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    96
            else if copy(l, 1, 11) = 'Difficulty=' then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    97
                team.botLevel:= StrToInt(midStr(l, 12))
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    98
        end else if (section >= 0) and (section <= 7) then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
    99
        begin // [Hedgehog*]
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
   100
            if copy(l, 1, 5) = 'Name=' then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
   101
                team.hedgehogs[section].name:= midStr(l, 6)
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
   102
            else if copy(l, 1, 4) = 'Hat=' then
465b4db35232 Load full team config from file
unc0rr
parents: 11449
diff changeset
   103
                team.hedgehogs[section].hat:= midStr(l, 5)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   104
        end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   105
    end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   106
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   107
    pfsClose(f)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   108
end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   109
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   110
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   111
procedure loadTeams;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   112
var filesList, tmp: PPChar;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   113
    team: PTeam;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   114
    s: shortstring;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   115
    l: Longword;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   116
begin
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   117
    filesList:= pfsEnumerateFiles('/Config/Teams');
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   118
    teamsNumber:= 0;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   119
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   120
    tmp:= filesList;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   121
    while tmp^ <> nil do
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   122
    begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   123
        s:= shortstring(tmp^);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   124
        l:= length(s);
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   125
        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
   126
        inc(tmp)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   127
    end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   128
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   129
    // TODO: no teams at all?
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   130
    teamsList:= GetMem(sizeof(teamsList^) * teamsNumber);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   131
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   132
    team:= teamsList;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   133
    tmp:= filesList;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   134
    while tmp^ <> nil do
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   135
    begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   136
        s:= shortstring(tmp^);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   137
        l:= length(s);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   138
        if (l > 4) and (copy(s, l - 3, 4) = '.hwt') then 
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   139
            begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   140
                loadTeam(team^, '/Config/Teams/' + s);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   141
                inc(team)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   142
            end;
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   143
        inc(tmp)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   144
    end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   145
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   146
    pfsFreeList(filesList)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   147
end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   148
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   149
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   150
function getTeamsList: PPChar; cdecl;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   151
var i, t, l: Longword;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   152
    team: PTeam;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   153
begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   154
    if teamsList = nil then
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   155
        loadTeams;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   156
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   157
    t:= teamsNumber;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   158
    if t >= MAX_TEAM_NAMES then 
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   159
        t:= MAX_TEAM_NAMES;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   160
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   161
    team:= teamsList;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   162
    for i:= 0 to Pred(t) do
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   163
    begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   164
        l:= length(team^.teamName);
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   165
        if l >= 255 then l:= 254;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   166
        team^.teamName[l + 1]:= #0;
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   167
        listOfTeamNames[i]:= @team^.teamName[1];
c58db813240b Load and show local teams list
unc0rr
parents: 10440
diff changeset
   168
        inc(team)
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   169
    end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   170
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   171
    listOfTeamNames[t]:= nil;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   172
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   173
    getTeamsList:= listOfTeamNames
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   174
end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   175
10446
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   176
function teamByName(s: shortstring): PTeam;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   177
var i: Longword;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   178
    team: PTeam;
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
    team:= teamsList;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   181
    i:= 0;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   182
    while (i < teamsNumber) and (team^.teamName <> s) do
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   183
    begin
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   184
        inc(team);
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   185
        inc(i)
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   186
    end;
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   187
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   188
    if i < teamsNumber then teamByName:= team else teamByName:= nil
7ae44f42a689 Perform some checks on team add
unc0rr
parents: 10442
diff changeset
   189
end;
10440
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   190
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   191
procedure freeTeamsList;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   192
begin
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   193
    if teamsList <> nil then
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   194
        FreeMem(teamsList, sizeof(teamsList^) * teamsNumber)
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   195
end;
b74a7bbe224e - Implement getTeamsList (not tested)
unc0rr
parents: 10434
diff changeset
   196
11449
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   197
procedure sendTeam(var team: TTeam);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   198
var i: Longword;
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   199
begin
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   200
    with team do
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   201
    begin
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   202
        sendNetLn('ADD_TEAM');
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   203
        sendNetLn(teamName);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   204
        sendNetLn(IntToStr(color));
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   205
        sendNetLn(grave);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   206
        sendNetLn(fort);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   207
        sendNetLn(voice);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   208
        sendNetLn(flag);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   209
        sendNetLn(IntToStr(botLevel));
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   210
        for i := 0 to 7 do
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   211
        begin
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   212
            sendNetLn(hedgehogs[i].name);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   213
            sendNetLn(hedgehogs[i].hat);
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   214
        end;
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   215
        sendNetLn('')
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   216
    end;
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   217
end;
91f8c6ff5bab - Send team to net
unc0rr
parents: 11447
diff changeset
   218
11451
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   219
procedure removeTeam(teamName: shortstring);
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   220
begin
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   221
    sendNetLn('REMOVE_TEAM');
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   222
    sendNet(teamName)
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   223
end;
321d0ce43568 Send team removal message to net
unc0rr
parents: 11450
diff changeset
   224
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents:
diff changeset
   225
end.