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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameclient): replay the condition states a tick would have flushed
Olcay Seygan1f213c44c3cf
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.hindex d7b8820b9..8d4dd421c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h@@ -826,8 +826,10 @@ private:#endifmutable Bool m_clientWorkQueued; ///< this drawable's ID is in the list flushPendingClientWork walksBool m_transformPending; ///< the tick moved it; the draw modules have not been told+ mutable std::vector<ModelConditionFlags> m_conditionSteps; ///< states an in-tick flush would have applied, in ordervoid queueClientWork() const;+ void deferModelConditionFlush() const;void flushModelCondition( Bool onDemand ) const;void doPendingClientWork( Bool onDemand );void markModelDirty();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex 88ee0b1ac..f9b7db09a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -1027,7 +1027,9 @@ Int Drawable::getPristineBonePositions(const char* boneNamePrefix, Int startIndeInt Drawable::getCurrentClientBonePositions(const char* boneNamePrefix, Int startIndex, Coord3D* positions, Matrix3D* transforms, Int maxBones) const{Int count = 0;- for (const DrawModule** dm = getDrawModules(); *dm; ++dm)+ // the uplink cannon asks from the tick for its raised antenna: DEPLOYED starts on the animation's+ // last frame, and the pristine bones are its first, about 34 units lower+ for (DrawModule** dm = const_cast<Drawable*>(this)->getDrawModulesFlushed(); *dm; ++dm){if (maxBones <= 0)break;@@ -5085,12 +5087,12 @@ DrawModule** Drawable::getDrawModulesNonDirty()//-------------------------------------------------------------------------------------------------DrawModule** Drawable::getDrawModules(){- DrawModule** dm = (DrawModule**)getModuleList(MODULETYPE_DRAW);+ DrawModule** dm = (DrawModule**)getModuleList(MODULETYPE_DRAW);#ifdef DIRTY_CONDITION_FLAGSif (m_isModelDirty){if (TheGameLogic->isInGameLogicUpdate())- queueClientWork();+ deferModelConditionFlush();elseflushModelCondition( FALSE );}@@ -5101,12 +5103,12 @@ DrawModule** Drawable::getDrawModules()//-------------------------------------------------------------------------------------------------DrawModule const** Drawable::getDrawModules() const{- DrawModule const** dm = (DrawModule const**)getModuleList(MODULETYPE_DRAW);+ DrawModule const** dm = (DrawModule const**)getModuleList(MODULETYPE_DRAW);#ifdef DIRTY_CONDITION_FLAGSif (m_isModelDirty){if (TheGameLogic->isInGameLogicUpdate())- queueClientWork();+ deferModelConditionFlush();elseflushModelCondition( FALSE );}@@ -5131,6 +5133,17 @@ void Drawable::queueClientWork() consts_clientWorkQueue.push_back( getID() );}+//-------------------------------------------------------------------------------------------------+/** Where a flush used to run inside the tick, the state it would have applied is kept, so the flush+ after the tick walks the same states in the same order and W3DModelDraw picks the same transition+ animations (a door, a deploy, an unpack set A then B in one tick) as an immediate flush did. */+void Drawable::deferModelConditionFlush() const+{+ if (m_conditionSteps.empty() || m_conditionSteps.back() != m_conditionState)+ m_conditionSteps.push_back( m_conditionState );+ queueClientWork();+}+//-------------------------------------------------------------------------------------------------/** The model condition flush. The census counts it from the logic thread: on its own channel when acaller asked for it on demand, under modelcondition when anything else made it run there. */@@ -5145,13 +5158,20 @@ void Drawable::flushModelCondition( Bool onDemand ) const// list of W3D render objects not being munged. (srj)return;}+ // the states a flush inside the tick would have applied first, then the one the tick ended on+ if (m_conditionSteps.empty() || m_conditionSteps.back() != m_conditionState)+ m_conditionSteps.push_back( m_conditionState );// yeah, yeah, yeah... I know (srj)- for (DrawModule** dm = (DrawModule**)getModuleList(MODULETYPE_DRAW); *dm; ++dm)+ for (size_t i = 0; i < m_conditionSteps.size(); ++i){- ObjectDrawInterface* di = (*dm)->getObjectDrawInterface();- if (di)- di->replaceModelConditionState( m_conditionState );+ for (DrawModule** dm = (DrawModule**)getModuleList(MODULETYPE_DRAW); *dm; ++dm)+ {+ ObjectDrawInterface* di = (*dm)->getObjectDrawInterface();+ if (di)+ di->replaceModelConditionState( m_conditionSteps[i] );+ }}+ m_conditionSteps.clear();m_isModelDirty = false;}@@ -5255,6 +5275,7 @@ void Drawable::replaceModelConditionFlags( const ModelConditionFlags &flags, Booif (di)di->replaceModelConditionState( m_conditionState );}+ m_conditionSteps.clear();m_isModelDirty = false;}else@@ -5420,7 +5441,10 @@ void Drawable::reactToTransformChange(const Matrix3D* oldMtx, const Coord3D* oldif (TheGameLogic->isInGameLogicUpdate()){m_transformPending = TRUE;- queueClientWork();+ if (m_isModelDirty)+ deferModelConditionFlush(); // the getDrawModules below flushed here+ else+ queueClientWork();return;}LOGIC_CENSUS( CENSUS_DRAWABLE );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cppindex 21a1cf925..634cd9284 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp@@ -1213,14 +1213,11 @@ Bool ParticleUplinkCannonUpdate::calculateUpBonePositions()Coord3D pos;if( draw ){- // Pristine bones of the state logic believes in: both positions are saved and steer the beam, and- // the render object's live bones are where this machine last drew the antenna. The uplink has- // no turret, so there is no turret angle to add.- if( data->m_connectorBoneName.isNotEmpty() && draw->getPristineBonePositions( data->m_connectorBoneName.str(), 0, &pos, &mtx, 1 ) )+ if( data->m_connectorBoneName.isNotEmpty() && draw->getCurrentClientBonePositions( data->m_connectorBoneName.str(), 0, &pos, &mtx, 1 ) ){obj->convertBonePosToWorldPos( &pos, &mtx, &m_connectorNodePosition, &mtx );}- if( data->m_fireBoneName.isNotEmpty() && draw->getPristineBonePositions( data->m_fireBoneName.str(), 0, &pos, &mtx, 1 ) )+ if( data->m_fireBoneName.isNotEmpty() && draw->getCurrentClientBonePositions( data->m_fireBoneName.str(), 0, &pos, &mtx, 1 ) ){obj->convertBonePosToWorldPos( &pos, &mtx, &m_laserOriginPosition, &mtx );}