author | unc0rr |
Mon, 12 Jan 2009 21:49:41 +0000 | |
changeset 1655 | 16f687fc18e3 |
parent 1654 | 9cfa6f23e767 |
child 1657 | dde8f60d3e07 |
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 |
|
1654 | 21 |
uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats, GL, uSound; |
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; |
1654 | 69 |
voicepack: PVoicepack; |
1299 | 70 |
end; |
71 |
||
72 |
TClan = record |
|
73 |
Color: Longword; |
|
74 |
Teams: array[0..Pred(cMaxTeams)] of PTeam; |
|
75 |
TeamsNumber: Longword; |
|
76 |
CurrTeam: LongWord; |
|
77 |
ClanHealth: LongInt; |
|
78 |
ClanIndex: LongInt; |
|
79 |
TurnNumber: LongWord; |
|
80 |
end; |
|
4 | 81 |
|
82 |
var CurrentTeam: PTeam = nil; |
|
1299 | 83 |
CurrentHedgehog: PHedgehog = nil; |
84 |
TeamsArray: array[0..Pred(cMaxTeams)] of PTeam; |
|
85 |
TeamsCount: Longword = 0; |
|
86 |
ClansArray: array[0..Pred(cMaxTeams)] of PClan; |
|
87 |
ClansCount: Longword = 0; |
|
88 |
CurMinAngle, CurMaxAngle: Longword; |
|
4 | 89 |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
90 |
function AddTeam(TeamColor: Longword): PTeam; |
4 | 91 |
procedure SwitchHedgehog; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
92 |
procedure AfterSwitchHedgehog; |
4 | 93 |
procedure InitTeams; |
94 |
function TeamSize(p: PTeam): Longword; |
|
47 | 95 |
procedure RecountTeamHealth(team: PTeam); |
72 | 96 |
procedure RestoreTeamsFromSave; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
97 |
function CheckForWin: boolean; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
98 |
procedure TeamGone(s: shortstring); |
4 | 99 |
|
100 |
implementation |
|
1654 | 101 |
uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uChat; |
371 | 102 |
const MaxTeamHealth: LongInt = 0; |
4 | 103 |
|
104 |
procedure FreeTeamsList; forward; |
|
105 |
||
92
0c359a7a2356
- Fix win message to appear only after all hedgehogs death
unc0rr
parents:
89
diff
changeset
|
106 |
function CheckForWin: boolean; |
576 | 107 |
var AliveClan: PClan; |
306 | 108 |
s: shortstring; |
1011 | 109 |
t, AliveCount, i, j: LongInt; |
83 | 110 |
begin |
548 | 111 |
AliveCount:= 0; |
549 | 112 |
for t:= 0 to Pred(ClansCount) do |
1299 | 113 |
if ClansArray[t]^.ClanHealth > 0 then |
114 |
begin |
|
115 |
inc(AliveCount); |
|
116 |
AliveClan:= ClansArray[t] |
|
117 |
end; |
|
548 | 118 |
|
1299 | 119 |
if (AliveCount > 1) |
120 |
or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then exit(false); |
|
351 | 121 |
CheckForWin:= true; |
83 | 122 |
|
123 |
TurnTimeLeft:= 0; |
|
548 | 124 |
if AliveCount = 0 then |
1011 | 125 |
begin // draw |
126 |
AddCaption(trmsg[sidDraw], $FFFFFF, capgrpGameState); |
|
127 |
SendStat(siGameResult, trmsg[sidDraw]); |
|
128 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
|
129 |
end else // win |
|
130 |
with AliveClan^ do |
|
131 |
begin |
|
132 |
if TeamsNumber = 1 then |
|
133 |
s:= Format(trmsg[sidWinner], Teams[0]^.TeamName) // team wins |
|
134 |
else |
|
135 |
s:= Format(trmsg[sidWinner], Teams[0]^.TeamName); // clan wins |
|
549 | 136 |
|
1011 | 137 |
for j:= 0 to Pred(TeamsNumber) do |
138 |
with Teams[j]^ do |
|
139 |
for i:= 0 to cMaxHHIndex do |
|
140 |
with Hedgehogs[i] do |
|
141 |
if (Gear <> nil) then |
|
142 |
Gear^.State:= gstWinner; |
|
143 |
||
144 |
AddCaption(s, $FFFFFF, capgrpGameState); |
|
145 |
SendStat(siGameResult, s); |
|
146 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
|
147 |
end; |
|
307 | 148 |
SendStats |
83 | 149 |
end; |
150 |
||
4 | 151 |
procedure SwitchHedgehog; |
551 | 152 |
var c: LongWord; |
552 | 153 |
PrevHH, PrevTeam: LongWord; |
4 | 154 |
begin |
155 |
FreeActionsList; |
|
156 |
TargetPoint.X:= NoPointX; |
|
89 | 157 |
TryDo(CurrentTeam <> nil, 'nil Team', true); |
547 | 158 |
|
944 | 159 |
with CurrentHedgehog^ do |
1299 | 160 |
if Gear <> nil then |
161 |
begin |
|
162 |
AttacksNum:= 0; |
|
163 |
Gear^.Message:= 0; |
|
164 |
Gear^.Z:= cHHZ; |
|
165 |
RemoveGearFromList(Gear); |
|
166 |
InsertGearToList(Gear) |
|
167 |
end; |
|
4 | 168 |
|
550 | 169 |
c:= CurrentTeam^.Clan^.ClanIndex; |
4 | 170 |
repeat |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
171 |
inc(c); |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
172 |
if c = ClansCount then |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
173 |
begin |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
174 |
inc(TotalRounds); |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
175 |
c:= 0 |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
176 |
end; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
177 |
|
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
178 |
with ClansArray[c]^ do |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
179 |
begin |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
180 |
PrevTeam:= CurrTeam; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
181 |
repeat |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
182 |
CurrTeam:= Succ(CurrTeam) mod TeamsNumber; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
183 |
CurrentTeam:= Teams[CurrTeam]; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
184 |
with CurrentTeam^ do |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
185 |
begin |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
186 |
PrevHH:= CurrHedgehog; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
187 |
repeat |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
188 |
CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
189 |
until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH) |
1299 | 190 |
end |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
191 |
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
|
192 |
end |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
193 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (not CurrentTeam^.hasGone); |
83 | 194 |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
195 |
CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]) |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
196 |
end; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
197 |
|
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
198 |
procedure AfterSwitchHedgehog; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
199 |
var g: PGear; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
200 |
begin |
944 | 201 |
SwitchNotHoldedAmmo(CurrentHedgehog^); |
602 | 202 |
with CurrentHedgehog^ do |
1299 | 203 |
begin |
204 |
with Gear^ do |
|
205 |
begin |
|
206 |
Z:= cCurrHHZ; |
|
207 |
State:= gstHHDriven; |
|
208 |
Active:= true |
|
209 |
end; |
|
210 |
RemoveGearFromList(Gear); |
|
211 |
InsertGearToList(Gear); |
|
212 |
FollowGear:= Gear |
|
213 |
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
|
214 |
|
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 |
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
|
216 |
|
4 | 217 |
ResetKbd; |
351 | 218 |
|
219 |
cWindSpeed:= rndSign(GetRandom * cMaxWindSpeed); |
|
498 | 220 |
g:= AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1); |
351 | 221 |
g^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
4 | 222 |
{$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF} |
602 | 223 |
ApplyAmmoChanges(CurrentHedgehog^); |
800 | 224 |
|
1650
a65681cc27c2
Don't fallback to default binds set when switching to remotely driven team
unc0rr
parents:
1495
diff
changeset
|
225 |
if not CurrentTeam^.ExtDriven then SetBinds(CurrentTeam^.Binds); |
a65681cc27c2
Don't fallback to default binds set when switching to remotely driven team
unc0rr
parents:
1495
diff
changeset
|
226 |
|
176 | 227 |
bShowFinger:= true; |
800 | 228 |
|
801 | 229 |
if (CurrentTeam^.ExtDriven or (CurrentHedgehog^.BotLevel > 0)) then |
1299 | 230 |
PlaySound(sndIllGetYou, false) |
801 | 231 |
else |
1299 | 232 |
PlaySound(sndYesSir, false); |
800 | 233 |
|
4 | 234 |
TurnTimeLeft:= cHedgehogTurnTime |
235 |
end; |
|
236 |
||
549 | 237 |
function AddTeam(TeamColor: Longword): PTeam; |
351 | 238 |
var Result: PTeam; |
549 | 239 |
c: LongInt; |
4 | 240 |
begin |
1170 | 241 |
TryDo(TeamsCount < cMaxTeams, 'Too many teams', true); |
17 | 242 |
New(Result); |
80 | 243 |
TryDo(Result <> nil, 'AddTeam: Result = nil', true); |
4 | 244 |
FillChar(Result^, sizeof(TTeam), 0); |
351 | 245 |
Result^.AttackBar:= 2; |
246 |
Result^.CurrHedgehog:= cMaxHHIndex; |
|
547 | 247 |
|
248 |
TeamsArray[TeamsCount]:= Result; |
|
249 |
inc(TeamsCount); |
|
250 |
||
549 | 251 |
c:= Pred(ClansCount); |
252 |
while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c); |
|
253 |
if c < 0 then |
|
254 |
begin |
|
255 |
new(Result^.Clan); |
|
256 |
FillChar(Result^.Clan^, sizeof(TClan), 0); |
|
257 |
ClansArray[ClansCount]:= Result^.Clan; |
|
258 |
inc(ClansCount); |
|
259 |
with Result^.Clan^ do |
|
260 |
begin |
|
550 | 261 |
ClanIndex:= Pred(ClansCount); |
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
262 |
Color:= TeamColor |
549 | 263 |
end |
264 |
end else |
|
265 |
begin |
|
266 |
Result^.Clan:= ClansArray[c]; |
|
267 |
end; |
|
268 |
||
269 |
with Result^.Clan^ do |
|
270 |
begin |
|
271 |
Teams[TeamsNumber]:= Result; |
|
272 |
inc(TeamsNumber) |
|
273 |
end; |
|
274 |
||
351 | 275 |
CurrentTeam:= Result; |
276 |
AddTeam:= Result |
|
4 | 277 |
end; |
278 |
||
279 |
procedure FreeTeamsList; |
|
547 | 280 |
var t: LongInt; |
4 | 281 |
begin |
547 | 282 |
for t:= 0 to Pred(TeamsCount) do Dispose(TeamsArray[t]); |
283 |
TeamsCount:= 0 |
|
4 | 284 |
end; |
285 |
||
47 | 286 |
procedure RecountAllTeamsHealth; |
547 | 287 |
var t: LongInt; |
288 |
begin |
|
289 |
for t:= 0 to Pred(TeamsCount) do |
|
290 |
RecountTeamHealth(TeamsArray[t]) |
|
47 | 291 |
end; |
292 |
||
293 |
procedure InitTeams; |
|
547 | 294 |
var i, t: LongInt; |
371 | 295 |
th: LongInt; |
47 | 296 |
begin |
547 | 297 |
for t:= 0 to Pred(TeamsCount) do |
298 |
with TeamsArray[t]^ do |
|
47 | 299 |
begin |
300 |
th:= 0; |
|
4 | 301 |
for i:= 0 to cMaxHHIndex do |
547 | 302 |
if Hedgehogs[i].Gear <> nil then |
303 |
inc(th, Hedgehogs[i].Gear^.Health); |
|
47 | 304 |
if th > MaxTeamHealth then MaxTeamHealth:= th; |
4 | 305 |
end; |
47 | 306 |
RecountAllTeamsHealth |
4 | 307 |
end; |
308 |
||
309 |
function TeamSize(p: PTeam): Longword; |
|
351 | 310 |
var i, Result: Longword; |
4 | 311 |
begin |
312 |
Result:= 0; |
|
313 |
for i:= 0 to cMaxHHIndex do |
|
351 | 314 |
if p^.Hedgehogs[i].Gear <> nil then inc(Result); |
315 |
TeamSize:= Result |
|
4 | 316 |
end; |
317 |
||
549 | 318 |
procedure RecountClanHealth(clan: PClan); |
319 |
var i: LongInt; |
|
320 |
begin |
|
321 |
with clan^ do |
|
322 |
begin |
|
323 |
ClanHealth:= 0; |
|
324 |
for i:= 0 to Pred(TeamsNumber) do |
|
325 |
inc(ClanHealth, Teams[i]^.TeamHealth) |
|
326 |
end |
|
327 |
end; |
|
328 |
||
47 | 329 |
procedure RecountTeamHealth(team: PTeam); |
371 | 330 |
var i: LongInt; |
47 | 331 |
begin |
332 |
with team^ do |
|
1352
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
333 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
334 |
NewTeamHealthBarWidth:= 0; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
335 |
|
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
336 |
if not hasGone then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
337 |
for i:= 0 to cMaxHHIndex do |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
338 |
if Hedgehogs[i].Gear <> nil then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
339 |
inc(NewTeamHealthBarWidth, Hedgehogs[i].Gear^.Health); |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
340 |
|
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
341 |
TeamHealth:= NewTeamHealthBarWidth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
342 |
if NewTeamHealthBarWidth > MaxTeamHealth then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
343 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
344 |
MaxTeamHealth:= NewTeamHealthBarWidth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
345 |
RecountAllTeamsHealth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
346 |
end else NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
347 |
end; |
549 | 348 |
|
349 |
RecountClanHealth(team^.Clan); |
|
350 |
||
498 | 351 |
AddGear(0, 0, gtTeamHealthSorter, 0, _0, _0, 0) |
47 | 352 |
end; |
353 |
||
72 | 354 |
procedure RestoreTeamsFromSave; |
547 | 355 |
var t: LongInt; |
72 | 356 |
begin |
547 | 357 |
for t:= 0 to Pred(TeamsCount) do |
358 |
TeamsArray[t]^.ExtDriven:= false |
|
72 | 359 |
end; |
360 |
||
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
361 |
procedure TeamGone(s: shortstring); |
1356 | 362 |
var i, t: LongInt; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
363 |
begin |
1362 | 364 |
t:= 0; |
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 |
1495 | 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 |
||
1363 | 386 |
RecountTeamHealth(TeamsArray[t]) |
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. |