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(gameengine): see bridge decks, let reveal abilities see past cover

Olcay Seygand81e095eae9b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fc1be97c1..c248c82be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -332,6 +332,8 @@ found and fixed — EA's own, not port damage.**
- A tank drives out the moment it is paid for. The factory doors only began opening once the vehicle was already finished, and it stood inside waiting for them, so every single unit cost its build time plus the whole door animation on top - on every tank, all game. The doors now start moving during the last seconds of the build and are open on the frame the unit is done. And they stay open while there is another vehicle behind him, however long that takes: a factory working through a queue keeps its doors up and shuts them when the queue runs out, instead of dropping and hauling them back for every unit. That was worth watching in its own right - there is no artwork for a door that changes its mind partway, so a door caught mid-close and pulled back open snapped wide in a single frame.
- A unit lifts the fog only half as far again as its guns reach: enough to spot what it is about to fight, not enough to scout. A rifleman used to see well past the range of his rifle, so any cheap soldier was a scout. Artillery that outshoots its own eyes still needs a spotter, and units with no weapon at all, like bulldozers and supply trucks, keep the sight they had. Buildings are unchanged.
- Hills and buildings block sight. A tank at the foot of a ridge used to see straight through it to the far side, and a squad in a city saw through every block around it. Now the fog stays on whatever a ridge, a building or a tree hides, yours, the enemy's or a civilian's, and a unit on high ground looks down over everything below it. Aircraft fly above it all and see past. Soldiers garrisoned in a building still see out of it; its own walls do not blind them.
+- A bridge is ground you can see, not a wall. Sight judged a bridge by the valley floor under it, so a bridge over a gorge sat hidden behind the gorge's own edge and a tank on the bank could not see the deck it was about to cross. A standing deck counts at its own height now; a bridge knocked down to rubble goes back to the ground beneath it.
+- The spy satellite, the radar van scan and the spy drone see everything in their circle again. They were blocked by hills and buildings like a tank on the ground, so a scan dropped on an enemy base came back with holes behind every building in it.
- High ground pays. A tank on a ridge now shoots, sees and picks its targets further down the slope than it could on the flat: three steps of range for every step of height over its target, up to twice its usual reach. Firing uphill costs nothing, and aircraft get no bonus from flying. Defences count too, and the range ring you see while placing one bends outward wherever the ground falls away, so you can site a Gattling Cannon on a hill and see exactly what it covers.
- The five soldiers in an Overlord's battle bunker live through the Overlord's death again. A rule added in this build, that nobody gets out of a vehicle which is itself being carried, caught the bunker too, so all five died on the spot where they used to take half damage and climb out.
- Pro Rules hold for the nuke and the carpet bomb whoever fires them. The refusal stopped the recharge but not the missile: a computer player or a map script could launch a neutron missile the rules forbid, and because the timer never started, launch it again straight away.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
index ae1a1000a..cc61f801f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
@@ -5236,11 +5236,22 @@ void Object::look()
Coord3D eye = *getPosition();
eye.z += getGeometryInfo().getMaxHeightAbovePosition();
- // out to the furthest the high ground could carry it; each cell is cut back to its own height
m_partitionLastLook->m_where = eye;
m_partitionLastLook->m_forWhom = lookingMask;
- m_partitionLastLook->m_howFar = Weapon_elevatedRange( this, shroudClearingRange, -FLT_MAX );
- ThePartitionManager->doBlockedShroudReveal( m_partitionLastLook, this, shroudClearingRange );
+
+ // the spy satellite, the radar van scan, the spy drone and the superweapon pings are INERT:
+ // a reveal ability opens its whole circle, behind hills and buildings too
+ if( isKindOf( KINDOF_INERT ) )
+ {
+ m_partitionLastLook->m_howFar = shroudClearingRange;
+ ThePartitionManager->doShroudReveal( eye.x, eye.y, shroudClearingRange, lookingMask );
+ }
+ else
+ {
+ // out to the furthest the high ground could carry it; each cell is cut back to its own height
+ m_partitionLastLook->m_howFar = Weapon_elevatedRange( this, shroudClearingRange, -FLT_MAX );
+ ThePartitionManager->doBlockedShroudReveal( m_partitionLastLook, this, shroudClearingRange );
+ }
// DEBUG_LOG(( "A %s looks at %f, %f for %x at range %f\n",
// getTemplate()->getName().str(),
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
index 6543605a2..c8fae254b 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp
@@ -4304,12 +4304,43 @@ void PartitionManager::applyRecordedReveal( const SightingInfo *sighting, Bool r
}
//-----------------------------------------------------------------------------
-/** The top of whatever stands in a cell: the highest ground in it, or the roof of a building on it if
- that is higher. Trees and bushes that are objects count, a bridge does not (it is ground to walk
- on and to see across). A planned building nobody has started is not there yet. */
-static Real sightBlockingHeight( PartitionCell *cell, const Object *looker, const Object *lookerContainer )
+/** The highest standing bridge deck over a cell, or the cell's ground where no deck crosses it. The
+ deck is ground to walk on and to see: judged by the valley floor under it, a bridge over a gorge
+ hid behind the gorge's own edge. Sampled on a 3x3 grid, since a deck is not much wider than a
+ cell and can miss the middle of one it crosses. */
+static Real sightGroundHeight( PartitionCell *cell )
{
Real height = cell->getHiTerrain();
+ Real centerX, centerY;
+ cell->getCellCenterPos( centerX, centerY );
+ const Real halfCell = 0.5f * ThePartitionManager->getCellSize();
+
+ for( Bridge *bridge = TheTerrainLogic->getFirstBridge(); bridge; bridge = bridge->getNext() )
+ {
+ if( bridge->peekBridgeInfo()->curDamageState == BODY_RUBBLE )
+ continue;
+
+ for( Int sampleY = -1; sampleY <= 1; ++sampleY )
+ {
+ for( Int sampleX = -1; sampleX <= 1; ++sampleX )
+ {
+ Coord3D sample;
+ sample.set( centerX + sampleX * halfCell, centerY + sampleY * halfCell, 0.0f );
+ if( bridge->isPointOnBridge( &sample ) )
+ height = max( height, bridge->getBridgeHeight( &sample, NULL ) );
+ }
+ }
+ }
+ return height;
+}
+
+//-----------------------------------------------------------------------------
+/** The top of whatever stands in a cell: the highest ground or bridge deck in it, or the roof of a
+ building on it if that is higher. Trees and bushes that are objects count; the bridge object
+ itself does not, its deck is the ground. A planned building nobody has started is not there yet. */
+static Real sightBlockingHeight( PartitionCell *cell, const Object *looker, const Object *lookerContainer )
+{
+ Real height = sightGroundHeight( cell );
for( CellAndObjectIntersection *coi = cell->getFirstCoiInCell(); coi; coi = coi->getNextCoi() )
{
// a ghost object has no Object behind it