mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-11 16:30:48 +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
|
||||
{
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4201 ) // warning C4201: nonstandard extension used : nameless struct/union
|
||||
union
|
||||
{
|
||||
F64 f;
|
||||
S64 i;
|
||||
char* s;
|
||||
void* data;
|
||||
ConsoleValueConsoleType* ct;
|
||||
struct
|
||||
{
|
||||
F64 f;
|
||||
S64 i;
|
||||
char* s;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
ConsoleValueConsoleType* ct;
|
||||
};
|
||||
};
|
||||
|
||||
S32 type;
|
||||
|
|
@ -152,21 +160,11 @@ class ConsoleValue
|
|||
|
||||
char* convertToBuffer() const;
|
||||
|
||||
TORQUE_FORCEINLINE bool hasAllocatedData() const
|
||||
{
|
||||
return (isConsoleType() && data != NULL);
|
||||
}
|
||||
|
||||
const char* getConsoleData() const;
|
||||
|
||||
TORQUE_FORCEINLINE void cleanupData()
|
||||
{
|
||||
if (hasAllocatedData())
|
||||
{
|
||||
dFree(data);
|
||||
data = NULL;
|
||||
}
|
||||
else if (type == ConsoleValueType::cvString)
|
||||
if (type == ConsoleValueType::cvString)
|
||||
{
|
||||
if (s != StringTable->EmptyString())
|
||||
dFree(s);
|
||||
|
|
@ -323,8 +321,12 @@ public:
|
|||
return;
|
||||
}
|
||||
cleanupData();
|
||||
|
||||
U32 oldLen = dStrlen(s);
|
||||
|
||||
type = ConsoleValueType::cvString;
|
||||
s = (char*)dMalloc(len + 1);
|
||||
|
||||
s[len] = '\0';
|
||||
dStrcpy(s, val, len + 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue