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
This commit is contained in:
jamesu 2012-10-11 21:29:39 +01:00 committed by James Urquhart
parent e99eadd61f
commit 08d4f6ebc0
58 changed files with 733 additions and 690 deletions

View file

@ -439,7 +439,7 @@ ConsoleMethod( LightBase, playAnimation, void, 2, 3, "( [LightAnimData anim] )\t
LightAnimData *animData; LightAnimData *animData;
if ( !Sim::findObject( argv[2], 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; return;
} }
@ -481,4 +481,4 @@ void LightBase::pauseAnimation( void )
mAnimState.active = false; mAnimState.active = false;
setMaskBits( UpdateMask ); setMaskBits( UpdateMask );
} }
} }

View file

@ -554,7 +554,7 @@ ConsoleMethod(SpawnSphere, spawnObject, S32, 2, 3,
String additionalProps; String additionalProps;
if (argc == 3) if (argc == 3)
additionalProps = String(argv[2]); additionalProps = (const char*)argv[2];
SimObject* obj = object->spawnObject(additionalProps); SimObject* obj = object->spawnObject(additionalProps);

View file

@ -147,13 +147,13 @@ ConsoleFunction( physicsDestroy, void, 1, 1, "physicsDestroy()" )
ConsoleFunction( physicsInitWorld, bool, 2, 2, "physicsInitWorld( String worldName )" ) 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 )" ) ConsoleFunction( physicsDestroyWorld, void, 2, 2, "physicsDestroyWorld( String worldName )" )
{ {
if ( PHYSICSMGR ) 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 )" ) ConsoleFunction( physicsStartSimulation, void, 2, 2, "physicsStartSimulation( String worldName )" )
{ {
if ( PHYSICSMGR ) if ( PHYSICSMGR )
PHYSICSMGR->enableSimulation( String( argv[1] ), true ); PHYSICSMGR->enableSimulation( (const char*)argv[1], true );
} }
ConsoleFunction( physicsStopSimulation, void, 2, 2, "physicsStopSimulation( String worldName )" ) ConsoleFunction( physicsStopSimulation, void, 2, 2, "physicsStopSimulation( String worldName )" )
{ {
if ( PHYSICSMGR ) if ( PHYSICSMGR )
PHYSICSMGR->enableSimulation( String( argv[1] ), false ); PHYSICSMGR->enableSimulation( (const char*)argv[1], false );
} }
ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled()" ) ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled()" )
@ -182,7 +182,7 @@ ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled
ConsoleFunction( physicsSetTimeScale, void, 2, 2, "physicsSetTimeScale( F32 scale )" ) ConsoleFunction( physicsSetTimeScale, void, 2, 2, "physicsSetTimeScale( F32 scale )" )
{ {
if ( PHYSICSMGR ) if ( PHYSICSMGR )
PHYSICSMGR->setTimeScale( dAtof( argv[1] ) ); PHYSICSMGR->setTimeScale( argv[1] );
} }
// Get the currently set time scale. // Get the currently set time scale.
@ -212,5 +212,5 @@ ConsoleFunction( physicsRestoreState, void, 1, 1, "physicsRestoreState()" )
ConsoleFunction( physicsDebugDraw, void, 2, 2, "physicsDebugDraw( bool enable )" ) ConsoleFunction( physicsDebugDraw, void, 2, 2, "physicsDebugDraw( bool enable )" )
{ {
if ( PHYSICSMGR ) if ( PHYSICSMGR )
PHYSICSMGR->enableDebugDraw( dAtoi( argv[1] ) ); PHYSICSMGR->enableDebugDraw( (S32)argv[1] );
} }

View file

@ -307,7 +307,7 @@ ConsoleFunction( addTaggedString, const char*, 2, 2, "(string str)"
"@see getTaggedString()\n" "@see getTaggedString()\n"
"@ingroup Networking\n") "@ingroup Networking\n")
{ {
NetStringHandle s(argv[1]); NetStringHandle s((const char*)argv[1]);
gNetStringTable->incStringRefScript(s.getIndex()); gNetStringTable->incStringRefScript(s.getIndex());
char *ret = Con::getReturnBuffer(10); char *ret = Con::getReturnBuffer(10);

View file

@ -21,6 +21,10 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include "component/dynamicConsoleMethodComponent.h" #include "component/dynamicConsoleMethodComponent.h"
#include "console/stringStack.h"
extern StringStack STR;
extern ConsoleValueStack CSTK;
IMPLEMENT_CO_NETOBJECT_V1(DynamicConsoleMethodComponent); IMPLEMENT_CO_NETOBJECT_V1(DynamicConsoleMethodComponent);
@ -152,23 +156,42 @@ const char *DynamicConsoleMethodComponent::_callMethod( U32 argc, ConsoleValueRe
DynamicConsoleMethodComponent *pThisComponent = dynamic_cast<DynamicConsoleMethodComponent*>( pComponent ); DynamicConsoleMethodComponent *pThisComponent = dynamic_cast<DynamicConsoleMethodComponent*>( pComponent );
AssertFatal( pThisComponent, "DynamicConsoleMethodComponent::callMethod - Non DynamicConsoleMethodComponent component attempting to callback!"); AssertFatal( pThisComponent, "DynamicConsoleMethodComponent::callMethod - Non DynamicConsoleMethodComponent component attempting to callback!");
// Prevent stack corruption
STR.pushFrame();
CSTK.pushFrame();
// --
// Only call on first depth components // Only call on first depth components
// Should isMethod check these calls? [11/22/2006 justind] // Should isMethod check these calls? [11/22/2006 justind]
if(pComponent->isEnabled()) if(pComponent->isEnabled())
Con::execute( pThisComponent, argc, argv ); Con::execute( pThisComponent, argc, argv );
// Prevent stack corruption
STR.popFrame();
CSTK.popFrame();
// --
// Bail if this was the first element // Bail if this was the first element
//if( nItr == componentList.begin() ) //if( nItr == componentList.begin() )
// break; // break;
} }
unlockComponentList(); unlockComponentList();
} }
// Prevent stack corruption
STR.pushFrame();
CSTK.pushFrame();
// --
// Set Owner Field // Set Owner Field
const char* result = ""; const char* result = "";
if(callThis) if(callThis)
result = Con::execute( pThis, argc, argv, true ); // true - exec method onThisOnly, not on DCMCs result = Con::execute( pThis, argc, argv, true ); // true - exec method onThisOnly, not on DCMCs
// Prevent stack corruption
STR.popFrame();
CSTK.popFrame();
// --
return result; return result;
} }

View file

@ -179,7 +179,7 @@ bool SimComponent::processArguments(S32 argc, ConsoleValueRef *argv)
if(obj) if(obj)
addComponent(obj); addComponent(obj);
else 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; return true;
} }
@ -383,7 +383,7 @@ ConsoleMethod( SimComponent, addComponents, bool, 3, 64, "%obj.addComponents( %c
if(obj) if(obj)
object->addComponent(obj); object->addComponent(obj);
else 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; return true;
} }
@ -399,7 +399,7 @@ ConsoleMethod( SimComponent, removeComponents, bool, 3, 64, "%obj.removeComponen
if(obj) if(obj)
object->removeComponent(obj); object->removeComponent(obj);
else 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; 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 true if is a template and false if not")
{ {
return object->getIsTemplate(); return object->getIsTemplate();
} }

View file

@ -103,10 +103,7 @@ S32 QSORT_CALLBACK ArrayObject::_keyFunctionCompare( const void* a, const void*
ArrayObject::Element* ea = ( ArrayObject::Element* )( a ); ArrayObject::Element* ea = ( ArrayObject::Element* )( a );
ArrayObject::Element* eb = ( ArrayObject::Element* )( b ); ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
const char* argv[ 3 ]; ConsoleValueRef argv[] = { smCompareFunction, ea->key, eb->key };
argv[ 0 ] = smCompareFunction;
argv[ 1 ] = ea->key;
argv[ 2 ] = eb->key;
S32 result = dAtoi( Con::execute( 3, argv ) ); S32 result = dAtoi( Con::execute( 3, argv ) );
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 ); 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* ea = ( ArrayObject::Element* )( a );
ArrayObject::Element* eb = ( ArrayObject::Element* )( b ); ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
const char* argv[ 3 ]; ConsoleValueRef argv[] = { smCompareFunction, ea->value, eb->value };
argv[ 0 ] = smCompareFunction;
argv[ 1 ] = ea->value;
argv[ 2 ] = eb->value;
S32 result = dAtoi( Con::execute( 3, argv ) ); S32 result = dAtoi( Con::execute( 3, argv ) );
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 ); S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 );

View file

@ -134,8 +134,8 @@ static U32 conversionOp(TypeReq src, TypeReq dst)
return OP_STR_TO_FLT; return OP_STR_TO_FLT;
case TypeReqNone: case TypeReqNone:
return OP_STR_TO_NONE; return OP_STR_TO_NONE;
case TypeReqVar: case TypeReqVar:
return OP_SAVEVAR_STR; return OP_SAVEVAR_STR;
default: default:
break; break;
} }
@ -150,7 +150,7 @@ static U32 conversionOp(TypeReq src, TypeReq dst)
return OP_FLT_TO_STR; return OP_FLT_TO_STR;
case TypeReqNone: case TypeReqNone:
return OP_FLT_TO_NONE; return OP_FLT_TO_NONE;
case TypeReqVar: case TypeReqVar:
return OP_SAVEVAR_FLT; return OP_SAVEVAR_FLT;
default: default:
break; break;
@ -166,7 +166,7 @@ static U32 conversionOp(TypeReq src, TypeReq dst)
return OP_UINT_TO_STR; return OP_UINT_TO_STR;
case TypeReqNone: case TypeReqNone:
return OP_UINT_TO_NONE; return OP_UINT_TO_NONE;
case TypeReqVar: case TypeReqVar:
return OP_SAVEVAR_UINT; return OP_SAVEVAR_UINT;
default: default:
break; break;
@ -276,21 +276,21 @@ U32 ReturnStmtNode::compileStmt(U32 *codeStream, U32 ip, U32, U32)
else else
{ {
TypeReq walkType = expr->getPreferredType(); TypeReq walkType = expr->getPreferredType();
if (walkType == TypeReqNone) walkType = TypeReqString; if (walkType == TypeReqNone) walkType = TypeReqString;
ip = expr->compile(codeStream, ip, walkType); ip = expr->compile(codeStream, ip, walkType);
// Return the correct type // Return the correct type
switch (walkType) { switch (walkType) {
case TypeReqUInt: case TypeReqUInt:
codeStream[ip++] = OP_RETURN_UINT; codeStream[ip++] = OP_RETURN_UINT;
break; break;
case TypeReqFloat: case TypeReqFloat:
codeStream[ip++] = OP_RETURN_FLT; codeStream[ip++] = OP_RETURN_FLT;
break; break;
default: default:
codeStream[ip++] = OP_RETURN; codeStream[ip++] = OP_RETURN;
break; break;
} }
} }
return ip; return ip;
} }
@ -1134,12 +1134,18 @@ U32 AssignExprNode::precompile(TypeReq type)
subType = expr->getPreferredType(); subType = expr->getPreferredType();
if(subType == TypeReqNone) if(subType == TypeReqNone)
subType = type; subType = type;
if(subType == TypeReqNone) { if(subType == TypeReqNone)
// jamesu - what we need to do in this case is turn it into a VarNode reference {
if (dynamic_cast<VarNode*>(expr) != NULL) { // What we need to do in this case is turn it into a VarNode reference.
// Sanity check passed // 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<VarNode*>(expr) != NULL)
{
subType = TypeReqVar; subType = TypeReqVar;
} else { }
else
{
subType = TypeReqString; subType = TypeReqString;
} }
} }
@ -1409,7 +1415,7 @@ U32 FuncCallExprNode::precompile(TypeReq type)
precompileIdent(nameSpace); precompileIdent(nameSpace);
for(ExprNode *walk = args; walk; walk = (ExprNode *) walk->getNext()) { for(ExprNode *walk = args; walk; walk = (ExprNode *) walk->getNext()) {
TypeReq walkType = walk->getPreferredType(); TypeReq walkType = walk->getPreferredType();
if (walkType == TypeReqNone) walkType = TypeReqString; if (walkType == TypeReqNone) walkType = TypeReqString;
size += walk->precompile(walkType) + 1; size += walk->precompile(walkType) + 1;
} }
return size + 5; 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()) for(ExprNode *walk = args; walk; walk = (ExprNode *) walk->getNext())
{ {
TypeReq walkType = walk->getPreferredType(); TypeReq walkType = walk->getPreferredType();
if (walkType == TypeReqNone) walkType = TypeReqString; if (walkType == TypeReqNone) walkType = TypeReqString;
ip = walk->compile(codeStream, ip, walkType); ip = walk->compile(codeStream, ip, walkType);
switch (walk->getPreferredType()) { switch (walk->getPreferredType())
case TypeReqFloat: {
codeStream[ip++] = OP_PUSH_FLT; case TypeReqFloat:
break; codeStream[ip++] = OP_PUSH_FLT;
case TypeReqUInt: break;
codeStream[ip++] = OP_PUSH_UINT; case TypeReqUInt:
break; codeStream[ip++] = OP_PUSH_UINT;
default: break;
codeStream[ip++] = OP_PUSH; default:
break; codeStream[ip++] = OP_PUSH;
} break;
}
} }
if(callType == MethodCall || callType == ParentCall) if(callType == MethodCall || callType == ParentCall)
codeStream[ip++] = OP_CALLFUNC; codeStream[ip++] = OP_CALLFUNC;
@ -1806,7 +1813,7 @@ U32 ObjectDeclNode::precompileSubObject(bool)
precompileIdent(parentObject); precompileIdent(parentObject);
for(ExprNode *exprWalk = argList; exprWalk; exprWalk = (ExprNode *) exprWalk->getNext()) { for(ExprNode *exprWalk = argList; exprWalk; exprWalk = (ExprNode *) exprWalk->getNext()) {
TypeReq walkType = exprWalk->getPreferredType(); TypeReq walkType = exprWalk->getPreferredType();
if (walkType == TypeReqNone) walkType = TypeReqString; if (walkType == TypeReqNone) walkType = TypeReqString;
argSize += exprWalk->precompile(walkType) + 1; argSize += exprWalk->precompile(walkType) + 1;
} }
argSize += classNameExpr->precompile(TypeReqString) + 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()) for(ExprNode *exprWalk = argList; exprWalk; exprWalk = (ExprNode *) exprWalk->getNext())
{ {
TypeReq walkType = exprWalk->getPreferredType(); TypeReq walkType = exprWalk->getPreferredType();
if (walkType == TypeReqNone) walkType = TypeReqString; if (walkType == TypeReqNone) walkType = TypeReqString;
ip = exprWalk->compile(codeStream, ip, walkType); ip = exprWalk->compile(codeStream, ip, walkType);
switch (exprWalk->getPreferredType()) { switch (exprWalk->getPreferredType())
case TypeReqFloat: {
codeStream[ip++] = OP_PUSH_FLT; case TypeReqFloat:
break; codeStream[ip++] = OP_PUSH_FLT;
case TypeReqUInt: break;
codeStream[ip++] = OP_PUSH_UINT; case TypeReqUInt:
break; codeStream[ip++] = OP_PUSH_UINT;
default: break;
codeStream[ip++] = OP_PUSH; default:
break; codeStream[ip++] = OP_PUSH;
} break;
}
} }
codeStream[ip++] = OP_CREATE_OBJECT; codeStream[ip++] = OP_CREATE_OBJECT;
codeStream[ip] = STEtoU32(parentObject, ip); codeStream[ip] = STEtoU32(parentObject, ip);

View file

@ -192,18 +192,16 @@ namespace Con
return STR.getArgBuffer(bufferSize); return STR.getArgBuffer(bufferSize);
} }
char *getFloatArg(F64 arg) ConsoleValueRef getFloatArg(F64 arg)
{ {
char *ret = STR.getArgBuffer(32); ConsoleValueRef ref = arg;
dSprintf(ret, 32, "%g", arg); return ref;
return ret;
} }
char *getIntArg(S32 arg) ConsoleValueRef getIntArg(S32 arg)
{ {
char *ret = STR.getArgBuffer(32); ConsoleValueRef ref = arg;
dSprintf(ret, 32, "%d", arg); return ref;
return ret;
} }
char *getStringArg( const char *arg ) char *getStringArg( const char *arg )
@ -287,7 +285,8 @@ inline void ExprEvalState::setStringVariable(const char *val)
inline void ExprEvalState::setCopyVariable() inline void ExprEvalState::setCopyVariable()
{ {
if (copyVariable) { if (copyVariable)
{
switch (copyVariable->value.type) switch (copyVariable->value.type)
{ {
case ConsoleValue::TypeInternalInt: case ConsoleValue::TypeInternalInt:
@ -485,16 +484,16 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi
StringTableEntry var = U32toSTE(code[ip + i + 6]); StringTableEntry var = U32toSTE(code[ip + i + 6]);
gEvalState.setCurVarNameCreate(var); gEvalState.setCurVarNameCreate(var);
ConsoleValueRef ref = argv[i+1]; ConsoleValueRef ref = argv[i+1];
if (argv[i+1].isString()) if (argv[i+1].isString())
gEvalState.setStringVariable(argv[i+1]); gEvalState.setStringVariable(argv[i+1]);
else if (argv[i+1].isInt()) else if (argv[i+1].isInt())
gEvalState.setIntVariable(argv[i+1]); gEvalState.setIntVariable(argv[i+1]);
else if (argv[i+1].isFloat()) else if (argv[i+1].isFloat())
gEvalState.setFloatVariable(argv[i+1]); gEvalState.setFloatVariable(argv[i+1]);
else else
gEvalState.setStringVariable(argv[i+1]); gEvalState.setStringVariable(argv[i+1]);
} }
ip = ip + fnArgc + 6; ip = ip + fnArgc + 6;
curFloatTable = functionFloats; 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 // either nothing or argv[] which we just copied
// NOTE: it might be better to do this when we are finished?
CSTK.resetFrame(); CSTK.resetFrame();
// Grab the state of the telenet debugger here once // 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 * val;
const char *retValue; 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; ConsoleValueRef returnValue;
// The frame temp is used by the variable accessor ops (OP_SAVEFIELD_* and // 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); Con::errorf(ConsoleLogEntry::General, "%s: Cannot re-declare data block %s with a different class.", getFileLine(ip), objectName);
ip = failJump; ip = failJump;
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
break; break;
} }
@ -730,18 +728,18 @@ breakContinue:
} }
//dMemcpy( savedArgv, callArgv, sizeof( savedArgv[ 0 ] ) * callArgc ); //dMemcpy( savedArgv, callArgv, sizeof( savedArgv[ 0 ] ) * callArgc );
// Prevent stack value corruption // Prevent stack value corruption
CSTK.pushFrame(); CSTK.pushFrame();
STR.pushFrame(); STR.pushFrame();
// -- // --
obj->deleteObject(); obj->deleteObject();
obj = NULL; obj = NULL;
// Prevent stack value corruption // Prevent stack value corruption
CSTK.popFrame(); CSTK.popFrame();
STR.popFrame(); STR.popFrame();
// -- // --
//dMemcpy( callArgv, savedArgv, sizeof( callArgv[ 0 ] ) * callArgc ); //dMemcpy( callArgv, savedArgv, sizeof( callArgv[ 0 ] ) * callArgc );
for (int i=0; i<callArgc; i++) { for (int i=0; i<callArgc; i++) {
@ -775,7 +773,7 @@ breakContinue:
getFileLine(ip), newName.c_str() ); getFileLine(ip), newName.c_str() );
ip = failJump; ip = failJump;
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
break; break;
} }
else else
@ -787,7 +785,7 @@ breakContinue:
getFileLine(ip), objectName); getFileLine(ip), objectName);
ip = failJump; ip = failJump;
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
break; break;
} }
} }
@ -795,7 +793,7 @@ breakContinue:
} }
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
if(!currentNewObject) if(!currentNewObject)
{ {
@ -885,10 +883,10 @@ breakContinue:
currentNewObject->setOriginalName( objectName ); currentNewObject->setOriginalName( objectName );
} }
// Prevent stack value corruption // Prevent stack value corruption
CSTK.pushFrame(); CSTK.pushFrame();
STR.pushFrame(); STR.pushFrame();
// -- // --
// Do the constructor parameters. // Do the constructor parameters.
if(!currentNewObject->processArguments(callArgc-3, callArgv+3)) if(!currentNewObject->processArguments(callArgc-3, callArgv+3))
@ -1041,10 +1039,10 @@ breakContinue:
else else
intStack[++_UINT] = currentNewObject->getId(); intStack[++_UINT] = currentNewObject->getId();
// Prevent stack value corruption // Prevent stack value corruption
CSTK.popFrame(); CSTK.popFrame();
STR.popFrame(); STR.popFrame();
// -- // --
break; break;
} }
@ -1127,7 +1125,7 @@ breakContinue:
// We're falling thru here on purpose. // We're falling thru here on purpose.
case OP_RETURN: case OP_RETURN:
retValue = STR.getStringValue(); retValue = STR.getStringValue();
if( iterDepth > 0 ) if( iterDepth > 0 )
{ {
@ -1140,12 +1138,12 @@ breakContinue:
STR.rewind(); STR.rewind();
STR.setStringValue( retValue ); // Not nice but works. 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(). // 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 // Now though we need to wrap it in a ConsoleValueRef
returnValue.value = CSTK.pushStackString(retValue); returnValue.value = CSTK.pushStackString(retValue);
goto execFinished; goto execFinished;
@ -1179,8 +1177,8 @@ breakContinue:
} }
} }
returnValue.value = CSTK.pushUINT(intStack[_UINT]); returnValue.value = CSTK.pushUINT(intStack[_UINT]);
_UINT--; _UINT--;
goto execFinished; goto execFinished;
@ -1323,7 +1321,7 @@ breakContinue:
var = U32toSTE(code[ip]); var = U32toSTE(code[ip]);
ip++; ip++;
// See OP_SETCURVAR // See OP_SETCURVAR
prevField = NULL; prevField = NULL;
prevObject = NULL; prevObject = NULL;
curObject = NULL; curObject = NULL;
@ -1398,7 +1396,7 @@ breakContinue:
break; break;
case OP_SAVEVAR_VAR: case OP_SAVEVAR_VAR:
// this basically handles %var1 = %var2 // this basically handles %var1 = %var2
gEvalState.setCopyVariable(); gEvalState.setCopyVariable();
break; break;
@ -1589,7 +1587,6 @@ breakContinue:
break; break;
case OP_COPYVAR_TO_NONE: case OP_COPYVAR_TO_NONE:
// nop
gEvalState.copyVariable = NULL; gEvalState.copyVariable = NULL;
break; break;
@ -1668,7 +1665,7 @@ breakContinue:
getFileLine(ip-4), fnNamespace ? fnNamespace : "", getFileLine(ip-4), fnNamespace ? fnNamespace : "",
fnNamespace ? "::" : "", fnName); fnNamespace ? "::" : "", fnName);
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
break; break;
} }
// Now fall through to OP_CALLFUNC... // 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); 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(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
break; break;
} }
@ -1774,7 +1771,7 @@ breakContinue:
} }
} }
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
if( routingId == MethodOnComponent ) if( routingId == MethodOnComponent )
STR.setStringValue( componentReturnValue ); STR.setStringValue( componentReturnValue );
@ -1789,9 +1786,9 @@ breakContinue:
if(nsEntry->mFunctionOffset) if(nsEntry->mFunctionOffset)
ret = nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage); ret = nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage);
STR.popFrame(); STR.popFrame();
// Functions are assumed to return strings, so look ahead to see if we can skip the conversion // Functions are assumed to return strings, so look ahead to see if we can skip the conversion
if(code[ip] == OP_STR_TO_UINT) if(code[ip] == OP_STR_TO_UINT)
{ {
ip++; ip++;
intStack[++_UINT] = (U32)((S32)ret); intStack[++_UINT] = (U32)((S32)ret);
@ -1806,9 +1803,9 @@ breakContinue:
else else
STR.setStringValue((const char*)ret); STR.setStringValue((const char*)ret);
// This will clear everything including returnValue // This will clear everything including returnValue
CSTK.popFrame(); CSTK.popFrame();
STR.clearFunctionOffset(); STR.clearFunctionOffset();
} }
else else
{ {
@ -1829,7 +1826,7 @@ breakContinue:
callArgc, nsEntry->mMinArgs, nsEntry->mMaxArgs); callArgc, nsEntry->mMinArgs, nsEntry->mMaxArgs);
Con::warnf(ConsoleLogEntry::Script, "%s: usage: %s", getFileLine(ip-4), nsEntry->mUsage); Con::warnf(ConsoleLogEntry::Script, "%s: usage: %s", getFileLine(ip-4), nsEntry->mUsage);
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
} }
else else
{ {
@ -1839,7 +1836,7 @@ breakContinue:
{ {
const char *ret = nsEntry->cb.mStringCallbackFunc(gEvalState.thisObject, callArgc, callArgv); const char *ret = nsEntry->cb.mStringCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
if(ret != STR.getStringValue()) if(ret != STR.getStringValue())
STR.setStringValue(ret); STR.setStringValue(ret);
//else //else
@ -1850,7 +1847,7 @@ breakContinue:
{ {
S32 result = nsEntry->cb.mIntCallbackFunc(gEvalState.thisObject, callArgc, callArgv); S32 result = nsEntry->cb.mIntCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
if(code[ip] == OP_STR_TO_UINT) if(code[ip] == OP_STR_TO_UINT)
{ {
ip++; ip++;
@ -1873,7 +1870,7 @@ breakContinue:
{ {
F64 result = nsEntry->cb.mFloatCallbackFunc(gEvalState.thisObject, callArgc, callArgv); F64 result = nsEntry->cb.mFloatCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
if(code[ip] == OP_STR_TO_UINT) if(code[ip] == OP_STR_TO_UINT)
{ {
ip++; 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); Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", getFileLine(ip-4), fnName, functionName);
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
STR.setStringValue(""); STR.setStringValue("");
break; break;
case Namespace::Entry::BoolCallbackType: case Namespace::Entry::BoolCallbackType:
{ {
bool result = nsEntry->cb.mBoolCallbackFunc(gEvalState.thisObject, callArgc, callArgv); bool result = nsEntry->cb.mBoolCallbackFunc(gEvalState.thisObject, callArgc, callArgv);
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
if(code[ip] == OP_STR_TO_UINT) if(code[ip] == OP_STR_TO_UINT)
{ {
ip++; ip++;
@ -1959,31 +1956,27 @@ breakContinue:
intStack[++_UINT] = STR.compare(); intStack[++_UINT] = STR.compare();
break; break;
case OP_PUSH: case OP_PUSH:
STR.push(); STR.push();
//Con::printf("Pushing str: %s",STR.getPreviousStringValue());
CSTK.pushString(STR.getPreviousStringValue()); CSTK.pushString(STR.getPreviousStringValue());
break; break;
case OP_PUSH_UINT: case OP_PUSH_UINT:
//Con::printf("Pushing int: %i",(S32)intStack[_UINT]);
CSTK.pushUINT(intStack[_UINT]); CSTK.pushUINT(intStack[_UINT]);
_UINT--; _UINT--;
break; break;
case OP_PUSH_FLT: case OP_PUSH_FLT:
//Con::printf("Pushing float: %f",(F32)intStack[_UINT]);
CSTK.pushFLT(floatStack[_FLT]); CSTK.pushFLT(floatStack[_FLT]);
_FLT--; _FLT--;
break; break;
case OP_PUSH_VAR: case OP_PUSH_VAR:
//Con::printf("Pushing variable: %s",gEvalState.getCurrentVariable()]);
if (gEvalState.currentVariable) if (gEvalState.currentVariable)
CSTK.pushValue(gEvalState.currentVariable->value); CSTK.pushValue(gEvalState.currentVariable->value);
else else
CSTK.pushString(""); CSTK.pushString("");
break; break;
case OP_PUSH_FRAME: case OP_PUSH_FRAME:
STR.pushFrame(); STR.pushFrame();
CSTK.pushFrame(); CSTK.pushFrame();
break; break;
case OP_ASSERT: case OP_ASSERT:
@ -2162,9 +2155,8 @@ execFinished:
if ( telDebuggerOn && setFrame < 0 ) if ( telDebuggerOn && setFrame < 0 )
TelDebugger->popStackFrame(); TelDebugger->popStackFrame();
if ( popFrame ) { if ( popFrame )
gEvalState.popFrame(); gEvalState.popFrame();
}
if(argv) if(argv)
{ {

View file

@ -54,8 +54,8 @@ namespace Compiler
OP_RETURN, OP_RETURN,
// fixes a bug when not explicitly returning a value // fixes a bug when not explicitly returning a value
OP_RETURN_VOID, OP_RETURN_VOID,
OP_RETURN_FLT, OP_RETURN_FLT,
OP_RETURN_UINT, OP_RETURN_UINT,
OP_CMPEQ, OP_CMPEQ,
OP_CMPGR, OP_CMPGR,

View file

@ -745,9 +745,9 @@ bool getVariableObjectField(const char *name, SimObject **object, const char **f
} }
else else
{ {
*object = obj; *object = obj;
*field = fieldToken; *field = fieldToken;
return true; return true;
} }
} }
} }
@ -778,9 +778,8 @@ Dictionary::Entry *getAddVariableEntry(const char *name)
name = prependDollar(name); name = prependDollar(name);
StringTableEntry stName = StringTable->insert(name); StringTableEntry stName = StringTable->insert(name);
Dictionary::Entry *entry = gEvalState.globalVars.lookup(stName); Dictionary::Entry *entry = gEvalState.globalVars.lookup(stName);
if (!entry) { if (!entry)
entry = gEvalState.globalVars.add(stName); entry = gEvalState.globalVars.add(stName);
}
return entry; return entry;
} }
@ -789,9 +788,8 @@ Dictionary::Entry *getAddLocalVariableEntry(const char *name)
name = prependPercent(name); name = prependPercent(name);
StringTableEntry stName = StringTable->insert(name); StringTableEntry stName = StringTable->insert(name);
Dictionary::Entry *entry = gEvalState.getCurrentFrame().lookup(stName); Dictionary::Entry *entry = gEvalState.getCurrentFrame().lookup(stName);
if (!entry) { if (!entry)
entry = gEvalState.getCurrentFrame().add(stName); entry = gEvalState.getCurrentFrame().add(stName);
}
return entry; return entry;
} }
@ -800,9 +798,12 @@ void setVariable(const char *name, const char *value)
SimObject *obj = NULL; SimObject *obj = NULL;
const char *objField = NULL; const char *objField = NULL;
if (getVariableObjectField(name, &obj, &objField)) { if (getVariableObjectField(name, &obj, &objField))
{
obj->setDataField(StringTable->insert(objField), 0, value); obj->setDataField(StringTable->insert(objField), 0, value);
} else { }
else
{
name = prependDollar(name); name = prependDollar(name);
gEvalState.globalVars.setVariable(StringTable->insert(name), value); gEvalState.globalVars.setVariable(StringTable->insert(name), value);
} }
@ -819,9 +820,12 @@ void setBoolVariable(const char *varName, bool value)
SimObject *obj = NULL; SimObject *obj = NULL;
const char *objField = NULL; const char *objField = NULL;
if (getVariableObjectField(varName, &obj, &objField)) { if (getVariableObjectField(varName, &obj, &objField))
{
obj->setDataField(StringTable->insert(objField), 0, value ? "1" : "0"); obj->setDataField(StringTable->insert(objField), 0, value ? "1" : "0");
} else { }
else
{
varName = prependDollar(varName); varName = prependDollar(varName);
Dictionary::Entry *entry = getAddVariableEntry(varName); Dictionary::Entry *entry = getAddVariableEntry(varName);
entry->setStringValue(value ? "1" : "0"); entry->setStringValue(value ? "1" : "0");
@ -833,11 +837,14 @@ void setIntVariable(const char *varName, S32 value)
SimObject *obj = NULL; SimObject *obj = NULL;
const char *objField = NULL; const char *objField = NULL;
if (getVariableObjectField(varName, &obj, &objField)) { if (getVariableObjectField(varName, &obj, &objField))
{
char scratchBuffer[32]; char scratchBuffer[32];
dSprintf(scratchBuffer, sizeof(scratchBuffer), "%d", value); dSprintf(scratchBuffer, sizeof(scratchBuffer), "%d", value);
obj->setDataField(StringTable->insert(objField), 0, scratchBuffer); obj->setDataField(StringTable->insert(objField), 0, scratchBuffer);
} else { }
else
{
varName = prependDollar(varName); varName = prependDollar(varName);
Dictionary::Entry *entry = getAddVariableEntry(varName); Dictionary::Entry *entry = getAddVariableEntry(varName);
entry->setIntValue(value); entry->setIntValue(value);
@ -849,11 +856,14 @@ void setFloatVariable(const char *varName, F32 value)
SimObject *obj = NULL; SimObject *obj = NULL;
const char *objField = NULL; const char *objField = NULL;
if (getVariableObjectField(varName, &obj, &objField)) { if (getVariableObjectField(varName, &obj, &objField))
{
char scratchBuffer[32]; char scratchBuffer[32];
dSprintf(scratchBuffer, sizeof(scratchBuffer), "%g", value); dSprintf(scratchBuffer, sizeof(scratchBuffer), "%g", value);
obj->setDataField(StringTable->insert(objField), 0, scratchBuffer); obj->setDataField(StringTable->insert(objField), 0, scratchBuffer);
} else { }
else
{
varName = prependDollar(varName); varName = prependDollar(varName);
Dictionary::Entry *entry = getAddVariableEntry(varName); Dictionary::Entry *entry = getAddVariableEntry(varName);
entry->setFloatValue(value); entry->setFloatValue(value);
@ -951,11 +961,14 @@ const char *getObjectTokenField(const char *name)
const char *getVariable(const char *name) const char *getVariable(const char *name)
{ {
const char *objField = getObjectTokenField(name); const char *objField = getObjectTokenField(name);
if (objField) { if (objField)
{
return objField; return objField;
} else { }
else
{
Dictionary::Entry *entry = getVariableEntry(name); 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) bool getBoolVariable(const char *varName, bool def)
{ {
const char *objField = getObjectTokenField(varName); const char *objField = getObjectTokenField(varName);
if (objField) { if (objField)
{
return *objField ? dAtob(objField) : def; return *objField ? dAtob(objField) : def;
} else { }
else
{
Dictionary::Entry *entry = getVariableEntry(varName); Dictionary::Entry *entry = getVariableEntry(varName);
objField = entry ? entry->getStringValue() : ""; objField = entry ? entry->getStringValue() : "";
return *objField ? dAtob(objField) : def; return *objField ? dAtob(objField) : def;
} }
} }
@ -981,22 +997,28 @@ bool getBoolVariable(const char *varName, bool def)
S32 getIntVariable(const char *varName, S32 def) S32 getIntVariable(const char *varName, S32 def)
{ {
const char *objField = getObjectTokenField(varName); const char *objField = getObjectTokenField(varName);
if (objField) { if (objField)
{
return *objField ? dAtoi(objField) : def; return *objField ? dAtoi(objField) : def;
} else { }
else
{
Dictionary::Entry *entry = getVariableEntry(varName); Dictionary::Entry *entry = getVariableEntry(varName);
return entry ? entry->getIntValue() : def; return entry ? entry->getIntValue() : def;
} }
} }
F32 getFloatVariable(const char *varName, F32 def) F32 getFloatVariable(const char *varName, F32 def)
{ {
const char *objField = getObjectTokenField(varName); const char *objField = getObjectTokenField(varName);
if (objField) { if (objField)
{
return *objField ? dAtof(objField) : def; return *objField ? dAtof(objField) : def;
} else { }
else
{
Dictionary::Entry *entry = getVariableEntry(varName); 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) 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. // Clean up arg buffers, if any.
STR.clearFunctionOffset(); STR.clearFunctionOffset();
CSTK.resetFrame(); CSTK.resetFrame();
return ""; return "";
} }
return ent->execute(argc, argv, &gEvalState); 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) const char *execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool thisCallOnly)
{ {
//static char idBuf[16];
if(argc < 2) if(argc < 2)
return ""; return "";
@ -1194,13 +1215,14 @@ const char *execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool th
if( !thisCallOnly ) if( !thisCallOnly )
{ {
ICallMethod *com = dynamic_cast<ICallMethod *>(object); ICallMethod *com = dynamic_cast<ICallMethod *>(object);
if(com) { if(com)
{
STR.pushFrame(); STR.pushFrame();
CSTK.pushFrame(); CSTK.pushFrame();
com->callMethodArgList(argc, argv, false); com->callMethodArgList(argc, argv, false);
STR.popFrame(); STR.popFrame();
CSTK.popFrame(); CSTK.popFrame();
} }
} }
if(object->getNamespace()) 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()); //warnf(ConsoleLogEntry::Script, "%s: undefined for object '%s' - id %d", funcName, object->getName(), object->getId());
// Clean up arg buffers, if any. // Clean up arg buffers, if any.
//CSTK.
STR.clearFunctionOffset(); STR.clearFunctionOffset();
CSTK.resetFrame(); CSTK.resetFrame();
return ""; return "";
} }
// Twiddle %this argument // Twiddle %this argument
argv[1] = (S32)ident; argv[1] = (S32)ident;
SimObject *save = gEvalState.thisObject; SimObject *save = gEvalState.thisObject;
gEvalState.thisObject = object; gEvalState.thisObject = object;
@ -1237,7 +1258,7 @@ const char *execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool th
return ret; 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 ""; return "";
} }
@ -1252,7 +1273,7 @@ inline const char*_executef(SimObject *obj, S32 checkArgc, S32 argc, ConsoleValu
const U32 maxArg = 12; const U32 maxArg = 12;
AssertWarn(checkArgc == argc, "Incorrect arg count passed to Con::executef(SimObject*)"); 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."); 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 #define A ConsoleValueRef
@ -1589,14 +1610,16 @@ StringStackWrapper::StringStackWrapper(int targc, ConsoleValueRef targv[])
argv = new const char*[targc]; argv = new const char*[targc];
argc = targc; argc = targc;
for (int i=0; i<targc; i++) { for (int i=0; i<targc; i++)
{
argv[i] = dStrdup(targv[i]); argv[i] = dStrdup(targv[i]);
} }
} }
StringStackWrapper::~StringStackWrapper() StringStackWrapper::~StringStackWrapper()
{ {
for (int i=0; i<argc; i++) { for (int i=0; i<argc; i++)
{
dFree(argv[i]); dFree(argv[i]);
} }
delete[] argv; delete[] argv;
@ -1615,7 +1638,8 @@ StringStackConsoleWrapper::StringStackConsoleWrapper(int targc, const char** tar
StringStackConsoleWrapper::~StringStackConsoleWrapper() StringStackConsoleWrapper::~StringStackConsoleWrapper()
{ {
for (int i=0; i<argc; i++) { for (int i=0; i<argc; i++)
{
argv[i] = NULL; argv[i] = NULL;
} }
delete[] argv; delete[] argv;
@ -1623,86 +1647,88 @@ StringStackConsoleWrapper::~StringStackConsoleWrapper()
U32 ConsoleValue::getIntValue() U32 ConsoleValue::getIntValue()
{
if(type <= TypeInternalString)
return ival;
else
return dAtoi(Con::getData(type, dataPtr, 0, enumTable));
}
F32 ConsoleValue::getFloatValue()
{
if(type <= TypeInternalString)
return fval;
else
return dAtof(Con::getData(type, dataPtr, 0, enumTable));
}
const char *ConsoleValue::getStringValue()
{
if(type == TypeInternalString || type == TypeInternalStackString)
return sval;
if(type == TypeInternalFloat)
return Con::getData(TypeF32, &fval, 0);
else if(type == TypeInternalInt)
return Con::getData(TypeS32, &ival, 0);
else
return Con::getData(type, dataPtr, 0, enumTable);
}
void ConsoleValue::setIntValue(U32 val)
{
if(type <= TypeInternalString)
{ {
if(type <= TypeInternalString) fval = (F32)val;
return ival; ival = val;
else if(sval != typeValueEmpty)
return dAtoi(Con::getData(type, dataPtr, 0, enumTable));
}
F32 ConsoleValue::getFloatValue()
{
if(type <= TypeInternalString)
return fval;
else
return dAtof(Con::getData(type, dataPtr, 0, enumTable));
}
const char *ConsoleValue::getStringValue()
{
if(type == TypeInternalString || type == TypeInternalStackString)
return sval;
if(type == TypeInternalFloat)
return Con::getData(TypeF32, &fval, 0);
else if(type == TypeInternalInt)
return Con::getData(TypeS32, &ival, 0);
else
return Con::getData(type, dataPtr, 0, enumTable);
}
void ConsoleValue::setIntValue(U32 val)
{
if(type <= TypeInternalString)
{ {
fval = (F32)val; if (type != TypeInternalStackString) dFree(sval);
ival = val; sval = typeValueEmpty;
if(sval != typeValueEmpty)
{
if (type != TypeInternalStackString) dFree(sval);
sval = typeValueEmpty;
}
type = TypeInternalInt;
}
else
{
const char *dptr = Con::getData(TypeS32, &val, 0);
Con::setData(type, dataPtr, 0, 1, &dptr, enumTable);
} }
type = TypeInternalInt;
} }
else
void ConsoleValue::setFloatValue(F32 val)
{ {
if(type <= TypeInternalString) const char *dptr = Con::getData(TypeS32, &val, 0);
{ Con::setData(type, dataPtr, 0, 1, &dptr, enumTable);
fval = val;
ival = static_cast<U32>(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);
}
} }
}
void ConsoleValue::setFloatValue(F32 val)
{
if(type <= TypeInternalString)
{
fval = val;
ival = static_cast<U32>(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)
if (stringStackValue == NULL) { stringStackValue = Con::getStringArg(value->getStringValue());
stringStackValue = Con::getStringArg(value->getStringValue()); return stringStackValue;
}
return stringStackValue;
} else {
return "";
}
} }
else
{
return "";
}
}
extern ConsoleValueStack CSTK; extern ConsoleValueStack CSTK;
@ -1748,4 +1774,4 @@ namespace Con
{ {
CSTK.resetFrame(); CSTK.resetFrame();
} }
} }

View file

@ -123,7 +123,7 @@ public:
{ {
TypeInternalInt = -4, TypeInternalInt = -4,
TypeInternalFloat = -3, TypeInternalFloat = -3,
TypeInternalStackString = -2, TypeInternalStackString = -2,
TypeInternalString = -1, TypeInternalString = -1,
}; };
@ -197,9 +197,10 @@ public:
}; };
// Proxy class for console variables // Proxy class for console variables
// Can point to existing console variables // Can point to existing console variables,
// or act like a free floating value // or act like a free floating value.
class ConsoleValueRef { class ConsoleValueRef
{
public: public:
ConsoleValue *value; ConsoleValue *value;
const char *stringStackValue; const char *stringStackValue;
@ -219,13 +220,11 @@ public:
inline S32 getIntValue() { return value ? value->getIntValue() : 0; } inline S32 getIntValue() { return value ? value->getIntValue() : 0; }
inline F32 getFloatValue() { return value ? value->getFloatValue() : 0.0f; } 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 const char*() { return getStringValue(); }
inline operator String() { return String(getStringValue()); } inline operator String() { return String(getStringValue()); }
inline operator S32() { return getIntValue(); } inline operator S32() { return getIntValue(); }
inline operator F32() { return getFloatValue(); } inline operator F32() { return getFloatValue(); }
//inline operator F64() { return getDoubleValue(); }
inline bool isString() { return value ? value->type >= ConsoleValue::TypeInternalStackString : true; } inline bool isString() { return value ? value->type >= ConsoleValue::TypeInternalStackString : true; }
inline bool isInt() { return value ? value->type == ConsoleValue::TypeInternalInt : false; } inline bool isInt() { return value ? value->type == ConsoleValue::TypeInternalInt : false; }
@ -239,6 +238,19 @@ public:
ConsoleValueRef& operator=(F64 newValue); 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** // Transparently converts ConsoleValue[] to const char**
class StringStackWrapper class StringStackWrapper
{ {
@ -342,6 +354,7 @@ namespace Con
/// 09/12/07 - CAF - 43->44 remove newmsg operator /// 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 /// 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 /// 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, DSOVersion = 47,
MaxLineLength = 512, ///< Maximum length of a line of console input. MaxLineLength = 512, ///< Maximum length of a line of console input.
@ -807,8 +820,8 @@ namespace Con
char* getReturnBuffer( const StringBuilder& str ); char* getReturnBuffer( const StringBuilder& str );
char* getArgBuffer(U32 bufferSize); char* getArgBuffer(U32 bufferSize);
char* getFloatArg(F64 arg); ConsoleValueRef getFloatArg(F64 arg);
char* getIntArg (S32 arg); ConsoleValueRef getIntArg (S32 arg);
char* getStringArg( const char *arg ); char* getStringArg( const char *arg );
char* getStringArg( const String& arg ); char* getStringArg( const String& arg );
/// @} /// @}

View file

@ -1306,7 +1306,7 @@ ConsoleFunction(getTag, const char *, 2, 2, "(string textTagString)"
TORQUE_UNUSED(argc); TORQUE_UNUSED(argc);
if(argv[1][0] == StringTagPrefixByte) if(argv[1][0] == StringTagPrefixByte)
{ {
const char *arg = argv[1]; const char *arg = argv[1];
const char * space = dStrchr(argv[1], ' '); const char * space = dStrchr(argv[1], ' ');
U32 len; 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)) if (dStrcmp(argv[1], "0") && dStrcmp(argv[1], "") && (Sim::findObject(argv[1]) != NULL))
return true; return true;
else if (argc > 2) 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; 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" "@note Appears to be useless in Torque 3D, should be deprecated\n"
"@internal") "@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) if(filename == NULL || *filename == 0)
return ""; return "";

View file

@ -34,45 +34,6 @@
//#define DEBUG_SPEW //#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 #define ST_INIT_SIZE 15
static char scratchBuffer[1024]; static char scratchBuffer[1024];
@ -325,10 +286,8 @@ Dictionary::Entry *Dictionary::add(StringTableEntry name)
//printf("Add Variable %s\n", name); //printf("Add Variable %s\n", name);
Entry* ret = lookup( name ); Entry* ret = lookup( name );
if( ret ) { if( ret )
//printf("Found Variable %s (named %s)\n", name, ret->name);
return ret; return ret;
}
// Rehash if the table get's too crowded. Be aware that this might // Rehash if the table get's too crowded. Be aware that this might
// modify a table that we don't own. // modify a table that we don't own.
@ -337,7 +296,6 @@ Dictionary::Entry *Dictionary::add(StringTableEntry name)
if( hashTable->count > hashTable->size * 2 ) if( hashTable->count > hashTable->size * 2 )
{ {
// Allocate a new table. // Allocate a new table.
printf("Re-hashing dictionary...\n");
const U32 newTableSize = hashTable->size * 4 - 1; const U32 newTableSize = hashTable->size * 4 - 1;
Entry** newTableData = new Entry*[ newTableSize ]; Entry** newTableData = new Entry*[ newTableSize ];
@ -351,9 +309,6 @@ Dictionary::Entry *Dictionary::add(StringTableEntry name)
Entry* next = entry->nextEntry; Entry* next = entry->nextEntry;
U32 index = HashPointer( entry->name ) % newTableSize; 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 ]; entry->nextEntry = newTableData[ index ];
newTableData[ index ] = entry; newTableData[ index ] = entry;
@ -373,9 +328,8 @@ Dictionary::Entry *Dictionary::add(StringTableEntry name)
// Add the new entry. // Add the new entry.
ret = getDictionaryStackEntry();//hashTable->mChunker.alloc(); ret = hashTable->mChunker.alloc();
ret->name = name; constructInPlace( ret, name );
//constructInPlace( ret, name );
U32 idx = HashPointer(name) % hashTable->size; U32 idx = HashPointer(name) % hashTable->size;
ret->nextEntry = hashTable->data[idx]; ret->nextEntry = hashTable->data[idx];
hashTable->data[idx] = ret; hashTable->data[idx] = ret;
@ -396,8 +350,8 @@ void Dictionary::remove(Dictionary::Entry *ent)
*walk = (ent->nextEntry); *walk = (ent->nextEntry);
disposeDictionaryStackEntry( ent ); destructInPlace( ent );
//hashTable->mChunker.free( ent ); hashTable->mChunker.free( ent );
hashTable->count--; hashTable->count--;
} }
@ -458,13 +412,13 @@ void Dictionary::reset()
while( walk ) while( walk )
{ {
Entry* temp = walk->nextEntry; Entry* temp = walk->nextEntry;
disposeDictionaryStackEntry( walk ); destructInPlace( walk );
walk = temp; walk = temp;
} }
} }
dMemset( ownHashTable.data, 0, ownHashTable.size * sizeof( Entry* ) ); dMemset( ownHashTable.data, 0, ownHashTable.size * sizeof( Entry* ) );
//ownHashTable.mChunker.freeBlocks( true ); ownHashTable.mChunker.freeBlocks( true );
ownHashTable.count = 0; ownHashTable.count = 0;
hashTable = NULL; hashTable = NULL;
@ -556,15 +510,16 @@ void ConsoleValue::setStringValue(const char * value)
return; return;
} }
*/ */
if (value == typeValueEmpty) { if (value == typeValueEmpty)
if (sval && sval != typeValueEmpty && type != TypeInternalStackString) dFree(sval); {
sval = typeValueEmpty; if (sval && sval != typeValueEmpty && type != TypeInternalStackString) dFree(sval);
bufferLen = 0; sval = typeValueEmpty;
fval = 0.f; bufferLen = 0;
ival = 0; fval = 0.f;
type = TypeInternalString; ival = 0;
return; type = TypeInternalString;
} return;
}
U32 stringLen = dStrlen(value); U32 stringLen = dStrlen(value);
@ -586,7 +541,7 @@ void ConsoleValue::setStringValue(const char * value)
// may as well pad to the next cache line // may as well pad to the next cache line
U32 newLen = ((stringLen + 1) + 15) & ~15; U32 newLen = ((stringLen + 1) + 15) & ~15;
if(sval == typeValueEmpty || type == TypeInternalStackString) if(sval == typeValueEmpty || type == TypeInternalStackString)
sval = (char *) dMalloc(newLen); sval = (char *) dMalloc(newLen);
else if(newLen > bufferLen) else if(newLen > bufferLen)
sval = (char *) dRealloc(sval, newLen); sval = (char *) dRealloc(sval, newLen);
@ -607,15 +562,16 @@ void ConsoleValue::setStackStringValue(const char * value)
if(type <= ConsoleValue::TypeInternalString) if(type <= ConsoleValue::TypeInternalString)
{ {
if (value == typeValueEmpty) { if (value == typeValueEmpty)
if (sval && sval != typeValueEmpty && type != ConsoleValue::TypeInternalStackString) dFree(sval); {
sval = typeValueEmpty; if (sval && sval != typeValueEmpty && type != ConsoleValue::TypeInternalStackString) dFree(sval);
bufferLen = 0; sval = typeValueEmpty;
bufferLen = 0;
fval = 0.f; fval = 0.f;
ival = 0; ival = 0;
type = TypeInternalString; type = TypeInternalString;
return; return;
} }
U32 stringLen = dStrlen(value); U32 stringLen = dStrlen(value);
if(stringLen < 256) if(stringLen < 256)
@ -640,32 +596,34 @@ void ConsoleValue::setStackStringValue(const char * value)
S32 Dictionary::getIntVariable(StringTableEntry name, bool *entValid) S32 Dictionary::getIntVariable(StringTableEntry name, bool *entValid)
{ {
Entry *ent = lookup(name); Entry *ent = lookup(name);
if(ent) if(ent)
{ {
if(entValid) if(entValid)
*entValid = true; *entValid = true;
return ent->getIntValue(); return ent->getIntValue();
} }
if(entValid)
*entValid = false; if(entValid)
*entValid = false;
return 0; return 0;
} }
F32 Dictionary::getFloatVariable(StringTableEntry name, bool *entValid) F32 Dictionary::getFloatVariable(StringTableEntry name, bool *entValid)
{ {
Entry *ent = lookup(name); Entry *ent = lookup(name);
if(ent) if(ent)
{ {
if(entValid) if(entValid)
*entValid = true; *entValid = true;
return ent->getFloatValue(); return ent->getFloatValue();
} }
if(entValid)
*entValid = false;
return 0; if(entValid)
*entValid = false;
return 0;
} }
void Dictionary::setVariable(StringTableEntry name, const char *value) void Dictionary::setVariable(StringTableEntry name, const char *value)
@ -726,7 +684,7 @@ void Dictionary::addVariableNotify( const char *name, const Con::NotifyDelegate
return; return;
if ( !ent->notify ) if ( !ent->notify )
ent->notify = new Entry::NotifySignal(); ent->notify = new Entry::NotifySignal();
ent->notify->notify( callback ); ent->notify->notify( callback );
} }
@ -1141,8 +1099,6 @@ void Namespace::init()
mGlobalNamespace->mName = NULL; mGlobalNamespace->mName = NULL;
mGlobalNamespace->mNext = NULL; mGlobalNamespace->mNext = NULL;
mNamespaceList = mGlobalNamespace; mNamespaceList = mGlobalNamespace;
setupDictionaryStack();
} }
Namespace *Namespace::global() Namespace *Namespace::global()

View file

@ -384,138 +384,138 @@ public:
} }
}; };
struct HashTableData struct HashTableData
{ {
Dictionary* owner; Dictionary* owner;
S32 size; S32 size;
S32 count; S32 count;
Entry **data; Entry **data;
FreeListChunker< Entry > mChunker; FreeListChunker< Entry > mChunker;
HashTableData( Dictionary* owner ) HashTableData( Dictionary* owner )
: owner( owner ), size( 0 ), count( 0 ), data( NULL ) {} : owner( owner ), size( 0 ), count( 0 ), data( NULL ) {}
}; };
HashTableData* hashTable; HashTableData* hashTable;
HashTableData ownHashTable; HashTableData ownHashTable;
ExprEvalState *exprState; ExprEvalState *exprState;
StringTableEntry scopeName;
Namespace *scopeNamespace;
CodeBlock *code;
U32 ip;
Dictionary(); StringTableEntry scopeName;
~Dictionary(); Namespace *scopeNamespace;
CodeBlock *code;
U32 ip;
Entry *lookup(StringTableEntry name); Dictionary();
Entry *add(StringTableEntry name); ~Dictionary();
void setState(ExprEvalState *state, Dictionary* ref=NULL);
void remove(Entry *);
void reset();
void exportVariables( const char *varString, const char *fileName, bool append ); Entry *lookup(StringTableEntry name);
void exportVariables( const char *varString, Vector<String> *names, Vector<String> *values ); Entry *add(StringTableEntry name);
void deleteVariables( const char *varString ); void setState(ExprEvalState *state, Dictionary* ref=NULL);
void remove(Entry *);
void reset();
void setVariable(StringTableEntry name, const char *value); void exportVariables( const char *varString, const char *fileName, bool append );
const char *getVariable(StringTableEntry name, bool *valid = NULL); void exportVariables( const char *varString, Vector<String> *names, Vector<String> *values );
S32 getIntVariable(StringTableEntry name, bool *valid = NULL); void deleteVariables( const char *varString );
F32 getFloatVariable(StringTableEntry name, bool *entValid = NULL);
void setVariable(StringTableEntry name, const char *value);
U32 getCount() const 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; return hashTable->count;
} }
bool isOwner() const bool isOwner() const
{ {
return hashTable->owner; return hashTable->owner;
} }
/// @see Con::addVariable /// @see Con::addVariable
Entry* addVariable( const char *name, Entry* addVariable( const char *name,
S32 type, S32 type,
void *dataPtr, void *dataPtr,
const char* usage ); const char* usage );
/// @see Con::removeVariable /// @see Con::removeVariable
bool removeVariable(StringTableEntry name); bool removeVariable(StringTableEntry name);
/// @see Con::addVariableNotify /// @see Con::addVariableNotify
void addVariableNotify( const char *name, const Con::NotifyDelegate &callback ); void addVariableNotify( const char *name, const Con::NotifyDelegate &callback );
/// @see Con::removeVariableNotify /// @see Con::removeVariableNotify
void removeVariableNotify( const char *name, const Con::NotifyDelegate &callback ); void removeVariableNotify( const char *name, const Con::NotifyDelegate &callback );
/// Return the best tab completion for prevText, with the length /// Return the best tab completion for prevText, with the length
/// of the pre-tab string in baseLen. /// of the pre-tab string in baseLen.
const char *tabComplete(const char *prevText, S32 baseLen, bool); const char *tabComplete(const char *prevText, S32 baseLen, bool);
/// Run integrity checks for debugging. /// Run integrity checks for debugging.
void validate(); void validate();
}; };
class ExprEvalState class ExprEvalState
{ {
public: public:
/// @name Expression Evaluation /// @name Expression Evaluation
/// @{ /// @{
/// ///
SimObject *thisObject; SimObject *thisObject;
Dictionary::Entry *currentVariable; Dictionary::Entry *currentVariable;
Dictionary::Entry *copyVariable; Dictionary::Entry *copyVariable;
bool traceOn; bool traceOn;
U32 mStackDepth;
ExprEvalState(); U32 mStackDepth;
~ExprEvalState();
/// @} ExprEvalState();
~ExprEvalState();
/// @name Stack Management /// @}
/// @{
/// The stack of callframes. The extra redirection is necessary since Dictionary holds /// @name Stack Management
/// an interior pointer that will become invalid when the object changes address. /// @{
Vector< Dictionary* > stack;
/// /// The stack of callframes. The extra redirection is necessary since Dictionary holds
Dictionary globalVars; /// an interior pointer that will become invalid when the object changes address.
Vector< Dictionary* > stack;
void setCurVarName(StringTableEntry name);
void setCurVarNameCreate(StringTableEntry name);
S32 getIntVariable(); ///
F64 getFloatVariable(); Dictionary globalVars;
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 setCurVarName(StringTableEntry name);
void popFrame(); void setCurVarNameCreate(StringTableEntry name);
/// Puts a reference to an existing stack frame S32 getIntVariable();
/// on the top of the stack. F64 getFloatVariable();
void pushFrameRef(S32 stackIndex); const char *getStringVariable();
void setIntVariable(S32 val);
U32 getStackDepth() const void setFloatVariable(F64 val);
{ void setStringVariable(const char *str);
return mStackDepth; void setCopyVariable();
}
void pushFrame(StringTableEntry frameName, Namespace *ns);
Dictionary& getCurrentFrame() 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 ] ); return *( stack[ mStackDepth - 1 ] );
} }
/// @} /// @}
/// Run integrity checks for debugging. /// Run integrity checks for debugging.
void validate(); void validate();
}; };
namespace Con namespace Con

View file

@ -160,7 +160,7 @@ inline void EngineMarshallData( bool arg, S32& argc, ConsoleValueRef *argv )
} }
inline void EngineMarshallData( S32 arg, S32& argc, ConsoleValueRef *argv ) inline void EngineMarshallData( S32 arg, S32& argc, ConsoleValueRef *argv )
{ {
argv[ argc ] = Con::getIntArg( arg ); argv[ argc ] = arg;
argc ++; argc ++;
} }
inline void EngineMarshallData( U32 arg, S32& argc, ConsoleValueRef *argv ) 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 ) inline void EngineMarshallData( F32 arg, S32& argc, ConsoleValueRef *argv )
{ {
argv[ argc ] = Con::getFloatArg( arg ); argv[ argc ] = arg;
argc ++; argc ++;
} }
inline void EngineMarshallData( const char* arg, S32& argc, ConsoleValueRef *argv ) inline void EngineMarshallData( const char* arg, S32& argc, ConsoleValueRef *argv )
@ -207,6 +207,11 @@ struct EngineUnmarshallData
template<> template<>
struct EngineUnmarshallData< S32 > struct EngineUnmarshallData< S32 >
{ {
S32 operator()( ConsoleValueRef &ref ) const
{
return (S32)ref;
}
S32 operator()( const char* str ) const S32 operator()( const char* str ) const
{ {
return dAtoi( str ); return dAtoi( str );
@ -215,6 +220,11 @@ struct EngineUnmarshallData< S32 >
template<> template<>
struct EngineUnmarshallData< U32 > struct EngineUnmarshallData< U32 >
{ {
U32 operator()( ConsoleValueRef &ref ) const
{
return (U32)((S32)ref);
}
U32 operator()( const char* str ) const U32 operator()( const char* str ) const
{ {
return dAtoui( str ); return dAtoui( str );
@ -223,6 +233,11 @@ struct EngineUnmarshallData< U32 >
template<> template<>
struct EngineUnmarshallData< F32 > struct EngineUnmarshallData< F32 >
{ {
F32 operator()( ConsoleValueRef &ref ) const
{
return (F32)ref;
}
F32 operator()( const char* str ) const F32 operator()( const char* str ) const
{ {
return dAtof( str ); return dAtof( str );
@ -2626,12 +2641,12 @@ struct _EngineConsoleCallbackHelper
if( mThis ) if( mThis )
{ {
// Cannot invoke callback until object has been registered // Cannot invoke callback until object has been registered
if (mThis->isProperlyAdded()) { if (mThis->isProperlyAdded()) {
return Con::execute( mThis, mArgc, mArgv ); return Con::execute( mThis, mArgc, mArgv );
} else { } else {
Con::resetStackFrame(); // jamesu - we might have pushed some vars here Con::resetStackFrame(); // We might have pushed some vars here
return ""; return "";
} }
} }
else else
return Con::execute( mArgc, mArgv ); return Con::execute( mArgc, mArgv );

View file

@ -383,7 +383,7 @@ ConsoleMethod(FieldBrushObject, copyFields, void, 3, 4, "(simObject, [fieldList]
} }
// Fetch field list. // Fetch field list.
const char* pFieldList = (argc > 3 ) ? argv[3] : NULL; const char* pFieldList = (argc > 3 ) ? (const char*)argv[3] : NULL;
// Copy Fields. // Copy Fields.
object->copyFields( pSimObject, pFieldList ); object->copyFields( pSimObject, pFieldList );

View file

@ -2204,7 +2204,7 @@ ConsoleMethod( PersistenceManager, setDirty, void, 3, 4, "(SimObject object, [fi
{ {
if (!Sim::findObject(argv[2], dirtyObject)) 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; return;
} }
} }
@ -2213,7 +2213,7 @@ ConsoleMethod( PersistenceManager, setDirty, void, 3, 4, "(SimObject object, [fi
if( dirtyObject == Sim::getRootGroup() ) if( dirtyObject == Sim::getRootGroup() )
{ {
Con::errorf( "%s(): Cannot save RootGroup", argv[ 0 ] ); Con::errorf( "%s(): Cannot save RootGroup", (const char*)argv[ 0 ] );
return; return;
} }
@ -2234,7 +2234,7 @@ ConsoleMethod( PersistenceManager, removeDirty, void, 3, 3, "(SimObject object)"
{ {
if (!Sim::findObject(argv[2], dirtyObject)) 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; return;
} }
} }
@ -2251,7 +2251,7 @@ ConsoleMethod( PersistenceManager, isDirty, bool, 3, 3, "(SimObject object)"
{ {
if (!Sim::findObject(argv[2], dirtyObject)) 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; return false;
} }
} }
@ -2280,7 +2280,7 @@ ConsoleMethod( PersistenceManager, getDirtyObject, S32, 3, 3, "( index )"
const S32 index = dAtoi( argv[2] ); const S32 index = dAtoi( argv[2] );
if ( index < 0 || index >= object->getDirtyList().size() ) 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; return 0;
} }
@ -2333,7 +2333,7 @@ ConsoleMethod( PersistenceManager, saveDirtyObject, bool, 3, 3, "(SimObject obje
{ {
if (!Sim::findObject(argv[2], dirtyObject)) 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; return false;
} }
} }
@ -2358,7 +2358,7 @@ ConsoleMethod( PersistenceManager, removeObjectFromFile, void, 3, 4, "(SimObject
{ {
if (!Sim::findObject(argv[2], dirtyObject)) 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; return;
} }
} }
@ -2380,7 +2380,7 @@ ConsoleMethod( PersistenceManager, removeField, void, 4, 4, "(SimObject object,
{ {
if (!Sim::findObject(argv[2], dirtyObject)) 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; return;
} }
} }
@ -2390,4 +2390,4 @@ ConsoleMethod( PersistenceManager, removeField, void, 4, 4, "(SimObject object,
if (argv[3][0]) if (argv[3][0])
object->addRemoveField(dirtyObject, argv[3]); object->addRemoveField(dirtyObject, argv[3]);
} }
} }

View file

@ -138,20 +138,20 @@ ConsoleDocFragment _spawnObject1(
ConsoleFunction(spawnObject, S32, 3, 6, "spawnObject(class [, dataBlock, name, properties, script])" ConsoleFunction(spawnObject, S32, 3, 6, "spawnObject(class [, dataBlock, name, properties, script])"
"@hide") "@hide")
{ {
String spawnClass((String)argv[1]); String spawnClass((const char*)argv[1]);
String spawnDataBlock; String spawnDataBlock;
String spawnName; String spawnName;
String spawnProperties; String spawnProperties;
String spawnScript; String spawnScript;
if (argc >= 3) if (argc >= 3)
spawnDataBlock = (String)argv[2]; spawnDataBlock = (const char*)argv[2];
if (argc >= 4) if (argc >= 4)
spawnName = (String)argv[3]; spawnName = (const char*)argv[3];
if (argc >= 5) if (argc >= 5)
spawnProperties = (String)argv[4]; spawnProperties = (const char*)argv[4];
if (argc >= 6) if (argc >= 6)
spawnScript = (String)argv[5]; spawnScript = (const char*)argv[5];
SimObject* spawnObject = Sim::spawnObject(spawnClass, spawnDataBlock, spawnName, spawnProperties, spawnScript); SimObject* spawnObject = Sim::spawnObject(spawnClass, spawnDataBlock, spawnName, spawnProperties, spawnScript);

View file

@ -32,6 +32,9 @@
#ifndef _MODULE_H_ #ifndef _MODULE_H_
#include "core/module.h" #include "core/module.h"
#endif #endif
#ifndef _CONSOLE_H_
#include "console/console.h"
#endif
// Forward Refs // Forward Refs
class SimSet; class SimSet;
@ -122,9 +125,15 @@ namespace Sim
SimDataBlockGroup *getDataBlockGroup(); SimDataBlockGroup *getDataBlockGroup();
SimGroup* getRootGroup(); SimGroup* getRootGroup();
SimObject* findObject(ConsoleValueRef&);
SimObject* findObject(SimObjectId); SimObject* findObject(SimObjectId);
SimObject* findObject(const char* name); SimObject* findObject(const char* name);
SimObject* findObject(const char* fileName, S32 declarationLine); SimObject* findObject(const char* fileName, S32 declarationLine);
template<class T> inline bool findObject(ConsoleValueRef &ref,T*&t)
{
t = dynamic_cast<T*>(findObject(ref));
return t != NULL;
}
template<class T> inline bool findObject(SimObjectId iD,T*&t) template<class T> inline bool findObject(SimObjectId iD,T*&t)
{ {
t = dynamic_cast<T*>(findObject(iD)); t = dynamic_cast<T*>(findObject(iD));

View file

@ -34,17 +34,19 @@ SimConsoleEvent::SimConsoleEvent(S32 argc, ConsoleValueRef *argv, bool onObject)
mArgc = argc; mArgc = argc;
mArgv = new ConsoleValueRef[argc]; mArgv = new ConsoleValueRef[argc];
for (int i=0; i<argc; i++) { for (int i=0; i<argc; i++)
mArgv[i].value = new ConsoleValue(); {
mArgv[i].value->type = ConsoleValue::TypeInternalString; mArgv[i].value = new ConsoleValue();
mArgv[i].value->init(); mArgv[i].value->type = ConsoleValue::TypeInternalString;
mArgv[i].value->init();
mArgv[i].value->setStringValue((const char*)argv[i]); mArgv[i].value->setStringValue((const char*)argv[i]);
} }
} }
SimConsoleEvent::~SimConsoleEvent() SimConsoleEvent::~SimConsoleEvent()
{ {
for (int i=0; i<mArgc; i++) { for (int i=0; i<mArgc; i++)
{
delete mArgv[i].value; delete mArgv[i].value;
} }
delete[] mArgv; delete[] mArgv;

View file

@ -328,6 +328,11 @@ SimObject* findObject(const char* fileName, S32 declarationLine)
return gRootGroup->findObjectByLineNumber(fileName, declarationLine, true); return gRootGroup->findObjectByLineNumber(fileName, declarationLine, true);
} }
SimObject* findObject(ConsoleValueRef &ref)
{
return findObject((const char*)ref);
}
SimObject* findObject(const char* name) SimObject* findObject(const char* name)
{ {
PROFILE_SCOPE(SimFindObject); PROFILE_SCOPE(SimFindObject);

View file

@ -54,7 +54,7 @@ bool SimPersistSet::processArguments( S32 argc, ConsoleValueRef *argv )
Torque::UUID uuid; Torque::UUID uuid;
if( !uuid.fromString( argv[ i ] ) ) 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; continue;
} }

View file

@ -909,7 +909,7 @@ ConsoleMethod( SimSet, add, void, 3, 0,
if(obj) if(obj)
object->addObject( obj ); object->addObject( obj );
else 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()) if(obj && object->find(object->begin(),object->end(),obj) != object->end())
object->removeObject(obj); object->removeObject(obj);
else 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(); object->unlock();
} }
} }

View file

@ -34,9 +34,9 @@ void ConsoleValueStack::getArgcArgv(StringTableEntry name, U32 *argc, ConsoleVal
mArgv[0] = name; mArgv[0] = name;
for(U32 i = 0; i < argCount; i++) { for(U32 i = 0; i < argCount; i++) {
ConsoleValueRef *ref = &mArgv[i+1]; ConsoleValueRef *ref = &mArgv[i+1];
ref->value = &mStack[startStack + i]; ref->value = &mStack[startStack + i];
ref->stringStackValue = NULL; ref->stringStackValue = NULL;
} }
argCount++; argCount++;
@ -50,10 +50,10 @@ ConsoleValueStack::ConsoleValueStack() :
mFrame(0), mFrame(0),
mStackPos(0) mStackPos(0)
{ {
for (int i=0; i<ConsoleValueStack::MaxStackDepth; i++) { for (int i=0; i<ConsoleValueStack::MaxStackDepth; i++) {
mStack[i].init(); mStack[i].init();
mStack[i].type = ConsoleValue::TypeInternalString; mStack[i].type = ConsoleValue::TypeInternalString;
} }
} }
ConsoleValueStack::~ConsoleValueStack() ConsoleValueStack::~ConsoleValueStack()
@ -62,138 +62,138 @@ ConsoleValueStack::~ConsoleValueStack()
void ConsoleValueStack::pushVar(ConsoleValue *variable) void ConsoleValueStack::pushVar(ConsoleValue *variable)
{ {
if (mStackPos == ConsoleValueStack::MaxStackDepth) { if (mStackPos == ConsoleValueStack::MaxStackDepth) {
AssertFatal(false, "Console Value Stack is empty"); AssertFatal(false, "Console Value Stack is empty");
return; return;
} }
switch (variable->type) switch (variable->type)
{ {
case ConsoleValue::TypeInternalInt: case ConsoleValue::TypeInternalInt:
mStack[mStackPos++].setIntValue((S32)variable->getIntValue()); mStack[mStackPos++].setIntValue((S32)variable->getIntValue());
case ConsoleValue::TypeInternalFloat: case ConsoleValue::TypeInternalFloat:
mStack[mStackPos++].setFloatValue((F32)variable->getFloatValue()); mStack[mStackPos++].setFloatValue((F32)variable->getFloatValue());
default: default:
mStack[mStackPos++].setStackStringValue(variable->getStringValue()); mStack[mStackPos++].setStackStringValue(variable->getStringValue());
} }
} }
void ConsoleValueStack::pushValue(ConsoleValue &variable) void ConsoleValueStack::pushValue(ConsoleValue &variable)
{ {
if (mStackPos == ConsoleValueStack::MaxStackDepth) { if (mStackPos == ConsoleValueStack::MaxStackDepth) {
AssertFatal(false, "Console Value Stack is empty"); AssertFatal(false, "Console Value Stack is empty");
return; return;
} }
switch (variable.type) switch (variable.type)
{ {
case ConsoleValue::TypeInternalInt: case ConsoleValue::TypeInternalInt:
mStack[mStackPos++].setIntValue((S32)variable.getIntValue()); mStack[mStackPos++].setIntValue((S32)variable.getIntValue());
case ConsoleValue::TypeInternalFloat: case ConsoleValue::TypeInternalFloat:
mStack[mStackPos++].setFloatValue((F32)variable.getFloatValue()); mStack[mStackPos++].setFloatValue((F32)variable.getFloatValue());
default: default:
mStack[mStackPos++].setStringValue(variable.getStringValue()); mStack[mStackPos++].setStringValue(variable.getStringValue());
} }
} }
ConsoleValue *ConsoleValueStack::pushString(const char *value) ConsoleValue *ConsoleValueStack::pushString(const char *value)
{ {
if (mStackPos == ConsoleValueStack::MaxStackDepth) { if (mStackPos == ConsoleValueStack::MaxStackDepth) {
AssertFatal(false, "Console Value Stack is empty"); AssertFatal(false, "Console Value Stack is empty");
return NULL; return NULL;
} }
//Con::printf("[%i]CSTK pushString %s", mStackPos, value); //Con::printf("[%i]CSTK pushString %s", mStackPos, value);
mStack[mStackPos++].setStringValue(value); mStack[mStackPos++].setStringValue(value);
return &mStack[mStackPos-1]; return &mStack[mStackPos-1];
} }
ConsoleValue *ConsoleValueStack::pushStackString(const char *value) ConsoleValue *ConsoleValueStack::pushStackString(const char *value)
{ {
if (mStackPos == ConsoleValueStack::MaxStackDepth) { if (mStackPos == ConsoleValueStack::MaxStackDepth) {
AssertFatal(false, "Console Value Stack is empty"); AssertFatal(false, "Console Value Stack is empty");
return NULL; return NULL;
} }
//Con::printf("[%i]CSTK pushString %s", mStackPos, value); //Con::printf("[%i]CSTK pushString %s", mStackPos, value);
mStack[mStackPos++].setStackStringValue(value); mStack[mStackPos++].setStackStringValue(value);
return &mStack[mStackPos-1]; return &mStack[mStackPos-1];
} }
ConsoleValue *ConsoleValueStack::pushUINT(U32 value) ConsoleValue *ConsoleValueStack::pushUINT(U32 value)
{ {
if (mStackPos == ConsoleValueStack::MaxStackDepth) { if (mStackPos == ConsoleValueStack::MaxStackDepth) {
AssertFatal(false, "Console Value Stack is empty"); AssertFatal(false, "Console Value Stack is empty");
return NULL; return NULL;
} }
//Con::printf("[%i]CSTK pushUINT %i", mStackPos, value); //Con::printf("[%i]CSTK pushUINT %i", mStackPos, value);
mStack[mStackPos++].setIntValue(value); mStack[mStackPos++].setIntValue(value);
return &mStack[mStackPos-1]; return &mStack[mStackPos-1];
} }
ConsoleValue *ConsoleValueStack::pushFLT(float value) ConsoleValue *ConsoleValueStack::pushFLT(float value)
{ {
if (mStackPos == ConsoleValueStack::MaxStackDepth) { if (mStackPos == ConsoleValueStack::MaxStackDepth) {
AssertFatal(false, "Console Value Stack is empty"); AssertFatal(false, "Console Value Stack is empty");
return NULL; return NULL;
} }
//Con::printf("[%i]CSTK pushFLT %f", mStackPos, value); //Con::printf("[%i]CSTK pushFLT %f", mStackPos, value);
mStack[mStackPos++].setFloatValue(value); mStack[mStackPos++].setFloatValue(value);
return &mStack[mStackPos-1]; return &mStack[mStackPos-1];
} }
static ConsoleValue gNothing; static ConsoleValue gNothing;
ConsoleValue* ConsoleValueStack::pop() ConsoleValue* ConsoleValueStack::pop()
{ {
if (mStackPos == 0) { if (mStackPos == 0) {
AssertFatal(false, "Console Value Stack is empty"); AssertFatal(false, "Console Value Stack is empty");
return &gNothing; return &gNothing;
} }
return &mStack[--mStackPos]; return &mStack[--mStackPos];
} }
void ConsoleValueStack::pushFrame() void ConsoleValueStack::pushFrame()
{ {
//Con::printf("CSTK pushFrame"); //Con::printf("CSTK pushFrame");
mStackFrames[mFrame++] = mStackPos; mStackFrames[mFrame++] = mStackPos;
} }
void ConsoleValueStack::resetFrame() void ConsoleValueStack::resetFrame()
{ {
if (mFrame == 0) { if (mFrame == 0) {
mStackPos = 0; mStackPos = 0;
return; return;
} }
U32 start = mStackFrames[mFrame-1]; U32 start = mStackFrames[mFrame-1];
//for (U32 i=start; i<mStackPos; i++) { //for (U32 i=start; i<mStackPos; i++) {
//mStack[i].clear(); //mStack[i].clear();
//} //}
mStackPos = start; mStackPos = start;
//Con::printf("CSTK resetFrame to %i", mStackPos); //Con::printf("CSTK resetFrame to %i", mStackPos);
} }
void ConsoleValueStack::popFrame() void ConsoleValueStack::popFrame()
{ {
//Con::printf("CSTK popFrame"); //Con::printf("CSTK popFrame");
if (mFrame == 0) { if (mFrame == 0) {
// Go back to start // Go back to start
mStackPos = 0; mStackPos = 0;
return; return;
} }
U32 start = mStackFrames[mFrame-1]; U32 start = mStackFrames[mFrame-1];
//for (U32 i=start; i<mStackPos; i++) { //for (U32 i=start; i<mStackPos; i++) {
//mStack[i].clear(); //mStack[i].clear();
//} //}
mStackPos = start; mStackPos = start;
mFrame--; mFrame--;
} }

View file

@ -291,33 +291,34 @@ class ConsoleValueStack
MaxArgs = 20, MaxArgs = 20,
ReturnBufferSpace = 512 ReturnBufferSpace = 512
}; };
public: public:
ConsoleValueStack(); ConsoleValueStack();
~ConsoleValueStack(); ~ConsoleValueStack();
void pushVar(ConsoleValue *variable); void pushVar(ConsoleValue *variable);
void pushValue(ConsoleValue &value); void pushValue(ConsoleValue &value);
ConsoleValue* pop(); ConsoleValue* pop();
ConsoleValue *pushString(const char *value); ConsoleValue *pushString(const char *value);
ConsoleValue *pushStackString(const char *value); ConsoleValue *pushStackString(const char *value);
ConsoleValue *pushUINT(U32 value); ConsoleValue *pushUINT(U32 value);
ConsoleValue *pushFLT(float value); ConsoleValue *pushFLT(float value);
void pushFrame(); void pushFrame();
void popFrame(); void popFrame();
void resetFrame(); void resetFrame();
void getArgcArgv(StringTableEntry name, U32 *argc, ConsoleValueRef **in_argv, bool popStackFrame = false); void getArgcArgv(StringTableEntry name, U32 *argc, ConsoleValueRef **in_argv, bool popStackFrame = false);
ConsoleValue mStack[MaxStackDepth]; ConsoleValue mStack[MaxStackDepth];
U32 mStackFrames[MaxStackDepth]; U32 mStackFrames[MaxStackDepth];
U32 mFrame; U32 mFrame;
U32 mStackPos; U32 mStackPos;
ConsoleValueRef mArgv[MaxArgs]; ConsoleValueRef mArgv[MaxArgs];
}; };
#endif #endif

View file

@ -1040,7 +1040,7 @@ void GuiMeshRoadEditorCtrl::setMode( String mode, bool sourceShortcut = false )
mMode = mode; mMode = mode;
if( sourceShortcut ) if( sourceShortcut )
Con::executef( this, "paletteSync", (const char*)mode ); Con::executef( this, "paletteSync", mode );
} }
void GuiMeshRoadEditorCtrl::setSelectedRoad( MeshRoad *road ) void GuiMeshRoadEditorCtrl::setSelectedRoad( MeshRoad *road )
@ -1240,7 +1240,7 @@ ConsoleMethod( GuiMeshRoadEditorCtrl, setNodePosition, void, 3, 3, "" )
if ( (count != 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; return;
} }
@ -1266,7 +1266,7 @@ ConsoleMethod( GuiMeshRoadEditorCtrl, setNodeNormal, void, 3, 3, "" )
if ( (count != 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; return;
} }
@ -1304,4 +1304,4 @@ ConsoleMethod( GuiMeshRoadEditorCtrl, regenerate, void, 2, 2, "" )
ConsoleMethod( GuiMeshRoadEditorCtrl, matchTerrainToRoad, void, 2, 2, "" ) ConsoleMethod( GuiMeshRoadEditorCtrl, matchTerrainToRoad, void, 2, 2, "" )
{ {
object->matchTerrainToRoad(); object->matchTerrainToRoad();
} }

View file

@ -1181,7 +1181,7 @@ void GuiRiverEditorCtrl::setMode( String mode, bool sourceShortcut = false )
mMode = mode; mMode = mode;
if( sourceShortcut ) if( sourceShortcut )
Con::executef( this, "paletteSync", mode.utf8() ); Con::executef( this, "paletteSync", mode );
} }
void GuiRiverEditorCtrl::setSelectedRiver( River *river ) void GuiRiverEditorCtrl::setSelectedRiver( River *river )
@ -1444,7 +1444,7 @@ ConsoleMethod( GuiRiverEditorCtrl, setNodePosition, void, 3, 3, "" )
if ( (count != 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; return;
} }
@ -1470,7 +1470,7 @@ ConsoleMethod( GuiRiverEditorCtrl, setNodeNormal, void, 3, 3, "" )
if ( (count != 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; return;
} }
@ -1503,4 +1503,4 @@ ConsoleMethod( GuiRiverEditorCtrl, regenerate, void, 2, 2, "" )
River *river = object->getSelectedRiver(); River *river = object->getSelectedRiver();
if ( river ) if ( river )
river->regenerate(); river->regenerate();
} }

View file

@ -945,7 +945,7 @@ void GuiRoadEditorCtrl::setMode( String mode, bool sourceShortcut = false )
mMode = mode; mMode = mode;
if( sourceShortcut ) if( sourceShortcut )
Con::executef( this, "paletteSync", mode.utf8() ); Con::executef( this, "paletteSync", mode );
} }
void GuiRoadEditorCtrl::setSelectedRoad( DecalRoad *road ) void GuiRoadEditorCtrl::setSelectedRoad( DecalRoad *road )
@ -1081,7 +1081,7 @@ ConsoleMethod( GuiRoadEditorCtrl, setNodePosition, void, 3, 3, "" )
if ( (count != 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; return;
} }

View file

@ -356,7 +356,7 @@ void Forest::saveDataFile( const char *path )
ConsoleMethod( Forest, saveDataFile, bool, 2, 3, "saveDataFile( [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; return true;
} }
@ -373,4 +373,4 @@ ConsoleMethod(Forest, regenCells, void, 2, 2, "()")
ConsoleMethod(Forest, clear, void, 2, 2, "()" ) ConsoleMethod(Forest, clear, void, 2, 2, "()" )
{ {
object->clear(); object->clear();
} }

View file

@ -431,7 +431,7 @@ ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, str
// get it? // get it?
if(!classRep) 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; return;
} }
@ -444,7 +444,7 @@ ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, str
// found it? // found it?
if(i == classRep->mFieldList.size()) 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; return;
} }
@ -454,7 +454,7 @@ ConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, 4, 4, "(string class, str
// check the type // check the type
if( !conType->getEnumTable() ) 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; return;
} }

View file

@ -604,7 +604,7 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4,
// get it? // get it?
if(!classRep) 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; return;
} }
@ -617,7 +617,7 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4,
// found it? // found it?
if(i == classRep->mFieldList.size()) 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; return;
} }
@ -627,7 +627,7 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, 4, 4,
// check the type // check the type
if( !conType->getEnumTable() ) 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; return;
} }

View file

@ -4928,7 +4928,7 @@ ConsoleMethod( GuiTreeViewCtrl, setItemTooltip, void, 4, 4, "( int id, string te
return; 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." ) ConsoleMethod( GuiTreeViewCtrl, setItemImages, void, 5, 5, "( int id, int normalImage, int expandedImage ) - Sets the normal and expanded images to show for the given item." )

View file

@ -2007,7 +2007,7 @@ ConsoleMethod( GuiCanvas, pushDialog, void, 3, 5, "(GuiControl ctrl, int layer=0
if (! Sim::findObject(argv[2], gui)) 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; return;
} }
@ -2052,7 +2052,7 @@ ConsoleMethod( GuiCanvas, popDialog, void, 2, 3, "(GuiControl ctrl=NULL)"
{ {
if (!Sim::findObject(argv[2], gui)) 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; return;
} }
} }

View file

@ -2540,7 +2540,7 @@ ConsoleMethod( GuiEditCtrl, setCurrentAddSet, void, 3, 3, "(GuiControl ctrl)")
if (!Sim::findObject(argv[2], addSet)) 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; return;
} }
object->setCurrentAddSet(addSet); object->setCurrentAddSet(addSet);
@ -2700,7 +2700,7 @@ ConsoleMethod( GuiEditCtrl, readGuides, void, 3, 4, "( GuiControl ctrl [, int ax
GuiControl* ctrl; GuiControl* ctrl;
if( !Sim::findObject( argv[ 2 ], 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; return;
} }
@ -2711,7 +2711,7 @@ ConsoleMethod( GuiEditCtrl, readGuides, void, 3, 4, "( GuiControl ctrl [, int ax
S32 axis = dAtoi( argv[ 3 ] ); S32 axis = dAtoi( argv[ 3 ] );
if( axis < 0 || axis > 1 ) 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; return;
} }
@ -2733,7 +2733,7 @@ ConsoleMethod( GuiEditCtrl, writeGuides, void, 3, 4, "( GuiControl ctrl [, int a
GuiControl* ctrl; GuiControl* ctrl;
if( !Sim::findObject( argv[ 2 ], 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; return;
} }
@ -2744,7 +2744,7 @@ ConsoleMethod( GuiEditCtrl, writeGuides, void, 3, 4, "( GuiControl ctrl [, int a
S32 axis = dAtoi( argv[ 3 ] ); S32 axis = dAtoi( argv[ 3 ] );
if( axis < 0 || axis > 1 ) 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; return;
} }

View file

@ -777,7 +777,7 @@ ConsoleMethod( GuiInspector, inspect, void, 3, 3, "Inspect(Object)")
if(!target) if(!target)
{ {
if(dAtoi(argv[2]) > 0) 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(); object->clearInspectObjects();
return; return;
@ -793,7 +793,7 @@ ConsoleMethod( GuiInspector, addInspect, void, 3, 4, "( id object, (bool autoSyn
SimObject* obj; SimObject* obj;
if( !Sim::findObject( argv[ 2 ], 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; return;
} }
@ -810,7 +810,7 @@ ConsoleMethod( GuiInspector, removeInspect, void, 3, 3, "( id object ) - Remove
SimObject* obj; SimObject* obj;
if( !Sim::findObject( argv[ 2 ], 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; return;
} }

View file

@ -571,7 +571,7 @@ void GuiInspectorTypeFileName::updateValue()
ConsoleMethod( GuiInspectorTypeFileName, apply, void, 3,3, "apply(newValue);" ) ConsoleMethod( GuiInspectorTypeFileName, apply, void, 3,3, "apply(newValue);" )
{ {
String path( argv[2] ); String path( (const char*)argv[2] );
if ( path.isNotEmpty() ) if ( path.isNotEmpty() )
path = Platform::makeRelativePathName( path, Platform::getMainDotCsDir() ); path = Platform::makeRelativePathName( path, Platform::getMainDotCsDir() );

View file

@ -63,5 +63,5 @@ void GuiVariableInspector::loadVars( String searchStr )
ConsoleMethod( GuiVariableInspector, loadVars, void, 3, 3, "loadVars( searchString )" ) ConsoleMethod( GuiVariableInspector, loadVars, void, 3, 3, "loadVars( searchString )" )
{ {
object->loadVars( (const char*)argv[2] ); object->loadVars( argv[2] );
} }

View file

@ -175,7 +175,7 @@ ConsoleStaticMethod( EditorIconRegistry, add, void, 3, 4, "( String className, S
if ( argc > 3 ) if ( argc > 3 )
overwrite = dAtob( argv[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] )" 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 ) if ( argc > 2 )
overwrite = dAtob( argv[2] ); overwrite = dAtob( argv[2] );
gEditorIcons.loadFromPath( (const char*)argv[1], overwrite ); gEditorIcons.loadFromPath( argv[1], overwrite );
} }
ConsoleStaticMethod( EditorIconRegistry, clear, void, 1, 1, "" ConsoleStaticMethod( EditorIconRegistry, clear, void, 1, 1, ""
@ -212,7 +212,7 @@ ConsoleStaticMethod( EditorIconRegistry, findIconBySimObject, const char*, 2, 2,
SimObject *obj = NULL; SimObject *obj = NULL;
if ( !Sim::findObject( argv[1], obj ) ) 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; return NULL;
} }

View file

@ -782,7 +782,7 @@ void GuiDecalEditorCtrl::setMode( String mode, bool sourceShortcut = false )
mMode = mode; mMode = mode;
if( sourceShortcut ) if( sourceShortcut )
Con::executef( this, "paletteSync", (const char*)mMode ); Con::executef( this, "paletteSync", mMode );
} }
ConsoleMethod( GuiDecalEditorCtrl, deleteSelectedDecal, void, 2, 2, "deleteSelectedDecal()" ) 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 )" ) ConsoleMethod( GuiDecalEditorCtrl, deleteDecalDatablock, void, 3, 3, "deleteSelectedDecalDatablock( String datablock )" )
{ {
String lookupName( argv[2] ); String lookupName( (const char*)argv[2] );
if( lookupName == String::EmptyString ) if( lookupName == String::EmptyString )
return; return;
@ -801,7 +801,7 @@ ConsoleMethod( GuiDecalEditorCtrl, deleteDecalDatablock, void, 3, 3, "deleteSele
ConsoleMethod( GuiDecalEditorCtrl, setMode, void, 3, 3, "setMode( String mode )()" ) ConsoleMethod( GuiDecalEditorCtrl, setMode, void, 3, 3, "setMode( String mode )()" )
{ {
String newMode = ( argv[2] ); String newMode = ( (const char*)argv[2] );
object->setMode( newMode ); object->setMode( newMode );
} }
@ -868,7 +868,7 @@ ConsoleMethod( GuiDecalEditorCtrl, editDecalDetails, void, 4, 4, "editDecalDetai
if ( (count != 7) ) 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; return;
} }
@ -894,7 +894,7 @@ ConsoleMethod( GuiDecalEditorCtrl, getSelectionCount, S32, 2, 2, "" )
ConsoleMethod( GuiDecalEditorCtrl, retargetDecalDatablock, void, 4, 4, "" ) ConsoleMethod( GuiDecalEditorCtrl, retargetDecalDatablock, void, 4, 4, "" )
{ {
if( dStrcmp( argv[2], "" ) != 0 && dStrcmp( argv[3], "" ) != 0 ) 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 ) void GuiDecalEditorCtrl::setGizmoFocus( DecalInstance * decalInstance )
@ -1253,4 +1253,4 @@ void DBRetargetUndoAction::redo()
if ( mEditor->isMethod( "rebuildInstanceTree" ) ) if ( mEditor->isMethod( "rebuildInstanceTree" ) )
Con::executef( mEditor, "rebuildInstanceTree" ); Con::executef( mEditor, "rebuildInstanceTree" );
} }
#endif #endif

View file

@ -2500,7 +2500,7 @@ ConsoleMethod( TerrainEditor, attachTerrain, void, 2, 3, "(TerrainBlock terrain)
terrains.push_back(terrBlock); terrains.push_back(terrBlock);
if(terrains.size() == 0) 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) if (terrains.size() > 0)
@ -2714,7 +2714,7 @@ ConsoleMethod(TerrainEditor, updateMaterial, bool, 4, 4,
if ( index >= terr->getMaterialCount() ) if ( index >= terr->getMaterialCount() )
return false; return false;
terr->updateMaterial( index, (const char*)argv[3] ); terr->updateMaterial( index, argv[3] );
object->setDirty(); object->setDirty();
@ -2729,7 +2729,7 @@ ConsoleMethod(TerrainEditor, addMaterial, S32, 3, 3,
if ( !terr ) if ( !terr )
return false; return false;
terr->addMaterial( (const char*)argv[2] ); terr->addMaterial( argv[2] );
object->setDirty(); object->setDirty();

View file

@ -3204,7 +3204,7 @@ ConsoleMethod( WorldEditor, setActiveSelection, void, 3, 3, "( id set ) - Set th
WorldEditorSelection* selection; WorldEditorSelection* selection;
if( !Sim::findObject( argv[ 2 ], 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; return;
} }
@ -3330,14 +3330,14 @@ ConsoleMethod( WorldEditor, alignByBounds, void, 3, 3, "(int boundsAxis)"
"Align all selected objects against the given bounds axis.") "Align all selected objects against the given bounds axis.")
{ {
if(!object->alignByBounds(dAtoi(argv[2]))) 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)" ConsoleMethod( WorldEditor, alignByAxis, void, 3, 3, "(int axis)"
"Align all selected objects along the given axis.") "Align all selected objects along the given axis.")
{ {
if(!object->alignByAxis(dAtoi(argv[2]))) 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, "") ConsoleMethod( WorldEditor, resetSelectedRotation, void, 2, 2, "")

View file

@ -682,7 +682,7 @@ ConsoleMethod( WorldEditorSelection, union, void, 3, 3, "( SimSet set ) - Add al
SimSet* selection; SimSet* selection;
if( !Sim::findObject( argv[ 2 ], 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; return;
} }
@ -698,7 +698,7 @@ ConsoleMethod( WorldEditorSelection, subtract, void, 3, 3, "( SimSet ) - Remove
SimSet* selection; SimSet* selection;
if( !Sim::findObject( argv[ 2 ], 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; return;
} }

View file

@ -78,7 +78,7 @@ ConsoleFunction(setCoreLangTable, void, 2, 2, "(string LangTable)"
if(Sim::findObject(argv[1], lt)) if(Sim::findObject(argv[1], lt))
gCoreLangTable = lt; gCoreLangTable = lt;
else else
Con::errorf("setCoreLangTable - Unable to find LanTable '%s'", argv[1]); Con::errorf("setCoreLangTable - Unable to find LanTable '%s'", (const char*)argv[1]);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -465,7 +465,7 @@ ConsoleFunction( addMaterialMapping, void, 3, 3, "(string texName, string matNam
"block or interior surface using the associated texture.\n\n" "block or interior surface using the associated texture.\n\n"
"@ingroup Materials") "@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" 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" "@param texName Name of the texture\n\n"
"@ingroup Materials") "@ingroup Materials")
{ {
return MATMGR->getMapEntry((const char*)argv[1]).c_str(); return MATMGR->getMapEntry(argv[1]).c_str();
} }
ConsoleFunction( dumpMaterialInstances, void, 1, 1, ConsoleFunction( dumpMaterialInstances, void, 1, 1,
@ -487,5 +487,5 @@ ConsoleFunction( dumpMaterialInstances, void, 1, 1,
ConsoleFunction( getMapEntry, const char *, 2, 2, ConsoleFunction( getMapEntry, const char *, 2, 2,
"@hide") "@hide")
{ {
return MATMGR->getMapEntry( String(argv[1]) ); return MATMGR->getMapEntry( argv[1] );
} }

View file

@ -884,7 +884,7 @@ bool Platform::fileTimeToString(FileTime * time, char * string, U32 strLen) { re
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if defined(TORQUE_DEBUG) #if defined(TORQUE_DEBUG)
ConsoleFunction(testHasSubdir,void,2,2,"tests platform::hasSubDirectory") { 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"); Platform::addExcludedDirectory(".svn");
if(Platform::hasSubDirectory(argv[1])) if(Platform::hasSubDirectory(argv[1]))
Con::printf(" has subdir"); Con::printf(" has subdir");
@ -901,7 +901,7 @@ ConsoleFunction(testDumpDirectories,void,4,4,"testDumpDirectories('path', int de
Platform::dumpDirectories(argv[1], paths, depth, noBasePath); 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<StringTableEntry>::iterator itr = paths.begin(); itr != paths.end(); itr++) { for(Vector<StringTableEntry>::iterator itr = paths.begin(); itr != paths.end(); itr++) {
Con::printf(*itr); Con::printf(*itr);

View file

@ -509,7 +509,7 @@ void Input::log( const char* format, ... )
ConsoleFunction( inputLog, void, 2, 2, "inputLog( string )" ) ConsoleFunction( inputLog, void, 2, 2, "inputLog( string )" )
{ {
argc; argc;
Input::log( "%s\n", argv[1] ); Input::log( "%s\n", (const char*)argv[1] );
} }
#endif // LOG_INPUT #endif // LOG_INPUT

View file

@ -335,7 +335,7 @@ void Input::log( const char* format, ... )
ConsoleFunction( inputLog, void, 2, 2, "inputLog( string )" ) ConsoleFunction( inputLog, void, 2, 2, "inputLog( string )" )
{ {
argc; argc;
Input::log( "%s\n", argv[1] ); Input::log( "%s\n", (const char*)argv[1] );
} }
#endif // LOG_INPUT #endif // LOG_INPUT

View file

@ -70,7 +70,7 @@ ConsoleFunction( MathInit, void, 1, 10, "(detect|C|FPU|MMX|3DNOW|SSE|...)")
properties |= CPU_PROP_SSE; properties |= CPU_PROP_SSE;
continue; 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); Math::init(properties);
} }

View file

@ -400,7 +400,7 @@ ConsoleStaticMethod( PfxVis, open, void, 2, 3, "( PostEffect, [bool clear = fals
PostEffect *pfx; PostEffect *pfx;
if ( !Sim::findObject( argv[1], 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; return;
} }
@ -450,9 +450,9 @@ ConsoleStaticMethod( PfxVis, onWindowClosed, void, 2, 2, "( GuiWindowCtrl )"
GuiWindowCtrl *ctrl; GuiWindowCtrl *ctrl;
if ( !Sim::findObject( argv[1], 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; return;
} }
PFXVIS->onWindowClosed( ctrl ); PFXVIS->onWindowClosed( ctrl );
} }

View file

@ -1454,7 +1454,7 @@ ConsoleFunction( sfxCreateSource, S32, 2, 6,
description = dynamic_cast< SFXDescription* >( Sim::findObject( argv[1] ) ); description = dynamic_cast< SFXDescription* >( Sim::findObject( argv[1] ) );
if ( !description ) 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; return 0;
} }
} }
@ -1560,7 +1560,7 @@ ConsoleFunction( sfxPlay, S32, 2, 5, "( SFXSource source | ( SFXTrack track [, f
SFXTrack* track = dynamic_cast<SFXTrack*>( Sim::findObject( argv[1] ) ); SFXTrack* track = dynamic_cast<SFXTrack*>( Sim::findObject( argv[1] ) );
if ( !track ) 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; return 0;
} }
@ -1663,7 +1663,7 @@ ConsoleFunction( sfxPlayOnce, S32, 2, 6,
description = dynamic_cast< SFXDescription* >( Sim::findObject( argv[1] ) ); description = dynamic_cast< SFXDescription* >( Sim::findObject( argv[1] ) );
if( !description ) 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; return 0;
} }
} }

View file

@ -1795,16 +1795,15 @@ static ConsoleDocFragment _ActionMapbindObj2(
ConsoleMethod( ActionMap, bindObj, bool, 6, 11, "(device, action, [modifier spec, mod...], command, object)" ConsoleMethod( ActionMap, bindObj, bool, 6, 11, "(device, action, [modifier spec, mod...], command, object)"
"@hide") "@hide")
{ {
SimObject* simObject = Sim::findObject(argv[argc - 1]); SimObject* simObject = Sim::findObject(argv[argc - 1]);
if ( simObject == NULL ) if ( simObject == NULL )
{ {
Con::warnf("ActionMap::bindObj() - Cannot bind, specified object was not found!"); Con::warnf("ActionMap::bindObj() - Cannot bind, specified object was not found!");
return false; return false;
} }
StringStackWrapper args(argc - 3, argv + 2); StringStackWrapper args(argc - 3, argv + 2);
return object->processBind( args.count(), args, simObject );
return object->processBind( args.count(), args, simObject );
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View file

@ -434,7 +434,7 @@ NetConnection::NetConnection()
// Disable starting a new journal recording or playback from here on // Disable starting a new journal recording or playback from here on
Journal::Disable(); Journal::Disable();
// jamesu - netAddress is not set // Ensure NetAddress is cleared
dMemset(&mNetAddress, '\0', sizeof(NetAddress)); dMemset(&mNetAddress, '\0', sizeof(NetAddress));
} }

View file

@ -141,7 +141,7 @@ ConsoleMethod( TerrainBlock, exportHeightMap, bool, 3, 4, "(string filename, [st
UTF8 fileName[1024]; UTF8 fileName[1024];
String format = "png"; String format = "png";
if( argc > 3 ) if( argc > 3 )
format = (String)argv[ 3 ]; format = (const char*)argv[ 3 ];
Con::expandScriptFilename( fileName, sizeof( fileName ), argv[2] ); Con::expandScriptFilename( fileName, sizeof( fileName ), argv[2] );
@ -153,7 +153,7 @@ ConsoleMethod( TerrainBlock, exportLayerMaps, bool, 3, 4, "(string filePrefix, [
UTF8 filePrefix[1024]; UTF8 filePrefix[1024];
String format = "png"; String format = "png";
if( argc > 3 ) if( argc > 3 )
format = (String)argv[3]; format = (const char*)argv[3];
Con::expandScriptFilename( filePrefix, sizeof( filePrefix ), argv[2] ); Con::expandScriptFilename( filePrefix, sizeof( filePrefix ), argv[2] );

View file

@ -139,7 +139,7 @@ ConsoleFunction( enumColladaForImport, bool, 3, 3,
GuiTreeViewCtrl* tree; GuiTreeViewCtrl* tree;
if (!Sim::findObject(argv[2], 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; return false;
} }

View file

@ -172,7 +172,7 @@ ConsoleFunction( loadColladaLights, bool, 2, 4,
if (!Sim::findObject(argv[2], group)) { if (!Sim::findObject(argv[2], group)) {
// Create the group if it could not be found // Create the group if it could not be found
group = new SimGroup; group = new SimGroup;
if (group->registerObject(argv[2])) { if (group->registerObject((const char*)argv[2])) {
if (missionGroup) if (missionGroup)
missionGroup->addObject(group); missionGroup->addObject(group);
} }

View file

@ -471,7 +471,7 @@ ConsoleMethod( EventManager, subscribe, bool, 4, 5, "( SimObject listener, Strin
return false; 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" ConsoleMethod( EventManager, remove, void, 4, 4, "( SimObject listener, String event )\n\n"

View file

@ -566,7 +566,7 @@ ConsoleMethod( UndoManager, pushCompound, const char*, 2, 3, "( string name=\"\"
{ {
String name; String name;
if( argc > 2 ) if( argc > 2 )
name = (String)argv[ 2 ]; name = (const char*)argv[ 2 ];
CompoundUndoAction* action = object->pushCompound( name ); CompoundUndoAction* action = object->pushCompound( name );
if( !action ) if( !action )
@ -584,7 +584,7 @@ ConsoleMethod( UndoManager, popCompound, void, 2, 3, "( bool discard=false ) - P
{ {
if( !object->getCompoundStackDepth() ) 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; return;
} }