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): keep enemy defence reach and blind spots hidden
Olcay Seygan182f58a10382
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 05956719d..57f2a7871 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -478,8 +478,8 @@ found and fixed — EA's own, not port damage.**- A building you point at blocked ground slides to the nearest spot it fits, and lands there.- The pointer keeps its build cursor while you place, even passing over your own buildings.- GLA defences get a range ring while you site them.-- The ground a defence on your cursor can shoot into is painted red. It used to be the thin white guard circle, which read as the edge of a building's footprint more than as a field of fire; now it is a thin line in the owner's colour, and the line sits exactly where the game stops allowing the shot: the weapon's range measured from the edge of the building, not from its middle. While any building is on your cursor, or when you click a turret, every armed building you can see shows its reach as well, yours, your allies' and the enemy's, and one player's overlapping circles join into one outline, so the gap between two Patriot batteries is something you can see before you pay for the third. An enemy defence hidden under fog stays hidden.-- Inside that red area, the ground the defence cannot see is shaded. A Patriot battery, a Gattling Cannon or a Fire Base does not shoot through a building - the game refuses the shot when a solid structure stands between the gun and its target - so from where your cursor is, each building in range throws a shadow that starts at its near wall and runs out to the edge of the reach, a wedge that swings as you move the defence round the corner of your War Factory. Hills count as well. The game will not pick a target when the ground rises between the top of the gun and the top of a tank, so the far side of a ridge goes dark too, and a valley beyond it lights up again where the gun can see down into it. The shade lies on the ground as one piece and follows its slopes. A corner one of your turrets, or an ally's, already sees into is not a hole, so it stays bright: the shade is only what nothing of yours can shoot. A Stinger Site or a bunker gets no shade, because a building in the way does not stop them. Click a defence that is already standing and it shows the same shade from where it stands, its own and nobody else's, so the corner behind your War Factory is there to see after the turret is built too.+- The ground a defence on your cursor can shoot into is painted red. It used to be the thin white guard circle, which read as the edge of a building's footprint more than as a field of fire; now it is a thin line in the owner's colour, and the line sits exactly where the game stops allowing the shot: the weapon's range measured from the edge of the building, not from its middle. While any building is on your cursor, or when you click a turret, every armed building of yours and your allies' shows its reach as well, and one player's overlapping circles join into one outline, so the gap between two Patriot batteries is something you can see before you pay for the third. The enemy's defences draw nothing, not while you place a building and not when you click one of them: how far a Gattling Cannon reaches and which corner behind it is blind are things you learn by losing a tank there. An observer still sees every side's.+- Inside that red area, the ground the defence cannot see is shaded. A Patriot battery, a Gattling Cannon or a Fire Base does not shoot through a building - the game refuses the shot when a solid structure stands between the gun and its target - so from where your cursor is, each building in range throws a shadow that starts at its near wall and runs out to the edge of the reach, a wedge that swings as you move the defence round the corner of your War Factory. Hills count as well. The game will not pick a target when the ground rises between the top of the gun and the top of a tank, so the far side of a ridge goes dark too, and a valley beyond it lights up again where the gun can see down into it. The shade lies on the ground as one piece and follows its slopes. A corner one of your turrets, or an ally's, already sees into is not a hole, so it stays bright: the shade is only what nothing of yours can shoot. A Stinger Site or a bunker gets no shade, because a building in the way does not stop them. Click one of your defences, or an ally's, that is already standing and it shows the same shade from where it stands, its own and nobody else's, so the corner behind your War Factory is there to see after the turret is built too.- Clicking a turret in a base full of them no longer drags the game down. Every circle's outline was worked out again against every other circle on every frame, so with 120 Patriot batteries on the map one selected battery took the game from 94 frames a second to 53. The outlines are worked out once and kept until a building goes up, comes down or comes out of the fog: the same base now holds 83 with the battery selected against 84 with nothing selected.- Selecting a GLA supply stash no longer puts reach circles round every defence on the map. The stash spawns workers, a worker carries a weapon for clearing mines, and that was enough to count the stash as armed.- Two buildings can no longer be put down on the same spot online. A build order travels to the other players before anything appears on the ground, and every click made while it was in flight was answered by a map that still showed the square as empty - so a shift-held row on a bad connection came out as buildings standing inside each other. The ghost now knows about the orders you have already spent, and turns red over them or slides to the square beside; and the order itself is checked again where it lands, on every machine, after the first building is standing. A second one aimed at the same ground is refused there and costs you nothing.diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex e9f1fa10e..502dccb24 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -2068,6 +2068,15 @@ static Bool reachViewHits( const ReachView &view, Real x, Real y )return !view.blocked[ ray * view.rings + ring ];}+/// a structure whose reach and blind spots the local player is shown: their own, an ally's, or any to+/// an observer. An enemy defence keeps both to itself, so they are found out by losing units to it.+static Bool reachRevealedToLocal( const Object *obj )+{+ const Player *local = ThePlayerList->getLocalPlayer();+ return obj->getControllingPlayer() == local || local->isPlayerObserver()+ || local->getRelationship( obj->getTeam() ) == ALLIES;+}+//-------------------------------------------------------------------------------------------------/** Every structure on the map as the reach drawing sees it, gathered once a frame. A building going* up or coming down changes what a defence can see past, and one coming out of the fog changes which@@ -2081,7 +2090,7 @@ struct StructureKeyObjectID id;Coord3D position;const Player *owner;- Bool reachShown; ///< armed and not hidden from the local player, so its circle is drawn+ Bool reachShown; ///< armed, revealed to the local player and out of the fog, so its circle is drawnBool operator==( const StructureKey &other ) const{@@ -2113,7 +2122,7 @@ static void refreshStructureKeys( void )key.id = obj->getID();key.position = *obj->getPosition();key.owner = obj->getControllingPlayer();- key.reachShown = templateReach( obj->getTemplate() ) > 0.0f+ key.reachShown = templateReach( obj->getTemplate() ) > 0.0f && reachRevealedToLocal( obj )&& ( key.owner == local || obj->getShroudedStatus( local->getPlayerIndex() ) < OBJECTSHROUD_FOGGED );keys.push_back( key );}@@ -2242,13 +2251,12 @@ static const ReachView &guardView( const Object *obj )//-------------------------------------------------------------------------------------------------static void clearGuardedBlindSpots( ReachView &pending ){- const Player *local = ThePlayerList->getLocalPlayer();std::vector< const ReachView * > guards;for( size_t k = 0; k < theStructureKeys.size(); k++ ){const StructureKey &key = theStructureKeys[ k ];const Object *obj = TheGameLogic->findObjectByID( key.id );- if( key.owner != local && local->getRelationship( obj->getTeam() ) != ALLIES )+ if( !reachRevealedToLocal( obj ) )continue;const Real flatReach = templateReach( obj->getTemplate() );@@ -2307,7 +2315,7 @@ static const BlindSpotShade &selectedBlindSpotShade( const Object *obj )//-------------------------------------------------------------------------------------------------/** The ground a defence could not shoot into, darkened inside its reach: the one on the cursor while- * it is being sited, and every selected one.+ * it is being sited, and every selected one of the local player's or an ally's.** A defence that needs a line of sight - a Patriot battery, a Gattling Cannon, a Fire Base - does* not fire through a building, and cannot pick a target a hill hides from it. Both rules are the@@ -2349,7 +2357,7 @@ void InGameUI::drawBlindSpots( void )const Object *obj = (*it)->getObject();if( obj == NULL || !obj->isKindOf( KINDOF_STRUCTURE ) || templateReach( obj->getTemplate() ) <= 0.0f )continue;- if( !templateNeedsLineOfSight( obj->getTemplate() ) )+ if( !templateNeedsLineOfSight( obj->getTemplate() ) || !reachRevealedToLocal( obj ) )continue;refreshStructureKeys();@@ -2539,13 +2547,13 @@ static void drawReachSegment( const ReachSegment &segment, const Player *owner )//-------------------------------------------------------------------------------------------------/** While a structure is on the cursor, the reach of every armed building in sight: yours, your- * allies', the enemy's you can currently see, and the one on the cursor if it is armed.+ * allies', and the one on the cursor if it is armed. An enemy's is never drawn.** Each circle is exactly the distance a shot is allowed at: the weapon range the game tests with,* measured from the edge of the shooter's bounding circle, so from the centre it is that range* plus the bounding radius. Each is drawn in its owner's colour. Where one player's circles* overlap they are one area: the thin outline leaves out every stretch of a circle that runs inside- * another of the same player's, cutting it where the two cross. An enemy building under fog is+ * another of the same player's, cutting it where the two cross. An ally's building under fog is* skipped, so the circles tell nothing the map does not. *///-------------------------------------------------------------------------------------------------void InGameUI::drawPlacementReach( void )@@ -2558,7 +2566,8 @@ void InGameUI::drawPlacementReach( void )for( DrawableListCIt it = m_selectedDrawables.begin(); it != m_selectedDrawables.end() && !armedSelected; ++it ){const Object *obj = (*it)->getObject();- armedSelected = obj && obj->isKindOf( KINDOF_STRUCTURE ) && templateReach( obj->getTemplate() ) > 0.0f;+ armedSelected = obj && obj->isKindOf( KINDOF_STRUCTURE ) && templateReach( obj->getTemplate() ) > 0.0f+ && reachRevealedToLocal( obj );}if( m_pendingPlaceType == NULL && !armedSelected )return;