Fixes after feedback from Luis.

* Made use of dStrIsEmpty in more locations (and fixed it :P)
 * Removed commented-out code
 * Corrected default params
 * Fixed some console warning formats
 * Removed tabs
 * Corrected setExtent API
This commit is contained in:
Daniel Buckmaster 2014-12-23 18:20:47 +11:00
parent 04ff04a95f
commit 3ab048c5b0
30 changed files with 130 additions and 110 deletions

View file

@ -1207,8 +1207,11 @@ DefineConsoleFunction( nextToken, const char*, ( const char* str1, const char* t
"@endtsexample\n\n"
"@ingroup Strings" )
{
char *str = (char *)str1;
if( str )
char buffer[4096];
dStrncpy(buffer, str1, 4096);
char *str = buffer;
if( str[0] )
{
// skip over any characters that are a member of delim
// no need for special '\0' check since it can never be in delim
@ -1237,7 +1240,10 @@ DefineConsoleFunction( nextToken, const char*, ( const char* str1, const char* t
str++;
}
return str;
U32 returnLen = dStrlen(str)+1;
char *ret = Con::getReturnBuffer(returnLen);
dStrncpy(ret, str, returnLen);
return ret;
}
//=============================================================================
@ -2263,7 +2269,7 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
"@endtsexample\n\n"
"@ingroup Scripting")
{
if(dStrlen(varName) == 0)
if(dStrIsEmpty(varName))
{
Con::errorf("isDefined() - did you forget to put quotes around the variable name?");
return false;
@ -2339,11 +2345,10 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
{
if (dStrlen(value) > 0)
return true;
else if (dStrcmp(varValue,"")!=0)
else if (!dStrIsEmpty(varValue))
{
obj->setDataField(valName, 0, varValue);
}
}
}
}
@ -2357,7 +2362,7 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
if (ent)
return true;
else if (dStrcmp (varValue,"")!=0)
else if (!dStrIsEmpty(varValue))
{
gEvalState.getCurrentFrame().setVariable(name, varValue);
}
@ -2372,7 +2377,7 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
if (ent)
return true;
else if (dStrcmp( varValue,"") != 0)
else if (!dStrIsEmpty(varValue))
{
gEvalState.globalVars.setVariable(name, varValue);
}
@ -2382,7 +2387,7 @@ DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varVa
// Is it an object?
if (dStrcmp(varName, "0") && dStrcmp(varName, "") && (Sim::findObject(varName) != NULL))
return true;
else if (dStrcmp(varValue, "" ) != 0)
else if (!dStrIsEmpty(varValue))
{
Con::errorf("%s() - can't assign a value to a variable of the form \"%s\"", __FUNCTION__, varValue);
}
@ -2436,7 +2441,7 @@ DefineConsoleFunction( popInstantGroup, void, (), , "()"
//-----------------------------------------------------------------------------
DefineConsoleFunction( getPrefsPath, const char *, ( const char* relativeFileName ), , "([relativeFileName])"
DefineConsoleFunction( getPrefsPath, const char *, ( const char* relativeFileName ), (""), "([relativeFileName])"
"@note Appears to be useless in Torque 3D, should be deprecated\n"
"@internal")
{

View file

@ -216,7 +216,7 @@ DefineConsoleMethod(FieldBrushObject, queryFields, const char*, (const char* sim
const AbstractClassRep::FieldList& staticFields = pSimObject->getFieldList();
// Did we specify a groups list?
if (dStrcmp (groupList,"")==0 )
if ( dStrIsEmpty(groupList) )
{
// No, so return all fields...

View file

@ -2205,16 +2205,15 @@ DefineConsoleMethod( PersistenceManager, setDirty, void, ( const char * objName
{
if (!Sim::findObject(objName, dirtyObject))
{
Con::printf("setDirty(): Invalid SimObject: %s", objName);
Con::printf("PersistenceManager::setDirty(): Invalid SimObject: %s", objName);
return;
}
}
// Prevent ourselves from shooting us in the foot.
if( dirtyObject == Sim::getRootGroup() )
{
Con::errorf( "%s(): Cannot save RootGroup", objName );
Con::errorf( "PersistenceManager::setDirty(): Cannot save RootGroup" );
return;
}
@ -2235,7 +2234,7 @@ DefineConsoleMethod( PersistenceManager, removeDirty, void, ( const char * objNa
{
if (!Sim::findObject(objName, dirtyObject))
{
Con::printf("%s(): Invalid SimObject: %s", object->getName(),objName);
Con::printf("PersistenceManager::removeDirty(): Invalid SimObject: %s", objName);
return;
}
}
@ -2252,7 +2251,7 @@ DefineConsoleMethod( PersistenceManager, isDirty, bool, ( const char * objName )
{
if (!Sim::findObject(objName, dirtyObject))
{
Con::printf("%s(): Invalid SimObject: %s", object->getName(), objName);
Con::printf("PersistenceManager::isDirty(): Invalid SimObject: %s", objName);
return false;
}
}
@ -2358,7 +2357,7 @@ DefineConsoleMethod( PersistenceManager, removeObjectFromFile, void, (const char
{
if (!Sim::findObject(objName, dirtyObject))
{
Con::printf("%s(): Invalid SimObject: %s", object->getName(), objName);
Con::printf("PersistenceManager::removeObjectFromFile(): Invalid SimObject: %s", objName);
return;
}
}
@ -2380,7 +2379,7 @@ DefineConsoleMethod( PersistenceManager, removeField, void, (const char * objNam
{
if (!Sim::findObject(objName, dirtyObject))
{
Con::printf("%s(): Invalid SimObject: %s", object->getName(), objName);
Con::printf("PersistenceManager::removeField(): Invalid SimObject: %s", objName);
return;
}
}

View file

@ -138,10 +138,9 @@ DefineConsoleFunction( spawnObject, S32, ( const char * spawnClass
, const char * spawnName
, const char * spawnProperties
, const char * spawnScript
),("","","","","") ,"spawnObject(class [, dataBlock, name, properties, script])"
),("","","","") ,"spawnObject(class [, dataBlock, name, properties, script])"
"@hide")
{
SimObject* spawnObject = Sim::spawnObject(spawnClass, spawnDataBlock, spawnName, spawnProperties, spawnScript);
if (spawnObject)