author | unc0rr |
Sun, 05 Jan 2014 23:58:13 +0400 | |
branch | webgl |
changeset 9958 | 5a222923c8f8 |
parent 9954 | bf51bc7e2808 |
child 10015 | 4feced261c68 |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
9080 | 3 |
* Copyright (c) 2004-2013 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 |
*) |
|
9280 | 18 |
|
19 |
{$INCLUDE "options.inc"} |
|
20 |
||
21 |
unit ArgParsers; |
|
22 |
interface |
|
23 |
||
9309
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9302
diff
changeset
|
24 |
{$IFNDEF HWLIBRARY} |
9280 | 25 |
procedure GetParams; |
9309
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9302
diff
changeset
|
26 |
{$ELSE} |
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9302
diff
changeset
|
27 |
procedure parseCommandLine(argc: LongInt; argv: PPChar); |
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9302
diff
changeset
|
28 |
{$ENDIF} |
9280 | 29 |
|
30 |
implementation |
|
9302 | 31 |
uses uVariables, uTypes, uUtils, uSound, uConsts; |
9309
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9302
diff
changeset
|
32 |
var isInternal: Boolean {$IFDEF HWLIBRARY} = true{$ENDIF}; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
33 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
34 |
procedure GciEasterEgg; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
35 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
36 |
WriteLn(stdout, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
37 |
WriteLn(stdout, ' /\\\\\\\\\\\\ /\\\\\\\\\ /\\\\\\\\\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
38 |
WriteLn(stdout, ' /\\\////////// /\\\//////// \/////\\\/// '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
39 |
WriteLn(stdout, ' /\\\ /\\\/ \/\\\ '); |
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, ' \/\\\ \/////\\\ \/\\\ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
42 |
WriteLn(stdout, ' \/\\\ \/\\\ \//\\\ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
43 |
WriteLn(stdout, ' \/\\\ \/\\\ \///\\\ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
44 |
WriteLn(stdout, ' \/\\\\\\\\\\\\\/ \////\\\\\\\\\ /\\\\\\\\\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
45 |
WriteLn(stdout, ' \///////////// \///////// \/////////// '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
46 |
WriteLn(stdout, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
47 |
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
|
48 |
WriteLn(stdout, ' ASCII Art easter egg idea by @sheepluva '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
49 |
WriteLn(stdout, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
50 |
end; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
51 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
52 |
procedure DisplayUsage; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
53 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
54 |
WriteLn(stdout, 'Usage: hwengine <path to replay file> [options]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
55 |
WriteLn(stdout, ''); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
56 |
WriteLn(stdout, 'where [options] can be any of the following:'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
57 |
WriteLn(stdout, ' --prefix [path to folder]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
58 |
WriteLn(stdout, ' --user-prefix [path to folder]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
59 |
WriteLn(stdout, ' --locale [name of language file]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
60 |
WriteLn(stdout, ' --nick [string]'); |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
61 |
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
|
62 |
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
|
63 |
WriteLn(stdout, ' --width [window width in pixels]'); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
64 |
WriteLn(stdout, ' --height [window height in pixels]'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
65 |
WriteLn(stdout, ' --volume [sound level]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
66 |
WriteLn(stdout, ' --frame-interval [milliseconds]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
67 |
Writeln(stdout, ' --stereo [value]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
68 |
WriteLn(stdout, ' --raw-quality [flags]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
69 |
WriteLn(stdout, ' --low-quality'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
70 |
WriteLn(stdout, ' --nomusic'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
71 |
WriteLn(stdout, ' --nosound'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
72 |
WriteLn(stdout, ' --fullscreen'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
73 |
WriteLn(stdout, ' --showfps'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
74 |
WriteLn(stdout, ' --altdmg'); |
9249 | 75 |
WriteLn(stdout, ' --no-teamtag'); |
76 |
WriteLn(stdout, ' --no-hogtag'); |
|
77 |
WriteLn(stdout, ' --no-healthtag'); |
|
78 |
WriteLn(stdout, ' --translucent-tags'); |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
79 |
WriteLn(stdout, ' --stats-only'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
80 |
WriteLn(stdout, ' --help'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
81 |
WriteLn(stdout, ''); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
82 |
WriteLn(stdout, 'For more detailed help and examples go to:'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
83 |
WriteLn(stdout, 'http://code.google.com/p/hedgewars/wiki/CommandLineOptions'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
84 |
GameType:= gmtSyntax; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
85 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
86 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
87 |
procedure setDepth(var paramIndex: LongInt); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
88 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
89 |
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
|
90 |
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
|
91 |
WriteLn(stdout, ''); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
92 |
inc(ParamIndex); |
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 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
95 |
procedure statsOnlyGame; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
96 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
97 |
cOnlyStats:= true; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
98 |
cReducedQuality:= $FFFFFFFF xor rqLowRes; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
99 |
SetSound(false); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
100 |
SetMusic(false); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
101 |
SetVolume(0); |
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 setIpcPort(port: LongInt; var wrongParameter:Boolean); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
105 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
106 |
if isInternal then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
107 |
ipcPort := port |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
108 |
else |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
109 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
110 |
WriteLn(stderr, 'ERROR: use of --port is not allowed'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
111 |
wrongParameter := true; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
112 |
end |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
113 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
114 |
|
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
115 |
function parseNick(nick: shortstring): shortstring; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
116 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
117 |
if isInternal then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
118 |
parseNick:= DecodeBase64(nick) |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
119 |
else |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
120 |
parseNick:= nick; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
121 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
122 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
123 |
procedure setStereoMode(tmp: LongInt); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
124 |
begin |
6982 | 125 |
GrayScale:= false; |
8221 | 126 |
{$IFDEF USE_S3D_RENDERING} |
8359
9a7024b2a4d3
Removed wiggle 3D mode, reorder the list of 3D modes.
martin_bede
parents:
8354
diff
changeset
|
127 |
if (tmp > 6) and (tmp < 13) then |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5239
diff
changeset
|
128 |
begin |
8221 | 129 |
// set the gray anaglyph rendering |
6982 | 130 |
GrayScale:= true; |
8359
9a7024b2a4d3
Removed wiggle 3D mode, reorder the list of 3D modes.
martin_bede
parents:
8354
diff
changeset
|
131 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))) |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5239
diff
changeset
|
132 |
end |
8359
9a7024b2a4d3
Removed wiggle 3D mode, reorder the list of 3D modes.
martin_bede
parents:
8354
diff
changeset
|
133 |
else if tmp <= 6 then |
8221 | 134 |
// 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
|
135 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) |
8221 | 136 |
else |
137 |
// 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
|
138 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); |
8221 | 139 |
{$ELSE} |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
140 |
tmp:= tmp; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
141 |
cStereoMode:= smNone; |
8221 | 142 |
{$ENDIF} |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
143 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
144 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
145 |
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
|
146 |
begin |
8370 | 147 |
// Silence the hint that appears when USE_VIDEO_RECORDING is not defined |
148 |
paramIndex:= paramIndex; |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
149 |
{$IFDEF USE_VIDEO_RECORDING} |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
150 |
GameType:= gmtRecord; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
151 |
inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
152 |
cVideoFramerateNum:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
153 |
cVideoFramerateDen:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
154 |
RecPrefix:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
155 |
cAVFormat:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
156 |
cVideoCodec:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
157 |
cVideoQuality:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
158 |
cAudioCodec:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
159 |
{$ENDIF} |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
160 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
161 |
|
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
162 |
function getLongIntParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt; |
8150 | 163 |
var tmpInt, c: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
164 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
165 |
inc(paramIndex); |
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
166 |
{$IFDEF PAS2C} |
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
167 |
val(str, tmpInt); |
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
168 |
{$ELSE} |
8150 | 169 |
val(str, tmpInt, c); |
170 |
wrongParameter:= c <> 0; |
|
171 |
if wrongParameter then |
|
172 |
WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"'); |
|
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
173 |
{$ENDIF} |
8150 | 174 |
getLongIntParameter:= tmpInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
175 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
176 |
|
9954 | 177 |
function getstringParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): shortstring; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
178 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
179 |
inc(paramIndex); |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
180 |
wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
181 |
if wrongParameter then |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
182 |
WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); |
9954 | 183 |
getstringParameter:= str; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
184 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
185 |
|
9954 | 186 |
procedure parseClassicParameter(cmdArray: array of string; size:LongInt; var paramIndex:LongInt); forward; |
8150 | 187 |
|
9954 | 188 |
function parseParameter(cmd:string; arg:string; var paramIndex:LongInt): Boolean; |
189 |
const videoArray: array [0..4] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
|
190 |
audioArray: array [0..2] of string = ('--volume','--nomusic','--nosound'); |
|
191 |
otherArray: array [0..2] of string = ('--locale','--fullscreen','--showfps'); |
|
192 |
mediaArray: array [0..9] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
|
193 |
allArray: array [0..17] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags'); |
|
9521
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
diff
changeset
|
194 |
reallyAll: array [0..34] of shortstring = ( |
8924 | 195 |
'--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
196 |
'--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
8924 | 197 |
'--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
198 |
{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
|
199 |
{internal} '--internal', '--port', '--recorder', '--landpreview', |
9249 | 200 |
{misc} '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags'); |
8197 | 201 |
var cmdIndex: byte; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
202 |
begin |
8150 | 203 |
parseParameter:= false; |
8197 | 204 |
cmdIndex:= 0; |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
205 |
|
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
206 |
//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
|
207 |
// 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
|
208 |
|
8197 | 209 |
while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
210 |
case cmdIndex of |
|
9954 | 211 |
{--prefix} 0 : PathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
212 |
{--user-prefix} 1 : UserPathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
|
213 |
{--locale} 2 : cLocaleFName := getstringParameter (arg, paramIndex, parseParameter); |
|
8985
fe8d1a476f0b
range checking for more engine command line parameters, issue 600
koda
parents:
8924
diff
changeset
|
214 |
{--fullscreen-width} 3 : cFullscreenWidth := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenWidth); |
fe8d1a476f0b
range checking for more engine command line parameters, issue 600
koda
parents:
8924
diff
changeset
|
215 |
{--fullscreen-height} 4 : cFullscreenHeight := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenHeight); |
8884
08fe08651130
set translucency on fruit theme water, clamp size to even number (same sdl window resize) and honouring min size, reduce calls to dmgmod a bit
nemo
parents:
8425
diff
changeset
|
216 |
{--width} 5 : cWindowedWidth := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenWidth); |
08fe08651130
set translucency on fruit theme water, clamp size to even number (same sdl window resize) and honouring min size, reduce calls to dmgmod a bit
nemo
parents:
8425
diff
changeset
|
217 |
{--height} 6 : cWindowedHeight := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenHeight); |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
218 |
{--frame-interval} 7 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
8985
fe8d1a476f0b
range checking for more engine command line parameters, issue 600
koda
parents:
8924
diff
changeset
|
219 |
{--volume} 8 : SetVolume ( max(getLongIntParameter(arg, paramIndex, parseParameter), 0) ); |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
220 |
{--nomusic} 9 : SetMusic ( false ); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
221 |
{--nosound} 10 : SetSound ( false ); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
222 |
{--fullscreen} 11 : cFullScreen := true; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
223 |
{--showfps} 12 : cShowFPS := true; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
224 |
{--altdmg} 13 : cAltDamage := true; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
225 |
{--low-quality} 14 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
226 |
{--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
|
227 |
{--stereo} 16 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
9954 | 228 |
{--nick} 17 : UserNick := parseNick( getstringParameter(arg, paramIndex, parseParameter) ); |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
229 |
{deprecated options} |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
230 |
{--depth} 18 : setDepth(paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
231 |
{--set-video} 19 : parseClassicParameter(videoArray,5,paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
232 |
{--set-audio} 20 : parseClassicParameter(audioArray,3,paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
233 |
{--set-other} 21 : parseClassicParameter(otherArray,3,paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
234 |
{--set-multimedia} 22 : parseClassicParameter(mediaArray,10,paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
235 |
{--set-everything} 23 : parseClassicParameter(allArray,14,paramIndex); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
236 |
{"internal" options} |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
237 |
{--internal} 24 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF}; |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
238 |
{--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
|
239 |
{--recorder} 26 : startVideoRecording(paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
240 |
{--landpreview} 27 : GameType := gmtLandPreview; |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
241 |
{anything else} |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
242 |
{--stats-only} 28 : statsOnlyGame(); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
243 |
{--gci} 29 : GciEasterEgg(); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
244 |
{--help} 30 : DisplayUsage(); |
9521
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
diff
changeset
|
245 |
{--no-teamtag} 31 : cTagsMask := cTagsMask and (not htTeamName); |
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
diff
changeset
|
246 |
{--no-hogtag} 32 : cTagsMask := cTagsMask and (not htName); |
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
diff
changeset
|
247 |
{--no-healthtag} 33 : cTagsMask := cTagsMask and (not htHealth); |
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
diff
changeset
|
248 |
{--translucent-tags} 34 : cTagsMask := cTagsMask or htTransparent |
8150 | 249 |
else |
250 |
begin |
|
8307 | 251 |
//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
|
252 |
if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
8307 | 253 |
recordFileName := cmd |
254 |
else |
|
255 |
begin |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
256 |
WriteLn(stderr, '"'+cmd+'" is not a valid option'); |
8307 | 257 |
parseParameter:= true; |
258 |
end; |
|
259 |
end; |
|
8150 | 260 |
end; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
261 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
262 |
|
9954 | 263 |
procedure parseClassicParameter(cmdArray: array of string; size:LongInt; var paramIndex:LongInt); |
8150 | 264 |
var index, tmpInt: LongInt; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
265 |
isBool, isValid: Boolean; |
9954 | 266 |
cmd, arg, newSyntax: string; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
267 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
268 |
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
|
269 |
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
|
270 |
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
|
271 |
WriteLn(stdout, ''); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
272 |
|
8150 | 273 |
index:= 0; |
274 |
tmpInt:= 1; |
|
275 |
while (index < size) do |
|
276 |
begin |
|
8370 | 277 |
newSyntax:= ''; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
278 |
inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
279 |
cmd:= cmdArray[index]; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
280 |
arg:= ParamStr(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
281 |
isValid:= (cmd<>'--depth'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
282 |
|
8197 | 283 |
// check if the parameter is a boolean one |
9249 | 284 |
isBool:= (cmd = '--nomusic') or (cmd = '--nosound') or (cmd = '--fullscreen') or (cmd = '--showfps') or (cmd = '--altdmg') or (cmd = '--no-teamtag') or (cmd = '--no-hogtag') or (cmd = '--no-healthtag') or (cmd = '--translucent-tags'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
285 |
if isBool and (arg='0') then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
286 |
isValid:= false; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
287 |
if (cmd='--nomusic') or (cmd='--nosound') then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
288 |
isValid:= not isValid; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
289 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
290 |
if isValid then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
291 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
292 |
parseParameter(cmd, arg, tmpInt); |
8332
9333216f2054
fix hwc install and pas2c preprocessing (but not total conversion)
koda
parents:
8330
diff
changeset
|
293 |
newSyntax:= newSyntax + cmd + ' '; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
294 |
if not isBool then |
8332
9333216f2054
fix hwc install and pas2c preprocessing (but not total conversion)
koda
parents:
8330
diff
changeset
|
295 |
newSyntax:= newSyntax + arg + ' '; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
296 |
end; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
297 |
inc(index); |
8150 | 298 |
end; |
8924 | 299 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
300 |
WriteLn(stdout, 'Attempted to automatically convert to the new syntax:'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
301 |
WriteLn(stdout, newSyntax); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
302 |
WriteLn(stdout, ''); |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
303 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
304 |
|
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
305 |
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
|
306 |
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
|
307 |
paramTotal: LongInt; |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
308 |
index, nextIndex: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
309 |
wrongParameter: boolean; |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
310 |
//var tmpInt: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
311 |
begin |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
312 |
paramIndex:= {$IFDEF HWLIBRARY}0{$ELSE}1{$ENDIF}; |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
313 |
paramTotal:= {$IFDEF HWLIBRARY}argc-1{$ELSE}ParamCount{$ENDIF}; //-1 because pascal enumeration is inclusive |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
314 |
(* |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
315 |
WriteLn(stdout, 'total parameters: ' + inttostr(paramTotal)); |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
316 |
tmpInt:= 0; |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
317 |
while (tmpInt <= paramTotal) do |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
318 |
begin |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
319 |
WriteLn(stdout, inttostr(tmpInt) + ': ' + {$IFDEF HWLIBRARY}argv[tmpInt]{$ELSE}paramCount(tmpInt){$ENDIF}); |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
320 |
inc(tmpInt); |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
321 |
end; |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
322 |
*) |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
323 |
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
|
324 |
while (paramIndex <= paramTotal) do |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
325 |
begin |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
326 |
// avoid going past the number of paramTotal (esp. w/ library) |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
327 |
index:= paramIndex; |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
328 |
if index = paramTotal then nextIndex:= index |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
329 |
else nextIndex:= index+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
|
330 |
{$IFDEF HWLIBRARY} |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
331 |
wrongParameter:= parseParameter( argv[index], argv[nextIndex], paramIndex); |
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
332 |
{$ELSE} |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
333 |
wrongParameter:= parseParameter( ParamStr(index), ParamStr(nextIndex), paramIndex); |
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
334 |
{$ENDIF} |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
335 |
inc(paramIndex); |
8150 | 336 |
end; |
337 |
if wrongParameter = true then |
|
338 |
GameType:= gmtSyntax; |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
339 |
end; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
340 |
|
8327
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
341 |
{$IFNDEF HWLIBRARY} |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
342 |
procedure GetParams; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
343 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
344 |
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
|
345 |
|
8446
c18ba8726f5a
Fix sources so pas2c written in haskell could render them again
unc0rr
parents:
8444
diff
changeset
|
346 |
UserPathPrefix := _S'.'; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
347 |
PathPrefix := cDefaultPathPrefix; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
348 |
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
|
349 |
parseCommandLine(); |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
350 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
351 |
if (isInternal) and (ParamCount<=1) then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
352 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
353 |
WriteLn(stderr, '--internal should not be manually used'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
354 |
GameType := gmtSyntax; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
355 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
356 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
357 |
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
|
358 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
359 |
WriteLn(stderr, 'You must specify a replay file'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
360 |
GameType := gmtSyntax; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
361 |
end |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
362 |
else if (recordFileName <> '') then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
363 |
WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
364 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
365 |
if (GameType = gmtSyntax) then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
366 |
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
|
367 |
|
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
368 |
(* |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
369 |
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
|
370 |
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
|
371 |
*) |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
372 |
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
|
373 |
{$ENDIF} |
a6f3452f5f94
convert Game() library call to argc,argv format so that we can use the new parsing functions
koda
parents:
8325
diff
changeset
|
374 |
|
9280 | 375 |
end. |
376 |