- Fix arguments parsing in engine assuming paramcount > 0 qmlfrontend
authorunc0rr
Sat, 13 Sep 2014 00:27:10 +0400
branchqmlfrontend
changeset 10404 1baaab44a0b2
parent 10402 3313336c1ee0
child 10406 b5fd52ac760f
- Fix arguments parsing in engine assuming paramcount > 0 - Pass "--help" for testing
hedgewars/ArgParsers.pas
hedgewars/uRender.pas
qmlFrontend/hwengine.cpp
--- 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');
--- 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
--- 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 <QLibrary>
 #include <QtQml>
+#include <QDebug>
 
 #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)