Merge branch 'development' of https://github.com/marauder2k9-torque/Torque3D into development

This commit is contained in:
marauder2k7 2026-03-01 13:13:22 +00:00
commit 43535cd846
23 changed files with 244 additions and 60 deletions

View file

@ -194,7 +194,9 @@ DefineEngineMethod(AIController, getAimObject, S32, (), ,
"@see setAimObject()\n") "@see setAimObject()\n")
{ {
SceneObject* obj = dynamic_cast<GameBase*>(object->getAim()->mObj.getPointer()); SceneObject* obj = NULL;
if (object->getAim())
obj = dynamic_cast<GameBase*>(object->getAim()->mObj.getPointer());
return obj ? obj->getId() : -1; return obj ? obj->getId() : -1;
} }

View file

@ -70,7 +70,12 @@ bool AIController::setControllerDataProperty(void* obj, const char* index, const
void AIController::setGoal(AIInfo* targ) void AIController::setGoal(AIInfo* targ)
{ {
if (mGoal) { delete(mGoal); mGoal = NULL; } if (mGoal)
{
if (mGoal->mObj.isValid() && targ->mObj.isValid() && mGoal->mObj == targ->mObj)
return;
delete(mGoal); mGoal = NULL;
}
if (targ->mObj.isValid()) if (targ->mObj.isValid())
{ {
@ -86,26 +91,58 @@ void AIController::setGoal(AIInfo* targ)
void AIController::setGoal(Point3F loc, F32 rad) void AIController::setGoal(Point3F loc, F32 rad)
{ {
if (mGoal) delete(mGoal); if (mGoal)
{
if (mGoal->mPosSet && mGoal->getPosition() == loc)
{
mGoal->mRadius = rad;
return;
}
delete(mGoal);
}
mGoal = new AIGoal(this, loc, rad); mGoal = new AIGoal(this, loc, rad);
} }
void AIController::setGoal(SimObjectPtr<SceneObject> objIn, F32 rad) void AIController::setGoal(SimObjectPtr<SceneObject> objIn, F32 rad)
{ {
if (mGoal) delete(mGoal); if (mGoal)
{
if (mGoal->mObj.isValid() && objIn.isValid() && mGoal->mObj == objIn)
{
mGoal->mRadius = rad;
return;
}
delete(mGoal);
}
mGoal = new AIGoal(this, objIn, rad); mGoal = new AIGoal(this, objIn, rad);
} }
void AIController::setAim(Point3F loc, F32 rad, Point3F offset) void AIController::setAim(Point3F loc, F32 rad, Point3F offset)
{ {
if (mAimTarget) delete(mAimTarget); if (mAimTarget)
{
if (mAimTarget->mPosSet && mAimTarget->getPosition() == loc)
{
mAimTarget->mAimOffset = offset;
return;
}
delete(mAimTarget);
}
mAimTarget = new AIAimTarget(this, loc, rad); mAimTarget = new AIAimTarget(this, loc, rad);
mAimTarget->mAimOffset = offset; mAimTarget->mAimOffset = offset;
} }
void AIController::setAim(SimObjectPtr<SceneObject> objIn, F32 rad, Point3F offset) void AIController::setAim(SimObjectPtr<SceneObject> objIn, F32 rad, Point3F offset)
{ {
if (mAimTarget) delete(mAimTarget); if (mAimTarget)
{
if (mAimTarget->mObj.isValid() && objIn.isValid() && mAimTarget->mObj == objIn)
{
mAimTarget->mAimOffset = offset;
return;
}
delete(mAimTarget);
}
mAimTarget = new AIAimTarget(this, objIn, rad); mAimTarget = new AIAimTarget(this, objIn, rad);
mAimTarget->mAimOffset = offset; mAimTarget->mAimOffset = offset;
} }

View file

@ -70,8 +70,24 @@ public:
private: private:
AICover* mCover; AICover* mCover;
public: public:
void setCover(Point3F loc, F32 rad = 0.0f) { delete(mCover); mCover = new AICover(this, loc, rad); } void setCover(Point3F loc, F32 rad = 0.0f)
void setCover(SimObjectPtr<SceneObject> objIn, F32 rad = 0.0f) { delete(mCover); mCover = new AICover(this, objIn, rad); } {
if (mCover && mCover->mPosSet && mCover->getPosition() == loc)
{
mCover->mRadius == rad;
return;
}
delete(mCover); mCover = new AICover(this, loc, rad);
}
void setCover(SimObjectPtr<SceneObject> objIn, F32 rad = 0.0f)
{
if (mCover && mCover->mObj == objIn)
{
mCover->mRadius == rad;
return;
}
delete(mCover); mCover = new AICover(this, objIn, rad);
}
AICover* getCover() { return mCover; } AICover* getCover() { return mCover; }
bool findCover(const Point3F& from, F32 radius); bool findCover(const Point3F& from, F32 radius);
void clearCover(); void clearCover();

View file

@ -225,7 +225,16 @@ bool SubScene::evaluateCondition()
Con::setBoolVariable(resVar.c_str(), false); Con::setBoolVariable(resVar.c_str(), false);
String command = resVar + "=" + mLoadIf + ";"; String command = resVar + "=" + mLoadIf + ";";
Con::evaluatef(command.c_str()); StringTableEntry objectName = getName();
if (objectName != NULL)
objectName = getIdString();
StringTableEntry groupName = getGroup()->getName();
if (groupName != NULL)
groupName = getGroup()->getIdString();
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
Con::evaluate(command.c_str(), false, context);
return Con::getBoolVariable(resVar.c_str()); return Con::getBoolVariable(resVar.c_str());
} }
return true; return true;

View file

@ -3003,7 +3003,7 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem)
if (hasRoughness) if (hasRoughness)
{ {
newMat->mInvertRoughness[0] = true; newMat->mInvertRoughness[0] = false;
} }
newAsset->addObject(newMat); newAsset->addObject(newMat);

View file

@ -367,7 +367,17 @@ bool SpawnSphere::testCondition()
String resVar = getIdString() + String(".result"); String resVar = getIdString() + String(".result");
Con::setBoolVariable(resVar.c_str(), false); Con::setBoolVariable(resVar.c_str(), false);
String command = resVar + "=" + mSpawnIf + ";"; String command = resVar + "=" + mSpawnIf + ";";
Con::evaluatef(command.c_str());
StringTableEntry objectName = getName();
if (objectName != NULL)
objectName = getIdString();
StringTableEntry groupName = getGroup()->getName();
if (groupName != NULL)
groupName = getGroup()->getIdString();
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
Con::evaluate(command.c_str(), false, context);
if (Con::getBoolVariable(resVar.c_str()) == 1) if (Con::getBoolVariable(resVar.c_str()) == 1)
{ {
return true; return true;

View file

@ -975,6 +975,7 @@ ShapeBase::ShapeBase()
mMoveMotion( false ), mMoveMotion( false ),
mShapeBaseMount( NULL ), mShapeBaseMount( NULL ),
mShapeInstance( NULL ), mShapeInstance( NULL ),
mCubeReflector(NULL),
mConvexList( new Convex ), mConvexList( new Convex ),
mEnergy( 0.0f ), mEnergy( 0.0f ),
mRechargeRate( 0.0f ), mRechargeRate( 0.0f ),
@ -1053,6 +1054,12 @@ ShapeBase::~ShapeBase()
mShapeInstance = NULL; mShapeInstance = NULL;
} }
if (mCubeReflector)
{
mCubeReflector->unregisterReflector();
SAFE_DELETE(mCubeReflector);
}
CollisionTimeout* ptr = mTimeoutList; CollisionTimeout* ptr = mTimeoutList;
while (ptr) { while (ptr) {
CollisionTimeout* cur = ptr; CollisionTimeout* cur = ptr;
@ -1173,7 +1180,11 @@ void ShapeBase::onRemove()
if ( isClientObject() ) if ( isClientObject() )
{ {
mCubeReflector.unregisterReflector(); if (mCubeReflector)
{
mCubeReflector->unregisterReflector();
SAFE_DELETE(mCubeReflector);
}
} }
} }
@ -1349,11 +1360,17 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
mLightPlugin->reset(); mLightPlugin->reset();
if ( isClientObject() ) if ( isClientObject() )
{ {
mCubeReflector.unregisterReflector(); if (mCubeReflector)
{
if ( mDataBlock->reflectorDesc ) mCubeReflector->unregisterReflector();
mCubeReflector.registerReflector( this, mDataBlock->reflectorDesc ); SAFE_DELETE(mCubeReflector);
}
if (mDataBlock->reflectorDesc)
{
mCubeReflector = new CubeReflector();
mCubeReflector->registerReflector(this, mDataBlock->reflectorDesc);
}
} }
return true; return true;
@ -2681,7 +2698,7 @@ void ShapeBase::_prepRenderImage( SceneRenderState *state,
// If we're currently rendering our own reflection we // If we're currently rendering our own reflection we
// don't want to render ourselves into it. // don't want to render ourselves into it.
if ( mCubeReflector.isRendering() ) if (mCubeReflector && mCubeReflector->isRendering())
return; return;
// We force all the shapes to use the highest detail // We force all the shapes to use the highest detail
@ -2785,8 +2802,8 @@ void ShapeBase::prepBatchRender(SceneRenderState* state, S32 mountedImageIndex )
// Set up our TS render state. // Set up our TS render state.
TSRenderState rdata; TSRenderState rdata;
rdata.setSceneState( state ); rdata.setSceneState( state );
if ( mCubeReflector.isEnabled() ) if (mCubeReflector && mCubeReflector->isEnabled())
rdata.setCubemap( mCubeReflector.getCubemap() ); rdata.setCubemap( mCubeReflector->getCubemap() );
rdata.setFadeOverride( (1.0f - mCloakLevel) * mFadeVal ); rdata.setFadeOverride( (1.0f - mCloakLevel) * mFadeVal );
// We might have some forward lit materials // We might have some forward lit materials
@ -2810,14 +2827,14 @@ void ShapeBase::prepBatchRender(SceneRenderState* state, S32 mountedImageIndex )
mat.scale( mObjScale ); mat.scale( mObjScale );
GFX->setWorldMatrix( mat ); GFX->setWorldMatrix( mat );
if ( state->isDiffusePass() && mCubeReflector.isEnabled() && mCubeReflector.getOcclusionQuery() ) if ( state->isDiffusePass() && mCubeReflector && mCubeReflector->isEnabled() && mCubeReflector->getOcclusionQuery() )
{ {
RenderPassManager *pass = state->getRenderPass(); RenderPassManager *pass = state->getRenderPass();
OccluderRenderInst *ri = pass->allocInst<OccluderRenderInst>(); OccluderRenderInst *ri = pass->allocInst<OccluderRenderInst>();
ri->type = RenderPassManager::RIT_Occluder; ri->type = RenderPassManager::RIT_Occluder;
ri->query = mCubeReflector.getOcclusionQuery(); ri->query = mCubeReflector->getOcclusionQuery();
mObjToWorld.mulP( mObjBox.getCenter(), &ri->position ); mObjToWorld.mulP( mObjBox.getCenter(), &ri->position );
ri->scale.set( mObjBox.getExtents() ); ri->scale.set( mObjBox.getExtents() );
ri->orientation = pass->allocUniqueXform( mObjToWorld ); ri->orientation = pass->allocUniqueXform( mObjToWorld );

View file

@ -1207,7 +1207,7 @@ public:
static F32 sFullCorrectionDistance; static F32 sFullCorrectionDistance;
static F32 sCloakSpeed; // Time to cloak, in seconds static F32 sCloakSpeed; // Time to cloak, in seconds
CubeReflector mCubeReflector; CubeReflector* mCubeReflector;
/// @name Initialization /// @name Initialization
/// @{ /// @{

View file

@ -28,6 +28,7 @@
#include "console/engineAPI.h" #include "console/engineAPI.h"
#include "collision/boxConvex.h" #include "collision/boxConvex.h"
#include "console/script.h" #include "console/script.h"
#include "console/consoleInternal.h"
#include "core/stream/bitStream.h" #include "core/stream/bitStream.h"
#include "math/mathIO.h" #include "math/mathIO.h"
@ -172,8 +173,9 @@ Trigger::Trigger()
mPhysicsRep = NULL; mPhysicsRep = NULL;
mTripOnce = false; mTripOnce = false;
mTripped = false;
mTrippedBy = 0xFFFFFFFF; mTrippedBy = 0xFFFFFFFF;
mTripIf = ""; mTripIf.clear();
//Default up a basic square //Default up a basic square
Point3F vecs[3] = { Point3F(1.0, 0.0, 0.0), Point3F vecs[3] = { Point3F(1.0, 0.0, 0.0),
@ -704,7 +706,17 @@ bool Trigger::testCondition()
String resVar = getIdString() + String(".result"); String resVar = getIdString() + String(".result");
Con::setBoolVariable(resVar.c_str(), false); Con::setBoolVariable(resVar.c_str(), false);
String command = resVar + "=" + mTripIf + ";"; String command = resVar + "=" + mTripIf + ";";
Con::evaluatef(command.c_str());
StringTableEntry objectName = getName();
if (objectName != NULL)
objectName = getIdString();
StringTableEntry groupName = getGroup()->getName();
if (groupName != NULL)
groupName = getGroup()->getIdString();
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
Con::evaluate(command.c_str(), false, context);
if (Con::getBoolVariable(resVar.c_str()) == 1) if (Con::getBoolVariable(resVar.c_str()) == 1)
{ {
return true; return true;
@ -738,11 +750,11 @@ void Trigger::potentialEnterObject(GameBase* enter)
mObjects.push_back(enter); mObjects.push_back(enter);
deleteNotify(enter); deleteNotify(enter);
if(evalCmD(&mEnterCommand)) if(isServerObject() && evalCmD(&mEnterCommand))
{ {
String command = String("%obj = ") + enter->getIdString() + ";"; String command = String("%obj = ") + enter->getIdString() + ";";
command = command + String("%this = ") + getIdString() + ";" + mEnterCommand; command = command + String("%this = ") + getIdString() + ";" + mEnterCommand;
Con::evaluate(command.c_str()); Con::evaluate(command.c_str(), false, Con::getCurrentScriptModulePath());
} }
if( mDataBlock && testTrippable() && testCondition()) if( mDataBlock && testTrippable() && testCondition())
@ -787,11 +799,11 @@ void Trigger::processTick(const Move* move)
mObjects.erase(i); mObjects.erase(i);
clearNotify(remove); clearNotify(remove);
if (evalCmD(&mLeaveCommand)) if (isServerObject() && evalCmD(&mLeaveCommand))
{ {
String command = String("%obj = ") + remove->getIdString() + ";"; String command = String("%obj = ") + remove->getIdString() + ";";
command = command + String("%this = ") + getIdString() + ";" + mLeaveCommand; command = command + String("%this = ") + getIdString() + ";" + mLeaveCommand;
Con::evaluate(command.c_str()); Con::evaluate(command.c_str(), false, Con::getCurrentScriptModulePath());
} }
if (testTrippable() && testCondition()) if (testTrippable() && testCondition())
mDataBlock->onLeaveTrigger_callback( this, remove ); mDataBlock->onLeaveTrigger_callback( this, remove );
@ -799,8 +811,19 @@ void Trigger::processTick(const Move* move)
} }
} }
if (evalCmD(&mTickCommand)) if (isServerObject() && evalCmD(&mTickCommand))
Con::evaluate(mTickCommand.c_str()); {
StringTableEntry objectName = getName();
if (objectName != NULL)
objectName = getIdString();
StringTableEntry groupName = getGroup()->getName();
if (groupName != NULL)
groupName = getGroup()->getIdString();
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
Con::evaluate(mTickCommand.c_str(), false, context);
}
if (mObjects.size() != 0 && testTrippable() && testCondition()) if (mObjects.size() != 0 && testTrippable() && testCondition())
mDataBlock->onTickTrigger_callback( this ); mDataBlock->onTickTrigger_callback( this );

View file

@ -109,7 +109,8 @@ F32 TSStatic::smStaticObjectUnfadeableSize = 75;
TSStatic::TSStatic() TSStatic::TSStatic()
: :
cubeDescId(0), cubeDescId(0),
reflectorDesc(NULL) reflectorDesc(NULL),
mCubeReflector(NULL)
{ {
mNetFlags.set(Ghostable | ScopeAlways); mNetFlags.set(Ghostable | ScopeAlways);
@ -159,6 +160,11 @@ TSStatic::~TSStatic()
delete mConvexList; delete mConvexList;
mConvexList = NULL; mConvexList = NULL;
mShapeAsset.unregisterRefreshNotify(); mShapeAsset.unregisterRefreshNotify();
if (mCubeReflector)
{
mCubeReflector->unregisterReflector();
SAFE_DELETE(mCubeReflector);
}
} }
ImplementEnumType(TSMeshType, ImplementEnumType(TSMeshType,
@ -361,10 +367,17 @@ bool TSStatic::onAdd()
if (isClientObject()) if (isClientObject())
{ {
mCubeReflector.unregisterReflector(); if (mCubeReflector)
{
mCubeReflector->unregisterReflector();
SAFE_DELETE(mCubeReflector);
}
if (reflectorDesc) if (reflectorDesc)
mCubeReflector.registerReflector(this, reflectorDesc); {
mCubeReflector = new CubeReflector();
mCubeReflector->registerReflector(this, reflectorDesc);
}
} }
_updateShouldTick(); _updateShouldTick();
@ -594,8 +607,11 @@ void TSStatic::onRemove()
mShapeInstance = NULL; mShapeInstance = NULL;
mAmbientThread = NULL; mAmbientThread = NULL;
if (isClientObject()) if (isClientObject() && mCubeReflector)
mCubeReflector.unregisterReflector(); {
mCubeReflector->unregisterReflector();
SAFE_DELETE(mCubeReflector);
}
Parent::onRemove(); Parent::onRemove();
} }
@ -780,7 +796,7 @@ void TSStatic::prepRenderImage(SceneRenderState* state)
// If we're currently rendering our own reflection we // If we're currently rendering our own reflection we
// don't want to render ourselves into it. // don't want to render ourselves into it.
if (mCubeReflector.isRendering()) if (mCubeReflector && mCubeReflector->isRendering())
return; return;
@ -800,8 +816,8 @@ void TSStatic::prepRenderImage(SceneRenderState* state)
rdata.setFadeOverride(1.0f); rdata.setFadeOverride(1.0f);
rdata.setOriginSort(mUseOriginSort); rdata.setOriginSort(mUseOriginSort);
if (mCubeReflector.isEnabled()) if (mCubeReflector && mCubeReflector->isEnabled())
rdata.setCubemap(mCubeReflector.getCubemap()); rdata.setCubemap(mCubeReflector->getCubemap());
// Acculumation // Acculumation
rdata.setAccuTex(mAccuTex); rdata.setAccuTex(mAccuTex);
@ -830,13 +846,13 @@ void TSStatic::prepRenderImage(SceneRenderState* state)
mat.scale(mObjScale); mat.scale(mObjScale);
GFX->setWorldMatrix(mat); GFX->setWorldMatrix(mat);
if (state->isDiffusePass() && mCubeReflector.isEnabled() && mCubeReflector.getOcclusionQuery()) if (state->isDiffusePass() && mCubeReflector && mCubeReflector->isEnabled() && mCubeReflector->getOcclusionQuery())
{ {
RenderPassManager* pass = state->getRenderPass(); RenderPassManager* pass = state->getRenderPass();
OccluderRenderInst* ri = pass->allocInst<OccluderRenderInst>(); OccluderRenderInst* ri = pass->allocInst<OccluderRenderInst>();
ri->type = RenderPassManager::RIT_Occluder; ri->type = RenderPassManager::RIT_Occluder;
ri->query = mCubeReflector.getOcclusionQuery(); ri->query = mCubeReflector->getOcclusionQuery();
mObjToWorld.mulP(mObjBox.getCenter(), &ri->position); mObjToWorld.mulP(mObjBox.getCenter(), &ri->position);
ri->scale.set(mObjBox.getExtents()); ri->scale.set(mObjBox.getExtents());
ri->orientation = pass->allocUniqueXform(mObjToWorld); ri->orientation = pass->allocUniqueXform(mObjToWorld);

View file

@ -184,7 +184,7 @@ protected:
String cubeDescName; String cubeDescName;
U32 cubeDescId; U32 cubeDescId;
ReflectorDesc* reflectorDesc; ReflectorDesc* reflectorDesc;
CubeReflector mCubeReflector; CubeReflector* mCubeReflector;
void onAssetRefreshed(AssetPtrBase* pAssetPtrBase) override void onAssetRefreshed(AssetPtrBase* pAssetPtrBase) override
{ {

View file

@ -2367,8 +2367,7 @@ DefineEngineFunction( exec, bool, ( const char* fileName, bool noCalls, bool jou
DefineEngineFunction( eval, const char*, ( const char* consoleString, bool echo ), (false), "eval(consoleString)") DefineEngineFunction( eval, const char*, ( const char* consoleString, bool echo ), (false), "eval(consoleString)")
{ {
Con::EvalResult returnValue = Con::evaluate(consoleString, echo, NULL); Con::EvalResult returnValue = Con::evaluate(consoleString, echo, Platform::makeRelativePathName(Con::getCurrentScriptModulePath(), NULL));
return Con::getReturnBuffer(returnValue.value.getString()); return Con::getReturnBuffer(returnValue.value.getString());
} }

View file

@ -59,7 +59,8 @@ inline FuncVars* getFuncVars(S32 lineNumber)
{ {
if (gFuncVars == &gGlobalScopeFuncVars) if (gFuncVars == &gGlobalScopeFuncVars)
{ {
const char* str = avar("Attemping to use local variable in global scope. File: %s Line: %d", CodeBlock::smCurrentParser->getCurrentFile(), lineNumber); const char* lineTxt = CodeBlock::smCurrentLineText;
const char* str = avar("Attemping to use local variable in global scope. File: %s\nLine Num: %d\nLine: \"%s\"", CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineTxt);
scriptErrorHandler(str); scriptErrorHandler(str);
} }
return gFuncVars; return gFuncVars;

View file

@ -35,6 +35,7 @@ using namespace Compiler;
bool CodeBlock::smInFunction = false; bool CodeBlock::smInFunction = false;
CodeBlock * CodeBlock::smCodeBlockList = NULL; CodeBlock * CodeBlock::smCodeBlockList = NULL;
const char* CodeBlock::smCurrentLineText = "\0";
TorqueScriptParser *CodeBlock::smCurrentParser = NULL; TorqueScriptParser *CodeBlock::smCurrentParser = NULL;
extern FuncVars gEvalFuncVars; extern FuncVars gEvalFuncVars;
@ -578,6 +579,7 @@ Con::EvalResult CodeBlock::compileExec(StringTableEntry fileName, const char *in
consoleAllocReset(); consoleAllocReset();
name = fileName; name = fileName;
smCurrentLineText = inString;
if (fileName) if (fileName)
{ {
@ -623,6 +625,7 @@ Con::EvalResult CodeBlock::compileExec(StringTableEntry fileName, const char *in
if (!Script::gStatementList) if (!Script::gStatementList)
{ {
smCurrentLineText = "\0";
delete this; delete this;
return Con::EvalResult(Con::getVariable("$ScriptError")); return Con::EvalResult(Con::getVariable("$ScriptError"));
} }
@ -668,7 +671,10 @@ Con::EvalResult CodeBlock::compileExec(StringTableEntry fileName, const char *in
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp); Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
// repurpose argc as local register counter for global state // repurpose argc as local register counter for global state
return (exec(0, fileName, NULL, localRegisterCount, 0, noCalls, NULL, setFrame)); Con::EvalResult execResult = (exec(0, fileName, NULL, localRegisterCount, 0, noCalls, NULL, setFrame));
smCurrentLineText = "\0";
return execResult;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------

View file

@ -61,6 +61,7 @@ private:
public: public:
static bool smInFunction; static bool smInFunction;
static TorqueScriptParser * smCurrentParser; static TorqueScriptParser * smCurrentParser;
static const char* smCurrentLineText;
static CodeBlock *getCodeBlockList() static CodeBlock *getCodeBlockList()
{ {

View file

@ -160,7 +160,16 @@ S32 FuncVars::assign(StringTableEntry var, TypeReq currentType, S32 lineNumber,
if (found->second.isConstant) if (found->second.isConstant)
{ {
const char* str = avar("Script Warning: Reassigning variable %s when it is a constant. File: %s Line : %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber); const char* lineText = CodeBlock::smCurrentLineText;
String codeString = CodeBlock::smCurrentLineText;
Vector<String> splitLines;
codeString.split("\n", splitLines);
if (lineNumber > 0 && splitLines.size() > lineNumber)
lineText = splitLines[lineNumber - 1].c_str();
const char* str = avar("Script Warning: Reassigning variable %s when it is a constant. File: %s\nLine Num: %d\nLine: \"%s\"", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineText);
scriptErrorHandler(str); scriptErrorHandler(str);
} }
return found->second.reg; return found->second.reg;
@ -179,7 +188,16 @@ S32 FuncVars::lookup(StringTableEntry var, S32 lineNumber)
if (found == vars.end()) if (found == vars.end())
{ {
const char* str = avar("Script Warning: Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber); const char* lineText = CodeBlock::smCurrentLineText;
String codeString = CodeBlock::smCurrentLineText;
Vector<String> splitLines;
codeString.split("\n", splitLines);
if (lineNumber > 0 && splitLines.size() > lineNumber)
lineText = splitLines[lineNumber - 1].c_str();
const char* str = avar("Script Warning: Variable %s referenced before used when compiling script. File: %s\nLine Num: %d\nLine: \"%s\"", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineText);
scriptErrorHandler(str); scriptErrorHandler(str);
return assign(var, TypeReqString, lineNumber, false); return assign(var, TypeReqString, lineNumber, false);
@ -194,7 +212,16 @@ TypeReq FuncVars::lookupType(StringTableEntry var, S32 lineNumber)
if (found == vars.end()) if (found == vars.end())
{ {
const char* str = avar("Script Warning: Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber); const char* lineText = CodeBlock::smCurrentLineText;
String codeString = CodeBlock::smCurrentLineText;
Vector<String> splitLines;
codeString.split("\n", splitLines);
if (lineNumber > 0 && splitLines.size() > lineNumber)
lineText = splitLines[lineNumber-1].c_str();
const char* str = avar("Script Warning: Variable %s referenced before used when compiling script. File: %s\nLine Num: %d\nLine: \"%s\"", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber, lineText);
scriptErrorHandler(str); scriptErrorHandler(str);
assign(var, TypeReqString, lineNumber, false); assign(var, TypeReqString, lineNumber, false);

View file

@ -974,7 +974,9 @@ void GuiGameListMenuCtrl::doScriptCommand(StringTableEntry command)
if (command && command[0]) if (command && command[0])
{ {
setThisControl(); setThisControl();
Con::evaluate(command, false, __FILE__); StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
String context = String::ToString("%s\nObject: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
Con::evaluate(command, false, context);
} }
} }

View file

@ -494,7 +494,9 @@ void GuiGameSettingsCtrl::doScriptCommand(StringTableEntry command)
if (command && command[0]) if (command && command[0])
{ {
setThisControl(); setThisControl();
Con::evaluate(command, false, __FILE__); StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
String context = String::ToString("%s\nObject: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
Con::evaluate(command, false, context.c_str());
} }
} }

View file

@ -1539,7 +1539,9 @@ StringTableEntry GuiListBoxCtrl::_makeMirrorItemName( SimObject *inObj )
Con::setIntVariable( "$ThisControl", getId() ); Con::setIntVariable( "$ThisControl", getId() );
Con::setIntVariable( "$ThisObject", inObj->getId() ); Con::setIntVariable( "$ThisObject", inObj->getId() );
outName = StringTable->insert( Con::evaluate( mMakeNameCallback ).value, true ); StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
String context = String::ToString("%s, Object: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
outName = StringTable->insert( Con::evaluate( mMakeNameCallback, false, context).value, true );
} }
else if ( inObj->getName() ) else if ( inObj->getName() )
outName = StringTable->insert( inObj->getName() ); outName = StringTable->insert( inObj->getName() );

View file

@ -211,7 +211,9 @@ bool GuiMLTextEditCtrl::onKeyDown(const GuiEvent& event)
case KEY_ESCAPE: case KEY_ESCAPE:
if ( mEscapeCommand[0] ) if ( mEscapeCommand[0] )
{ {
Con::evaluate( mEscapeCommand ); StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
String context = String::ToString("%s, Object: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
Con::evaluate( mEscapeCommand, false, context.c_str());
return( true ); return( true );
} }
return( Parent::onKeyDown( event ) ); return( Parent::onKeyDown( event ) );

View file

@ -2495,7 +2495,15 @@ void GuiControl::getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent
const char* GuiControl::evaluate( const char* str ) const char* GuiControl::evaluate( const char* str )
{ {
smThisControl = this; smThisControl = this;
const char* result = Con::evaluate(str, false).value; StringTableEntry objectName = getName();
if (getName() == NULL)
objectName = getInternalName();
StringTableEntry fileName = getFilename();
if (fileName != NULL)
fileName = Platform::makeRelativePathName(fileName, NULL);
String context = String::ToString("%s\nObject: %s", fileName, objectName);
const char* result = Con::evaluate(str, false, context).value;
smThisControl = NULL; smThisControl = NULL;
return result; return result;

View file

@ -1482,8 +1482,12 @@ bool ActionMap::processAction(const InputEventInfo* pEvent)
if(pNode->flags & Node::BindCmd) if(pNode->flags & Node::BindCmd)
{ {
// it's a bind command // it's a bind command
if(pNode->makeConsoleCommand) if (pNode->makeConsoleCommand)
Con::evaluate(pNode->makeConsoleCommand); {
StringTableEntry objectName = getName() != StringTable->EmptyString() ? getName() : getInternalName();
String context = String::ToString("%s\nObject: %s", Platform::makeRelativePathName(getFilename(), NULL), objectName);
Con::evaluate(pNode->makeConsoleCommand, false, context.c_str());
}
} }
else if (pNode->flags & Node::Held) else if (pNode->flags & Node::Held)
{ {

View file

@ -206,15 +206,15 @@ void AssimpAppMaterial::initMaterial(const Torque::Path& path, Material* mat) co
if (rmName.isNotEmpty()) if (rmName.isNotEmpty())
{ {
mat->_setRoughMap(cleanTextureName(rmName, cleanFile, path, false), 0); // Roughness mat->_setRoughMap(cleanTextureName(rmName, cleanFile, path, false), 0); // Roughness
mat->mRoughnessChan[0] = 1.0f; mat->mRoughnessChan[0] = 1;
mat->mInvertRoughness[0] = (floatVal == 1.0f); mat->mInvertRoughness[0] = false;
mat->_setMetalMap(cleanTextureName(rmName, cleanFile, path, false), 0); // Metallic mat->_setMetalMap(cleanTextureName(rmName, cleanFile, path, false), 0); // Metallic
mat->mMetalChan[0] = 2.0f; mat->mMetalChan[0] = 2;
} }
if (aoName.isNotEmpty()) if (aoName.isNotEmpty())
{ {
mat->_setAOMap(cleanTextureName(aoName, cleanFile, path, false), 0); // occlusion mat->_setAOMap(cleanTextureName(aoName, cleanFile, path, false), 0); // occlusion
mat->mAOChan[0] = 0.0f; mat->mAOChan[0] = 0;
} }
else else
{ {