author | Wuzzy <Wuzzy2@mail.ru> |
Sat, 02 Nov 2019 17:00:40 +0100 | |
changeset 15507 | ad9fe7dc2ff7 |
parent 15305 | a3823f0916b8 |
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; |
13492
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
37 |
helpCommandUsed: Boolean; |
10175
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
38 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
39 |
{$IFDEF HWLIBRARY} |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
40 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
41 |
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
|
42 |
PPCharArray = ^PCharArray; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
43 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
44 |
function ParamCount: LongInt; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
45 |
begin |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
46 |
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
|
47 |
end; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
48 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
49 |
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
|
50 |
begin |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
51 |
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
|
52 |
end; |
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
53 |
|
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
54 |
{$ENDIF} |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
55 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
56 |
procedure GciEasterEgg; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
57 |
begin |
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, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
69 |
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
|
70 |
WriteLn(stdout, ' '); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
71 |
end; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
72 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
73 |
procedure DisplayUsage; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
74 |
begin |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
75 |
WriteLn(stdout, 'This is the Hedgewars Engine (hwengine), used to play Hedgewars games and demos.'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
76 |
WriteLn(stdout, 'Use the command-line arguments to play a demo.'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
77 |
WriteLn(stdout, ''); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
78 |
WriteLn(stdout, 'Usage: hwengine <path to demo file> [options]'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
79 |
WriteLn(stdout, ''); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
80 |
WriteLn(stdout, 'where [options] can be any of the following:'); |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
81 |
WriteLn(stdout, ''); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
82 |
WriteLn(stdout, 'File locations:'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
83 |
WriteLn(stdout, ' --prefix <path to folder>: Set the path to the system game data folder'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
84 |
WriteLn(stdout, ' --user-prefix <path to folder>: Set the path to the custom data folder to find game content'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
85 |
WriteLn(stdout, ' --locale <name of file>: Set the game language (en.txt for example)'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
86 |
WriteLn(stdout, ''); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
87 |
WriteLn(stdout, 'Graphics:'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
88 |
WriteLn(stdout, ' --width <width in pixels>: Set game window width'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
89 |
WriteLn(stdout, ' --height <height in pixels>: Set game window height'); |
15304
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
90 |
WriteLn(stdout, ' --maximized: Start in maximized window'); |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
91 |
WriteLn(stdout, ' --fullscreen: Start in fullscreen'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
92 |
WriteLn(stdout, ' --fullscreen-width <width in pixels>: Set fullscreen width'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
93 |
WriteLn(stdout, ' --fullscreen-height <height in pixels>: Set fullscreen height'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
94 |
WriteLn(stdout, ' --low-quality: Lowers the game quality'); |
14682
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
95 |
WriteLn(stdout, ' --zoom <percent>: Start with custom zoom level'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
96 |
WriteLn(stdout, ''); |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
97 |
WriteLn(stdout, 'Audio:'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
98 |
WriteLn(stdout, ' --volume <sound level>: Set volume between 0 and 100'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
99 |
WriteLn(stdout, ' --nomusic: Disable music'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
100 |
WriteLn(stdout, ' --nosound: Disable sound effects'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
101 |
WriteLn(stdout, ' --nodampen: Don''t dampen sound volume when game application loses focus'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
102 |
WriteLn(stdout, ''); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
103 |
WriteLn(stdout, 'HUD:'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
104 |
WriteLn(stdout, ' --altdmg: Show alternative damage'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
105 |
WriteLn(stdout, ' --no-teamtag: Disable team name tags'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
106 |
WriteLn(stdout, ' --no-hogtag: Disable hedgehog name tags'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
107 |
WriteLn(stdout, ' --no-healthtag: Disable hedgehog health tags'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
108 |
WriteLn(stdout, ' --translucent-tags: Enable translucent name and health tags'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
109 |
WriteLn(stdout, ' --showfps: Show frames per second'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
110 |
WriteLn(stdout, ''); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
111 |
WriteLn(stdout, 'Miscellaneous:'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
112 |
WriteLn(stdout, ' --nick <name>: Set user nickname'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
113 |
WriteLn(stdout, ' --help: Show a list of command-line options and exit'); |
13955 | 114 |
WriteLn(stdout, ' --protocol: Display protocol number and exit'); |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
115 |
WriteLn(stdout, ''); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
116 |
Writeln(stdout, 'Advanced options:'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
117 |
Writeln(stdout, ' --stereo <value>: Set stereoscopic rendering (1 to 14)'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
118 |
WriteLn(stdout, ' --frame-interval <milliseconds>: Set minimum interval (in ms) between each frame. Eg, 40 would make the game run at most 25 fps'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
119 |
WriteLn(stdout, ' --raw-quality <flags>: Manually specify the reduced quality flags'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
120 |
WriteLn(stdout, ' --stats-only: Write the round information to console without launching the game, useful for statistics only'); |
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
121 |
WriteLn(stdout, ' --lua-test <path to script>: Run a Lua test script'); |
13492
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
122 |
GameType:= gmtSyntaxHelp; |
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
123 |
helpCommandUsed:= true; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
124 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
125 |
|
13955 | 126 |
procedure DisplayProtocol; |
127 |
begin |
|
128 |
WriteLn(stdout, IntToStr(cNetProtoVersion)); |
|
129 |
GameType:= gmtSyntaxHelp; |
|
130 |
helpCommandUsed:= true; |
|
131 |
end; |
|
132 |
||
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
133 |
procedure statsOnlyGame; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
134 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
135 |
cOnlyStats:= true; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
136 |
cReducedQuality:= $FFFFFFFF xor rqLowRes; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
137 |
SetSound(false); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
138 |
SetMusic(false); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
139 |
SetVolume(0); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
140 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
141 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
142 |
procedure setIpcPort(port: LongInt; var wrongParameter:Boolean); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
143 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
144 |
if isInternal then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
145 |
ipcPort := port |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
146 |
else |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
147 |
begin |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
148 |
WriteLn(stderr, 'ERROR: use of --port is not allowed!'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
149 |
wrongParameter := true; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
150 |
end |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
151 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
152 |
|
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
153 |
function parseNick(nick: shortstring): shortstring; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
154 |
begin |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
155 |
if isInternal then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
156 |
parseNick:= DecodeBase64(nick) |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
157 |
else |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
158 |
parseNick:= nick; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
159 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
160 |
|
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
161 |
procedure setStereoMode(tmp: LongInt); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
162 |
begin |
6982 | 163 |
GrayScale:= false; |
8221 | 164 |
{$IFDEF USE_S3D_RENDERING} |
8359
9a7024b2a4d3
Removed wiggle 3D mode, reorder the list of 3D modes.
martin_bede
parents:
8354
diff
changeset
|
165 |
if (tmp > 6) and (tmp < 13) then |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5239
diff
changeset
|
166 |
begin |
8221 | 167 |
// set the gray anaglyph rendering |
6982 | 168 |
GrayScale:= true; |
8359
9a7024b2a4d3
Removed wiggle 3D mode, reorder the list of 3D modes.
martin_bede
parents:
8354
diff
changeset
|
169 |
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
|
170 |
end |
8359
9a7024b2a4d3
Removed wiggle 3D mode, reorder the list of 3D modes.
martin_bede
parents:
8354
diff
changeset
|
171 |
else if tmp <= 6 then |
8221 | 172 |
// 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
|
173 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) |
8221 | 174 |
else |
175 |
// 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
|
176 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); |
8221 | 177 |
{$ELSE} |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
178 |
tmp:= tmp; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
179 |
cStereoMode:= smNone; |
8221 | 180 |
{$ENDIF} |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
181 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
182 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
183 |
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
|
184 |
begin |
8370 | 185 |
// Silence the hint that appears when USE_VIDEO_RECORDING is not defined |
186 |
paramIndex:= paramIndex; |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
187 |
{$IFDEF USE_VIDEO_RECORDING} |
10173 | 188 |
{$IFNDEF HWLIBRARY} |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
189 |
GameType:= gmtRecord; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
190 |
inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
191 |
cVideoFramerateNum:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
192 |
cVideoFramerateDen:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
193 |
RecPrefix:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
194 |
cAVFormat:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
195 |
cVideoCodec:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
196 |
cVideoQuality:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
197 |
cAudioCodec:= ParamStr(paramIndex); inc(paramIndex); |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
198 |
{$ENDIF} |
10173 | 199 |
{$ENDIF} |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
200 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
201 |
|
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
202 |
function getLongIntParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt; |
8150 | 203 |
var tmpInt, c: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
204 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
205 |
inc(paramIndex); |
10173 | 206 |
{$IFDEF PAS2C OR HWLIBRARY} |
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
207 |
val(str, tmpInt); |
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8446
diff
changeset
|
208 |
{$ELSE} |
8150 | 209 |
val(str, tmpInt, c); |
210 |
wrongParameter:= c <> 0; |
|
211 |
if wrongParameter then |
|
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
212 |
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
|
213 |
{$ENDIF} |
8150 | 214 |
getLongIntParameter:= tmpInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
215 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
216 |
|
9954 | 217 |
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
|
218 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
219 |
inc(paramIndex); |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
220 |
wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
10173 | 221 |
{$IFNDEF HWLIBRARY} |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
222 |
if wrongParameter then |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
223 |
WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"!'); |
10173 | 224 |
{$ENDIF} |
9954 | 225 |
getstringParameter:= str; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
226 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
227 |
|
14682
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
228 |
procedure setZoom(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean); |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
229 |
var param: LongInt; |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
230 |
begin |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
231 |
param:= getLongIntParameter(str, paramIndex, wrongParameter); |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
232 |
|
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
233 |
if param = 100 then |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
234 |
exit; |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
235 |
UserZoom:= (param/100.0) * cDefaultZoomLevel; |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
236 |
|
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
237 |
if UserZoom < cMaxZoomLevel then |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
238 |
UserZoom:= cMaxZoomLevel; |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
239 |
if UserZoom > cMinZoomLevel then |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
240 |
UserZoom:= cMinZoomLevel; |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
241 |
zoom:= UserZoom; |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
242 |
ZoomValue:= UserZoom; |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
243 |
end; |
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
244 |
|
9954 | 245 |
function parseParameter(cmd:string; arg:string; var paramIndex:LongInt): Boolean; |
15305
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
246 |
const reallyAll: array[0..34] of shortstring = ( |
8924 | 247 |
'--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
15304
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
248 |
'--height', '--maximized', '--frame-interval', '--volume','--nomusic', '--nosound', '--nodampen', |
8924 | 249 |
'--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
14682
93429d8f6b3f
Add setting to set default/initial zoom
Wuzzy <Wuzzy2@mail.ru>
parents:
14675
diff
changeset
|
250 |
'--zoom', |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
251 |
{internal} '--internal', '--port', '--recorder', '--landpreview', |
14675
56831f466d1d
Add settings.ini setting and hwengine param to disable holiday silliness (hat changes, etc.)
Wuzzy <Wuzzy2@mail.ru>
parents:
14603
diff
changeset
|
252 |
{misc} '--stats-only', '--gci', '--help','--protocol', '--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test','--no-holiday-silliness'); |
8197 | 253 |
var cmdIndex: byte; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
254 |
begin |
8150 | 255 |
parseParameter:= false; |
8197 | 256 |
cmdIndex:= 0; |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
257 |
|
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
258 |
//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
|
259 |
// 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
|
260 |
|
8197 | 261 |
while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
262 |
case cmdIndex of |
|
9954 | 263 |
{--prefix} 0 : PathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
264 |
{--user-prefix} 1 : UserPathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
|
14603
62dea281e4d5
Refactor hwengine: Rename cLocale to cLanguage
Wuzzy <Wuzzy2@mail.ru>
parents:
13955
diff
changeset
|
265 |
{--locale} 2 : cLanguageFName := getstringParameter (arg, paramIndex, parseParameter); |
8985
fe8d1a476f0b
range checking for more engine command line parameters, issue 600
koda
parents:
8924
diff
changeset
|
266 |
{--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
|
267 |
{--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
|
268 |
{--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
|
269 |
{--height} 6 : cWindowedHeight := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenHeight); |
15304
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
270 |
{--maximized} 7 : cWindowedMaximized:= true; |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
271 |
{--frame-interval} 8 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
272 |
{--volume} 9 : SetVolume ( max(getLongIntParameter(arg, paramIndex, parseParameter), 0) ); |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
273 |
{--nomusic} 10 : SetMusic ( false ); |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
274 |
{--nosound} 11 : SetSound ( false ); |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
275 |
{--nodampen} 12 : SetAudioDampen ( false ); |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
276 |
{--fullscreen} 13 : cFullScreen := true; |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
277 |
{--showfps} 14 : cShowFPS := true; |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
278 |
{--altdmg} 15 : cAltDamage := true; |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
279 |
{--low-quality} 16 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
280 |
{--raw-quality} 17 : cReducedQuality := getLongIntParameter(arg, paramIndex, parseParameter); |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
281 |
{--stereo} 18 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
282 |
{--nick} 19 : UserNick := parseNick( getstringParameter(arg, paramIndex, parseParameter) ); |
3bf780084c86
Remember maximized state of game window
Wuzzy <Wuzzy2@mail.ru>
parents:
14682
diff
changeset
|
283 |
{--zoom} 20 : setZoom(arg, paramIndex, parseParameter); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
284 |
{"internal" options} |
15305
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
285 |
{--internal} 21 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF}; |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
286 |
{--port} 22 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter ); |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
287 |
{--recorder} 23 : startVideoRecording(paramIndex); |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
288 |
{--landpreview} 24 : GameType := gmtLandPreview; |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
289 |
{anything else} |
15305
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
290 |
{--stats-only} 25 : statsOnlyGame(); |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
291 |
{--gci} 26 : GciEasterEgg(); |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
292 |
{--help} 27 : DisplayUsage(); |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
293 |
{--protocol} 28 : DisplayProtocol(); |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
294 |
{--no-teamtag} 29 : cTagsMask := cTagsMask and (not htTeamName); |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
295 |
{--no-hogtag} 30 : cTagsMask := cTagsMask and (not htName); |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
296 |
{--no-healthtag} 31 : cTagsMask := cTagsMask and (not htHealth); |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
297 |
{--translucent-tags} 32 : cTagsMask := cTagsMask or htTransparent; |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
298 |
{--lua-test} 33 : begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end; |
a3823f0916b8
ArgParsers: Remove deprecated command-line arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
15304
diff
changeset
|
299 |
{--no-holiday-silliness} 34 : cHolidaySilliness:= false; |
8150 | 300 |
else |
301 |
begin |
|
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
302 |
//Assume the first "non parameter" is the demo file, anything else is invalid |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
303 |
if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
8307 | 304 |
recordFileName := cmd |
305 |
else |
|
306 |
begin |
|
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
307 |
WriteLn(stderr, '"'+cmd+'" is not a valid option.'); |
8307 | 308 |
parseParameter:= true; |
309 |
end; |
|
310 |
end; |
|
8150 | 311 |
end; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
312 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
313 |
|
10175
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10173
diff
changeset
|
314 |
procedure parseCommandLine; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
315 |
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
|
316 |
paramTotal: LongInt; |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
317 |
index, nextIndex: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
318 |
wrongParameter: boolean; |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
319 |
//var tmpInt: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
320 |
begin |
10173 | 321 |
|
11099
c51e4c942525
- Fix for wrong start paramIndex in case of Hwlibrary
antonc27 <antonc27@mail.ru>
parents:
10316
diff
changeset
|
322 |
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
|
323 |
paramTotal:= ParamCount; //-1 because pascal enumeration is inclusive |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
324 |
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
|
325 |
while (paramIndex <= paramTotal) do |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
326 |
begin |
8425
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
327 |
// 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
|
328 |
index:= paramIndex; |
4f226963faef
restored ios project file, updated Game() interface, tweaked arg parsing, updated log writing, minor warnings
koda
parents:
8370
diff
changeset
|
329 |
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
|
330 |
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
|
331 |
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
|
332 |
inc(paramIndex); |
8150 | 333 |
end; |
334 |
if wrongParameter = true then |
|
13492
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
335 |
GameType:= gmtBadSyntax; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
336 |
end; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
337 |
|
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
338 |
procedure GetParams; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
339 |
begin |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
340 |
isInternal:= (ParamStr(1) = '--internal'); |
13492
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
341 |
helpCommandUsed:= false; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
342 |
|
8446
c18ba8726f5a
Fix sources so pas2c written in haskell could render them again
unc0rr
parents:
8444
diff
changeset
|
343 |
UserPathPrefix := _S'.'; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
344 |
PathPrefix := cDefaultPathPrefix; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
345 |
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
|
346 |
parseCommandLine(); |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
347 |
|
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
348 |
if (isInternal) and (ParamCount<=1) then |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
349 |
begin |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
350 |
WriteLn(stderr, 'The "--internal" option should not be manually used!'); |
13492
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
351 |
GameType := gmtBadSyntax; |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
352 |
end; |
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
353 |
|
13492
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
354 |
if (not helpCommandUsed) then |
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
355 |
if (not cTestLua) and (not isInternal) and (recordFileName = '') then |
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
356 |
begin |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
357 |
WriteLn(stderr, 'You must specify a demo file.'); |
13492
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
358 |
GameType := gmtBadSyntax; |
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
359 |
end |
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
360 |
else if (recordFileName <> '') then |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
361 |
WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '".'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
362 |
|
13492
d23731fe84d4
Fix hwengine --help returning with exit code 51
Wuzzy <Wuzzy2@mail.ru>
parents:
11794
diff
changeset
|
363 |
if (GameType = gmtBadSyntax) then |
13727
6cdb12449be7
Add description of hwengine command-line arguments in --help
Wuzzy <Wuzzy2@mail.ru>
parents:
13633
diff
changeset
|
364 |
WriteLn(stderr, 'Please use --help to see possible arguments and their usage.'); |
8325
ecd51650d5d8
GCI2012: Change Argument Passing Between Frontend and Engine
RowanD
parents:
8309
diff
changeset
|
365 |
|
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
366 |
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
|
367 |
|
9280 | 368 |
end. |
369 |