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