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(gameengine): hide an enemy's planned structure from sight and fog
Olcay Seygan76b73e3d4b6d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d3d68e71e..7a0da2630 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -254,7 +254,9 @@ found and fixed — EA's own, not port damage.**- Click a plan, or press Stop, to cancel it and take the money back.- Cancelling a plan is silent — nothing was built, so nothing explodes.- Ground your units have walked stays buildable after they leave it.-- A plan opens no fog of its own, and your opponent never sees it.+- A plan opens no fog of its own, and your opponent never sees it. Not with a unit parked right next+ to the site, and not as a leftover outline in the fog after that unit walks away. Both used to show+ an AI's whole base layout before its first worker arrived.- And nothing shoots at one. A plan is invisible to the other side, so a tank that stopped andopened fire on empty ground was telling that player where your base was going up before a singlewall existed. The first work a builder puts in ends this and the site is a target like any other.diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.hindex 16976e76c..7de6cb1c9 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h@@ -183,6 +183,9 @@ extern Bool Object_isAttackableStructure( Bool underConstruction, Real construct///< does this object count as something its player still has, for defeat and "team destroyed"?extern Bool Object_keepsOwnerAlive( Bool underConstruction, Real constructionPercent );+///< is this a plan a viewer on that footing with its owner must not see, live or remembered in the fog?+extern Bool Object_isPlanHiddenFrom( Bool underConstruction, Real constructionPercent, Relationship viewerToOwner );+class Object : public Thing, public Snapshot{diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex 560fdc0d7..dc910cc29 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -5456,6 +5456,16 @@ Bool Object_keepsOwnerAlive( Bool underConstruction, Real constructionPercent )return !Object_isAwaitingBuilder( underConstruction, constructionPercent );}+//-------------------------------------------------------------------------------------------------+/** Clearing no shroud of its own kept a plan out of fog only. An enemy whose units already had sight+ * of the site saw the silhouette go down, and once they looked away the fog kept a snapshot of it,+ * so a base could be read off the map before a builder arrived. Allies and observers still see it. */+//-------------------------------------------------------------------------------------------------+Bool Object_isPlanHiddenFrom( Bool underConstruction, Real constructionPercent, Relationship viewerToOwner )+{+ return viewerToOwner == ENEMIES && Object_isAwaitingBuilder( underConstruction, constructionPercent );+}+Real Object::getShroudClearingRange() const{Real shroudClearingRange = Object_shroudClearingRange( m_shroudClearingRange,diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cppindex 76be16de7..df1f10674 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp@@ -1639,6 +1639,13 @@ ObjectShroudStatus PartitionData::getShroudedStatus(Int playerIndex)return m_shroudedness[playerIndex];}+ // answered before the cache, so no snapshot is taken and the site is not marked as seen: the+ // building that goes up there later is news to this player like any other+ if (m_object && Object_isPlanHiddenFrom(m_object->testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION),+ m_object->getConstructionPercent(),+ ThePlayerList->getNthPlayer(playerIndex)->getRelationship(m_object->getTeam())))+ return OBJECTSHROUD_SHROUDED;+#ifndef DISABLE_INVALID_PREVENTIONif (m_shroudedness[playerIndex] == OBJECTSHROUD_INVALID || m_shroudedness[playerIndex] == OBJECTSHROUD_INVALID_BUT_PREVIOUS_VALID){diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 7a7a09be0..e5d446a3a 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -6494,6 +6494,21 @@ TEST(your_own_plan_is_drawn_through_the_fog_that_hides_everything_else)CHECK( GameClient_hiddenByShroud( OBJECTSHROUD_PARTIAL_CLEAR, FALSE ) == FALSE );}+/** Fog was the only thing hiding an enemy's plan, so a unit already looking at the site watched it go+ down and the fog remembered it afterwards. An enemy is shown nothing until the first percent of+ work; allies and observers, who are never enemies, see the plan as before. */+TEST(an_enemy_plan_is_hidden_even_where_the_viewer_has_sight)+{+ CHECK( Object_isPlanHiddenFrom( TRUE, 0.0f, ENEMIES ) == TRUE );++ CHECK( Object_isPlanHiddenFrom( TRUE, 0.0f, ALLIES ) == FALSE );+ CHECK( Object_isPlanHiddenFrom( TRUE, 0.0f, NEUTRAL ) == FALSE );++ // started or finished, it is a building the enemy is entitled to see+ CHECK( Object_isPlanHiddenFrom( TRUE, 0.1f, ENEMIES ) == FALSE );+ CHECK( Object_isPlanHiddenFrom( FALSE, CONSTRUCTION_COMPLETE, ENEMIES ) == FALSE );+}+/** There is nothing to stop about a building that is still going up, so the stop key calls it offinstead - the same cancel, refund and all, that the command bar button on that structure does.One structure of your own only: a mixed selection or anything already finished still means