mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Add workaround for issue #1292
This commit is contained in:
parent
7a54e300e3
commit
d9436e65c5
3 changed files with 67 additions and 29 deletions
|
|
@ -1736,12 +1736,34 @@ const char *ConsoleValue::getStringValue()
|
|||
return sval;
|
||||
else if (type == TypeInternalStringStackPtr)
|
||||
return STR.mBuffer + (uintptr_t)sval;
|
||||
if(type == TypeInternalFloat)
|
||||
return Con::getData(TypeF32, &fval, 0);
|
||||
else if(type == TypeInternalInt)
|
||||
return Con::getData(TypeS32, &ival, 0);
|
||||
else
|
||||
return Con::getData(type, dataPtr, 0, enumTable);
|
||||
{
|
||||
// We need a string representation, so lets create one
|
||||
const char *internalValue = NULL;
|
||||
|
||||
if(type == TypeInternalFloat)
|
||||
internalValue = Con::getData(TypeF32, &fval, 0);
|
||||
else if(type == TypeInternalInt)
|
||||
internalValue = Con::getData(TypeS32, &ival, 0);
|
||||
else
|
||||
return Con::getData(type, dataPtr, 0, enumTable); // We can't save sval here since it is the same as dataPtr
|
||||
|
||||
if (!internalValue)
|
||||
return "";
|
||||
|
||||
U32 stringLen = dStrlen(internalValue);
|
||||
U32 newLen = ((stringLen + 1) + 15) & ~15; // pad upto next cache line
|
||||
|
||||
if (bufferLen == 0)
|
||||
sval = (char *) dMalloc(newLen);
|
||||
else if(newLen > bufferLen)
|
||||
sval = (char *) dRealloc(sval, newLen);
|
||||
|
||||
dStrcpy(sval, internalValue);
|
||||
bufferLen = newLen;
|
||||
|
||||
return sval;
|
||||
}
|
||||
}
|
||||
|
||||
StringStackPtr ConsoleValue::getStringStackPtr()
|
||||
|
|
@ -1777,11 +1799,13 @@ void ConsoleValue::setIntValue(U32 val)
|
|||
{
|
||||
fval = (F32)val;
|
||||
ival = val;
|
||||
if(sval != typeValueEmpty)
|
||||
if(bufferLen > 0)
|
||||
{
|
||||
if (type != TypeInternalStackString && type != TypeInternalStringStackPtr) dFree(sval);
|
||||
sval = typeValueEmpty;
|
||||
dFree(sval);
|
||||
bufferLen = 0;
|
||||
}
|
||||
|
||||
sval = typeValueEmpty;
|
||||
type = TypeInternalInt;
|
||||
}
|
||||
else
|
||||
|
|
@ -1802,11 +1826,12 @@ void ConsoleValue::setFloatValue(F32 val)
|
|||
{
|
||||
fval = val;
|
||||
ival = static_cast<U32>(val);
|
||||
if(sval != typeValueEmpty)
|
||||
if(bufferLen > 0)
|
||||
{
|
||||
if (type != TypeInternalStackString && type != TypeInternalStringStackPtr) dFree(sval);
|
||||
sval = typeValueEmpty;
|
||||
dFree(sval);
|
||||
bufferLen = 0;
|
||||
}
|
||||
sval = typeValueEmpty;
|
||||
type = TypeInternalFloat;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue