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
feat(gameclient): ctrl flips grid placement while placing a building
Olcay Seyganc88ed71fa723
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3cca15b57..4dde2a79c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -32,6 +32,7 @@ found and fixed — EA's own, not port damage.**- Point at the attack, hold position or move key and a card says what it does, in English or Turkish. Those three are painted onto the grid rather than given to a unit, so the game had no card for them and showed nothing. The card stands on top of the command bar like every other button's.- HUD Size grows the console from its middle, and on a narrow screen it stops at the size that still fits.- The grid under a building you are placing is fainter and its lines thinner, and the red squares where nothing can stand are lighter, so the ground under them shows through. Untick grid placement on the Controls page and the lines go altogether.+- Hold Ctrl while placing a building and grid placement flips for as long as the key is down. With the box unticked the building snaps to the grid and the lines come up, so one flush row is a held key away; with it ticked you get a free hand for the odd building that has to sit between two squares. Classic places by its own rules and ignores Ctrl here.- Your general's promotion screen opens in the middle of the screen, in the Classic interface as well, instead of hanging from the top edge. The battlefield dims behind it, and a click anywhere off the screen closes it without selecting or ordering anything underneath.## Groups attack-move at their own speed@@ -1257,7 +1258,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- Taking over another base no longer squeezes the picture into the top four fifths of the screen.- A match opens with the camera 300 over the ground, close enough to read your base, in Classic and Reforged alike. Start Zoomed Out on Options > Controls opens it as far out as the wheel goes instead; it starts unticked.- Hold Ctrl and roll the wheel to turn a building before placing it.-- Buildings snap to the pathfinder's own grid (`GridBuildPlacement = No` for the old way).+- Buildings can snap to the grid the game itself plans movement on. Tick grid placement on the Controls page; it starts unticked.- The grid under a structure is drawn, with blocked squares crossed out.- Snapping now uses the true cell offset and the building's concrete apron.- A building faces the way you drag it, read at the moment you release.diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex cb5119e12..8b5c8c06a 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -689,6 +689,8 @@ public: // ********************************************************************* build grid, so that structures put down by eye line up with each other and with the cells* the pathfinder actually reasons about. */virtual void snapPlacementToGrid( Coord3D *world, const ThingTemplate *what, Real angle ) const;+ /// is that snap on right now: the option, turned the other way while ctrl is held (not in Classic)+ Bool gridPlacementOn( void ) const;/** Where the pathfinder's cell boundaries actually are. It files a world position under* floor( (v + 0.5) / PATHFIND_CELL_SIZE ) (see Pathfinder::internal_classifyObjectFootprint),diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex fc02cd518..c683bf0a4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -7770,7 +7770,7 @@ static void placementHalfExtents( const ThingTemplate *what, Real angle, Real *hvoid InGameUI::snapPlacementToGrid( Coord3D *world, const ThingTemplate *what, Real angle ) const{- if( world == NULL || what == NULL || TheGlobalData->m_gridBuildPlacement == FALSE )+ if( world == NULL || what == NULL || gridPlacementOn() == FALSE )return;Real halfX, halfY;@@ -7781,6 +7781,18 @@ void InGameUI::snapPlacementToGrid( Coord3D *world, const ThingTemplate *what, R} // end snapPlacementToGrid+//-------------------------------------------------------------------------------------------------+/** Ctrl held while placing turns GridBuildPlacement the other way for as long as it is down: off,+ * it snaps; on, it places freely. The ghost, the lines and the order the click sends all ask+ * this, so they cannot disagree. Classic keeps the option as the only switch, as it does with+ * the shift and alt rows. */+//-------------------------------------------------------------------------------------------------+Bool InGameUI::gridPlacementOn( void ) const+{+ const Bool flip = TheKeyboard && !TheGlobalData->isClassicUI() && TheKeyboard->isCtrl();+ return ( TheGlobalData->m_gridBuildPlacement != FALSE ) != flip;+}+//-------------------------------------------------------------------------------------------------/** Shift or alt held on the drag: a wall already tiles from any drag, so it is left to do that.* Everything that asks this wants to know whether the drag lays pieces instead of aiming one, anddiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cppindex cd93196e8..1ff730acb 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp@@ -970,7 +970,7 @@ void W3DInGameUI::drawBuildGrid( void )return;// the grid you see is the grid you snap to: with the snap off the lines would mean nothing, but// the cells nothing can stand on still do- const Bool drawLines = TheGlobalData->m_gridBuildPlacement;+ const Bool drawLines = gridPlacementOn();if( m_placeIcon == NULL || m_placeIcon[ 0 ] == NULL )return;if( TheTerrainLogic == NULL || TheAI == NULL )