Skip to content

Commit 98f6cd1

Browse files
committed
fix(ghostobject): Add additional tests in W3DRenderObjectSnapshot::addToScene, W3DGhostObject::removeParentObject for robustness (#1569)
1 parent 98de109 commit 98f6cd1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Generals/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void W3DRenderObjectSnapshot::update(RenderObjClass *robj, DrawableInfo *drawInf
153153
// ------------------------------------------------------------------------------------------------
154154
void W3DRenderObjectSnapshot::addToScene(void)
155155
{
156-
if (W3DDisplay::m_3DScene != NULL)
156+
if (!m_robj->Is_In_Scene())
157157
W3DDisplay::m_3DScene->Add_Render_Object(m_robj);
158158
}
159159

@@ -406,6 +406,8 @@ void W3DGhostObject::removeParentObject(void)
406406
return;
407407

408408
Drawable *draw = m_parentObject->getDrawable();
409+
if (!draw)
410+
return;
409411

410412
//After we remove the unfogged object, we also disable
411413
//anything that should be hidden inside fog - shadow, particles, etc.

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void W3DRenderObjectSnapshot::update(RenderObjClass *robj, DrawableInfo *drawInf
157157
// ------------------------------------------------------------------------------------------------
158158
void W3DRenderObjectSnapshot::addToScene(void)
159159
{
160-
if (W3DDisplay::m_3DScene != NULL)
160+
if (!m_robj->Is_In_Scene())
161161
W3DDisplay::m_3DScene->Add_Render_Object(m_robj);
162162
}
163163

@@ -410,6 +410,8 @@ void W3DGhostObject::removeParentObject(void)
410410
return;
411411

412412
Drawable *draw = m_parentObject->getDrawable();
413+
if (!draw)
414+
return;
413415

414416
//After we remove the unfogged object, we also disable
415417
//anything that should be hidden inside fog - shadow, particles, etc.

0 commit comments

Comments
 (0)