author | unc0rr |
Sat, 22 Sep 2007 16:19:11 +0000 | |
changeset 609 | e8ff5fcbe841 |
parent 602 | f7628ebfccde |
child 626 | a30171dbcd19 |
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 |
602 | 55 |
if CurrentHedgehog^.BotLevel <> 0 then ProcessBot; |
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; |
|
519 | 69 |
SetBinds(CurrentTeam^.Binds); |
72 | 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. |