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
refactor(gameclient): take the draw's shroud status at the sync point
Olcay Seygan5530fff7ab31
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.hindex becd68413..3a2054416 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h@@ -474,6 +474,14 @@ public:void setShroudClearFrame( UnsignedInt frame ) { m_shroudClearFrame = frame; }UnsignedInt getShroudClearFrame( void ) { return m_shroudClearFrame; }++ /** LOGIC-THREAD.md phase 3: what the draw asks of the shroud, taken by GameClient::update's drawable+ * walk, at the sync point, for the player whose fog is drawn: the object's status, or for a drawable+ * with no object the status of the object its DrawableInfo names (a prison's inmates). The draw+ * calls no getShroudedStatus, which fills the partition's cache and can take a ghost snapshot. */+ void setShroudForDraw( ObjectShroudStatus status, Bool objectDead ) { m_shroudForDraw = status; m_objectDeadForDraw = objectDead; }+ ObjectShroudStatus getShroudForDraw( void ) const { return m_shroudForDraw; }+ Bool isObjectDeadForDraw( void ) const { return m_objectDeadForDraw; }void setShadowsEnabled(Bool enable);Bool getShadowsEnabled() const { return BitTest(m_status, DRAWABLE_STATUS_SHADOWS); }@@ -797,6 +805,9 @@ private:UnsignedInt m_timeToFade; ///< how slowly am I fadingUnsignedInt m_shroudClearFrame; ///< Last frame the local player saw this drawable "OBJECTSHROUD_CLEAR"+ ObjectShroudStatus m_shroudForDraw; ///< see setShroudForDraw+ Bool m_objectDeadForDraw; ///< see setShroudForDraw+DrawableLocoInfo* m_locoInfo; // lazily allocatedDynamicAudioEventRTS* m_ambientSound; ///< sound module for ambient sound (lazily allocated)diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex fd55cec54..99ac6fbb7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -614,6 +614,8 @@ Drawable::Drawable( const ThingTemplate *thingTemplate, DrawableStatus statusBitm_timeToFade = 0;m_shroudClearFrame = 0;+ m_shroudForDraw = OBJECTSHROUD_CLEAR;+ m_objectDeadForDraw = FALSE;for (i = 0; i < NUM_DRAWABLE_MODULE_TYPES; ++i)m_modules[i] = NULL;@@ -4471,7 +4473,7 @@ void Drawable::drawSupplyCash( const IRegion2D *healthBarRegion )}// shrouded ground keeps its secrets: what was there when you last looked is not news- if( obj->getShroudedStatus( TheObserverCamera.getShroudPlayerIndex() ) != OBJECTSHROUD_CLEAR )+ if( getShroudForDraw() != OBJECTSHROUD_CLEAR )return;// only a SupplyWarehouseDockUpdate answers getSupplyCashValue with cash, so this finds onediff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cppindex 742b22cb4..ab6c1f464 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp@@ -903,6 +903,29 @@ void GameClient::update( void )}}+ // LOGIC-THREAD.md phase 3: what the draw below asks of the shroud, asked here, on every pass and+ // frozen time included, as the draw asked it. The walk above has filled the cache for this player,+ // so this reads it; the draw no longer calls into the partition beside a tick.+ for( Drawable *draw = m_drawableList; draw; draw = draw->getNextDrawable() )+ {+ const Object *object = draw->getObject();+ if( object )+ {+ draw->setShroudForDraw( object->getShroudedStatus( localPlayerIndex ), object->isEffectivelyDead() );+ continue;+ }+ //Hack for prison camps which contain enemy prisoner drawables: another object holds the shroud+ ObjectShroudStatus status = OBJECTSHROUD_CLEAR;+ const ObjectID shroudObjectID = draw->getDrawableInfo()->m_shroudStatusObjectID;+ if( shroudObjectID != INVALID_ID )+ {+ const Object *shroudObject = TheGameLogic->findObjectByID( shroudObjectID );+ if( shroudObject )+ status = shroudObject->getShroudedStatus( localPlayerIndex );+ }+ draw->setShroudForDraw( status, FALSE );+ }+// update all particle systemsif( !freezeTime ){diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cppindex e83d8e769..db8c3a178 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp@@ -762,16 +762,18 @@ void RTS3DScene::renderOneObject(RenderInfoClass &rinfo, RenderObjClass *robj, Iambient.Add(ambient, *drawAmbient, &ambient);#endifobj = draw->getObject();+ // the shroud as GameClient::update's pass asked it for this player, ahead of the draw+ // (LOGIC-THREAD.md phase 3: the draw does not call into the partition)if (obj) {- ss = obj->getShroudedStatus(localPlayerIndex);- // For objects like planes, that pop out of the shroud, fire, then head back,- // we keep drawing them for 2 seconds after they return to the fogged area,+ ss = draw->getShroudForDraw();+ // For objects like planes, that pop out of the shroud, fire, then head back,+ // we keep drawing them for 2 seconds after they return to the fogged area,// so the player can see them and missiles chasing them. jba.if (ss == OBJECTSHROUD_CLEAR) {draw->setShroudClearFrame(TheGameLogic->getFrame());} else if (ss >= OBJECTSHROUD_FOGGED && draw->getShroudClearFrame()!=0) {UnsignedInt limit = 2*LOGICFRAMES_PER_SECOND;- if (obj->isEffectivelyDead()) {+ if (draw->isObjectDeadForDraw()) {limit += 3*LOGICFRAMES_PER_SECOND;}if (TheGameLogic->getFrame() < limit + draw->getShroudClearFrame()) {@@ -779,19 +781,13 @@ void RTS3DScene::renderOneObject(RenderInfoClass &rinfo, RenderObjClass *robj, Iss = OBJECTSHROUD_PARTIAL_CLEAR;}}- if (!robj->Peek_Scene())- return; //this object was removed by the getShroudedStatus() call.}else{ //drawable with no object so no way to know if it's shrouded.- ss = OBJECTSHROUD_CLEAR; //assume not shrouded/fogged.- //Check to see if there is another unrelated object which controls the shroud status- //(Hack for prison camps which contain enemy prisoner drawables)- if (drawInfo->m_shroudStatusObjectID != INVALID_ID)- { Object *shroudObject=TheGameLogic->findObjectByID(drawInfo->m_shroudStatusObjectID);- if (shroudObject && shroudObject->getShroudedStatus(localPlayerIndex) >= OBJECTSHROUD_FOGGED)- ss = OBJECTSHROUD_SHROUDED; //we will assume that drawables without objects are 'particle' like and therefore don't need drawing if fogged/shrouded.- }+ //Unless another unrelated object controls the shroud status+ //(Hack for prison camps which contain enemy prisoner drawables): we will assume that drawables+ //without objects are 'particle' like and therefore don't need drawing if fogged/shrouded.+ ss = draw->getShroudForDraw() >= OBJECTSHROUD_FOGGED ? OBJECTSHROUD_SHROUDED : OBJECTSHROUD_CLEAR;}if (draw->isKindOf(KINDOF_INFANTRY))diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cppindex 799977c03..8c3b446ea 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp@@ -1581,12 +1581,12 @@ static void drawablePostDraw( Drawable *draw, void *userData )if (CinemaDirector_hidesHud() && !TheGlobalData->m_directorRecord)return;+ // the shroud as GameClient::update's pass asked it, ahead of the draw (LOGIC-THREAD.md phase 3)Object* obj = draw->getObject();- Int localPlayerIndex = ThePlayerList ? TheObserverCamera.getShroudPlayerIndex() : 0;#if defined(_DEBUG) || defined(_INTERNAL)- ObjectShroudStatus ss = (!obj || !TheGlobalData->m_shroudOn) ? OBJECTSHROUD_CLEAR : obj->getShroudedStatus(localPlayerIndex);+ ObjectShroudStatus ss = (!obj || !TheGlobalData->m_shroudOn) ? OBJECTSHROUD_CLEAR : draw->getShroudForDraw();#else- ObjectShroudStatus ss = (!obj) ? OBJECTSHROUD_CLEAR : obj->getShroudedStatus(localPlayerIndex);+ ObjectShroudStatus ss = (!obj) ? OBJECTSHROUD_CLEAR : draw->getShroudForDraw();#endifif (ss > OBJECTSHROUD_PARTIAL_CLEAR)return;