Changeset 5558 in orxonox.OLD for branches/world_entities/src/lib/shell/shell_command.cc
- Timestamp:
- Nov 13, 2005, 3:10:49 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/world_entities/src/lib/shell/shell_command.cc
r5374 r5558 259 259 tList<ShellCommandAlias>* ShellCommandClass::aliasList = NULL; 260 260 261 262 263 264 265 266 267 268 269 270 //////////////////////// 271 // SHELL COMMAND BASE // 272 //////////////////////// 261 273 /** 262 274 * constructs and registers a new Command … … 264 276 * @param className the name of the class to apply this command to 265 277 * @param paramCount the count of parameters this command takes 266 * @return self267 278 */ 268 279 ShellCommandBase::ShellCommandBase(const char* commandName, const char* className, unsigned int paramCount, ...) … … 282 293 this->paramCount = paramCount; 283 294 this->parameters = new unsigned int[paramCount]; 295 this->defaultValue = new MultiType[paramCount]; 284 296 285 297 va_list parameterList; 286 298 va_start(parameterList, paramCount); 287 299 300 // What Parameters we have got 288 301 for (unsigned int i = 0; i < paramCount; i++) 289 {290 302 this->parameters[i] = va_arg(parameterList, int); 291 292 switch (this->parameters[i])293 {294 case ParameterBool:295 this->defaultBools[i] = va_arg(parameterList, int);296 break;297 case ParameterChar:298 this->defaultStrings[i] = new char[2];299 sprintf(this->defaultStrings[0], "%c", va_arg(parameterList, int));300 break;301 case ParameterString:302 this->defaultStrings[i] = va_arg(parameterList, char*);303 break;304 case ParameterInt:305 this->defaultInts[i] = va_arg(parameterList, int);306 break;307 case ParameterUInt:308 this->defaultInts[i] = va_arg(parameterList, unsigned int);309 break;310 case ParameterFloat:311 this->defaultFloats[i] = va_arg(parameterList, double);312 break;313 case ParameterLong:314 this->defaultInts[i] = va_arg(parameterList, long);315 break;316 default:317 break;318 }319 }320 303 } 321 304 322 305 /** 323 306 * deconstructs a ShellCommand 324 * @return325 307 */ 326 308 ShellCommandBase::~ShellCommandBase() 327 309 { 328 310 delete[] this->parameters; 311 delete[] this->defaultValue; 329 312 if (this->alias != NULL && ShellCommandClass::aliasList != NULL) 330 313 { … … 417 400 * @return true on success, false otherwise. 418 401 */ 419 #include "stdlibincl.h"420 402 bool ShellCommandBase::execute(const char* executionString) 421 403 { … … 598 580 for (unsigned int i = 0; i < count; i++) 599 581 { 582 583 600 584 switch (this->parameters[i]) 601 585 { 602 586 case ParameterBool: 603 this->default Bools[i] = va_arg(defaultList, int);587 this->defaultValue[i].setInt(va_arg(defaultList, int)); 604 588 break; 605 589 case ParameterChar: 606 this->defaultStrings[i] = new char[2]; 607 sprintf(this->defaultStrings[0], "%c", va_arg(defaultList, int)); 590 this->defaultValue[i].setChar((char)va_arg(defaultList, int)); 608 591 break; 609 592 case ParameterString: 610 this->default Strings[i] = va_arg(defaultList, char*);593 this->defaultValue[i].setString(va_arg(defaultList, char*)); 611 594 break; 612 595 case ParameterInt: 613 this->default Ints[i] = va_arg(defaultList, int);596 this->defaultValue[i].setInt(va_arg(defaultList, int)); 614 597 break; 615 598 case ParameterUInt: 616 this->default Ints[i] = va_arg(defaultList, unsigned int);599 this->defaultValue[i].setInt((int)va_arg(defaultList, unsigned int)); 617 600 break; 618 601 case ParameterFloat: 619 this->default Floats[i] = va_arg(defaultList, double);602 this->defaultValue[i].setFloat(va_arg(defaultList, double)); 620 603 break; 621 604 case ParameterLong: 622 this->default Ints[i] = va_arg(defaultList, long);605 this->defaultValue[i].setInt((int) va_arg(defaultList, long)); 623 606 break; 624 607 default: … … 626 609 } 627 610 } 628 629 611 return this; 630 612 }
Note: See TracChangeset
for help on using the changeset viewer.