# HG changeset patch # User unc0rr # Date 1410553630 -14400 # Node ID 1baaab44a0b2c92931aca463c49647ec8fd15bb2 # Parent 3313336c1ee00f357ab65dd9b6d950e32cff6bc3 - Fix arguments parsing in engine assuming paramcount > 0 - Pass "--help" for testing diff -r 3313336c1ee0 -r 1baaab44a0b2 hedgewars/ArgParsers.pas --- a/hedgewars/ArgParsers.pas Fri Sep 12 00:51:14 2014 +0400 +++ b/hedgewars/ArgParsers.pas Sat Sep 13 00:27:10 2014 +0400 @@ -332,12 +332,12 @@ paramTotal: LongInt; index, nextIndex: LongInt; wrongParameter: boolean; -//var tmpInt: LongInt; +var tmpInt: LongInt; begin paramIndex:= 1; paramTotal:= ParamCount; //-1 because pascal enumeration is inclusive - (* + WriteLn(stdout, 'total parameters: ' + inttostr(paramTotal)); tmpInt:= 0; while (tmpInt <= paramTotal) do @@ -345,7 +345,7 @@ WriteLn(stdout, inttostr(tmpInt) + ': ' + {$IFDEF HWLIBRARY}argv[tmpInt]{$ELSE}paramCount(tmpInt){$ENDIF}); inc(tmpInt); end; - *) + wrongParameter:= false; while (paramIndex <= paramTotal) do begin @@ -362,26 +362,31 @@ procedure GetParams; begin - isInternal:= (ParamStr(1) = '--internal'); - - UserPathPrefix := _S'.'; - PathPrefix := cDefaultPathPrefix; - recordFileName := ''; - parseCommandLine(); - - if (isInternal) and (ParamCount<=1) then + if ParamCount > 0 then begin - WriteLn(stderr, '--internal should not be manually used'); - GameType := gmtSyntax; - end; + isInternal:= (ParamStr(1) = '--internal'); + + UserPathPrefix := _S'.'; + PathPrefix := cDefaultPathPrefix; + recordFileName := ''; + parseCommandLine(); - if (not cTestLua) and (not isInternal) and (recordFileName = '') then - begin - WriteLn(stderr, 'You must specify a replay file'); - GameType := gmtSyntax; - end - else if (recordFileName <> '') then - WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"'); + if (isInternal) and (ParamCount<=1) then + begin + WriteLn(stderr, '--internal should not be manually used'); + GameType := gmtSyntax; + end; + + if (not cTestLua) and (not isInternal) and (recordFileName = '') then + begin + WriteLn(stderr, 'You must specify a replay file'); + GameType := gmtSyntax; + end + else if (recordFileName <> '') then + WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"'); + end + else + GameType:= gmtSyntax; if (GameType = gmtSyntax) then WriteLn(stderr, 'Please use --help to see possible arguments and their usage'); diff -r 3313336c1ee0 -r 1baaab44a0b2 hedgewars/uRender.pas --- a/hedgewars/uRender.pas Fri Sep 12 00:51:14 2014 +0400 +++ b/hedgewars/uRender.pas Sat Sep 13 00:27:10 2014 +0400 @@ -101,8 +101,7 @@ implementation uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}SysUtils, uVariables, uUtils, uConsts - {$IFDEF GL2}, uMatrix, uConsole{$ENDIF} - {$IF NOT DEFINED(SDL2) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; + {$IFDEF GL2}, uMatrix, uConsole{$ENDIF}; {$IFDEF USE_TOUCH_INTERFACE} const diff -r 3313336c1ee0 -r 1baaab44a0b2 qmlFrontend/hwengine.cpp --- a/qmlFrontend/hwengine.cpp Fri Sep 12 00:51:14 2014 +0400 +++ b/qmlFrontend/hwengine.cpp Sat Sep 13 00:27:10 2014 +0400 @@ -1,5 +1,6 @@ #include #include +#include #include "hwengine.h" @@ -10,10 +11,10 @@ HWEngine::HWEngine(QObject *parent) : QObject(parent) { - QLibrary hwlib("hwengine"); + QLibrary hwlib("./libhwengine.so"); if(!hwlib.load()) - qWarning("Engine library not found"); + qWarning() << "Engine library not found" << hwlib.errorString(); RunEngine = (void (*)(int, char **))hwlib.resolve("RunEngine"); } @@ -25,7 +26,8 @@ void HWEngine::run() { - RunEngine(0, nullptr); + char* args[2] = {"", "--help"}; + RunEngine(2, args); } static QObject *hwengine_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)