author | unc0rr |
Sat, 27 Jan 2007 14:18:33 +0000 | |
changeset 371 | 731ad6d27bd1 |
parent 358 | 236bbd12d4d9 |
child 393 | db01cc79f278 |
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 |
|
351 | 21 |
uses uFloat; |
4 | 22 |
{$INCLUDE options.inc} |
23 |
||
371 | 24 |
procedure DoGameTick(Lag: LongInt); |
4 | 25 |
|
26 |
//////////////////// |
|
27 |
implementation |
|
28 |
//////////////////// |
|
72 | 29 |
uses uMisc, uConsts, uWorld, uKeys, uTeams, uIO, uAI, uGears, uConsole; |
4 | 30 |
|
371 | 31 |
procedure DoGameTick(Lag: LongInt); |
4 | 32 |
const SendEmptyPacketTicks: LongWord = 0; |
371 | 33 |
var i: LongInt; |
4 | 34 |
begin |
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
196
diff
changeset
|
35 |
if isPaused then exit; |
351 | 36 |
if not CurrentTeam^.ExtDriven then |
4 | 37 |
begin |
358 | 38 |
NetGetNextCmd; // its for the case of receiving "/say" message |
113 | 39 |
isInLag:= false; |
40 |
inc(SendEmptyPacketTicks, Lag); |
|
4 | 41 |
if SendEmptyPacketTicks >= cSendEmptyPacketTime then |
42 |
begin |
|
143 | 43 |
SendIPC('+'); |
4 | 44 |
SendEmptyPacketTicks:= 0 |
113 | 45 |
end |
4 | 46 |
end; |
72 | 47 |
if Lag > 100 then Lag:= 100 |
109 | 48 |
else if GameType = gmtSave then Lag:= 2500; |
4 | 49 |
|
89 | 50 |
i:= 1; |
51 |
while (GameState <> gsExit) and (i <= Lag) do |
|
52 |
begin |
|
351 | 53 |
if not CurrentTeam^.ExtDriven then |
4 | 54 |
begin |
55 |
with CurrentTeam^ do |
|
191
a03c2d037e24
Bots are in the same thread as game. Fixes FreePascal issues.
unc0rr
parents:
183
diff
changeset
|
56 |
if Hedgehogs[CurrHedgehog].BotLevel <> 0 then ProcessBot(Frames); |
4 | 57 |
ProcessGears |
58 |
end else |
|
59 |
begin |
|
60 |
NetGetNextCmd; |
|
61 |
if isInLag then |
|
62 |
case GameType of |
|
113 | 63 |
gmtNet: break; |
4 | 64 |
gmtDemo: begin |
65 |
GameState:= gsExit; |
|
66 |
exit |
|
72 | 67 |
end; |
68 |
gmtSave: begin |
|
69 |
RestoreTeamsFromSave; |
|
70 |
isSoundEnabled:= isSEBackup; |
|
71 |
GameType:= gmtLocal |
|
72 |
end; |
|
4 | 73 |
end |
74 |
else ProcessGears |
|
75 |
end; |
|
89 | 76 |
inc(i) |
162 | 77 |
end |
4 | 78 |
end; |
79 |
||
80 |
end. |