MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / setStringValue

Method setStringValue

Engine/source/console/consoleInternal.cpp:495–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493}
494
495void Dictionary::Entry::setStringValue(const char* value)
496{
497 if (mIsConstant)
498 {
499 Con::errorf("Cannot assign value to constant '%s'.", name);
500 return;
501 }
502
503 if (type <= TypeInternalString)
504 {
505 // Let's not remove empty-string-valued global vars from the dict.
506 // If we remove them, then they won't be exported, and sometimes
507 // it could be necessary to export such a global. There are very
508 // few empty-string global vars so there's no performance-related
509 // need to remove them from the dict.
510 /*
511 if(!value[0] && name[0] == '$')
512 {
513 gEvalState.globalVars.remove(this);
514 return;
515 }
516 */
517
518 U32 stringLen = dStrlen(value);
519
520 // If it's longer than 256 bytes, it's certainly not a number.
521 //
522 // (This decision may come back to haunt you. Shame on you if it
523 // does.)
524 if (stringLen < 256)
525 {
526 fval = dAtof(value);
527 ival = dAtoi(value);
528 }
529 else
530 {
531 fval = 0.f;
532 ival = 0;
533 }
534
535 type = TypeInternalString;
536
537 // may as well pad to the next cache line
538 U32 newLen = ((stringLen + 1) + 15) & ~15;
539
540 if (sval == NULL)
541 sval = (char*)dMalloc(newLen);
542 else if (newLen > bufferLen)
543 sval = (char*)dRealloc(sval, newLen);
544
545 bufferLen = newLen;
546 dStrcpy(sval, value, newLen);
547 }
548 else
549 Con::setData(type, dataPtr, 0, 1, &value, enumTable);
550
551 // Fire off the notification if we have one.
552 if (notify)

Callers 1

setVariableMethod · 0.45

Calls 7

dAtofFunction · 0.85
dAtoiFunction · 0.85
dStrcpyFunction · 0.85
setDataFunction · 0.85
errorfFunction · 0.70
dStrlenFunction · 0.50
triggerMethod · 0.45

Tested by

no test coverage detected