author | unc0rr |
Sat, 02 Feb 2008 15:20:41 +0000 | |
changeset 781 | 4101f0f1c0b9 |
parent 741 | 8bf8c0ac8d94 |
child 883 | 07a568ba44e0 |
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; |
626 | 49 |
if (GameType = gmtDemo) and isSpeed then Lag:= Lag * 10; |
4 | 50 |
|
89 | 51 |
i:= 1; |
52 |
while (GameState <> gsExit) and (i <= Lag) do |
|
53 |
begin |
|
351 | 54 |
if not CurrentTeam^.ExtDriven then |
4 | 55 |
begin |
602 | 56 |
if CurrentHedgehog^.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); |
741 | 71 |
CurrentHedgehog^.Gear^.Message:= 0; |
72 | 72 |
isSoundEnabled:= isSEBackup; |
73 |
GameType:= gmtLocal |
|
74 |
end; |
|
4 | 75 |
end |
76 |
else ProcessGears |
|
77 |
end; |
|
89 | 78 |
inc(i) |
162 | 79 |
end |
4 | 80 |
end; |
81 |
||
82 |
end. |