# HG changeset patch # User sheepluva # Date 1402783345 -7200 # Node ID 4fca8bcfaff0751f4c9e313dcd37eab176a6c6b0 # Parent 17f3ca06e39af3481107cf890217270e0b362002 clean up halting a little diff -r 17f3ca06e39a -r 4fca8bcfaff0 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Sat Jun 14 23:59:20 2014 +0200 +++ b/hedgewars/hwengine.pas Sun Jun 15 00:02:25 2014 +0200 @@ -575,9 +575,9 @@ // return 1 when engine is not called correctly if GameType = gmtSyntax then {$IFDEF PAS2C} - exit(1); + exit(HaltUsageError); {$ELSE} - halt(1); + halt(HaltUsageError); {$ENDIF} {$IFDEF HWLIBRARY} diff -r 17f3ca06e39a -r 4fca8bcfaff0 hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Sat Jun 14 23:59:20 2014 +0200 +++ b/hedgewars/uConsts.pas Sun Jun 15 00:02:25 2014 +0200 @@ -26,6 +26,17 @@ {$INCLUDE "config.inc"} const + HaltNoError = 0; + HaltUsageError = 1; + HaltFatalError = 2; + HaltStartupError = 3; + + // for automatic tests + HaltTestSuccess = 0; + HaltTestFailed = 10; + HaltTestLuaError = 11; + + sfMax = 1000; // message constants @@ -302,10 +313,6 @@ kSystemSoundID_Vibrate = $00000FFF; - rtnTestSuccess = $00000000; - rtnTestFailed = $00000001; - rtnTestLuaErr = $00000002; - implementation end. diff -r 17f3ca06e39a -r 4fca8bcfaff0 hedgewars/uDebug.pas --- a/hedgewars/uDebug.pas Sat Jun 14 23:59:20 2014 +0200 +++ b/hedgewars/uDebug.pas Sun Jun 15 00:02:25 2014 +0200 @@ -27,13 +27,18 @@ procedure SDLTry(Assert: boolean; isFatal: boolean); implementation -uses SDLh, uConsole, uCommands; +uses SDLh, uConsole, uCommands, uConsts; procedure OutError(Msg: shortstring; isFatalError: boolean); begin WriteLnToConsole(Msg); if isFatalError then + begin ParseCommand('fatal ' + lastConsoleline, true); + // hint for the 'coverity' source analyzer + // this halt is never actually reached because ParseCommands will halt first + halt(HaltFatalError); + end; end; procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); diff -r 17f3ca06e39a -r 4fca8bcfaff0 hedgewars/uIO.pas --- a/hedgewars/uIO.pas Sat Jun 14 23:59:20 2014 +0200 +++ b/hedgewars/uIO.pas Sun Jun 15 00:02:25 2014 +0200 @@ -416,7 +416,7 @@ SendIPC('E' + s); // TODO: should we try to clean more stuff here? SDL_Quit; - halt(2) + halt(HaltFatalError); end; procedure doPut(putX, putY: LongInt; fromAI: boolean); diff -r 17f3ca06e39a -r 4fca8bcfaff0 hedgewars/uMatrix.pas --- a/hedgewars/uMatrix.pas Sat Jun 14 23:59:20 2014 +0200 +++ b/hedgewars/uMatrix.pas Sun Jun 15 00:02:25 2014 +0200 @@ -44,6 +44,8 @@ implementation +uses uDebug; + const MATRIX_STACK_SIZE = 10; @@ -258,7 +260,7 @@ write(Result[i, j]); writeln; end; - halt(0); + TryDo(false, 'error in matrix multiplication?!', true); end; {$ENDIF} diff -r 17f3ca06e39a -r 4fca8bcfaff0 hedgewars/uRender.pas --- a/hedgewars/uRender.pas Sat Jun 14 23:59:20 2014 +0200 +++ b/hedgewars/uRender.pas Sun Jun 15 00:02:25 2014 +0200 @@ -159,7 +159,7 @@ if IOResult <> 0 then begin AddFileLog('Unable to load ' + shaderFile); - halt(-1); + halt(HaltStartupError); end; source:=''; @@ -195,7 +195,7 @@ if compileResult <> GL_TRUE then begin WriteLnToConsole('Shader compilation failed, halting'); - halt(-1); + halt(HaltStartupError); end; CompileShader:= shader; @@ -239,7 +239,7 @@ if linkResult <> GL_TRUE then begin WriteLnToConsole('Linking program failed, halting'); - halt(-1); + halt(HaltStartupError); end; CompileProgram:= program_; @@ -333,7 +333,7 @@ if err <> GLEW_OK then begin WriteLnToConsole('Failed to initialize GLEW.'); - halt; + halt(HaltStartupError); end; {$ENDIF} diff -r 17f3ca06e39a -r 4fca8bcfaff0 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Sat Jun 14 23:59:20 2014 +0200 +++ b/hedgewars/uScript.pas Sun Jun 15 00:02:25 2014 +0200 @@ -136,7 +136,7 @@ WriteLnToConsole(s); AddChatString(#5 + s); if cTestLua then - halt(rtnTestLuaErr); + halt(HaltTestLuaError); end; procedure LuaCallError(error, call, paramsyntax: shortstring); @@ -2849,8 +2849,8 @@ if cTestLua then begin - ScriptSetInteger('TEST_SUCCESSFUL' ,rtnTestSuccess); - ScriptSetInteger('TEST_FAILED' ,rtnTestFailed); + ScriptSetInteger('TEST_SUCCESSFUL' , HaltTestSuccess); + ScriptSetInteger('TEST_FAILED' , HaltTestFailed); lua_register(luaState, _P'EndLuaTest', @lc_endluatest); end; diff -r 17f3ca06e39a -r 4fca8bcfaff0 hedgewars/uVideoRec.pas --- a/hedgewars/uVideoRec.pas Sat Jun 14 23:59:20 2014 +0200 +++ b/hedgewars/uVideoRec.pas Sun Jun 15 00:02:25 2014 +0200 @@ -117,7 +117,7 @@ , PChar(ansistring(cVideoCodec)) , PChar(ansistring(cAudioCodec)) , cScreenWidth, cScreenHeight, cVideoFramerateNum, cVideoFramerateDen, cVideoQuality) < 0 then - halt(-1); + halt(HaltFatalError); numPixels:= cScreenWidth*cScreenHeight; YCbCr_Planes[0]:= GetMem(numPixels);