--- a/hedgewars/hwengine.pas Wed Jan 13 16:19:50 2016 +0100
+++ b/hedgewars/hwengine.pas Sun Jan 10 00:45:13 2016 +0300
@@ -342,18 +342,23 @@
AddFileLog(inttostr(i) + ': ' + ParamStr(i));
WriteToConsole('Init SDL... ');
- if not cOnlyStats then SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, 'SDL_Init', true);
+ if not cOnlyStats then SDLCheck(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, 'SDL_Init', true);
WriteLnToConsole(msgOK);
+ if not cOnlyStats then
+ begin
+ WriteToConsole('Init SDL_ttf... ');
+ SDLCheck(TTF_Init() <> -1, 'TTF_Init', true);
+ WriteLnToConsole(msgOK);
+ end;
+ if not allOK then
+ begin
+ freeEverything(true);
+ exit
+ end;
//SDL_StartTextInput();
SDL_ShowCursor(0);
- if not cOnlyStats then
- begin
- WriteToConsole('Init SDL_ttf... ');
- SDLTry(TTF_Init() <> -1, 'TTF_Init', true);
- WriteLnToConsole(msgOK);
- end;
{$IFDEF USE_VIDEO_RECORDING}
if GameType = gmtRecord then
@@ -401,32 +406,35 @@
LoadRecordFromFile(recordFileName);
end;
- ScriptOnGameInit;
- s:= 'eproto ' + inttostr(cNetProtoVersion);
- SendIPCRaw(@s[0], Length(s) + 1); // send proto version
+ if allOK then
+ begin
+ ScriptOnGameInit;
+ s:= 'eproto ' + inttostr(cNetProtoVersion);
+ SendIPCRaw(@s[0], Length(s) + 1); // send proto version
- InitTeams();
- AssignStores();
+ InitTeams();
+ AssignStores();
- if GameType = gmtRecord then
- SetSound(false);
+ if GameType = gmtRecord then
+ SetSound(false);
- InitSound();
+ InitSound();
- isDeveloperMode:= false;
- TryDo(InitStepsFlags = cifAllInited, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
- //ParseCommand('rotmask', true);
+ isDeveloperMode:= false;
+ TryDo(InitStepsFlags = cifAllInited, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
+ //ParseCommand('rotmask', true);
-{$IFDEF USE_VIDEO_RECORDING}
- if GameType = gmtRecord then
- begin
- RecorderMainLoop();
- freeEverything(true);
- exit;
+ {$IFDEF USE_VIDEO_RECORDING}
+ if GameType = gmtRecord then
+ begin
+ RecorderMainLoop();
+ freeEverything(true);
+ exit;
+ end;
+ {$ENDIF}
+
+ MainLoop;
end;
-{$ENDIF}
-
- MainLoop;
// clean up all the memory allocated
freeEverything(true);
end;
@@ -437,6 +445,7 @@
// freeEverything - free above. Pay attention to the init/free order!
procedure preInitEverything;
begin
+ allOK:= true;
Randomize();
uVariables.preInitModule;
@@ -537,19 +546,23 @@
initEverything(false);
InitIPC;
- IPCWaitPongEvent;
- TryDo(InitStepsFlags = cifRandomize, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
+ if allOK then
+ begin
+ IPCWaitPongEvent;
+ TryDo(InitStepsFlags = cifRandomize, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
- ScriptOnPreviewInit;
-{$IFDEF MOBILE}
- GenPreview(Preview);
-{$ELSE}
- GenPreviewAlpha(Preview);
-{$ENDIF}
- WriteLnToConsole('Sending preview...');
- SendIPCRaw(@Preview, sizeof(Preview));
- SendIPCRaw(@MaxHedgehogs, sizeof(byte));
- WriteLnToConsole('Preview sent, disconnect');
+ ScriptOnPreviewInit;
+ {$IFDEF MOBILE}
+ GenPreview(Preview);
+ {$ELSE}
+ GenPreviewAlpha(Preview);
+ {$ENDIF}
+ WriteLnToConsole('Sending preview...');
+ SendIPCRaw(@Preview, sizeof(Preview));
+ SendIPCRaw(@MaxHedgehogs, sizeof(byte));
+ WriteLnToConsole('Preview sent, disconnect');
+ end;
+
freeEverything(false);
end;