author | unc0rr |
Sat, 18 Nov 2006 18:17:03 +0000 | |
changeset 248 | aab204fe5061 |
parent 196 | 993cf173218b |
child 281 | 5b483aa9f2ab |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
3 |
* Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com> |
|
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 uGame; |
|
20 |
interface |
|
21 |
{$INCLUDE options.inc} |
|
22 |
||
23 |
procedure DoGameTick(Lag: integer); |
|
24 |
||
25 |
//////////////////// |
|
26 |
implementation |
|
27 |
//////////////////// |
|
72 | 28 |
uses uMisc, uConsts, uWorld, uKeys, uTeams, uIO, uAI, uGears, uConsole; |
4 | 29 |
|
30 |
procedure DoGameTick(Lag: integer); |
|
31 |
const SendEmptyPacketTicks: LongWord = 0; |
|
32 |
var i: integer; |
|
33 |
begin |
|
167 | 34 |
if not CurrentTeam.ExtDriven then |
4 | 35 |
begin |
113 | 36 |
NetGetNextCmd; // its for the case when receiving "/say" message |
37 |
isInLag:= false; |
|
38 |
inc(SendEmptyPacketTicks, Lag); |
|
4 | 39 |
if SendEmptyPacketTicks >= cSendEmptyPacketTime then |
40 |
begin |
|
143 | 41 |
SendIPC('+'); |
4 | 42 |
SendEmptyPacketTicks:= 0 |
113 | 43 |
end |
4 | 44 |
end; |
45 |
||
72 | 46 |
if Lag > 100 then Lag:= 100 |
109 | 47 |
else if GameType = gmtSave then Lag:= 2500; |
4 | 48 |
|
89 | 49 |
i:= 1; |
50 |
while (GameState <> gsExit) and (i <= Lag) do |
|
51 |
begin |
|
4 | 52 |
if not CurrentTeam.ExtDriven then |
53 |
begin |
|
54 |
with CurrentTeam^ do |
|
191
a03c2d037e24
Bots are in the same thread as game. Fixes FreePascal issues.
unc0rr
parents:
183
diff
changeset
|
55 |
if Hedgehogs[CurrHedgehog].BotLevel <> 0 then ProcessBot(Frames); |
4 | 56 |
ProcessGears |
57 |
end else |
|
58 |
begin |
|
59 |
NetGetNextCmd; |
|
60 |
if isInLag then |
|
61 |
case GameType of |
|
113 | 62 |
gmtNet: break; |
4 | 63 |
gmtDemo: begin |
64 |
GameState:= gsExit; |
|
65 |
exit |
|
72 | 66 |
end; |
67 |
gmtSave: begin |
|
68 |
RestoreTeamsFromSave; |
|
69 |
isSoundEnabled:= isSEBackup; |
|
70 |
GameType:= gmtLocal |
|
71 |
end; |
|
4 | 72 |
end |
73 |
else ProcessGears |
|
74 |
end; |
|
89 | 75 |
inc(i) |
162 | 76 |
end |
4 | 77 |
end; |
78 |
||
79 |
end. |