author | unc0rr |
Sat, 10 Jan 2009 12:44:26 +0000 | |
changeset 1630 | 513a2c089160 |
parent 1524 | 5a652a465559 |
child 1645 | f010d68adbb7 |
permissions | -rw-r--r-- |
498 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
393 | 3 |
* Copyright (c) 2004-2007 Andrey Korotaev <unC0Rr@gmail.com> |
51 | 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 |
|
51 | 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. |
|
51 | 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 |
|
51 | 17 |
*) |
18 |
||
355 | 19 |
{$IFNDEF FPC} |
20 |
WriteLn('Only Freepascal supported'); |
|
21 |
{$ENDIF} |
|
22 |
||
51 | 23 |
program hwengine; |
24 |
uses |
|
1524
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
25 |
SDLh, |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
26 |
GL, |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
27 |
uConsts in 'uConsts.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
28 |
uGame in 'uGame.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
29 |
uMisc in 'uMisc.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
30 |
uStore in 'uStore.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
31 |
uWorld in 'uWorld.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
32 |
uIO in 'uIO.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
33 |
uGears in 'uGears.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
34 |
uVisualGears in 'uVisualGears.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
35 |
uConsole in 'uConsole.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
36 |
uKeys in 'uKeys.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
37 |
uTeams in 'uTeams.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
38 |
uSound in 'uSound.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
39 |
uRandom in 'uRandom.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
40 |
uAI in 'uAI.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
41 |
uAIMisc in 'uAIMisc.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
42 |
uAIAmmoTests in 'uAIAmmoTests.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
43 |
uAIActions in 'uAIActions.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
44 |
uCollisions in 'uCollisions.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
45 |
uLand in 'uLand.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
46 |
uLandTemplates in 'uLandTemplates.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
47 |
uLandObjects in 'uLandObjects.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
48 |
uLandGraphics in 'uLandGraphics.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
49 |
uLocale in 'uLocale.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
50 |
uAmmos in 'uAmmos.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
51 |
uSHA in 'uSHA.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
52 |
uFloat in 'uFloat.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
53 |
uStats in 'uStats.pas', |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
54 |
uChat in 'uChat.pas'; |
51 | 55 |
|
56 |
{$INCLUDE options.inc} |
|
57 |
||
58 |
// also: GSHandlers.inc |
|
59 |
// CCHandlers.inc |
|
60 |
// HHHandlers.inc |
|
357 | 61 |
// SinTable.inc |
271 | 62 |
// proto.inc |
51 | 63 |
|
64 |
||
65 |
procedure OnDestroy; forward; |
|
66 |
||
67 |
//////////////////////////////// |
|
371 | 68 |
procedure DoTimer(Lag: LongInt); |
1080 | 69 |
var s: string; |
51 | 70 |
begin |
564 | 71 |
inc(RealTicks, Lag); |
72 |
||
51 | 73 |
case GameState of |
1524
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
74 |
gsLandGen: begin |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
75 |
GenMap; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
76 |
GameState:= gsStart; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
77 |
end; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
78 |
gsStart: begin |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
79 |
AddClouds; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
80 |
AssignHHCoords; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
81 |
AddMiscGears; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
82 |
StoreLoad; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
83 |
ResetKbd; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
84 |
SoundLoad; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
85 |
if GameType = gmtSave then |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
86 |
begin |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
87 |
isSEBackup:= isSoundEnabled; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
88 |
isSoundEnabled:= false |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
89 |
end; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
90 |
FinishProgress; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
91 |
PlayMusic; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
92 |
GameState:= gsGame |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
93 |
end; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
94 |
gsConfirm, |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
95 |
gsGame: begin |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
96 |
ProcessKbd; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
97 |
DrawWorld(Lag); |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
98 |
DoGameTick(Lag); |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
99 |
ProcessVisualGears(Lag); |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
100 |
end; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
101 |
gsChat: begin |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
102 |
DrawWorld(Lag); |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
103 |
DoGameTick(Lag); |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
104 |
ProcessVisualGears(Lag); |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
105 |
end; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
106 |
gsExit: begin |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
107 |
OnDestroy; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
108 |
end; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
109 |
end; |
564 | 110 |
|
753 | 111 |
SDL_GL_SwapBuffers(); |
51 | 112 |
if flagMakeCapture then |
1524
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
113 |
begin |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
114 |
flagMakeCapture:= false; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
115 |
s:= 'hw_' + cSeed + '_' + inttostr(GameTicks) + '.tga'; |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
116 |
WriteLnToConsole('Saving ' + s); |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
117 |
MakeScreenshot(s); |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
118 |
// SDL_SaveBMP_RW(SDLPrimSurface, SDL_RWFromFile(Str2PChar(s), 'wb'), 1) |
5a652a465559
Draw world before processing gears, as this should improve performance by introducing cpu-gpu parallelizm
unc0rr
parents:
1128
diff
changeset
|
119 |
end; |
51 | 120 |
end; |
121 |
||
122 |
//////////////////// |
|
79 | 123 |
procedure OnDestroy; |
51 | 124 |
begin |
125 |
{$IFDEF DEBUGFILE}AddFileLog('Freeing resources...');{$ENDIF} |
|
126 |
if isSoundEnabled then ReleaseSound; |
|
619 | 127 |
StoreRelease; |
128 |
SendKB; |
|
51 | 129 |
CloseIPC; |
130 |
TTF_Quit; |
|
131 |
SDL_Quit; |
|
132 |
halt |
|
133 |
end; |
|
134 |
||
1120 | 135 |
//////////////////////////////// |
136 |
procedure Resize(w, h: LongInt); |
|
137 |
begin |
|
138 |
cScreenWidth:= w; |
|
139 |
cScreenHeight:= h; |
|
140 |
if cFullScreen then |
|
141 |
ParseCommand('/fullscr 1', true) |
|
142 |
else |
|
143 |
ParseCommand('/fullscr 0', true); |
|
144 |
end; |
|
145 |
||
51 | 146 |
/////////////////// |
147 |
procedure MainLoop; |
|
148 |
var PrevTime, |
|
188 | 149 |
CurrTime: Longword; |
51 | 150 |
event: TSDL_Event; |
151 |
begin |
|
152 |
PrevTime:= SDL_GetTicks; |
|
153 |
repeat |
|
154 |
while SDL_PollEvent(@event) <> 0 do |
|
1120 | 155 |
case event.type_ of |
156 |
SDL_KEYDOWN: if GameState = gsChat then KeyPressChat(event.key.keysym.unicode); |
|
157 |
SDL_ACTIVEEVENT: if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then |
|
158 |
cHasFocus:= event.active.gain = 1; |
|
1127 | 159 |
//SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450)); |
1120 | 160 |
SDL_QUITEV: isTerminated:= true |
161 |
end; |
|
51 | 162 |
CurrTime:= SDL_GetTicks; |
163 |
if PrevTime + cTimerInterval <= CurrTime then |
|
164 |
begin |
|
165 |
DoTimer(CurrTime - PrevTime); |
|
166 |
PrevTime:= CurrTime |
|
434 | 167 |
end else SDL_Delay(1); |
51 | 168 |
IPCCheckSock |
169 |
until isTerminated |
|
170 |
end; |
|
171 |
||
172 |
//////////////////// |
|
173 |
procedure GetParams; |
|
889 | 174 |
var |
267 | 175 |
{$IFDEF DEBUGFILE} |
371 | 176 |
i: LongInt; |
267 | 177 |
{$ENDIF} |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
81
diff
changeset
|
178 |
p: TPathType; |
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
81
diff
changeset
|
179 |
begin |
51 | 180 |
{$IFDEF DEBUGFILE} |
97
e7c1df9cce2c
- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
unc0rr
parents:
81
diff
changeset
|
181 |
AddFileLog('Prefix: "' + PathPrefix +'"'); |
51 | 182 |
for i:= 0 to ParamCount do |
183 |
AddFileLog(inttostr(i) + ': ' + ParamStr(i)); |
|
184 |
{$ENDIF} |
|
267 | 185 |
|
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
186 |
case ParamCount of |
1128 | 187 |
15: begin |
498 | 188 |
val(ParamStr(2), cScreenWidth); |
189 |
val(ParamStr(3), cScreenHeight); |
|
1121
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
190 |
cInitWidth:= cScreenWidth; |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
191 |
cInitHeight:= cScreenHeight; |
497 | 192 |
cBitsStr:= ParamStr(4); |
498 | 193 |
val(cBitsStr, cBits); |
194 |
val(ParamStr(5), ipcPort); |
|
497 | 195 |
cFullScreen:= ParamStr(6) = '1'; |
196 |
isSoundEnabled:= ParamStr(7) = '1'; |
|
197 |
cLocaleFName:= ParamStr(8); |
|
498 | 198 |
val(ParamStr(9), cInitVolume); |
199 |
val(ParamStr(10), cTimerInterval); |
|
497 | 200 |
PathPrefix:= ParamStr(11); |
201 |
cShowFPS:= ParamStr(12) = '1'; |
|
529 | 202 |
cAltDamage:= ParamStr(13) = '1'; |
949 | 203 |
UserNick:= DecodeBase64(ParamStr(14)); |
1128 | 204 |
isMusicEnabled:= ParamStr(15) = '1'; |
267 | 205 |
for p:= Succ(Low(TPathType)) to High(TPathType) do |
949 | 206 |
if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p] |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
207 |
end; |
497 | 208 |
3: begin |
498 | 209 |
val(ParamStr(2), ipcPort); |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
210 |
GameType:= gmtLandPreview; |
497 | 211 |
if ParamStr(3) <> 'landpreview' then OutError(errmsgShouldntRun, true); |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
212 |
end |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
213 |
else |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
214 |
OutError(errmsgShouldntRun, true) |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
215 |
end |
51 | 216 |
end; |
217 |
||
218 |
procedure ShowMainWindow; |
|
219 |
begin |
|
351 | 220 |
if cFullScreen then ParseCommand('fullscr 1', true) |
221 |
else ParseCommand('fullscr 0', true); |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
271
diff
changeset
|
222 |
SDL_ShowCursor(0) |
51 | 223 |
end; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
224 |
|
160 | 225 |
/////////////// |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
226 |
procedure Game; |
205 | 227 |
var s: shortstring; |
51 | 228 |
begin |
229 |
WriteToConsole('Init SDL... '); |
|
230 |
SDLTry(SDL_Init(SDL_INIT_VIDEO) >= 0, true); |
|
231 |
WriteLnToConsole(msgOK); |
|
753 | 232 |
|
377 | 233 |
SDL_EnableUNICODE(1); |
51 | 234 |
|
235 |
WriteToConsole('Init SDL_ttf... '); |
|
200 | 236 |
SDLTry(TTF_Init <> -1, true); |
51 | 237 |
WriteLnToConsole(msgOK); |
238 |
||
239 |
ShowMainWindow; |
|
240 |
||
241 |
InitKbdKeyTable; |
|
242 |
InitIPC; |
|
243 |
WriteLnToConsole(msgGettingConfig); |
|
80 | 244 |
|
245 |
LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName); |
|
246 |
||
247 |
SendIPCAndWaitReply('C'); // ask for game config |
|
205 | 248 |
|
249 |
s:= 'eproto ' + inttostr(cNetProtoVersion); |
|
250 |
SendIPCRaw(@s[0], Length(s) + 1); // send proto version |
|
251 |
||
51 | 252 |
InitTeams; |
288 | 253 |
AssignStores; |
51 | 254 |
|
255 |
if isSoundEnabled then InitSound; |
|
256 |
InitWorld; |
|
257 |
||
258 |
StoreInit; |
|
259 |
||
260 |
isDeveloperMode:= false; |
|
261 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
54
diff
changeset
|
262 |
TryDo(InitStepsFlags = cifAllInited, |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
54
diff
changeset
|
263 |
'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
54
diff
changeset
|
264 |
true); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
54
diff
changeset
|
265 |
|
51 | 266 |
MainLoop |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
267 |
end; |
51 | 268 |
|
160 | 269 |
///////////////////////// |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
270 |
procedure GenLandPreview; |
566 | 271 |
var Preview: TPreview; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
272 |
begin |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
273 |
InitIPC; |
159 | 274 |
IPCWaitPongEvent; |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
275 |
TryDo(InitStepsFlags = cifRandomize, |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
276 |
'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
277 |
true); |
160 | 278 |
|
566 | 279 |
Preview:= GenPreview; |
159 | 280 |
WriteLnToConsole('Sending preview...'); |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
281 |
SendIPCRaw(@Preview, sizeof(Preview)); |
159 | 282 |
WriteLnToConsole('Preview sent, disconnect'); |
158 | 283 |
CloseIPC |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
284 |
end; |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
285 |
|
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
286 |
//////////////////////////////////////////////////////////////////////////////// |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
287 |
/////////////////////////////// m a i n //////////////////////////////////////// |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
288 |
//////////////////////////////////////////////////////////////////////////////// |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
289 |
|
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
290 |
begin |
907 | 291 |
WriteLnToConsole('-= Hedgewars ' + cVersionString + ' =-'); |
720 | 292 |
WriteLnToConsole(' -= by unC0Rr =- '); |
155
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
293 |
GetParams; |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
294 |
Randomize; |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
295 |
|
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
296 |
if GameType = gmtLandPreview then GenLandPreview |
401f4ea24715
Engine can generate land preview and send it via IPC
unc0rr
parents:
109
diff
changeset
|
297 |
else Game |
51 | 298 |
end. |