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): slide director panes by camera and hold pane 0 as they go
Olcay Seygan3ef3ba4c9f85
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.hindex 555473258..268799d4a 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h@@ -205,8 +205,6 @@ public:const Real *getPaneRays( void ) const { return m_paneRays; }/// where the rays meet on the screen, in pixels, which slides in from off the screen and back outCoord2D getPaneOrigin( void ) const { return m_paneOrigin; }- /// how far a pane's picture past the first is moved with the meeting point, in pixels- Coord2D getPaneShift( void ) const;/// how far the radar in the bottom left corner is slid out to the left, 0 to 1Real getCornerRadarSlide( void ) const { return m_cornerRadarSlide; }/// the radar framed on the rays' meeting point, pane 0's, while there are panes; its middle comes@@ -280,6 +278,8 @@ private:UnsignedInt m_panePhaseStart; ///< the logic frame the phase began onBool m_intro; ///< the panes are the match's opening, one a playerBool m_introDone;+ Bool m_introGlide; ///< the opening has gone and the camera glides to the director's place, however far+ Coord2D m_panesLeftPlace; ///< pane 0's place while its panes are up, kept as they goInt m_paneCount; ///< 0 with no panesReal m_paneRays[ OBSERVER_MOST_PANES ];Real m_paneProgress; ///< 0 for no panes on the screen, 1 for all of them, easeddiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cppindex 342165d05..3aaf8ca06 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp@@ -566,6 +566,8 @@ void ObserverCamera::reset( void )m_panePhaseStart = 0;m_intro = FALSE;m_introDone = FALSE;+ m_introGlide = FALSE;+ m_panesLeftPlace.x = m_panesLeftPlace.y = 0.0f;m_paneCount = 0;m_paneProgress = 0.0f;m_paneExit = 0.0f;@@ -906,7 +908,10 @@ void ObserverCamera::advancePanes( UnsignedInt frame )break;case PANES_OUT:if( elapsed >= PANE_SLIDE_FRAMES )+ {next = PANES_RADAR_IN;+ m_introGlide = m_intro;+ }break;case PANES_RADAR_IN:if( elapsed >= PANE_RADAR_FRAMES )@@ -994,7 +999,9 @@ void ObserverCamera::updateIntroPlaces( void )//-------------------------------------------------------------------------------------------------/** Each pane past the first glides to its subject on its own, and its camera sits back from the- * subject by the pane's middle, so the subject is in the middle of its pane. Angle, pitch and zoom+ * subject by the pane's middle, so the subject is in the middle of its pane. While the rays' meeting+ * point slides, the camera sits back by that much more, so the pane's picture slides with it and+ * is the world on the whole screen, with no edge of a moved picture to show. Angle, pitch and zoom* are the main camera's. *///-------------------------------------------------------------------------------------------------void ObserverCamera::stepPaneCameras( const ViewLocation &step, Real elapsedSeconds )@@ -1025,8 +1032,8 @@ void ObserverCamera::stepPaneCameras( const ViewLocation &step, Real elapsedSeco}Coord2D fromMiddle;- fromMiddle.x = middles[ pane ].x - TheDisplay->getWidth() * 0.5f;- fromMiddle.y = middles[ pane ].y - TheDisplay->getHeight() * 0.5f;+ fromMiddle.x = middles[ pane ].x + m_paneOrigin.x - TheDisplay->getWidth();+ fromMiddle.y = middles[ pane ].y + m_paneOrigin.y - TheDisplay->getHeight();const Coord2D offset = screenToGround( step, fromMiddle );Coord2D camera;camera.x = m_paneGlide[ pane ].getPosition().x - offset.x;@@ -1036,15 +1043,6 @@ void ObserverCamera::stepPaneCameras( const ViewLocation &step, Real elapsedSeco}}-//--------------------------------------------------------------------------------------------------Coord2D ObserverCamera::getPaneShift( void ) const-{- Coord2D shift;- shift.x = m_paneOrigin.x - TheDisplay->getWidth() * 0.5f;- shift.y = m_paneOrigin.y - TheDisplay->getHeight() * 0.5f;- return shift;-}-//-------------------------------------------------------------------------------------------------/** On the meeting point when the panes are all in, and far enough out along its way off the screen,* the radar's own size further, that none of it shows when they have gone. */@@ -1285,9 +1283,16 @@ Bool ObserverCamera::chooseTarget( const ViewLocation ¤t, ViewLocation *tareturn FALSE;if( TheGlobalData->m_directorRecord && m_placeScanned == TheGameLogic->getFrame() )updateSplit();- // the opening shows the first player's base in pane 0 until the panes start to go+ // the opening shows the first player's base in pane 0. Pane 0 keeps its place until the panes+ // have gone: a split ends when the director moves onto the second fight, and pane 0 going there at+ // once showed that fight twice while pane 1 slid outif( m_intro && m_panePhase == PANES_HELD )place = m_paneSubject[ 0 ];+ const Bool panesUp = m_panePhase == PANES_IN || m_panePhase == PANES_HELD || m_panePhase == PANES_OUT;+ if( panesUp && ( m_panePhase == PANES_OUT || ( !m_split && !m_intro ) ) )+ place = m_panesLeftPlace;+ else+ m_panesLeftPlace = place;place = keepInMap( place, current );target->init( place.x, place.y, at.z, current.getAngle(), current.getPitch(), current.getZoom() );return TRUE;@@ -1370,6 +1375,23 @@ void ObserverCamera::update( UnsignedInt nowMilliseconds )const Coord3D &camera = current.getPosition();ViewLocation subject;subject.init( camera.x + m_mainOffset.x, camera.y + m_mainOffset.y, camera.z, current.getAngle(), current.getPitch(), current.getZoom() );+ // from the opening's last player to the director's first place is a glide whatever the distance,+ // on a target kept just inside the cut distance until the real one is+ if( m_introGlide )+ {+ const Real dx = target.getPosition().x - subject.getPosition().x;+ const Real dy = target.getPosition().y - subject.getPosition().y;+ const Real distance = sqrtf( dx * dx + dy * dy );+ const Real glideReach = CUT_DISTANCE * 0.9f;+ if( distance > glideReach )+ {+ const Real share = glideReach / distance;+ target.init( subject.getPosition().x + dx * share, subject.getPosition().y + dy * share, target.getPosition().z,+ target.getAngle(), target.getPitch(), target.getZoom() );+ }+ else+ m_introGlide = FALSE;+ }const Bool player = m_mode == OBSERVER_CAMERA_PLAYER;const ViewLocation step = ObserverCamera_approach( subject, target, elapsed / MILLISECONDS_PER_SECOND,player ? PLAYER_PAN_SECONDS : DIRECTOR_PAN_SECONDS, player ? PLAYER_TOP_SPEED : DIRECTOR_TOP_SPEED, &m_velocity );diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cppindex 8abe38662..16c6c575b 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp@@ -4299,7 +4299,8 @@ static Bool openVideoPipe(Int width, Int height)#endif/** -directorrecord's panes joined into pane 0's picture: each pixel is taken from the pane whose wedge- * it lies in, moved with the rays' meeting point. Pane 0 keeps the framed radar and a band along every+ * it lies in. A pane's camera already slid its picture with the rays' meeting point, so the copy is+ * pixel for pixel; moving the pixels instead read past a picture's edge and smeared it. Pane 0 keeps the framed radar and a band along every* seam, where only its draw has the line. A pane with no picture of this frame and size stays pane* 0's. */static void joinVideoPanes(char *rows, Int width, Int height, UnsignedInt frame)@@ -4308,9 +4309,6 @@ static void joinVideoPanes(char *rows, Int width, Int height, UnsignedInt frame)const Int count = TheObserverCamera.getDrawnPaneCount();const Real *rays = TheObserverCamera.getPaneRays();const Coord2D origin = TheObserverCamera.getPaneOrigin();- const Coord2D shift = TheObserverCamera.getPaneShift();- const Int shiftX = REAL_TO_INT(shift.x);- const Int shiftY = REAL_TO_INT(shift.y);const IRegion2D &radar = TheObserverCamera.getRadarFrame();if (s_videoPaneMapSize != width * height)@@ -4343,9 +4341,8 @@ static void joinVideoPanes(char *rows, Int width, Int height, UnsignedInt frame)if (s_videoPaneMap[y * width + left] != pane || s_videoPaneMap[y * width + right] != pane|| s_videoPaneMap[up * width + x] != pane || s_videoPaneMap[down * width + x] != pane)continue;- const Int fromX = min(max(x - shiftX, 0), width - 1);- const Int fromY = min(max(y - shiftY, 0), height - 1);- memcpy(rows + (y * width + x) * 3, s_videoHeld[pane] + (fromY * width + fromX) * 3, 3);+ const Int at = (y * width + x) * 3;+ memcpy(rows + at, s_videoHeld[pane] + at, 3);}}}diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cppindex 223e43023..80c05fab4 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp@@ -441,9 +441,8 @@ void W3DInGameUI::draw( void )if( CinemaDirector_hidesHud() ){// -directorrecord's panes: the rays between them, from where they meet to past the screen's- // edge, drawn in pane 0's draw alone. The other panes' pictures are moved with the meeting- // point when they are joined, which would carry a line of theirs off the seam; the join takes- // a band along every seam from pane 0, line and all+ // edge, drawn in pane 0's draw alone; the join takes a band along every seam from pane 0, line+ // and allconst Bool framed = TheObserverCamera.isRadarFramed();IRegion2D noFrame;noFrame.lo.x = noFrame.lo.y = noFrame.hi.x = noFrame.hi.y = 0;