From 315bbdb69a2e2f572dabc5e0a4935f63302e0d85 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Mon, 13 Oct 2025 09:34:09 +0000 Subject: [PATCH] W3DDependencyModelDraw: Add null checks for container module and drawable --- .../Drawable/Draw/W3DDependencyModelDraw.cpp | 27 ++++++++------ .../Drawable/Draw/W3DDependencyModelDraw.cpp | 37 +++++++++++-------- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp index a0151a6016e..26bc792ab06 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp @@ -108,22 +108,25 @@ void W3DDependencyModelDraw::adjustTransformMtx(Matrix3D& mtx) const if( md->m_attachToDrawableBoneInContainer.isNotEmpty() && me && me->getContainedBy() - && !me->getContainedBy()->getContain()->isEnclosingContainerFor(me) ) { - // If we are currently "riding on", then our client position is determined by the client position of - // a particular bone in our container object. Our logic position is updated by OpenContain. - const Drawable *theirDrawable = me->getContainedBy()->getDrawable(); - if( theirDrawable ) + const ContainModuleInterface* containerModule = me->getContainedBy()->getContain(); + if( containerModule && !containerModule->isEnclosingContainerFor(me) ) { - Matrix3D theirBoneMtx; - if( theirDrawable->getCurrentWorldspaceClientBonePositions( md->m_attachToDrawableBoneInContainer.str(), theirBoneMtx ) ) + // If we are currently "riding on", then our client position is determined by the client position of + // a particular bone in our container object. Our logic position is updated by OpenContain. + const Drawable *theirDrawable = me->getContainedBy()->getDrawable(); + if( theirDrawable ) { - mtx = theirBoneMtx; - } - else - { - DEBUG_LOG(("m_attachToDrawableBoneInContainer %s not found",getW3DDependencyModelDrawModuleData()->m_attachToDrawableBoneInContainer.str())); + Matrix3D theirBoneMtx; + if( theirDrawable->getCurrentWorldspaceClientBonePositions( md->m_attachToDrawableBoneInContainer.str(), theirBoneMtx ) ) + { + mtx = theirBoneMtx; + } + else + { + DEBUG_LOG(("m_attachToDrawableBoneInContainer %s not found",getW3DDependencyModelDrawModuleData()->m_attachToDrawableBoneInContainer.str())); + } } } } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp index 8582b2e5b1b..65747cf58f2 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp @@ -100,8 +100,12 @@ void W3DDependencyModelDraw::doDrawModule(const Matrix3D* transformMtx) Drawable *theirDrawable = NULL; - if( me->getContainedBy() && !me->getContainedBy()->getContain()->isEnclosingContainerFor(me) ) - theirDrawable = me->getContainedBy()->getDrawable(); + if( me->getContainedBy() ) + { + const ContainModuleInterface* containerModule = me->getContainedBy()->getContain(); + if( containerModule && !containerModule->isEnclosingContainerFor(me) ) + theirDrawable = me->getContainedBy()->getDrawable(); + } if( ! theirDrawable ) return; @@ -129,23 +133,26 @@ void W3DDependencyModelDraw::adjustTransformMtx(Matrix3D& mtx) const if( md->m_attachToDrawableBoneInContainer.isNotEmpty() && me && me->getContainedBy() - && !me->getContainedBy()->getContain()->isEnclosingContainerFor(me) ) { - // If we are currently "riding on", then our client position is determined by the client position of - // a particular bone in our container object. Our logic position is updated by OpenContain. - const Drawable *theirDrawable = me->getContainedBy()->getDrawable(); - if( theirDrawable ) + const ContainModuleInterface* containerModule = me->getContainedBy()->getContain(); + if( containerModule && !containerModule->isEnclosingContainerFor(me) ) { - Matrix3D theirBoneMtx; - if( theirDrawable->getCurrentWorldspaceClientBonePositions( md->m_attachToDrawableBoneInContainer.str(), theirBoneMtx ) ) + // If we are currently "riding on", then our client position is determined by the client position of + // a particular bone in our container object. Our logic position is updated by OpenContain. + const Drawable *theirDrawable = me->getContainedBy()->getDrawable(); + if( theirDrawable ) { - mtx = theirBoneMtx; - } - else - { - mtx = *theirDrawable->getTransformMatrix();//TransformMatrix(); - DEBUG_LOG(("m_attachToDrawableBoneInContainer %s not found",getW3DDependencyModelDrawModuleData()->m_attachToDrawableBoneInContainer.str())); + Matrix3D theirBoneMtx; + if( theirDrawable->getCurrentWorldspaceClientBonePositions( md->m_attachToDrawableBoneInContainer.str(), theirBoneMtx ) ) + { + mtx = theirBoneMtx; + } + else + { + mtx = *theirDrawable->getTransformMatrix();//TransformMatrix(); + DEBUG_LOG(("m_attachToDrawableBoneInContainer %s not found",getW3DDependencyModelDrawModuleData()->m_attachToDrawableBoneInContainer.str())); + } } } }