41 WriteLn(stdout, 'where [options] can be any of the following:'); |
41 WriteLn(stdout, 'where [options] can be any of the following:'); |
42 WriteLn(stdout, ' --prefix [path to folder]'); |
42 WriteLn(stdout, ' --prefix [path to folder]'); |
43 WriteLn(stdout, ' --user-prefix [path to folder]'); |
43 WriteLn(stdout, ' --user-prefix [path to folder]'); |
44 WriteLn(stdout, ' --locale [name of language file]'); |
44 WriteLn(stdout, ' --locale [name of language file]'); |
45 WriteLn(stdout, ' --nick [string]'); |
45 WriteLn(stdout, ' --nick [string]'); |
46 WriteLn(stdout, ' --width [screen width in pixels]'); |
46 WriteLn(stdout, ' --fullscreen-width [fullscreen width in pixels]'); |
47 WriteLn(stdout, ' --height [screen height 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]'); |
48 WriteLn(stdout, ' --volume [sound level]'); |
50 WriteLn(stdout, ' --volume [sound level]'); |
49 WriteLn(stdout, ' --frame-interval [milliseconds]'); |
51 WriteLn(stdout, ' --frame-interval [milliseconds]'); |
50 Writeln(stdout, ' --stereo [value]'); |
52 Writeln(stdout, ' --stereo [value]'); |
51 WriteLn(stdout, ' --raw-quality [flags]'); |
53 WriteLn(stdout, ' --raw-quality [flags]'); |
52 WriteLn(stdout, ' --low-quality'); |
54 WriteLn(stdout, ' --low-quality'); |
101 |
103 |
102 procedure setStereoMode(tmp: LongInt); |
104 procedure setStereoMode(tmp: LongInt); |
103 begin |
105 begin |
104 GrayScale:= false; |
106 GrayScale:= false; |
105 {$IFDEF USE_S3D_RENDERING} |
107 {$IFDEF USE_S3D_RENDERING} |
106 if (tmp > 9) and (tmp < 16) then |
108 if (tmp > 6) and (tmp < 13) then |
107 begin |
109 begin |
108 // set the gray anaglyph rendering |
110 // set the gray anaglyph rendering |
109 GrayScale:= true; |
111 GrayScale:= true; |
110 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-9))) |
112 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))) |
111 end |
113 end |
112 else if tmp <= 9 then |
114 else if tmp <= 6 then |
113 // set the fullcolor anaglyph |
115 // set the fullcolor anaglyph |
114 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) |
116 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) |
115 else |
117 else |
116 // any other mode |
118 // any other mode |
117 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); |
119 cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); |
118 {$ELSE} |
120 {$ELSE} |
|
121 tmp:= tmp; |
119 cStereoMode:= smNone; |
122 cStereoMode:= smNone; |
120 {$ENDIF} |
123 {$ENDIF} |
121 end; |
124 end; |
122 |
125 |
123 procedure startVideoRecording(var paramIndex: LongInt); |
126 procedure startVideoRecording(var paramIndex: LongInt); |
124 begin |
127 begin |
|
128 // Silence the hint that appears when USE_VIDEO_RECORDING is not defined |
|
129 paramIndex:= paramIndex; |
125 {$IFDEF USE_VIDEO_RECORDING} |
130 {$IFDEF USE_VIDEO_RECORDING} |
126 GameType:= gmtRecord; |
131 GameType:= gmtRecord; |
127 inc(paramIndex); |
132 inc(paramIndex); |
128 cVideoFramerateNum:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
133 cVideoFramerateNum:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
129 cVideoFramerateDen:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
134 cVideoFramerateDen:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
156 end; |
161 end; |
157 |
162 |
158 procedure parseClassicParameter(cmdArray: array of String; size:LongInt; var paramIndex:LongInt); forward; |
163 procedure parseClassicParameter(cmdArray: array of String; size:LongInt; var paramIndex:LongInt); forward; |
159 |
164 |
160 function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean; |
165 function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean; |
161 const videoArray: array [1..3] of String = ('--width','--height','--depth'); |
166 const videoArray: Array [1..5] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
162 audioArray: array [1..3] of String = ('--volume','--nomusic','--nosound'); |
167 audioArray: Array [1..3] of String = ('--volume','--nomusic','--nosound'); |
163 otherArray: array [1..3] of String = ('--locale','--fullscreen','--showfps'); |
168 otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps'); |
164 mediaArray: array [1..8] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen'); |
169 mediaArray: Array [1..10] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
165 allArray: array [1..12] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality'); |
170 allArray: Array [1..14] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality'); |
166 reallyAll: array[0..28] of shortstring = ( |
171 reallyAll: array[0..30] of shortstring = ( |
167 '--prefix', '--user-prefix', '--locale', '--width', '--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
172 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
168 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
173 '--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
|
174 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
169 {deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
175 {deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
170 {internal} '--internal', '--port', '--recorder', '--landpreview', |
176 {internal} '--internal', '--port', '--recorder', '--landpreview', |
171 {misc} '--stats-only', '--gci', '--help'); |
177 {misc} '--stats-only', '--gci', '--help'); |
172 var cmdIndex: byte; |
178 var cmdIndex: byte; |
173 begin |
179 begin |
177 //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above, |
183 //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above, |
178 // the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki |
184 // the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki |
179 |
185 |
180 while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
186 while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
181 case cmdIndex of |
187 case cmdIndex of |
182 {--prefix} 0 : PathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
188 {--prefix} 0 : PathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
183 {--user-prefix} 1 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
189 {--user-prefix} 1 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
184 {--locale} 2 : cLocaleFName := getStringParameter (arg, paramIndex, parseParameter); |
190 {--locale} 2 : cLocaleFName := getStringParameter (arg, paramIndex, parseParameter); |
185 {--width} 3 : cScreenWidth := getLongIntParameter(arg, paramIndex, parseParameter); |
191 {--fullscreen-width} 3 : cFullscreenWidth := getLongIntParameter(arg, paramIndex, parseParameter); |
186 {--height} 4 : cScreenHeight := getLongIntParameter(arg, paramIndex, parseParameter); |
192 {--fullscreen-height} 4 : cFullscreenHeight := getLongIntParameter(arg, paramIndex, parseParameter); |
187 {--frame-interval} 5 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
193 {--width} 5 : cWindowedWidth := getLongIntParameter(arg, paramIndex, parseParameter); |
188 {--volume} 6 : SetVolume ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
194 {--height} 6 : cWindowedHeight := getLongIntParameter(arg, paramIndex, parseParameter); |
189 {--nomusic} 7 : SetMusic ( false ); |
195 {--frame-interval} 7 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
190 {--nosound} 8 : SetSound ( false ); |
196 {--volume} 8 : SetVolume ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
191 {--fullscreen} 9 : cFullScreen := true; |
197 {--nomusic} 9 : SetMusic ( false ); |
192 {--showfps} 10 : cShowFPS := true; |
198 {--nosound} 10 : SetSound ( false ); |
193 {--altdmg} 11 : cAltDamage := true; |
199 {--fullscreen} 11 : cFullScreen := true; |
194 {--low-quality} 12 : cReducedQuality:= $FFFFFFFF xor rqLowRes; |
200 {--showfps} 12 : cShowFPS := true; |
195 {--raw-quality} 13 : cReducedQuality:= getLongIntParameter(arg, paramIndex, parseParameter); |
201 {--altdmg} 13 : cAltDamage := true; |
196 {--stereo} 14 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
202 {--low-quality} 14 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
197 {--nick} 15 : UserNick := parseNick( getStringParameter(arg, paramIndex, parseParameter) ); |
203 {--raw-quality} 15 : cReducedQuality := getLongIntParameter(arg, paramIndex, parseParameter); |
|
204 {--stereo} 16 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
|
205 {--nick} 17 : UserNick := parseNick( getStringParameter(arg, paramIndex, parseParameter) ); |
198 {deprecated options} |
206 {deprecated options} |
199 {--depth} 16 : setDepth(paramIndex); |
207 {--depth} 18 : setDepth(paramIndex); |
200 {--set-video} 17 : parseClassicParameter(videoArray,3,paramIndex); |
208 {--set-video} 19 : parseClassicParameter(videoArray,5,paramIndex); |
201 {--set-audio} 18 : parseClassicParameter(audioArray,3,paramIndex); |
209 {--set-audio} 20 : parseClassicParameter(audioArray,3,paramIndex); |
202 {--set-other} 19 : parseClassicParameter(otherArray,3,paramIndex); |
210 {--set-other} 21 : parseClassicParameter(otherArray,3,paramIndex); |
203 {--set-multimedia} 20 : parseClassicParameter(mediaArray,8,paramIndex); |
211 {--set-multimedia} 22 : parseClassicParameter(mediaArray,10,paramIndex); |
204 {--set-everything} 21 : parseClassicParameter(allArray,12,paramIndex); |
212 {--set-everything} 23 : parseClassicParameter(allArray,14,paramIndex); |
205 {"internal" options} |
213 {"internal" options} |
206 {--internal} 22 : {note it, but do nothing}; |
214 {--internal} 24 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF}; |
207 {--port} 23 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter ); |
215 {--port} 25 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter ); |
208 {--recorder} 24 : startVideoRecording(paramIndex); |
216 {--recorder} 26 : startVideoRecording(paramIndex); |
209 {--landpreview} 25 : GameType := gmtLandPreview; |
217 {--landpreview} 27 : GameType := gmtLandPreview; |
210 {anything else} |
218 {anything else} |
211 {--stats-only} 26 : statsOnlyGame(); |
219 {--stats-only} 28 : statsOnlyGame(); |
212 {--gci} 27 : GciEasterEgg(); |
220 {--gci} 29 : GciEasterEgg(); |
213 {--help} 28 : DisplayUsage(); |
221 {--help} 30 : DisplayUsage(); |
214 else |
222 else |
215 begin |
223 begin |
216 //Asusme the first "non parameter" is the replay file, anything else is invalid |
224 //Asusme the first "non parameter" is the replay file, anything else is invalid |
217 if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
225 if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
218 recordFileName := cmd |
226 recordFileName := cmd |
267 end; |
276 end; |
268 |
277 |
269 procedure parseCommandLine{$IFDEF HWLIBRARY}(argc: LongInt; argv: PPChar){$ENDIF}; |
278 procedure parseCommandLine{$IFDEF HWLIBRARY}(argc: LongInt; argv: PPChar){$ENDIF}; |
270 var paramIndex: LongInt; |
279 var paramIndex: LongInt; |
271 paramTotal: LongInt; |
280 paramTotal: LongInt; |
|
281 index, nextIndex: LongInt; |
272 wrongParameter: boolean; |
282 wrongParameter: boolean; |
273 begin |
283 //var tmpInt: LongInt; |
274 paramIndex:= 1; |
284 begin |
275 paramTotal:={$IFDEF HWLIBRARY}argc{$ELSE}ParamCount{$ENDIF}; |
285 paramIndex:= {$IFDEF HWLIBRARY}0{$ELSE}1{$ENDIF}; |
|
286 paramTotal:= {$IFDEF HWLIBRARY}argc-1{$ELSE}ParamCount{$ENDIF}; //-1 because pascal enumeration is inclusive |
|
287 (* |
|
288 WriteLn(stdout, 'total parameters: ' + inttostr(paramTotal)); |
|
289 tmpInt:= 0; |
|
290 while (tmpInt <= paramTotal) do |
|
291 begin |
|
292 WriteLn(stdout, inttostr(tmpInt) + ': ' + {$IFDEF HWLIBRARY}argv[tmpInt]{$ELSE}paramCount(tmpInt){$ENDIF}); |
|
293 inc(tmpInt); |
|
294 end; |
|
295 *) |
276 wrongParameter:= false; |
296 wrongParameter:= false; |
277 while (paramIndex <= paramTotal) do |
297 while (paramIndex <= paramTotal) do |
278 begin |
298 begin |
|
299 // avoid going past the number of paramTotal (esp. w/ library) |
|
300 index:= paramIndex; |
|
301 if index = paramTotal then nextIndex:= index |
|
302 else nextIndex:= index+1; |
279 {$IFDEF HWLIBRARY} |
303 {$IFDEF HWLIBRARY} |
280 wrongParameter:= parseParameter( argv[paramIndex], argv[paramIndex+1], paramIndex); |
304 wrongParameter:= parseParameter( argv[index], argv[nextIndex], paramIndex); |
281 {$ELSE} |
305 {$ELSE} |
282 wrongParameter:= parseParameter( ParamStr(paramIndex), ParamStr(paramIndex+1), paramIndex); |
306 wrongParameter:= parseParameter( ParamStr(index), ParamStr(nextIndex), paramIndex); |
283 {$ENDIF} |
307 {$ENDIF} |
284 inc(paramIndex); |
308 inc(paramIndex); |
285 end; |
309 end; |
286 if wrongParameter = true then |
310 if wrongParameter = true then |
287 GameType:= gmtSyntax; |
311 GameType:= gmtSyntax; |
288 end; |
312 end; |
289 |
313 |
290 {$IFNDEF HWLIBRARY} |
314 {$IFNDEF HWLIBRARY} |
291 procedure GetParams; |
315 procedure GetParams; |
292 //var tmpInt: LongInt; |
316 begin |
293 begin |
|
294 (* |
|
295 tmpInt:=0; |
|
296 while (tmpInt <= ParamCount) do |
|
297 begin |
|
298 WriteLn(stdout, inttostr(tmpInt) + ': ' + ParamStr(tmpInt)); |
|
299 inc(tmpInt); |
|
300 end; |
|
301 *) |
|
302 |
|
303 isInternal:= (ParamStr(1) = '--internal'); |
317 isInternal:= (ParamStr(1) = '--internal'); |
304 |
318 |
305 UserPathPrefix := '.'; |
319 UserPathPrefix := '.'; |
306 PathPrefix := cDefaultPathPrefix; |
320 PathPrefix := cDefaultPathPrefix; |
307 recordFileName := ''; |
321 recordFileName := ''; |