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): seat the American centre plate and lose the line off its edge
Olcay Seyganbe9e3748b32e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8839a6200..397fe860e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -383,7 +383,7 @@ found and fixed — EA's own, not port damage.**- The writing on screen grows with your monitor now. Every panel is stretched to your resolution and always was, but the text inside it stayed the size it was drawn at in 2003, and what growth there was stopped dead at twice - so on a 2560 wide screen a command bar three times its original size still wore eight point lettering. The keys on the build buttons, the prices and the build times were the worst of it: at 2K they were drawn, and unreadable.- The strip of everything your base is building follows the screen too, instead of staying a row of postage stamps under a command bar three times its size.-- On a widescreen monitor the command bar is three pieces instead of one stretched strip. It was drawn for a 4:3 screen and every measurement in it is multiplied by your resolution separately across and down, so at 16:9 the whole thing came out a third wider than it is tall: square build pictures as rectangles, and one slab of metal across the entire bottom edge. The radar now sits hard in the left corner, the build grid in the middle, the selected unit's panel hard in the right corner, each at the size it was drawn at, and the battlefield shows through the two gaps that opens. At 4:3 the three pieces meet and it is the bar it has always been. The three pieces reach the screen: the paintings stop a pixel or two inside their own edges, which left a hairline of ground down both sides and along the bottom, and anything that close to an edge is now that edge. The American middle piece stands on the bottom edge like the other two sides' do, instead of hanging ten units high with a band of battlefield under the build grid.+- On a widescreen monitor the command bar is three pieces instead of one stretched strip. It was drawn for a 4:3 screen and every measurement in it is multiplied by your resolution separately across and down, so at 16:9 the whole thing came out a third wider than it is tall: square build pictures as rectangles, and one slab of metal across the entire bottom edge. The radar now sits hard in the left corner, the build grid in the middle, the selected unit's panel hard in the right corner, each at the size it was drawn at, and the battlefield shows through the two gaps that opens. At 4:3 the three pieces meet and it is the bar it has always been. The three pieces reach the screen: the paintings stop a pixel or two inside their own edges, which left a hairline of ground down both sides and along the bottom, and anything that close to an edge is now that edge. The American middle piece stands on the bottom edge like the other two sides' do, instead of hanging ten units high with a band of battlefield under the build grid, and your money now sits in the middle of its readout instead of riding the top rim of it. A one-pixel light line that stood off the right edge of that same piece at 1920x1080, from the top of the frame to the bottom, is gone too.- Widescreen resolutions are back in the options menu.- Borderless fullscreen: start with `-borderless` and the game fills the screen at your desktop resolution with no frame and no display mode change, so alt-tab is instant, nothing on the desktop gets shuffled around behind it, and a second monitor stays usable. Screen-edge scrolling works there, the way it does in fullscreen. The loading picture still opens as its own small window with your desktop around it, and the game only takes the screen once it has something to draw.- Fullscreen, borderless and windowed are one saved setting now, so borderless no longer means adding a switch to your shortcut every time. `WindowMode` in `Options.ini` takes 0, 1 or 2 in that order; a switch on the command line still wins for that one run.diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex a93fec8ff..5cebb691e 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -1283,6 +1283,7 @@ struct ControlBarPlate{const char *filename; ///< the targa, which is all the Image needsIRegion2D design; ///< the 800x600 rectangle of the painting this piece is+ Int readoutShiftY; ///< design units the money readout moves to sit in this art's box};/** The plate 'panel' wears while the bar is dressed in 'side'. A general's scheme names a sidediff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 55805835a..269df6752 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -1446,10 +1446,13 @@ static const ControlBarPlateSet thePlateSets[] ={ "America",{{ "RebornBarAmericaLeft.tga", { { 0, 412 }, { 183, 599 } } },- // the drawing registers at its bottom edge, which is the bottom of the bar - hung from its- // top instead it sat ten units high, showing ground under the grid and starting higher- // than the Chinese (433) and GLA (437) centre pieces do- { "RebornBarAmericaCenter.tga", { { 180, 429 }, { 623, 599 } } },+ /* This painting is 170 design units tall for a 180-unit slot, and it is the plate's own+ composition rather than a straight cut of the shipped bar: its grid field lines up with+ the command buttons (494-589) exactly where it stands, and its money box does not line+ up with the scheme's readout. So it stands on the bottom of the screen, where a plate+ belongs, and the readout moves the ten units down into the box - the box's dark+ interior measures 448.5 to 465.4, and the 19-unit readout centres on 457. */+ { "RebornBarAmericaCenter.tga", { { 180, 429 }, { 623, 599 } }, 10 },{ "RebornBarAmericaRight.tga", { { 610, 433 }, { 800, 599 } } },}},@@ -1547,6 +1550,20 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,// well as holding the command windows, and is authored full width, so it gets the same// treatment - left alone it would swallow every click over the gaps we just opened up.//+ //+ // A plate is its side's own painting, not a cut of the shipped one, so where it draws the money+ // box is the plate's business and not ControlBarScheme.ini's. Where the two disagree the plate+ // says by how much and the readout follows the art - see ControlBarPlate::readoutShiftY.+ //+ if( strcmp( shortName, "MoneyDisplay" ) == 0 && m_controlBarSchemeManager )+ {+ const ControlBarPlate *plate = ControlBarPlateForSide( m_controlBarSchemeManager->getCurrentSide(), panel );+ if( plate == NULL )+ plate = ControlBarPlateForSide( m_controlBarSchemeManager->getCurrentArtTwinSide(), panel );+ if( plate )+ newY += REAL_TO_INT_FLOOR( plate->readoutShiftY * s );+ }+if( shortName[ 0 ] == 0 || strcmp( shortName, "CenterBackground" ) == 0 ){newX = m_panelRect[ panel ].lo.x;diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cppindex 5ddabafe7..8c6373b28 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp@@ -653,12 +653,22 @@ static const Image *plateImage( const ControlBarPlate *plate )image->setName( name );image->setFilename( name );- // the whole targa is the image, so there is nothing to look up and no page to share+ //+ // The whole targa is the image, so there is nothing to look up and no page to share. Not quite+ // the whole targa, though: the last pixel column the quad draws samples the texture's outermost+ // texel, and on the American centre plate that came out as a one-pixel light line standing off+ // the plate's right edge, from the top of the frame to the bottom, over rows the painting leaves+ // transparent. Drawing the plate with the centre panel skipped removed it, so it is this draw+ // and nothing behind it. Stopping a texel and a half short of each edge keeps the sampler off+ // that column; the painting's own edges are transparent or a rim of bezel, so nothing is lost.+ //+ const Real insetX = 1.5f / (Real)( plate->design.width() * 1.6f ); // the targas are ~1.6 texels per design unit+ const Real insetY = 1.5f / (Real)( plate->design.height() * 1.6f );Region2D uv;- uv.lo.x = 0.0f;- uv.lo.y = 0.0f;- uv.hi.x = 1.0f;- uv.hi.y = 1.0f;+ uv.lo.x = insetX;+ uv.lo.y = insetY;+ uv.hi.x = 1.0f - insetX;+ uv.hi.y = 1.0f - insetY;image->setUV( &uv );ICoord2D size;diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 8b9074115..1dde67a37 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -7844,6 +7844,35 @@ TEST(a_plate_covers_the_windows_its_panel_is_responsible_for)}}+TEST(the_money_readout_follows_the_plate_that_paints_its_box)+{+ /* A plate is its side's own painting rather than a cut of the shipped bar, so the money box is+ where the plate draws it and not where ControlBarScheme.ini puts the readout. On the American+ centre plate the two are ten design units apart: the box's dark interior measures 448.5 to+ 465.4 and the readout is 19 units tall, so it centres on 457 - ten below the scheme's 447.5.+ China and GLA draw their boxes where the scheme expects and shift nothing. */+ struct Expect { const char *side; Int shift; };+ static const Expect expected[] =+ {+ { "America", 10 }, { "China", 0 }, { "GLA", 0 }, { NULL, 0 }+ };++ // what ControlBarScheme.ini gives the readout, before any plate has its say+ const Int schemeTop = 438, schemeBottom = 457;++ for( const Expect *e = expected; e->side; e++ )+ {+ const ControlBarPlate *plate = ControlBarPlateForSide( AsciiString( e->side ), ControlBar::CB_PANEL_CENTER );+ CHECK( plate != NULL );+ CHECK_EQ( plate->readoutShiftY, e->shift );++ // wherever it ends up, the readout has to land on the plate rather than off the top or the+ // bottom of it - a shift big enough to hang it in the battlefield is the failure to catch+ CHECK( schemeTop + plate->readoutShiftY >= plate->design.lo.y );+ CHECK( schemeBottom + plate->readoutShiftY <= plate->design.hi.y );+ }+}+TEST(every_plate_that_touches_a_design_edge_touches_the_screen_edge){/* The plate rectangles were measured against the paintings, and a painting stops a pixel or two