Add proper exit codes when halt-ing hwengine due to error
authorWuzzy <Wuzzy2@mail.ru>
Tue, 17 Jul 2018 14:20:58 +0200
changeset 13495 b5f8864a38d3
parent 13494 424944a835a7
child 13496 cbda0f842364
Add proper exit codes when halt-ing hwengine due to error
hedgewars/uConsts.pas
hedgewars/uRender.pas
hedgewars/uVideoRec.pas
--- a/hedgewars/uConsts.pas	Tue Jul 17 12:55:07 2018 +0200
+++ b/hedgewars/uConsts.pas	Tue Jul 17 14:20:58 2018 +0200
@@ -37,6 +37,7 @@
     HaltFatalError      =  52;
     HaltStartupError    =  53;
     HaltFatalErrorNoIPC =  54;
+    HaltVideoRec        =  55;
 
     // for automatic tests
     HaltTestSuccess     =  0;
--- a/hedgewars/uRender.pas	Tue Jul 17 12:55:07 2018 +0200
+++ b/hedgewars/uRender.pas	Tue Jul 17 14:20:58 2018 +0200
@@ -527,7 +527,10 @@
 
 {$IFNDEF PAS2C}
     if not Load_GL_VERSION_2_0 then
-        halt;
+        begin
+        WriteLnToConsole('Load_GL_VERSION_2_0 returned false!');
+        halt(HaltStartupError);
+        end;
 {$ENDIF}
 
     shaderWater:= CompileProgram('water');
--- a/hedgewars/uVideoRec.pas	Tue Jul 17 12:55:07 2018 +0200
+++ b/hedgewars/uVideoRec.pas	Tue Jul 17 14:20:58 2018 +0200
@@ -48,7 +48,7 @@
 procedure freeModule;
 
 implementation
-uses uVariables, GLunit, SDLh, SysUtils, uUtils, uIO, uMisc, uTypes, uDebug;
+uses uVariables, GLunit, SDLh, SysUtils, uUtils, uIO, uMisc, uConsts, uTypes, uDebug;
 
 type TAddFileLogRaw = procedure (s: pchar); cdecl;
 const AvwrapperLibName = 'libavwrapper';
@@ -153,7 +153,10 @@
     FreeMem(RGB_Buffer, 4*numPixels);
     Close(cameraFile);
     if AVWrapper_Close() < 0 then
-        halt(-1);
+        begin
+        AddFileLog('AVWrapper_Close() has failed.');
+        halt(HaltVideoRec);
+        end;
     Erase(cameraFile);
     if recordAudio then
         DeleteFile(soundFilePath);
@@ -167,7 +170,10 @@
     glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, RGB_Buffer);
 
     if AVWrapper_WriteFrame(RGB_Buffer) < 0 then
-        halt(-1);
+        begin
+        AddFileLog('AVWrapper_WriteFrame(RGB_Buffer) has failed.');
+        halt(HaltVideoRec);
+        end;
 
     // inform frontend that we have encoded new frame
     s[0]:= #3;