Skip to content

Commit c56fcd8

Browse files
authored
Merge pull request #1679 from Azaezel/alpha41/contextCrashes
context safties
2 parents 41aa23f + 80f6257 commit c56fcd8

8 files changed

Lines changed: 22 additions & 19 deletions

File tree

Engine/source/T3D/SubScene.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ bool SubScene::evaluateCondition()
229229
if (objectName != NULL)
230230
objectName = getIdString();
231231

232-
StringTableEntry groupName = getGroup()->getName();
232+
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
233233
if (groupName != NULL)
234234
groupName = getGroup()->getIdString();
235235

236236
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
237-
Con::evaluate(command.c_str(), false, context);
237+
Con::evaluate(command.c_str(), false, context.c_str());
238238
return Con::getBoolVariable(resVar.c_str());
239239
}
240240
return true;

Engine/source/T3D/missionMarker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,12 @@ bool SpawnSphere::testCondition()
372372
if (objectName != NULL)
373373
objectName = getIdString();
374374

375-
StringTableEntry groupName = getGroup()->getName();
375+
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
376376
if (groupName != NULL)
377377
groupName = getGroup()->getIdString();
378378

379379
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
380-
Con::evaluate(command.c_str(), false, context);
380+
Con::evaluate(command.c_str(), false, context.c_str());
381381
if (Con::getBoolVariable(resVar.c_str()) == 1)
382382
{
383383
return true;

Engine/source/T3D/trigger.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,12 +711,12 @@ bool Trigger::testCondition()
711711
if (objectName != NULL)
712712
objectName = getIdString();
713713

714-
StringTableEntry groupName = getGroup()->getName();
714+
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
715715
if (groupName != NULL)
716716
groupName = getGroup()->getIdString();
717717

718718
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
719-
Con::evaluate(command.c_str(), false, context);
719+
Con::evaluate(command.c_str(), false, context.c_str());
720720
if (Con::getBoolVariable(resVar.c_str()) == 1)
721721
{
722722
return true;
@@ -817,7 +817,7 @@ void Trigger::processTick(const Move* move)
817817
if (objectName != NULL)
818818
objectName = getIdString();
819819

820-
StringTableEntry groupName = getGroup()->getName();
820+
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
821821
if (groupName != NULL)
822822
groupName = getGroup()->getIdString();
823823

Engine/source/console/torquescript/codeBlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ Con::EvalResult CodeBlock::compileExec(StringTableEntry fileName, const char *in
611611
Script::gStatementList = NULL;
612612

613613
// we are an eval compile if we don't have a file name associated (no exec)
614-
gIsEvalCompile = fileName == NULL;
614+
gIsEvalCompile = fileName == NULL || setFrame == 0;
615615
gFuncVars = gIsEvalCompile ? &gEvalFuncVars : &gGlobalScopeFuncVars;
616616

617617
// Set up the parser.

Engine/source/console/torquescript/runtime.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ namespace TorqueScript
3838
if (fileName)
3939
fileName = StringTable->insert(fileName);
4040

41+
bool fileExec = Torque::FS::IsFile(fileName);
42+
4143
CodeBlock* newCodeBlock = new CodeBlock();
42-
return (newCodeBlock->compileExec(fileName, string, false, fileName ? -1 : 0));
44+
return (newCodeBlock->compileExec(fileName, string, false, fileExec ? -1 : 0));
4345
}
4446

4547
Con::EvalResult TorqueScriptRuntime::evaluate(const char* script, S32 frame, bool echo, const char* fileName)

Engine/source/gui/controls/guiGameListMenuCtrl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ void GuiGameListMenuCtrl::doScriptCommand(StringTableEntry command)
976976
setThisControl();
977977
StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
978978
String context = String::ToString("%s\nObject: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
979-
Con::evaluate(command, false, context);
979+
Con::evaluate(command, false, context.c_str());
980980
}
981981
}
982982

Engine/source/gui/controls/guiListBoxCtrl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ StringTableEntry GuiListBoxCtrl::_makeMirrorItemName( SimObject *inObj )
15411541

15421542
StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
15431543
String context = String::ToString("%s, Object: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
1544-
outName = StringTable->insert( Con::evaluate( mMakeNameCallback, false, context).value, true );
1544+
outName = StringTable->insert( Con::evaluate( mMakeNameCallback, false, context.c_str()).value, true );
15451545
}
15461546
else if ( inObj->getName() )
15471547
outName = StringTable->insert( inObj->getName() );

Engine/source/gui/core/guiControl.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,14 +2496,15 @@ const char* GuiControl::evaluate( const char* str )
24962496
{
24972497
smThisControl = this;
24982498
StringTableEntry objectName = getName();
2499-
if (getName() == NULL)
2500-
objectName = getInternalName();
2501-
StringTableEntry fileName = getFilename();
2502-
if (fileName != NULL)
2503-
fileName = Platform::makeRelativePathName(fileName, NULL);
2504-
2505-
String context = String::ToString("%s\nObject: %s", fileName, objectName);
2506-
const char* result = Con::evaluate(str, false, context).value;
2499+
if (objectName != NULL)
2500+
objectName = getIdString();
2501+
2502+
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
2503+
if (groupName != NULL)
2504+
groupName = getGroup()->getIdString();
2505+
2506+
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
2507+
const char* result = Con::evaluate(str, false, context.c_str()).value;
25072508
smThisControl = NULL;
25082509

25092510
return result;

0 commit comments

Comments
 (0)