14 * You should have received a copy of the GNU General Public License |
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 |
15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 *) |
17 *) |
18 |
18 |
19 |
19 procedure GciEasterEgg; |
20 procedure internalStartGameWithParameters(); |
20 begin |
21 var tmp: LongInt; |
21 WriteLn(stdout, ' '); |
22 begin |
22 WriteLn(stdout, ' /\\\\\\\\\\\\ /\\\\\\\\\ /\\\\\\\\\\\ '); |
23 UserPathPrefix:= ParamStr(1); |
23 WriteLn(stdout, ' /\\\////////// /\\\//////// \/////\\\/// '); |
24 cScreenWidth:= StrToInt(ParamStr(2)); |
24 WriteLn(stdout, ' /\\\ /\\\/ \/\\\ '); |
25 cScreenHeight:= StrToInt(ParamStr(3)); |
25 WriteLn(stdout, ' \/\\\ /\\\\\\\ /\\\ \/\\\ '); |
26 cBits:= StrToInt(ParamStr(4)); |
26 WriteLn(stdout, ' \/\\\ \/////\\\ \/\\\ \/\\\ '); |
27 ipcPort:= StrToInt(ParamStr(5)); |
27 WriteLn(stdout, ' \/\\\ \/\\\ \//\\\ \/\\\ '); |
28 cFullScreen:= ParamStr(6) = '1'; |
28 WriteLn(stdout, ' \/\\\ \/\\\ \///\\\ \/\\\ '); |
29 SetSound(ParamStr(7) = '1'); |
29 WriteLn(stdout, ' \/\\\\\\\\\\\\\/ \////\\\\\\\\\ /\\\\\\\\\\\ '); |
30 SetMusic(ParamStr(8) = '1'); |
30 WriteLn(stdout, ' \///////////// \///////// \/////////// '); |
31 SetVolume(StrToInt(ParamStr(9))); |
31 WriteLn(stdout, ' '); |
32 cTimerInterval:= StrToInt(ParamStr(10)); |
32 WriteLn(stdout, ' Command Line Parser Implementation by a Google Code-In Student '); |
33 PathPrefix:= ParamStr(11); |
33 WriteLn(stdout, ' ASCII Art easter egg idea by @sheepluva '); |
34 cShowFPS:= ParamStr(12) = '1'; |
34 WriteLn(stdout, ' '); |
35 cAltDamage:= ParamStr(13) = '1'; |
35 end; |
36 UserNick:= DecodeBase64(ParamStr(14)); |
36 |
37 cReducedQuality:= StrToInt(ParamStr(15)); |
37 procedure DisplayUsage; |
38 tmp:= StrToInt(ParamStr(16)); |
38 begin |
|
39 WriteLn(stdout, 'Usage: hwengine <path to replay file> [options]'); |
|
40 WriteLn(stdout, ''); |
|
41 WriteLn(stdout, 'where [options] can be any of the following:'); |
|
42 WriteLn(stdout, ' --prefix [path to folder]'); |
|
43 WriteLn(stdout, ' --user-prefix [path to folder]'); |
|
44 WriteLn(stdout, ' --locale [name of language file]'); |
|
45 WriteLn(stdout, ' --nick [string]'); |
|
46 WriteLn(stdout, ' --fullscreen-width [fullscreen width in pixels]'); |
|
47 WriteLn(stdout, ' --fullscreen-height [fullscreen height in pixels]'); |
|
48 WriteLn(stdout, ' --width [window width in pixels]'); |
|
49 WriteLn(stdout, ' --height [window height in pixels]'); |
|
50 WriteLn(stdout, ' --volume [sound level]'); |
|
51 WriteLn(stdout, ' --frame-interval [milliseconds]'); |
|
52 Writeln(stdout, ' --stereo [value]'); |
|
53 WriteLn(stdout, ' --raw-quality [flags]'); |
|
54 WriteLn(stdout, ' --low-quality'); |
|
55 WriteLn(stdout, ' --nomusic'); |
|
56 WriteLn(stdout, ' --nosound'); |
|
57 WriteLn(stdout, ' --fullscreen'); |
|
58 WriteLn(stdout, ' --showfps'); |
|
59 WriteLn(stdout, ' --altdmg'); |
|
60 WriteLn(stdout, ' --stats-only'); |
|
61 WriteLn(stdout, ' --help'); |
|
62 WriteLn(stdout, ''); |
|
63 WriteLn(stdout, 'For more detailed help and examples go to:'); |
|
64 WriteLn(stdout, 'http://code.google.com/p/hedgewars/wiki/CommandLineOptions'); |
|
65 GameType:= gmtSyntax; |
|
66 end; |
|
67 |
|
68 procedure setDepth(var paramIndex: LongInt); |
|
69 begin |
|
70 WriteLn(stdout, 'WARNING: --depth is a deprecated command, which could be removed in a future version!'); |
|
71 WriteLn(stdout, ' This option no longer does anything, please consider removing it'); |
|
72 WriteLn(stdout, ''); |
|
73 inc(ParamIndex); |
|
74 end; |
|
75 |
|
76 procedure statsOnlyGame; |
|
77 begin |
|
78 cOnlyStats:= true; |
|
79 cReducedQuality:= $FFFFFFFF xor rqLowRes; |
|
80 SetSound(false); |
|
81 SetMusic(false); |
|
82 SetVolume(0); |
|
83 end; |
|
84 |
|
85 procedure setIpcPort(port: LongInt; var wrongParameter:Boolean); |
|
86 begin |
|
87 if isInternal then |
|
88 ipcPort := port |
|
89 else |
|
90 begin |
|
91 WriteLn(stderr, 'ERROR: use of --port is not allowed'); |
|
92 wrongParameter := true; |
|
93 end |
|
94 end; |
|
95 |
|
96 function parseNick(nick: String): String; |
|
97 begin |
|
98 if isInternal then |
|
99 parseNick:= DecodeBase64(nick) |
|
100 else |
|
101 parseNick:= nick; |
|
102 end; |
|
103 |
|
104 procedure setStereoMode(tmp: LongInt); |
|
105 begin |
39 GrayScale:= false; |
106 GrayScale:= false; |
40 if (tmp > 9) and (tmp < 16) then |
107 {$IFDEF USE_S3D_RENDERING} |
41 begin |
108 if (tmp > 6) and (tmp < 13) then |
|
109 begin |
|
110 // set the gray anaglyph rendering |
42 GrayScale:= true; |
111 GrayScale:= true; |
43 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-9))) |
112 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))) |
44 end |
113 end |
45 else if tmp <= 9 then |
114 else if tmp <= 6 then |
|
115 // set the fullcolor anaglyph |
46 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) |
116 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) |
47 else |
117 else |
|
118 // any other mode |
48 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); |
119 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); |
49 cLocaleFName:= ParamStr(17); |
120 {$ELSE} |
50 end; |
121 tmp:= tmp; |
51 |
122 cStereoMode:= smNone; |
|
123 {$ENDIF} |
|
124 end; |
|
125 |
|
126 procedure startVideoRecording(var paramIndex: LongInt); |
|
127 begin |
|
128 // Silence the hint that appears when USE_VIDEO_RECORDING is not defined |
|
129 paramIndex:= paramIndex; |
52 {$IFDEF USE_VIDEO_RECORDING} |
130 {$IFDEF USE_VIDEO_RECORDING} |
53 procedure internalStartVideoRecordingWithParameters(); |
|
54 begin |
|
55 internalStartGameWithParameters(); |
|
56 GameType:= gmtRecord; |
131 GameType:= gmtRecord; |
57 cVideoFramerateNum:= StrToInt(ParamStr(18)); |
132 inc(paramIndex); |
58 cVideoFramerateDen:= StrToInt(ParamStr(19)); |
133 cVideoFramerateNum:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
59 RecPrefix:= ParamStr(20); |
134 cVideoFramerateDen:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
60 cAVFormat:= ParamStr(21); |
135 RecPrefix:= ParamStr(paramIndex); inc(paramIndex); |
61 cVideoCodec:= ParamStr(22); |
136 cAVFormat:= ParamStr(paramIndex); inc(paramIndex); |
62 cVideoQuality:= StrToInt(ParamStr(23)); |
137 cVideoCodec:= ParamStr(paramIndex); inc(paramIndex); |
63 cAudioCodec:= ParamStr(24); |
138 cVideoQuality:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
64 end; |
139 cAudioCodec:= ParamStr(paramIndex); inc(paramIndex); |
65 {$ENDIF} |
140 {$ENDIF} |
66 |
141 end; |
67 procedure setVideo(screenWidth: LongInt; screenHeight: LongInt; bitsStr: LongInt); |
142 |
68 begin |
143 function getLongIntParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt; |
69 cScreenWidth:= screenWidth; |
144 var tmpInt, c: LongInt; |
70 cScreenHeight:= screenHeight; |
145 begin |
71 cBits:= bitsStr |
146 inc(paramIndex); |
72 end; |
147 val(str, tmpInt, c); |
73 |
148 wrongParameter:= c <> 0; |
74 procedure setVideoWithParameters(screenWidthParam: string; screenHeightParam: string; bitsParam: string); |
149 if wrongParameter then |
75 var screenWidthAsInt, screenHeightAsInt, bitsStrAsInt, c: LongInt; |
150 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"'); |
76 begin |
151 getLongIntParameter:= tmpInt; |
77 val(screenWidthParam, screenWidthAsInt, c); |
152 end; |
78 val(screenHeightParam, screenHeightAsInt, c); |
153 |
79 val(bitsParam, bitsStrAsInt, c); |
154 function getStringParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): String; |
80 setVideo(screenWidthAsInt,screenHeightAsInt,bitsStrAsInt) |
155 begin |
81 end; |
156 inc(paramIndex); |
82 |
157 wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
83 procedure setOtherOptions(languageFile: string; fullScreen: boolean); |
158 if wrongParameter then |
84 begin |
159 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); |
85 cLocaleFName:= languageFile; |
160 getStringParameter:= str; |
86 cFullScreen:= fullScreen |
161 end; |
87 end; |
162 |
88 |
163 |
89 procedure setShowFPS(showFPS: boolean); |
164 procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); Forward; |
90 begin |
165 |
91 cShowFPS:= showFPS |
166 function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean; |
92 end; |
167 const videoArray: Array [1..5] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
93 |
168 audioArray: Array [1..3] of String = ('--volume','--nomusic','--nosound'); |
94 procedure setOtherOptionsWithParameters(languageFileParam: string; fullScreenParam: string; showFPSParam: string); |
169 otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps'); |
95 var fullScreen, showFPS: boolean; |
170 mediaArray: Array [1..10] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
96 begin |
171 allArray: Array [1..14] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality'); |
97 fullScreen:= fullScreenParam = '1'; |
172 reallyAll: array[0..30] of shortstring = ( |
98 showFPS:= showFPSParam = '1'; |
173 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
99 setOtherOptions(languageFileParam,fullScreen); |
174 '--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
100 setShowFPS(showFPS) |
175 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
101 end; |
176 {deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
102 |
177 {internal} '--internal', '--port', '--recorder', '--landpreview', |
103 procedure setAudio(initialVolume: LongInt; musicEnabled: boolean; soundEnabled: boolean); |
178 {misc} '--stats-only', '--gci', '--help'); |
104 begin |
179 var cmdIndex: byte; |
105 SetVolume(initialVolume); |
180 begin |
106 SetMusic(musicEnabled); |
181 parseParameter:= false; |
107 SetSound(soundEnabled); |
182 cmdIndex:= 0; |
108 end; |
183 |
109 |
184 //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above, |
110 procedure setAudioWithParameters(initialVolumeParam: string; musicEnabledParam: string; soundEnabledParam: string); |
185 // the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki |
111 var initialVolumeAsInt, c: LongInt; |
186 |
112 musicEnabled, soundEnabled: boolean; |
187 while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
113 begin |
188 case cmdIndex of |
114 val(initialVolumeParam, initialVolumeAsInt, c); |
189 {--prefix} 0 : PathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
115 musicEnabled:= musicEnabledParam = '1'; |
190 {--user-prefix} 1 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
116 soundEnabled:= soundEnabledParam = '1'; |
191 {--locale} 2 : cLocaleFName := getStringParameter (arg, paramIndex, parseParameter); |
117 setAudio(initialVolumeAsInt,musicEnabled, soundEnabled) |
192 {--fullscreen-width} 3 : cFullscreenWidth := getLongIntParameter(arg, paramIndex, parseParameter); |
118 end; |
193 {--fullscreen-height} 4 : cFullscreenHeight := getLongIntParameter(arg, paramIndex, parseParameter); |
119 |
194 {--width} 5 : cWindowedWidth := getLongIntParameter(arg, paramIndex, parseParameter); |
120 procedure setMultimediaOptionsWithParameters(screenWidthParam, screenHeightParam, bitsParam: string; |
195 {--height} 6 : cWindowedHeight := getLongIntParameter(arg, paramIndex, parseParameter); |
121 initialVolumeParam, musicEnabledParam, soundEnabledParam: string; |
196 {--frame-interval} 7 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
122 languageFileParam, fullScreenParam: string); |
197 {--volume} 8 : SetVolume ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
123 begin |
198 {--nomusic} 9 : SetMusic ( false ); |
124 setVideoWithParameters(screenWidthParam,screenHeightParam, bitsParam); |
199 {--nosound} 10 : SetSound ( false ); |
125 setAudioWithParameters(initialVolumeParam,musicEnabledParam,soundEnabledParam); |
200 {--fullscreen} 11 : cFullScreen := true; |
126 setOtherOptions(languageFileParam,fullScreenParam = '1') |
201 {--showfps} 12 : cShowFPS := true; |
127 end; |
202 {--altdmg} 13 : cAltDamage := true; |
128 |
203 {--low-quality} 14 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
129 procedure setAltDamageTimerValueAndQuality(altDamage: boolean; timeIterval: LongInt; reducedQuality: boolean); |
204 {--raw-quality} 15 : cReducedQuality := getLongIntParameter(arg, paramIndex, parseParameter); |
130 begin |
205 {--stereo} 16 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
131 cAltDamage:= altDamage; |
206 {--nick} 17 : UserNick := parseNick( getStringParameter(arg, paramIndex, parseParameter) ); |
132 cTimerInterval:= timeIterval; |
207 {deprecated options} |
133 if (reducedQuality) then //HACK |
208 {--depth} 18 : setDepth(paramIndex); |
134 cReducedQuality:= $FFFFFFFF xor rqLowRes |
209 {--set-video} 19 : parseClassicParameter(videoArray,5,paramIndex); |
135 end; |
210 {--set-audio} 20 : parseClassicParameter(audioArray,3,paramIndex); |
136 |
211 {--set-other} 21 : parseClassicParameter(otherArray,3,paramIndex); |
137 procedure setAllOptionsWithParameters(screenWidthParam:string; screenHeightParam:string; bitsParam:string; |
212 {--set-multimedia} 22 : parseClassicParameter(mediaArray,10,paramIndex); |
138 initialVolumeParam:string; musicEnabledParam:string; soundEnabledParam:string; |
213 {--set-everything} 23 : parseClassicParameter(allArray,14,paramIndex); |
139 languageFileParam:string; fullScreenParam:string; showFPSParam:string; |
214 {"internal" options} |
140 altDamageParam:string; timeItervalParam:string; reducedQualityParam: string); |
215 {--internal} 24 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF}; |
141 var showFPS, altDamage, reducedQuality: boolean; |
216 {--port} 25 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter ); |
142 timeIterval, c: LongInt; |
217 {--recorder} 26 : startVideoRecording(paramIndex); |
143 begin |
218 {--landpreview} 27 : GameType := gmtLandPreview; |
144 setMultimediaOptionsWithParameters(screenWidthParam,screenHeightParam, bitsParam, |
219 {anything else} |
145 initialVolumeParam,musicEnabledParam,soundEnabledParam, |
220 {--stats-only} 28 : statsOnlyGame(); |
146 languageFileParam,fullScreenParam); |
221 {--gci} 29 : GciEasterEgg(); |
147 showFPS := showFPSParam = '1'; |
222 {--help} 30 : DisplayUsage(); |
148 setShowFPS(showFPS); |
223 else |
149 |
224 begin |
150 altDamage:= altDamageParam = '1'; |
225 //Asusme the first "non parameter" is the replay file, anything else is invalid |
151 val(timeItervalParam, timeIterval, c); |
226 if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
152 reducedQuality:= reducedQualityParam = '1'; |
227 recordFileName := cmd |
153 setAltDamageTimerValueAndQuality(altDamage,timeIterval,reducedQuality); |
228 else |
154 end; |
229 begin |
155 |
230 WriteLn(stderr, '"'+cmd+'" is not a valid option'); |
156 procedure playReplayFileWithParameters(); |
231 parseParameter:= true; |
|
232 end; |
|
233 end; |
|
234 end; |
|
235 end; |
|
236 |
|
237 procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); |
|
238 var index, tmpInt: LongInt; |
|
239 isBool, isValid: Boolean; |
|
240 cmd, arg, newSyntax: String; |
|
241 begin |
|
242 WriteLn(stdout, 'WARNING: you are using a deprecated command, which could be removed in a future version!'); |
|
243 WriteLn(stdout, ' Consider updating to the latest syntax, which is much more flexible!'); |
|
244 WriteLn(stdout, ' Run `hwegine --help` to learn it!'); |
|
245 WriteLn(stdout, ''); |
|
246 |
|
247 index:= 0; |
|
248 tmpInt:= 1; |
|
249 while (index < size) do |
|
250 begin |
|
251 newSyntax:= ''; |
|
252 inc(paramIndex); |
|
253 cmd:= cmdArray[index]; |
|
254 arg:= ParamStr(paramIndex); |
|
255 isValid:= (cmd<>'--depth'); |
|
256 |
|
257 // check if the parameter is a boolean one |
|
258 isBool:= (cmd = '--nomusic') or (cmd = '--nosound') or (cmd = '--fullscreen') or (cmd = '--showfps') or (cmd = '--altdmg'); |
|
259 if isBool and (arg='0') then |
|
260 isValid:= false; |
|
261 if (cmd='--nomusic') or (cmd='--nosound') then |
|
262 isValid:= not isValid; |
|
263 |
|
264 if isValid then |
|
265 begin |
|
266 parseParameter(cmd, arg, tmpInt); |
|
267 newSyntax := newSyntax + cmd + ' '; |
|
268 if not isBool then |
|
269 newSyntax := newSyntax + arg + ' '; |
|
270 end; |
|
271 inc(index); |
|
272 end; |
|
273 |
|
274 WriteLn(stdout, 'Attempted to automatically convert to the new syntax:'); |
|
275 WriteLn(stdout, newSyntax); |
|
276 WriteLn(stdout, ''); |
|
277 end; |
|
278 |
|
279 procedure parseCommandLine{$IFDEF HWLIBRARY}(argc: LongInt; argv: PPChar){$ENDIF}; |
157 var paramIndex: LongInt; |
280 var paramIndex: LongInt; |
|
281 paramTotal: LongInt; |
|
282 index, nextIndex: LongInt; |
158 wrongParameter: boolean; |
283 wrongParameter: boolean; |
159 begin |
284 //var tmpInt: LongInt; |
160 UserPathPrefix:= ParamStr(1); |
285 begin |
161 PathPrefix:= ParamStr(2); |
286 paramIndex:= {$IFDEF HWLIBRARY}0{$ELSE}1{$ENDIF}; |
162 recordFileName:= ParamStr(3); |
287 paramTotal:= {$IFDEF HWLIBRARY}argc-1{$ELSE}ParamCount{$ENDIF}; //-1 because pascal enumeration is inclusive |
163 paramIndex:= 4; |
288 (* |
|
289 WriteLn(stdout, 'total parameters: ' + inttostr(paramTotal)); |
|
290 tmpInt:= 0; |
|
291 while (tmpInt <= paramTotal) do |
|
292 begin |
|
293 WriteLn(stdout, inttostr(tmpInt) + ': ' + {$IFDEF HWLIBRARY}argv[tmpInt]{$ELSE}paramCount(tmpInt){$ENDIF}); |
|
294 inc(tmpInt); |
|
295 end; |
|
296 *) |
164 wrongParameter:= false; |
297 wrongParameter:= false; |
165 while (paramIndex <= ParamCount) and (not wrongParameter) do |
298 while (paramIndex <= paramTotal) do |
166 begin |
299 begin |
167 if ParamStr(paramIndex) = '--set-video' then |
300 // avoid going past the number of paramTotal (esp. w/ library) |
168 //--set-video [screen width] [screen height] [color dept] |
301 index:= paramIndex; |
169 begin |
302 if index = paramTotal then nextIndex:= index |
170 if(ParamCount-paramIndex < 3) then |
303 else nextIndex:= index+1; |
171 begin |
304 {$IFDEF HWLIBRARY} |
172 wrongParameter:= true; |
305 wrongParameter:= parseParameter( argv[index], argv[nextIndex], paramIndex); |
173 GameType:= gmtSyntax |
306 {$ELSE} |
174 end; |
307 wrongParameter:= parseParameter( ParamStr(index), ParamStr(nextIndex), paramIndex); |
175 setVideoWithParameters(ParamStr(paramIndex+1), ParamStr(paramIndex+2), ParamStr(paramIndex+3)); |
308 {$ENDIF} |
176 paramIndex:= paramIndex + 4 |
309 inc(paramIndex); |
177 end |
310 end; |
178 else |
311 if wrongParameter = true then |
179 //--set-audio [volume] [enable music] [enable sounds] |
312 GameType:= gmtSyntax; |
180 if ParamStr(paramIndex) = '--set-audio' then |
313 end; |
181 begin |
314 |
182 if(ParamCount-paramIndex < 3) then |
315 {$IFNDEF HWLIBRARY} |
183 begin |
316 procedure GetParams; |
184 wrongParameter := true; |
317 begin |
185 GameType:= gmtSyntax |
318 isInternal:= (ParamStr(1) = '--internal'); |
186 end; |
319 |
187 setAudioWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2), ParamStr(paramIndex+3)); |
320 UserPathPrefix := '.'; |
188 paramIndex:= paramIndex + 4 |
321 PathPrefix := cDefaultPathPrefix; |
189 end |
322 recordFileName := ''; |
190 else |
323 parseCommandLine(); |
191 // --set-other [language file] [full screen] [show FPS] |
324 |
192 if ParamStr(paramIndex) = '--set-other' then |
325 if (isInternal) and (ParamCount<=1) then |
193 begin |
326 begin |
194 if(ParamCount-paramIndex < 3) then |
327 WriteLn(stderr, '--internal should not be manually used'); |
195 begin |
328 GameType := gmtSyntax; |
196 wrongParameter:= true; |
329 end; |
197 GameType:= gmtSyntax |
330 |
198 end; |
331 if (not isInternal) and (recordFileName = '') then |
199 setOtherOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2), ParamStr(paramIndex+3)); |
332 begin |
200 paramIndex:= paramIndex + 4 |
333 WriteLn(stderr, 'You must specify a replay file'); |
201 end |
334 GameType := gmtSyntax; |
202 else |
335 end |
203 //--set-multimedia [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] |
336 else if (recordFileName <> '') then |
204 if ParamStr(paramIndex) = '--set-multimedia' then |
337 WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"'); |
205 begin |
338 |
206 if ParamCount-paramIndex < 8 then |
339 if (GameType = gmtSyntax) then |
207 begin |
340 WriteLn(stderr, 'Please use --help to see possible arguments and their usage'); |
208 wrongParameter:= true; |
341 |
209 GameType:= gmtSyntax |
342 (* |
210 end; |
343 WriteLn(stdout,'PathPrefix: ' + PathPrefix); |
211 setMultimediaOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2),ParamStr(paramIndex+3), |
344 WriteLn(stdout,'UserPathPrefix: ' + UserPathPrefix); |
212 ParamStr(paramIndex+4),ParamStr(paramIndex+5),ParamStr(paramIndex+6), |
345 *) |
213 ParamStr(paramIndex+7),ParamStr(paramIndex+8)); |
346 end; |
214 paramIndex:= paramIndex + 9 |
347 {$ENDIF} |
215 end |
348 |
216 else |
|
217 //--set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality] |
|
218 if ParamStr(paramIndex) = '--set-everything' then |
|
219 begin |
|
220 if ParamCount-paramIndex < 12 then |
|
221 begin |
|
222 wrongParameter:= true; |
|
223 GameType:= gmtSyntax |
|
224 end; |
|
225 setAllOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2),ParamStr(paramIndex+3), |
|
226 ParamStr(paramIndex+4),ParamStr(paramIndex+5),ParamStr(paramIndex+6), |
|
227 ParamStr(paramIndex+7),ParamStr(paramIndex+8),ParamStr(paramIndex+9), |
|
228 ParamStr(paramIndex+10),ParamStr(paramIndex+11),ParamStr(paramIndex+12)); |
|
229 paramIndex:= paramIndex + 13 |
|
230 end |
|
231 else |
|
232 if ParamStr(paramIndex) = '--stats-only' then |
|
233 begin |
|
234 cOnlyStats:= true; |
|
235 SetSound(false); |
|
236 SetMusic(false); |
|
237 cReducedQuality:= $FFFFFFFF xor rqLowRes; // HACK |
|
238 paramIndex:= paramIndex + 1 |
|
239 end |
|
240 else |
|
241 begin |
|
242 wrongParameter:= true; |
|
243 GameType:= gmtSyntax |
|
244 end |
|
245 end |
|
246 end; |
|
247 |
|