author | unc0rr |
Wed, 08 Oct 2008 18:56:32 +0000 | |
changeset 1325 | c8994d47f41d |
parent 1066 | 1f1b3686a2b0 |
child 1560 | e140bc57ff68 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy 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 |
|
917 | 26 |
var skipFlag: boolean = false; |
27 |
||
4 | 28 |
//////////////////// |
29 |
implementation |
|
30 |
//////////////////// |
|
72 | 31 |
uses uMisc, uConsts, uWorld, uKeys, uTeams, uIO, uAI, uGears, uConsole; |
4 | 32 |
|
371 | 33 |
procedure DoGameTick(Lag: LongInt); |
4 | 34 |
const SendEmptyPacketTicks: LongWord = 0; |
371 | 35 |
var i: LongInt; |
4 | 36 |
begin |
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
196
diff
changeset
|
37 |
if isPaused then exit; |
351 | 38 |
if not CurrentTeam^.ExtDriven then |
4 | 39 |
begin |
358 | 40 |
NetGetNextCmd; // its for the case of receiving "/say" message |
113 | 41 |
isInLag:= false; |
42 |
inc(SendEmptyPacketTicks, Lag); |
|
4 | 43 |
if SendEmptyPacketTicks >= cSendEmptyPacketTime then |
44 |
begin |
|
143 | 45 |
SendIPC('+'); |
4 | 46 |
SendEmptyPacketTicks:= 0 |
113 | 47 |
end |
4 | 48 |
end; |
72 | 49 |
if Lag > 100 then Lag:= 100 |
109 | 50 |
else if GameType = gmtSave then Lag:= 2500; |
626 | 51 |
if (GameType = gmtDemo) and isSpeed then Lag:= Lag * 10; |
4 | 52 |
|
89 | 53 |
i:= 1; |
54 |
while (GameState <> gsExit) and (i <= Lag) do |
|
55 |
begin |
|
917 | 56 |
skipFlag:= false; |
351 | 57 |
if not CurrentTeam^.ExtDriven then |
4 | 58 |
begin |
602 | 59 |
if CurrentHedgehog^.BotLevel <> 0 then ProcessBot; |
4 | 60 |
ProcessGears |
61 |
end else |
|
62 |
begin |
|
63 |
NetGetNextCmd; |
|
64 |
if isInLag then |
|
65 |
case GameType of |
|
113 | 66 |
gmtNet: break; |
4 | 67 |
gmtDemo: begin |
68 |
GameState:= gsExit; |
|
69 |
exit |
|
72 | 70 |
end; |
71 |
gmtSave: begin |
|
72 |
RestoreTeamsFromSave; |
|
519 | 73 |
SetBinds(CurrentTeam^.Binds); |
909
122c1b57bbf3
Fix bug with demos and saves after restoring round from save
unc0rr
parents:
883
diff
changeset
|
74 |
//CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos |
72 | 75 |
isSoundEnabled:= isSEBackup; |
76 |
GameType:= gmtLocal |
|
77 |
end; |
|
4 | 78 |
end |
79 |
else ProcessGears |
|
80 |
end; |
|
917 | 81 |
if skipFlag then TurnTimeLeft:= 0; |
89 | 82 |
inc(i) |
162 | 83 |
end |
4 | 84 |
end; |
85 |
||
86 |
end. |