author | unc0rr |
Mon, 02 Jul 2007 16:21:07 +0000 | |
changeset 545 | f527450337c1 |
parent 519 | 981df6f6e2a9 |
child 602 | f7628ebfccde |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
393 | 3 |
* Copyright (c) 2004-2007 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 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 |
|
433 | 56 |
if Hedgehogs[CurrHedgehog].BotLevel <> 0 then ProcessBot; |
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; |
|
519 | 70 |
SetBinds(CurrentTeam^.Binds); |
72 | 71 |
isSoundEnabled:= isSEBackup; |
72 |
GameType:= gmtLocal |
|
73 |
end; |
|
4 | 74 |
end |
75 |
else ProcessGears |
|
76 |
end; |
|
89 | 77 |
inc(i) |
162 | 78 |
end |
4 | 79 |
end; |
80 |
||
81 |
end. |