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.

feat(gameengine): orders on fogged buildings go through

Olcay Seyganb00644539676
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20aa321a6..879714e79 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -177,6 +177,7 @@ found and fixed — EA's own, not port damage.**
- A guarding unit no longer fights itself between returning to post and shooting back.
- Engineers can clear mines and booby traps they cannot see.
- A helicopter no longer boards a transport from the air.
+- A building in the fog takes orders. Send infantry into a fogged garrison, a Ranger at a fogged oil derrick or a hacker at a fogged supply center and they go, where the click used to turn into a plain move to the spot. What decides whether the job still works is what they find when they get there: if the building was taken or filled up while you were not looking, they stop at the door. Ground you have never seen stays out of reach.
- A computer player's reinforcement catches up with the team it joined. A unit sent to a team already walking a waypoint path took the team's orders without the path itself, which crashed the match; the crash was stopped by leaving the newcomer standing where it spawned, and now it picks up the route from wherever the team has got to. Found and fixed by T0T0W.
- Select a big army, right click once, and all of it goes. In a crowd, units step aside to let a neighbour past, and a unit that stepped aside at the moment it was working out its route forgot the order and stood where it was. Out of 120 units sent across a small map, 7 were left behind, and the bigger the selection the more of them stayed. Now 200 out of 200 get there. Clicking on a building did the same thing to the whole group: there was no open ground right under the cursor, so nobody was given a place to stand. The group now stands around the building.
- The whole unit limit moves on one click. The lobby allows 840 units in a match, and the game could only keep 512 of them waiting for a route at once: sent across the map together, 329 of 841 never took a step, then or ever. All 840 go now, whether one player owns them or two armies of 420 are crossing through each other, and the game never falls behind: the click itself costs 13 milliseconds, and no moment of the march took longer than 33, the time the game has for each step of the battle. With all 840 on screen the picture averages 30 frames a second on the new renderer and 37 on the old one, 2.7 milliseconds quicker than before because a crowd of infantry now redraws its shadows' poses in turns instead of every soldier every frame.
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ActionManager.h b/GeneralsMD/Code/GameEngine/Include/Common/ActionManager.h
index 5f7237ee7..7b5d72503 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/ActionManager.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/ActionManager.h
@@ -61,7 +61,7 @@ enum CanEnterType
//-------------------------------------------------------------------------------------------------
/** Does what the asking player can see of a target stop them ordering something done to it? */
//-------------------------------------------------------------------------------------------------
-extern Bool ActionManager_shroudHidesTarget( Bool humanSource, Bool fromScript, Bool targetFoggedOrWorse,
+extern Bool ActionManager_shroudHidesTarget( Bool humanSource, Bool fromScript, Bool targetShrouded,
Bool ownPlacementSilhouette );
class ActionManager : public SubsystemInterface
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp
index a6eecdc1a..18d542568 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp
@@ -110,7 +110,9 @@ static Bool isObjectShroudedForAction ( const Object *source, const Object *targ
// the asking player is human
// the asking impetus is not from a script
- // and the target object is Fogged or worse
+ // and the target object is Shrouded. Fog alone does not stop the order: what the player last saw
+ // there is what they click on, and whether the enter, capture or hack still works is decided when
+ // the unit arrives and can see it.
if( source && target && source->getControllingPlayer() )
{
@@ -126,7 +128,7 @@ static Bool isObjectShroudedForAction ( const Object *source, const Object *targ
return ActionManager_shroudHidesTarget( source->getControllingPlayer()->getPlayerType() == PLAYER_HUMAN,
commandSource == CMD_FROM_SCRIPT,
- target->getShroudedStatus( source->getControllingPlayer()->getPlayerIndex() ) >= OBJECTSHROUD_FOGGED,
+ target->getShroudedStatus( source->getControllingPlayer()->getPlayerIndex() ) == OBJECTSHROUD_SHROUDED,
ownPlacementSilhouette );
}
@@ -135,13 +137,13 @@ static Bool isObjectShroudedForAction ( const Object *source, const Object *targ
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
-Bool ActionManager_shroudHidesTarget( Bool humanSource, Bool fromScript, Bool targetFoggedOrWorse,
+Bool ActionManager_shroudHidesTarget( Bool humanSource, Bool fromScript, Bool targetShrouded,
Bool ownPlacementSilhouette )
{
if( ownPlacementSilhouette )
return FALSE;
- return humanSource && !fromScript && targetFoggedOrWorse;
+ return humanSource && !fromScript && targetShrouded;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index f82aec640..614c9d80a 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -6650,15 +6650,16 @@ TEST(the_stop_key_cancels_a_building_that_is_still_going_up)
CHECK( Command_stopMeansCancelConstruction( 0, FALSE, FALSE ) == FALSE ); // nothing selected
}
-/** The plan sits in fog on its owner's screen on purpose, and the fog gate on orders would then
- refuse every click on it: no build cursor, no resume, nothing but selection. A player's own
+/** A player's own plan can sit in shroud on its owner's screen, and the shroud gate on orders would
+ then refuse every click on it: no build cursor, no resume, nothing but selection. A player's own
plan is never hidden from that player's own builders. Everything else the gate does is
- untouched - an enemy in fog is still out of reach, the AI and scripts still ignore the gate
- entirely. */
-TEST(the_fog_never_hides_your_own_plan_from_your_own_builder)
+ untouched - anything else in shroud is still out of reach, the AI and scripts still ignore the
+ gate entirely. Fog is not shroud and never reaches the gate: a fogged building can be entered,
+ captured or docked at, and the unit finds out on arrival whether it still can. */
+TEST(the_shroud_never_hides_your_own_plan_from_your_own_builder)
{
CHECK( ActionManager_shroudHidesTarget( TRUE, FALSE, TRUE, TRUE ) == FALSE ); // your own plan
- CHECK( ActionManager_shroudHidesTarget( TRUE, FALSE, TRUE, FALSE ) == TRUE ); // anything else fogged
+ CHECK( ActionManager_shroudHidesTarget( TRUE, FALSE, TRUE, FALSE ) == TRUE ); // anything else shrouded
CHECK( ActionManager_shroudHidesTarget( TRUE, TRUE, TRUE, FALSE ) == FALSE ); // from a script
CHECK( ActionManager_shroudHidesTarget( FALSE, FALSE, TRUE, FALSE ) == FALSE ); // asked by the AI