author | smxx |
Mon, 15 Feb 2010 21:54:26 +0000 | |
changeset 2814 | 71e80c6e74bb |
parent 2786 | 85f6425a4d74 |
child 2948 | 3f21a9dc93d0 |
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 |
||
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uGame; |
22 |
interface |
|
351 | 23 |
uses uFloat; |
4 | 24 |
|
371 | 25 |
procedure DoGameTick(Lag: LongInt); |
4 | 26 |
|
27 |
//////////////////// |
|
28 |
implementation |
|
29 |
//////////////////// |
|
2786 | 30 |
uses uMisc, uConsts, uWorld, uKeys, uTeams, uIO, uAI, uGears, uConsole, uScript; |
4 | 31 |
|
371 | 32 |
procedure DoGameTick(Lag: LongInt); |
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; |
1611 | 36 |
if (not CurrentTeam^.ExtDriven) then |
2382 | 37 |
begin |
38 |
NetGetNextCmd; // its for the case of receiving "/say" message |
|
39 |
isInLag:= false; |
|
40 |
SendKeepAliveMessage(Lag) |
|
41 |
end; |
|
72 | 42 |
if Lag > 100 then Lag:= 100 |
1727 | 43 |
else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then Lag:= 2500; |
626 | 44 |
if (GameType = gmtDemo) and isSpeed then Lag:= Lag * 10; |
4 | 45 |
|
89 | 46 |
i:= 1; |
47 |
while (GameState <> gsExit) and (i <= Lag) do |
|
48 |
begin |
|
2814 | 49 |
ScriptCall('onGameTick'); |
351 | 50 |
if not CurrentTeam^.ExtDriven then |
4 | 51 |
begin |
602 | 52 |
if CurrentHedgehog^.BotLevel <> 0 then ProcessBot; |
4 | 53 |
ProcessGears |
54 |
end else |
|
55 |
begin |
|
56 |
NetGetNextCmd; |
|
57 |
if isInLag then |
|
58 |
case GameType of |
|
113 | 59 |
gmtNet: break; |
4 | 60 |
gmtDemo: begin |
61 |
GameState:= gsExit; |
|
62 |
exit |
|
72 | 63 |
end; |
64 |
gmtSave: begin |
|
65 |
RestoreTeamsFromSave; |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
66 |
{$IFNDEF IPHONEOS} |
519 | 67 |
SetBinds(CurrentTeam^.Binds); |
2579 | 68 |
{$ENDIF} |
909
122c1b57bbf3
Fix bug with demos and saves after restoring round from save
unc0rr
parents:
883
diff
changeset
|
69 |
//CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos |
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. |