author | unc0rr |
Wed, 07 May 2008 14:59:59 +0000 | |
changeset 909 | 122c1b57bbf3 |
parent 883 | 07a568ba44e0 |
child 917 | e59614bffc3f |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
883 | 3 |
* Copyright (c) 2004-2008 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); |
909
122c1b57bbf3
Fix bug with demos and saves after restoring round from save
unc0rr
parents:
883
diff
changeset
|
71 |
//CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos |
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. |