author | Stepan777 <stepik-777@mail.ru> |
Tue, 10 Jul 2012 21:58:19 +0400 | |
changeset 7386 | e82a076df09b |
parent 7180 | 53ffc8853008 |
child 7442 | 9bb6abdb5675 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
6700 | 3 |
* Copyright (c) 2004-2012 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 |
|
23 |
||
371 | 24 |
procedure DoGameTick(Lag: LongInt); |
4 | 25 |
|
26 |
//////////////////// |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
27 |
implementation |
4 | 28 |
//////////////////// |
6954
a61458a81480
changed uKeys to uInputHandler to better reflect its function
Xeli
parents:
6700
diff
changeset
|
29 |
uses uInputHandler, uTeams, uIO, uAI, uGears, uSound, uMobile, uVisualGears, uTypes, uVariables{$IFDEF SDL13}, uTouch{$ENDIF}; |
4 | 30 |
|
371 | 31 |
procedure DoGameTick(Lag: LongInt); |
32 |
var i: LongInt; |
|
4 | 33 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
34 |
if isPaused then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
35 |
exit; |
1611 | 36 |
if (not CurrentTeam^.ExtDriven) then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2814
diff
changeset
|
37 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2814
diff
changeset
|
38 |
NetGetNextCmd; // its for the case of receiving "/say" message |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2814
diff
changeset
|
39 |
isInLag:= false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2814
diff
changeset
|
40 |
SendKeepAliveMessage(Lag) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2814
diff
changeset
|
41 |
end; |
7180 | 42 |
if GameType <> gmtRecord then |
43 |
begin |
|
44 |
if Lag > 100 then |
|
45 |
Lag:= 100 |
|
46 |
else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then |
|
47 |
Lag:= 2500; |
|
5130
3602ede67ec5
Add a parameter for game simulation with no gui/sound enabled, just to get statistics
unc0rr
parents:
4976
diff
changeset
|
48 |
|
7180 | 49 |
if (GameType = gmtDemo) then |
50 |
if isSpeed then |
|
51 |
Lag:= Lag * 10 |
|
52 |
else |
|
53 |
if cOnlyStats then |
|
54 |
Lag:= High(LongInt); |
|
55 |
end; |
|
5638
e35ba2a400d8
Try to avoid overlapping voices for major statements (not things like byebye or oof)
nemo
parents:
5357
diff
changeset
|
56 |
PlayNextVoice; |
89 | 57 |
i:= 1; |
58 |
while (GameState <> gsExit) and (i <= Lag) do |
|
59 |
begin |
|
351 | 60 |
if not CurrentTeam^.ExtDriven then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
61 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
62 |
if CurrentHedgehog^.BotLevel <> 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
63 |
ProcessBot; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
64 |
ProcessGears; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
65 |
{$IFDEF SDL13}ProcessTouch;{$ENDIF} |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
66 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
67 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
68 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
69 |
NetGetNextCmd; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
70 |
if isInLag then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
71 |
case GameType of |
4075 | 72 |
gmtNet: begin |
73 |
// just update the health bars |
|
74 |
AddVisualGear(0, 0, vgtTeamHealthSorter); |
|
75 |
break; |
|
76 |
end; |
|
7386
e82a076df09b
Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
77 |
gmtDemo, gmtRecord: begin |
4 | 78 |
GameState:= gsExit; |
79 |
exit |
|
72 | 80 |
end; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
81 |
gmtSave: begin |
72 | 82 |
RestoreTeamsFromSave; |
519 | 83 |
SetBinds(CurrentTeam^.Binds); |
909
122c1b57bbf3
Fix bug with demos and saves after restoring round from save
unc0rr
parents:
883
diff
changeset
|
84 |
//CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos |
7061 | 85 |
ResetSound; // restore previous sound state |
5809 | 86 |
PlayMusic; |
3902
3aac7ca07b0e
have Saves restart net when loaded, also resumes music
koda
parents:
3663
diff
changeset
|
87 |
GameType:= gmtLocal; |
4049
fe799b5d601b
fix issue 63 and draw health bars right away for savefiles
koda
parents:
4048
diff
changeset
|
88 |
AddVisualGear(0, 0, vgtTeamHealthSorter); |
5357
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5174
diff
changeset
|
89 |
AddVisualGear(0, 0, vgtSmoothWindBar); |
4048 | 90 |
{$IFDEF IPHONEOS}InitIPC;{$ENDIF} |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
5809
diff
changeset
|
91 |
uMobile.SaveLoadingEnded(); |
72 | 92 |
end; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
93 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
94 |
else ProcessGears |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6341
diff
changeset
|
95 |
end; |
89 | 96 |
inc(i) |
162 | 97 |
end |
4 | 98 |
end; |
99 |
||
100 |
end. |