equal
deleted
inserted
replaced
205 IPCCheckSock(); |
205 IPCCheckSock(); |
206 end; |
206 end; |
207 end; |
207 end; |
208 end; |
208 end; |
209 |
209 |
210 ///////////////////////// |
|
211 procedure ShowMainWindow; |
|
212 begin |
|
213 if cFullScreen then ParseCommand('fullscr 1', true) |
|
214 else ParseCommand('fullscr 0', true); |
|
215 SDL_ShowCursor(0) |
|
216 end; |
|
217 |
|
218 /////////////// |
210 /////////////// |
219 {$IFDEF HWLIBRARY} |
211 {$IFDEF HWLIBRARY} |
220 procedure Game(gameArgs: PPChar); cdecl; export; |
212 procedure Game(gameArgs: PPChar); cdecl; export; |
221 {$ELSE} |
213 {$ELSE} |
222 procedure Game; |
214 procedure Game; |
249 val(gameArgs[9], rotationQt); |
241 val(gameArgs[9], rotationQt); |
250 recordFileName:= gameArgs[10]; |
242 recordFileName:= gameArgs[10]; |
251 cStereoMode:= smNone; |
243 cStereoMode:= smNone; |
252 {$ENDIF} |
244 {$ENDIF} |
253 |
245 |
254 cLogfileBase:= 'game'; |
|
255 initEverything(true); |
246 initEverything(true); |
256 WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')'); |
247 WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')'); |
257 AddFileLog('Prefix: "' + PathPrefix +'"'); |
248 AddFileLog('Prefix: "' + PathPrefix +'"'); |
258 AddFileLog('UserPrefix: "' + UserPathPrefix +'"'); |
249 AddFileLog('UserPrefix: "' + UserPathPrefix +'"'); |
259 for i:= 0 to ParamCount do |
250 for i:= 0 to ParamCount do |
270 WriteToConsole('Init SDL... '); |
261 WriteToConsole('Init SDL... '); |
271 SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true); |
262 SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true); |
272 WriteLnToConsole(msgOK); |
263 WriteLnToConsole(msgOK); |
273 |
264 |
274 SDL_EnableUNICODE(1); |
265 SDL_EnableUNICODE(1); |
|
266 SDL_ShowCursor(0); |
275 |
267 |
276 WriteToConsole('Init SDL_ttf... '); |
268 WriteToConsole('Init SDL_ttf... '); |
277 SDLTry(TTF_Init() <> -1, true); |
269 SDLTry(TTF_Init() <> -1, true); |
278 WriteLnToConsole(msgOK); |
270 WriteLnToConsole(msgOK); |
279 |
271 |
280 {$IFDEF WIN32} |
272 // show main window |
281 s:= SDL_getenv('SDL_VIDEO_CENTERED'); |
273 if cFullScreen then ParseCommand('fullscr 1', true) |
282 SDL_putenv('SDL_VIDEO_CENTERED=1'); |
274 else ParseCommand('fullscr 0', true); |
283 ShowMainWindow(); |
|
284 SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s)); |
|
285 {$ELSE} |
|
286 ShowMainWindow(); |
|
287 {$ENDIF} |
|
288 |
275 |
289 ControllerInit(); // has to happen before InitKbdKeyTable to map keys |
276 ControllerInit(); // has to happen before InitKbdKeyTable to map keys |
290 InitKbdKeyTable(); |
277 InitKbdKeyTable(); |
291 AddProgress(); |
278 AddProgress(); |
292 |
279 |
343 end; |
330 end; |
344 |
331 |
345 procedure initEverything (complete:boolean); |
332 procedure initEverything (complete:boolean); |
346 begin |
333 begin |
347 Randomize(); |
334 Randomize(); |
|
335 |
|
336 if complete then cLogfileBase:= 'game' |
|
337 else cLogfileBase:= 'preview'; |
348 |
338 |
349 // uConsts does not need initialization as they are all consts |
339 // uConsts does not need initialization as they are all consts |
350 uUtils.initModule; |
340 uUtils.initModule; |
351 uMisc.initModule; |
341 uMisc.initModule; |
352 uVariables.initModule; |
342 uVariables.initModule; |
438 |
428 |
439 ///////////////////////// |
429 ///////////////////////// |
440 procedure GenLandPreview{$IFDEF HWLIBRARY}(port: LongInt); cdecl; export{$ENDIF}; |
430 procedure GenLandPreview{$IFDEF HWLIBRARY}(port: LongInt); cdecl; export{$ENDIF}; |
441 var Preview: TPreview; |
431 var Preview: TPreview; |
442 begin |
432 begin |
443 cLogfileBase:= 'preview'; |
|
444 initEverything(false); |
433 initEverything(false); |
445 {$IFDEF HWLIBRARY} |
434 {$IFDEF HWLIBRARY} |
446 WriteLnToConsole('Preview connecting on port ' + inttostr(port)); |
435 WriteLnToConsole('Preview connecting on port ' + inttostr(port)); |
447 ipcPort:= port; |
436 ipcPort:= port; |
448 {$ENDIF} |
437 {$ENDIF} |
509 |
498 |
510 if GameType = gmtLandPreview then GenLandPreview() |
499 if GameType = gmtLandPreview then GenLandPreview() |
511 else if GameType = gmtSyntax then DisplayUsage() |
500 else if GameType = gmtSyntax then DisplayUsage() |
512 else Game(); |
501 else Game(); |
513 |
502 |
514 if GameType = gmtSyntax then |
503 // return 1 when engine is not called correctly |
515 ExitCode:= 1 |
504 ExitCode:= LongInt(GameType = gmtSyntax); |
516 else |
|
517 ExitCode:= 0; |
|
518 {$ENDIF} |
505 {$ENDIF} |
519 end. |
506 end. |