| 2594 | } |
| 2595 | |
| 2596 | const char *ConsoleValue::getStringValue() |
| 2597 | { |
| 2598 | if(type == TypeInternalString || type == TypeInternalStackString) |
| 2599 | return sval; |
| 2600 | else if (type == TypeInternalStringStackPtr) |
| 2601 | return STR.mBuffer + (uintptr_t)sval; |
| 2602 | else |
| 2603 | { |
| 2604 | // We need a string representation, so lets create one |
| 2605 | const char *internalValue = NULL; |
| 2606 | |
| 2607 | if(type == TypeInternalFloat) |
| 2608 | internalValue = Con::getData(TypeF32, &fval, 0); |
| 2609 | else if(type == TypeInternalInt) |
| 2610 | internalValue = Con::getData(TypeS32, &ival, 0); |
| 2611 | else |
| 2612 | return Con::getData(type, dataPtr, 0, enumTable); // We can't save sval here since it is the same as dataPtr |
| 2613 | |
| 2614 | if (!internalValue) |
| 2615 | return ""; |
| 2616 | |
| 2617 | U32 stringLen = dStrlen(internalValue); |
| 2618 | U32 newLen = ((stringLen + 1) + 15) & ~15; // pad upto next cache line |
| 2619 | |
| 2620 | if (bufferLen == 0) |
| 2621 | sval = (char *) dMalloc(newLen); |
| 2622 | else if(newLen > bufferLen) |
| 2623 | sval = (char *) dRealloc(sval, newLen); |
| 2624 | |
| 2625 | dStrcpy(sval, internalValue); |
| 2626 | bufferLen = newLen; |
| 2627 | |
| 2628 | return sval; |
| 2629 | } |
| 2630 | } |
| 2631 | |
| 2632 | StringStackPtr ConsoleValue::getStringStackPtr() |
| 2633 | { |