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): start the build where the builder reaches the site

Olcay Seyganc20a7b4336df
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 451bc8042..943b35476 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -120,6 +120,7 @@ found and fixed — EA's own, not port damage.**
- A plan opens no fog of its own, and your opponent never sees it.
- Your units walk straight over a plan — nothing solid is there until the builder starts work.
- The plan turns solid the instant the first work goes in, so no building goes up inside its own ghost.
+- The builder starts work from where it reaches the site instead of shuffling into place first.
- The stop button prints its key on it, like the build buttons do.
## Bonuses that come and go when they should
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp
index bcb68529f..2e5a9913c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp
@@ -510,11 +510,26 @@ StateReturnType DozerActionDoActionState::update( void )
if( dozerAI->getBuildSubTask() == DOZER_SELECT_BUILD_DOCK_LOCATION )
{
const Coord3D *dockLocation = dozerAI->getDockPoint( m_task, DOZER_DOCK_POINT_ACTION );
- if( dockLocation )
+
+ //
+ // The action dock point is the same spot the builder was just sent to (see newTask),
+ // so ordering the walk again only bought a second approach and a wait for the move
+ // to settle into idle - the builder stood at the site doing nothing while the plan
+ // sat at zero percent. Standing there already means it can start from where it is.
+ //
+ if( dockLocation == NULL || dozerHasArrivedAt( dozer, dockLocation ) )
+ {
+ dozerAI->setBuildSubTask( DOZER_DO_BUILD_AT_DOCK );
+ dozerAI->startBuildingSound( goalObject->getTemplate()->getPerUnitSound( "UnderConstruction" ),
+ goalObject->getID() );
+ }
+ else
+ {
ai->aiMoveToPosition( dockLocation, CMD_FROM_AI );
- // we're now moving to the dock location
- dozerAI->setBuildSubTask( DOZER_MOVING_TO_BUILD_DOCK_LOCATION );
+ // we're now moving to the dock location
+ dozerAI->setBuildSubTask( DOZER_MOVING_TO_BUILD_DOCK_LOCATION );
+ }
} // end if