author | displacer |
Thu, 18 Jan 2007 20:29:28 +0000 | |
changeset 350 | c3ccec3834e8 |
parent 281 | 5b483aa9f2ab |
child 351 | 29bc9c36ad5f |
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 |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
196
diff
changeset
|
34 |
if isPaused then exit; |
167 | 35 |
if not CurrentTeam.ExtDriven then |
4 | 36 |
begin |
113 | 37 |
NetGetNextCmd; // its for the case when receiving "/say" message |
38 |
isInLag:= false; |
|
39 |
inc(SendEmptyPacketTicks, Lag); |
|
4 | 40 |
if SendEmptyPacketTicks >= cSendEmptyPacketTime then |
41 |
begin |
|
143 | 42 |
SendIPC('+'); |
4 | 43 |
SendEmptyPacketTicks:= 0 |
113 | 44 |
end |
4 | 45 |
end; |
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. |