| 677 | } |
| 678 | |
| 679 | Dictionary::Entry* Dictionary::addVariable( const char *name, |
| 680 | S32 type, |
| 681 | void *dataPtr, |
| 682 | const char* usage ) |
| 683 | { |
| 684 | AssertFatal( type >= 0, "Dictionary::addVariable - Got bad type!" ); |
| 685 | |
| 686 | if(name[0] != '$') |
| 687 | { |
| 688 | scratchBuffer[0] = '$'; |
| 689 | dStrcpy(scratchBuffer + 1, name); |
| 690 | name = scratchBuffer; |
| 691 | } |
| 692 | |
| 693 | Entry *ent = add(StringTable->insert(name)); |
| 694 | |
| 695 | if ( ent->value.type <= ConsoleValue::TypeInternalString && |
| 696 | ent->value.bufferLen > 0 ) |
| 697 | dFree(ent->value.sval); |
| 698 | |
| 699 | ent->value.type = type; |
| 700 | ent->value.dataPtr = dataPtr; |
| 701 | ent->mUsage = usage; |
| 702 | |
| 703 | // Fetch enum table, if any. |
| 704 | |
| 705 | ConsoleBaseType* conType = ConsoleBaseType::getType( type ); |
| 706 | AssertFatal( conType, "Dictionary::addVariable - invalid console type" ); |
| 707 | ent->value.enumTable = conType->getEnumTable(); |
| 708 | |
| 709 | return ent; |
| 710 | } |
| 711 | |
| 712 | bool Dictionary::removeVariable(StringTableEntry name) |
| 713 | { |