author | koda |
Thu, 05 Nov 2009 16:23:09 +0000 | |
changeset 2599 | c7153d2348f3 |
parent 2586 | 204e6b2885bc |
child 2621 | 956ff066f3a5 |
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; |
2599 | 22 |
{$INCLUDE "options.inc"} |
4 | 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); |
34 |
var i: LongInt; |
|
4 | 35 |
begin |
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
196
diff
changeset
|
36 |
if isPaused then exit; |
1611 | 37 |
if (not CurrentTeam^.ExtDriven) then |
2382 | 38 |
begin |
39 |
NetGetNextCmd; // its for the case of receiving "/say" message |
|
40 |
isInLag:= false; |
|
41 |
SendKeepAliveMessage(Lag) |
|
42 |
end; |
|
72 | 43 |
if Lag > 100 then Lag:= 100 |
1727 | 44 |
else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then Lag:= 2500; |
626 | 45 |
if (GameType = gmtDemo) and isSpeed then Lag:= Lag * 10; |
4 | 46 |
|
89 | 47 |
i:= 1; |
48 |
while (GameState <> gsExit) and (i <= Lag) do |
|
49 |
begin |
|
917 | 50 |
skipFlag:= false; |
351 | 51 |
if not CurrentTeam^.ExtDriven then |
4 | 52 |
begin |
602 | 53 |
if CurrentHedgehog^.BotLevel <> 0 then ProcessBot; |
4 | 54 |
ProcessGears |
55 |
end else |
|
56 |
begin |
|
57 |
NetGetNextCmd; |
|
58 |
if isInLag then |
|
59 |
case GameType of |
|
113 | 60 |
gmtNet: break; |
4 | 61 |
gmtDemo: begin |
62 |
GameState:= gsExit; |
|
63 |
exit |
|
72 | 64 |
end; |
65 |
gmtSave: begin |
|
66 |
RestoreTeamsFromSave; |
|
2586
204e6b2885bc
added little/big endian checks, added symbol for touch input, simplified iphoneos definitions
koda
parents:
2579
diff
changeset
|
67 |
{$IFNDEF TOUCHINPUT} |
519 | 68 |
SetBinds(CurrentTeam^.Binds); |
2579 | 69 |
{$ENDIF} |
909
122c1b57bbf3
Fix bug with demos and saves after restoring round from save
unc0rr
parents:
883
diff
changeset
|
70 |
//CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos |
72 | 71 |
isSoundEnabled:= isSEBackup; |
72 |
GameType:= gmtLocal |
|
73 |
end; |
|
4 | 74 |
end |
75 |
else ProcessGears |
|
76 |
end; |
|
917 | 77 |
if skipFlag then TurnTimeLeft:= 0; |
89 | 78 |
inc(i) |
162 | 79 |
end |
4 | 80 |
end; |
81 |
||
82 |
end. |