author | vitiv <nikita.utiu@gmail.com> |
Thu, 03 Jan 2013 15:59:30 +0200 | |
changeset 8354 | c25bee85d6f8 |
parent 8329 | f14d16c5277a |
child 8359 | 9a7024b2a4d3 |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
6700 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
4976 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
18 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
19 |
procedure GciEasterEgg; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
20 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
21 |
WriteLn(stdout, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
22 |
WriteLn(stdout, ' /\\\\\\\\\\\\ /\\\\\\\\\ /\\\\\\\\\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
23 |
WriteLn(stdout, ' /\\\////////// /\\\//////// \/////\\\/// '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
24 |
WriteLn(stdout, ' /\\\ /\\\/ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
25 |
WriteLn(stdout, ' \/\\\ /\\\\\\\ /\\\ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
26 |
WriteLn(stdout, ' \/\\\ \/////\\\ \/\\\ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
27 |
WriteLn(stdout, ' \/\\\ \/\\\ \//\\\ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
28 |
WriteLn(stdout, ' \/\\\ \/\\\ \///\\\ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
29 |
WriteLn(stdout, ' \/\\\\\\\\\\\\\/ \////\\\\\\\\\ /\\\\\\\\\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
30 |
WriteLn(stdout, ' \///////////// \///////// \/////////// '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
31 |
WriteLn(stdout, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
32 |
WriteLn(stdout, ' Command Line Parser Implementation by a Google Code-In Student '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
33 |
WriteLn(stdout, ' ASCII Art easter egg idea by @sheepluva '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
34 |
WriteLn(stdout, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
35 |
end; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
36 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
37 |
procedure DisplayUsage; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
38 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
39 |
WriteLn(stdout, 'Usage: hwengine <path to replay file> [options]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
40 |
WriteLn(stdout, ''); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
41 |
WriteLn(stdout, 'where [options] can be any of the following:'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
42 |
WriteLn(stdout, ' --prefix [path to folder]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
43 |
WriteLn(stdout, ' --user-prefix [path to folder]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
44 |
WriteLn(stdout, ' --locale [name of language file]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
45 |
WriteLn(stdout, ' --nick [string]'); |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
46 |
WriteLn(stdout, ' --fullscreen-width [fullscreen width in pixels]'); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
47 |
WriteLn(stdout, ' --fullscreen-height [fullscreen height in pixels]'); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
48 |
WriteLn(stdout, ' --width [window width in pixels]'); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
49 |
WriteLn(stdout, ' --height [window height in pixels]'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
50 |
WriteLn(stdout, ' --volume [sound level]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
51 |
WriteLn(stdout, ' --frame-interval [milliseconds]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
52 |
Writeln(stdout, ' --stereo [value]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
53 |
WriteLn(stdout, ' --raw-quality [flags]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
54 |
WriteLn(stdout, ' --low-quality'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
55 |
WriteLn(stdout, ' --nomusic'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
56 |
WriteLn(stdout, ' --nosound'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
57 |
WriteLn(stdout, ' --fullscreen'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
58 |
WriteLn(stdout, ' --showfps'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
59 |
WriteLn(stdout, ' --altdmg'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
60 |
WriteLn(stdout, ' --stats-only'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
61 |
WriteLn(stdout, ' --help'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
62 |
WriteLn(stdout, ''); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
63 |
WriteLn(stdout, 'For more detailed help and examples go to:'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
64 |
WriteLn(stdout, 'http://code.google.com/p/hedgewars/wiki/CommandLineOptions'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
65 |
GameType:= gmtSyntax; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
66 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
67 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
68 |
procedure setDepth(var paramIndex: LongInt); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
69 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
70 |
WriteLn(stdout, 'WARNING: --depth is a deprecated command, which could be removed in a future version!'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
71 |
WriteLn(stdout, ' This option no longer does anything, please consider removing it'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
72 |
WriteLn(stdout, ''); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
73 |
inc(ParamIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
74 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
75 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
76 |
procedure statsOnlyGame; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
77 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
78 |
cOnlyStats:= true; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
79 |
cReducedQuality:= $FFFFFFFF xor rqLowRes; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
80 |
SetSound(false); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
81 |
SetMusic(false); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
82 |
SetVolume(0); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
83 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
84 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
85 |
procedure setIpcPort(port: LongInt; var wrongParameter:Boolean); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
86 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
87 |
if isInternal then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
88 |
ipcPort := port |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
89 |
else |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
90 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
91 |
WriteLn(stderr, 'ERROR: use of --port is not allowed'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
92 |
wrongParameter := true; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
93 |
end |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
94 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
95 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
96 |
function parseNick(nick: String): String; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
97 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
98 |
if isInternal then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
99 |
parseNick:= DecodeBase64(nick) |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
100 |
else |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
101 |
parseNick:= nick; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
102 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
103 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
104 |
procedure setStereoMode(tmp: LongInt); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
105 |
begin |
6982 | 106 |
GrayScale:= false; |
8221 | 107 |
{$IFDEF USE_S3D_RENDERING} |
108 |
if (tmp > 9) and (tmp < 16) then |
|
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5239
diff
changeset
|
109 |
begin |
8221 | 110 |
// set the gray anaglyph rendering |
6982 | 111 |
GrayScale:= true; |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5239
diff
changeset
|
112 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-9))) |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5239
diff
changeset
|
113 |
end |
8221 | 114 |
else if tmp <= 9 then |
115 |
// set the fullcolor anaglyph |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6426
diff
changeset
|
116 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) |
8221 | 117 |
else |
118 |
// any other mode |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6426
diff
changeset
|
119 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); |
8221 | 120 |
{$ELSE} |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
121 |
cStereoMode:= smNone; |
8221 | 122 |
{$ENDIF} |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
123 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
124 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
125 |
procedure startVideoRecording(var paramIndex: LongInt); |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
126 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
127 |
{$IFDEF USE_VIDEO_RECORDING} |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
128 |
GameType:= gmtRecord; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
129 |
inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
130 |
cVideoFramerateNum:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
131 |
cVideoFramerateDen:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
132 |
RecPrefix:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
133 |
cAVFormat:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
134 |
cVideoCodec:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
135 |
cVideoQuality:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
136 |
cAudioCodec:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
137 |
{$ENDIF} |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
138 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
139 |
|
8150 | 140 |
function getLongIntParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt; |
141 |
var tmpInt, c: LongInt; |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
142 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
143 |
inc(paramIndex); |
8150 | 144 |
val(str, tmpInt, c); |
145 |
wrongParameter:= c <> 0; |
|
146 |
if wrongParameter then |
|
147 |
WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"'); |
|
148 |
getLongIntParameter:= tmpInt; |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
149 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
150 |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
151 |
function getStringParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): String; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
152 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
153 |
inc(paramIndex); |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
154 |
wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
155 |
if wrongParameter then |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
156 |
WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); |
8150 | 157 |
getStringParameter:= str; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
158 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
159 |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
160 |
|
8150 | 161 |
procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); Forward; |
162 |
||
163 |
function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean; |
|
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
164 |
const videoArray: Array [1..5] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
165 |
audioArray: Array [1..3] of String = ('--volume','--nomusic','--nosound'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
166 |
otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps'); |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
167 |
mediaArray: Array [1..10] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
168 |
allArray: Array [1..14] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality'); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
169 |
reallyAll: array[0..30] of shortstring = ( |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
170 |
'--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
171 |
'--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
172 |
'--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
173 |
{deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
174 |
{internal} '--internal', '--port', '--recorder', '--landpreview', |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
175 |
{misc} '--stats-only', '--gci', '--help'); |
8197 | 176 |
var cmdIndex: byte; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
177 |
begin |
8150 | 178 |
parseParameter:= false; |
8197 | 179 |
cmdIndex:= 0; |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
180 |
|
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
181 |
//NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above, |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
182 |
// the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
183 |
|
8197 | 184 |
while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
185 |
case cmdIndex of |
|
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
186 |
{--prefix} 0 : PathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
187 |
{--user-prefix} 1 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
188 |
{--locale} 2 : cLocaleFName := getStringParameter (arg, paramIndex, parseParameter); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
189 |
{--fullscreen-width} 3 : cFullscreenWidth := getLongIntParameter(arg, paramIndex, parseParameter); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
190 |
{--fullscreen-height} 4 : cFullscreenHeight := getLongIntParameter(arg, paramIndex, parseParameter); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
191 |
{--width} 5 : cWindowedWidth := getLongIntParameter(arg, paramIndex, parseParameter); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
192 |
{--height} 6 : cWindowedHeight := getLongIntParameter(arg, paramIndex, parseParameter); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
193 |
{--frame-interval} 7 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
194 |
{--volume} 8 : SetVolume ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
195 |
{--nomusic} 9 : SetMusic ( false ); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
196 |
{--nosound} 10 : SetSound ( false ); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
197 |
{--fullscreen} 11 : cFullScreen := true; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
198 |
{--showfps} 12 : cShowFPS := true; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
199 |
{--altdmg} 13 : cAltDamage := true; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
200 |
{--low-quality} 14 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
201 |
{--raw-quality} 15 : cReducedQuality := getLongIntParameter(arg, paramIndex, parseParameter); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
202 |
{--stereo} 16 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
203 |
{--nick} 17 : UserNick := parseNick( getStringParameter(arg, paramIndex, parseParameter) ); |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
204 |
{deprecated options} |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
205 |
{--depth} 18 : setDepth(paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
206 |
{--set-video} 19 : parseClassicParameter(videoArray,5,paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
207 |
{--set-audio} 20 : parseClassicParameter(audioArray,3,paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
208 |
{--set-other} 21 : parseClassicParameter(otherArray,3,paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
209 |
{--set-multimedia} 22 : parseClassicParameter(mediaArray,10,paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
210 |
{--set-everything} 23 : parseClassicParameter(allArray,14,paramIndex); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
211 |
{"internal" options} |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
212 |
{--internal} 24 : {note it, but do nothing}; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
213 |
{--port} 25 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter ); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
214 |
{--recorder} 26 : startVideoRecording(paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
215 |
{--landpreview} 27 : GameType := gmtLandPreview; |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
216 |
{anything else} |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
217 |
{--stats-only} 28 : statsOnlyGame(); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
218 |
{--gci} 29 : GciEasterEgg(); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
219 |
{--help} 30 : DisplayUsage(); |
8150 | 220 |
else |
221 |
begin |
|
8307 | 222 |
//Asusme the first "non parameter" is the replay file, anything else is invalid |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
223 |
if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
8307 | 224 |
recordFileName := cmd |
225 |
else |
|
226 |
begin |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
227 |
WriteLn(stderr, '"'+cmd+'" is not a valid option'); |
8307 | 228 |
parseParameter:= true; |
229 |
end; |
|
230 |
end; |
|
8150 | 231 |
end; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
232 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
233 |
|
8150 | 234 |
procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); |
235 |
var index, tmpInt: LongInt; |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
236 |
isBool, isValid: Boolean; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
237 |
cmd, arg, newSyntax: String; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
238 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
239 |
WriteLn(stdout, 'WARNING: you are using a deprecated command, which could be removed in a future version!'); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
240 |
WriteLn(stdout, ' Consider updating to the latest syntax, which is much more flexible!'); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
241 |
WriteLn(stdout, ' Run `hwegine --help` to learn it!'); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
242 |
WriteLn(stdout, ''); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
243 |
|
8150 | 244 |
index:= 0; |
245 |
tmpInt:= 1; |
|
246 |
while (index < size) do |
|
247 |
begin |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
248 |
inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
249 |
cmd:= cmdArray[index]; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
250 |
arg:= ParamStr(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
251 |
isValid:= (cmd<>'--depth'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
252 |
|
8197 | 253 |
// check if the parameter is a boolean one |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
254 |
isBool:= (cmd = '--nomusic') or (cmd = '--nosound') or (cmd = '--fullscreen') or (cmd = '--showfps') or (cmd = '--altdmg'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
255 |
if isBool and (arg='0') then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
256 |
isValid:= false; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
257 |
if (cmd='--nomusic') or (cmd='--nosound') then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
258 |
isValid:= not isValid; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
259 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
260 |
if isValid then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
261 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
262 |
parseParameter(cmd, arg, tmpInt); |
8329 | 263 |
newSyntax := newSyntax + cmd + ' '; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
264 |
if not isBool then |
8329 | 265 |
newSyntax := newSyntax + arg + ' '; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
266 |
end; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
267 |
inc(index); |
8150 | 268 |
end; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
269 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
270 |
WriteLn(stdout, 'Attempted to automatically convert to the new syntax:'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
271 |
WriteLn(stdout, newSyntax); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
272 |
WriteLn(stdout, ''); |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
273 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
274 |
|
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
275 |
procedure parseCommandLine{$IFDEF HWLIBRARY}(argc: LongInt; argv: PPChar){$ENDIF}; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
276 |
var paramIndex: LongInt; |
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
277 |
paramTotal: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
278 |
wrongParameter: boolean; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
279 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
280 |
paramIndex:= 1; |
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
281 |
paramTotal:={$IFDEF HWLIBRARY}argc{$ELSE}ParamCount{$ENDIF}; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
282 |
wrongParameter:= false; |
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
283 |
while (paramIndex <= paramTotal) do |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
284 |
begin |
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
285 |
{$IFDEF HWLIBRARY} |
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
286 |
wrongParameter:= parseParameter( argv[paramIndex], argv[paramIndex+1], paramIndex); |
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
287 |
{$ELSE} |
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
288 |
wrongParameter:= parseParameter( ParamStr(paramIndex), ParamStr(paramIndex+1), paramIndex); |
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
289 |
{$ENDIF} |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
290 |
inc(paramIndex); |
8150 | 291 |
end; |
292 |
if wrongParameter = true then |
|
293 |
GameType:= gmtSyntax; |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
294 |
end; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
295 |
|
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
296 |
{$IFNDEF HWLIBRARY} |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
297 |
procedure GetParams; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
298 |
//var tmpInt: LongInt; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
299 |
begin |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
300 |
(* |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
301 |
tmpInt:=0; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
302 |
while (tmpInt <= ParamCount) do |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
303 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
304 |
WriteLn(stdout, inttostr(tmpInt) + ': ' + ParamStr(tmpInt)); |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
305 |
inc(tmpInt); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
306 |
end; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
307 |
*) |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
308 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
309 |
isInternal:= (ParamStr(1) = '--internal'); |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
310 |
|
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
311 |
UserPathPrefix := '.'; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
312 |
PathPrefix := cDefaultPathPrefix; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
313 |
recordFileName := ''; |
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
314 |
parseCommandLine(); |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
315 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
316 |
if (isInternal) and (ParamCount<=1) then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
317 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
318 |
WriteLn(stderr, '--internal should not be manually used'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
319 |
GameType := gmtSyntax; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
320 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
321 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
322 |
if (not isInternal) and (recordFileName = '') then |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
323 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
324 |
WriteLn(stderr, 'You must specify a replay file'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
325 |
GameType := gmtSyntax; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
326 |
end |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
327 |
else if (recordFileName <> '') then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
328 |
WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
329 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
330 |
if (GameType = gmtSyntax) then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
331 |
WriteLn(stderr, 'Please use --help to see possible arguments and their usage'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
332 |
|
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
333 |
(* |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
334 |
WriteLn(stdout,'PathPrefix: ' + PathPrefix); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
335 |
WriteLn(stdout,'UserPathPrefix: ' + UserPathPrefix); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
336 |
*) |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
337 |
end; |
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
338 |
{$ENDIF} |
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
339 |