156 cVideoQuality:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
156 cVideoQuality:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); |
157 cAudioCodec:= ParamStr(paramIndex); inc(paramIndex); |
157 cAudioCodec:= ParamStr(paramIndex); inc(paramIndex); |
158 {$ENDIF} |
158 {$ENDIF} |
159 end; |
159 end; |
160 |
160 |
161 function getLongIntParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt; |
161 function getLongIntParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt; |
162 var tmpInt, c: LongInt; |
162 var tmpInt, c: LongInt; |
163 begin |
163 begin |
164 inc(paramIndex); |
164 inc(paramIndex); |
|
165 {$IFDEF PAS2C} |
|
166 val(str, tmpInt); |
|
167 {$ELSE} |
165 val(str, tmpInt, c); |
168 val(str, tmpInt, c); |
166 wrongParameter:= c <> 0; |
169 wrongParameter:= c <> 0; |
167 if wrongParameter then |
170 if wrongParameter then |
168 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"'); |
171 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"'); |
|
172 {$ENDIF} |
169 getLongIntParameter:= tmpInt; |
173 getLongIntParameter:= tmpInt; |
170 end; |
174 end; |
171 |
175 |
172 function getStringParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): String; |
176 function getstringParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): shortstring; |
173 begin |
177 begin |
174 inc(paramIndex); |
178 inc(paramIndex); |
175 wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
179 wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
176 if wrongParameter then |
180 if wrongParameter then |
177 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); |
181 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); |
178 getStringParameter:= str; |
182 getstringParameter:= str; |
179 end; |
183 end; |
180 |
184 |
181 |
185 procedure parseClassicParameter(cmdArray: array of string; size:LongInt; var paramIndex:LongInt); forward; |
182 procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); Forward; |
186 |
183 |
187 function parseParameter(cmd:string; arg:string; var paramIndex:LongInt): Boolean; |
184 function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean; |
188 const videoArray: Array [1..5] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
185 const videoArray: Array [1..5] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
189 audioArray: Array [1..3] of string = ('--volume','--nomusic','--nosound'); |
186 audioArray: Array [1..3] of String = ('--volume','--nomusic','--nosound'); |
190 otherArray: Array [1..3] of string = ('--locale','--fullscreen','--showfps'); |
187 otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps'); |
191 mediaArray: Array [1..10] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
188 mediaArray: Array [1..10] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
192 allArray: Array [1..18] 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'); |
189 allArray: Array [1..18] 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'); |
|
190 reallyAll: array[0..35] of shortstring = ( |
193 reallyAll: array[0..35] of shortstring = ( |
191 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
194 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
192 '--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
195 '--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
193 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
196 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
194 {deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
197 {deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
202 //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above, |
205 //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above, |
203 // the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki |
206 // the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki |
204 |
207 |
205 while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
208 while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
206 case cmdIndex of |
209 case cmdIndex of |
207 {--prefix} 0 : PathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
210 {--prefix} 0 : PathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
208 {--user-prefix} 1 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
211 {--user-prefix} 1 : UserPathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
209 {--locale} 2 : cLocaleFName := getStringParameter (arg, paramIndex, parseParameter); |
212 {--locale} 2 : cLocaleFName := getstringParameter (arg, paramIndex, parseParameter); |
210 {--fullscreen-width} 3 : cFullscreenWidth := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenWidth); |
213 {--fullscreen-width} 3 : cFullscreenWidth := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenWidth); |
211 {--fullscreen-height} 4 : cFullscreenHeight := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenHeight); |
214 {--fullscreen-height} 4 : cFullscreenHeight := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenHeight); |
212 {--width} 5 : cWindowedWidth := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenWidth); |
215 {--width} 5 : cWindowedWidth := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenWidth); |
213 {--height} 6 : cWindowedHeight := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenHeight); |
216 {--height} 6 : cWindowedHeight := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenHeight); |
214 {--frame-interval} 7 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
217 {--frame-interval} 7 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
219 {--showfps} 12 : cShowFPS := true; |
222 {--showfps} 12 : cShowFPS := true; |
220 {--altdmg} 13 : cAltDamage := true; |
223 {--altdmg} 13 : cAltDamage := true; |
221 {--low-quality} 14 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
224 {--low-quality} 14 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
222 {--raw-quality} 15 : cReducedQuality := getLongIntParameter(arg, paramIndex, parseParameter); |
225 {--raw-quality} 15 : cReducedQuality := getLongIntParameter(arg, paramIndex, parseParameter); |
223 {--stereo} 16 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
226 {--stereo} 16 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
224 {--nick} 17 : UserNick := parseNick( getStringParameter(arg, paramIndex, parseParameter) ); |
227 {--nick} 17 : UserNick := parseNick( getstringParameter(arg, paramIndex, parseParameter) ); |
225 {deprecated options} |
228 {deprecated options} |
226 {--depth} 18 : setDepth(paramIndex); |
229 {--depth} 18 : setDepth(paramIndex); |
227 {--set-video} 19 : parseClassicParameter(videoArray,5,paramIndex); |
230 {--set-video} 19 : parseClassicParameter(videoArray,5,paramIndex); |
228 {--set-audio} 20 : parseClassicParameter(audioArray,3,paramIndex); |
231 {--set-audio} 20 : parseClassicParameter(audioArray,3,paramIndex); |
229 {--set-other} 21 : parseClassicParameter(otherArray,3,paramIndex); |
232 {--set-other} 21 : parseClassicParameter(otherArray,3,paramIndex); |
240 {--help} 30 : DisplayUsage(); |
243 {--help} 30 : DisplayUsage(); |
241 {--no-teamtag} 31 : cTagsMask := cTagsMask and not htTeamName; |
244 {--no-teamtag} 31 : cTagsMask := cTagsMask and not htTeamName; |
242 {--no-hogtag} 32 : cTagsMask := cTagsMask and not htName; |
245 {--no-hogtag} 32 : cTagsMask := cTagsMask and not htName; |
243 {--no-healthtag} 33 : cTagsMask := cTagsMask and not htHealth; |
246 {--no-healthtag} 33 : cTagsMask := cTagsMask and not htHealth; |
244 {--translucent-tags} 34 : cTagsMask := cTagsMask or htTransparent; |
247 {--translucent-tags} 34 : cTagsMask := cTagsMask or htTransparent; |
245 {--lua-test} 35 : begin cTestLua := true; cScriptName := getStringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end; |
248 {--lua-test} 35 : begin cTestLua := true; cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end; |
246 else |
249 else |
247 begin |
250 begin |
248 //Assume the first "non parameter" is the replay file, anything else is invalid |
251 //Assume the first "non parameter" is the replay file, anything else is invalid |
249 if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
252 if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then |
250 recordFileName := cmd |
253 recordFileName := cmd |