Merge
authorJoe Doyle (Ginto8) <ginto8@gmail.com>
Sat, 01 Dec 2012 15:14:34 -0500
changeset 8172 aaa64f03ac62
parent 8170 b0abfa1a4d4a (diff)
parent 8169 c76a00ad070c (current diff)
child 8174 df02c2ad4a2c
Merge
--- a/hedgewars/ArgParsers.inc	Sat Dec 01 04:36:27 2012 +0100
+++ b/hedgewars/ArgParsers.inc	Sat Dec 01 15:14:34 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]');
@@ -195,13 +195,9 @@
         end;
 end;
 
-procedure playReplayFileWithParameters();
-var paramIndex, tmpInt: LongInt;
-    wrongParameter: boolean;
+procedure playReplayFileWithParameters(paramIndex: LongInt);
+var wrongParameter: boolean;
 begin
-    UserPathPrefix:= ParamStr(1);
-    PathPrefix:= ParamStr(2);
-    recordFileName:= ParamStr(3);
     paramIndex:= 4;
     wrongParameter:= false;
     while (paramIndex <= ParamCount) do
--- a/hedgewars/hwengine.pas	Sat Dec 01 04:36:27 2012 +0100
+++ b/hedgewars/hwengine.pas	Sat Dec 01 15:14:34 2012 -0500
@@ -541,23 +541,41 @@
 {$INCLUDE "ArgParsers.inc"}
 
 procedure GetParams;
-var tmpInt: LongInt;
+var startIndex: LongInt;
+    tmpInt: LongInt;
 begin
-    if (ParamCount < 3) then
-        begin
+    if (ParamCount < 2) then
         DisplayUsage();
-        GameType:= gmtSyntax;
-        end
+        GameType:= gmtSyntax
     else
-        if (ParamCount = 3) and (ParamStr(3) = 'landpreview') then
+        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;
+            startIndex := 3;
+            WriteLn(stdout,'defaulting UserPathPrefix')
+            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,7 +584,7 @@
                     internalStartVideoRecordingWithParameters()
 {$ENDIF}
                 else
-                    playReplayFileWithParameters();
+                    playReplayFileWithParameters(startIndex);
             end
 end;