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): let builders and half-built structures see

Olcay Seygan0ed1a41fb9ee
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 52c44d5d8..72ad39fac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -290,6 +290,7 @@ found and fixed — EA's own, not port damage.**
- Cancelling a placement no longer deselects the builder.
- The building on your cursor shows where its units will come out.
- An ordered building stands as a see-through plan until a worker starts it.
+- A building going up lifts the fog around it the moment work starts. It used to see no further than its own walls until the last brick was in, so a base built out into the fog stood blind for the whole build and the worker on the site saw more than the site did.
- 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.
@@ -345,6 +346,7 @@ found and fixed — EA's own, not port damage.**
- Taking over a defeated ally's base no longer starts his research again from scratch. A player upgrade is bought once for the whole player, and the buildings you inherit were left paying for a second copy of what you already had.
- 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.
+- Workers and bulldozers can see again. Each one carries a mine-clearing tool a few feet long, and the rule above took it for a gun, so a builder saw no further than the end of its own blade and walked into the fog blind. They keep their full sight now, armed or not.
- 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.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
index 253486888..0bd83b016 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
@@ -171,8 +171,7 @@ extern Bool Object_constructionFootprintGoesDown( Bool underConstruction, Real w
Real nowPercent );
///< how far a structure clears shroud, given where it is in its construction
-extern Real Object_shroudClearingRange( Real ownRange, Bool underConstruction, Real constructionPercent,
- Real boundingCircleRadius );
+extern Real Object_shroudClearingRange( Real ownRange, Bool underConstruction, Real constructionPercent );
///< how far an armed unit clears shroud: no further than half as far again as its longest weapon reaches
extern Real Object_armedShroudClearingRange( Real clearingRange, Real largestWeaponRange );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
index cc61f801f..c40852abe 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
@@ -5189,9 +5189,11 @@ void Object::look()
// Otherwise we'd just have enclosingContainer control looking which is the 'correct' answer.
// applied here and not in getShroudClearingRange, so the sight bonuses that multiply the
- // stored range and later divide it back out never bake the weapon cap into it
+ // stored range and later divide it back out never bake the weapon cap into it. A dozer or
+ // a worker carries a mine-clearing weapon a few feet long, and capped by it the builder
+ // was blind: it keeps its template's sight
Real shroudClearingRange = getShroudClearingRange();
- if( !isKindOf( KINDOF_STRUCTURE ) )
+ if( !isKindOf( KINDOF_STRUCTURE ) && !isKindOf( KINDOF_DOZER ) )
shroudClearingRange = Object_armedShroudClearingRange( shroudClearingRange, getLargestWeaponRange() );
if( shroudClearingRange > 0.0f )
@@ -5404,8 +5406,7 @@ void Object::setVisionRange( Real newVisionRange )
/** A structure that has only been planned - it stands on the map at zero percent and its builder is
* still walking over - is not there yet as far as sight is concerned, so it opens no shroud: a base
* can be laid out into fog without the plan itself scouting the ground it sits on. Once the
- * builder arrives and the first percent goes in, EA's rule takes over and the structure sees
- * itself and no further. */
+ * builder arrives and the first percent goes in, the structure sees its full range. */
//-------------------------------------------------------------------------------------------------
Bool Object_isAwaitingBuilder( Bool underConstruction, Real constructionPercent )
{
@@ -5426,15 +5427,15 @@ Bool Object_constructionFootprintGoesDown( Bool underConstruction, Real wasPerce
}
//-------------------------------------------------------------------------------------------------
-Real Object_shroudClearingRange( Real ownRange, Bool underConstruction, Real constructionPercent,
- Real boundingCircleRadius )
+/** EA held a structure going up to its own footprint, so a base built out into the fog stood blind
+ * until the last percent went in and a builder on the site saw further than the site did. Once
+ * the work has started it sees what it will see finished. */
+//-------------------------------------------------------------------------------------------------
+Real Object_shroudClearingRange( Real ownRange, Bool underConstruction, Real constructionPercent )
{
if( Object_isAwaitingBuilder( underConstruction, constructionPercent ) )
return 0.0f;
- if( underConstruction )
- return boundingCircleRadius;
-
return ownRange;
}
@@ -5496,8 +5497,7 @@ Real Object::getShroudClearingRange() const
{
Real shroudClearingRange = Object_shroudClearingRange( m_shroudClearingRange,
getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ),
- m_constructionPercent,
- getGeometryInfo().getBoundingCircleRadius() );
+ m_constructionPercent );
#if defined(_DEBUG) || defined(_INTERNAL)
if (TheGlobalData->m_debugVisibility)
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index f8886f57c..56563abf3 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -6453,21 +6453,18 @@ TEST(a_base_can_be_planned_into_fog_but_not_into_shroud)
/** A plan is not a scout. A structure that has been placed but not started opens no shroud at all,
so drawing a base out into the fog cannot be used to see what is standing there. Once the
- builder arrives EA's own rule takes over - the structure sees itself and no further - and a
- finished building goes back to the sight its template gives it. */
+ builder arrives the structure sees as far as its template says, finished or not. */
TEST(a_planned_structure_opens_no_shroud_until_the_work_starts)
{
const Real templateRange = 300.0f;
- const Real boundingRadius = 40.0f;
- CHECK_NEAR( Object_shroudClearingRange( templateRange, TRUE, 0.0f, boundingRadius ), 0.0f, 0.0001f );
- CHECK_NEAR( Object_shroudClearingRange( templateRange, TRUE, 0.1f, boundingRadius ), boundingRadius, 0.0001f );
- CHECK_NEAR( Object_shroudClearingRange( templateRange, TRUE, 99.9f, boundingRadius ), boundingRadius, 0.0001f );
- CHECK_NEAR( Object_shroudClearingRange( templateRange, FALSE, CONSTRUCTION_COMPLETE, boundingRadius ),
- templateRange, 0.0001f );
+ CHECK_NEAR( Object_shroudClearingRange( templateRange, TRUE, 0.0f ), 0.0f, 0.0001f );
+ CHECK_NEAR( Object_shroudClearingRange( templateRange, TRUE, 0.1f ), templateRange, 0.0001f );
+ CHECK_NEAR( Object_shroudClearingRange( templateRange, TRUE, 99.9f ), templateRange, 0.0001f );
+ CHECK_NEAR( Object_shroudClearingRange( templateRange, FALSE, CONSTRUCTION_COMPLETE ), templateRange, 0.0001f );
// a structure that clears no shroud at all is not the same as one with no vision by template
- CHECK_NEAR( Object_shroudClearingRange( 0.0f, FALSE, CONSTRUCTION_COMPLETE, boundingRadius ), 0.0f, 0.0001f );
+ CHECK_NEAR( Object_shroudClearingRange( 0.0f, FALSE, CONSTRUCTION_COMPLETE ), 0.0f, 0.0001f );
}
/** A unit sees half as far again as its longest weapon reaches. Artillery that outranges its own sight