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): nudge blocked placement as a controls box, off
Olcay Seygan2ae15508ba9e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c79c47233..d46665a37 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1102,8 +1102,8 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- The tab you are on is lit in the same green as the group headings. The original drew it in dark grey on the black panel, which read as a button you could not press rather than the page you were looking at.- Accept sits in the bottom right corner with Cancel beside it, and Defaults stands alone on the far left, out of reach of a slip off Accept. The window is as tall as its busiest page and centred on the screen, instead of reaching from the top of the screen to the bottom with half of every page empty. The box that asks whether to keep a new resolution opens in the middle of the screen too, where it used to sit jammed in the top left corner.- Eight settings that used to need a text editor have a control now: window mode on display, antialiasing, the two glow settings, texture filtering and anisotropic samples on graphics, and who wears a health bar and which colours the players wear on gameplay.-- More are decided for you instead of asked about. Nudging a blocked building, the placement range ring, workers going back to supply, detailed build tooltips, the HUD overlay and archived replays are simply on - every one of them is the version of the game people were choosing anyway, and a page of six checkboxes nobody unticks is a page of six decisions nobody wanted to make. Middle-mouse panning left the screen too, and edge scrolling in a window is still yours by name in `Options.ini` if the default is wrong for your setup.-- Grid placement, 45 degree building rotation, snapping to nearby buildings and 45 degree camera steps are checkboxes on the Controls page in both Classic and Reforged, and every one starts unticked, the way 1.04 played. A setting you saved while they were on does not carry over: the boxes start empty once and remember what you pick after that. Snap to Nearby Buildings pulls a building put down a cell or so short of another one flush against its edge. With grid placement off a building goes down exactly where the cursor puts it, and the white grid lines under the ghost go with it. The red squares where nothing can be built still show, so you can see the rock before you click on it.+- More are decided for you instead of asked about. The placement range ring, workers going back to supply, detailed build tooltips, the HUD overlay and archived replays are simply on - every one of them is the version of the game people were choosing anyway, and a page of five checkboxes nobody unticks is a page of five decisions nobody wanted to make. Middle-mouse panning left the screen too, and edge scrolling in a window is still yours by name in `Options.ini` if the default is wrong for your setup.+- Grid placement, 45 degree building rotation, snapping to nearby buildings, nudging a blocked building and 45 degree camera steps are checkboxes on the Controls page in both Classic and Reforged, and every one starts unticked, the way 1.04 played. A setting you saved while they were on does not carry over: the boxes start empty once and remember what you pick after that. Snap to Nearby Buildings pulls a building put down a cell or so short of another one flush against its edge. Nudge Blocked Placement slides a building whose spot is taken by a rock or another building's footprint to the nearest place it fits, instead of turning it red under the cursor. With grid placement off a building goes down exactly where the cursor puts it, and the white grid lines under the ghost go with it. The red squares where nothing can be built still show, so you can see the rock before you click on it.- A page no longer says its own name twice. Every tab used to open onto a heading repeating the word already written on the button you just pressed, with a rule under it dividing nothing from nothing.- An open dropdown covers what is under it instead of the other way round. The list of resolutions grew downwards behind the labels below it, so half the entries were readable and half were words on top of words.- Every button, slider and checkbox is the artwork the game already had, down to the fonts and the hover colours.diff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wndindex 23cf45f2f..264287b71 100644--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd@@ -7559,6 +7559,53 @@ WINDOWIMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;ENDCHILD+ WINDOW+ WINDOWTYPE = CHECKBOX;+ SCREENRECT = UPPERLEFT: 288 370, BOTTOMRIGHT: 512 394, CREATIONRESOLUTION: 800 600;+ NAME = "OptionsMenu.wnd:CheckNudgeBuild";+ STATUS = ENABLED+IMAGE+BORDER;+ STYLE = CHECKBOX+MOUSETRACK;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;+ HEADERTEMPLATE = "MinorTitle";+ TOOLTIPTEXT = "TOOLTIP:NudgeBuild";+ TOOLTIPDELAY = -1;+ TEXT = "GUI:NudgeBuild";+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 186 255 12 255, HILITEBORDER: 0 0 0 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ END+ CHILDWINDOWWINDOWTYPE = STATICTEXT;SCREENRECT = UPPERLEFT: 530 150, BOTTOMRIGHT: 754 174, CREATIONRESOLUTION: 800 600;diff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wndindex ca8c0d11c..bc212c852 100644--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd@@ -7512,6 +7512,53 @@ WINDOWIMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;ENDCHILD+ WINDOW+ WINDOWTYPE = CHECKBOX;+ SCREENRECT = UPPERLEFT: 288 370, BOTTOMRIGHT: 512 394, CREATIONRESOLUTION: 800 600;+ NAME = "OptionsMenu.wnd:CheckNudgeBuild";+ STATUS = ENABLED+IMAGE+BORDER;+ STYLE = CHECKBOX+MOUSETRACK;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;+ HEADERTEMPLATE = "MinorTitle";+ TOOLTIPTEXT = "TOOLTIP:NudgeBuild";+ TOOLTIPDELAY = -1;+ TEXT = "GUI:NudgeBuild";+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 186 255 12 255, HILITEBORDER: 0 0 0 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ END+ CHILDWINDOWWINDOWTYPE = STATICTEXT;SCREENRECT = UPPERLEFT: 530 150, BOTTOMRIGHT: 754 174, CREATIONRESOLUTION: 800 600;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex 7126a2982..686abebc2 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -1141,8 +1141,9 @@ GlobalData::GlobalData()// controls that used to set them, and what is written here is what every game gets. GameData.ini// remains the way to change one, because the field table above still names it.//- // The snaps are the exception: the camera's and a building's 45 degree steps, grid placement and- // the snap to a neighbour's edge start off, ticked on Options > Controls by whoever wants them.+ // The snaps are the exception: the camera's and a building's 45 degree steps, grid placement, the+ // snap to a neighbour's edge, the nudge off a blocked spot and zoom to cursor start off, ticked on+ // Options > Controls by whoever wants them.//m_useCameraConstraints = TRUE;m_cameraBoundaryMargin = 200;@@ -1170,7 +1171,7 @@ GlobalData::GlobalData()m_snapBuildPlacementTo45 = FALSE;m_gridBuildPlacement = FALSE;m_snapBuildToNeighbour = FALSE;- m_nudgeBuildPlacement = TRUE;+ m_nudgeBuildPlacement = FALSE;m_moneyPerMinute = 0;m_buildPlacementOpacity = PLACEMENT_SILHOUETTE_OPACITY;m_buildPlacementShadows = TRUE;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cppindex 67cb89b98..ee29c1118 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp@@ -61,6 +61,7 @@ OPTION_BOOL_ACCESSORS( m_snapCameraRotateTo45 )OPTION_BOOL_ACCESSORS( m_gridBuildPlacement )OPTION_BOOL_ACCESSORS( m_snapBuildPlacementTo45 )OPTION_BOOL_ACCESSORS( m_snapBuildToNeighbour )+OPTION_BOOL_ACCESSORS( m_nudgeBuildPlacement )OPTION_BOOL_ACCESSORS( m_zoomToCursor )OPTION_BOOL_ACCESSORS( m_isometricCamera )OPTION_BOOL_ACCESSORS( m_smoothMotion )@@ -261,6 +262,13 @@ const OptionDef TheOptionCatalog[] =OPTION_BOOL, APPLY_LIVE, 0, 1,get_m_snapBuildToNeighbour, set_m_snapBuildToNeighbour },+ // InGameUI::nudgePlacementToLegal: a structure whose spot is blocked slides to the nearest one it+ // fits. A key of its own: NudgeBuildPlacement, the one it had before it was forced on, can still+ // be a "yes" in an Options.ini saved back then.+ { "BuildNudge", OPT_WND( "CheckNudgeBuild" ), "GUI:NudgeBuild",+ OPTION_BOOL, APPLY_LIVE, 0, 1,+ get_m_nudgeBuildPlacement, set_m_nudgeBuildPlacement },+// MiddleMousePans used to sit here. There is nothing left to choose: a right drag pans and a// middle drag turns the camera.@@ -342,11 +350,11 @@ const OptionDef TheOptionCatalog[] =OPTION_INT, APPLY_RESTART, 0, 16,get_m_anisotropyLevel, set_m_anisotropyLevel },- // Six rows used to sit here: nudge build placement, the placement range ring, workers returning- // to supply, detailed build tooltips, the HUD overlay and replay archiving. Every one of them is- // now on for everybody, decided in GlobalData's constructor, so there is nothing left to load or- // save. Grid placement and snap-to-45 building rotation left with them and came back to- // Options > Controls, above.+ // Five rows used to sit here: the placement range ring, workers returning to supply, detailed+ // build tooltips, the HUD overlay and replay archiving. Every one of them is now on for+ // everybody, decided in GlobalData's constructor, so there is nothing left to load or save.+ // Grid placement, snap-to-45 building rotation and the nudge left with them and came back to+ // Options > Controls, above, off until ticked.// Off, subtle, normal, strong. Normal (60, the menu's Medium) is the default, set in// GlobalData's constructor: it is the strength the Direct3D 11 frame applied before there was adiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex f46be384b..c67007711 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -8076,7 +8076,7 @@ void InGameUI::forgetPendingPlacements( void )Bool InGameUI::nudgePlacementToLegal( Coord3D *world, const ThingTemplate *what, Real angle,Object *builderObject ) const{- if( world == NULL || what == NULL || TheGlobalData->m_nudgeBuildPlacement == FALSE || TheGlobalData->isClassicUI() )+ if( world == NULL || what == NULL || TheGlobalData->m_nudgeBuildPlacement == FALSE )return FALSE;// a wall tiles from the two points you dragged between; sliding one end off that line is not helpdiff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 29b887fa5..6f72b8f71 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -12662,12 +12662,13 @@ TEST(text_language_row_offers_every_language)TEST(gameplay_conveniences_are_forced_on_and_left_the_catalog){- /* Six settings that used to share the Gameplay page are decided here instead of by the player.+ /* Five settings that used to share the Gameplay page are decided here instead of by the player.Two halves have to agree or the removal is a feature switched off by accident: the row mustbe gone from the catalog, so nothing loads a stale "no" out of an Options.ini written beforethis change, and the constructor must say TRUE, because with the row gone the constructor is- the only thing left that says anything. Grid placement and snap-to-45 building rotation left- with them and came back as Controls check boxes, so they are below with the menu rows. */+ the only thing left that says anything. Grid placement, snap-to-45 building rotation and the+ nudge left with them and came back as Controls check boxes under new keys, so they are below+ with the menu rows; their old keys stay out of the catalog. */static const char *const forced[] ={"NudgeBuildPlacement", "ShowPlacementRangeRing", "WorkersReturnToSupply",@@ -12680,7 +12681,6 @@ TEST(gameplay_conveniences_are_forced_on_and_left_the_catalog)GlobalData *scratch = NEW GlobalData;TheWritableGlobalData = scratch;- CHECK( scratch->m_nudgeBuildPlacement );CHECK( scratch->m_showPlacementRangeRing );CHECK( scratch->m_workersReturnToSupply );CHECK( scratch->m_detailedBuildTooltips );@@ -12716,7 +12716,7 @@ TEST(gameplay_conveniences_are_forced_on_and_left_the_catalog)static const char *const menu[] ={"CameraSnapTo45", "BuildGrid", "BuildSnapTo45", "BuildSnapToNeighbour", "OpenAtMaxZoom",- "WheelZoomToCursor", NULL+ "WheelZoomToCursor", "BuildNudge", NULL};for( Int i = 0; menu[ i ] != NULL; ++i ){diff --git a/GeneralsMD/Code/Tools/optionsmenu_layout.py b/GeneralsMD/Code/Tools/optionsmenu_layout.pyindex 666c19a0a..66ef029a9 100644--- a/GeneralsMD/Code/Tools/optionsmenu_layout.py+++ b/GeneralsMD/Code/Tools/optionsmenu_layout.py@@ -171,6 +171,7 @@ NEW_CONTROLS = [(CHECK, "CheckGridBuild", "GUI:GridBuild"),(CHECK, "CheckSnapBuild45", "GUI:SnapBuild45"),(CHECK, "CheckSnapBuildNeighbour", "GUI:SnapBuildNeighbour"),+ (CHECK, "CheckNudgeBuild", "GUI:NudgeBuild"),(LABEL, "LabelDragTolerance", "GUI:DragTolerance"),(SLIDER, "SliderDragTolerance", None),(CHECK, "CheckTreeSway", "GUI:TreeSway"),@@ -312,7 +313,8 @@ GROUP_LAYOUT = [("GUI:OptionsGroupPlacement", [("check", "CheckGridBuild"),("check", "CheckSnapBuild45"),- ("check", "CheckSnapBuildNeighbour")]),+ ("check", "CheckSnapBuildNeighbour"),+ ("check", "CheckNudgeBuild")]),("GUI:OptionsGroupInput", [setting("LabelDragTolerance", "SliderDragTolerance", "ValueDragTolerance"),("check", "CheckChromaLighting")])]),@@ -348,7 +350,7 @@ GROUP_LAYOUT = [# health bar mode and empty garrison pips (Drawable.cpp) and order lines (W3DInGameUI.cpp). Every one# is a catalog row, whose menu passes skip a control the layout does not carry, so the Classic layout# leaves them out and keeps the value. Zoom to cursor, the opening zoom, the camera's 45 degree steps-# and the three placement snaps are not here: they start off, which is how 1.04 played, and Classic+# the three placement snaps and the nudge are not here: they start off, which is how 1.04 played, and Classic# honours them once ticked.REFORGED_ONLY = ["CheckSmoothMotion", "ComboBoxHudScale", "CheckNetBox", "ComboBoxIncomeRate", "CheckOrderLines",