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): Classic drops the fork's HUD extras and multi-structure picks
Olcay Seyganaf0723d6ed6f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c0ce98604..7e771c5d2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1087,7 +1087,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- Display, graphics, effects, audio, controls, gameplay and network, behind seven buttons across the top. The original screen was one panel with everything on it at once, and it was already full the day it shipped: the language filter, the keyboard button and four camera checkboxes are all still in there, parked off the right edge where nobody can reach them, because there was nowhere left to put them.- Classic Graphics, at the top of the Graphics page, puts the game back the way it looked in 2003 in one click: its own textures and ground in place of the upscaled ones, the old hard shadows, the round dark patch under every tree where Reforged lays the tree's own outline on the ground, no bump detail on the models and no glow or sharpening over the picture. Leave it off and you have Reforged. The rest of the options stay yours either way, and the box takes effect the next time the game starts.-- Interface, at the top of the HUD group on the Gameplay page, picks between Classic and Reforged. Classic is the command bar, mouse and hotkeys of Zero Hour 1.04 that your hands still remember; Reforged is the console in the middle, right-click orders and the key grid this version built. Every player starts on Classic, including anyone updating whose settings never named it. The choice is yours alone: two players on different styles still play the same match and the same replay. It takes effect the next time the game starts. Classic's screen is EA's again: the one-piece command bar in each side's own painting, the radar with its flashing under-attack lamp, the beacon button, six lines of messages in the top left that fade as they did, superweapon countdowns written out by name, the old chat line and quit menu, lettering at the old sizes, and Tab opening diplomacy. What it does not do is stretch. On a 16:9 or 21:9 screen the bar, the menus and every dialog sit in a 4:3 frame in the middle at their drawn shape, and the battlefield runs out to both edges past them; at 2560x1080 that is 560 pixels of ground on either side of the bar. The mouse and keys are 1.04's as well. The left button selects and gives the order, so an enemy under it is an attack and a bunker under your infantry is a way in; the right button drops your selection or takes back a half-given order, and a right drag scrolls the map. Ctrl held is force fire. Alt held lays waypoints, and the white path joining them is drawn again. A guard order holds the range it always held, Shift and a number adds that group to what you have selected, and a build button is one unit a click. The keys are your language's own key map from the game's files, with nothing of Reforged's grid laid over it. The camera zooms on the middle of the screen, turns without snapping, and scrolls from the last three pixels of a full screen and not at all in a window, whatever the options say. None of it reaches the battle itself: Classic sends the game only the orders 1.04 sent, so a Classic player and a Reforged one share a match, and a replay plays back the same in either.+- Interface, at the top of the HUD group on the Gameplay page, picks between Classic and Reforged. Classic is the command bar, mouse and hotkeys of Zero Hour 1.04 that your hands still remember; Reforged is the console in the middle, right-click orders and the key grid this version built. Every player starts on Classic, including anyone updating whose settings never named it. The choice is yours alone: two players on different styles still play the same match and the same replay. It takes effect the next time the game starts. Classic's screen is EA's again: the one-piece command bar in each side's own painting, the radar with its flashing under-attack lamp, the beacon button, six lines of messages in the top left that fade as they did, superweapon countdowns written out by name, the old chat line and quit menu, lettering at the old sizes, and Tab opening diplomacy. What it does not do is stretch. On a 16:9 or 21:9 screen the bar, the menus and every dialog sit in a 4:3 frame in the middle at their drawn shape, and the battlefield runs out to both edges past them; at 2560x1080 that is 560 pixels of ground on either side of the bar. The mouse and keys are 1.04's as well. The left button selects and gives the order, so an enemy under it is an attack and a bunker under your infantry is a way in; the right button drops your selection or takes back a half-given order, and a right drag scrolls the map. Ctrl held is force fire. Alt held lays waypoints, and the white path joining them is drawn again. A guard order holds the range it always held, Shift and a number adds that group to what you have selected, and a build button is one unit a click. The keys are your language's own key map from the game's files, with nothing of Reforged's grid laid over it, and a build button's key is the letter painted yellow in its name again. A structure is selected on its own, as it always was. The radar shows no money piles or tech buildings, the piles carry no money over them, and the clock plate, the frame counter and the experience bar under the portrait stay off the screen. So does the peace time plate, though a host's truce still holds. The camera zooms on the middle of the screen, turns without snapping, and scrolls from the last three pixels of a full screen and not at all in a window, whatever the options say. None of it reaches the battle itself: Classic sends the game only the orders 1.04 sent, so a Classic player and a Reforged one share a match, and a replay plays back the same in either.- Every graphics setting is on the Graphics and Effects pages. Shadows, clouds, ground lighting, soft water edges, trees, extra animations, heat haze, texture resolution and the particle limit used to hide in a popup that only opened if you picked Custom from the detail box on another page, so choosing High never showed you what High turns on. Pick a preset now and its settings change in front of you; touch any one of them and the box reads Custom. Texture filtering and the number of anisotropic samples, which needed a text editor, sit there too.- Every page is sorted into titled groups by what the settings do, and the groups sit in the same three columns on every tab. On Graphics the detail preset heads the first column with the texture and particle sliders under it, the picture settings take the second and the terrain the third. The framed boxes the original drew inside each page are gone. They were sized for headings that no longer exist, which is why no two pages started their first setting at the same height.- The detail box has Ultra above High, and a preset now sets everything it is responsible for. Picking High used to leave antialiasing and texture filtering wherever they happened to be; High now brings 4x antialiasing and 8 anisotropic samples with it, and Low turns both down for the machines that need it. Ultra is High with the particle limit at the top of its slider, 5,000 against High's 3,000, detail that is never dropped when the frame rate dips, 8x antialiasing, 16 anisotropic samples, thick smoke and every new shadow and effect switched on. Glow stays yours whichever you pick: the artwork was painted without it.diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cppindex 4dec7f9ce..9174c4bf7 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp@@ -285,6 +285,9 @@ void Radar::clearAllEvents( void )//-------------------------------------------------------------------------------------------------RadarLandmarkType Radar::landmarkTypeOf( const Object *obj ){+ // Classic's radar is EA's: no money piles, no tech buildings it was not already showing+ if( TheGlobalData->isClassicUI() )+ return RADAR_LANDMARK_NONE;if( obj->isKindOf( KINDOF_SUPPLY_SOURCE ) )return RADAR_LANDMARK_SUPPLY;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex d8f985b0e..caf31a1ab 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -3125,7 +3125,9 @@ void Drawable::drawIconUI( void )drawCaption( healthBarRegion );drawConstructPercent( healthBarRegion );- drawSupplyCash( healthBarRegion );+ // Classic's piles wear no money, as the game shipped+ if( !TheGlobalData->isClassicUI() )+ drawSupplyCash( healthBarRegion );//All Icons Below only draw on ALIVE things, so bail here -------------------------if( obj->isEffectivelyDead() || obj->isKindOf( KINDOF_IGNORED_IN_GUI )) // object explicitly wants nothing to do with these icons, so...@@ -5682,7 +5684,9 @@ Bool Drawable::isSelectable( void ) const//-------------------------------------------------------------------------------------------------Bool Drawable::isMassSelectable( void ) const{- return getObject() && getObject()->isMassSelectable();+ // Classic is the game as shipped, where a structure was only ever selected on its own+ return getObject() && getObject()->isMassSelectable()+ && !( TheGlobalData->isClassicUI() && getObject()->isKindOf( KINDOF_STRUCTURE ) );}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 6d5689571..a51727b23 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -3598,7 +3598,8 @@ void ControlBar::update( void )m_currentSelectedDrawable ) ? m_currentSelectedDrawable->getObject(): NULL;const ExperienceTracker *xp = portraitObj ? portraitObj->getExperienceTracker() : NULL;- if( xp && portraitObj->isLocallyControlled() && xp->isTrainable() &&+ // Classic's portrait is EA's picture alone: the bar stays empty+ if( xp && !TheGlobalData->isClassicUI() && portraitObj->isLocallyControlled() && xp->isTrainable() &&xp->getVeterancyLevel() < LEVEL_LAST ){const ThingTemplate *tmpl = portraitObj->getTemplate();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex ceeb879b4..027d0da5d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -307,7 +307,7 @@ static Bool kindOfUnitSelection( Drawable *test, void *userData )&& !object->isContained()&& !object->getDrawable()->isSelected()&& !object->isEffectivelyDead()- && object->isMassSelectable()+ && object->getDrawable()->isMassSelectable()&& !object->isOffMap()){@@ -366,7 +366,7 @@ static Bool similarUnitSelection( Drawable *test, void *userData )&& object->isLocallyControlled()&& !object->isContained()&& !( object->getDrawable()->isSelected() )- && object->isMassSelectable() // And only if they can be multiply selected. (otherwise the drawable will be, but the object will not be)+ && object->getDrawable()->isMassSelectable() // And only if they can be multiply selected. (otherwise the drawable will be, but the object will not be)&& !object->isOffMap()){@@ -6642,7 +6642,7 @@ void InGameUI::createMouseoverHint( const GameMessage *msg )Int boxes = warehouseModule->getBoxesStored();Int value = boxes * TheGlobalData->m_baseValuePerSupplyBox;Int startingBoxes = warehouseModule->getStartingBoxes();- if( startingBoxes > 0 )+ if( startingBoxes > 0 && !TheGlobalData->isClassicUI() ){// what is left against what the pile began the match with; it can be stocked past thatInt percent = min( 100, boxes * 100 / startingBoxes );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cppindex c8d79e051..fc55d7be0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp@@ -816,16 +816,55 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessaBool addToGroup = TheInGameUI->isInPreferSelectionMode();- if (si.currentCountEnemies > 0 ||- si.currentCountCivilians > 0 ||- si.currentCountFriends > 0)+ const Bool classic = TheGlobalData->isClassicUI();+ if (si.currentCountEnemies > 0 ||+ si.currentCountCivilians > 0 ||+ si.currentCountFriends > 0 ||+ (classic && si.currentCountMineBuildings > 0)){// force a new group creationaddToGroup = FALSE;}+ // Classic is the game as shipped: a structure is only ever selected on its own, when it is the+ // one thing clicked or the only selectable thing in the box (EA's Firebase case)+ if (si.newCountMine > 0 && classic)+ {+ si.selectMine = TRUE;+ if ( si.newCountMineBuildings == 1 && si.newCountMine == 1 )+ {+ addToGroup = FALSE;+ si.selectMineBuildings = TRUE;+ }+ else if ( si.newCountMineBuildings > 0 )+ {+ Bool onlyTheOneBuildingIsSelectableAnyway = TRUE;+ DrawableID buildingID = INVALID_DRAWABLE_ID;+ for (DrawableListIt it = drawablesThatWillSelect.begin(); it != drawablesThatWillSelect.end(); ++it)+ {+ const Drawable *d = *it;+ if ( d->isKindOf( KINDOF_STRUCTURE ) )+ {+ if ( buildingID == INVALID_DRAWABLE_ID )+ buildingID = d->getID();+ else if ( buildingID != d->getID() )+ onlyTheOneBuildingIsSelectableAnyway = FALSE;+ }+ else if ( d->isSelectable() )+ onlyTheOneBuildingIsSelectableAnyway = FALSE;++ if ( ! onlyTheOneBuildingIsSelectableAnyway )+ break;+ }+ if ( onlyTheOneBuildingIsSelectableAnyway )+ {+ addToGroup = FALSE;+ si.selectMineBuildings = TRUE;+ }+ }+ }// If there are any of my units, then select those.- if (si.newCountMine > 0)+ else if (si.newCountMine > 0){si.selectMine = TRUE;diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayString.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayString.hindex d86cf3f36..0ea8584d7 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayString.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayString.h@@ -105,6 +105,9 @@ protected:Bool m_textChanged; ///< when contents of string change this is TRUEBool m_fontChanged; ///< when font has chagned this is TRUEBool m_useHotKey; ///< '&' hotkey markers are hidden+ Render2DSentenceClass m_textRendererHotKey; ///< Classic: the hotkey letter again, bold, in HotKeyTextColor over its own+ ICoord2D m_hotKeyPos; ///< where Build_Sentence found that letter, from the text's corner+ Bool m_drawHotKey; ///< the sentence was built with a letter to paint overICoord2D m_textPos; ///< current text pos set in text rendererColor m_currTextColor, ///< current color used in text rendererm_currDropColor; ///< current color used for shadow in textdiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayString.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayString.cppindex ee1fc2dcc..c1766c24f 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayString.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayString.cpp@@ -59,6 +59,7 @@#include "W3DDevice/GameClient/W3DDisplayString.h"#include "GameClient/GameFont.h"#include "GameClient/GlobalLanguage.h"+#include "Common/GlobalData.h"// DEFINES ////////////////////////////////////////////////////////////////////#ifdef _INTERNAL@@ -124,6 +125,9 @@ W3DDisplayString::W3DDisplayString( void )m_clipRegion.hi.y = 0;m_lastResourceFrame = 0;m_useHotKey = FALSE;+ m_hotKeyPos.x = 0;+ m_hotKeyPos.y = 0;+ m_drawHotKey = FALSE;} // end W3DDisplayString@@ -198,7 +202,38 @@ void W3DDisplayString::draw( Int x, Int y, Color color, Color dropColor, Int xDr{// Reset() clears the parse flag on every text change, so it is put back here, where it is readm_textRenderer.Set_Hot_Key_Parse( m_useHotKey != FALSE );- m_textRenderer.Build_Sentence( getText().str(), NULL, NULL );+ m_textRenderer.Build_Sentence( getText().str(), &m_hotKeyPos.x, &m_hotKeyPos.y );++ //+ // Classic paints the hotkey letter again in the hotkey colour, in the bold cut, over the one+ // the sentence already drew, the way the game shipped. Over rather than in a gap: a letter+ // the bold renderer cannot draw still reads in the text's own colour.+ //+ m_drawHotKey = FALSE;+ m_textRendererHotKey.Reset();+ if( m_useHotKey && TheGlobalData && TheGlobalData->isClassicUI() && m_font )+ {+ // the letter after the first '&', by the sentence's own test, kept wide so a Turkish letter+ // is painted as itself+ UnicodeString letter;+ for( const WideChar *c = getText().str(); *c; ++c )+ {+ if( c[ 0 ] == L'&' && c[ 1 ] > L' ' && c[ 1 ] != L'\n' )+ {+ const WideChar text[ 2 ] = { c[ 1 ], 0 };+ letter.set( text );+ break;+ }+ }+ if( !letter.isEmpty() )+ {+ GameFont *boldFont = TheFontLibrary->getFont( m_font->nameString, m_font->pointSize, TRUE );+ m_textRendererHotKey.Set_Font( static_cast<FontCharsClass *>( boldFont ? boldFont->fontData : m_font->fontData ) );+ m_textRendererHotKey.Build_Sentence( letter.str(), NULL, NULL );+ m_drawHotKey = TRUE;+ }+ }+m_fontChanged = FALSE;m_textChanged = FALSE;needNewPolys = TRUE;@@ -237,10 +272,19 @@ void W3DDisplayString::draw( Int x, Int y, Color color, Color dropColor, Int xDrm_textRenderer.Set_Location( Vector2( m_textPos.x, m_textPos.y ) );m_textRenderer.Draw_Sentence( m_currTextColor );+ if( m_drawHotKey )+ {+ m_textRendererHotKey.Reset_Polys();+ m_textRendererHotKey.Set_Location( Vector2( m_textPos.x + m_hotKeyPos.x, m_textPos.y + m_hotKeyPos.y ) );+ m_textRendererHotKey.Draw_Sentence( TheGlobalData->m_hotKeyTextColor );+ }+} // end if// render the textm_textRenderer.Render();+ if( m_drawHotKey )+ m_textRendererHotKey.Render();// we are for sure using display resources nowif( TheGameClient )@@ -345,6 +389,10 @@ void W3DDisplayString::setClipRegion( IRegion2D *region )m_clipRegion.lo.y,m_clipRegion.hi.x,m_clipRegion.hi.y ) );+ m_textRendererHotKey.Set_Clipping_Rect( RectClass( m_clipRegion.lo.x,+ m_clipRegion.lo.y,+ m_clipRegion.hi.x,+ m_clipRegion.hi.y ) );} // end if} // end setClipRegiondiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cppindex 85599fd04..339de5877 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp@@ -206,6 +206,7 @@ void W3DDisplayStringManager::update( void )// free the resourcesstring->m_textRenderer.Reset();+ string->m_textRendererHotKey.Reset();//// mark data in the string as changed so that if it needs to// be drawn again it will know to reconstruct the render datadiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cppindex 4af2b71ff..a6255e391 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp@@ -540,7 +540,8 @@ void W3DInGameUI::draw( void )// the one reading you want visible exactly when something is going wrong.//// the peace time clock across the top middle, and the clock plate in the corner beside it- if( matchOnScreen )+ // Classic's screen is EA's, which had neither plate+ if( matchOnScreen && !TheGlobalData->isClassicUI() ){drawPeaceTimer();drawHudOverlay();