author | Wuzzy <almikes@aol.com> |
Fri, 28 Apr 2017 00:21:16 +0200 | |
changeset 12370 | 92b4bab79c26 |
parent 11794 | e2de320aaf69 |
child 11833 | a69124eb7ce7 |
child 13394 | 24b531dcebe7 |
child 13492 | d23731fe84d4 |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
10078
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4976 | 17 |
*) |
10015 | 18 |
|
9280 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
21 |
unit ArgParsers; |
|
22 |
interface |
|
23 |
||
24 |
procedure GetParams; |
|
10175
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
25 |
{$IFDEF HWLIBRARY} |
11794
e2de320aaf69
- More ugly ifdefs for the ifdef god
antonc27 <antonc27@mail.ru>
parents:
11685
diff
changeset
|
26 |
var operatingsystem_parameter_argc: LongInt = 0; {$IFNDEF PAS2C}{$IFNDEF IPHONEOS}cdecl;{$ENDIF} export;{$ENDIF} |
e2de320aaf69
- More ugly ifdefs for the ifdef god
antonc27 <antonc27@mail.ru>
parents:
11685
diff
changeset
|
27 |
operatingsystem_parameter_argv: pointer = nil; {$IFNDEF PAS2C}{$IFNDEF IPHONEOS}cdecl;{$ENDIF} export;{$ENDIF} |
e2de320aaf69
- More ugly ifdefs for the ifdef god
antonc27 <antonc27@mail.ru>
parents:
11685
diff
changeset
|
28 |
operatingsystem_parameter_envp: pointer = nil; {$IFNDEF PAS2C}{$IFNDEF IPHONEOS}cdecl;{$ENDIF} export;{$ENDIF} |
10175
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
29 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
30 |
function ParamCount: LongInt; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
31 |
function ParamStr(i: LongInt): shortstring; |
9309
7e8f91634f80
engine compiles for ios again, but SDL bindings are outdated. Fix some warnings
koda
parents:
9302
diff
changeset
|
32 |
{$ENDIF} |
9280 | 33 |
|
34 |
implementation |
|
9302 | 35 |
uses uVariables, uTypes, uUtils, uSound, uConsts; |
10175
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
36 |
var isInternal: Boolean; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
37 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
38 |
{$IFDEF HWLIBRARY} |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
39 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
40 |
type PCharArray = array[0..255] of PChar; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
41 |
PPCharArray = ^PCharArray; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
42 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
43 |
function ParamCount: LongInt; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
44 |
begin |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
45 |
ParamCount:= operatingsystem_parameter_argc - 1 |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
46 |
end; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
47 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
48 |
function ParamStr(i: LongInt): shortstring; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
49 |
begin |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
50 |
ParamStr:= StrPas(PPCharArray(operatingsystem_parameter_argv)^[i]) |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
51 |
end; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
52 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
53 |
{$ENDIF} |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
54 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
55 |
procedure GciEasterEgg; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
56 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
57 |
WriteLn(stdout, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
58 |
WriteLn(stdout, ' /\\\\\\\\\\\\ /\\\\\\\\\ /\\\\\\\\\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
59 |
WriteLn(stdout, ' /\\\////////// /\\\//////// \/////\\\/// '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
60 |
WriteLn(stdout, ' /\\\ /\\\/ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
61 |
WriteLn(stdout, ' \/\\\ /\\\\\\\ /\\\ \/\\\ '); |
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, ' \/\\\ \/\\\ \//\\\ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
64 |
WriteLn(stdout, ' \/\\\ \/\\\ \///\\\ \/\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
65 |
WriteLn(stdout, ' \/\\\\\\\\\\\\\/ \////\\\\\\\\\ /\\\\\\\\\\\ '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
66 |
WriteLn(stdout, ' \///////////// \///////// \/////////// '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
67 |
WriteLn(stdout, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
68 |
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
|
69 |
WriteLn(stdout, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
70 |
end; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
71 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
72 |
procedure DisplayUsage; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
73 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
74 |
WriteLn(stdout, 'Usage: hwengine <path to replay file> [options]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
75 |
WriteLn(stdout, ''); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
76 |
WriteLn(stdout, 'where [options] can be any of the following:'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
77 |
WriteLn(stdout, ' --prefix [path to folder]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
78 |
WriteLn(stdout, ' --user-prefix [path to folder]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
79 |
WriteLn(stdout, ' --locale [name of language file]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
80 |
WriteLn(stdout, ' --nick [string]'); |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
81 |
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
|
82 |
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
|
83 |
WriteLn(stdout, ' --width [window width in pixels]'); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
84 |
WriteLn(stdout, ' --height [window height in pixels]'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
85 |
WriteLn(stdout, ' --volume [sound level]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
86 |
WriteLn(stdout, ' --frame-interval [milliseconds]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
87 |
Writeln(stdout, ' --stereo [value]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
88 |
WriteLn(stdout, ' --raw-quality [flags]'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
89 |
WriteLn(stdout, ' --low-quality'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
90 |
WriteLn(stdout, ' --nomusic'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
91 |
WriteLn(stdout, ' --nosound'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
92 |
WriteLn(stdout, ' --fullscreen'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
93 |
WriteLn(stdout, ' --showfps'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
94 |
WriteLn(stdout, ' --altdmg'); |
9249 | 95 |
WriteLn(stdout, ' --no-teamtag'); |
96 |
WriteLn(stdout, ' --no-hogtag'); |
|
97 |
WriteLn(stdout, ' --no-healthtag'); |
|
98 |
WriteLn(stdout, ' --translucent-tags'); |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
99 |
WriteLn(stdout, ' --stats-only'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
100 |
WriteLn(stdout, ' --help'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
101 |
WriteLn(stdout, ''); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
102 |
WriteLn(stdout, 'For more detailed help and examples go to:'); |
11520
4dd77731453b
update some old google code links in the code/etc. thanks Wuzzy for the heads-up
sheepluva
parents:
11151
diff
changeset
|
103 |
WriteLn(stdout, 'http://hedgewars.org/kb/CommandLineOptions'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
104 |
GameType:= gmtSyntax; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
105 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
106 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
107 |
procedure setDepth(var paramIndex: LongInt); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
108 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
109 |
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
|
110 |
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
|
111 |
WriteLn(stdout, ''); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
112 |
inc(ParamIndex); |
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 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
115 |
procedure statsOnlyGame; |
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 |
cOnlyStats:= true; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
118 |
cReducedQuality:= $FFFFFFFF xor rqLowRes; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
119 |
SetSound(false); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
120 |
SetMusic(false); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
121 |
SetVolume(0); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
122 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
123 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
124 |
procedure setIpcPort(port: LongInt; var wrongParameter:Boolean); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
125 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
126 |
if isInternal then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
127 |
ipcPort := port |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
128 |
else |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
129 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
130 |
WriteLn(stderr, 'ERROR: use of --port is not allowed'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
131 |
wrongParameter := true; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
132 |
end |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
133 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
134 |
|
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
135 |
function parseNick(nick: shortstring): shortstring; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
136 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
137 |
if isInternal then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
138 |
parseNick:= DecodeBase64(nick) |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
139 |
else |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
140 |
parseNick:= nick; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
141 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
142 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
143 |
procedure setStereoMode(tmp: LongInt); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
144 |
begin |
6982 | 145 |
GrayScale:= false; |
8221 | 146 |
{$IFDEF USE_S3D_RENDERING} |
8359
9a7024b2a4d3
Removed wiggle 3D mode, reorder the list of 3D modes.
martin_bede
parents:
8354
diff
changeset
|
147 |
if (tmp > 6) and (tmp < 13) then |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5239
diff
changeset
|
148 |
begin |
8221 | 149 |
// set the gray anaglyph rendering |
6982 | 150 |
GrayScale:= true; |
8359
9a7024b2a4d3
Removed wiggle 3D mode, reorder the list of 3D modes.
martin_bede
parents:
8354
diff
changeset
|
151 |
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
|
152 |
end |
8359
9a7024b2a4d3
Removed wiggle 3D mode, reorder the list of 3D modes.
martin_bede
parents:
8354
diff
changeset
|
153 |
else if tmp <= 6 then |
8221 | 154 |
// 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
|
155 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) |
8221 | 156 |
else |
157 |
// 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
|
158 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); |
8221 | 159 |
{$ELSE} |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
160 |
tmp:= tmp; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
161 |
cStereoMode:= smNone; |
8221 | 162 |
{$ENDIF} |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
163 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
164 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
165 |
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
|
166 |
begin |
8370 | 167 |
// Silence the hint that appears when USE_VIDEO_RECORDING is not defined |
168 |
paramIndex:= paramIndex; |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
169 |
{$IFDEF USE_VIDEO_RECORDING} |
10173 | 170 |
{$IFNDEF HWLIBRARY} |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
171 |
GameType:= gmtRecord; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
172 |
inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
173 |
cVideoFramerateNum:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
174 |
cVideoFramerateDen:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
175 |
RecPrefix:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
176 |
cAVFormat:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
177 |
cVideoCodec:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
178 |
cVideoQuality:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
179 |
cAudioCodec:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
180 |
{$ENDIF} |
10173 | 181 |
{$ENDIF} |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
182 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
183 |
|
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
184 |
function getLongIntParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt; |
8150 | 185 |
var tmpInt, c: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
186 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
187 |
inc(paramIndex); |
10173 | 188 |
{$IFDEF PAS2C OR HWLIBRARY} |
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
189 |
val(str, tmpInt); |
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
190 |
{$ELSE} |
8150 | 191 |
val(str, tmpInt, c); |
192 |
wrongParameter:= c <> 0; |
|
193 |
if wrongParameter then |
|
194 |
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
|
195 |
{$ENDIF} |
8150 | 196 |
getLongIntParameter:= tmpInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
197 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
198 |
|
9954 | 199 |
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
|
200 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
201 |
inc(paramIndex); |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
202 |
wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
10173 | 203 |
{$IFNDEF HWLIBRARY} |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
204 |
if wrongParameter then |
10173 | 205 |
WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); |
206 |
{$ENDIF} |
|
9954 | 207 |
getstringParameter:= str; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
208 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
209 |
|
10078 | 210 |
procedure parseClassicParameter(cmdarray: array of string; size:LongInt; var paramIndex:LongInt); forward; |
8150 | 211 |
|
9954 | 212 |
function parseParameter(cmd:string; arg:string; var paramIndex:LongInt): Boolean; |
10078 | 213 |
const videoarray: array [0..4] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
214 |
audioarray: array [0..2] of string = ('--volume','--nomusic','--nosound'); |
|
215 |
otherarray: array [0..2] of string = ('--locale','--fullscreen','--showfps'); |
|
216 |
mediaarray: array [0..9] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
|
217 |
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'); |
|
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9309
diff
changeset
|
218 |
reallyAll: array[0..35] of shortstring = ( |
8924 | 219 |
'--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
|
220 |
'--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
8924 | 221 |
'--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
222 |
{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
|
223 |
{internal} '--internal', '--port', '--recorder', '--landpreview', |
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9309
diff
changeset
|
224 |
{misc} '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test'); |
8197 | 225 |
var cmdIndex: byte; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
226 |
begin |
8150 | 227 |
parseParameter:= false; |
8197 | 228 |
cmdIndex:= 0; |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
229 |
|
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
230 |
//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
|
231 |
// 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
|
232 |
|
8197 | 233 |
while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
234 |
case cmdIndex of |
|
9954 | 235 |
{--prefix} 0 : PathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
236 |
{--user-prefix} 1 : UserPathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
|
237 |
{--locale} 2 : cLocaleFName := getstringParameter (arg, paramIndex, parseParameter); |
|
8985
fe8d1a476f0b
range checking for more engine command line parameters, issue 600
koda
parents:
8924
diff
changeset
|
238 |
{--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
|
239 |
{--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
|
240 |
{--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
|
241 |
{--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
|
242 |
{--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
|
243 |
{--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
|
244 |
{--nomusic} 9 : SetMusic ( false ); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
245 |
{--nosound} 10 : SetSound ( false ); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
246 |
{--fullscreen} 11 : cFullScreen := true; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
247 |
{--showfps} 12 : cShowFPS := true; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
248 |
{--altdmg} 13 : cAltDamage := true; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
249 |
{--low-quality} 14 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
250 |
{--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
|
251 |
{--stereo} 16 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
9954 | 252 |
{--nick} 17 : UserNick := parseNick( getstringParameter(arg, paramIndex, parseParameter) ); |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
253 |
{deprecated options} |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
254 |
{--depth} 18 : setDepth(paramIndex); |
10078 | 255 |
{--set-video} 19 : parseClassicParameter(videoarray,5,paramIndex); |
256 |
{--set-audio} 20 : parseClassicParameter(audioarray,3,paramIndex); |
|
257 |
{--set-other} 21 : parseClassicParameter(otherarray,3,paramIndex); |
|
258 |
{--set-multimedia} 22 : parseClassicParameter(mediaarray,10,paramIndex); |
|
259 |
{--set-everything} 23 : parseClassicParameter(allarray,14,paramIndex); |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
260 |
{"internal" options} |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
261 |
{--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
|
262 |
{--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
|
263 |
{--recorder} 26 : startVideoRecording(paramIndex); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
264 |
{--landpreview} 27 : GameType := gmtLandPreview; |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
265 |
{anything else} |
8354
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
266 |
{--stats-only} 28 : statsOnlyGame(); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
267 |
{--gci} 29 : GciEasterEgg(); |
c25bee85d6f8
Separated fullscreen and windowed hwengine resolution parameters.
vitiv <nikita.utiu@gmail.com>
parents:
8329
diff
changeset
|
268 |
{--help} 30 : DisplayUsage(); |
10078 | 269 |
{--no-teamtag} 31 : cTagsMask := cTagsMask and (not htTeamName); |
270 |
{--no-hogtag} 32 : cTagsMask := cTagsMask and (not htName); |
|
271 |
{--no-healthtag} 33 : cTagsMask := cTagsMask and (not htHealth); |
|
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9309
diff
changeset
|
272 |
{--translucent-tags} 34 : cTagsMask := cTagsMask or htTransparent; |
10316 | 273 |
{--lua-test} 35 : begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end; |
8150 | 274 |
else |
275 |
begin |
|
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9309
diff
changeset
|
276 |
//Assume 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
|
277 |
if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
8307 | 278 |
recordFileName := cmd |
279 |
else |
|
280 |
begin |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
281 |
WriteLn(stderr, '"'+cmd+'" is not a valid option'); |
8307 | 282 |
parseParameter:= true; |
283 |
end; |
|
284 |
end; |
|
8150 | 285 |
end; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
286 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
287 |
|
10078 | 288 |
procedure parseClassicParameter(cmdarray: array of string; size:LongInt; var paramIndex:LongInt); |
8150 | 289 |
var index, tmpInt: LongInt; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
290 |
isBool, isValid: Boolean; |
9954 | 291 |
cmd, arg, newSyntax: string; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
292 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
293 |
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
|
294 |
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
|
295 |
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
|
296 |
WriteLn(stdout, ''); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
297 |
|
8150 | 298 |
index:= 0; |
299 |
tmpInt:= 1; |
|
300 |
while (index < size) do |
|
301 |
begin |
|
8370 | 302 |
newSyntax:= ''; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
303 |
inc(paramIndex); |
10078 | 304 |
cmd:= cmdarray[index]; |
10173 | 305 |
arg:= cmdarray[paramIndex]; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
306 |
isValid:= (cmd<>'--depth'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
307 |
|
8197 | 308 |
// check if the parameter is a boolean one |
9249 | 309 |
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
|
310 |
if isBool and (arg='0') then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
311 |
isValid:= false; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
312 |
if (cmd='--nomusic') or (cmd='--nosound') then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
313 |
isValid:= not isValid; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
314 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
315 |
if isValid then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
316 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
317 |
parseParameter(cmd, arg, tmpInt); |
8332
9333216f2054
fix hwc install and pas2c preprocessing (but not total conversion)
koda
parents:
8330
diff
changeset
|
318 |
newSyntax:= newSyntax + cmd + ' '; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
319 |
if not isBool then |
8332
9333216f2054
fix hwc install and pas2c preprocessing (but not total conversion)
koda
parents:
8330
diff
changeset
|
320 |
newSyntax:= newSyntax + arg + ' '; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
321 |
end; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
322 |
inc(index); |
8150 | 323 |
end; |
8924 | 324 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
325 |
WriteLn(stdout, 'Attempted to automatically convert to the new syntax:'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
326 |
WriteLn(stdout, newSyntax); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
327 |
WriteLn(stdout, ''); |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
328 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
329 |
|
10175
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
330 |
procedure parseCommandLine; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
331 |
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
|
332 |
paramTotal: LongInt; |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
333 |
index, nextIndex: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
334 |
wrongParameter: boolean; |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
335 |
//var tmpInt: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
336 |
begin |
10173 | 337 |
|
11099
c51e4c942525
- Fix for wrong start paramIndex in case of Hwlibrary
antonc27 <antonc27@mail.ru>
parents:
10316
diff
changeset
|
338 |
paramIndex:= {$IFDEF HWLIBRARY}0{$ELSE}1{$ENDIF}; |
10175
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
339 |
paramTotal:= ParamCount; //-1 because pascal enumeration is inclusive |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
340 |
(* |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
341 |
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
|
342 |
tmpInt:= 0; |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
343 |
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
|
344 |
begin |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
345 |
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
|
346 |
inc(tmpInt); |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
347 |
end; |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
348 |
*) |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
349 |
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
|
350 |
while (paramIndex <= paramTotal) do |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
351 |
begin |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
352 |
// 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
|
353 |
index:= paramIndex; |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
354 |
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
|
355 |
else nextIndex:= index+1; |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
356 |
wrongParameter:= parseParameter( ParamStr(index), ParamStr(nextIndex), paramIndex); |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
357 |
inc(paramIndex); |
8150 | 358 |
end; |
359 |
if wrongParameter = true then |
|
360 |
GameType:= gmtSyntax; |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
361 |
end; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
362 |
|
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
363 |
procedure GetParams; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
364 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
365 |
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
|
366 |
|
8446
c18ba8726f5a
Fix sources so pas2c written in haskell could render them again
unc0rr
parents:
8444
diff
changeset
|
367 |
UserPathPrefix := _S'.'; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
368 |
PathPrefix := cDefaultPathPrefix; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
369 |
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
|
370 |
parseCommandLine(); |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
371 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
372 |
if (isInternal) and (ParamCount<=1) then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
373 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
374 |
WriteLn(stderr, '--internal should not be manually used'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
375 |
GameType := gmtSyntax; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
376 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
377 |
|
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9309
diff
changeset
|
378 |
if (not cTestLua) and (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
|
379 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
380 |
WriteLn(stderr, 'You must specify a replay file'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
381 |
GameType := gmtSyntax; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
382 |
end |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
383 |
else if (recordFileName <> '') then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
384 |
WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"'); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
385 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
386 |
if (GameType = gmtSyntax) then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
387 |
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
|
388 |
|
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
389 |
(* |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
390 |
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
|
391 |
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
|
392 |
*) |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
393 |
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
|
394 |
|
9280 | 395 |
end. |
396 |