Skip to content

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.

feat(gameengine): end a handed-over split on pane 1 without a cut

Olcay Seygan21f948265e17
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 47c8f0baa..29b2838a3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -749,7 +749,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- Watching, the bars over the buildings are everyone's too - what each factory is turning out, and how long the superweapons have left. An observer used to see none of it.
- Watching, the camera can drive itself. Two drop-downs in the camera panel on the right, above the board, say who has it and which player you follow, and you can follow nobody. The Director goes to the fight with the most on the line over the last five seconds, where a dead Overlord counts for more than six riflemen being shot at and anything happening to a superweapon counts three times over. It stays with that fight twelve seconds, leaves after six only for one four times the size, and after half a minute on the same fight a third bigger is enough. So a 4v4 is watched like a broadcast rather than hunted for, and it does not hop between spots every few seconds. Any general's power used on the map outranks every fight. A nuke is shown in its silo as it leaves, then the camera waits at the target for it to come down and stays through the blast. The particle cannon's beam is followed along its whole sweep, and a Scud Storm or a carpet bomb is watched until the last explosion has died down. Then it goes back to the fighting. The camera glides between places and slows into each one, and only cuts when the next one is across most of the map. When nobody is shooting it no longer parks on empty ground: it goes round what is worth seeing, an army on the march, a superweapon, a base going up, the rest of a base, the dearest first and fourteen seconds each, and does not come back to one of the last three while there is anything else to show. With a player picked it keeps to his fights and his own armies and buildings. Player camera shows his screen: a human player's camera comes over the network five times a second, smoothed in between, and a computer player, who has no camera, gets the Director narrowed to his own fights. Scroll with the keys or a drag, turn the view or click the radar and the camera is yours again, still following the same player. The edge of the screen does not scroll while it drives: the panel on the right stands on that edge, and reaching for it used to hand the camera back to you, so the Director stopped following the fighting the first time you went to change a setting. In a replay with the recorded camera switched on in the options, the player you follow still drives the camera the way his button in the old list did.
- Watching, the Director climbs over a wide battle until the whole of it is on the screen, and comes back down to your own height when it moves on or you take the camera. The mouse wheel still zooms while it drives, and it keeps what you chose. It stops short of the map's border too, where a fight on the edge used to come with a black corner of nothing beside it. A nuke or a Scud Storm is shown leaving its silo even when the Director has only just arrived at another fight; before, the launch was over by the time it was allowed to move. Rewinding a replay leaves your camera settings as they were, where a rewind used to hand you back a free camera with nobody followed. And following one player while a superweapon wiped out everything he had at the spot could close the game. It no longer does.
-- Watching can be filmed. Start the game with `-directorrecord` and the Director has the camera from the first second, with nothing over the picture but the radar, and the whole match goes into one video; the game closes itself when the match is decided or the replay runs out. Beside `-replay` it turns an old match into footage, and beside four computer players it films a match nobody played. It plays the match twice. The first time there is no picture and the game runs as fast as the machine goes, 8,000 frames of a four-player match in 17 seconds, writing down where each fight starts and when each superweapon fires; the second time it films, and the camera is already at a fight four seconds before the first shot instead of arriving halfway through it. When two fights are about to start far apart the screen splits three seconds before the second begins, and only when the first run saw the Director's own fight go on for the whole time the split will be up, so the second picture never sweeps in and straight back out. A skirmish the first run saw come to nothing is not cut to, and neither is a special power that hurts nobody: an Air Force general's spy satellite every minute used to pull the camera to empty ground, where a carpet bomb or an artillery strike still gets it from the launch. Each half keeps its own fight. The main camera used to leave for the second half's fight as it began, and the two halves glided past each other over empty ground and swapped places; now it takes that fight over only once its own is finished, and the second half closes as it does. The two runs compare the whole state of the game every 30 seconds, and if they ever disagree the rest is filmed the old way, finding fights as they happen. A skirmish without `-seed` is handed one, the same for both runs. The film opens on every player at once: the screen cut into one picture per player along lines at 45 degrees that meet round the radar, two players on a diagonal and four on an X, each picture on that player's base. Seven seconds in they sweep away to the Director's single view, which stays on the first player's base until something happens instead of gliding across empty ground to another one. When two real fights far apart are both worth watching, the radar slides out of its corner, then the second fight sweeps in from the corner along a 45 degree diagonal, carrying the radar in a frame of the same line to the middle, one fight on each side with its own camera gliding to it. Going back is the same film run backwards: the second fight sweeps out with the radar, and the radar slides back into its corner. The lines are the Reforged gold on a dark edge, so they read on snow and at night, and they run straight into the radar's frame. Under each line and round the radar lies a soft band of the Reforged blue. The pictures slide into place first, and only then does the gold draw out from where the lines meet, over most of a second, with the band fading in behind it and the radar's frame tracing its gold round the map once the radar has arrived; going out, the gold pulls back in before the pictures leave. The opening plays it the same way from the first player's full view. While the screen stays cut a bright white-gold light runs out along every line every five seconds, the opening included. At first all of this ran inside the half second the pictures take to slide, and on film the lines were already whole by the third frame. While the screen is cut, each picture frames its own fight: the camera puts it in the biggest round space its slice has clear of the lines and the radar, and rises until the whole fight fits there with room to spare, never lower than the Director flies and never more than three times as high. A fight that spreads is let out smoothly; one that shrinks does not make the picture pump in and out. The single view rises and settles over a second and a half when it reaches a fight, where it used to glide in for seconds and then step back up in a third of one, and the hand-over between the cut screen and the single view is one camera: the opening's last picture used to jump sideways about fifty paces the moment it became the Director's. The opening frames each player's base the same way. A split holds at least six seconds after its second picture is all the way in and ends once the second fight has burnt down to a quarter of the first, and the picture then stays whole four seconds even for a fight the first run saw coming, so it does not flicker between one and two. The two fights have to be further apart than either half's picture is wide once it has risen to fit its fight, so no piece of ground shows in both: at a fixed 660 the two halves of a 1v1 showed the same bridge from neighbouring angles. A crowd beside the Director's fight that the first run saw as part of it does not split the screen either; that was the Director's own fight spreading, and the second half swept in for two seconds before the camera followed it there. Only the video shows the other pictures; the window keeps the Director's own fight under the lines. Two bases going up are not a fight, and the split ends the moment the camera's own fight and the second one turn out to be the same. The pictures go straight into ffmpeg as they are drawn, so an hour of 1080p does not need tens of gigabytes of disk first; put ffmpeg beside the game or on your PATH, because without it nothing is recorded and the game says so and closes. The film carries a score bar across the top in the Reforged colours, the match clock in a tab over it and every side in one row, "Team A vs Team B vs" a player alone: a card a player, his colour along its top, his name in that colour, his general (a computer player goes by his general with his difficulty under it, where every one of them used to read "Hard AI"), then his cash and what his army cost, each beside its label so the two never get mixed up. A team's cards sit together under its name and its army's total. Under the whole row is one bar the armies pull on, each player's share in his colour and a gold mark at the middle when two sides play, so whoever is past it is ahead. The type gets smaller as players are added, and eight alone or a 4v4 fill the width of a 720p picture without running off it. A dark colour like purple is lightened where it is text, so it reads on the bar's ground, and the gold player's colour gets a dark edge two pixels wide even at 720p so it does not melt into the gold lines. A skirmish can be staged in any shape now, 4v1 or three players alone beside a pair: `-team 4 0` puts slot 4 on team 0. The opening seats teammates next to each other and names their team on their plates, and a split names a team as "Team A" where a player alone keeps his own name. Each picture of the opening names its player on a plate hanging just over his command centre, and the plate stays on the building as the camera rises and the pictures sweep away. The name sits over his general and team in smaller type, and the plate stays wholly inside its picture: in an eight-player opening the lines used to cut it down to "ank General Team A", and in a 4v1 the top one hid under the score bar. Each half of a split names the players in its fight, in a plate inside its own slice clear of the lines and the radar, and while the halves sweep in it rides above its fight, where it used to slide down over it. It is sized from the screen's height and reads the same at 720p and 1080p, and the pictures under it are framed below it, so no base or fight sits behind the bar. Any recorded clip also plays its animations at their real speed now. The animation clock used to move by however long each picture took to save, and a slow disk made every explosion in the footage run fast.
+- Watching can be filmed. Start the game with `-directorrecord` and the Director has the camera from the first second, with nothing over the picture but the radar, and the whole match goes into one video; the game closes itself when the match is decided or the replay runs out. Beside `-replay` it turns an old match into footage, and beside four computer players it films a match nobody played. It plays the match twice. The first time there is no picture and the game runs as fast as the machine goes, 8,000 frames of a four-player match in 17 seconds, writing down where each fight starts and when each superweapon fires; the second time it films, and the camera is already at a fight four seconds before the first shot instead of arriving halfway through it. When two fights are about to start far apart the screen splits three seconds before the second begins, and only when the first run saw the Director's own fight go on for the whole time the split will be up, so the second picture never sweeps in and straight back out. A skirmish the first run saw come to nothing is not cut to, and neither is a special power that hurts nobody: an Air Force general's spy satellite every minute used to pull the camera to empty ground, where a carpet bomb or an artillery strike still gets it from the launch. Each half keeps its own fight. The main camera used to leave for the second half's fight as it began, and the two halves glided past each other over empty ground and swapped places; now it takes that fight over only once its own is finished, and the second half closes as it does. The two runs compare the whole state of the game every 30 seconds, and if they ever disagree the rest is filmed the old way, finding fights as they happen. A skirmish without `-seed` is handed one, the same for both runs. The film opens on every player at once: the screen cut into one picture per player along lines at 45 degrees that meet round the radar, two players on a diagonal and four on an X, each picture on that player's base. Seven seconds in they sweep away to the Director's single view, which stays on the first player's base until something happens instead of gliding across empty ground to another one. When two real fights far apart are both worth watching, the radar slides out of its corner, then the second fight sweeps in from the corner along a 45 degree diagonal, carrying the radar in a frame of the same line to the middle, one fight on each side with its own camera gliding to it. Going back is the same film run backwards: the second fight sweeps out with the radar, and the radar slides back into its corner. The lines are the Reforged gold on a dark edge, so they read on snow and at night, and they run straight into the radar's frame. Under each line and round the radar lies a soft band of the Reforged blue. The pictures slide into place first, and only then does the gold draw out from where the lines meet, over most of a second, with the band fading in behind it and the radar's frame tracing its gold round the map once the radar has arrived; going out, the gold pulls back in before the pictures leave. The opening plays it the same way from the first player's full view. While the screen stays cut a bright white-gold light runs out along every line every five seconds, the opening included. At first all of this ran inside the half second the pictures take to slide, and on film the lines were already whole by the third frame. While the screen is cut, each picture frames its own fight: the camera puts it in the biggest round space its slice has clear of the lines and the radar, and rises until the whole fight fits there with room to spare, never lower than the Director flies and never more than three times as high. A fight that spreads is let out smoothly; one that shrinks does not make the picture pump in and out. The single view rises and settles over a second and a half when it reaches a fight, where it used to glide in for seconds and then step back up in a third of one, and the hand-over between the cut screen and the single view is one camera: the opening's last picture used to jump sideways about fifty paces the moment it became the Director's. When the Director moves onto the second half's fight, that half is the one that stays: it widens to fill the screen and carries straight on as the single view, where the other half used to fill the screen and the camera then cut across the map. The opening frames each player's base the same way. A split holds at least six seconds after its second picture is all the way in and ends once the second fight has burnt down to a quarter of the first, and the picture then stays whole four seconds even for a fight the first run saw coming, so it does not flicker between one and two. The two fights have to be further apart than either half's picture is wide once it has risen to fit its fight, so no piece of ground shows in both: at a fixed 660 the two halves of a 1v1 showed the same bridge from neighbouring angles. A crowd beside the Director's fight that the first run saw as part of it does not split the screen either; that was the Director's own fight spreading, and the second half swept in for two seconds before the camera followed it there. Only the video shows the other pictures; the window keeps the Director's own fight under the lines. Two bases going up are not a fight, and the split ends the moment the camera's own fight and the second one turn out to be the same. The pictures go straight into ffmpeg as they are drawn, so an hour of 1080p does not need tens of gigabytes of disk first; put ffmpeg beside the game or on your PATH, because without it nothing is recorded and the game says so and closes. The film carries a score bar across the top in the Reforged colours, the match clock in a tab over it and every side in one row, "Team A vs Team B vs" a player alone: a card a player, his colour along its top, his name in that colour, his general (a computer player goes by his general with his difficulty under it, where every one of them used to read "Hard AI"), then his cash and what his army cost, each beside its label so the two never get mixed up. A team's cards sit together under its name and its army's total. Under the whole row is one bar the armies pull on, each player's share in his colour and a gold mark at the middle when two sides play, so whoever is past it is ahead. The type gets smaller as players are added, and eight alone or a 4v4 fill the width of a 720p picture without running off it. A dark colour like purple is lightened where it is text, so it reads on the bar's ground, and the gold player's colour gets a dark edge two pixels wide even at 720p so it does not melt into the gold lines. A skirmish can be staged in any shape now, 4v1 or three players alone beside a pair: `-team 4 0` puts slot 4 on team 0. The opening seats teammates next to each other and names their team on their plates, and a split names a team as "Team A" where a player alone keeps his own name. Each picture of the opening names its player on a plate hanging just over his command centre, and the plate stays on the building as the camera rises and the pictures sweep away. The name sits over his general and team in smaller type, and the plate stays wholly inside its picture: in an eight-player opening the lines used to cut it down to "ank General Team A", and in a 4v1 the top one hid under the score bar. Each half of a split names the players in its fight, in a plate inside its own slice clear of the lines and the radar, and while the halves sweep in it rides above its fight, where it used to slide down over it. It is sized from the screen's height and reads the same at 720p and 1080p, and the pictures under it are framed below it, so no base or fight sits behind the bar. Any recorded clip also plays its animations at their real speed now. The animation clock used to move by however long each picture took to save, and a slow disk made every explosion in the footage run fast.
- Watching, tick Fog of war under the camera and you see what the player you follow sees and nothing more: black where he has never been, grey where he has been, none of the enemy he cannot see, and an enemy base as he last saw it. Stealth goes by his eyes too: a Jarmen Kell he has not found is gone from the screen and the radar, and his own stealthed units show the way they show him. It stays on whoever drives the camera, until you switch it off or follow nobody. Switch to another player and his fog comes in whole, shadows included: a building he has never seen casts nothing on his grey ground. An observer used to have no fog at all: the whole map, all match, with no way to see the game the way one of its players was seeing it.
- An ally, and anyone watching, now sees a stealthed unit's muzzle flash, its promotion and the cash it earns - if they can see the unit at all. Those three asked 'is it mine' instead of 'can I see it', so allies and observers got nothing.
- Watching, the match opens on the middle of the map. An observer has no start position, so the game looked for the camera waypoint of "player zero", did not find it, and fell back to the corner of the map: every match watched from the stands began pointed at empty ground in the south west.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h
index 0f7d68a59..a17cc0c19 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h
@@ -454,6 +454,8 @@ private:
Real m_lastZoom; ///< the view's zoom at the last update, for the zoom jump log
Bool m_lastCut; ///< the last update cut
UnsignedInt m_handoverLogUntil; ///< the frame the per-frame hand-over log stops at
+ Int m_paneSurvivor; ///< the pane that fills the screen as the panes go out: 1 when the split ended on the director taking pane 1's fight
+ Bool m_survivorHandover; ///< the panes have just gone out on pane 1, whose camera the single view takes over this update
Coord3D m_drivenTo; ///< where this put the camera last frame, inside the view's constraint
UnsignedInt m_lastUpdate;
ObserverCameraVelocity m_velocity;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp
index f44a68564..1d89fb53b 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp
@@ -1202,6 +1202,8 @@ void ObserverCamera::reset( void )
m_lastZoom = 0.0f;
m_lastCut = FALSE;
m_handoverLogUntil = 0;
+ m_paneSurvivor = 0;
+ m_survivorHandover = FALSE;
m_drivenTo.zero();
m_lastUpdate = 0;
m_velocity.x = m_velocity.y = m_velocity.z = m_velocity.angle = m_velocity.pitch = m_velocity.zoom = 0.0f;
@@ -1819,6 +1821,10 @@ void ObserverCamera::updateSplit( void )
m_split = split;
m_splitChanged = frame;
m_splitApart = needed;
+ // the director has gone over to pane 1's fight: pane 1 is the picture that stays, and the panes
+ // go out towards pane 0's side, where pane 0 used to fill the screen and the camera then cut
+ // across the map to the fight pane 1 had been showing
+ m_paneSurvivor = !split && handedOver && !m_intro ? 1 : 0;
}
if( m_split )
m_secondPlace = shown;
@@ -1929,6 +1935,9 @@ void ObserverCamera::advancePanes( UnsignedInt frame )
{
next = PANES_RADAR_IN;
m_introGlide = m_intro;
+ // pane 1 fills the screen: from here pane 0 does, with pane 1's camera, which update hands it
+ m_survivorHandover = m_paneSurvivor == 1;
+ m_paneSurvivor = 0;
}
break;
case PANES_RADAR_IN:
@@ -1994,9 +2003,12 @@ void ObserverCamera::advancePanes( UnsignedInt frame )
m_paneOrigin.y = TheDisplay->getHeight() * 0.5f;
if( m_paneCount >= 2 )
{
+ // pane 1 staying, the meeting point leaves the other way, and a split's two wedges are mirror
+ // images, so the same distance leaves pane 1 holding the whole screen
const Coord2D away = ObserverCamera_paneExitDirection( m_paneRays );
- m_paneOrigin.x += away.x * ( 1.0f - m_paneProgress ) * m_paneExit;
- m_paneOrigin.y += away.y * ( 1.0f - m_paneProgress ) * m_paneExit;
+ const Real side = m_paneSurvivor == 1 ? -1.0f : 1.0f;
+ m_paneOrigin.x += side * away.x * ( 1.0f - m_paneProgress ) * m_paneExit;
+ m_paneOrigin.y += side * away.y * ( 1.0f - m_paneProgress ) * m_paneExit;
}
}
@@ -2191,8 +2203,8 @@ void ObserverCamera::stepPaneCameras( const ViewLocation &step, Real elapsedSeco
// the circle's centre moved with the meeting point; it only ever slides down the screen, away
// from the horizon, so the projection holds off the screen too
Coord2D pixel;
- pixel.x = m_paneCentres[ pane ].x + m_paneOrigin.x - TheDisplay->getWidth() * 0.5f;
- pixel.y = m_paneCentres[ pane ].y + m_paneOrigin.y - TheDisplay->getHeight() * 0.5f;
+ Real radius = 0.0f;
+ getPaneCircle( pane, &pixel, &radius );
Coord2D glided;
glided.x = m_paneGlide[ pane ].getPosition().x;
glided.y = m_paneGlide[ pane ].getPosition().y;
@@ -2208,7 +2220,8 @@ void ObserverCamera::stepPaneCameras( const ViewLocation &step, Real elapsedSeco
Coord2D ObserverCamera::getFramedRadarMiddle( Real radarDiagonal ) const
{
const Coord2D away = ObserverCamera_paneExitDirection( m_paneRays );
- const Real out = ( 1.0f - m_paneProgress ) * ( m_paneExit + radarDiagonal );
+ const Real side = m_paneSurvivor == 1 ? -1.0f : 1.0f;
+ const Real out = side * ( 1.0f - m_paneProgress ) * ( m_paneExit + radarDiagonal );
Coord2D middle;
middle.x = TheDisplay->getWidth() * 0.5f + away.x * out;
middle.y = TheDisplay->getHeight() * 0.5f + away.y * out;
@@ -2237,10 +2250,10 @@ void ObserverCamera::getPaneCircle( Int pane, Coord2D *centre, Real *radius ) co
{
const Real middleX = TheDisplay->getWidth() * 0.5f;
const Real middleY = TheDisplay->getHeight() * 0.5f;
- if( pane == 0 )
+ if( pane == 0 || pane == m_paneSurvivor )
{
- centre->x = middleX + ( m_paneCentres[ 0 ].x - middleX ) * m_paneProgress;
- centre->y = middleY + ( m_paneCentres[ 0 ].y - middleY ) * m_paneProgress;
+ centre->x = middleX + ( m_paneCentres[ pane ].x - middleX ) * m_paneProgress;
+ centre->y = middleY + ( m_paneCentres[ pane ].y - middleY ) * m_paneProgress;
}
else
{
@@ -2733,6 +2746,14 @@ void ObserverCamera::logHandover( const ViewLocation &step, const ViewLocation &
TheTacticalView->worldToScreenTriReturn( &world, &pixel );
DEBUG_LOG(( "OBSCAM frame %u hand look (%.1f,%.1f) zoom %.3f subject (%.1f,%.1f) at (%d,%d)\n", frame,
placed.getPosition().x, placed.getPosition().y, TheTacticalView->getZoom(), world.x, world.y, pixel.x, pixel.y ));
+ if( m_paneCount < 2 )
+ return;
+ Coord2D circle;
+ Real radius = 0.0f;
+ getPaneCircle( 1, &circle, &radius );
+ DEBUG_LOG(( "OBSCAM frame %u hand pane 1 look (%.1f,%.1f) zoom %.3f subject (%.1f,%.1f) at (%.0f,%.0f)\n", frame,
+ m_paneView[ 1 ].getPosition().x, m_paneView[ 1 ].getPosition().y, m_paneView[ 1 ].getZoom(),
+ m_paneGlide[ 1 ].getPosition().x, m_paneGlide[ 1 ].getPosition().y, circle.x, circle.y ));
}
//-------------------------------------------------------------------------------------------------
@@ -2779,6 +2800,20 @@ void ObserverCamera::update( UnsignedInt nowMilliseconds )
pickIntroBases();
if( m_intro && ( introStarting || frame % DIRECTOR_SCAN_FRAMES == 0 ) )
updateIntroPlaces();
+ // pane 1 went out holding the whole screen: the single view takes its camera, its subject and
+ // its glide as they stand, and goes on from there
+ if( m_survivorHandover )
+ {
+ m_survivorHandover = FALSE;
+ TheTacticalView->setLocation( &m_paneView[ 1 ] );
+ TheTacticalView->getLocation( &current );
+ m_mainOffset.x = m_paneGlide[ 1 ].getPosition().x - current.getPosition().x;
+ m_mainOffset.y = m_paneGlide[ 1 ].getPosition().y - current.getPosition().y;
+ m_velocity = m_paneVelocity[ 1 ];
+ m_panesLeftPlace.x = m_paneGlide[ 1 ].getPosition().x;
+ m_panesLeftPlace.y = m_paneGlide[ 1 ].getPosition().y;
+ DEBUG_LOG(( "OBSCAM frame %u panes went out on pane 1, the single view takes its camera\n", frame ));
+ }
}
ViewLocation target;