mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Update console.h
This commit is contained in:
parent
954c3b03db
commit
1ddc7219a5
1 changed files with 18 additions and 16 deletions
|
|
@ -137,13 +137,21 @@ struct ConsoleValueConsoleType
|
||||||
|
|
||||||
class ConsoleValue
|
class ConsoleValue
|
||||||
{
|
{
|
||||||
|
#pragma warning( push )
|
||||||
|
#pragma warning( disable : 4201 ) // warning C4201: nonstandard extension used : nameless struct/union
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
F64 f;
|
struct
|
||||||
S64 i;
|
{
|
||||||
char* s;
|
F64 f;
|
||||||
void* data;
|
S64 i;
|
||||||
ConsoleValueConsoleType* ct;
|
char* s;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ConsoleValueConsoleType* ct;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
S32 type;
|
S32 type;
|
||||||
|
|
@ -152,21 +160,11 @@ class ConsoleValue
|
||||||
|
|
||||||
char* convertToBuffer() const;
|
char* convertToBuffer() const;
|
||||||
|
|
||||||
TORQUE_FORCEINLINE bool hasAllocatedData() const
|
|
||||||
{
|
|
||||||
return (isConsoleType() && data != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* getConsoleData() const;
|
const char* getConsoleData() const;
|
||||||
|
|
||||||
TORQUE_FORCEINLINE void cleanupData()
|
TORQUE_FORCEINLINE void cleanupData()
|
||||||
{
|
{
|
||||||
if (hasAllocatedData())
|
if (type == ConsoleValueType::cvString)
|
||||||
{
|
|
||||||
dFree(data);
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
else if (type == ConsoleValueType::cvString)
|
|
||||||
{
|
{
|
||||||
if (s != StringTable->EmptyString())
|
if (s != StringTable->EmptyString())
|
||||||
dFree(s);
|
dFree(s);
|
||||||
|
|
@ -323,8 +321,12 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cleanupData();
|
cleanupData();
|
||||||
|
|
||||||
|
U32 oldLen = dStrlen(s);
|
||||||
|
|
||||||
type = ConsoleValueType::cvString;
|
type = ConsoleValueType::cvString;
|
||||||
s = (char*)dMalloc(len + 1);
|
s = (char*)dMalloc(len + 1);
|
||||||
|
|
||||||
s[len] = '\0';
|
s[len] = '\0';
|
||||||
dStrcpy(s, val, len + 1);
|
dStrcpy(s, val, len + 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue