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
fix(gameclient): guard shield back, no promotion dim, white bold lists
Olcay Seygan68678274913d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 95f40f27f..f93409e76 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -31,7 +31,7 @@ found and fixed — EA's own, not port damage.**## One interface-- The choice between a Classic and a Reforged interface is gone. There is one, laid out the way Zero Hour shipped, and the orders Reforged added now live on the keys you already know: A attack-moves, holding Ctrl fires on whatever is under the cursor as it did in 2003, a guard order can cover a patch of ground instead of one spot, and orders queue up one after another. Everything your base is building stands on the screen as a line of text each, the six closest to done first and "+N more" for the rest. Superweapon countdowns are listed the same way, up to eighteen. Whether the right button gives orders, or the left as in 1.04, is a setting in the launcher.+- The choice between a Classic and a Reforged interface is gone. There is one, laid out the way Zero Hour shipped, and the orders Reforged added now live on the keys you already know: A attack-moves, holding Ctrl fires on whatever is under the cursor as it did in 2003, a guard order can cover a patch of ground instead of one spot, and orders queue up one after another. Everything your base is building stands on the screen as a line of text each, the six closest to done first and "+N more" for the rest. Superweapon countdowns are listed the same way, up to eighteen. Both lists are in bold white, readable on any ground. The promotion screen no longer darkens the battlefield behind it. Whether the right button gives orders, or the left as in 1.04, is a setting in the launcher.- Every key is yours to move. The launcher's Hotkeys page draws the command bar of every building and unit each general can field, cameos and letters as the game shows them, and a click and a keypress gives any button a new letter or none. Two buttons on one bar that would share a letter are marked before you play. The keyboard commands are there too, from bookmarks and team keys to the camera, along with the ones Zero Hour never bound: select every fighting unit, vehicle or aircraft, every barracks, war factory or airfield, the next idle worker or unit, pause, the general's promotions, the three signals to your allies and the general's powers. Your keys are yours alone; the other players in a match keep theirs, and a match never refuses you for them.## The command bar moves to the middlediff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex d17d6bd74..6be97d369 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -1326,6 +1326,7 @@ protected:Bool m_isAttackCircling; ///< TRUE while an attack circle is being dragged (fork)ICoord2D m_attackCircleAnchor; ///< where the circle was started, in pixelsICoord2D m_attackCircleCursor; ///< where the cursor is now, which is the rim+ Coord3D m_attackCircleCenter; ///< the ground the press landed on, held while the camera movesvoid updateFormationHints( void ); ///< recompute who goes where from the curve being drawnvoid updateOrderHints( void ); ///< read the selection's own goals, once a framediff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex d0c91e768..2952d01b1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -2622,16 +2622,6 @@ void ControlBar::shutdownWindows( void )} // end shutdownWindows-/** The painted promotion screen's own draw, and the battlefield and bar dimmed under it. */-static GameWinDrawFunc theClassicPromotionDraw = NULL;--static void drawClassicPromotionScreen( GameWindow *window, WinInstanceData *instData )-{- enum { DIM_ALPHA = 166 }; ///< rgba(0, 0, 0, 0.65)- TheDisplay->drawFillRect( 0, 0, TheDisplay->getWidth(), TheDisplay->getHeight(), GameMakeColor( 0, 0, 0, DIM_ALPHA ) );- theClassicPromotionDraw( window, instData );-}-//-------------------------------------------------------------------------------------------------/** Look up every window the bar drives, and lay the bar out. Re-callable: a resolution change* rebuilds ControlBar.wnd and then calls this instead of replacing the whole ControlBar. */@@ -2674,8 +2664,6 @@ void ControlBar::initWindows( void )id = TheNameKeyGenerator->nameToKey( "GeneralsExpPoints.wnd:GenExpParent" );m_contextParent[ CP_PURCHASE_SCIENCE ] = TheWindowManager->winGetWindowFromId( NULL, id );//m_scienceLayout->getFirstWindow();- theClassicPromotionDraw = m_contextParent[ CP_PURCHASE_SCIENCE ]->winGetDrawFunc();- m_contextParent[ CP_PURCHASE_SCIENCE ]->winSetDrawFunc( drawClassicPromotionScreen );id = TheNameKeyGenerator->nameToKey( "ControlBar.wnd:UnderConstructionWindow" );m_contextParent[ CP_UNDER_CONSTRUCTION ] = TheWindowManager->winGetWindowFromId( NULL, id );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 9460e16a9..24ae4a77a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -642,8 +642,8 @@ void InGameUI::xfer( Xfer *xfer )evaReadyPlayed,m_superweaponNormalFont,m_superweaponNormalPointSize,- m_superweaponNormalBold,- player->getPlayerColor(),+ TRUE, // the countdown list is white and bold+ player->getPlayerColor(),powerTemplate);m_superweapons[playerIndex][powerName].push_back(swInfo);}@@ -736,8 +736,8 @@ void InGameUI::addSuperweapon(Int playerIndex, const AsciiString& powerName, ObjFALSE, // evaReadyPlayedm_superweaponNormalFont,m_superweaponNormalPointSize,- m_superweaponNormalBold,- player->getPlayerColor(),+ TRUE, // the countdown list is white and bold+ player->getPlayerColor(),powerTemplate);m_superweapons[playerIndex][powerName].push_back(info);@@ -2864,7 +2864,7 @@ void InGameUI::drawClassicSuperweapon( SuperweaponInfo *info, const AsciiStringif( isReady )info->setFont( m_superweaponReadyFont, m_superweaponReadyPointSize, m_superweaponReadyBold );else if( info->m_timestamp == 0 )- info->setFont( m_superweaponNormalFont, m_superweaponNormalPointSize, m_superweaponNormalBold );+ info->setFont( m_superweaponNormalFont, m_superweaponNormalPointSize, TRUE );info->m_forceUpdateText = false;info->m_ready = isReady;info->m_timestamp = readySecs;@@ -2876,7 +2876,9 @@ void InGameUI::drawClassicSuperweapon( SuperweaponInfo *info, const AsciiStringinfo->setText( name, time );}- Color color = 0;+ // white, flashing to EA's flash colour once ready+ const Color white = GameMakeColor( 255, 255, 255, 255 );+ Color color = white;if( isReady && m_superweaponFlashDuration != 0.0f ){if( TheGameLogic->getFrame() >= m_superweaponLastFlashFrame + (Int)m_superweaponFlashDuration )@@ -2884,7 +2886,7 @@ void InGameUI::drawClassicSuperweapon( SuperweaponInfo *info, const AsciiStringm_superweaponUsedFlashColor = !m_superweaponUsedFlashColor;m_superweaponLastFlashFrame = TheGameLogic->getFrame();}- color = m_superweaponUsedFlashColor ? 0 : m_superweaponFlashColor;+ color = m_superweaponUsedFlashColor ? white : m_superweaponFlashColor;}const Color drop = GameMakeColor( 0, 0, 0, 255 );info->drawName( x, *y, color, drop );@@ -3922,6 +3924,7 @@ void InGameUI::beginAttackCircle( const ICoord2D& pt )m_isAttackCircling = TRUE;m_attackCircleAnchor = pt;m_attackCircleCursor = pt;+ TheTacticalView->screenToTerrain( &pt, &m_attackCircleCenter );DEBUG_LOG(("attack circle: begun at %d,%d with %d selected\n", pt.x, pt.y, getSelectCount()));}@@ -3932,9 +3935,10 @@ void InGameUI::updateAttackCircle( const ICoord2D& pt )}//--------------------------------------------------------------------------------------------------/** The circle the player is dragging, in world terms: the anchor is its centre and the cursor sits- * on its rim. Both the rim drawn on the screen and the wash laid on the ground ask this, so they- * cannot disagree about where the circle is. */+/** The circle the player is dragging, in world terms: its centre is the ground the press landed on,+ * and the cursor sits on its rim. Both the rim drawn on the screen and the wash laid on the ground+ * ask this, so they cannot disagree about where the circle is. The centre is kept as ground, not+ * as the pixel: a camera that moves during the drag used to slide the whole circle over the map. *///-------------------------------------------------------------------------------------------------Bool InGameUI::getAttackCircleGround( Coord3D& center, Real& radius ) const{@@ -3942,7 +3946,7 @@ Bool InGameUI::getAttackCircleGround( Coord3D& center, Real& radius ) constreturn FALSE;Coord3D rim;- TheTacticalView->screenToTerrain( &m_attackCircleAnchor, ¢er );+ center = m_attackCircleCenter;TheTacticalView->screenToTerrain( &m_attackCircleCursor, &rim );const Real dx = rim.x - center.x;@@ -6399,7 +6403,7 @@ void InGameUI::postDraw( void ){m_superweaponMoreText = TheDisplayStringManager->newDisplayString();m_superweaponMoreText->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,- TheGlobalLanguageData->adjustFontSize( m_superweaponNormalPointSize ), m_superweaponNormalBold ) );+ TheGlobalLanguageData->adjustFontSize( m_superweaponNormalPointSize ), TRUE ) );}if( m_superweaponMoreText->getText().compare( more ) != 0 )m_superweaponMoreText->setText( more );@@ -9648,12 +9652,13 @@ void InGameUI::drawProductionList( void )const Int hidden = m_productionListTotal - shown;const Int lines = m_productionListCount + ( hidden > 0 ? 1 : 0 );- // left-aligned under the messages' column, the last line standing just clear of the control bar+ // left-aligned under the messages' column, the last line standing just clear of the control bar,+ // white and bold so it reads on any groundGameFont *font = TheFontLibrary->getFont( m_superweaponNormalFont,- TheGlobalLanguageData->adjustFontSize( m_superweaponNormalPointSize ), m_superweaponNormalBold );+ TheGlobalLanguageData->adjustFontSize( m_superweaponNormalPointSize ), TRUE );const Int x = m_messagePosition.x;Int y = controlBarTop() - stripPixels( PRODUCTION_LIST_LIFT ) - lines * font->height;- const Color color = clientPlayerColor( player );+ const Color color = GameMakeColor( 255, 255, 255, 255 );const Color drop = GameMakeColor( 0, 0, 0, 255 );for( Int line = 0; line < lines; line++ ){diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.hindex 070290cb6..3bcef48b2 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h@@ -83,6 +83,7 @@ protected:virtual void drawAttackCircleFill( void ); ///< the wash on the ground inside an attack circlevirtual void drawFormationLine( void ); ///< the line an armed left drag is spreading the selection alongvirtual void drawAttackCircle( void ); ///< the circle a left drag is sweeping targets out of+ void drawGuardMarkers( void ); ///< the shield over each of the local player's guarding unitsRenderObjClass *m_buildingPlacementAnchor;RenderObjClass *m_buildingPlacementArrow;diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cppindex 88bba1847..56231d770 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp@@ -601,6 +601,9 @@ void W3DInGameUI::draw( void )if( isAttackCircling() )drawAttackCircle();+ // which of the local player's units are holding a guard+ drawGuardMarkers();+// for each view draw hints/// @todo should the UI be iterating through views like this?if( TheDisplay )@@ -813,6 +816,9 @@ static void setGroundOverlayState( void )REF_PTR_RELEASE( material );DX8Wrapper::Set_Texture( 0, NULL );DX8Wrapper::Set_Shader( overlayShader );+ // the quads are in world space; the terrain pass has rendered pucks and bridges since its own+ // identity was set, and the sheet used to inherit whichever of their matrices came last+ DX8Wrapper::Set_Transform( D3DTS_WORLD, Matrix3D( 1 ) );DX8Wrapper::Apply_Render_State_Changes();}@@ -1127,6 +1133,105 @@ void W3DInGameUI::drawAttackCircle( void )} // end drawAttackCircle+//-------------------------------------------------------------------------------------------------+/** One screen row from `left` to `right`, the two end pixels at the share of them the span covers,+ * so a slanted edge fades across a pixel instead of stepping. */+//-------------------------------------------------------------------------------------------------+static void drawCoveredSpan( Real left, Real right, Int y, UnsignedInt color )+{+ if( right <= left )+ return;+ const UnsignedInt rgb = color & 0x00FFFFFF;+ const Real alpha = (Real)( color >> 24 );+ const Int first = (Int)floorf( left );+ const Int last = (Int)floorf( right );+ if( first == last )+ {+ TheDisplay->drawFillRect( first, y, 1, 1, rgb | ( REAL_TO_INT( alpha * ( right - left ) ) << 24 ) );+ return;+ }+ TheDisplay->drawFillRect( first, y, 1, 1, rgb | ( REAL_TO_INT( alpha * ( first + 1 - left ) ) << 24 ) );+ if( last > first + 1 )+ TheDisplay->drawFillRect( first + 1, y, last - first - 1, 1, color );+ if( right > last )+ TheDisplay->drawFillRect( last, y, 1, 1, rgb | ( REAL_TO_INT( alpha * ( right - last ) ) << 24 ) );+}++//-------------------------------------------------------------------------------------------------+/** A heater shield centred on `centreX`, filled one screen row at a time: straight sides for the+ * upper part, then a curve closing to the point at the bottom. The left half takes `leftColor`+ * and the right half `rightColor`, which with a light and a darker steel reads as a raised+ * centre ridge with the light from the left. */+//-------------------------------------------------------------------------------------------------+static void drawShieldShape( Real centreX, Int top, Real width, Int height, UnsignedInt leftColor, UnsignedInt rightColor )+{+ const Real SHOULDER = 0.4f; // share of the height above the taper+ for( Int row = 0; row < height; ++row )+ {+ const Real t = ( row + 0.5f ) / height;+ Real half = width * 0.5f;+ if( t > SHOULDER )+ half *= sqrtf( ( 1.0f - t ) / ( 1.0f - SHOULDER ) );+ drawCoveredSpan( centreX - half, centreX, top + row, leftColor );+ drawCoveredSpan( centreX, centreX + half, top + row, rightColor );+ }+}++//-------------------------------------------------------------------------------------------------+/** A guarding unit looks like an idle one until something walks into its circle, so each of the+ * local player's guards wears a small shield over its head, selected or not. It follows the zoom+ * like the health bar does, between a floor that still reads as a shield and a ceiling that does+ * not cover a close-up infantryman. The one-interface change took it out with the Reforged+ * interface it was drawn under; it belongs to guard, not to that interface. */+//-------------------------------------------------------------------------------------------------+void W3DInGameUI::drawGuardMarkers( void )+{+ const Real MARKER_HEIGHT = 10.0f; // at 800x600 and zoom 1, a little closer than the opening camera+ const Real MARKER_MIN_HEIGHT = 6.0f;+ const Real MARKER_MAX_HEIGHT = 10.0f;+ const UnsignedInt SHADOW_COLOR = 0x60000000; // lifts it off snow and sand alike+ const UnsignedInt EDGE_COLOR = 0xE00C1014;+ const UnsignedInt LIT_COLOR = 0xF0E8EEF4; // the command bar's steel, the side facing the light+ const UnsignedInt SHADED_COLOR = 0xF0939FAC;++ if( !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )+ return;++ const Real uiScale = TheUIScale();+ const Real size = MARKER_HEIGHT * uiScale / TheTacticalView->getZoom();+ const Int height = REAL_TO_INT( max( MARKER_MIN_HEIGHT * uiScale, min( MARKER_MAX_HEIGHT * uiScale, size ) ) );+ const Real width = height * 0.8f;+ const Int lift = height / 2; // clear of the health bar's line over the model's top+ const Real rim = max( 1.0f, height / 10.0f );++ // ponytail: walks every object each frame; share one walk with another per-object overlay if it shows+ for( Object *obj = TheGameLogic->getFirstObject(); obj; obj = obj->getNextObject() )+ {+ if( !obj->isLocallyControlled() || obj->isEffectivelyDead() || obj->getContainedBy() )+ continue;+ const AIUpdateInterface *ai = obj->getAI();+ if( ai == NULL || ai->getCurrentStateID() != AI_GUARD )+ continue;+ const Drawable *draw = obj->getDrawable();+ if( draw == NULL || draw->isDrawableEffectivelyHidden() )+ continue;++ Coord3D top = *obj->getPosition();+ top.z += obj->getGeometryInfo().getMaxHeightAbovePosition();+ ICoord2D spot;+ if( !TheTacticalView->worldToScreen( &top, &spot ) )+ continue;++ const Real centreX = spot.x + 0.5f;+ const Int y = spot.y - lift - height;+ const Int inset = REAL_TO_INT( rim );+ drawShieldShape( centreX + rim, y + inset, width, height, SHADOW_COLOR, SHADOW_COLOR );+ drawShieldShape( centreX, y, width, height, EDGE_COLOR, EDGE_COLOR );+ drawShieldShape( centreX, y + inset, width - 2.0f * rim, height - 3 * inset, LIT_COLOR, SHADED_COLOR );+ }++} // end drawGuardMarkers+//-------------------------------------------------------------------------------------------------/** EA's animated ring on the ground where a move order landed, 40 client frames each. EA's own* code, deleted by fec052cc and brought back (InGameUI::createMoveHint fills it). */