| 613 | } |
| 614 | |
| 615 | Dictionary::Entry* Dictionary::addVariable(const char *name, |
| 616 | S32 type, |
| 617 | void *dataPtr, |
| 618 | const char* usage) |
| 619 | { |
| 620 | AssertFatal(type >= 0, "Dictionary::addVariable - Got bad type!"); |
| 621 | |
| 622 | if (name[0] != '$') |
| 623 | { |
| 624 | scratchBuffer[0] = '$'; |
| 625 | dStrcpy(scratchBuffer + 1, name, 1023); |
| 626 | name = scratchBuffer; |
| 627 | } |
| 628 | |
| 629 | Entry *ent = add(StringTable->insert(name)); |
| 630 | |
| 631 | if (ent->type <= Entry::TypeInternalString && ent->sval != NULL) |
| 632 | dFree(ent->sval); |
| 633 | |
| 634 | ent->mUsage = usage; |
| 635 | ent->type = type; |
| 636 | ent->dataPtr = dataPtr; |
| 637 | |
| 638 | // Fetch enum table, if any. |
| 639 | ConsoleBaseType* conType = ConsoleBaseType::getType(type); |
| 640 | AssertFatal(conType, "Dictionary::addVariable - invalid console type"); |
| 641 | ent->enumTable = conType->getEnumTable(); |
| 642 | |
| 643 | return ent; |
| 644 | } |
| 645 | |
| 646 | bool Dictionary::removeVariable(StringTableEntry name) |
| 647 | { |