author | unc0rr |
Wed, 15 Oct 2008 15:02:39 +0000 | |
changeset 1356 | 77ab8735401d |
parent 1355 | 8e167aa3b2e4 |
child 1362 | 6298e9dbd33c |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
19 |
unit uTeams; |
|
20 |
interface |
|
1251 | 21 |
uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats, GL; |
4 | 22 |
{$INCLUDE options.inc} |
534 | 23 |
|
24 |
type PHHAmmo = ^THHAmmo; |
|
1299 | 25 |
THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo; |
534 | 26 |
|
1299 | 27 |
PHedgehog = ^THedgehog; |
28 |
PTeam = ^TTeam; |
|
29 |
PClan = ^TClan; |
|
30 |
||
31 |
THedgehog = record |
|
32 |
Name: string[MAXNAMELEN]; |
|
33 |
Gear: PGear; |
|
34 |
NameTagTex, |
|
35 |
HealthTagTex, |
|
36 |
HatTex: PTexture; |
|
37 |
Ammo: PHHAmmo; |
|
38 |
AmmoStore: Longword; |
|
39 |
CurSlot, CurAmmo: LongWord; |
|
40 |
Team: PTeam; |
|
41 |
AttacksNum: Longword; |
|
42 |
visStepPos: LongWord; |
|
43 |
BotLevel : LongWord; // 0 - Human player |
|
44 |
HatVisibility: GLfloat; |
|
45 |
stats: TStatistics; |
|
46 |
Hat: String; |
|
47 |
end; |
|
48 |
||
49 |
TTeam = record |
|
50 |
Clan: PClan; |
|
51 |
TeamName: string[MAXNAMELEN]; |
|
52 |
ExtDriven: boolean; |
|
53 |
Binds: TBinds; |
|
54 |
Hedgehogs: array[0..cMaxHHIndex] of THedgehog; |
|
55 |
CurrHedgehog: LongWord; |
|
56 |
NameTagTex: PTexture; |
|
57 |
CrosshairTex, |
|
58 |
GraveTex, |
|
59 |
HealthTex: PTexture; |
|
60 |
GraveName: string; |
|
61 |
FortName: string; |
|
62 |
TeamHealth: LongInt; |
|
63 |
TeamHealthBarWidth, |
|
64 |
NewTeamHealthBarWidth: LongInt; |
|
65 |
DrawHealthY: LongInt; |
|
66 |
AttackBar: LongWord; |
|
67 |
HedgehogsNumber: Longword; |
|
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
68 |
hasGone: boolean; |
1299 | 69 |
end; |
70 |
||
71 |
TClan = record |
|
72 |
Color: Longword; |
|
73 |
Teams: array[0..Pred(cMaxTeams)] of PTeam; |
|
74 |
TeamsNumber: Longword; |
|
75 |
CurrTeam: LongWord; |
|
76 |
ClanHealth: LongInt; |
|
77 |
ClanIndex: LongInt; |
|
78 |
TurnNumber: LongWord; |
|
79 |
end; |
|
4 | 80 |
|
81 |
var CurrentTeam: PTeam = nil; |
|
1299 | 82 |
CurrentHedgehog: PHedgehog = nil; |
83 |
TeamsArray: array[0..Pred(cMaxTeams)] of PTeam; |
|
84 |
TeamsCount: Longword = 0; |
|
85 |
ClansArray: array[0..Pred(cMaxTeams)] of PClan; |
|
86 |
ClansCount: Longword = 0; |
|
87 |
CurMinAngle, CurMaxAngle: Longword; |
|
4 | 88 |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
89 |
function AddTeam(TeamColor: Longword): PTeam; |
4 | 90 |
procedure SwitchHedgehog; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
91 |
procedure AfterSwitchHedgehog; |
4 | 92 |
procedure InitTeams; |
93 |
function TeamSize(p: PTeam): Longword; |
|
47 | 94 |
procedure RecountTeamHealth(team: PTeam); |
72 | 95 |
procedure RestoreTeamsFromSave; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
96 |
function CheckForWin: boolean; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
97 |
procedure TeamGone(s: shortstring); |
4 | 98 |
|
99 |
implementation |
|
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
100 |
uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uSound, uChat; |
371 | 101 |
const MaxTeamHealth: LongInt = 0; |
4 | 102 |
|
103 |
procedure FreeTeamsList; forward; |
|
104 |
||
92
0c359a7a2356
- Fix win message to appear only after all hedgehogs death
unc0rr
parents:
89
diff
changeset
|
105 |
function CheckForWin: boolean; |
576 | 106 |
var AliveClan: PClan; |
306 | 107 |
s: shortstring; |
1011 | 108 |
t, AliveCount, i, j: LongInt; |
83 | 109 |
begin |
548 | 110 |
AliveCount:= 0; |
549 | 111 |
for t:= 0 to Pred(ClansCount) do |
1299 | 112 |
if ClansArray[t]^.ClanHealth > 0 then |
113 |
begin |
|
114 |
inc(AliveCount); |
|
115 |
AliveClan:= ClansArray[t] |
|
116 |
end; |
|
548 | 117 |
|
1299 | 118 |
if (AliveCount > 1) |
119 |
or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then exit(false); |
|
351 | 120 |
CheckForWin:= true; |
83 | 121 |
|
122 |
TurnTimeLeft:= 0; |
|
548 | 123 |
if AliveCount = 0 then |
1011 | 124 |
begin // draw |
125 |
AddCaption(trmsg[sidDraw], $FFFFFF, capgrpGameState); |
|
126 |
SendStat(siGameResult, trmsg[sidDraw]); |
|
127 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
|
128 |
end else // win |
|
129 |
with AliveClan^ do |
|
130 |
begin |
|
131 |
if TeamsNumber = 1 then |
|
132 |
s:= Format(trmsg[sidWinner], Teams[0]^.TeamName) // team wins |
|
133 |
else |
|
134 |
s:= Format(trmsg[sidWinner], Teams[0]^.TeamName); // clan wins |
|
549 | 135 |
|
1011 | 136 |
for j:= 0 to Pred(TeamsNumber) do |
137 |
with Teams[j]^ do |
|
138 |
for i:= 0 to cMaxHHIndex do |
|
139 |
with Hedgehogs[i] do |
|
140 |
if (Gear <> nil) then |
|
141 |
Gear^.State:= gstWinner; |
|
142 |
||
143 |
AddCaption(s, $FFFFFF, capgrpGameState); |
|
144 |
SendStat(siGameResult, s); |
|
145 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
|
146 |
end; |
|
307 | 147 |
SendStats |
83 | 148 |
end; |
149 |
||
4 | 150 |
procedure SwitchHedgehog; |
551 | 151 |
var c: LongWord; |
552 | 152 |
PrevHH, PrevTeam: LongWord; |
4 | 153 |
begin |
154 |
FreeActionsList; |
|
155 |
TargetPoint.X:= NoPointX; |
|
89 | 156 |
TryDo(CurrentTeam <> nil, 'nil Team', true); |
547 | 157 |
|
944 | 158 |
with CurrentHedgehog^ do |
1299 | 159 |
if Gear <> nil then |
160 |
begin |
|
161 |
AttacksNum:= 0; |
|
162 |
Gear^.Message:= 0; |
|
163 |
Gear^.Z:= cHHZ; |
|
164 |
RemoveGearFromList(Gear); |
|
165 |
InsertGearToList(Gear) |
|
166 |
end; |
|
4 | 167 |
|
550 | 168 |
c:= CurrentTeam^.Clan^.ClanIndex; |
4 | 169 |
repeat |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
170 |
inc(c); |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
171 |
if c = ClansCount then |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
172 |
begin |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
173 |
inc(TotalRounds); |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
174 |
c:= 0 |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
175 |
end; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
176 |
|
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
177 |
with ClansArray[c]^ do |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
178 |
begin |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
179 |
PrevTeam:= CurrTeam; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
180 |
repeat |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
181 |
CurrTeam:= Succ(CurrTeam) mod TeamsNumber; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
182 |
CurrentTeam:= Teams[CurrTeam]; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
183 |
with CurrentTeam^ do |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
184 |
begin |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
185 |
PrevHH:= CurrHedgehog; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
186 |
repeat |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
187 |
CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
188 |
until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH) |
1299 | 189 |
end |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
190 |
until ((CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (not CurrentTeam^.hasGone)) or (PrevTeam = CurrTeam); |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
191 |
end |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
192 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (not CurrentTeam^.hasGone); |
83 | 193 |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
194 |
CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]) |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
195 |
end; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
196 |
|
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
197 |
procedure AfterSwitchHedgehog; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
198 |
var g: PGear; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
199 |
begin |
944 | 200 |
SwitchNotHoldedAmmo(CurrentHedgehog^); |
602 | 201 |
with CurrentHedgehog^ do |
1299 | 202 |
begin |
203 |
with Gear^ do |
|
204 |
begin |
|
205 |
Z:= cCurrHHZ; |
|
206 |
State:= gstHHDriven; |
|
207 |
Active:= true |
|
208 |
end; |
|
209 |
RemoveGearFromList(Gear); |
|
210 |
InsertGearToList(Gear); |
|
211 |
FollowGear:= Gear |
|
212 |
end; |
|
941
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
927
diff
changeset
|
213 |
|
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
927
diff
changeset
|
214 |
inc(CurrentTeam^.Clan^.TurnNumber); |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
927
diff
changeset
|
215 |
|
4 | 216 |
ResetKbd; |
351 | 217 |
|
218 |
cWindSpeed:= rndSign(GetRandom * cMaxWindSpeed); |
|
498 | 219 |
g:= AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1); |
351 | 220 |
g^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
4 | 221 |
{$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF} |
602 | 222 |
ApplyAmmoChanges(CurrentHedgehog^); |
800 | 223 |
|
351 | 224 |
if CurrentTeam^.ExtDriven then SetDefaultBinds |
225 |
else SetBinds(CurrentTeam^.Binds); |
|
176 | 226 |
bShowFinger:= true; |
800 | 227 |
|
801 | 228 |
if (CurrentTeam^.ExtDriven or (CurrentHedgehog^.BotLevel > 0)) then |
1299 | 229 |
PlaySound(sndIllGetYou, false) |
801 | 230 |
else |
1299 | 231 |
PlaySound(sndYesSir, false); |
800 | 232 |
|
4 | 233 |
TurnTimeLeft:= cHedgehogTurnTime |
234 |
end; |
|
235 |
||
549 | 236 |
function AddTeam(TeamColor: Longword): PTeam; |
351 | 237 |
var Result: PTeam; |
549 | 238 |
c: LongInt; |
4 | 239 |
begin |
1170 | 240 |
TryDo(TeamsCount < cMaxTeams, 'Too many teams', true); |
17 | 241 |
New(Result); |
80 | 242 |
TryDo(Result <> nil, 'AddTeam: Result = nil', true); |
4 | 243 |
FillChar(Result^, sizeof(TTeam), 0); |
351 | 244 |
Result^.AttackBar:= 2; |
245 |
Result^.CurrHedgehog:= cMaxHHIndex; |
|
547 | 246 |
|
247 |
TeamsArray[TeamsCount]:= Result; |
|
248 |
inc(TeamsCount); |
|
249 |
||
549 | 250 |
c:= Pred(ClansCount); |
251 |
while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c); |
|
252 |
if c < 0 then |
|
253 |
begin |
|
254 |
new(Result^.Clan); |
|
255 |
FillChar(Result^.Clan^, sizeof(TClan), 0); |
|
256 |
ClansArray[ClansCount]:= Result^.Clan; |
|
257 |
inc(ClansCount); |
|
258 |
with Result^.Clan^ do |
|
259 |
begin |
|
550 | 260 |
ClanIndex:= Pred(ClansCount); |
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
261 |
Color:= TeamColor |
549 | 262 |
end |
263 |
end else |
|
264 |
begin |
|
265 |
Result^.Clan:= ClansArray[c]; |
|
266 |
end; |
|
267 |
||
268 |
with Result^.Clan^ do |
|
269 |
begin |
|
270 |
Teams[TeamsNumber]:= Result; |
|
271 |
inc(TeamsNumber) |
|
272 |
end; |
|
273 |
||
351 | 274 |
CurrentTeam:= Result; |
275 |
AddTeam:= Result |
|
4 | 276 |
end; |
277 |
||
278 |
procedure FreeTeamsList; |
|
547 | 279 |
var t: LongInt; |
4 | 280 |
begin |
547 | 281 |
for t:= 0 to Pred(TeamsCount) do Dispose(TeamsArray[t]); |
282 |
TeamsCount:= 0 |
|
4 | 283 |
end; |
284 |
||
47 | 285 |
procedure RecountAllTeamsHealth; |
547 | 286 |
var t: LongInt; |
287 |
begin |
|
288 |
for t:= 0 to Pred(TeamsCount) do |
|
289 |
RecountTeamHealth(TeamsArray[t]) |
|
47 | 290 |
end; |
291 |
||
292 |
procedure InitTeams; |
|
547 | 293 |
var i, t: LongInt; |
371 | 294 |
th: LongInt; |
47 | 295 |
begin |
547 | 296 |
for t:= 0 to Pred(TeamsCount) do |
297 |
with TeamsArray[t]^ do |
|
47 | 298 |
begin |
299 |
th:= 0; |
|
4 | 300 |
for i:= 0 to cMaxHHIndex do |
547 | 301 |
if Hedgehogs[i].Gear <> nil then |
302 |
inc(th, Hedgehogs[i].Gear^.Health); |
|
47 | 303 |
if th > MaxTeamHealth then MaxTeamHealth:= th; |
4 | 304 |
end; |
47 | 305 |
RecountAllTeamsHealth |
4 | 306 |
end; |
307 |
||
308 |
function TeamSize(p: PTeam): Longword; |
|
351 | 309 |
var i, Result: Longword; |
4 | 310 |
begin |
311 |
Result:= 0; |
|
312 |
for i:= 0 to cMaxHHIndex do |
|
351 | 313 |
if p^.Hedgehogs[i].Gear <> nil then inc(Result); |
314 |
TeamSize:= Result |
|
4 | 315 |
end; |
316 |
||
549 | 317 |
procedure RecountClanHealth(clan: PClan); |
318 |
var i: LongInt; |
|
319 |
begin |
|
320 |
with clan^ do |
|
321 |
begin |
|
322 |
ClanHealth:= 0; |
|
323 |
for i:= 0 to Pred(TeamsNumber) do |
|
324 |
inc(ClanHealth, Teams[i]^.TeamHealth) |
|
325 |
end |
|
326 |
end; |
|
327 |
||
47 | 328 |
procedure RecountTeamHealth(team: PTeam); |
371 | 329 |
var i: LongInt; |
47 | 330 |
begin |
331 |
with team^ do |
|
1352
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
332 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
333 |
NewTeamHealthBarWidth:= 0; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
334 |
|
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
335 |
if not hasGone then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
336 |
for i:= 0 to cMaxHHIndex do |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
337 |
if Hedgehogs[i].Gear <> nil then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
338 |
inc(NewTeamHealthBarWidth, Hedgehogs[i].Gear^.Health); |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
339 |
|
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
340 |
TeamHealth:= NewTeamHealthBarWidth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
341 |
if NewTeamHealthBarWidth > MaxTeamHealth then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
342 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
343 |
MaxTeamHealth:= NewTeamHealthBarWidth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
344 |
RecountAllTeamsHealth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
345 |
end else NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
346 |
end; |
549 | 347 |
|
348 |
RecountClanHealth(team^.Clan); |
|
349 |
||
498 | 350 |
AddGear(0, 0, gtTeamHealthSorter, 0, _0, _0, 0) |
47 | 351 |
end; |
352 |
||
72 | 353 |
procedure RestoreTeamsFromSave; |
547 | 354 |
var t: LongInt; |
72 | 355 |
begin |
547 | 356 |
for t:= 0 to Pred(TeamsCount) do |
357 |
TeamsArray[t]^.ExtDriven:= false |
|
72 | 358 |
end; |
359 |
||
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
360 |
procedure TeamGone(s: shortstring); |
1356 | 361 |
var i, t: LongInt; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
362 |
begin |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
363 |
i:= 0; |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
364 |
|
1356 | 365 |
while (t < cMaxTeams) |
366 |
and (TeamsArray[t] <> nil) |
|
367 |
and (TeamsArray[t]^.TeamName <> s) do inc(t); |
|
368 |
if (t = cMaxTeams) or (TeamsArray[t] = nil) then exit; |
|
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
369 |
|
1356 | 370 |
with TeamsArray[t]^ do |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
371 |
begin |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
372 |
AddChatString('* '+ TeamName + ' is gone'); |
1354
a8dcdeb88a43
Various small insignificant improvements everywhere
unc0rr
parents:
1352
diff
changeset
|
373 |
for i:= 0 to cMaxHHIndex do |
a8dcdeb88a43
Various small insignificant improvements everywhere
unc0rr
parents:
1352
diff
changeset
|
374 |
with Hedgehogs[i] do |
1355 | 375 |
if Gear <> nil then |
376 |
begin |
|
377 |
if Gear^.State and gstAttacking <> 0 then |
|
378 |
AttackBar:= 0; |
|
379 |
||
380 |
Gear^.State:= Gear^.State and not gstHHDriven |
|
381 |
end; |
|
382 |
||
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
383 |
hasGone:= true |
1355 | 384 |
end; |
385 |
||
386 |
RecountTeamHealth(TeamsArray[i]) |
|
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
387 |
end; |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
388 |
|
4 | 389 |
initialization |
390 |
||
391 |
finalization |
|
392 |
||
393 |
FreeTeamsList |
|
394 |
||
395 |
end. |