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