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