mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-09 23:40:42 +00:00
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:
parent
04ff04a95f
commit
3ab048c5b0
30 changed files with 130 additions and 110 deletions
|
|
@ -431,7 +431,7 @@ DefineConsoleMethod( LightBase, playAnimation, void, (const char * anim), (""),
|
|||
"existing one is played."
|
||||
"@hide")
|
||||
{
|
||||
if ( dStrcmp(anim,"" )==0)
|
||||
if ( dStrIsEmpty(anim) )
|
||||
{
|
||||
object->playAnimation();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -504,7 +504,6 @@ ConsoleDocFragment _SpawnSpherespawnObject1(
|
|||
"bool spawnObject(string additionalProps);"
|
||||
);
|
||||
|
||||
//ConsoleMethod(SpawnSphere, spawnObject, S32, 2, 3,
|
||||
DefineConsoleMethod(SpawnSphere, spawnObject, S32, (String additionalProps), ,
|
||||
"([string additionalProps]) Spawns the object based on the SpawnSphere's "
|
||||
"class, datablock, properties, and script settings. Allows you to pass in "
|
||||
|
|
|
|||
|
|
@ -131,9 +131,8 @@ DefineConsoleFunction( physicsPluginPresent, bool, (), , "physicsPluginPresent()
|
|||
return PHYSICSMGR != NULL;
|
||||
}
|
||||
|
||||
DefineConsoleFunction( physicsInit, bool, (const char * library), (""), "physicsInit( [string library] )")
|
||||
DefineConsoleFunction( physicsInit, bool, (const char * library), ("default"), "physicsInit( [string library] )")
|
||||
{
|
||||
|
||||
return PhysicsPlugin::activate( library );
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +151,7 @@ DefineConsoleFunction( physicsInitWorld, bool, (const char * worldName), , "phys
|
|||
DefineConsoleFunction( physicsDestroyWorld, void, (const char * worldName), , "physicsDestroyWorld( String worldName )")
|
||||
{
|
||||
if ( PHYSICSMGR )
|
||||
{ PHYSICSMGR->destroyWorld( String( worldName ) ); }
|
||||
PHYSICSMGR->destroyWorld( worldName );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -568,12 +568,9 @@ DefineConsoleFunction( queryMasterServer
|
|||
|
||||
DefineConsoleFunction( querySingleServer
|
||||
, void, ( const char* addrText, U8 flags )
|
||||
,(0) , "querySingleServer(...);" )
|
||||
, (0), "querySingleServer(address, flags);" )
|
||||
{
|
||||
|
||||
NetAddress addr;
|
||||
|
||||
|
||||
Net::stringToAddress( addrText, &addr );
|
||||
querySingleServer(&addr,flags);
|
||||
}
|
||||
|
|
@ -655,7 +652,7 @@ void cancelServerQuery()
|
|||
}
|
||||
}
|
||||
|
||||
DefineConsoleFunction( cancelServerQuery, void, (), , "cancelServerQuery(...);" )
|
||||
DefineConsoleFunction( cancelServerQuery, void, (), , "cancelServerQuery();" )
|
||||
{
|
||||
cancelServerQuery();
|
||||
}
|
||||
|
|
@ -683,14 +680,14 @@ void stopServerQuery()
|
|||
}
|
||||
}
|
||||
|
||||
DefineConsoleFunction( stopServerQuery, void, (), , "stopServerQuery(...);" )
|
||||
DefineConsoleFunction( stopServerQuery, void, (), , "stopServerQuery();" )
|
||||
{
|
||||
stopServerQuery();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineConsoleFunction( startHeartbeat, void, (), , "startHeartbeat(...);" )
|
||||
DefineConsoleFunction( startHeartbeat, void, (), , "startHeartbeat();" )
|
||||
{
|
||||
if (validateAuthenticatedServer()) {
|
||||
gHeartbeatSeq++;
|
||||
|
|
@ -698,19 +695,19 @@ DefineConsoleFunction( startHeartbeat, void, (), , "startHeartbeat(...);" )
|
|||
}
|
||||
}
|
||||
|
||||
DefineConsoleFunction( stopHeartbeat, void, (), , "stopHeartbeat(...);" )
|
||||
DefineConsoleFunction( stopHeartbeat, void, (), , "stopHeartbeat();" )
|
||||
{
|
||||
gHeartbeatSeq++;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineConsoleFunction( getServerCount, int, (), , "getServerCount(...);" )
|
||||
DefineConsoleFunction( getServerCount, int, (), , "getServerCount();" )
|
||||
{
|
||||
return gServerList.size();
|
||||
}
|
||||
|
||||
DefineConsoleFunction( setServerInfo, bool, (U32 index), , "setServerInfo(...);" )
|
||||
DefineConsoleFunction( setServerInfo, bool, (U32 index), , "setServerInfo(index);" )
|
||||
{
|
||||
if (index < gServerList.size()) {
|
||||
ServerInfo& info = gServerList[index];
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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...
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -228,9 +228,9 @@ ConsoleFunction(resourceDump, void, 1, 1, "()"
|
|||
"@ingroup Editors\n"
|
||||
"@internal")
|
||||
{
|
||||
#ifdef TORQUE_DEBUG
|
||||
#ifdef TORQUE_DEBUG
|
||||
ResourceManager::get().dumpToConsole();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ inline S32 dStrcmp(const char *str1, const char *str2)
|
|||
|
||||
inline bool dStrIsEmpty(const char *src)
|
||||
{
|
||||
return src == 0 || !dStrcmp(src, "");
|
||||
return src == 0 || src[0] == '\0';
|
||||
}
|
||||
|
||||
inline S32 dStrncmp(const char *str1, const char *str2, dsize_t len)
|
||||
|
|
|
|||
|
|
@ -1248,7 +1248,7 @@ DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeNormal, void, (Point3F normal
|
|||
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, setSelectedRoad, void, (const char * objName), (""), "" )
|
||||
{
|
||||
if ( dStrcmp(objName, "" )==0)
|
||||
if ( dStrIsEmpty(objName) )
|
||||
object->setSelectedRoad(NULL);
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1470,7 +1470,7 @@ DefineConsoleMethod( GuiRiverEditorCtrl, getSelectedRiver, S32, (), , "" )
|
|||
if ( !river )
|
||||
return NULL;
|
||||
|
||||
return river->getId();
|
||||
return river->getId();
|
||||
}
|
||||
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, regenerate, void, (), , "" )
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void GFXCardProfiler::loadProfileScript(const char* aScriptName)
|
|||
|
||||
Con::printf(" - Loaded card profile %s", scriptName.c_str());
|
||||
|
||||
Con::evaluate(script, false, NULL);
|
||||
Con::evaluate(script, false, NULL);
|
||||
delete[] script;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -379,7 +379,6 @@ void GuiFileTreeCtrl::recurseInsert( Item* parent, StringTableEntry path )
|
|||
|
||||
}
|
||||
|
||||
//ConsoleMethod( GuiFileTreeCtrl, getSelectedPath, const char*, 2, 2, "getSelectedPath() - returns the currently selected path in the tree")
|
||||
DefineConsoleMethod( GuiFileTreeCtrl, getSelectedPath, const char*, (), , "getSelectedPath() - returns the currently selected path in the tree")
|
||||
{
|
||||
const String& path = object->getSelectedPath();
|
||||
|
|
|
|||
|
|
@ -5124,8 +5124,9 @@ DefineConsoleMethod(GuiTreeViewCtrl, getTextToRoot, const char*, (S32 itemId, co
|
|||
|
||||
DefineConsoleMethod(GuiTreeViewCtrl, getSelectedItemList,const char*, (), ,"returns a space seperated list of mulitple item ids")
|
||||
{
|
||||
char* buff = Con::getReturnBuffer(1024);
|
||||
dSprintf(buff,1024,"");
|
||||
const U32 bufSize = 1024;
|
||||
char* buff = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(buff, bufSize, "");
|
||||
|
||||
const Vector< S32 >& selected = object->getSelected();
|
||||
for(int i = 0; i < selected.size(); i++)
|
||||
|
|
@ -5163,7 +5164,7 @@ S32 GuiTreeViewCtrl::findItemByObjectId(S32 iObjId)
|
|||
return mItems[i]->mId;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -2052,10 +2052,9 @@ ConsoleDocFragment _popDialog2(
|
|||
"void popDialog();"
|
||||
);
|
||||
|
||||
DefineConsoleMethod( GuiCanvas, popDialog, void, (GuiControl * gui), , "(GuiControl ctrl=NULL)"
|
||||
DefineConsoleMethod( GuiCanvas, popDialog, void, (GuiControl * gui), (NULL), "(GuiControl ctrl=NULL)"
|
||||
"@hide")
|
||||
{
|
||||
|
||||
if (gui)
|
||||
object->popDialogControl(gui);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -2810,12 +2810,19 @@ static ConsoleDocFragment _sGuiControlSetExtent2(
|
|||
"GuiControl", // The class to place the method in; use NULL for functions.
|
||||
"void setExtent( Point2I p );" ); // The definition string.
|
||||
|
||||
//ConsoleMethod( GuiControl, setExtent, void, 3, 4,
|
||||
DefineConsoleMethod( GuiControl, setExtent, void, ( Point2I ext ), ,
|
||||
" Set the width and height of the control.\n\n"
|
||||
DefineConsoleMethod( GuiControl, setExtent, void, ( const char* extOrX, const char* y ), (""),
|
||||
"( Point2I p | int x, int y ) Set the width and height of the control.\n\n"
|
||||
"@hide" )
|
||||
{
|
||||
object->setExtent( (S32)ext.x, (S32)ext.y );
|
||||
Point2I extent;
|
||||
if(!dStrIsEmpty(extOrX) && dStrIsEmpty(y))
|
||||
dSscanf(extOrX, "%f %f", &extent.x, &extent.y);
|
||||
else if(!dStrIsEmpty(extOrX) && !dStrIsEmpty(y))
|
||||
{
|
||||
extent.x = dAtof(extOrX);
|
||||
extent.y = dAtof(y);
|
||||
}
|
||||
object->setExtent( extent );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -804,8 +804,8 @@ DefineConsoleMethod( GuiInspector, addInspect, void, (const char * className, bo
|
|||
|
||||
DefineConsoleMethod( GuiInspector, removeInspect, void, (SimObject* obj), , "( id object ) - Remove the object from the list of objects being inspected." )
|
||||
{
|
||||
if (object)
|
||||
object->removeInspectObject( obj );
|
||||
if (obj)
|
||||
object->removeInspectObject( obj );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1205,9 +1205,10 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getGraphName, const char*, (S32 plotID
|
|||
Con::errorf("Invalid plotID.");
|
||||
}
|
||||
|
||||
char *retBuffer = Con::getReturnBuffer(64);
|
||||
const U32 bufSize = 64;
|
||||
char *retBuffer = Con::getReturnBuffer(bufSize);
|
||||
const StringTableEntry graphName = object->getGraphName(plotID);
|
||||
dSprintf(retBuffer, 64, "%s", graphName);
|
||||
dSprintf(retBuffer, bufSize, "%s", graphName);
|
||||
return retBuffer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -637,7 +637,7 @@ DefineConsoleMethod( GuiInspectorField, getInspectedFieldType, const char*, (),
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineConsoleMethod( GuiInspectorField, apply, void, ( const char * newValue, bool callbacks ), ("", true), "( string newValue, bool callbacks=true ) - Set the field's value. Suppress callbacks for undo if callbacks=false." )
|
||||
DefineConsoleMethod( GuiInspectorField, apply, void, ( const char * newValue, bool callbacks ), (true), "( string newValue, bool callbacks=true ) - Set the field's value. Suppress callbacks for undo if callbacks=false." )
|
||||
{
|
||||
object->setData( newValue, callbacks );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -823,8 +823,9 @@ DefineConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, ( U32 i
|
|||
return "";
|
||||
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
returnBuffer[0] = 0;
|
||||
|
||||
|
||||
if ( decalInstance )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2521,8 +2521,9 @@ DefineConsoleMethod( TerrainEditor, getBrushSize, const char*, (), , "()")
|
|||
{
|
||||
Point2I size = object->getBrushSize();
|
||||
|
||||
char * ret = Con::getReturnBuffer(32);
|
||||
dSprintf(ret, 32, "%d %d", size.x, size.y);
|
||||
static const U32 bufSize = 32;
|
||||
char * ret = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(ret, bufSize, "%d %d", size.x, size.y);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3448,10 +3448,10 @@ DefineConsoleMethod( WorldEditor, transformSelection, void,
|
|||
S32 scaleType,
|
||||
Point3F scale,
|
||||
bool sRelative,
|
||||
bool sLocal ), , "transformSelection(...)\n"
|
||||
bool sLocal ), ,
|
||||
"transformSelection(...)\n"
|
||||
"Transform selection by given parameters.")
|
||||
{
|
||||
|
||||
object->transformSelection(position, point, relativePos, rotate, rotation, relativeRot, rotLocal, scaleType, scale, sRelative, sLocal);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,22 +94,14 @@ DefineConsoleFunction( mFloor, S32, ( F32 v ),,
|
|||
return (S32)mFloor( v );
|
||||
}
|
||||
|
||||
DefineConsoleFunction( mRound, F32, ( F32 v, S32 n ), (0),
|
||||
"Round v to the nth decimal place or the nearest whole number by default."
|
||||
"@param v Value to roundn"
|
||||
"@param n Number of decimal places to round to, 0 by defaultn"
|
||||
DefineConsoleFunction( mRound, S32, ( F32 v ),,
|
||||
"Round v to the nth decimal place or the nearest whole number by default."
|
||||
"@param v Value to roundn"
|
||||
"@return The rounded value as a S32."
|
||||
"@ingroup Math" )
|
||||
{
|
||||
if(n <= 0)
|
||||
{
|
||||
return mRound(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mRound(v, n);
|
||||
}
|
||||
}
|
||||
{
|
||||
return mRound(v);
|
||||
}
|
||||
|
||||
DefineConsoleFunction( mCeil, S32, ( F32 v ),,
|
||||
"Round v up to the nearest integer.\n"
|
||||
|
|
|
|||
|
|
@ -1466,7 +1466,7 @@ DefineConsoleFunction( sfxCreateSource, S32, ( const char * SFXType, const char
|
|||
|
||||
if ( track )
|
||||
{
|
||||
if (dStrcmp(x, "") == 0)
|
||||
if ( dStrIsEmpty(x) )
|
||||
{
|
||||
source = SFX->createSource( track );
|
||||
}
|
||||
|
|
@ -1487,7 +1487,7 @@ DefineConsoleFunction( sfxCreateSource, S32, ( const char * SFXType, const char
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( dStrcmp(x , "")==0 )
|
||||
if ( dStrIsEmpty(x) )
|
||||
{
|
||||
source = SFX->createSource( tempProfile );
|
||||
}
|
||||
|
|
@ -1550,7 +1550,7 @@ DefineConsoleFunction( sfxPlay, S32, ( const char * trackName, const char * poin
|
|||
"Start playing the given source or create a new source for the given track and play it.\n"
|
||||
"@hide" )
|
||||
{
|
||||
if ( dStrcmp(pointOrX , "")==0 )
|
||||
if ( dStrIsEmpty(pointOrX) )
|
||||
{
|
||||
SFXSource* source = dynamic_cast<SFXSource*>( Sim::findObject( trackName ) );
|
||||
if ( source )
|
||||
|
|
@ -1568,11 +1568,11 @@ DefineConsoleFunction( sfxPlay, S32, ( const char * trackName, const char * poin
|
|||
}
|
||||
|
||||
Point3F pos(0.f, 0.f, 0.f);
|
||||
if (dStrcmp( pointOrX, "" ) != 0 && dStrcmp( y, "" ) == 0 && dStrcmp( z, "" ) == 0 )
|
||||
if ( !dStrIsEmpty( pointOrX ) && dStrIsEmpty( y ) && dStrIsEmpty( z ) )
|
||||
{
|
||||
dSscanf( pointOrX, "%g %g %g", &pos.x, &pos.y, &pos.z );
|
||||
}
|
||||
else if(dStrcmp( pointOrX, "" ) != 0 && dStrcmp( y, "" ) != 0 && dStrcmp( z, "" ) != 0 )
|
||||
else if( !dStrIsEmpty( pointOrX ) && !dStrIsEmpty( y ) && !dStrIsEmpty( z ) )
|
||||
pos.set( dAtof(pointOrX), dAtof(y), dAtof(z) );
|
||||
|
||||
MatrixF transform;
|
||||
|
|
@ -1676,7 +1676,7 @@ DefineConsoleFunction( sfxPlayOnce, S32, ( const char * SFXType, const char * fi
|
|||
SFXSource* source = NULL;
|
||||
if( track )
|
||||
{
|
||||
if (dStrcmp(x, "") == 0)
|
||||
if (dStrIsEmpty(x))
|
||||
{
|
||||
source = SFX->playOnce( track );
|
||||
}
|
||||
|
|
@ -1697,7 +1697,7 @@ DefineConsoleFunction( sfxPlayOnce, S32, ( const char * SFXType, const char * fi
|
|||
}
|
||||
else
|
||||
{
|
||||
if (dStrcmp(x, "") == 0)
|
||||
if (dStrIsEmpty(x))
|
||||
source = SFX->playOnce( tempProfile );
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
#include "platform/platform.h"
|
||||
#include "core/dnet.h"
|
||||
#include "console/simBase.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "sim/netConnection.h"
|
||||
#include "core/stream/bitStream.h"
|
||||
#include "core/stream/fileStream.h"
|
||||
|
|
|
|||
|
|
@ -142,22 +142,28 @@ ConsoleDocFragment _getTerrainUnderWorldPoint2(
|
|||
"bool getTerrainUnderWorldPoint( F32 x, F32 y, F32 z);"
|
||||
);
|
||||
|
||||
DefineConsoleFunction( getTerrainUnderWorldPoint, S32, (Point3F position), ,
|
||||
DefineConsoleFunction( getTerrainUnderWorldPoint, S32, (const char* ptOrX, const char* y, const char* z), ("", ""),
|
||||
"(Point3F x/y/z) Gets the terrain block that is located under the given world point.\n"
|
||||
"@param x/y/z The world coordinates (floating point values) you wish to query at. "
|
||||
"These can be formatted as either a string (\"x y z\") or separately as (x, y, z)\n"
|
||||
"@return Returns the ID of the requested terrain block (0 if not found).\n\n"
|
||||
"@hide")
|
||||
"@hide")
|
||||
{
|
||||
|
||||
TerrainBlock* terrain = getTerrainUnderWorldPoint(position);
|
||||
Point3F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y) && dStrIsEmpty(z))
|
||||
dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y) && !dStrIsEmpty(z))
|
||||
{
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
pos.z = dAtof(z);
|
||||
}
|
||||
TerrainBlock* terrain = getTerrainUnderWorldPoint(pos);
|
||||
if(terrain != NULL)
|
||||
{
|
||||
return terrain->getId();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1313,24 +1319,31 @@ ConsoleDocFragment _getTerrainHeight2(
|
|||
"bool getTerrainHeight( F32 x, F32 y);"
|
||||
);
|
||||
|
||||
DefineConsoleFunction( getTerrainHeight, F32, (Point2F pos), , "(Point2 pos) - gets the terrain height at the specified position."
|
||||
DefineConsoleFunction( getTerrainHeight, F32, (const char* ptOrX, const char* y), (""), "(Point2 pos) - gets the terrain height at the specified position."
|
||||
"@param pos The world space point, minus the z (height) value\n Can be formatted as either (\"x y\") or (x,y)\n"
|
||||
"@return Returns the terrain height at the given point as an F32 value.\n"
|
||||
"@hide")
|
||||
{
|
||||
F32 height = 0.0f;
|
||||
F32 height = 0.0f;
|
||||
|
||||
Point2F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y))
|
||||
dSscanf(ptOrX, "%f %f", &pos.x, &pos.y);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y))
|
||||
{
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
}
|
||||
|
||||
TerrainBlock * terrain = getTerrainUnderWorldPoint(Point3F(pos.x, pos.y, 5000.0f));
|
||||
if(terrain)
|
||||
if(terrain->isServerObject())
|
||||
{
|
||||
Point3F offset;
|
||||
terrain->getTransform().getColumn(3, &offset);
|
||||
pos -= Point2F(offset.x, offset.y);
|
||||
terrain->getHeight(pos, &height);
|
||||
}
|
||||
return height;
|
||||
TerrainBlock * terrain = getTerrainUnderWorldPoint(Point3F(pos.x, pos.y, 5000.0f));
|
||||
if(terrain && terrain->isServerObject())
|
||||
{
|
||||
Point3F offset;
|
||||
terrain->getTransform().getColumn(3, &offset);
|
||||
pos -= Point2F(offset.x, offset.y);
|
||||
terrain->getHeight(pos, &height);
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
ConsoleDocFragment _getTerrainHeightBelowPosition1(
|
||||
|
|
@ -1351,7 +1364,7 @@ ConsoleDocFragment _getTerrainHeightBelowPosition2(
|
|||
"bool getTerrainHeightBelowPosition( F32 x, F32 y);"
|
||||
);
|
||||
|
||||
DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (Point3F pos), ,
|
||||
DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (const char* ptOrX, const char* y, const char* z), ("", ""),
|
||||
"(Point3F pos) - gets the terrain height at the specified position."
|
||||
"@param pos The world space point. Can be formatted as either (\"x y z\") or (x,y,z)\n"
|
||||
"@note This function is useful if you simply want to grab the terrain height underneath an object.\n"
|
||||
|
|
@ -1360,6 +1373,15 @@ DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (Point3F pos), ,
|
|||
{
|
||||
F32 height = 0.0f;
|
||||
|
||||
Point3F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y) && dStrIsEmpty(z))
|
||||
dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y) && !dStrIsEmpty(z))
|
||||
{
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
pos.z = dAtof(z);
|
||||
}
|
||||
|
||||
TerrainBlock * terrain = getTerrainUnderWorldPoint(pos);
|
||||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ DefineConsoleFunction( loadColladaLights, bool, (const char * filename, const ch
|
|||
// the MissionGroup if not specified.
|
||||
SimGroup* missionGroup = dynamic_cast<SimGroup*>(Sim::findObject("MissionGroup"));
|
||||
SimGroup* group = 0;
|
||||
if (dStrcmp(parentGroup, "") == 0){
|
||||
if (!dStrIsEmpty(parentGroup)){
|
||||
if (!Sim::findObject(parentGroup, group)) {
|
||||
// Create the group if it could not be found
|
||||
group = new SimGroup;
|
||||
|
|
@ -188,7 +188,7 @@ DefineConsoleFunction( loadColladaLights, bool, (const char * filename, const ch
|
|||
|
||||
// Optional object to provide the base transform
|
||||
MatrixF offset(true);
|
||||
if (dStrcmp(baseObject, "") != 0){
|
||||
if (!dStrIsEmpty(baseObject)){
|
||||
SceneObject *obj;
|
||||
if (Sim::findObject(baseObject, obj))
|
||||
offset = obj->getTransform();
|
||||
|
|
|
|||
|
|
@ -646,9 +646,9 @@ void SettingSaveNode::buildDocument(SimXMLDocument *document, bool skipWrite)
|
|||
|
||||
DefineConsoleMethod(Settings, setValue, void, (const char * settingName, const char * value), (""), "settingObj.setValue(settingName, value);")
|
||||
{
|
||||
const char *fieldName = StringTable->insert( settingName );
|
||||
StringTableEntry fieldName = StringTable->insert( settingName );
|
||||
|
||||
if (dStrcmp(value, "") != 0)
|
||||
if (!dStrIsEmpty(value))
|
||||
object->setValue( fieldName, value );
|
||||
else
|
||||
object->setValue( fieldName );
|
||||
|
|
@ -656,13 +656,13 @@ DefineConsoleMethod(Settings, setValue, void, (const char * settingName, const c
|
|||
|
||||
DefineConsoleMethod(Settings, setDefaultValue, void, (const char * settingName, const char * value), , "settingObj.setDefaultValue(settingName, value);")
|
||||
{
|
||||
const char *fieldName = StringTable->insert( settingName );
|
||||
StringTableEntry fieldName = StringTable->insert( settingName );
|
||||
object->setDefaultValue( fieldName, value );
|
||||
}
|
||||
|
||||
DefineConsoleMethod(Settings, value, const char*, (const char * settingName, const char * defaultValue), (""), "settingObj.value(settingName, defaultValue);")
|
||||
{
|
||||
const char *fieldName = StringTable->insert( settingName );
|
||||
StringTableEntry fieldName = StringTable->insert( settingName );
|
||||
|
||||
if (dStrcmp(defaultValue, "") != 0)
|
||||
return object->value( fieldName, defaultValue );
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ void UndoManager::popCompound( bool discard )
|
|||
DefineConsoleMethod(UndoAction, addToManager, void, (const char * undoManager), (""), "action.addToManager([undoManager])")
|
||||
{
|
||||
UndoManager *theMan = NULL;
|
||||
if (dStrcmp(undoManager, "") != 0)
|
||||
if (!dStrIsEmpty(undoManager))
|
||||
{
|
||||
SimObject *obj = Sim::findObject(undoManager);
|
||||
if(obj)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue