diff --git a/Engine/source/T3D/lightBase.cpp b/Engine/source/T3D/lightBase.cpp index cbc366efa..dd168a483 100644 --- a/Engine/source/T3D/lightBase.cpp +++ b/Engine/source/T3D/lightBase.cpp @@ -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; diff --git a/Engine/source/T3D/missionMarker.cpp b/Engine/source/T3D/missionMarker.cpp index e13b661fc..151cd7336 100644 --- a/Engine/source/T3D/missionMarker.cpp +++ b/Engine/source/T3D/missionMarker.cpp @@ -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 " diff --git a/Engine/source/T3D/physics/physicsPlugin.cpp b/Engine/source/T3D/physics/physicsPlugin.cpp index d49027f3c..b2f06b55e 100644 --- a/Engine/source/T3D/physics/physicsPlugin.cpp +++ b/Engine/source/T3D/physics/physicsPlugin.cpp @@ -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 ); } diff --git a/Engine/source/app/net/serverQuery.cpp b/Engine/source/app/net/serverQuery.cpp index e7a533c54..e3ac401b4 100644 --- a/Engine/source/app/net/serverQuery.cpp +++ b/Engine/source/app/net/serverQuery.cpp @@ -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]; diff --git a/Engine/source/console/consoleFunctions.cpp b/Engine/source/console/consoleFunctions.cpp index 17a0740a9..a5ea49f33 100644 --- a/Engine/source/console/consoleFunctions.cpp +++ b/Engine/source/console/consoleFunctions.cpp @@ -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") { diff --git a/Engine/source/console/fieldBrushObject.cpp b/Engine/source/console/fieldBrushObject.cpp index d1d308e56..3b6f38b25 100644 --- a/Engine/source/console/fieldBrushObject.cpp +++ b/Engine/source/console/fieldBrushObject.cpp @@ -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... diff --git a/Engine/source/console/persistenceManager.cpp b/Engine/source/console/persistenceManager.cpp index 19a903d43..322626801 100644 --- a/Engine/source/console/persistenceManager.cpp +++ b/Engine/source/console/persistenceManager.cpp @@ -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; } } diff --git a/Engine/source/console/sim.cpp b/Engine/source/console/sim.cpp index 86e4e5e25..e0465050f 100644 --- a/Engine/source/console/sim.cpp +++ b/Engine/source/console/sim.cpp @@ -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) diff --git a/Engine/source/core/resourceManager.cpp b/Engine/source/core/resourceManager.cpp index 3dca3d358..09b889f95 100644 --- a/Engine/source/core/resourceManager.cpp +++ b/Engine/source/core/resourceManager.cpp @@ -228,9 +228,9 @@ ConsoleFunction(resourceDump, void, 1, 1, "()" "@ingroup Editors\n" "@internal") { - #ifdef TORQUE_DEBUG +#ifdef TORQUE_DEBUG ResourceManager::get().dumpToConsole(); - #endif +#endif } diff --git a/Engine/source/core/strings/stringFunctions.h b/Engine/source/core/strings/stringFunctions.h index 32396701a..b8d98676a 100644 --- a/Engine/source/core/strings/stringFunctions.h +++ b/Engine/source/core/strings/stringFunctions.h @@ -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) diff --git a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp index 8c9f10ddf..10fdbe115 100644 --- a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp @@ -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 { diff --git a/Engine/source/environment/editors/guiRiverEditorCtrl.cpp b/Engine/source/environment/editors/guiRiverEditorCtrl.cpp index d21646c1a..44f161232 100644 --- a/Engine/source/environment/editors/guiRiverEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiRiverEditorCtrl.cpp @@ -1470,7 +1470,7 @@ DefineConsoleMethod( GuiRiverEditorCtrl, getSelectedRiver, S32, (), , "" ) if ( !river ) return NULL; - return river->getId(); + return river->getId(); } DefineConsoleMethod( GuiRiverEditorCtrl, regenerate, void, (), , "" ) diff --git a/Engine/source/gfx/gfxCardProfile.cpp b/Engine/source/gfx/gfxCardProfile.cpp index 99078537d..b222fa3e0 100644 --- a/Engine/source/gfx/gfxCardProfile.cpp +++ b/Engine/source/gfx/gfxCardProfile.cpp @@ -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; } diff --git a/Engine/source/gui/controls/guiFileTreeCtrl.cpp b/Engine/source/gui/controls/guiFileTreeCtrl.cpp index 08aec0968..db38fbe58 100644 --- a/Engine/source/gui/controls/guiFileTreeCtrl.cpp +++ b/Engine/source/gui/controls/guiFileTreeCtrl.cpp @@ -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(); diff --git a/Engine/source/gui/controls/guiTreeViewCtrl.cpp b/Engine/source/gui/controls/guiTreeViewCtrl.cpp index e103e1403..6e84e398f 100644 --- a/Engine/source/gui/controls/guiTreeViewCtrl.cpp +++ b/Engine/source/gui/controls/guiTreeViewCtrl.cpp @@ -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; } //------------------------------------------------------------------------------ diff --git a/Engine/source/gui/core/guiCanvas.cpp b/Engine/source/gui/core/guiCanvas.cpp index 8ec369490..ced5b666d 100644 --- a/Engine/source/gui/core/guiCanvas.cpp +++ b/Engine/source/gui/core/guiCanvas.cpp @@ -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 diff --git a/Engine/source/gui/core/guiControl.cpp b/Engine/source/gui/core/guiControl.cpp index 4f8e46e57..f61a3b6dc 100644 --- a/Engine/source/gui/core/guiControl.cpp +++ b/Engine/source/gui/core/guiControl.cpp @@ -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 ); } //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/editor/guiInspector.cpp b/Engine/source/gui/editor/guiInspector.cpp index 2fdc2881f..9cb771a31 100644 --- a/Engine/source/gui/editor/guiInspector.cpp +++ b/Engine/source/gui/editor/guiInspector.cpp @@ -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 ); } //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/editor/guiParticleGraphCtrl.cpp b/Engine/source/gui/editor/guiParticleGraphCtrl.cpp index 08a598235..11dfedafc 100644 --- a/Engine/source/gui/editor/guiParticleGraphCtrl.cpp +++ b/Engine/source/gui/editor/guiParticleGraphCtrl.cpp @@ -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; } diff --git a/Engine/source/gui/editor/inspector/field.cpp b/Engine/source/gui/editor/inspector/field.cpp index 7f226d635..b2023ffb2 100644 --- a/Engine/source/gui/editor/inspector/field.cpp +++ b/Engine/source/gui/editor/inspector/field.cpp @@ -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 ); } diff --git a/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp b/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp index b5d0c5551..8da96bbda 100644 --- a/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp +++ b/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp @@ -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 ) { diff --git a/Engine/source/gui/worldEditor/terrainEditor.cpp b/Engine/source/gui/worldEditor/terrainEditor.cpp index bb5dcf5d8..ebf132fd1 100644 --- a/Engine/source/gui/worldEditor/terrainEditor.cpp +++ b/Engine/source/gui/worldEditor/terrainEditor.cpp @@ -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; } diff --git a/Engine/source/gui/worldEditor/worldEditor.cpp b/Engine/source/gui/worldEditor/worldEditor.cpp index 78566bcb0..befd30b92 100644 --- a/Engine/source/gui/worldEditor/worldEditor.cpp +++ b/Engine/source/gui/worldEditor/worldEditor.cpp @@ -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); } diff --git a/Engine/source/math/mConsoleFunctions.cpp b/Engine/source/math/mConsoleFunctions.cpp index 09141989a..1a11fe23e 100644 --- a/Engine/source/math/mConsoleFunctions.cpp +++ b/Engine/source/math/mConsoleFunctions.cpp @@ -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" diff --git a/Engine/source/sfx/sfxSystem.cpp b/Engine/source/sfx/sfxSystem.cpp index 55be8fed1..0eb12e2e9 100644 --- a/Engine/source/sfx/sfxSystem.cpp +++ b/Engine/source/sfx/sfxSystem.cpp @@ -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( 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 { diff --git a/Engine/source/sim/netDownload.cpp b/Engine/source/sim/netDownload.cpp index 00fc6f0fc..a53d633ef 100644 --- a/Engine/source/sim/netDownload.cpp +++ b/Engine/source/sim/netDownload.cpp @@ -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" diff --git a/Engine/source/terrain/terrData.cpp b/Engine/source/terrain/terrData.cpp index 9cbd59beb..f33e32340 100644 --- a/Engine/source/terrain/terrData.cpp +++ b/Engine/source/terrain/terrData.cpp @@ -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); diff --git a/Engine/source/ts/collada/colladaLights.cpp b/Engine/source/ts/collada/colladaLights.cpp index 2d31b8f55..ff491d341 100644 --- a/Engine/source/ts/collada/colladaLights.cpp +++ b/Engine/source/ts/collada/colladaLights.cpp @@ -169,7 +169,7 @@ DefineConsoleFunction( loadColladaLights, bool, (const char * filename, const ch // the MissionGroup if not specified. SimGroup* missionGroup = dynamic_cast(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(); diff --git a/Engine/source/util/settings.cpp b/Engine/source/util/settings.cpp index db812f76b..1b0ddfea6 100644 --- a/Engine/source/util/settings.cpp +++ b/Engine/source/util/settings.cpp @@ -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 ); diff --git a/Engine/source/util/undo.cpp b/Engine/source/util/undo.cpp index 724df67ee..140eda541 100644 --- a/Engine/source/util/undo.cpp +++ b/Engine/source/util/undo.cpp @@ -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)