Fix specific usage of Con::executef where it was not being assigned to a ConsoleValue before getting it's data out of it.

This commit is contained in:
Jeff Hutchinson 2021-09-24 19:32:57 -04:00
parent 0f89373782
commit 755bbacaa0
13 changed files with 35 additions and 21 deletions

View file

@ -250,8 +250,9 @@ namespace VPersistence
if ( object->isMethod( "onAdd" ) )
{
// Callback.
const char *retValue = Con::executef( object, "onAdd" );
if ( !dAtob( retValue ) )
ConsoleValue cValue = Con::executef( object, "onAdd" );
if ( !cValue.getBool() )
{
// Delete.
object->deleteObject();

View file

@ -989,9 +989,10 @@ afxEffectron::start_effect(afxEffectronData* datablock, SimObject* extra)
}
// CALL SCRIPT afxEffectronData::onPreactivate(%params, %extra)
const char* result = Con::executef(datablock, "onPreactivate",
ConsoleValue cValue = Con::executef(datablock, "onPreactivate",
Con::getIntArg(param_holder->getId()),
(extra) ? Con::getIntArg(extra->getId()) : "");
const char* result = cValue.getString();
if (result && result[0] != '\0' && !dAtob(result))
{
#if defined(TORQUE_DEBUG)

View file

@ -1068,9 +1068,11 @@ afxSelectron::start_selectron(SceneObject* picked, U8 subcode, SimObject* extra)
}
// CALL SCRIPT afxSelectronData::onPreactivate(%params, %extra)
const char* result = Con::executef(datablock, "onPreactivate",
ConsoleValue cValue = Con::executef(datablock, "onPreactivate",
Con::getIntArg(param_holder->getId()),
(extra) ? Con::getIntArg(extra->getId()) : "").getString();
(extra) ? Con::getIntArg(extra->getId()) : "");
const char* result = cValue.getString();
if (result && result[0] != '\0' && !dAtob(result))
{
#if defined(TORQUE_DEBUG)

View file

@ -103,7 +103,8 @@ S32 QSORT_CALLBACK ArrayObject::_keyFunctionCompare( const void* a, const void*
ArrayObject::Element* ea = ( ArrayObject::Element* )( a );
ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
S32 result = dAtoi(Con::executef((const char*)smCompareFunction, ea->key, eb->key));
ConsoleValue cValue = Con::executef((const char*)smCompareFunction, ea->key, eb->key);
S32 result = cValue.getInt();
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 );
return ( smDecreasing ? -res : res );
}
@ -113,7 +114,8 @@ S32 QSORT_CALLBACK ArrayObject::_valueFunctionCompare( const void* a, const void
ArrayObject::Element* ea = ( ArrayObject::Element* )( a );
ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
S32 result = dAtoi( Con::executef( (const char*)smCompareFunction, ea->value, eb->value ) );
ConsoleValue cValue = Con::executef( (const char*)smCompareFunction, ea->value, eb->value );
S32 result = cValue.getInt();
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 );
return ( smDecreasing ? -res : res );
}

View file

@ -118,7 +118,8 @@ S32 QSORT_CALLBACK SimObjectList::_callbackSort( const void *a, const void *b )
static char idB[64];
dSprintf( idB, sizeof( idB ), "%d", objB->getId() );
return dAtoi( Con::executef( (const char*)smSortScriptCallbackFn, idA, idB ) );
ConsoleValue cValue = Con::executef( (const char*)smSortScriptCallbackFn, idA, idB );
return cValue.getInt();
}
void SimObjectList::scriptSort( const String &scriptCallback )

View file

@ -438,7 +438,8 @@ void GuiRiverEditorCtrl::_process3DMouseDown( const Gui3DMouseEvent& event )
return;
}
const char *res = Con::executef( this, "createRiver" );
ConsoleValue cValue = Con::executef( this, "createRiver" );
const char* res = cValue.getString();
River *newRiver;
if ( !Sim::findObject( res, newRiver ) )

View file

@ -588,7 +588,8 @@ void ForestBrushTool::_collectElements()
if ( !Sim::findObject( "ForestEditBrushTree", brushTree ) )
return;
const char* objectIdList = Con::executef( brushTree, "getSelectedObjectList" );
ConsoleValue cValue = Con::executef( brushTree, "getSelectedObjectList" );
const char* objectIdList = cValue.getString();
// Collect those objects in a vector and mark them as selected.
@ -685,4 +686,4 @@ bool ForestBrushTool::getGroundAt( const Point3F &worldPt, F32 *zValueOut, Vecto
DefineEngineMethod( ForestBrushTool, collectElements, void, (), , "" )
{
object->collectElements();
}
}

View file

@ -637,7 +637,9 @@ void GuiTreeViewCtrl::Item::getTooltipText(U32 bufLen, char *buf)
method += pClassName;
if(mParentControl->isMethod(method.c_str()))
{
const char* tooltip = Con::executef( mParentControl, method.c_str(), pObject->getIdString() );
ConsoleValue cValue = Con::executef( mParentControl, method.c_str(), pObject->getIdString() );
const char* tooltip = cValue.getString();
dsize_t len = dStrlen(buf);
S32 newBufLen = bufLen-len;
if(dStrlen(tooltip) > 0 && newBufLen > 0)

View file

@ -226,7 +226,9 @@ void GuiPopupMenuTextListCtrl::onMouseUp(const GuiEvent &event)
if (item)
{
if (item->mEnabled)
dAtob(Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), item->mText.isNotEmpty() ? item->mText : ""));
{
Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), item->mText.isNotEmpty() ? item->mText : "");
}
}
}

View file

@ -288,7 +288,8 @@ bool PopupMenu::canHandleID(U32 id)
bool PopupMenu::handleSelect(U32 command, const char *text /* = NULL */)
{
return dAtob(Con::executef(this, "onSelectItem", Con::getIntArg(command), text ? text : ""));
ConsoleValue cValue = Con::executef(this, "onSelectItem", Con::getIntArg(command), text ? text : "");
return cValue.getBool();
}
//////////////////////////////////////////////////////////////////////////

View file

@ -461,7 +461,9 @@ bool WorldEditor::pasteSelection( bool dropSel )
SimGroup *targetGroup = NULL;
if( isMethod( "getNewObjectGroup" ) )
{
const char* targetGroupName = Con::executef( this, "getNewObjectGroup" );
ConsoleValue cValue = Con::executef( this, "getNewObjectGroup" );
const char* targetGroupName = cValue.getString();
if( targetGroupName && targetGroupName[ 0 ] && !Sim::findObject( targetGroupName, targetGroup) )
Con::errorf( "WorldEditor::pasteSelection() - no SimGroup called '%s'", targetGroupName );
}

View file

@ -397,7 +397,8 @@ bool ModuleManager::loadModuleGroup( const char* pModuleGroup )
if ( pLoadReadyModuleDefinition->getModuleScriptFilePath() != StringTable->EmptyString() )
{
// Yes, so execute the script file.
const bool scriptFileExecuted = dAtob( Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath() ) );
ConsoleValue cValue = Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath());
const bool scriptFileExecuted = cValue.getBool();
// Did we execute the script file?
if ( scriptFileExecuted )
@ -784,7 +785,8 @@ bool ModuleManager::loadModuleExplicit( const char* pModuleId, const U32 version
if ( pLoadReadyModuleDefinition->getModuleScriptFilePath() != StringTable->EmptyString() )
{
// Yes, so execute the script file.
const bool scriptFileExecuted = dAtob( Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath() ) );
ConsoleValue cValue = Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath());
const bool scriptFileExecuted = cValue.getBool();
// Did we execute the script file?
if ( !scriptFileExecuted )

View file

@ -121,7 +121,6 @@ IMPLEMENT_CALLBACK( ScriptMsgListener, onMessageReceived, bool, ( const char* qu
bool ScriptMsgListener::onMessageReceived(StringTableEntry queue, const char* event, const char* data)
{
return onMessageReceived_callback(queue, event, data);
//return dAtob(Con::executef(this, "onMessageReceived", queue, event, data));
}
IMPLEMENT_CALLBACK( ScriptMsgListener, onMessageObjectReceived, bool, ( const char* queue, Message *msg ), ( queue, msg ),
@ -135,7 +134,6 @@ IMPLEMENT_CALLBACK( ScriptMsgListener, onMessageObjectReceived, bool, ( const ch
bool ScriptMsgListener::onMessageObjectReceived(StringTableEntry queue, Message *msg)
{
return onMessageObjectReceived_callback(queue, msg);
//return dAtob(Con::executef(this, "onMessageObjectReceived", queue, Con::getIntArg(msg->getId())));
}
//-----------------------------------------------------------------------------
@ -150,7 +148,6 @@ IMPLEMENT_CALLBACK( ScriptMsgListener, onAddToQueue, void, ( const char* queue),
void ScriptMsgListener::onAddToQueue(StringTableEntry queue)
{
//Con::executef(this, "onAddToQueue", queue);
onAddToQueue_callback(queue);
IMLParent::onAddToQueue(queue);
}
@ -176,7 +173,6 @@ IMPLEMENT_CALLBACK( ScriptMsgListener, onRemoveFromQueue, void, ( const char* qu
void ScriptMsgListener::onRemoveFromQueue(StringTableEntry queue)
{
//Con::executef(this, "onRemoveFromQueue", queue);
onRemoveFromQueue_callback(queue);
IMLParent::onRemoveFromQueue(queue);
}