Various misc. tweaks and fixes based on static code analysis to minimize/fix memleaks, crashes, or other performance impacting code.

This commit is contained in:
Areloch 2020-09-19 18:25:10 -05:00
parent d76c73c252
commit 8956559bfd
44 changed files with 124 additions and 258 deletions

View file

@ -11,7 +11,8 @@ Scene::Scene() :
mParentScene(nullptr),
mSceneId(-1),
mIsEditing(false),
mIsDirty(false)
mIsDirty(false),
mEditPostFX(0)
{
mGameModeName = StringTable->EmptyString();
}

View file

@ -120,6 +120,8 @@ AIPlayer::AIPlayer()
for( S32 i = 0; i < MaxTriggerKeys; i ++ )
mMoveTriggers[ i ] = false;
mAttackRadius = 1;
}
/**

View file

@ -266,7 +266,7 @@ GuiControl* GuiInspectorTypeGameObjectAssetPtr::constructEditControl()
const char* assetId = getData();
if (assetId == "")
if (dStrEqual(assetId, ""))
{
mGameObjectEditButton->setText("Create Game Object");

View file

@ -280,7 +280,7 @@ bool GuiInspectorTypeMaterialAssetPtr::updateRects()
bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
if (mMatEdContainer != nullptr)
if (mMatEdContainer != nullptr && mMatPreviewButton != nullptr)
{
mMatPreviewButton->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
}

View file

@ -783,7 +783,7 @@ U32 DecalManager::_generateConvexHull( const Vector<Point3F> &points, Vector<Poi
while ( ++i <= maxmin )
{
// the lower line joins P[minmin] with P[maxmin]
if ( isLeft( points[minmin], points[maxmin], points[i]) >= 0 && i < maxmin )
if (i < maxmin && isLeft(points[minmin], points[maxmin], points[i]) >= 0)
continue; // ignore P[i] above or on the lower line
while (top > 0) // there are at least 2 points on the stack

View file

@ -747,14 +747,21 @@ void ReflectionProbe::processStaticCubemap()
if (Platform::isFile(irradFileName))
{
mIrridianceMap->setCubemapFile(FileName(irradFileName));
mIrridianceMap->updateFaces();
}
if (mIrridianceMap == nullptr)
{
Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked irradiance map at %s", irradFileName);
return;
}
if (mIrridianceMap == nullptr || mIrridianceMap->mCubemap.isNull())
{
Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked irradiance map at %s", irradFileName);
return;
mIrridianceMap->setCubemapFile(FileName(irradFileName));
if (mIrridianceMap->mCubemap.isNull())
{
Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked irradiance map at %s", irradFileName);
return;
}
mIrridianceMap->updateFaces();
}
char prefilterFileName[256];
@ -762,14 +769,21 @@ void ReflectionProbe::processStaticCubemap()
if (Platform::isFile(prefilterFileName))
{
mPrefilterMap->setCubemapFile(FileName(prefilterFileName));
mPrefilterMap->updateFaces();
}
if (mPrefilterMap == nullptr)
{
Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked prefilter map at %s", prefilterFileName);
return;
}
if (mPrefilterMap == nullptr || mPrefilterMap->mCubemap.isNull())
{
Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked prefilter map at %s", prefilterFileName);
return;
mPrefilterMap->setCubemapFile(FileName(prefilterFileName));
if (mPrefilterMap->mCubemap.isNull())
{
Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked prefilter map at %s", prefilterFileName);
return;
}
mPrefilterMap->updateFaces();
}
if (!Platform::isFile(prefilterFileName) || !Platform::isFile(irradFileName))
@ -809,7 +823,7 @@ void ReflectionProbe::processStaticCubemap()
IBLUtilities::SaveCubeMap(prefilterFileName, mPrefilterMap->mCubemap);
}
if ((mIrridianceMap != nullptr || !mIrridianceMap->mCubemap.isNull()) && (mPrefilterMap != nullptr || !mPrefilterMap->mCubemap.isNull()))
if ((mIrridianceMap != nullptr && !mIrridianceMap->mCubemap.isNull()) && (mPrefilterMap != nullptr && !mPrefilterMap->mCubemap.isNull()))
{
mProbeInfo->mPrefilterCubemap = mPrefilterMap->mCubemap;
mProbeInfo->mIrradianceCubemap = mIrridianceMap->mCubemap;

View file

@ -290,6 +290,7 @@ PlayerData::PlayerData()
maxStepHeight = 1.0f;
runSurfaceAngle = 80.0f;
runSurfaceCos = mCos(mDegToRad(runSurfaceAngle));
fallingSpeedThreshold = -10.0f;

View file

@ -120,8 +120,7 @@ SFXEmitter::~SFXEmitter()
{
mLocalProfile._unregisterSignals();
if( mSource )
SFX_DELETE( mSource );
SFX_DELETE( mSource );
}
//-----------------------------------------------------------------------------

View file

@ -1210,7 +1210,7 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
}
ShapeBaseData *prevDB = dynamic_cast<ShapeBaseData*>( mDataBlock );
bool isInitialDataBlock = ( mDataBlock == 0 );
bool isInitialDataBlock = (prevDB == 0);
if ( Parent::onNewDataBlock( dptr, reload ) == false )
return false;
@ -1236,13 +1236,14 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
for (S32 i = 0; i < mDataBlock->txr_tag_remappings.size(); i++)
{
ShapeBaseData::TextureTagRemapping* remap = &mDataBlock->txr_tag_remappings[i];
Vector<String> & mat_names = (Vector<String>&) mat_list->getMaterialNameList();
for (S32 j = 0; j < mat_names.size(); j++)
Vector<String>& mat_names = (Vector<String>&) mat_list->getMaterialNameList();
S32 old_tagLen = dStrlen(remap->old_tag);
for (S32 j = 0; j < mat_names.size(); j++)
{
if (mat_names[j].compare(remap->old_tag, dStrlen(remap->old_tag), String::NoCase) == 0)
if (mat_names[j].compare(remap->old_tag, old_tagLen, String::NoCase) == 0)
{
mat_names[j] = String(remap->new_tag);
mat_names[j].insert(0,'#');
mat_names[j].insert(0, '#');
break;
}
}
@ -1263,14 +1264,15 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
for (S32 i = 0; i < mDataBlock->txr_tag_remappings.size(); i++)
{
ShapeBaseData::TextureTagRemapping* remap = &mDataBlock->txr_tag_remappings[i];
Vector<String> & mat_names = (Vector<String>&) mat_list->getMaterialNameList();
for (S32 j = 0; j < mat_names.size(); j++)
Vector<String>& mat_names = (Vector<String>&) mat_list->getMaterialNameList();
S32 new_tagLen = dStrlen(remap->new_tag);
for (S32 j = 0; j < mat_names.size(); j++)
{
String::SizeType len = mat_names[j].length();
if (len > 1)
{
String temp_name = mat_names[j].substr(1,len-1);
if (temp_name.compare(remap->new_tag, dStrlen(remap->new_tag)) == 0)
String temp_name = mat_names[j].substr(1, len - 1);
if (temp_name.compare(remap->new_tag, new_tagLen) == 0)
{
mat_names[j] = String(remap->old_tag);
break;
@ -1286,7 +1288,7 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
resetWorldBox();
// Set the initial mesh hidden state.
mMeshHidden.setSize( mDataBlock->mShape->objects.size() );
mMeshHidden.setSize(mDataBlock->mShape->objects.size());
mMeshHidden.clear();
// Initialize the threads
@ -1304,37 +1306,37 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
// initialized either by the constructor or from the server.
bool reset = st.thread != 0;
st.thread = 0;
// New datablock/shape may not actually HAVE this sequence.
// In that case stop playing it.
AssertFatal( prevDB != NULL, "ShapeBase::onNewDataBlock - how did you have a sequence playing without a prior datablock?" );
const TSShape *prevShape = prevDB->mShape;
const TSShape::Sequence &prevSeq = prevShape->sequences[st.sequence];
const String &prevSeqName = prevShape->names[prevSeq.nameIndex];
st.sequence = mDataBlock->mShape->findSequence( prevSeqName );
AssertFatal(prevDB != NULL, "ShapeBase::onNewDataBlock - how did you have a sequence playing without a prior datablock?");
if ( st.sequence != -1 )
const TSShape* prevShape = prevDB->mShape;
const TSShape::Sequence& prevSeq = prevShape->sequences[st.sequence];
const String& prevSeqName = prevShape->names[prevSeq.nameIndex];
st.sequence = mDataBlock->mShape->findSequence(prevSeqName);
if (st.sequence != -1)
{
setThreadSequence( i, st.sequence, reset );
}
setThreadSequence(i, st.sequence, reset);
}
}
}
if (mDataBlock->damageSequence != -1) {
mDamageThread = mShapeInstance->addThread();
mShapeInstance->setSequence(mDamageThread,
mDataBlock->damageSequence,0);
mDataBlock->damageSequence, 0);
}
if (mDataBlock->hulkSequence != -1) {
mHulkThread = mShapeInstance->addThread();
mShapeInstance->setSequence(mHulkThread,
mDataBlock->hulkSequence,0);
mDataBlock->hulkSequence, 0);
}
if( isGhost() )
if (isGhost())
{
// Reapply the current skin
mAppliedSkinName = "";

View file

@ -339,8 +339,13 @@ bool WheeledVehicleData::preload(bool server, String &errorStr)
// Resolve objects transmitted from server
if (!server) {
for (S32 i = 0; i < MaxSounds; i++)
if( !sfxResolve( &sound[ i ], errorStr ) )
{
if (!sfxResolve(&sound[i], errorStr))
{
delete si;
return false;
}
}
if (tireEmitter)
Sim::findObject(SimObjectId((uintptr_t)tireEmitter),tireEmitter);