Made user data path default to '.'. flibqtfrontend
authorJoe Doyle (Ginto8) <ginto8@gmail.com>
Mon, 03 Dec 2012 17:38:31 -0500
branchflibqtfrontend
changeset 8212 49eb757a1a4d
parent 8210 ad178654142a
child 8214 8edc37cdcfbf
Made user data path default to '.'.
hedgewars/ArgParsers.inc
hedgewars/hwengine.pas
--- a/hedgewars/ArgParsers.inc	Tue Dec 04 22:31:22 2012 +0400
+++ b/hedgewars/ArgParsers.inc	Mon Dec 03 17:38:31 2012 -0500
@@ -68,7 +68,7 @@
 begin
     WriteLn(stdout, 'Usage:');
     WriteLn(stdout, '');
-    WriteLn(stdout, '  hwengine <path to user hedgewars folder> <path to global data folder> <path to replay file> [options]');
+    WriteLn(stdout, '  hwengine [path to user hedgewars folder] <path to global data folder> <path to replay file> [options]');
     WriteLn(stdout, '');
     WriteLn(stdout, 'where [options] are any of the following:');
     WriteLn(stdout, ' --locale [path to language file]');
@@ -206,14 +206,10 @@
         end;
 end;
 
-procedure playReplayFileWithParameters();
-var paramIndex, tmpInt: LongInt;
+procedure playReplayFileWithParameters(paramIndex: LongInt);
+var tmpInt: LongInt;
     wrongParameter: boolean;
 begin
-    UserPathPrefix:= ParamStr(1);
-    PathPrefix:= ParamStr(2);
-    recordFileName:= ParamStr(3);
-    paramIndex:= 4;
     wrongParameter:= false;
     while (paramIndex <= ParamCount) do
         begin
--- a/hedgewars/hwengine.pas	Tue Dec 04 22:31:22 2012 +0400
+++ b/hedgewars/hwengine.pas	Mon Dec 03 17:38:31 2012 -0500
@@ -541,23 +541,44 @@
 {$INCLUDE "ArgParsers.inc"}
 
 procedure GetParams;
-var tmpInt: LongInt;
+var startIndex,tmpInt: LongInt;
+    debug: string;
 begin
-    if (ParamCount < 3) then
+    if (ParamCount < 2) then
         begin
         DisplayUsage();
         GameType:= gmtSyntax;
         end
     else
-        if (ParamCount = 3) and (ParamStr(3) = 'landpreview') then
+        begin
+        if (ParamCount >= 2) then
+            begin
+            UserPathPrefix := ParamStr(1);
+            PathPrefix     := ParamStr(2)
+            end;
+        if (ParamCount >= 3) then
+            recordFilename := ParamStr(3);
+        if (ParamCount = 2) or
+           ((ParamCount >= 3) and (Copy(recordFileName,1,2) = '--')) then
+            begin
+            recordFileName := PathPrefix;
+            PathPrefix     := UserPathPrefix;
+            UserPathPrefix := '.';
+            startIndex := 3;
+            end
+        else
+            startIndex := 4;
+        if (ParamCount = startIndex) and 
+           (ParamStr(startIndex) = 'landpreview') then
             begin
             ipcPort:= StrToInt(ParamStr(2));
             GameType:= gmtLandPreview;
             end
         else
             begin
-            if (ParamCount = 3) and (ParamStr(3) = '--stats-only') then
-                playReplayFileWithParameters()
+            if (ParamCount = startIndex) and 
+               (ParamStr(startIndex) = '--stats-only') then
+                playReplayFileWithParameters(startIndex)
             else
                 if ParamCount = cDefaultParamNum then
                     internalStartGameWithParameters()
@@ -566,8 +587,12 @@
                     internalStartVideoRecordingWithParameters()
 {$ENDIF}
                 else
-                    playReplayFileWithParameters();
+                    playReplayFileWithParameters(startIndex);
             end
+        end;
+    WriteLn(stdout,recordFilename);
+    WriteLn(stdout,PathPrefix);
+    WriteLn(stdout,UserPathPrefix);
 end;
 
 ///////////////////////////////////////////////////////////////////////////////