Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(w3ddevice): cap a destroyed tank's track on the ground

Olcay Seygan34f5115af333
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp
index f190b16d6..fd48d82f5 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp
@@ -209,7 +209,9 @@ void TerrainTracksRenderObjClass::addCapEdgeToTrack(Real x, Real y)
PathfindLayerEnum objectLayer;
Real eHeight;
- if (m_ownerDrawable && (objectLayer=m_ownerDrawable->getObject()->getLayer()) != LAYER_GROUND)
+ // a tank the tick destroyed caps its track after the tick, its object gone: the cap goes on the ground
+ const Object *owner = m_ownerDrawable ? m_ownerDrawable->getObject() : NULL;
+ if (owner && (objectLayer=owner->getLayer()) != LAYER_GROUND)
eHeight=BRIDGE_OFFSET_FACTOR+TheTerrainLogic->getLayerHeight(x,y,objectLayer,&vZTmp);
else
eHeight=TheTerrainLogic->getGroundHeight(x,y,&vZTmp);