330 procedure parseCommandLine; |
330 procedure parseCommandLine; |
331 var paramIndex: LongInt; |
331 var paramIndex: LongInt; |
332 paramTotal: LongInt; |
332 paramTotal: LongInt; |
333 index, nextIndex: LongInt; |
333 index, nextIndex: LongInt; |
334 wrongParameter: boolean; |
334 wrongParameter: boolean; |
335 //var tmpInt: LongInt; |
335 var tmpInt: LongInt; |
336 begin |
336 begin |
337 |
337 |
338 paramIndex:= 1; |
338 paramIndex:= 1; |
339 paramTotal:= ParamCount; //-1 because pascal enumeration is inclusive |
339 paramTotal:= ParamCount; //-1 because pascal enumeration is inclusive |
340 (* |
340 |
341 WriteLn(stdout, 'total parameters: ' + inttostr(paramTotal)); |
341 WriteLn(stdout, 'total parameters: ' + inttostr(paramTotal)); |
342 tmpInt:= 0; |
342 tmpInt:= 0; |
343 while (tmpInt <= paramTotal) do |
343 while (tmpInt <= paramTotal) do |
344 begin |
344 begin |
345 WriteLn(stdout, inttostr(tmpInt) + ': ' + {$IFDEF HWLIBRARY}argv[tmpInt]{$ELSE}paramCount(tmpInt){$ENDIF}); |
345 WriteLn(stdout, inttostr(tmpInt) + ': ' + {$IFDEF HWLIBRARY}argv[tmpInt]{$ELSE}paramCount(tmpInt){$ENDIF}); |
346 inc(tmpInt); |
346 inc(tmpInt); |
347 end; |
347 end; |
348 *) |
348 |
349 wrongParameter:= false; |
349 wrongParameter:= false; |
350 while (paramIndex <= paramTotal) do |
350 while (paramIndex <= paramTotal) do |
351 begin |
351 begin |
352 // avoid going past the number of paramTotal (esp. w/ library) |
352 // avoid going past the number of paramTotal (esp. w/ library) |
353 index:= paramIndex; |
353 index:= paramIndex; |
360 GameType:= gmtSyntax; |
360 GameType:= gmtSyntax; |
361 end; |
361 end; |
362 |
362 |
363 procedure GetParams; |
363 procedure GetParams; |
364 begin |
364 begin |
365 isInternal:= (ParamStr(1) = '--internal'); |
365 if ParamCount > 0 then |
366 |
366 begin |
367 UserPathPrefix := _S'.'; |
367 isInternal:= (ParamStr(1) = '--internal'); |
368 PathPrefix := cDefaultPathPrefix; |
368 |
369 recordFileName := ''; |
369 UserPathPrefix := _S'.'; |
370 parseCommandLine(); |
370 PathPrefix := cDefaultPathPrefix; |
371 |
371 recordFileName := ''; |
372 if (isInternal) and (ParamCount<=1) then |
372 parseCommandLine(); |
373 begin |
373 |
374 WriteLn(stderr, '--internal should not be manually used'); |
374 if (isInternal) and (ParamCount<=1) then |
375 GameType := gmtSyntax; |
375 begin |
376 end; |
376 WriteLn(stderr, '--internal should not be manually used'); |
377 |
377 GameType := gmtSyntax; |
378 if (not cTestLua) and (not isInternal) and (recordFileName = '') then |
378 end; |
379 begin |
379 |
380 WriteLn(stderr, 'You must specify a replay file'); |
380 if (not cTestLua) and (not isInternal) and (recordFileName = '') then |
381 GameType := gmtSyntax; |
381 begin |
382 end |
382 WriteLn(stderr, 'You must specify a replay file'); |
383 else if (recordFileName <> '') then |
383 GameType := gmtSyntax; |
384 WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"'); |
384 end |
|
385 else if (recordFileName <> '') then |
|
386 WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"'); |
|
387 end |
|
388 else |
|
389 GameType:= gmtSyntax; |
385 |
390 |
386 if (GameType = gmtSyntax) then |
391 if (GameType = gmtSyntax) then |
387 WriteLn(stderr, 'Please use --help to see possible arguments and their usage'); |
392 WriteLn(stderr, 'Please use --help to see possible arguments and their usage'); |
388 |
393 |
389 (* |
394 (* |