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(gameclient): build no render object for a drawable born and dead in one tick

Olcay Seygan70c941dff970
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
index 4df96c7e2..72b994ee5 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
@@ -454,6 +454,7 @@ public:
static Bool tickDefersLifetime();
void flushPendingTransform( Bool onDemand ); ///< tells the draw modules of a transform the tick deferred; GameClient::destroyDrawable
void doPendingClientWork( Bool onDemand ); ///< everything the tick deferred on this drawable; flushDestroyedDrawables for one the tick also destroyed
+ Bool isRenderPending( void ) const { return m_renderPending; } ///< made in a tick and its render objects not built yet
/** Where a doClientWork goes among the model condition states the tick has not applied yet. */
enum ClientWorkOrder
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
index 19d514e9a..382e53f2c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
@@ -1115,9 +1115,15 @@ void GameClient::flushDestroyedDrawables( void )
{
LOGIC_CENSUS( CENSUS_DESTROY_DRAWABLE );
// what the tick deferred on it before it died, which flushPendingClientWork no longer finds by ID:
- // the last mine's detonation FX, and the model's last place as on the immediate path above
- m_destroyedInTick[ i ]->doPendingClientWork( FALSE );
- m_destroyedInTick[ i ]->deleteInstance();
+ // the last mine's detonation FX, and the model's last place as on the immediate path above. One
+ // the same tick made was never drawn, and building its render objects only to delete them is not
+ // worth the effect: it keeps the transform alone, as before
+ Drawable *draw = m_destroyedInTick[ i ];
+ if( draw->isRenderPending() )
+ draw->flushPendingTransform( FALSE );
+ else
+ draw->doPendingClientWork( FALSE );
+ draw->deleteInstance();
}
m_destroyedInTick.clear();
}