From 08d4f6ebc00a93bddeb575d2e2bf494369225d0e Mon Sep 17 00:00:00 2001 From: jamesu Date: Thu, 11 Oct 2012 21:29:39 +0100 Subject: [PATCH] Improvements to console refactor code - Prevent stack corruption in a few places - Use correct type in printfs - Reduce type conversions in EngineApi & dAto* - Fix compilation on GCC - Tidy up code --- Engine/source/T3D/lightBase.cpp | 4 +- Engine/source/T3D/missionMarker.cpp | 2 +- Engine/source/T3D/physics/physicsPlugin.cpp | 14 +- Engine/source/app/net/net.cpp | 2 +- .../dynamicConsoleMethodComponent.cpp | 23 ++ Engine/source/component/simComponent.cpp | 8 +- Engine/source/console/arrayObject.cpp | 10 +- Engine/source/console/astNodes.cpp | 104 ++++---- Engine/source/console/compiledEval.cpp | 150 +++++------ Engine/source/console/compiler.h | 4 +- Engine/source/console/console.cpp | 248 ++++++++++-------- Engine/source/console/console.h | 29 +- Engine/source/console/consoleFunctions.cpp | 6 +- Engine/source/console/consoleInternal.cpp | 140 ++++------ Engine/source/console/consoleInternal.h | 208 +++++++-------- Engine/source/console/engineAPI.h | 31 ++- Engine/source/console/fieldBrushObject.cpp | 2 +- Engine/source/console/persistenceManager.cpp | 18 +- Engine/source/console/sim.cpp | 10 +- Engine/source/console/sim.h | 9 + Engine/source/console/simEvents.cpp | 12 +- Engine/source/console/simManager.cpp | 5 + Engine/source/console/simPersistSet.cpp | 2 +- Engine/source/console/simSet.cpp | 4 +- Engine/source/console/stringStack.cpp | 180 ++++++------- Engine/source/console/stringStack.h | 37 +-- .../editors/guiMeshRoadEditorCtrl.cpp | 8 +- .../editors/guiRiverEditorCtrl.cpp | 8 +- .../environment/editors/guiRoadEditorCtrl.cpp | 4 +- Engine/source/forest/forest.cpp | 4 +- Engine/source/gui/controls/guiPopUpCtrl.cpp | 6 +- Engine/source/gui/controls/guiPopUpCtrlEx.cpp | 6 +- .../source/gui/controls/guiTreeViewCtrl.cpp | 2 +- Engine/source/gui/core/guiCanvas.cpp | 4 +- Engine/source/gui/editor/guiEditCtrl.cpp | 10 +- Engine/source/gui/editor/guiInspector.cpp | 6 +- .../source/gui/editor/guiInspectorTypes.cpp | 2 +- .../editor/inspector/variableInspector.cpp | 2 +- .../gui/worldEditor/editorIconRegistry.cpp | 6 +- .../gui/worldEditor/guiDecalEditorCtrl.cpp | 12 +- .../source/gui/worldEditor/terrainEditor.cpp | 6 +- Engine/source/gui/worldEditor/worldEditor.cpp | 6 +- .../gui/worldEditor/worldEditorSelection.cpp | 4 +- Engine/source/i18n/i18n.cpp | 2 +- Engine/source/materials/materialManager.cpp | 8 +- Engine/source/platformMac/macCarbFileio.mm | 4 +- Engine/source/platformWin32/winInput.cpp | 2 +- .../platformX86UNIX/x86UNIXInput.client.cpp | 2 +- Engine/source/platformX86UNIX/x86UNIXMath.cpp | 2 +- Engine/source/postFx/postEffectVis.cpp | 6 +- Engine/source/sfx/sfxSystem.cpp | 6 +- Engine/source/sim/actionMap.cpp | 17 +- Engine/source/sim/netConnection.cpp | 2 +- Engine/source/terrain/terrExport.cpp | 4 +- Engine/source/ts/collada/colladaImport.cpp | 2 +- Engine/source/ts/collada/colladaLights.cpp | 2 +- Engine/source/util/messaging/eventManager.cpp | 2 +- Engine/source/util/undo.cpp | 4 +- 58 files changed, 733 insertions(+), 690 deletions(-) diff --git a/Engine/source/T3D/lightBase.cpp b/Engine/source/T3D/lightBase.cpp index a3a5372cf..150f6e9cc 100644 --- a/Engine/source/T3D/lightBase.cpp +++ b/Engine/source/T3D/lightBase.cpp @@ -439,7 +439,7 @@ ConsoleMethod( LightBase, playAnimation, void, 2, 3, "( [LightAnimData anim] )\t LightAnimData *animData; if ( !Sim::findObject( argv[2], animData ) ) { - Con::errorf( "LightBase::playAnimation() - Invalid LightAnimData '%s'.", argv[2] ); + Con::errorf( "LightBase::playAnimation() - Invalid LightAnimData '%s'.", (const char*)argv[2] ); return; } @@ -481,4 +481,4 @@ void LightBase::pauseAnimation( void ) mAnimState.active = false; setMaskBits( UpdateMask ); } -} \ No newline at end of file +} diff --git a/Engine/source/T3D/missionMarker.cpp b/Engine/source/T3D/missionMarker.cpp index bff79e962..668054559 100644 --- a/Engine/source/T3D/missionMarker.cpp +++ b/Engine/source/T3D/missionMarker.cpp @@ -554,7 +554,7 @@ ConsoleMethod(SpawnSphere, spawnObject, S32, 2, 3, String additionalProps; if (argc == 3) - additionalProps = String(argv[2]); + additionalProps = (const char*)argv[2]; SimObject* obj = object->spawnObject(additionalProps); diff --git a/Engine/source/T3D/physics/physicsPlugin.cpp b/Engine/source/T3D/physics/physicsPlugin.cpp index afb06ccb8..79c5076e9 100644 --- a/Engine/source/T3D/physics/physicsPlugin.cpp +++ b/Engine/source/T3D/physics/physicsPlugin.cpp @@ -147,13 +147,13 @@ ConsoleFunction( physicsDestroy, void, 1, 1, "physicsDestroy()" ) ConsoleFunction( physicsInitWorld, bool, 2, 2, "physicsInitWorld( String worldName )" ) { - return PHYSICSMGR && PHYSICSMGR->createWorld( String( argv[1] ) ); + return PHYSICSMGR && PHYSICSMGR->createWorld( (const char*)argv[1] ); } ConsoleFunction( physicsDestroyWorld, void, 2, 2, "physicsDestroyWorld( String worldName )" ) { if ( PHYSICSMGR ) - PHYSICSMGR->destroyWorld( String( argv[1] ) ); + PHYSICSMGR->destroyWorld( (const char*)argv[1] ); } @@ -162,13 +162,13 @@ ConsoleFunction( physicsDestroyWorld, void, 2, 2, "physicsDestroyWorld( String w ConsoleFunction( physicsStartSimulation, void, 2, 2, "physicsStartSimulation( String worldName )" ) { if ( PHYSICSMGR ) - PHYSICSMGR->enableSimulation( String( argv[1] ), true ); + PHYSICSMGR->enableSimulation( (const char*)argv[1], true ); } ConsoleFunction( physicsStopSimulation, void, 2, 2, "physicsStopSimulation( String worldName )" ) { if ( PHYSICSMGR ) - PHYSICSMGR->enableSimulation( String( argv[1] ), false ); + PHYSICSMGR->enableSimulation( (const char*)argv[1], false ); } ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled()" ) @@ -182,7 +182,7 @@ ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled ConsoleFunction( physicsSetTimeScale, void, 2, 2, "physicsSetTimeScale( F32 scale )" ) { if ( PHYSICSMGR ) - PHYSICSMGR->setTimeScale( dAtof( argv[1] ) ); + PHYSICSMGR->setTimeScale( argv[1] ); } // Get the currently set time scale. @@ -212,5 +212,5 @@ ConsoleFunction( physicsRestoreState, void, 1, 1, "physicsRestoreState()" ) ConsoleFunction( physicsDebugDraw, void, 2, 2, "physicsDebugDraw( bool enable )" ) { if ( PHYSICSMGR ) - PHYSICSMGR->enableDebugDraw( dAtoi( argv[1] ) ); -} \ No newline at end of file + PHYSICSMGR->enableDebugDraw( (S32)argv[1] ); +} diff --git a/Engine/source/app/net/net.cpp b/Engine/source/app/net/net.cpp index d24e698d4..6166f981e 100644 --- a/Engine/source/app/net/net.cpp +++ b/Engine/source/app/net/net.cpp @@ -307,7 +307,7 @@ ConsoleFunction( addTaggedString, const char*, 2, 2, "(string str)" "@see getTaggedString()\n" "@ingroup Networking\n") { - NetStringHandle s(argv[1]); + NetStringHandle s((const char*)argv[1]); gNetStringTable->incStringRefScript(s.getIndex()); char *ret = Con::getReturnBuffer(10); diff --git a/Engine/source/component/dynamicConsoleMethodComponent.cpp b/Engine/source/component/dynamicConsoleMethodComponent.cpp index c0a971405..f889b5c39 100644 --- a/Engine/source/component/dynamicConsoleMethodComponent.cpp +++ b/Engine/source/component/dynamicConsoleMethodComponent.cpp @@ -21,6 +21,10 @@ //----------------------------------------------------------------------------- #include "component/dynamicConsoleMethodComponent.h" +#include "console/stringStack.h" + +extern StringStack STR; +extern ConsoleValueStack CSTK; IMPLEMENT_CO_NETOBJECT_V1(DynamicConsoleMethodComponent); @@ -152,23 +156,42 @@ const char *DynamicConsoleMethodComponent::_callMethod( U32 argc, ConsoleValueRe DynamicConsoleMethodComponent *pThisComponent = dynamic_cast( pComponent ); AssertFatal( pThisComponent, "DynamicConsoleMethodComponent::callMethod - Non DynamicConsoleMethodComponent component attempting to callback!"); + // Prevent stack corruption + STR.pushFrame(); + CSTK.pushFrame(); + // -- + // Only call on first depth components // Should isMethod check these calls? [11/22/2006 justind] if(pComponent->isEnabled()) Con::execute( pThisComponent, argc, argv ); + // Prevent stack corruption + STR.popFrame(); + CSTK.popFrame(); + // -- + // Bail if this was the first element //if( nItr == componentList.begin() ) // break; } unlockComponentList(); } + + // Prevent stack corruption + STR.pushFrame(); + CSTK.pushFrame(); + // -- // Set Owner Field const char* result = ""; if(callThis) result = Con::execute( pThis, argc, argv, true ); // true - exec method onThisOnly, not on DCMCs + // Prevent stack corruption + STR.popFrame(); + CSTK.popFrame(); + // -- return result; } diff --git a/Engine/source/component/simComponent.cpp b/Engine/source/component/simComponent.cpp index b1a1cf86d..f4e1f5c67 100644 --- a/Engine/source/component/simComponent.cpp +++ b/Engine/source/component/simComponent.cpp @@ -179,7 +179,7 @@ bool SimComponent::processArguments(S32 argc, ConsoleValueRef *argv) if(obj) addComponent(obj); else - Con::printf("SimComponent::processArguments - Invalid Component Object \"%s\"", argv[i]); + Con::printf("SimComponent::processArguments - Invalid Component Object \"%s\"", (const char*)argv[i]); } return true; } @@ -383,7 +383,7 @@ ConsoleMethod( SimComponent, addComponents, bool, 3, 64, "%obj.addComponents( %c if(obj) object->addComponent(obj); else - Con::printf("SimComponent::addComponents - Invalid Component Object \"%s\"", argv[i]); + Con::printf("SimComponent::addComponents - Invalid Component Object \"%s\"", (const char*)argv[i]); } return true; } @@ -399,7 +399,7 @@ ConsoleMethod( SimComponent, removeComponents, bool, 3, 64, "%obj.removeComponen if(obj) object->removeComponent(obj); else - Con::printf("SimComponent::removeComponents - Invalid Component Object \"%s\"", argv[i]); + Con::printf("SimComponent::removeComponents - Invalid Component Object \"%s\"", (const char*)argv[i]); } return true; } @@ -449,4 +449,4 @@ ConsoleMethod(SimComponent, getIsTemplate, bool, 2, 2, "() Check whether SimComp "@return true if is a template and false if not") { return object->getIsTemplate(); -} \ No newline at end of file +} diff --git a/Engine/source/console/arrayObject.cpp b/Engine/source/console/arrayObject.cpp index 180461cb1..ddcab509f 100644 --- a/Engine/source/console/arrayObject.cpp +++ b/Engine/source/console/arrayObject.cpp @@ -103,10 +103,7 @@ S32 QSORT_CALLBACK ArrayObject::_keyFunctionCompare( const void* a, const void* ArrayObject::Element* ea = ( ArrayObject::Element* )( a ); ArrayObject::Element* eb = ( ArrayObject::Element* )( b ); - const char* argv[ 3 ]; - argv[ 0 ] = smCompareFunction; - argv[ 1 ] = ea->key; - argv[ 2 ] = eb->key; + ConsoleValueRef argv[] = { smCompareFunction, ea->key, eb->key }; S32 result = dAtoi( Con::execute( 3, argv ) ); S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 ); @@ -118,10 +115,7 @@ S32 QSORT_CALLBACK ArrayObject::_valueFunctionCompare( const void* a, const void ArrayObject::Element* ea = ( ArrayObject::Element* )( a ); ArrayObject::Element* eb = ( ArrayObject::Element* )( b ); - const char* argv[ 3 ]; - argv[ 0 ] = smCompareFunction; - argv[ 1 ] = ea->value; - argv[ 2 ] = eb->value; + ConsoleValueRef argv[] = { smCompareFunction, ea->value, eb->value }; S32 result = dAtoi( Con::execute( 3, argv ) ); S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 ); diff --git a/Engine/source/console/astNodes.cpp b/Engine/source/console/astNodes.cpp index ae09abbd2..0d63a6ddb 100644 --- a/Engine/source/console/astNodes.cpp +++ b/Engine/source/console/astNodes.cpp @@ -134,8 +134,8 @@ static U32 conversionOp(TypeReq src, TypeReq dst) return OP_STR_TO_FLT; case TypeReqNone: return OP_STR_TO_NONE; - case TypeReqVar: - return OP_SAVEVAR_STR; + case TypeReqVar: + return OP_SAVEVAR_STR; default: break; } @@ -150,7 +150,7 @@ static U32 conversionOp(TypeReq src, TypeReq dst) return OP_FLT_TO_STR; case TypeReqNone: return OP_FLT_TO_NONE; - case TypeReqVar: + case TypeReqVar: return OP_SAVEVAR_FLT; default: break; @@ -166,7 +166,7 @@ static U32 conversionOp(TypeReq src, TypeReq dst) return OP_UINT_TO_STR; case TypeReqNone: return OP_UINT_TO_NONE; - case TypeReqVar: + case TypeReqVar: return OP_SAVEVAR_UINT; default: break; @@ -276,21 +276,21 @@ U32 ReturnStmtNode::compileStmt(U32 *codeStream, U32 ip, U32, U32) else { TypeReq walkType = expr->getPreferredType(); - if (walkType == TypeReqNone) walkType = TypeReqString; + if (walkType == TypeReqNone) walkType = TypeReqString; ip = expr->compile(codeStream, ip, walkType); - // Return the correct type - switch (walkType) { - case TypeReqUInt: - codeStream[ip++] = OP_RETURN_UINT; - break; - case TypeReqFloat: - codeStream[ip++] = OP_RETURN_FLT; - break; - default: - codeStream[ip++] = OP_RETURN; - break; - } + // Return the correct type + switch (walkType) { + case TypeReqUInt: + codeStream[ip++] = OP_RETURN_UINT; + break; + case TypeReqFloat: + codeStream[ip++] = OP_RETURN_FLT; + break; + default: + codeStream[ip++] = OP_RETURN; + break; + } } return ip; } @@ -1134,12 +1134,18 @@ U32 AssignExprNode::precompile(TypeReq type) subType = expr->getPreferredType(); if(subType == TypeReqNone) subType = type; - if(subType == TypeReqNone) { - // jamesu - what we need to do in this case is turn it into a VarNode reference - if (dynamic_cast(expr) != NULL) { - // Sanity check passed + if(subType == TypeReqNone) + { + // What we need to do in this case is turn it into a VarNode reference. + // Unfortunately other nodes such as field access (SlotAccessNode) + // cannot be optimized in the same manner as all fields are exposed + // and set as strings. + if (dynamic_cast(expr) != NULL) + { subType = TypeReqVar; - } else { + } + else + { subType = TypeReqString; } } @@ -1409,7 +1415,7 @@ U32 FuncCallExprNode::precompile(TypeReq type) precompileIdent(nameSpace); for(ExprNode *walk = args; walk; walk = (ExprNode *) walk->getNext()) { TypeReq walkType = walk->getPreferredType(); - if (walkType == TypeReqNone) walkType = TypeReqString; + if (walkType == TypeReqNone) walkType = TypeReqString; size += walk->precompile(walkType) + 1; } return size + 5; @@ -1421,19 +1427,20 @@ U32 FuncCallExprNode::compile(U32 *codeStream, U32 ip, TypeReq type) for(ExprNode *walk = args; walk; walk = (ExprNode *) walk->getNext()) { TypeReq walkType = walk->getPreferredType(); - if (walkType == TypeReqNone) walkType = TypeReqString; + if (walkType == TypeReqNone) walkType = TypeReqString; ip = walk->compile(codeStream, ip, walkType); - switch (walk->getPreferredType()) { - case TypeReqFloat: - codeStream[ip++] = OP_PUSH_FLT; - break; - case TypeReqUInt: - codeStream[ip++] = OP_PUSH_UINT; - break; - default: - codeStream[ip++] = OP_PUSH; - break; - } + switch (walk->getPreferredType()) + { + case TypeReqFloat: + codeStream[ip++] = OP_PUSH_FLT; + break; + case TypeReqUInt: + codeStream[ip++] = OP_PUSH_UINT; + break; + default: + codeStream[ip++] = OP_PUSH; + break; + } } if(callType == MethodCall || callType == ParentCall) codeStream[ip++] = OP_CALLFUNC; @@ -1806,7 +1813,7 @@ U32 ObjectDeclNode::precompileSubObject(bool) precompileIdent(parentObject); for(ExprNode *exprWalk = argList; exprWalk; exprWalk = (ExprNode *) exprWalk->getNext()) { TypeReq walkType = exprWalk->getPreferredType(); - if (walkType == TypeReqNone) walkType = TypeReqString; + if (walkType == TypeReqNone) walkType = TypeReqString; argSize += exprWalk->precompile(walkType) + 1; } argSize += classNameExpr->precompile(TypeReqString) + 1; @@ -1854,19 +1861,20 @@ U32 ObjectDeclNode::compileSubObject(U32 *codeStream, U32 ip, bool root) for(ExprNode *exprWalk = argList; exprWalk; exprWalk = (ExprNode *) exprWalk->getNext()) { TypeReq walkType = exprWalk->getPreferredType(); - if (walkType == TypeReqNone) walkType = TypeReqString; + if (walkType == TypeReqNone) walkType = TypeReqString; ip = exprWalk->compile(codeStream, ip, walkType); - switch (exprWalk->getPreferredType()) { - case TypeReqFloat: - codeStream[ip++] = OP_PUSH_FLT; - break; - case TypeReqUInt: - codeStream[ip++] = OP_PUSH_UINT; - break; - default: - codeStream[ip++] = OP_PUSH; - break; - } + switch (exprWalk->getPreferredType()) + { + case TypeReqFloat: + codeStream[ip++] = OP_PUSH_FLT; + break; + case TypeReqUInt: + codeStream[ip++] = OP_PUSH_UINT; + break; + default: + codeStream[ip++] = OP_PUSH; + break; + } } codeStream[ip++] = OP_CREATE_OBJECT; codeStream[ip] = STEtoU32(parentObject, ip); diff --git a/Engine/source/console/compiledEval.cpp b/Engine/source/console/compiledEval.cpp index 612ddad12..5946d2445 100644 --- a/Engine/source/console/compiledEval.cpp +++ b/Engine/source/console/compiledEval.cpp @@ -192,18 +192,16 @@ namespace Con return STR.getArgBuffer(bufferSize); } - char *getFloatArg(F64 arg) + ConsoleValueRef getFloatArg(F64 arg) { - char *ret = STR.getArgBuffer(32); - dSprintf(ret, 32, "%g", arg); - return ret; + ConsoleValueRef ref = arg; + return ref; } - char *getIntArg(S32 arg) + ConsoleValueRef getIntArg(S32 arg) { - char *ret = STR.getArgBuffer(32); - dSprintf(ret, 32, "%d", arg); - return ret; + ConsoleValueRef ref = arg; + return ref; } char *getStringArg( const char *arg ) @@ -287,7 +285,8 @@ inline void ExprEvalState::setStringVariable(const char *val) inline void ExprEvalState::setCopyVariable() { - if (copyVariable) { + if (copyVariable) + { switch (copyVariable->value.type) { case ConsoleValue::TypeInternalInt: @@ -485,16 +484,16 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi StringTableEntry var = U32toSTE(code[ip + i + 6]); gEvalState.setCurVarNameCreate(var); - ConsoleValueRef ref = argv[i+1]; + ConsoleValueRef ref = argv[i+1]; - if (argv[i+1].isString()) - gEvalState.setStringVariable(argv[i+1]); - else if (argv[i+1].isInt()) - gEvalState.setIntVariable(argv[i+1]); - else if (argv[i+1].isFloat()) - gEvalState.setFloatVariable(argv[i+1]); - else - gEvalState.setStringVariable(argv[i+1]); + if (argv[i+1].isString()) + gEvalState.setStringVariable(argv[i+1]); + else if (argv[i+1].isInt()) + gEvalState.setIntVariable(argv[i+1]); + else if (argv[i+1].isFloat()) + gEvalState.setFloatVariable(argv[i+1]); + else + gEvalState.setStringVariable(argv[i+1]); } ip = ip + fnArgc + 6; curFloatTable = functionFloats; @@ -531,9 +530,8 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi } } - // jamesu - reset the console stack frame which at this point will contain + // Reset the console stack frame which at this point will contain // either nothing or argv[] which we just copied - // NOTE: it might be better to do this when we are finished? CSTK.resetFrame(); // Grab the state of the telenet debugger here once @@ -584,7 +582,7 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi const char * val; const char *retValue; - // note: anything returned is pushed to CSTK and will be invalidated on the next exec() + // note: anything returned is pushed to CSTK and will be invalidated on the next exec() ConsoleValueRef returnValue; // The frame temp is used by the variable accessor ops (OP_SAVEFIELD_* and @@ -681,7 +679,7 @@ breakContinue: Con::errorf(ConsoleLogEntry::General, "%s: Cannot re-declare data block %s with a different class.", getFileLine(ip), objectName); ip = failJump; STR.popFrame(); - CSTK.popFrame(); + CSTK.popFrame(); break; } @@ -730,18 +728,18 @@ breakContinue: } //dMemcpy( savedArgv, callArgv, sizeof( savedArgv[ 0 ] ) * callArgc ); - // Prevent stack value corruption - CSTK.pushFrame(); - STR.pushFrame(); - // -- + // Prevent stack value corruption + CSTK.pushFrame(); + STR.pushFrame(); + // -- obj->deleteObject(); obj = NULL; - // Prevent stack value corruption - CSTK.popFrame(); - STR.popFrame(); - // -- + // Prevent stack value corruption + CSTK.popFrame(); + STR.popFrame(); + // -- //dMemcpy( callArgv, savedArgv, sizeof( callArgv[ 0 ] ) * callArgc ); for (int i=0; isetOriginalName( objectName ); } - // Prevent stack value corruption - CSTK.pushFrame(); - STR.pushFrame(); - // -- + // Prevent stack value corruption + CSTK.pushFrame(); + STR.pushFrame(); + // -- // Do the constructor parameters. if(!currentNewObject->processArguments(callArgc-3, callArgv+3)) @@ -1041,10 +1039,10 @@ breakContinue: else intStack[++_UINT] = currentNewObject->getId(); - // Prevent stack value corruption - CSTK.popFrame(); - STR.popFrame(); - // -- + // Prevent stack value corruption + CSTK.popFrame(); + STR.popFrame(); + // -- break; } @@ -1127,7 +1125,7 @@ breakContinue: // We're falling thru here on purpose. case OP_RETURN: - retValue = STR.getStringValue(); + retValue = STR.getStringValue(); if( iterDepth > 0 ) { @@ -1140,12 +1138,12 @@ breakContinue: STR.rewind(); STR.setStringValue( retValue ); // Not nice but works. - retValue = STR.getStringValue(); + retValue = STR.getStringValue(); } - // Previously the return value was on the stack and would be returned using STR.getStringValue(). - // Now though we need to wrap it in a ConsoleValueRef - returnValue.value = CSTK.pushStackString(retValue); + // Previously the return value was on the stack and would be returned using STR.getStringValue(). + // Now though we need to wrap it in a ConsoleValueRef + returnValue.value = CSTK.pushStackString(retValue); goto execFinished; @@ -1179,8 +1177,8 @@ breakContinue: } } - returnValue.value = CSTK.pushUINT(intStack[_UINT]); - _UINT--; + returnValue.value = CSTK.pushUINT(intStack[_UINT]); + _UINT--; goto execFinished; @@ -1323,7 +1321,7 @@ breakContinue: var = U32toSTE(code[ip]); ip++; - // See OP_SETCURVAR + // See OP_SETCURVAR prevField = NULL; prevObject = NULL; curObject = NULL; @@ -1398,7 +1396,7 @@ breakContinue: break; case OP_SAVEVAR_VAR: - // this basically handles %var1 = %var2 + // this basically handles %var1 = %var2 gEvalState.setCopyVariable(); break; @@ -1589,7 +1587,6 @@ breakContinue: break; case OP_COPYVAR_TO_NONE: - // nop gEvalState.copyVariable = NULL; break; @@ -1668,7 +1665,7 @@ breakContinue: getFileLine(ip-4), fnNamespace ? fnNamespace : "", fnNamespace ? "::" : "", fnName); STR.popFrame(); - CSTK.popFrame(); + CSTK.popFrame(); break; } // Now fall through to OP_CALLFUNC... @@ -1718,7 +1715,7 @@ breakContinue: Con::warnf(ConsoleLogEntry::General,"%s: Unable to find object: '%s' attempting to call function '%s'", getFileLine(ip-4), (const char*)callArgv[1], fnName); STR.popFrame(); - CSTK.popFrame(); + CSTK.popFrame(); break; } @@ -1774,7 +1771,7 @@ breakContinue: } } STR.popFrame(); - CSTK.popFrame(); + CSTK.popFrame(); if( routingId == MethodOnComponent ) STR.setStringValue( componentReturnValue ); @@ -1789,9 +1786,9 @@ breakContinue: if(nsEntry->mFunctionOffset) ret = nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage); - STR.popFrame(); - // Functions are assumed to return strings, so look ahead to see if we can skip the conversion - if(code[ip] == OP_STR_TO_UINT) + STR.popFrame(); + // Functions are assumed to return strings, so look ahead to see if we can skip the conversion + if(code[ip] == OP_STR_TO_UINT) { ip++; intStack[++_UINT] = (U32)((S32)ret); @@ -1806,9 +1803,9 @@ breakContinue: else STR.setStringValue((const char*)ret); - // This will clear everything including returnValue - CSTK.popFrame(); - STR.clearFunctionOffset(); + // This will clear everything including returnValue + CSTK.popFrame(); + STR.clearFunctionOffset(); } else { @@ -1829,7 +1826,7 @@ breakContinue: callArgc, nsEntry->mMinArgs, nsEntry->mMaxArgs); Con::warnf(ConsoleLogEntry::Script, "%s: usage: %s", getFileLine(ip-4), nsEntry->mUsage); STR.popFrame(); - CSTK.popFrame(); + CSTK.popFrame(); } else { @@ -1839,7 +1836,7 @@ breakContinue: { const char *ret = nsEntry->cb.mStringCallbackFunc(gEvalState.thisObject, callArgc, callArgv); STR.popFrame(); - CSTK.popFrame(); + CSTK.popFrame(); if(ret != STR.getStringValue()) STR.setStringValue(ret); //else @@ -1850,7 +1847,7 @@ breakContinue: { S32 result = nsEntry->cb.mIntCallbackFunc(gEvalState.thisObject, callArgc, callArgv); STR.popFrame(); - CSTK.popFrame(); + CSTK.popFrame(); if(code[ip] == OP_STR_TO_UINT) { ip++; @@ -1873,7 +1870,7 @@ breakContinue: { F64 result = nsEntry->cb.mFloatCallbackFunc(gEvalState.thisObject, callArgc, callArgv); STR.popFrame(); - CSTK.popFrame(); + CSTK.popFrame(); if(code[ip] == OP_STR_TO_UINT) { ip++; @@ -1898,14 +1895,14 @@ breakContinue: Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", getFileLine(ip-4), fnName, functionName); STR.popFrame(); - CSTK.popFrame(); + CSTK.popFrame(); STR.setStringValue(""); break; case Namespace::Entry::BoolCallbackType: { bool result = nsEntry->cb.mBoolCallbackFunc(gEvalState.thisObject, callArgc, callArgv); STR.popFrame(); - CSTK.popFrame(); + CSTK.popFrame(); if(code[ip] == OP_STR_TO_UINT) { ip++; @@ -1959,31 +1956,27 @@ breakContinue: intStack[++_UINT] = STR.compare(); break; case OP_PUSH: - STR.push(); - //Con::printf("Pushing str: %s",STR.getPreviousStringValue()); + STR.push(); CSTK.pushString(STR.getPreviousStringValue()); break; case OP_PUSH_UINT: - //Con::printf("Pushing int: %i",(S32)intStack[_UINT]); CSTK.pushUINT(intStack[_UINT]); - _UINT--; + _UINT--; break; case OP_PUSH_FLT: - //Con::printf("Pushing float: %f",(F32)intStack[_UINT]); CSTK.pushFLT(floatStack[_FLT]); - _FLT--; + _FLT--; break; case OP_PUSH_VAR: - //Con::printf("Pushing variable: %s",gEvalState.getCurrentVariable()]); if (gEvalState.currentVariable) - CSTK.pushValue(gEvalState.currentVariable->value); - else - CSTK.pushString(""); + CSTK.pushValue(gEvalState.currentVariable->value); + else + CSTK.pushString(""); break; case OP_PUSH_FRAME: STR.pushFrame(); - CSTK.pushFrame(); + CSTK.pushFrame(); break; case OP_ASSERT: @@ -2162,9 +2155,8 @@ execFinished: if ( telDebuggerOn && setFrame < 0 ) TelDebugger->popStackFrame(); - if ( popFrame ) { + if ( popFrame ) gEvalState.popFrame(); - } if(argv) { diff --git a/Engine/source/console/compiler.h b/Engine/source/console/compiler.h index 150b92b2e..1873d704d 100644 --- a/Engine/source/console/compiler.h +++ b/Engine/source/console/compiler.h @@ -54,8 +54,8 @@ namespace Compiler OP_RETURN, // fixes a bug when not explicitly returning a value OP_RETURN_VOID, - OP_RETURN_FLT, - OP_RETURN_UINT, + OP_RETURN_FLT, + OP_RETURN_UINT, OP_CMPEQ, OP_CMPGR, diff --git a/Engine/source/console/console.cpp b/Engine/source/console/console.cpp index efe658db6..8ef659891 100644 --- a/Engine/source/console/console.cpp +++ b/Engine/source/console/console.cpp @@ -745,9 +745,9 @@ bool getVariableObjectField(const char *name, SimObject **object, const char **f } else { - *object = obj; - *field = fieldToken; - return true; + *object = obj; + *field = fieldToken; + return true; } } } @@ -778,9 +778,8 @@ Dictionary::Entry *getAddVariableEntry(const char *name) name = prependDollar(name); StringTableEntry stName = StringTable->insert(name); Dictionary::Entry *entry = gEvalState.globalVars.lookup(stName); - if (!entry) { + if (!entry) entry = gEvalState.globalVars.add(stName); - } return entry; } @@ -789,9 +788,8 @@ Dictionary::Entry *getAddLocalVariableEntry(const char *name) name = prependPercent(name); StringTableEntry stName = StringTable->insert(name); Dictionary::Entry *entry = gEvalState.getCurrentFrame().lookup(stName); - if (!entry) { + if (!entry) entry = gEvalState.getCurrentFrame().add(stName); - } return entry; } @@ -800,9 +798,12 @@ void setVariable(const char *name, const char *value) SimObject *obj = NULL; const char *objField = NULL; - if (getVariableObjectField(name, &obj, &objField)) { + if (getVariableObjectField(name, &obj, &objField)) + { obj->setDataField(StringTable->insert(objField), 0, value); - } else { + } + else + { name = prependDollar(name); gEvalState.globalVars.setVariable(StringTable->insert(name), value); } @@ -819,9 +820,12 @@ void setBoolVariable(const char *varName, bool value) SimObject *obj = NULL; const char *objField = NULL; - if (getVariableObjectField(varName, &obj, &objField)) { + if (getVariableObjectField(varName, &obj, &objField)) + { obj->setDataField(StringTable->insert(objField), 0, value ? "1" : "0"); - } else { + } + else + { varName = prependDollar(varName); Dictionary::Entry *entry = getAddVariableEntry(varName); entry->setStringValue(value ? "1" : "0"); @@ -833,11 +837,14 @@ void setIntVariable(const char *varName, S32 value) SimObject *obj = NULL; const char *objField = NULL; - if (getVariableObjectField(varName, &obj, &objField)) { + if (getVariableObjectField(varName, &obj, &objField)) + { char scratchBuffer[32]; dSprintf(scratchBuffer, sizeof(scratchBuffer), "%d", value); obj->setDataField(StringTable->insert(objField), 0, scratchBuffer); - } else { + } + else + { varName = prependDollar(varName); Dictionary::Entry *entry = getAddVariableEntry(varName); entry->setIntValue(value); @@ -849,11 +856,14 @@ void setFloatVariable(const char *varName, F32 value) SimObject *obj = NULL; const char *objField = NULL; - if (getVariableObjectField(varName, &obj, &objField)) { + if (getVariableObjectField(varName, &obj, &objField)) + { char scratchBuffer[32]; dSprintf(scratchBuffer, sizeof(scratchBuffer), "%g", value); obj->setDataField(StringTable->insert(objField), 0, scratchBuffer); - } else { + } + else + { varName = prependDollar(varName); Dictionary::Entry *entry = getAddVariableEntry(varName); entry->setFloatValue(value); @@ -951,11 +961,14 @@ const char *getObjectTokenField(const char *name) const char *getVariable(const char *name) { const char *objField = getObjectTokenField(name); - if (objField) { + if (objField) + { return objField; - } else { + } + else + { Dictionary::Entry *entry = getVariableEntry(name); - return entry ? entry->getStringValue() : ""; + return entry ? entry->getStringValue() : ""; } } @@ -969,11 +982,14 @@ const char *getLocalVariable(const char *name) bool getBoolVariable(const char *varName, bool def) { const char *objField = getObjectTokenField(varName); - if (objField) { + if (objField) + { return *objField ? dAtob(objField) : def; - } else { + } + else + { Dictionary::Entry *entry = getVariableEntry(varName); - objField = entry ? entry->getStringValue() : ""; + objField = entry ? entry->getStringValue() : ""; return *objField ? dAtob(objField) : def; } } @@ -981,22 +997,28 @@ bool getBoolVariable(const char *varName, bool def) S32 getIntVariable(const char *varName, S32 def) { const char *objField = getObjectTokenField(varName); - if (objField) { + if (objField) + { return *objField ? dAtoi(objField) : def; - } else { + } + else + { Dictionary::Entry *entry = getVariableEntry(varName); - return entry ? entry->getIntValue() : def; + return entry ? entry->getIntValue() : def; } } F32 getFloatVariable(const char *varName, F32 def) { const char *objField = getObjectTokenField(varName); - if (objField) { + if (objField) + { return *objField ? dAtof(objField) : def; - } else { + } + else + { Dictionary::Entry *entry = getVariableEntry(varName); - return entry ? entry->getFloatValue() : def; + return entry ? entry->getFloatValue() : def; } } @@ -1154,11 +1176,11 @@ const char *execute(S32 argc, ConsoleValueRef argv[]) if(!ent) { - warnf(ConsoleLogEntry::Script, "%s: Unknown command.", argv[0]); + warnf(ConsoleLogEntry::Script, "%s: Unknown command.", (const char*)argv[0]); // Clean up arg buffers, if any. STR.clearFunctionOffset(); - CSTK.resetFrame(); + CSTK.resetFrame(); return ""; } return ent->execute(argc, argv, &gEvalState); @@ -1184,7 +1206,6 @@ const char *execute(S32 argc, const char *argv[]) //------------------------------------------------------------------------------ const char *execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool thisCallOnly) { - //static char idBuf[16]; if(argc < 2) return ""; @@ -1194,13 +1215,14 @@ const char *execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool th if( !thisCallOnly ) { ICallMethod *com = dynamic_cast(object); - if(com) { + if(com) + { STR.pushFrame(); CSTK.pushFrame(); com->callMethodArgList(argc, argv, false); STR.popFrame(); CSTK.popFrame(); - } + } } if(object->getNamespace()) @@ -1218,14 +1240,13 @@ const char *execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool th //warnf(ConsoleLogEntry::Script, "%s: undefined for object '%s' - id %d", funcName, object->getName(), object->getId()); // Clean up arg buffers, if any. - //CSTK. STR.clearFunctionOffset(); - CSTK.resetFrame(); + CSTK.resetFrame(); return ""; } // Twiddle %this argument - argv[1] = (S32)ident; + argv[1] = (S32)ident; SimObject *save = gEvalState.thisObject; gEvalState.thisObject = object; @@ -1237,7 +1258,7 @@ const char *execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool th return ret; } - warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), argv[0]); + warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), (const char*)argv[0]); return ""; } @@ -1252,7 +1273,7 @@ inline const char*_executef(SimObject *obj, S32 checkArgc, S32 argc, ConsoleValu const U32 maxArg = 12; AssertWarn(checkArgc == argc, "Incorrect arg count passed to Con::executef(SimObject*)"); AssertFatal(argc <= maxArg - 1, "Too many args passed to Con::_executef(SimObject*). Please update the function to handle more."); - return execute(obj, argc, argv); // jamesu - argc should == argc + return execute(obj, argc, argv); } #define A ConsoleValueRef @@ -1589,14 +1610,16 @@ StringStackWrapper::StringStackWrapper(int targc, ConsoleValueRef targv[]) argv = new const char*[targc]; argc = targc; - for (int i=0; i(val); - if(sval != typeValueEmpty) - { - if (type != TypeInternalStackString) dFree(sval); - sval = typeValueEmpty; - } - type = TypeInternalFloat; - } - else - { - const char *dptr = Con::getData(TypeF32, &val, 0); - Con::setData(type, dataPtr, 0, 1, &dptr, enumTable); - } + const char *dptr = Con::getData(TypeS32, &val, 0); + Con::setData(type, dataPtr, 0, 1, &dptr, enumTable); } +} + +void ConsoleValue::setFloatValue(F32 val) +{ + if(type <= TypeInternalString) + { + fval = val; + ival = static_cast(val); + if(sval != typeValueEmpty) + { + if (type != TypeInternalStackString) dFree(sval); + sval = typeValueEmpty; + } + type = TypeInternalFloat; + } + else + { + const char *dptr = Con::getData(TypeF32, &val, 0); + Con::setData(type, dataPtr, 0, 1, &dptr, enumTable); + } +} - const char *ConsoleValueRef::getStringArgValue() +const char *ConsoleValueRef::getStringArgValue() +{ + if (value) { - if (value) { - if (stringStackValue == NULL) { - stringStackValue = Con::getStringArg(value->getStringValue()); - } - return stringStackValue; - } else { - return ""; - } + if (stringStackValue == NULL) + stringStackValue = Con::getStringArg(value->getStringValue()); + return stringStackValue; } + else + { + return ""; + } +} extern ConsoleValueStack CSTK; @@ -1748,4 +1774,4 @@ namespace Con { CSTK.resetFrame(); } -} \ No newline at end of file +} diff --git a/Engine/source/console/console.h b/Engine/source/console/console.h index 8e2802d48..2783a048f 100644 --- a/Engine/source/console/console.h +++ b/Engine/source/console/console.h @@ -123,7 +123,7 @@ public: { TypeInternalInt = -4, TypeInternalFloat = -3, - TypeInternalStackString = -2, + TypeInternalStackString = -2, TypeInternalString = -1, }; @@ -197,9 +197,10 @@ public: }; // Proxy class for console variables -// Can point to existing console variables -// or act like a free floating value -class ConsoleValueRef { +// Can point to existing console variables, +// or act like a free floating value. +class ConsoleValueRef +{ public: ConsoleValue *value; const char *stringStackValue; @@ -219,13 +220,11 @@ public: inline S32 getIntValue() { return value ? value->getIntValue() : 0; } inline F32 getFloatValue() { return value ? value->getFloatValue() : 0.0f; } - //inline F64 getDoubleValue() { return value ? value->getDoubleValue() : 0.0; } inline operator const char*() { return getStringValue(); } inline operator String() { return String(getStringValue()); } inline operator S32() { return getIntValue(); } inline operator F32() { return getFloatValue(); } - //inline operator F64() { return getDoubleValue(); } inline bool isString() { return value ? value->type >= ConsoleValue::TypeInternalStackString : true; } inline bool isInt() { return value ? value->type == ConsoleValue::TypeInternalInt : false; } @@ -239,6 +238,19 @@ public: ConsoleValueRef& operator=(F64 newValue); }; +// Overrides to allow ConsoleValueRefs to be directly converted to S32&F32 + +inline S32 dAtoi(ConsoleValueRef &ref) +{ + return ref.getIntValue(); +} + +inline F32 dAtof(ConsoleValueRef &ref) +{ + return ref.getFloatValue(); +} + + // Transparently converts ConsoleValue[] to const char** class StringStackWrapper { @@ -342,6 +354,7 @@ namespace Con /// 09/12/07 - CAF - 43->44 remove newmsg operator /// 09/27/07 - RDB - 44->45 Patch from Andreas Kirsch: Added opcode to support correct void return /// 01/13/09 - TMS - 45->46 Added script assert + /// 10/11/12 - JU - 46->47 Added opcodes to reduce reliance on strings in function calls DSOVersion = 47, MaxLineLength = 512, ///< Maximum length of a line of console input. @@ -807,8 +820,8 @@ namespace Con char* getReturnBuffer( const StringBuilder& str ); char* getArgBuffer(U32 bufferSize); - char* getFloatArg(F64 arg); - char* getIntArg (S32 arg); + ConsoleValueRef getFloatArg(F64 arg); + ConsoleValueRef getIntArg (S32 arg); char* getStringArg( const char *arg ); char* getStringArg( const String& arg ); /// @} diff --git a/Engine/source/console/consoleFunctions.cpp b/Engine/source/console/consoleFunctions.cpp index bc3870cec..9e5208375 100644 --- a/Engine/source/console/consoleFunctions.cpp +++ b/Engine/source/console/consoleFunctions.cpp @@ -1306,7 +1306,7 @@ ConsoleFunction(getTag, const char *, 2, 2, "(string textTagString)" TORQUE_UNUSED(argc); if(argv[1][0] == StringTagPrefixByte) { - const char *arg = argv[1]; + const char *arg = argv[1]; const char * space = dStrchr(argv[1], ' '); U32 len; @@ -2364,7 +2364,7 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)" if (dStrcmp(argv[1], "0") && dStrcmp(argv[1], "") && (Sim::findObject(argv[1]) != NULL)) return true; else if (argc > 2) - Con::errorf("%s() - can't assign a value to a variable of the form \"%s\"", __FUNCTION__, argv[1]); + Con::errorf("%s() - can't assign a value to a variable of the form \"%s\"", __FUNCTION__, (const char*)argv[1]); } return false; @@ -2419,7 +2419,7 @@ ConsoleFunction(getPrefsPath, const char *, 1, 2, "([relativeFileName])" "@note Appears to be useless in Torque 3D, should be deprecated\n" "@internal") { - const char *filename = Platform::getPrefsPath(argc > 1 ? argv[1] : NULL); + const char *filename = Platform::getPrefsPath(argc > 1 ? (const char*)argv[1] : NULL); if(filename == NULL || *filename == 0) return ""; diff --git a/Engine/source/console/consoleInternal.cpp b/Engine/source/console/consoleInternal.cpp index 208c998cc..c8c497515 100644 --- a/Engine/source/console/consoleInternal.cpp +++ b/Engine/source/console/consoleInternal.cpp @@ -34,45 +34,6 @@ //#define DEBUG_SPEW - -Dictionary::Entry smLocalDictionaryEntryStack[4096*4]; -Dictionary::Entry *smLocalDictionaryEntryStackHead = NULL; - -void setupDictionaryStack() -{ - smLocalDictionaryEntryStackHead = &smLocalDictionaryEntryStack[0]; - - for (int i=0; i<4096*4; i++) { - (smLocalDictionaryEntryStackHead + i)->mNext = i == (4096*4)-1 ? NULL : smLocalDictionaryEntryStackHead + (i+1); - } -} - -Dictionary::Entry * getDictionaryStackEntry() -{ - Dictionary::Entry *entry = smLocalDictionaryEntryStackHead; - AssertFatal(entry, "No more local variables"); - - entry->reset(); - - Dictionary::Entry *next = entry->mNext; - - smLocalDictionaryEntryStackHead = next; - - entry->mNext = NULL; - - return entry; -} - -void disposeDictionaryStackEntry(Dictionary::Entry *entry) -{ - Dictionary::Entry *prevHead = smLocalDictionaryEntryStackHead; - smLocalDictionaryEntryStackHead = entry; - - smLocalDictionaryEntryStackHead->mNext = prevHead; -} - - - #define ST_INIT_SIZE 15 static char scratchBuffer[1024]; @@ -325,10 +286,8 @@ Dictionary::Entry *Dictionary::add(StringTableEntry name) //printf("Add Variable %s\n", name); Entry* ret = lookup( name ); - if( ret ) { - //printf("Found Variable %s (named %s)\n", name, ret->name); + if( ret ) return ret; - } // Rehash if the table get's too crowded. Be aware that this might // modify a table that we don't own. @@ -337,7 +296,6 @@ Dictionary::Entry *Dictionary::add(StringTableEntry name) if( hashTable->count > hashTable->size * 2 ) { // Allocate a new table. - printf("Re-hashing dictionary...\n"); const U32 newTableSize = hashTable->size * 4 - 1; Entry** newTableData = new Entry*[ newTableSize ]; @@ -351,9 +309,6 @@ Dictionary::Entry *Dictionary::add(StringTableEntry name) Entry* next = entry->nextEntry; U32 index = HashPointer( entry->name ) % newTableSize; - - //printf(" Variable(%s) in bucket %i moved to bucket %i\n", entry->name, i, index); - entry->nextEntry = newTableData[ index ]; newTableData[ index ] = entry; @@ -373,9 +328,8 @@ Dictionary::Entry *Dictionary::add(StringTableEntry name) // Add the new entry. - ret = getDictionaryStackEntry();//hashTable->mChunker.alloc(); - ret->name = name; - //constructInPlace( ret, name ); + ret = hashTable->mChunker.alloc(); + constructInPlace( ret, name ); U32 idx = HashPointer(name) % hashTable->size; ret->nextEntry = hashTable->data[idx]; hashTable->data[idx] = ret; @@ -396,8 +350,8 @@ void Dictionary::remove(Dictionary::Entry *ent) *walk = (ent->nextEntry); - disposeDictionaryStackEntry( ent ); - //hashTable->mChunker.free( ent ); + destructInPlace( ent ); + hashTable->mChunker.free( ent ); hashTable->count--; } @@ -458,13 +412,13 @@ void Dictionary::reset() while( walk ) { Entry* temp = walk->nextEntry; - disposeDictionaryStackEntry( walk ); + destructInPlace( walk ); walk = temp; } } dMemset( ownHashTable.data, 0, ownHashTable.size * sizeof( Entry* ) ); - //ownHashTable.mChunker.freeBlocks( true ); + ownHashTable.mChunker.freeBlocks( true ); ownHashTable.count = 0; hashTable = NULL; @@ -556,15 +510,16 @@ void ConsoleValue::setStringValue(const char * value) return; } */ - if (value == typeValueEmpty) { - if (sval && sval != typeValueEmpty && type != TypeInternalStackString) dFree(sval); - sval = typeValueEmpty; - bufferLen = 0; - fval = 0.f; - ival = 0; - type = TypeInternalString; - return; - } + if (value == typeValueEmpty) + { + if (sval && sval != typeValueEmpty && type != TypeInternalStackString) dFree(sval); + sval = typeValueEmpty; + bufferLen = 0; + fval = 0.f; + ival = 0; + type = TypeInternalString; + return; + } U32 stringLen = dStrlen(value); @@ -586,7 +541,7 @@ void ConsoleValue::setStringValue(const char * value) // may as well pad to the next cache line U32 newLen = ((stringLen + 1) + 15) & ~15; - if(sval == typeValueEmpty || type == TypeInternalStackString) + if(sval == typeValueEmpty || type == TypeInternalStackString) sval = (char *) dMalloc(newLen); else if(newLen > bufferLen) sval = (char *) dRealloc(sval, newLen); @@ -607,15 +562,16 @@ void ConsoleValue::setStackStringValue(const char * value) if(type <= ConsoleValue::TypeInternalString) { - if (value == typeValueEmpty) { - if (sval && sval != typeValueEmpty && type != ConsoleValue::TypeInternalStackString) dFree(sval); - sval = typeValueEmpty; - bufferLen = 0; + if (value == typeValueEmpty) + { + if (sval && sval != typeValueEmpty && type != ConsoleValue::TypeInternalStackString) dFree(sval); + sval = typeValueEmpty; + bufferLen = 0; fval = 0.f; ival = 0; - type = TypeInternalString; - return; - } + type = TypeInternalString; + return; + } U32 stringLen = dStrlen(value); if(stringLen < 256) @@ -640,32 +596,34 @@ void ConsoleValue::setStackStringValue(const char * value) S32 Dictionary::getIntVariable(StringTableEntry name, bool *entValid) { - Entry *ent = lookup(name); - if(ent) - { - if(entValid) - *entValid = true; - return ent->getIntValue(); - } - if(entValid) - *entValid = false; + Entry *ent = lookup(name); + if(ent) + { + if(entValid) + *entValid = true; + return ent->getIntValue(); + } + + if(entValid) + *entValid = false; return 0; } F32 Dictionary::getFloatVariable(StringTableEntry name, bool *entValid) { - Entry *ent = lookup(name); - if(ent) - { - if(entValid) - *entValid = true; - return ent->getFloatValue(); - } - if(entValid) - *entValid = false; + Entry *ent = lookup(name); + if(ent) + { + if(entValid) + *entValid = true; + return ent->getFloatValue(); + } - return 0; + if(entValid) + *entValid = false; + + return 0; } void Dictionary::setVariable(StringTableEntry name, const char *value) @@ -726,7 +684,7 @@ void Dictionary::addVariableNotify( const char *name, const Con::NotifyDelegate return; if ( !ent->notify ) - ent->notify = new Entry::NotifySignal(); + ent->notify = new Entry::NotifySignal(); ent->notify->notify( callback ); } @@ -1141,8 +1099,6 @@ void Namespace::init() mGlobalNamespace->mName = NULL; mGlobalNamespace->mNext = NULL; mNamespaceList = mGlobalNamespace; - - setupDictionaryStack(); } Namespace *Namespace::global() diff --git a/Engine/source/console/consoleInternal.h b/Engine/source/console/consoleInternal.h index da465d74f..e6dd6b99d 100644 --- a/Engine/source/console/consoleInternal.h +++ b/Engine/source/console/consoleInternal.h @@ -384,138 +384,138 @@ public: } }; - struct HashTableData - { - Dictionary* owner; - S32 size; - S32 count; - Entry **data; - FreeListChunker< Entry > mChunker; - - HashTableData( Dictionary* owner ) - : owner( owner ), size( 0 ), count( 0 ), data( NULL ) {} - }; + struct HashTableData + { + Dictionary* owner; + S32 size; + S32 count; + Entry **data; + FreeListChunker< Entry > mChunker; + + HashTableData( Dictionary* owner ) + : owner( owner ), size( 0 ), count( 0 ), data( NULL ) {} + }; - HashTableData* hashTable; - HashTableData ownHashTable; - ExprEvalState *exprState; - - StringTableEntry scopeName; - Namespace *scopeNamespace; - CodeBlock *code; - U32 ip; + HashTableData* hashTable; + HashTableData ownHashTable; + ExprEvalState *exprState; - Dictionary(); - ~Dictionary(); + StringTableEntry scopeName; + Namespace *scopeNamespace; + CodeBlock *code; + U32 ip; - Entry *lookup(StringTableEntry name); - Entry *add(StringTableEntry name); - void setState(ExprEvalState *state, Dictionary* ref=NULL); - void remove(Entry *); - void reset(); + Dictionary(); + ~Dictionary(); - void exportVariables( const char *varString, const char *fileName, bool append ); - void exportVariables( const char *varString, Vector *names, Vector *values ); - void deleteVariables( const char *varString ); + Entry *lookup(StringTableEntry name); + Entry *add(StringTableEntry name); + void setState(ExprEvalState *state, Dictionary* ref=NULL); + void remove(Entry *); + void reset(); - void setVariable(StringTableEntry name, const char *value); - const char *getVariable(StringTableEntry name, bool *valid = NULL); - S32 getIntVariable(StringTableEntry name, bool *valid = NULL); - F32 getFloatVariable(StringTableEntry name, bool *entValid = NULL); - - U32 getCount() const - { + void exportVariables( const char *varString, const char *fileName, bool append ); + void exportVariables( const char *varString, Vector *names, Vector *values ); + void deleteVariables( const char *varString ); + + void setVariable(StringTableEntry name, const char *value); + const char *getVariable(StringTableEntry name, bool *valid = NULL); + S32 getIntVariable(StringTableEntry name, bool *valid = NULL); + F32 getFloatVariable(StringTableEntry name, bool *entValid = NULL); + + U32 getCount() const + { return hashTable->count; - } - bool isOwner() const - { + } + bool isOwner() const + { return hashTable->owner; - } + } - /// @see Con::addVariable - Entry* addVariable( const char *name, - S32 type, - void *dataPtr, - const char* usage ); + /// @see Con::addVariable + Entry* addVariable( const char *name, + S32 type, + void *dataPtr, + const char* usage ); - /// @see Con::removeVariable - bool removeVariable(StringTableEntry name); + /// @see Con::removeVariable + bool removeVariable(StringTableEntry name); - /// @see Con::addVariableNotify - void addVariableNotify( const char *name, const Con::NotifyDelegate &callback ); + /// @see Con::addVariableNotify + void addVariableNotify( const char *name, const Con::NotifyDelegate &callback ); - /// @see Con::removeVariableNotify - void removeVariableNotify( const char *name, const Con::NotifyDelegate &callback ); + /// @see Con::removeVariableNotify + void removeVariableNotify( const char *name, const Con::NotifyDelegate &callback ); - /// Return the best tab completion for prevText, with the length - /// of the pre-tab string in baseLen. - const char *tabComplete(const char *prevText, S32 baseLen, bool); - - /// Run integrity checks for debugging. - void validate(); + /// Return the best tab completion for prevText, with the length + /// of the pre-tab string in baseLen. + const char *tabComplete(const char *prevText, S32 baseLen, bool); + + /// Run integrity checks for debugging. + void validate(); }; class ExprEvalState { public: - /// @name Expression Evaluation - /// @{ + /// @name Expression Evaluation + /// @{ - /// - SimObject *thisObject; - Dictionary::Entry *currentVariable; - Dictionary::Entry *copyVariable; - bool traceOn; - - U32 mStackDepth; + /// + SimObject *thisObject; + Dictionary::Entry *currentVariable; + Dictionary::Entry *copyVariable; + bool traceOn; - ExprEvalState(); - ~ExprEvalState(); + U32 mStackDepth; - /// @} + ExprEvalState(); + ~ExprEvalState(); - /// @name Stack Management - /// @{ + /// @} - /// The stack of callframes. The extra redirection is necessary since Dictionary holds - /// an interior pointer that will become invalid when the object changes address. - Vector< Dictionary* > stack; + /// @name Stack Management + /// @{ - /// - Dictionary globalVars; - - void setCurVarName(StringTableEntry name); - void setCurVarNameCreate(StringTableEntry name); + /// The stack of callframes. The extra redirection is necessary since Dictionary holds + /// an interior pointer that will become invalid when the object changes address. + Vector< Dictionary* > stack; - S32 getIntVariable(); - F64 getFloatVariable(); - const char *getStringVariable(); - void setIntVariable(S32 val); - void setFloatVariable(F64 val); - void setStringVariable(const char *str); - void setCopyVariable(); + /// + Dictionary globalVars; - void pushFrame(StringTableEntry frameName, Namespace *ns); - void popFrame(); + void setCurVarName(StringTableEntry name); + void setCurVarNameCreate(StringTableEntry name); - /// Puts a reference to an existing stack frame - /// on the top of the stack. - void pushFrameRef(S32 stackIndex); - - U32 getStackDepth() const - { - return mStackDepth; - } - - Dictionary& getCurrentFrame() - { + S32 getIntVariable(); + F64 getFloatVariable(); + const char *getStringVariable(); + void setIntVariable(S32 val); + void setFloatVariable(F64 val); + void setStringVariable(const char *str); + void setCopyVariable(); + + void pushFrame(StringTableEntry frameName, Namespace *ns); + void popFrame(); + + /// Puts a reference to an existing stack frame + /// on the top of the stack. + void pushFrameRef(S32 stackIndex); + + U32 getStackDepth() const + { + return mStackDepth; + } + + Dictionary& getCurrentFrame() + { return *( stack[ mStackDepth - 1 ] ); - } + } - /// @} - - /// Run integrity checks for debugging. - void validate(); + /// @} + + /// Run integrity checks for debugging. + void validate(); }; namespace Con diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index 1383277ce..f69396e32 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -160,7 +160,7 @@ inline void EngineMarshallData( bool arg, S32& argc, ConsoleValueRef *argv ) } inline void EngineMarshallData( S32 arg, S32& argc, ConsoleValueRef *argv ) { - argv[ argc ] = Con::getIntArg( arg ); + argv[ argc ] = arg; argc ++; } inline void EngineMarshallData( U32 arg, S32& argc, ConsoleValueRef *argv ) @@ -169,7 +169,7 @@ inline void EngineMarshallData( U32 arg, S32& argc, ConsoleValueRef *argv ) } inline void EngineMarshallData( F32 arg, S32& argc, ConsoleValueRef *argv ) { - argv[ argc ] = Con::getFloatArg( arg ); + argv[ argc ] = arg; argc ++; } inline void EngineMarshallData( const char* arg, S32& argc, ConsoleValueRef *argv ) @@ -207,6 +207,11 @@ struct EngineUnmarshallData template<> struct EngineUnmarshallData< S32 > { + S32 operator()( ConsoleValueRef &ref ) const + { + return (S32)ref; + } + S32 operator()( const char* str ) const { return dAtoi( str ); @@ -215,6 +220,11 @@ struct EngineUnmarshallData< S32 > template<> struct EngineUnmarshallData< U32 > { + U32 operator()( ConsoleValueRef &ref ) const + { + return (U32)((S32)ref); + } + U32 operator()( const char* str ) const { return dAtoui( str ); @@ -223,6 +233,11 @@ struct EngineUnmarshallData< U32 > template<> struct EngineUnmarshallData< F32 > { + F32 operator()( ConsoleValueRef &ref ) const + { + return (F32)ref; + } + F32 operator()( const char* str ) const { return dAtof( str ); @@ -2626,12 +2641,12 @@ struct _EngineConsoleCallbackHelper if( mThis ) { // Cannot invoke callback until object has been registered - if (mThis->isProperlyAdded()) { - return Con::execute( mThis, mArgc, mArgv ); - } else { - Con::resetStackFrame(); // jamesu - we might have pushed some vars here - return ""; - } + if (mThis->isProperlyAdded()) { + return Con::execute( mThis, mArgc, mArgv ); + } else { + Con::resetStackFrame(); // We might have pushed some vars here + return ""; + } } else return Con::execute( mArgc, mArgv ); diff --git a/Engine/source/console/fieldBrushObject.cpp b/Engine/source/console/fieldBrushObject.cpp index 0d160ec7c..2bc6906eb 100644 --- a/Engine/source/console/fieldBrushObject.cpp +++ b/Engine/source/console/fieldBrushObject.cpp @@ -383,7 +383,7 @@ ConsoleMethod(FieldBrushObject, copyFields, void, 3, 4, "(simObject, [fieldList] } // Fetch field list. - const char* pFieldList = (argc > 3 ) ? argv[3] : NULL; + const char* pFieldList = (argc > 3 ) ? (const char*)argv[3] : NULL; // Copy Fields. object->copyFields( pSimObject, pFieldList ); diff --git a/Engine/source/console/persistenceManager.cpp b/Engine/source/console/persistenceManager.cpp index c269c44a8..23dcd754e 100644 --- a/Engine/source/console/persistenceManager.cpp +++ b/Engine/source/console/persistenceManager.cpp @@ -2204,7 +2204,7 @@ ConsoleMethod( PersistenceManager, setDirty, void, 3, 4, "(SimObject object, [fi { if (!Sim::findObject(argv[2], dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]); + Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); return; } } @@ -2213,7 +2213,7 @@ ConsoleMethod( PersistenceManager, setDirty, void, 3, 4, "(SimObject object, [fi if( dirtyObject == Sim::getRootGroup() ) { - Con::errorf( "%s(): Cannot save RootGroup", argv[ 0 ] ); + Con::errorf( "%s(): Cannot save RootGroup", (const char*)argv[ 0 ] ); return; } @@ -2234,7 +2234,7 @@ ConsoleMethod( PersistenceManager, removeDirty, void, 3, 3, "(SimObject object)" { if (!Sim::findObject(argv[2], dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]); + Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); return; } } @@ -2251,7 +2251,7 @@ ConsoleMethod( PersistenceManager, isDirty, bool, 3, 3, "(SimObject object)" { if (!Sim::findObject(argv[2], dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]); + Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); return false; } } @@ -2280,7 +2280,7 @@ ConsoleMethod( PersistenceManager, getDirtyObject, S32, 3, 3, "( index )" const S32 index = dAtoi( argv[2] ); if ( index < 0 || index >= object->getDirtyList().size() ) { - Con::warnf( "PersistenceManager::getDirtyObject() - Index (%s) out of range.", argv[2] ); + Con::warnf( "PersistenceManager::getDirtyObject() - Index (%s) out of range.", (const char*)argv[2] ); return 0; } @@ -2333,7 +2333,7 @@ ConsoleMethod( PersistenceManager, saveDirtyObject, bool, 3, 3, "(SimObject obje { if (!Sim::findObject(argv[2], dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]); + Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); return false; } } @@ -2358,7 +2358,7 @@ ConsoleMethod( PersistenceManager, removeObjectFromFile, void, 3, 4, "(SimObject { if (!Sim::findObject(argv[2], dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]); + Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); return; } } @@ -2380,7 +2380,7 @@ ConsoleMethod( PersistenceManager, removeField, void, 4, 4, "(SimObject object, { if (!Sim::findObject(argv[2], dirtyObject)) { - Con::printf("%s(): Invalid SimObject: %s", argv[0], argv[2]); + Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]); return; } } @@ -2390,4 +2390,4 @@ ConsoleMethod( PersistenceManager, removeField, void, 4, 4, "(SimObject object, if (argv[3][0]) object->addRemoveField(dirtyObject, argv[3]); } -} \ No newline at end of file +} diff --git a/Engine/source/console/sim.cpp b/Engine/source/console/sim.cpp index aa41316a2..918a69b79 100644 --- a/Engine/source/console/sim.cpp +++ b/Engine/source/console/sim.cpp @@ -138,20 +138,20 @@ ConsoleDocFragment _spawnObject1( ConsoleFunction(spawnObject, S32, 3, 6, "spawnObject(class [, dataBlock, name, properties, script])" "@hide") { - String spawnClass((String)argv[1]); + String spawnClass((const char*)argv[1]); String spawnDataBlock; String spawnName; String spawnProperties; String spawnScript; if (argc >= 3) - spawnDataBlock = (String)argv[2]; + spawnDataBlock = (const char*)argv[2]; if (argc >= 4) - spawnName = (String)argv[3]; + spawnName = (const char*)argv[3]; if (argc >= 5) - spawnProperties = (String)argv[4]; + spawnProperties = (const char*)argv[4]; if (argc >= 6) - spawnScript = (String)argv[5]; + spawnScript = (const char*)argv[5]; SimObject* spawnObject = Sim::spawnObject(spawnClass, spawnDataBlock, spawnName, spawnProperties, spawnScript); diff --git a/Engine/source/console/sim.h b/Engine/source/console/sim.h index c7cfa52fb..013721872 100644 --- a/Engine/source/console/sim.h +++ b/Engine/source/console/sim.h @@ -32,6 +32,9 @@ #ifndef _MODULE_H_ #include "core/module.h" #endif +#ifndef _CONSOLE_H_ +#include "console/console.h" +#endif // Forward Refs class SimSet; @@ -122,9 +125,15 @@ namespace Sim SimDataBlockGroup *getDataBlockGroup(); SimGroup* getRootGroup(); + SimObject* findObject(ConsoleValueRef&); SimObject* findObject(SimObjectId); SimObject* findObject(const char* name); SimObject* findObject(const char* fileName, S32 declarationLine); + template inline bool findObject(ConsoleValueRef &ref,T*&t) + { + t = dynamic_cast(findObject(ref)); + return t != NULL; + } template inline bool findObject(SimObjectId iD,T*&t) { t = dynamic_cast(findObject(iD)); diff --git a/Engine/source/console/simEvents.cpp b/Engine/source/console/simEvents.cpp index 3fe32b2a5..afb634bdf 100644 --- a/Engine/source/console/simEvents.cpp +++ b/Engine/source/console/simEvents.cpp @@ -34,17 +34,19 @@ SimConsoleEvent::SimConsoleEvent(S32 argc, ConsoleValueRef *argv, bool onObject) mArgc = argc; mArgv = new ConsoleValueRef[argc]; - for (int i=0; itype = ConsoleValue::TypeInternalString; - mArgv[i].value->init(); + for (int i=0; itype = ConsoleValue::TypeInternalString; + mArgv[i].value->init(); mArgv[i].value->setStringValue((const char*)argv[i]); } } SimConsoleEvent::~SimConsoleEvent() { - for (int i=0; ifindObjectByLineNumber(fileName, declarationLine, true); } +SimObject* findObject(ConsoleValueRef &ref) +{ + return findObject((const char*)ref); +} + SimObject* findObject(const char* name) { PROFILE_SCOPE(SimFindObject); diff --git a/Engine/source/console/simPersistSet.cpp b/Engine/source/console/simPersistSet.cpp index 82dd6e856..c8630002e 100644 --- a/Engine/source/console/simPersistSet.cpp +++ b/Engine/source/console/simPersistSet.cpp @@ -54,7 +54,7 @@ bool SimPersistSet::processArguments( S32 argc, ConsoleValueRef *argv ) Torque::UUID uuid; if( !uuid.fromString( argv[ i ] ) ) { - Con::errorf( "SimPersistSet::processArguments - could not read UUID at index %i: %s", i, argv[ i ] ); + Con::errorf( "SimPersistSet::processArguments - could not read UUID at index %i: %s", i, (const char*)argv[ i ] ); continue; } diff --git a/Engine/source/console/simSet.cpp b/Engine/source/console/simSet.cpp index 6f72319fe..d03f10248 100644 --- a/Engine/source/console/simSet.cpp +++ b/Engine/source/console/simSet.cpp @@ -909,7 +909,7 @@ ConsoleMethod( SimSet, add, void, 3, 0, if(obj) object->addObject( obj ); else - Con::printf("Set::add: Object \"%s\" doesn't exist", argv[ i ] ); + Con::printf("Set::add: Object \"%s\" doesn't exist", (const char*)argv[ i ] ); } } @@ -934,7 +934,7 @@ ConsoleMethod( SimSet, remove, void, 3, 0, if(obj && object->find(object->begin(),object->end(),obj) != object->end()) object->removeObject(obj); else - Con::printf("Set::remove: Object \"%s\" does not exist in set", argv[i]); + Con::printf("Set::remove: Object \"%s\" does not exist in set", (const char*)argv[i]); object->unlock(); } } diff --git a/Engine/source/console/stringStack.cpp b/Engine/source/console/stringStack.cpp index 1473d614c..e57445657 100644 --- a/Engine/source/console/stringStack.cpp +++ b/Engine/source/console/stringStack.cpp @@ -34,9 +34,9 @@ void ConsoleValueStack::getArgcArgv(StringTableEntry name, U32 *argc, ConsoleVal mArgv[0] = name; for(U32 i = 0; i < argCount; i++) { - ConsoleValueRef *ref = &mArgv[i+1]; - ref->value = &mStack[startStack + i]; - ref->stringStackValue = NULL; + ConsoleValueRef *ref = &mArgv[i+1]; + ref->value = &mStack[startStack + i]; + ref->stringStackValue = NULL; } argCount++; @@ -50,10 +50,10 @@ ConsoleValueStack::ConsoleValueStack() : mFrame(0), mStackPos(0) { - for (int i=0; itype) - { - case ConsoleValue::TypeInternalInt: - mStack[mStackPos++].setIntValue((S32)variable->getIntValue()); - case ConsoleValue::TypeInternalFloat: - mStack[mStackPos++].setFloatValue((F32)variable->getFloatValue()); - default: - mStack[mStackPos++].setStackStringValue(variable->getStringValue()); - } + switch (variable->type) + { + case ConsoleValue::TypeInternalInt: + mStack[mStackPos++].setIntValue((S32)variable->getIntValue()); + case ConsoleValue::TypeInternalFloat: + mStack[mStackPos++].setFloatValue((F32)variable->getFloatValue()); + default: + mStack[mStackPos++].setStackStringValue(variable->getStringValue()); + } } void ConsoleValueStack::pushValue(ConsoleValue &variable) { - if (mStackPos == ConsoleValueStack::MaxStackDepth) { - AssertFatal(false, "Console Value Stack is empty"); - return; - } + if (mStackPos == ConsoleValueStack::MaxStackDepth) { + AssertFatal(false, "Console Value Stack is empty"); + return; + } - switch (variable.type) - { - case ConsoleValue::TypeInternalInt: - mStack[mStackPos++].setIntValue((S32)variable.getIntValue()); - case ConsoleValue::TypeInternalFloat: - mStack[mStackPos++].setFloatValue((F32)variable.getFloatValue()); - default: - mStack[mStackPos++].setStringValue(variable.getStringValue()); - } + switch (variable.type) + { + case ConsoleValue::TypeInternalInt: + mStack[mStackPos++].setIntValue((S32)variable.getIntValue()); + case ConsoleValue::TypeInternalFloat: + mStack[mStackPos++].setFloatValue((F32)variable.getFloatValue()); + default: + mStack[mStackPos++].setStringValue(variable.getStringValue()); + } } ConsoleValue *ConsoleValueStack::pushString(const char *value) { - if (mStackPos == ConsoleValueStack::MaxStackDepth) { - AssertFatal(false, "Console Value Stack is empty"); - return NULL; - } + if (mStackPos == ConsoleValueStack::MaxStackDepth) { + AssertFatal(false, "Console Value Stack is empty"); + return NULL; + } - //Con::printf("[%i]CSTK pushString %s", mStackPos, value); + //Con::printf("[%i]CSTK pushString %s", mStackPos, value); - mStack[mStackPos++].setStringValue(value); - return &mStack[mStackPos-1]; + mStack[mStackPos++].setStringValue(value); + return &mStack[mStackPos-1]; } ConsoleValue *ConsoleValueStack::pushStackString(const char *value) { - if (mStackPos == ConsoleValueStack::MaxStackDepth) { - AssertFatal(false, "Console Value Stack is empty"); - return NULL; - } + if (mStackPos == ConsoleValueStack::MaxStackDepth) { + AssertFatal(false, "Console Value Stack is empty"); + return NULL; + } - //Con::printf("[%i]CSTK pushString %s", mStackPos, value); + //Con::printf("[%i]CSTK pushString %s", mStackPos, value); - mStack[mStackPos++].setStackStringValue(value); - return &mStack[mStackPos-1]; + mStack[mStackPos++].setStackStringValue(value); + return &mStack[mStackPos-1]; } ConsoleValue *ConsoleValueStack::pushUINT(U32 value) { - if (mStackPos == ConsoleValueStack::MaxStackDepth) { - AssertFatal(false, "Console Value Stack is empty"); - return NULL; - } + if (mStackPos == ConsoleValueStack::MaxStackDepth) { + AssertFatal(false, "Console Value Stack is empty"); + return NULL; + } - //Con::printf("[%i]CSTK pushUINT %i", mStackPos, value); + //Con::printf("[%i]CSTK pushUINT %i", mStackPos, value); - mStack[mStackPos++].setIntValue(value); - return &mStack[mStackPos-1]; + mStack[mStackPos++].setIntValue(value); + return &mStack[mStackPos-1]; } ConsoleValue *ConsoleValueStack::pushFLT(float value) { - if (mStackPos == ConsoleValueStack::MaxStackDepth) { - AssertFatal(false, "Console Value Stack is empty"); - return NULL; - } + if (mStackPos == ConsoleValueStack::MaxStackDepth) { + AssertFatal(false, "Console Value Stack is empty"); + return NULL; + } - //Con::printf("[%i]CSTK pushFLT %f", mStackPos, value); + //Con::printf("[%i]CSTK pushFLT %f", mStackPos, value); - mStack[mStackPos++].setFloatValue(value); - return &mStack[mStackPos-1]; + mStack[mStackPos++].setFloatValue(value); + return &mStack[mStackPos-1]; } static ConsoleValue gNothing; ConsoleValue* ConsoleValueStack::pop() { - if (mStackPos == 0) { - AssertFatal(false, "Console Value Stack is empty"); - return &gNothing; - } + if (mStackPos == 0) { + AssertFatal(false, "Console Value Stack is empty"); + return &gNothing; + } - return &mStack[--mStackPos]; + return &mStack[--mStackPos]; } void ConsoleValueStack::pushFrame() { - //Con::printf("CSTK pushFrame"); - mStackFrames[mFrame++] = mStackPos; + //Con::printf("CSTK pushFrame"); + mStackFrames[mFrame++] = mStackPos; } void ConsoleValueStack::resetFrame() { - if (mFrame == 0) { - mStackPos = 0; - return; - } + if (mFrame == 0) { + mStackPos = 0; + return; + } - U32 start = mStackFrames[mFrame-1]; - //for (U32 i=start; imatchTerrainToRoad(); -} \ No newline at end of file +} diff --git a/Engine/source/environment/editors/guiRiverEditorCtrl.cpp b/Engine/source/environment/editors/guiRiverEditorCtrl.cpp index 26fabc99b..cbd776618 100644 --- a/Engine/source/environment/editors/guiRiverEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiRiverEditorCtrl.cpp @@ -1181,7 +1181,7 @@ void GuiRiverEditorCtrl::setMode( String mode, bool sourceShortcut = false ) mMode = mode; if( sourceShortcut ) - Con::executef( this, "paletteSync", mode.utf8() ); + Con::executef( this, "paletteSync", mode ); } void GuiRiverEditorCtrl::setSelectedRiver( River *river ) @@ -1444,7 +1444,7 @@ ConsoleMethod( GuiRiverEditorCtrl, setNodePosition, void, 3, 3, "" ) if ( (count != 3) ) { - Con::printf("Failed to parse node information \"px py pz\" from '%s'", argv[3]); + Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]); return; } @@ -1470,7 +1470,7 @@ ConsoleMethod( GuiRiverEditorCtrl, setNodeNormal, void, 3, 3, "" ) if ( (count != 3) ) { - Con::printf("Failed to parse node information \"px py pz\" from '%s'", argv[3]); + Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]); return; } @@ -1503,4 +1503,4 @@ ConsoleMethod( GuiRiverEditorCtrl, regenerate, void, 2, 2, "" ) River *river = object->getSelectedRiver(); if ( river ) river->regenerate(); -} \ No newline at end of file +} diff --git a/Engine/source/environment/editors/guiRoadEditorCtrl.cpp b/Engine/source/environment/editors/guiRoadEditorCtrl.cpp index a5c32abe5..627573691 100644 --- a/Engine/source/environment/editors/guiRoadEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiRoadEditorCtrl.cpp @@ -945,7 +945,7 @@ void GuiRoadEditorCtrl::setMode( String mode, bool sourceShortcut = false ) mMode = mode; if( sourceShortcut ) - Con::executef( this, "paletteSync", mode.utf8() ); + Con::executef( this, "paletteSync", mode ); } void GuiRoadEditorCtrl::setSelectedRoad( DecalRoad *road ) @@ -1081,7 +1081,7 @@ ConsoleMethod( GuiRoadEditorCtrl, setNodePosition, void, 3, 3, "" ) if ( (count != 3) ) { - Con::printf("Failed to parse node information \"px py pz\" from '%s'", argv[3]); + Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]); return; } diff --git a/Engine/source/forest/forest.cpp b/Engine/source/forest/forest.cpp index 41da38500..a61bf9f3b 100644 --- a/Engine/source/forest/forest.cpp +++ b/Engine/source/forest/forest.cpp @@ -356,7 +356,7 @@ void Forest::saveDataFile( const char *path ) ConsoleMethod( Forest, saveDataFile, bool, 2, 3, "saveDataFile( [path] )" ) { - object->saveDataFile( argc == 3 ? argv[2] : NULL ); + object->saveDataFile( argc == 3 ? (const char*)argv[2] : NULL ); return true; } @@ -373,4 +373,4 @@ ConsoleMethod(Forest, regenCells, void, 2, 2, "()") ConsoleMethod(Forest, clear, void, 2, 2, "()" ) { object->clear(); -} \ No newline at end of file +} diff --git a/Engine/source/gui/controls/guiPopUpCtrl.cpp b/Engine/source/gui/controls/guiPopUpCtrl.cpp index e4b2903f7..9f3775bd3 100644 --- a/Engine/source/gui/controls/guiPopUpCtrl.cpp +++ b/Engine/source/gui/controls/guiPopUpCtrl.cpp @@ -431,7 +431,7 @@ ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, str // get it? if(!classRep) { - Con::warnf(ConsoleLogEntry::General, "failed to locate class rep for '%s'", argv[2]); + Con::warnf(ConsoleLogEntry::General, "failed to locate class rep for '%s'", (const char*)argv[2]); return; } @@ -444,7 +444,7 @@ ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, str // found it? if(i == classRep->mFieldList.size()) { - Con::warnf(ConsoleLogEntry::General, "failed to locate field '%s' for class '%s'", argv[3], argv[2]); + Con::warnf(ConsoleLogEntry::General, "failed to locate field '%s' for class '%s'", (const char*)argv[3], (const char*)argv[2]); return; } @@ -454,7 +454,7 @@ ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, str // check the type if( !conType->getEnumTable() ) { - Con::warnf(ConsoleLogEntry::General, "field '%s' is not an enumeration for class '%s'", argv[3], argv[2]); + Con::warnf(ConsoleLogEntry::General, "field '%s' is not an enumeration for class '%s'", (const char*)argv[3], (const char*)argv[2]); return; } diff --git a/Engine/source/gui/controls/guiPopUpCtrlEx.cpp b/Engine/source/gui/controls/guiPopUpCtrlEx.cpp index 275faf75c..108f37ea4 100644 --- a/Engine/source/gui/controls/guiPopUpCtrlEx.cpp +++ b/Engine/source/gui/controls/guiPopUpCtrlEx.cpp @@ -604,7 +604,7 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4, // get it? if(!classRep) { - Con::warnf(ConsoleLogEntry::General, "failed to locate class rep for '%s'", argv[2]); + Con::warnf(ConsoleLogEntry::General, "failed to locate class rep for '%s'", (const char*)argv[2]); return; } @@ -617,7 +617,7 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4, // found it? if(i == classRep->mFieldList.size()) { - Con::warnf(ConsoleLogEntry::General, "failed to locate field '%s' for class '%s'", argv[3], argv[2]); + Con::warnf(ConsoleLogEntry::General, "failed to locate field '%s' for class '%s'", (const char*)argv[3], (const char*)argv[2]); return; } @@ -627,7 +627,7 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4, // check the type if( !conType->getEnumTable() ) { - Con::warnf(ConsoleLogEntry::General, "field '%s' is not an enumeration for class '%s'", argv[3], argv[2]); + Con::warnf(ConsoleLogEntry::General, "field '%s' is not an enumeration for class '%s'", (const char*)argv[3], (const char*)argv[2]); return; } diff --git a/Engine/source/gui/controls/guiTreeViewCtrl.cpp b/Engine/source/gui/controls/guiTreeViewCtrl.cpp index 390cbfcae..10001d006 100644 --- a/Engine/source/gui/controls/guiTreeViewCtrl.cpp +++ b/Engine/source/gui/controls/guiTreeViewCtrl.cpp @@ -4928,7 +4928,7 @@ ConsoleMethod( GuiTreeViewCtrl, setItemTooltip, void, 4, 4, "( int id, string te return; } - item->mTooltip = (String)argv[ 3 ]; + item->mTooltip = (const char*)argv[ 3 ]; } ConsoleMethod( GuiTreeViewCtrl, setItemImages, void, 5, 5, "( int id, int normalImage, int expandedImage ) - Sets the normal and expanded images to show for the given item." ) diff --git a/Engine/source/gui/core/guiCanvas.cpp b/Engine/source/gui/core/guiCanvas.cpp index 00a669646..36e1d1ed1 100644 --- a/Engine/source/gui/core/guiCanvas.cpp +++ b/Engine/source/gui/core/guiCanvas.cpp @@ -2007,7 +2007,7 @@ ConsoleMethod( GuiCanvas, pushDialog, void, 3, 5, "(GuiControl ctrl, int layer=0 if (! Sim::findObject(argv[2], gui)) { - Con::printf("%s(): Invalid control: %s", argv[0], argv[2]); + Con::printf("%s(): Invalid control: %s", (const char*)argv[0], (const char*)argv[2]); return; } @@ -2052,7 +2052,7 @@ ConsoleMethod( GuiCanvas, popDialog, void, 2, 3, "(GuiControl ctrl=NULL)" { if (!Sim::findObject(argv[2], gui)) { - Con::printf("%s(): Invalid control: %s", argv[0], argv[2]); + Con::printf("%s(): Invalid control: %s", (const char*)argv[0], (const char*)argv[2]); return; } } diff --git a/Engine/source/gui/editor/guiEditCtrl.cpp b/Engine/source/gui/editor/guiEditCtrl.cpp index 584c9b9e2..1710ec4f5 100644 --- a/Engine/source/gui/editor/guiEditCtrl.cpp +++ b/Engine/source/gui/editor/guiEditCtrl.cpp @@ -2540,7 +2540,7 @@ ConsoleMethod( GuiEditCtrl, setCurrentAddSet, void, 3, 3, "(GuiControl ctrl)") if (!Sim::findObject(argv[2], addSet)) { - Con::printf("%s(): Invalid control: %s", argv[0], argv[2]); + Con::printf("%s(): Invalid control: %s", (const char*)argv[0], (const char*)argv[2]); return; } object->setCurrentAddSet(addSet); @@ -2700,7 +2700,7 @@ ConsoleMethod( GuiEditCtrl, readGuides, void, 3, 4, "( GuiControl ctrl [, int ax GuiControl* ctrl; if( !Sim::findObject( argv[ 2 ], ctrl ) ) { - Con::errorf( "GuiEditCtrl::readGuides - no control '%s'", argv[ 2 ] ); + Con::errorf( "GuiEditCtrl::readGuides - no control '%s'", (const char*)argv[ 2 ] ); return; } @@ -2711,7 +2711,7 @@ ConsoleMethod( GuiEditCtrl, readGuides, void, 3, 4, "( GuiControl ctrl [, int ax S32 axis = dAtoi( argv[ 3 ] ); if( axis < 0 || axis > 1 ) { - Con::errorf( "GuiEditCtrl::readGuides - invalid axis '%s'", argv[ 3 ] ); + Con::errorf( "GuiEditCtrl::readGuides - invalid axis '%s'", (const char*)argv[ 3 ] ); return; } @@ -2733,7 +2733,7 @@ ConsoleMethod( GuiEditCtrl, writeGuides, void, 3, 4, "( GuiControl ctrl [, int a GuiControl* ctrl; if( !Sim::findObject( argv[ 2 ], ctrl ) ) { - Con::errorf( "GuiEditCtrl::writeGuides - no control '%i'", argv[ 2 ] ); + Con::errorf( "GuiEditCtrl::writeGuides - no control '%i'", (const char*)argv[ 2 ] ); return; } @@ -2744,7 +2744,7 @@ ConsoleMethod( GuiEditCtrl, writeGuides, void, 3, 4, "( GuiControl ctrl [, int a S32 axis = dAtoi( argv[ 3 ] ); if( axis < 0 || axis > 1 ) { - Con::errorf( "GuiEditCtrl::writeGuides - invalid axis '%s'", argv[ 3 ] ); + Con::errorf( "GuiEditCtrl::writeGuides - invalid axis '%s'", (const char*)argv[ 3 ] ); return; } diff --git a/Engine/source/gui/editor/guiInspector.cpp b/Engine/source/gui/editor/guiInspector.cpp index dab92cafb..d05e03c6d 100644 --- a/Engine/source/gui/editor/guiInspector.cpp +++ b/Engine/source/gui/editor/guiInspector.cpp @@ -777,7 +777,7 @@ ConsoleMethod( GuiInspector, inspect, void, 3, 3, "Inspect(Object)") if(!target) { if(dAtoi(argv[2]) > 0) - Con::warnf("%s::inspect(): invalid object: %s", argv[0], argv[2]); + Con::warnf("%s::inspect(): invalid object: %s", (const char*)argv[0], (const char*)argv[2]); object->clearInspectObjects(); return; @@ -793,7 +793,7 @@ ConsoleMethod( GuiInspector, addInspect, void, 3, 4, "( id object, (bool autoSyn SimObject* obj; if( !Sim::findObject( argv[ 2 ], obj ) ) { - Con::errorf( "%s::addInspect(): invalid object: %s", argv[ 0 ], argv[ 2 ] ); + Con::errorf( "%s::addInspect(): invalid object: %s", (const char*)argv[ 0 ], (const char*)argv[ 2 ] ); return; } @@ -810,7 +810,7 @@ ConsoleMethod( GuiInspector, removeInspect, void, 3, 3, "( id object ) - Remove SimObject* obj; if( !Sim::findObject( argv[ 2 ], obj ) ) { - Con::errorf( "%s::removeInspect(): invalid object: %s", argv[ 0 ], argv[ 2 ] ); + Con::errorf( "%s::removeInspect(): invalid object: %s", (const char*)argv[ 0 ], (const char*)argv[ 2 ] ); return; } diff --git a/Engine/source/gui/editor/guiInspectorTypes.cpp b/Engine/source/gui/editor/guiInspectorTypes.cpp index e1533134f..2482d3c2e 100644 --- a/Engine/source/gui/editor/guiInspectorTypes.cpp +++ b/Engine/source/gui/editor/guiInspectorTypes.cpp @@ -571,7 +571,7 @@ void GuiInspectorTypeFileName::updateValue() ConsoleMethod( GuiInspectorTypeFileName, apply, void, 3,3, "apply(newValue);" ) { - String path( argv[2] ); + String path( (const char*)argv[2] ); if ( path.isNotEmpty() ) path = Platform::makeRelativePathName( path, Platform::getMainDotCsDir() ); diff --git a/Engine/source/gui/editor/inspector/variableInspector.cpp b/Engine/source/gui/editor/inspector/variableInspector.cpp index 1a061e8a0..62993d600 100644 --- a/Engine/source/gui/editor/inspector/variableInspector.cpp +++ b/Engine/source/gui/editor/inspector/variableInspector.cpp @@ -63,5 +63,5 @@ void GuiVariableInspector::loadVars( String searchStr ) ConsoleMethod( GuiVariableInspector, loadVars, void, 3, 3, "loadVars( searchString )" ) { - object->loadVars( (const char*)argv[2] ); + object->loadVars( argv[2] ); } \ No newline at end of file diff --git a/Engine/source/gui/worldEditor/editorIconRegistry.cpp b/Engine/source/gui/worldEditor/editorIconRegistry.cpp index 1a80dc725..6dd1f2cc6 100644 --- a/Engine/source/gui/worldEditor/editorIconRegistry.cpp +++ b/Engine/source/gui/worldEditor/editorIconRegistry.cpp @@ -175,7 +175,7 @@ ConsoleStaticMethod( EditorIconRegistry, add, void, 3, 4, "( String className, S if ( argc > 3 ) overwrite = dAtob( argv[3] ); - gEditorIcons.add( (const char*)argv[1], (const char*)argv[2], overwrite ); + gEditorIcons.add( argv[1], argv[2], overwrite ); } ConsoleStaticMethod( EditorIconRegistry, loadFromPath, void, 2, 3, "( String imagePath [, bool overwrite = true] )" @@ -185,7 +185,7 @@ ConsoleStaticMethod( EditorIconRegistry, loadFromPath, void, 2, 3, "( String ima if ( argc > 2 ) overwrite = dAtob( argv[2] ); - gEditorIcons.loadFromPath( (const char*)argv[1], overwrite ); + gEditorIcons.loadFromPath( argv[1], overwrite ); } ConsoleStaticMethod( EditorIconRegistry, clear, void, 1, 1, "" @@ -212,7 +212,7 @@ ConsoleStaticMethod( EditorIconRegistry, findIconBySimObject, const char*, 2, 2, SimObject *obj = NULL; if ( !Sim::findObject( argv[1], obj ) ) { - Con::warnf( "EditorIconRegistry::findIcon, parameter %d was not a SimObject!", argv[1] ); + Con::warnf( "EditorIconRegistry::findIcon, parameter %d was not a SimObject!", (const char*)argv[1] ); return NULL; } diff --git a/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp b/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp index 2bcf0c822..79385948c 100644 --- a/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp +++ b/Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp @@ -782,7 +782,7 @@ void GuiDecalEditorCtrl::setMode( String mode, bool sourceShortcut = false ) mMode = mode; if( sourceShortcut ) - Con::executef( this, "paletteSync", (const char*)mMode ); + Con::executef( this, "paletteSync", mMode ); } ConsoleMethod( GuiDecalEditorCtrl, deleteSelectedDecal, void, 2, 2, "deleteSelectedDecal()" ) @@ -792,7 +792,7 @@ ConsoleMethod( GuiDecalEditorCtrl, deleteSelectedDecal, void, 2, 2, "deleteSelec ConsoleMethod( GuiDecalEditorCtrl, deleteDecalDatablock, void, 3, 3, "deleteSelectedDecalDatablock( String datablock )" ) { - String lookupName( argv[2] ); + String lookupName( (const char*)argv[2] ); if( lookupName == String::EmptyString ) return; @@ -801,7 +801,7 @@ ConsoleMethod( GuiDecalEditorCtrl, deleteDecalDatablock, void, 3, 3, "deleteSele ConsoleMethod( GuiDecalEditorCtrl, setMode, void, 3, 3, "setMode( String mode )()" ) { - String newMode = ( argv[2] ); + String newMode = ( (const char*)argv[2] ); object->setMode( newMode ); } @@ -868,7 +868,7 @@ ConsoleMethod( GuiDecalEditorCtrl, editDecalDetails, void, 4, 4, "editDecalDetai if ( (count != 7) ) { - Con::printf("Failed to parse decal information \"px py pz tx ty tz s\" from '%s'", argv[3]); + Con::printf("Failed to parse decal information \"px py pz tx ty tz s\" from '%s'", (const char*)argv[3]); return; } @@ -894,7 +894,7 @@ ConsoleMethod( GuiDecalEditorCtrl, getSelectionCount, S32, 2, 2, "" ) ConsoleMethod( GuiDecalEditorCtrl, retargetDecalDatablock, void, 4, 4, "" ) { if( dStrcmp( argv[2], "" ) != 0 && dStrcmp( argv[3], "" ) != 0 ) - object->retargetDecalDatablock( (const char*)argv[2], (const char*)argv[3] ); + object->retargetDecalDatablock( argv[2], argv[3] ); } void GuiDecalEditorCtrl::setGizmoFocus( DecalInstance * decalInstance ) @@ -1253,4 +1253,4 @@ void DBRetargetUndoAction::redo() if ( mEditor->isMethod( "rebuildInstanceTree" ) ) Con::executef( mEditor, "rebuildInstanceTree" ); } -#endif \ No newline at end of file +#endif diff --git a/Engine/source/gui/worldEditor/terrainEditor.cpp b/Engine/source/gui/worldEditor/terrainEditor.cpp index ec032e5f9..a26314121 100644 --- a/Engine/source/gui/worldEditor/terrainEditor.cpp +++ b/Engine/source/gui/worldEditor/terrainEditor.cpp @@ -2500,7 +2500,7 @@ ConsoleMethod( TerrainEditor, attachTerrain, void, 2, 3, "(TerrainBlock terrain) terrains.push_back(terrBlock); if(terrains.size() == 0) - Con::errorf(ConsoleLogEntry::Script, "TerrainEditor::attach: failed to attach to object '%s'", argv[2]); + Con::errorf(ConsoleLogEntry::Script, "TerrainEditor::attach: failed to attach to object '%s'", (const char*)argv[2]); } if (terrains.size() > 0) @@ -2714,7 +2714,7 @@ ConsoleMethod(TerrainEditor, updateMaterial, bool, 4, 4, if ( index >= terr->getMaterialCount() ) return false; - terr->updateMaterial( index, (const char*)argv[3] ); + terr->updateMaterial( index, argv[3] ); object->setDirty(); @@ -2729,7 +2729,7 @@ ConsoleMethod(TerrainEditor, addMaterial, S32, 3, 3, if ( !terr ) return false; - terr->addMaterial( (const char*)argv[2] ); + terr->addMaterial( argv[2] ); object->setDirty(); diff --git a/Engine/source/gui/worldEditor/worldEditor.cpp b/Engine/source/gui/worldEditor/worldEditor.cpp index 21948ceff..9ac8b2576 100644 --- a/Engine/source/gui/worldEditor/worldEditor.cpp +++ b/Engine/source/gui/worldEditor/worldEditor.cpp @@ -3204,7 +3204,7 @@ ConsoleMethod( WorldEditor, setActiveSelection, void, 3, 3, "( id set ) - Set th WorldEditorSelection* selection; if( !Sim::findObject( argv[ 2 ], selection ) ) { - Con::errorf( "WorldEditor::setActiveSelectionSet - no selection set '%s'", argv[ 2 ] ); + Con::errorf( "WorldEditor::setActiveSelectionSet - no selection set '%s'", (const char*)argv[ 2 ] ); return; } @@ -3330,14 +3330,14 @@ ConsoleMethod( WorldEditor, alignByBounds, void, 3, 3, "(int boundsAxis)" "Align all selected objects against the given bounds axis.") { if(!object->alignByBounds(dAtoi(argv[2]))) - Con::warnf(ConsoleLogEntry::General, avar("worldEditor.alignByBounds: invalid bounds axis '%s'", argv[2])); + Con::warnf(ConsoleLogEntry::General, avar("worldEditor.alignByBounds: invalid bounds axis '%s'", (const char*)argv[2])); } ConsoleMethod( WorldEditor, alignByAxis, void, 3, 3, "(int axis)" "Align all selected objects along the given axis.") { if(!object->alignByAxis(dAtoi(argv[2]))) - Con::warnf(ConsoleLogEntry::General, avar("worldEditor.alignByAxis: invalid axis '%s'", argv[2])); + Con::warnf(ConsoleLogEntry::General, avar("worldEditor.alignByAxis: invalid axis '%s'", (const char*)argv[2])); } ConsoleMethod( WorldEditor, resetSelectedRotation, void, 2, 2, "") diff --git a/Engine/source/gui/worldEditor/worldEditorSelection.cpp b/Engine/source/gui/worldEditor/worldEditorSelection.cpp index ed2e1f5a3..c8b2e2680 100644 --- a/Engine/source/gui/worldEditor/worldEditorSelection.cpp +++ b/Engine/source/gui/worldEditor/worldEditorSelection.cpp @@ -682,7 +682,7 @@ ConsoleMethod( WorldEditorSelection, union, void, 3, 3, "( SimSet set ) - Add al SimSet* selection; if( !Sim::findObject( argv[ 2 ], selection ) ) { - Con::errorf( "WorldEditorSelection::union - no SimSet '%s'", argv[ 2 ] ); + Con::errorf( "WorldEditorSelection::union - no SimSet '%s'", (const char*)argv[ 2 ] ); return; } @@ -698,7 +698,7 @@ ConsoleMethod( WorldEditorSelection, subtract, void, 3, 3, "( SimSet ) - Remove SimSet* selection; if( !Sim::findObject( argv[ 2 ], selection ) ) { - Con::errorf( "WorldEditorSelection::subtract - no SimSet '%s'", argv[ 2 ] ); + Con::errorf( "WorldEditorSelection::subtract - no SimSet '%s'", (const char*)argv[ 2 ] ); return; } diff --git a/Engine/source/i18n/i18n.cpp b/Engine/source/i18n/i18n.cpp index a5cfaf9de..38b213361 100644 --- a/Engine/source/i18n/i18n.cpp +++ b/Engine/source/i18n/i18n.cpp @@ -78,7 +78,7 @@ ConsoleFunction(setCoreLangTable, void, 2, 2, "(string LangTable)" if(Sim::findObject(argv[1], lt)) gCoreLangTable = lt; else - Con::errorf("setCoreLangTable - Unable to find LanTable '%s'", argv[1]); + Con::errorf("setCoreLangTable - Unable to find LanTable '%s'", (const char*)argv[1]); } //----------------------------------------------------------------------------- diff --git a/Engine/source/materials/materialManager.cpp b/Engine/source/materials/materialManager.cpp index bc30791da..e0d04e9ad 100644 --- a/Engine/source/materials/materialManager.cpp +++ b/Engine/source/materials/materialManager.cpp @@ -465,7 +465,7 @@ ConsoleFunction( addMaterialMapping, void, 3, 3, "(string texName, string matNam "block or interior surface using the associated texture.\n\n" "@ingroup Materials") { - MATMGR->mapMaterial((const char*)argv[1],(const char*)argv[2]); + MATMGR->mapMaterial(argv[1], argv[2]); } ConsoleFunction( getMaterialMapping, const char*, 2, 2, "(string texName)\n" @@ -474,7 +474,7 @@ ConsoleFunction( getMaterialMapping, const char*, 2, 2, "(string texName)\n" "@param texName Name of the texture\n\n" "@ingroup Materials") { - return MATMGR->getMapEntry((const char*)argv[1]).c_str(); + return MATMGR->getMapEntry(argv[1]).c_str(); } ConsoleFunction( dumpMaterialInstances, void, 1, 1, @@ -487,5 +487,5 @@ ConsoleFunction( dumpMaterialInstances, void, 1, 1, ConsoleFunction( getMapEntry, const char *, 2, 2, "@hide") { - return MATMGR->getMapEntry( String(argv[1]) ); -} \ No newline at end of file + return MATMGR->getMapEntry( argv[1] ); +} diff --git a/Engine/source/platformMac/macCarbFileio.mm b/Engine/source/platformMac/macCarbFileio.mm index 9b95d67fc..03329593f 100644 --- a/Engine/source/platformMac/macCarbFileio.mm +++ b/Engine/source/platformMac/macCarbFileio.mm @@ -884,7 +884,7 @@ bool Platform::fileTimeToString(FileTime * time, char * string, U32 strLen) { re //----------------------------------------------------------------------------- #if defined(TORQUE_DEBUG) ConsoleFunction(testHasSubdir,void,2,2,"tests platform::hasSubDirectory") { - Con::printf("testing %s",argv[1]); + Con::printf("testing %s",(const char*)argv[1]); Platform::addExcludedDirectory(".svn"); if(Platform::hasSubDirectory(argv[1])) Con::printf(" has subdir"); @@ -901,7 +901,7 @@ ConsoleFunction(testDumpDirectories,void,4,4,"testDumpDirectories('path', int de Platform::dumpDirectories(argv[1], paths, depth, noBasePath); - Con::printf("Dumping directories starting from %s with depth %i", argv[1],depth); + Con::printf("Dumping directories starting from %s with depth %i", (const char*)argv[1],depth); for(Vector::iterator itr = paths.begin(); itr != paths.end(); itr++) { Con::printf(*itr); diff --git a/Engine/source/platformWin32/winInput.cpp b/Engine/source/platformWin32/winInput.cpp index f6ee3cc02..58586981d 100644 --- a/Engine/source/platformWin32/winInput.cpp +++ b/Engine/source/platformWin32/winInput.cpp @@ -509,7 +509,7 @@ void Input::log( const char* format, ... ) ConsoleFunction( inputLog, void, 2, 2, "inputLog( string )" ) { argc; - Input::log( "%s\n", argv[1] ); + Input::log( "%s\n", (const char*)argv[1] ); } #endif // LOG_INPUT diff --git a/Engine/source/platformX86UNIX/x86UNIXInput.client.cpp b/Engine/source/platformX86UNIX/x86UNIXInput.client.cpp index 0db1d7a0f..e05e910d5 100644 --- a/Engine/source/platformX86UNIX/x86UNIXInput.client.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXInput.client.cpp @@ -335,7 +335,7 @@ void Input::log( const char* format, ... ) ConsoleFunction( inputLog, void, 2, 2, "inputLog( string )" ) { argc; - Input::log( "%s\n", argv[1] ); + Input::log( "%s\n", (const char*)argv[1] ); } #endif // LOG_INPUT diff --git a/Engine/source/platformX86UNIX/x86UNIXMath.cpp b/Engine/source/platformX86UNIX/x86UNIXMath.cpp index 300515083..2a9abf547 100644 --- a/Engine/source/platformX86UNIX/x86UNIXMath.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXMath.cpp @@ -70,7 +70,7 @@ ConsoleFunction( MathInit, void, 1, 10, "(detect|C|FPU|MMX|3DNOW|SSE|...)") properties |= CPU_PROP_SSE; continue; } - Con::printf("Error: MathInit(): ignoring unknown math extension '%s'", *argv); + Con::printf("Error: MathInit(): ignoring unknown math extension '%s'", (const char*)argv[0]); } Math::init(properties); } diff --git a/Engine/source/postFx/postEffectVis.cpp b/Engine/source/postFx/postEffectVis.cpp index bf4e40057..c938e9a93 100644 --- a/Engine/source/postFx/postEffectVis.cpp +++ b/Engine/source/postFx/postEffectVis.cpp @@ -400,7 +400,7 @@ ConsoleStaticMethod( PfxVis, open, void, 2, 3, "( PostEffect, [bool clear = fals PostEffect *pfx; if ( !Sim::findObject( argv[1], pfx ) ) { - Con::errorf( "PfxVis::add, argument %s was not a PostEffect", argv[1] ); + Con::errorf( "PfxVis::add, argument %s was not a PostEffect", (const char*)argv[1] ); return; } @@ -450,9 +450,9 @@ ConsoleStaticMethod( PfxVis, onWindowClosed, void, 2, 2, "( GuiWindowCtrl )" GuiWindowCtrl *ctrl; if ( !Sim::findObject( argv[1], ctrl ) ) { - Con::errorf( "PfxVis::onWindowClosed, argument %s was not a GuiWindowCtrl", argv[1] ); + Con::errorf( "PfxVis::onWindowClosed, argument %s was not a GuiWindowCtrl", (const char*)argv[1] ); return; } PFXVIS->onWindowClosed( ctrl ); -} \ No newline at end of file +} diff --git a/Engine/source/sfx/sfxSystem.cpp b/Engine/source/sfx/sfxSystem.cpp index c43a44b2f..f016136f9 100644 --- a/Engine/source/sfx/sfxSystem.cpp +++ b/Engine/source/sfx/sfxSystem.cpp @@ -1454,7 +1454,7 @@ ConsoleFunction( sfxCreateSource, S32, 2, 6, description = dynamic_cast< SFXDescription* >( Sim::findObject( argv[1] ) ); if ( !description ) { - Con::printf( "Unable to locate sound track/description '%s'", argv[1] ); + Con::printf( "Unable to locate sound track/description '%s'", (const char*)argv[1] ); return 0; } } @@ -1560,7 +1560,7 @@ ConsoleFunction( sfxPlay, S32, 2, 5, "( SFXSource source | ( SFXTrack track [, f SFXTrack* track = dynamic_cast( Sim::findObject( argv[1] ) ); if ( !track ) { - Con::printf( "Unable to locate sfx track '%s'", argv[1] ); + Con::printf( "Unable to locate sfx track '%s'", (const char*)argv[1] ); return 0; } @@ -1663,7 +1663,7 @@ ConsoleFunction( sfxPlayOnce, S32, 2, 6, description = dynamic_cast< SFXDescription* >( Sim::findObject( argv[1] ) ); if( !description ) { - Con::errorf( "sfxPlayOnce - Unable to locate sound track/description '%s'", argv[1] ); + Con::errorf( "sfxPlayOnce - Unable to locate sound track/description '%s'", (const char*)argv[1] ); return 0; } } diff --git a/Engine/source/sim/actionMap.cpp b/Engine/source/sim/actionMap.cpp index c7e7665a1..43e50b568 100644 --- a/Engine/source/sim/actionMap.cpp +++ b/Engine/source/sim/actionMap.cpp @@ -1795,16 +1795,15 @@ static ConsoleDocFragment _ActionMapbindObj2( ConsoleMethod( ActionMap, bindObj, bool, 6, 11, "(device, action, [modifier spec, mod...], command, object)" "@hide") { - SimObject* simObject = Sim::findObject(argv[argc - 1]); - if ( simObject == NULL ) - { - Con::warnf("ActionMap::bindObj() - Cannot bind, specified object was not found!"); - return false; - } + SimObject* simObject = Sim::findObject(argv[argc - 1]); + if ( simObject == NULL ) + { + Con::warnf("ActionMap::bindObj() - Cannot bind, specified object was not found!"); + return false; + } - StringStackWrapper args(argc - 3, argv + 2); - - return object->processBind( args.count(), args, simObject ); + StringStackWrapper args(argc - 3, argv + 2); + return object->processBind( args.count(), args, simObject ); } //------------------------------------------------------------------------------ diff --git a/Engine/source/sim/netConnection.cpp b/Engine/source/sim/netConnection.cpp index 469d20f60..b16265b82 100644 --- a/Engine/source/sim/netConnection.cpp +++ b/Engine/source/sim/netConnection.cpp @@ -434,7 +434,7 @@ NetConnection::NetConnection() // Disable starting a new journal recording or playback from here on Journal::Disable(); - // jamesu - netAddress is not set + // Ensure NetAddress is cleared dMemset(&mNetAddress, '\0', sizeof(NetAddress)); } diff --git a/Engine/source/terrain/terrExport.cpp b/Engine/source/terrain/terrExport.cpp index 09fbbca19..1a9b3d76a 100644 --- a/Engine/source/terrain/terrExport.cpp +++ b/Engine/source/terrain/terrExport.cpp @@ -141,7 +141,7 @@ ConsoleMethod( TerrainBlock, exportHeightMap, bool, 3, 4, "(string filename, [st UTF8 fileName[1024]; String format = "png"; if( argc > 3 ) - format = (String)argv[ 3 ]; + format = (const char*)argv[ 3 ]; Con::expandScriptFilename( fileName, sizeof( fileName ), argv[2] ); @@ -153,7 +153,7 @@ ConsoleMethod( TerrainBlock, exportLayerMaps, bool, 3, 4, "(string filePrefix, [ UTF8 filePrefix[1024]; String format = "png"; if( argc > 3 ) - format = (String)argv[3]; + format = (const char*)argv[3]; Con::expandScriptFilename( filePrefix, sizeof( filePrefix ), argv[2] ); diff --git a/Engine/source/ts/collada/colladaImport.cpp b/Engine/source/ts/collada/colladaImport.cpp index f22ee4662..ca50a8f55 100644 --- a/Engine/source/ts/collada/colladaImport.cpp +++ b/Engine/source/ts/collada/colladaImport.cpp @@ -139,7 +139,7 @@ ConsoleFunction( enumColladaForImport, bool, 3, 3, GuiTreeViewCtrl* tree; if (!Sim::findObject(argv[2], tree)) { - Con::errorf("enumColladaScene::Could not find GuiTreeViewCtrl '%s'", argv[2]); + Con::errorf("enumColladaScene::Could not find GuiTreeViewCtrl '%s'", (const char*)argv[2]); return false; } diff --git a/Engine/source/ts/collada/colladaLights.cpp b/Engine/source/ts/collada/colladaLights.cpp index 62ea45c50..a13bed1ef 100644 --- a/Engine/source/ts/collada/colladaLights.cpp +++ b/Engine/source/ts/collada/colladaLights.cpp @@ -172,7 +172,7 @@ ConsoleFunction( loadColladaLights, bool, 2, 4, if (!Sim::findObject(argv[2], group)) { // Create the group if it could not be found group = new SimGroup; - if (group->registerObject(argv[2])) { + if (group->registerObject((const char*)argv[2])) { if (missionGroup) missionGroup->addObject(group); } diff --git a/Engine/source/util/messaging/eventManager.cpp b/Engine/source/util/messaging/eventManager.cpp index 328fe2d6d..e7c7d1d8a 100644 --- a/Engine/source/util/messaging/eventManager.cpp +++ b/Engine/source/util/messaging/eventManager.cpp @@ -471,7 +471,7 @@ ConsoleMethod( EventManager, subscribe, bool, 4, 5, "( SimObject listener, Strin return false; } - return object->subscribe( cbObj, argv[3], argc > 4 ? argv[4] : NULL ); + return object->subscribe( cbObj, argv[3], argc > 4 ? (const char*)argv[4] : NULL ); } ConsoleMethod( EventManager, remove, void, 4, 4, "( SimObject listener, String event )\n\n" diff --git a/Engine/source/util/undo.cpp b/Engine/source/util/undo.cpp index 3a8e52cff..0a04a8ca2 100644 --- a/Engine/source/util/undo.cpp +++ b/Engine/source/util/undo.cpp @@ -566,7 +566,7 @@ ConsoleMethod( UndoManager, pushCompound, const char*, 2, 3, "( string name=\"\" { String name; if( argc > 2 ) - name = (String)argv[ 2 ]; + name = (const char*)argv[ 2 ]; CompoundUndoAction* action = object->pushCompound( name ); if( !action ) @@ -584,7 +584,7 @@ ConsoleMethod( UndoManager, popCompound, void, 2, 3, "( bool discard=false ) - P { if( !object->getCompoundStackDepth() ) { - Con::errorf( "%s::popCompound - no compound on stack", argv[ 0 ] ); + Con::errorf( "%s::popCompound - no compound on stack", (const char*)argv[ 0 ] ); return; }