94 WriteLn(stdout, ' --altdmg'); |
98 WriteLn(stdout, ' --altdmg'); |
95 WriteLn(stdout, ' --no-teamtag'); |
99 WriteLn(stdout, ' --no-teamtag'); |
96 WriteLn(stdout, ' --no-hogtag'); |
100 WriteLn(stdout, ' --no-hogtag'); |
97 WriteLn(stdout, ' --no-healthtag'); |
101 WriteLn(stdout, ' --no-healthtag'); |
98 WriteLn(stdout, ' --translucent-tags'); |
102 WriteLn(stdout, ' --translucent-tags'); |
|
103 WriteLn(stdout, ' --stats-only'); |
99 WriteLn(stdout, ' --chat-size [default chat size in percent]'); |
104 WriteLn(stdout, ' --chat-size [default chat size in percent]'); |
100 WriteLn(stdout, ' --stats-only'); |
|
101 WriteLn(stdout, ' --help'); |
105 WriteLn(stdout, ' --help'); |
102 WriteLn(stdout, ''); |
106 WriteLn(stdout, ''); |
103 WriteLn(stdout, 'For more detailed help and examples go to:'); |
107 WriteLn(stdout, 'HUD:'); |
104 WriteLn(stdout, 'http://hedgewars.org/kb/CommandLineOptions'); |
108 WriteLn(stdout, ' --altdmg: Show alternative damage'); |
105 GameType:= gmtSyntax; |
109 WriteLn(stdout, ' --no-teamtag: Disable team name tags'); |
|
110 WriteLn(stdout, ' --no-hogtag: Disable hedgehog name tags'); |
|
111 WriteLn(stdout, ' --no-healthtag: Disable hedgehog health tags'); |
|
112 WriteLn(stdout, ' --translucent-tags: Enable translucent name and health tags'); |
|
113 WriteLn(stdout, ' --chat-size [default chat size in percent]'); |
|
114 WriteLn(stdout, ' --showfps: Show frames per second'); |
|
115 WriteLn(stdout, ''); |
|
116 WriteLn(stdout, 'Miscellaneous:'); |
|
117 WriteLn(stdout, ' --nick <name>: Set user nickname'); |
|
118 WriteLn(stdout, ' --help: Show a list of command-line options and exit'); |
|
119 WriteLn(stdout, ' --protocol: Display protocol number and exit'); |
|
120 WriteLn(stdout, ''); |
|
121 Writeln(stdout, 'Advanced options:'); |
|
122 Writeln(stdout, ' --stereo <value>: Set stereoscopic rendering (1 to 14)'); |
|
123 WriteLn(stdout, ' --frame-interval <milliseconds>: Set minimum interval (in ms) between each frame. Eg, 40 would make the game run at most 25 fps'); |
|
124 WriteLn(stdout, ' --raw-quality <flags>: Manually specify the reduced quality flags'); |
|
125 WriteLn(stdout, ' --stats-only: Write the round information to console without launching the game, useful for statistics only'); |
|
126 WriteLn(stdout, ' --lua-test <path to script>: Run a Lua test script'); |
|
127 GameType:= gmtSyntaxHelp; |
|
128 helpCommandUsed:= true; |
|
129 end; |
|
130 |
|
131 procedure DisplayProtocol; |
|
132 begin |
|
133 WriteLn(stdout, IntToStr(cNetProtoVersion)); |
|
134 GameType:= gmtSyntaxHelp; |
|
135 helpCommandUsed:= true; |
106 end; |
136 end; |
107 |
137 |
108 procedure setDepth(var paramIndex: LongInt); |
138 procedure setDepth(var paramIndex: LongInt); |
109 begin |
139 begin |
110 WriteLn(stdout, 'WARNING: --depth is a deprecated command, which could be removed in a future version!'); |
140 WriteLn(stdout, 'WARNING: --depth is a deprecated command, which could be removed in a future version!'); |
111 WriteLn(stdout, ' This option no longer does anything, please consider removing it'); |
141 WriteLn(stdout, ' This option no longer does anything, please consider removing it.'); |
112 WriteLn(stdout, ''); |
142 WriteLn(stdout, ''); |
113 inc(ParamIndex); |
143 inc(ParamIndex); |
114 end; |
144 end; |
115 |
145 |
116 procedure statsOnlyGame; |
146 procedure statsOnlyGame; |
190 val(str, tmpInt); |
220 val(str, tmpInt); |
191 {$ELSE} |
221 {$ELSE} |
192 val(str, tmpInt, c); |
222 val(str, tmpInt, c); |
193 wrongParameter:= c <> 0; |
223 wrongParameter:= c <> 0; |
194 if wrongParameter then |
224 if wrongParameter then |
195 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"'); |
225 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"!'); |
196 {$ENDIF} |
226 {$ENDIF} |
197 getLongIntParameter:= tmpInt; |
227 getLongIntParameter:= tmpInt; |
198 end; |
228 end; |
199 |
229 |
200 function getstringParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): shortstring; |
230 function getstringParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): shortstring; |
201 begin |
231 begin |
202 inc(paramIndex); |
232 inc(paramIndex); |
203 wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
233 wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
204 {$IFNDEF HWLIBRARY} |
234 {$IFNDEF HWLIBRARY} |
205 if wrongParameter then |
235 if wrongParameter then |
206 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); |
236 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"!'); |
207 {$ENDIF} |
237 {$ENDIF} |
208 getstringParameter:= str; |
238 getstringParameter:= str; |
|
239 end; |
|
240 |
|
241 procedure setZoom(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean); |
|
242 var param: LongInt; |
|
243 begin |
|
244 param:= getLongIntParameter(str, paramIndex, wrongParameter); |
|
245 |
|
246 if param = 100 then |
|
247 exit; |
|
248 UserZoom:= (param/100.0) * cDefaultZoomLevel; |
|
249 |
|
250 if UserZoom < cMaxZoomLevel then |
|
251 UserZoom:= cMaxZoomLevel; |
|
252 if UserZoom > cMinZoomLevel then |
|
253 UserZoom:= cMinZoomLevel; |
|
254 zoom:= UserZoom; |
|
255 ZoomValue:= UserZoom; |
209 end; |
256 end; |
210 |
257 |
211 procedure parseClassicParameter(cmdarray: array of string; size:LongInt; var paramIndex:LongInt); forward; |
258 procedure parseClassicParameter(cmdarray: array of string; size:LongInt; var paramIndex:LongInt); forward; |
212 |
259 |
213 function parseParameter(cmd:string; arg:string; var paramIndex:LongInt): Boolean; |
260 function parseParameter(cmd:string; arg:string; var paramIndex:LongInt): Boolean; |
214 const videoarray: array [0..4] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
261 const videoarray: array [0..4] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
215 audioarray: array [0..2] of string = ('--volume','--nomusic','--nosound'); |
262 audioarray: array [0..2] of string = ('--volume','--nomusic','--nosound'); |
216 otherarray: array [0..2] of string = ('--locale','--fullscreen','--showfps'); |
263 otherarray: array [0..2] of string = ('--locale','--fullscreen','--showfps'); |
217 mediaarray: array [0..9] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
264 mediaarray: array [0..9] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
218 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'); |
265 allarray: array [0..19] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--nodampen','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags', '--chat-size'); |
219 reallyAll: array[0..36] of shortstring = ( |
266 reallyAll: array[0..40] of shortstring = ( |
220 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
267 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
221 '--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
268 '--height', '--frame-interval', '--volume','--nomusic', '--nosound', '--nodampen', |
222 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
269 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
|
270 '--zoom', |
223 {deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
271 {deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
224 {internal} '--internal', '--port', '--recorder', '--landpreview', |
272 {internal} '--internal', '--port', '--recorder', '--landpreview', |
225 {misc} '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test','--chat-size'); |
273 {misc} '--stats-only', '--gci', '--help','--protocol', '--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test','--no-holiday-silliness','--chat-size'); |
226 var cmdIndex: byte; |
274 var cmdIndex: byte; |
227 begin |
275 begin |
228 parseParameter:= false; |
276 parseParameter:= false; |
229 cmdIndex:= 0; |
277 cmdIndex:= 0; |
230 |
278 |
233 |
281 |
234 while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
282 while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
235 case cmdIndex of |
283 case cmdIndex of |
236 {--prefix} 0 : PathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
284 {--prefix} 0 : PathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
237 {--user-prefix} 1 : UserPathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
285 {--user-prefix} 1 : UserPathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
238 {--locale} 2 : cLocaleFName := getstringParameter (arg, paramIndex, parseParameter); |
286 {--locale} 2 : cLanguageFName := getstringParameter (arg, paramIndex, parseParameter); |
239 {--fullscreen-width} 3 : cFullscreenWidth := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenWidth); |
287 {--fullscreen-width} 3 : cFullscreenWidth := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenWidth); |
240 {--fullscreen-height} 4 : cFullscreenHeight := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenHeight); |
288 {--fullscreen-height} 4 : cFullscreenHeight := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenHeight); |
241 {--width} 5 : cWindowedWidth := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenWidth); |
289 {--width} 5 : cWindowedWidth := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenWidth); |
242 {--height} 6 : cWindowedHeight := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenHeight); |
290 {--height} 6 : cWindowedHeight := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenHeight); |
243 {--frame-interval} 7 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
291 {--frame-interval} 7 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
244 {--volume} 8 : SetVolume ( max(getLongIntParameter(arg, paramIndex, parseParameter), 0) ); |
292 {--volume} 8 : SetVolume ( max(getLongIntParameter(arg, paramIndex, parseParameter), 0) ); |
245 {--nomusic} 9 : SetMusic ( false ); |
293 {--nomusic} 9 : SetMusic ( false ); |
246 {--nosound} 10 : SetSound ( false ); |
294 {--nosound} 10 : SetSound ( false ); |
247 {--fullscreen} 11 : cFullScreen := true; |
295 {--nodampen} 11 : SetAudioDampen ( false ); |
248 {--showfps} 12 : cShowFPS := true; |
296 {--fullscreen} 12 : cFullScreen := true; |
249 {--altdmg} 13 : cAltDamage := true; |
297 {--showfps} 13 : cShowFPS := true; |
250 {--low-quality} 14 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
298 {--altdmg} 14 : cAltDamage := true; |
251 {--raw-quality} 15 : cReducedQuality := getLongIntParameter(arg, paramIndex, parseParameter); |
299 {--low-quality} 15 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
252 {--stereo} 16 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
300 {--raw-quality} 16 : cReducedQuality := getLongIntParameter(arg, paramIndex, parseParameter); |
253 {--nick} 17 : UserNick := parseNick( getstringParameter(arg, paramIndex, parseParameter) ); |
301 {--stereo} 17 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
|
302 {--nick} 18 : UserNick := parseNick( getstringParameter(arg, paramIndex, parseParameter) ); |
|
303 {--zoom} 19 : setZoom(arg, paramIndex, parseParameter); |
254 {deprecated options} |
304 {deprecated options} |
255 {--depth} 18 : setDepth(paramIndex); |
305 {--depth} 20 : setDepth(paramIndex); |
256 {--set-video} 19 : parseClassicParameter(videoarray,5,paramIndex); |
306 {--set-video} 21 : parseClassicParameter(videoarray,5,paramIndex); |
257 {--set-audio} 20 : parseClassicParameter(audioarray,3,paramIndex); |
307 {--set-audio} 22 : parseClassicParameter(audioarray,3,paramIndex); |
258 {--set-other} 21 : parseClassicParameter(otherarray,3,paramIndex); |
308 {--set-other} 23 : parseClassicParameter(otherarray,3,paramIndex); |
259 {--set-multimedia} 22 : parseClassicParameter(mediaarray,10,paramIndex); |
309 {--set-multimedia} 24 : parseClassicParameter(mediaarray,10,paramIndex); |
260 {--set-everything} 23 : parseClassicParameter(allarray,14,paramIndex); |
310 {--set-everything} 25 : parseClassicParameter(allarray,14,paramIndex); |
261 {"internal" options} |
311 {"internal" options} |
262 {--internal} 24 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF}; |
312 {--internal} 26 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF}; |
263 {--port} 25 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter ); |
313 {--port} 27 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter ); |
264 {--recorder} 26 : startVideoRecording(paramIndex); |
314 {--recorder} 28 : startVideoRecording(paramIndex); |
265 {--landpreview} 27 : GameType := gmtLandPreview; |
315 {--landpreview} 29 : GameType := gmtLandPreview; |
266 {anything else} |
316 {anything else} |
267 {--stats-only} 28 : statsOnlyGame(); |
317 {--stats-only} 30 : statsOnlyGame(); |
268 {--gci} 29 : GciEasterEgg(); |
318 {--gci} 31 : GciEasterEgg(); |
269 {--help} 30 : DisplayUsage(); |
319 {--help} 32 : DisplayUsage(); |
270 {--no-teamtag} 31 : cTagsMask := cTagsMask and (not htTeamName); |
320 {--protocol} 33 : DisplayProtocol(); |
271 {--no-hogtag} 32 : cTagsMask := cTagsMask and (not htName); |
321 {--no-teamtag} 34 : cTagsMask := cTagsMask and (not htTeamName); |
272 {--no-healthtag} 33 : cTagsMask := cTagsMask and (not htHealth); |
322 {--no-hogtag} 35 : cTagsMask := cTagsMask and (not htName); |
273 {--translucent-tags} 34 : cTagsMask := cTagsMask or htTransparent; |
323 {--no-healthtag} 36 : cTagsMask := cTagsMask and (not htHealth); |
274 {--lua-test} 35 : begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end; |
324 {--translucent-tags} 37 : cTagsMask := cTagsMask or htTransparent; |
275 {--chat-size} 36 : cDefaultChatScale := 1.0 * getLongIntParameter(arg, paramIndex, parseParameter) / 100; |
325 {--lua-test} 38 : begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end; |
|
326 {--no-holiday-silliness} 39 : cHolidaySilliness:= false; |
|
327 {--chat-size} 40 : cDefaultChatScale := 1.0 * getLongIntParameter(arg, paramIndex, parseParameter) / 100; |
276 else |
328 else |
277 begin |
329 begin |
278 //Assume the first "non parameter" is the replay file, anything else is invalid |
330 //Assume the first "non parameter" is the demo file, anything else is invalid |
279 if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
331 if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
280 recordFileName := cmd |
332 recordFileName := cmd |
281 else |
333 else |
282 begin |
334 begin |
283 WriteLn(stderr, '"'+cmd+'" is not a valid option'); |
335 WriteLn(stderr, '"'+cmd+'" is not a valid option.'); |
284 parseParameter:= true; |
336 parseParameter:= true; |
285 end; |
337 end; |
286 end; |
338 end; |
287 end; |
339 end; |
288 end; |
340 end; |
357 else nextIndex:= index+1; |
409 else nextIndex:= index+1; |
358 wrongParameter:= parseParameter( ParamStr(index), ParamStr(nextIndex), paramIndex); |
410 wrongParameter:= parseParameter( ParamStr(index), ParamStr(nextIndex), paramIndex); |
359 inc(paramIndex); |
411 inc(paramIndex); |
360 end; |
412 end; |
361 if wrongParameter = true then |
413 if wrongParameter = true then |
362 GameType:= gmtSyntax; |
414 GameType:= gmtBadSyntax; |
363 end; |
415 end; |
364 |
416 |
365 procedure GetParams; |
417 procedure GetParams; |
366 begin |
418 begin |
367 isInternal:= (ParamStr(1) = '--internal'); |
419 isInternal:= (ParamStr(1) = '--internal'); |
|
420 helpCommandUsed:= false; |
368 |
421 |
369 UserPathPrefix := _S'.'; |
422 UserPathPrefix := _S'.'; |
370 PathPrefix := cDefaultPathPrefix; |
423 PathPrefix := cDefaultPathPrefix; |
371 recordFileName := ''; |
424 recordFileName := ''; |
372 parseCommandLine(); |
425 parseCommandLine(); |
373 |
426 |
374 if (isInternal) and (ParamCount<=1) then |
427 if (isInternal) and (ParamCount<=1) then |
375 begin |
428 begin |
376 WriteLn(stderr, '--internal should not be manually used'); |
429 WriteLn(stderr, 'The "--internal" option should not be manually used!'); |
377 GameType := gmtSyntax; |
430 GameType := gmtBadSyntax; |
378 end; |
431 end; |
379 |
432 |
380 if (not cTestLua) and (not isInternal) and (recordFileName = '') then |
433 if (not helpCommandUsed) then |
381 begin |
434 if (not cTestLua) and (not isInternal) and (recordFileName = '') then |
382 WriteLn(stderr, 'You must specify a replay file'); |
435 begin |
383 GameType := gmtSyntax; |
436 WriteLn(stderr, 'You must specify a demo file.'); |
384 end |
437 GameType := gmtBadSyntax; |
385 else if (recordFileName <> '') then |
438 end |
386 WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"'); |
439 else if (recordFileName <> '') then |
387 |
440 WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '".'); |
388 if (GameType = gmtSyntax) then |
441 |
389 WriteLn(stderr, 'Please use --help to see possible arguments and their usage'); |
442 if (GameType = gmtBadSyntax) then |
|
443 WriteLn(stderr, 'Please use --help to see possible arguments and their usage.'); |
390 |
444 |
391 (* |
445 (* |
392 WriteLn(stdout,'PathPrefix: ' + PathPrefix); |
446 WriteLn(stdout,'PathPrefix: ' + PathPrefix); |
393 WriteLn(stdout,'UserPathPrefix: ' + UserPathPrefix); |
447 WriteLn(stdout,'UserPathPrefix: ' + UserPathPrefix); |
394 *) |
448 *) |