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