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(gameengine): end director splits instead of jumping, two card rows
Olcay Seyganeba1f69e18f7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 006053fc4..0b00e7bdc 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. 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 on one line his cash and what his army cost, the army's figure labelled so the two never get mixed up; the bar is a fifth shorter than its first cut, 99 rows of a 720p picture for a 1v1 where it took 126. 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. Inside a split no picture ever jumps. A split ends the usual way after eighteen seconds, or the moment either half's fight is over or moves on to somewhere else, and only then does the camera go where the next fight is; in an eight-player film one split stayed up for three minutes while the main half was thrown across the map to six new fights, once by 2,900 paces as it was still sweeping in. 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 on one line his cash and what his army cost, the army's figure labelled so the two never get mixed up; the bar is a fifth shorter than its first cut, 99 rows of a 720p picture for a 1v1 where it took 126. 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. From five players on the cards stand in two rows, a team never broken across them, and each card keeps to one line, the name and the army's value, so the type stays at its full size: eight players in one row had shrunk it to letters six pixels tall that nobody could read in motion. Eight alone take 103 rows of a 720p picture, a 4v4 with its two team names 139. 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.hindex a17cc0c19..a751caf51 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h@@ -244,6 +244,9 @@ Real ObserverCamera_paneLabelTop( const Coord2D ¢re, Real radius, Real width/// block: every card's left and every block's left from the row's, and the row's whole widthInt ObserverCamera_cardRow( const std::vector< Int > &sizes, Int cardWidth, Int cardGap, Int versusWidth,std::vector< Int > *cardLefts, std::vector< Int > *blockLefts );+/// the score bar's row, 0 or 1, for each block of players: one row under five players, else blocks+/// kept whole and in order, the first row taking them until it holds about half the cards+std::vector< Int > ObserverCamera_cardRows( const std::vector< Int > &sizes );/// the first of steps sizes, largest first, whose row of cards is no wider than room; the last when/// none isInt ObserverCamera_cardStep( const std::vector< Int > &sizes, const Int *cardWidths, const Int *cardGaps,@@ -454,7 +457,11 @@ private:Real m_lastZoom; ///< the view's zoom at the last update, for the zoom jump logBool m_lastCut; ///< the last update cutUnsignedInt m_handoverLogUntil; ///< the frame the per-frame hand-over log stops at+ Coord2D m_paneLookLast[ 2 ]; ///< each pane's subject at the last frame panes were up, for the jump check+ UnsignedInt m_paneLookFrame; ///< that frame, 0 while no panes are up+ Real m_paneLookStepMost[ 2 ]; ///< each pane's largest subject step a logic frame while these panes are upInt 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+ Int m_spentMoment; ///< the timeline moment whose split was ended early, so it does not open againBool m_survivorHandover; ///< the panes have just gone out on pane 1, whose camera the single view takes over this updateCoord3D m_drivenTo; ///< where this put the camera last frame, inside the view's constraintUnsignedInt m_lastUpdate;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 1b04870c7..b18a3b751 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -10712,7 +10712,7 @@ static const Real BROADCAST_CARD_STRIP = 3.0f;//-------------------------------------------------------------------------------------------------/** The score bar hangs from the top edge in the middle: the match clock in a tab of its own, and under- * it every side in one row, "Team A vs Team B vs a player alone", a card a player with his name in+ * it every side in one row (two rows of one-line cards from five players), "Team A vs Team B vs a player alone", a card a player with his name in* his colour, his general or difficulty, his cash and the cost of everything he has standing that is* not a building. A team's cards sit together under its name and its armies' total. Under the row* the armies pull on one bar, each player his colour in the cards' order, gold at the middle when@@ -10751,6 +10751,16 @@ void InGameUI::drawDirectorBroadcast( void )}const Int blocks = (Int)blockSizes.size();+ // five players or more stand in two rows, whole blocks to a row, and their cards keep one line each:+ // the name at the left, the army's value at the right, no general and no cash. One row of eight+ // two-line cards fell to 7 point text at 720, and one line with the cash had to be cut to fit+ const std::vector< Int > lineOf = ObserverCamera_cardRows( blockSizes );+ const Int lines = lineOf.back() + 1;+ const Bool compact = lines > 1;+ std::vector< std::vector< Int > > lineSizes( lines );+ for( Int block = 0; block < blocks; block++ )+ lineSizes[ lineOf[ block ] ].push_back( blockSizes[ block ] );+// every card's text at a size, and the card width it needs: the widest of the name, the general or// difficulty, the money line (cash, then the army's label and value) at six digits each, and a team// header spread over its block's cards. Each size keeps strings of its own, since a string keeps@@ -10759,6 +10769,7 @@ void InGameUI::drawDirectorBroadcast( void )std::vector< DisplayString * > teamNames( blocks, NULL ), teamTotals( blocks, NULL );DisplayString *armyHead = NULL;DisplayString *versusText = NULL;+ Int widestWidth = 0;auto buildCards = [ & ]( Int step ) -> Int{const std::string size = "card" + std::to_string( step ) + ":";@@ -10769,10 +10780,10 @@ void InGameUI::drawDirectorBroadcast( void )broadcastPoints( BROADCAST_HEAD_POINTS ), FALSE );versusText = broadcastText( size + "versus", UnicodeString( u"vs" ), BROADCAST_WORDS, detailPoints, FALSE );DisplayString *widest = broadcastText( size + "widest", broadcastNumber( "$", BROADCAST_WIDEST ), BROADCAST_NUMBERS, detailPoints, TRUE );- Int width = 0, height = 0, labelWidth = 0, widestWidth = 0;+ Int width = 0, height = 0, labelWidth = 0;armyHead->getSize( &labelWidth, &height );widest->getSize( &widestWidth, &height );- Int content = widestWidth + cardPad + labelWidth + cardPad / 2 + widestWidth;+ Int content = compact ? 0 : widestWidth + cardPad + labelWidth + cardPad / 2 + widestWidth;for( size_t index = 0; index < players.size(); index++ ){const SpectatorStats &stats = players[ index ];@@ -10785,7 +10796,9 @@ void InGameUI::drawDirectorBroadcast( void )row.cash = broadcastText( "cash" + seat, broadcastNumber( "$", stats.cash ), BROADCAST_NUMBERS, detailPoints, TRUE );row.army = broadcastText( "army" + seat, broadcastNumber( "$", stats.army ), BROADCAST_NUMBERS, detailPoints, TRUE );row.name->getSize( &width, &height );- content = max( content, width );+ content = max( content, compact ? width + cardPad + widestWidth : width );+ if( compact )+ continue;row.side->getSize( &width, &height );content = max( content, width );}@@ -10819,17 +10832,41 @@ void InGameUI::drawDirectorBroadcast( void )versusWidths[ step ] = versusWidth + 4 * cardGaps[ step ];}const Int room = (Int)TheDisplay->getWidth() - 4 * pad;- const Int step = ObserverCamera_cardStep( blockSizes, cardWidths, cardGaps, versusWidths, BROADCAST_CARD_STEPS, room );+ Int step = 0;+ for( Int line = 0; line < lines; line++ )+ step = max( step, ObserverCamera_cardStep( lineSizes[ line ], cardWidths, cardGaps, versusWidths, BROADCAST_CARD_STEPS, room ) );buildCards( step );const Int cardPad = cardGaps[ step ];const Int versusWidth = versusWidths[ step ];- std::vector< Int > cardLefts, blockLefts;+ std::vector< Int > lineCards, lineBlocks;Int cardWidth = cardWidths[ step ];- Int rowWidth = ObserverCamera_cardRow( blockSizes, cardWidth, cardPad, versusWidth, &cardLefts, &blockLefts );+ std::vector< Int > lineWidths( lines, 0 );+ for( Int line = 0; line < lines; line++ )+ lineWidths[ line ] = ObserverCamera_cardRow( lineSizes[ line ], cardWidth, cardPad, versusWidth, &lineCards, &lineBlocks );+ Int rowWidth = *std::max_element( lineWidths.begin(), lineWidths.end() );if( rowWidth > room ){- cardWidth = ObserverCamera_cardWidthIn( blockSizes, cardPad, versusWidth, room );- rowWidth = ObserverCamera_cardRow( blockSizes, cardWidth, cardPad, versusWidth, &cardLefts, &blockLefts );+ for( Int line = 0; line < lines; line++ )+ cardWidth = min( cardWidth, ObserverCamera_cardWidthIn( lineSizes[ line ], cardPad, versusWidth, room ) );+ for( Int line = 0; line < lines; line++ )+ lineWidths[ line ] = ObserverCamera_cardRow( lineSizes[ line ], cardWidth, cardPad, versusWidth, &lineCards, &lineBlocks );+ rowWidth = *std::max_element( lineWidths.begin(), lineWidths.end() );+ }+ // every block's and every card's left across the bar, a shorter line in the middle under the longer+ std::vector< Int > cardLefts( players.size(), 0 ), blockLefts( blocks, 0 );+ for( Int line = 0; line < lines; line++ )+ {+ ObserverCamera_cardRow( lineSizes[ line ], cardWidth, cardPad, versusWidth, &lineCards, &lineBlocks );+ const Int shift = ( rowWidth - lineWidths[ line ] ) / 2;+ Int blockInLine = 0, cardInLine = 0;+ for( Int block = 0; block < blocks; block++ )+ {+ if( lineOf[ block ] != line )+ continue;+ blockLefts[ block ] = shift + lineBlocks[ blockInLine++ ];+ for( Int index = blockFirst[ block ]; index < blockFirst[ block ] + blockSizes[ block ]; index++ )+ cardLefts[ index ] = shift + lineCards[ cardInLine++ ];+ }}UnicodeString clockText;@@ -10839,7 +10876,8 @@ void InGameUI::drawDirectorBroadcast( void )clock->getSize( &clockWidth, &clockHeight );// the bar's measures: the clock in a tab at the top in the middle, under it a line of team headers- // when there are teams, the cards, and the armies' bar under the whole row+ // when there are teams, the cards, a header line and a card line again for a second row, and the+ // armies' bar under all of itInt nameHeight = 0, sideHeight = 0, numberHeight = 0, labelHeight = 0, headerHeight = 0, width = 0;rows[ 0 ].name->getSize( &width, &nameHeight );rows[ 0 ].side->getSize( &width, &sideHeight );@@ -10860,10 +10898,20 @@ void InGameUI::drawDirectorBroadcast( void )const Int left = ( (Int)TheDisplay->getWidth() - barWidth ) / 2;const Int rowLeft = left + ( barWidth - rowWidth ) / 2;const Int headerTop = clockBoxHeight + halfPad;- const Int cardsTop = headerTop + headerHeight;const Int strip = broadcastPixels( BROADCAST_CARD_STRIP );- const Int cardHeight = strip + halfPad + nameHeight + sideHeight + numberHeight + halfPad;- const Int tugTop = cardsTop + cardHeight + halfPad;+ const Int textHeight = compact ? max( nameHeight, numberHeight ) : nameHeight + sideHeight + numberHeight;+ const Int cardHeight = strip + halfPad + textHeight + halfPad;+ // a row's team headers take a line over it only when the row has a team+ std::vector< Int > lineHeaders( lines, 0 ), lineTops( lines, 0 );+ for( Int block = 0; block < blocks; block++ )+ if( teamNames[ block ] != NULL )+ lineHeaders[ lineOf[ block ] ] = headerHeight;+ Int tugTop = headerTop;+ for( Int line = 0; line < lines; line++ )+ {+ lineTops[ line ] = tugTop;+ tugTop += lineHeaders[ line ] + cardHeight + halfPad;+ }const Int height = tugTop + tug + pad / 2;const Int clockLeft = left + ( barWidth - clockBox ) / 2;@@ -10877,19 +10925,23 @@ void InGameUI::drawDirectorBroadcast( void )// difficulty, then one money line: the cash at the left, the army's label and value at the rightInt versusTextWidth = 0, versusTextHeight = 0;versusText->getSize( &versusTextWidth, &versusTextHeight );+ Int armyLabelWidth = 0;+ armyHead->getSize( &armyLabelWidth, &labelHeight );for( Int block = 0; block < blocks; block++ ){const Int blockLeft = rowLeft + blockLefts[ block ];const Int blockWidth = blockSizes[ block ] * cardWidth + ( blockSizes[ block ] - 1 ) * cardPad;- if( block > 0 )- versusText->draw( blockLeft - ( versusWidth + versusTextWidth ) / 2, cardsTop + ( cardHeight - versusTextHeight ) / 2,+ const Int blockHeaderTop = lineTops[ lineOf[ block ] ];+ const Int blockCardsTop = blockHeaderTop + lineHeaders[ lineOf[ block ] ];+ if( block > 0 && lineOf[ block ] == lineOf[ block - 1 ] )+ versusText->draw( blockLeft - ( versusWidth + versusTextWidth ) / 2, blockCardsTop + ( cardHeight - versusTextHeight ) / 2,BROADCAST_MUTED, BROADCAST_GROUND );if( teamNames[ block ] != NULL ){Int totalWidth = 0, totalHeight = 0;teamTotals[ block ]->getSize( &totalWidth, &totalHeight );- teamNames[ block ]->draw( blockLeft, headerTop, BROADCAST_GOLD, BROADCAST_GROUND );- teamTotals[ block ]->draw( blockLeft + blockWidth - totalWidth, headerTop, BROADCAST_INK, BROADCAST_GROUND );+ teamNames[ block ]->draw( blockLeft, blockHeaderTop, BROADCAST_GOLD, BROADCAST_GROUND );+ teamTotals[ block ]->draw( blockLeft + blockWidth - totalWidth, blockHeaderTop, BROADCAST_INK, BROADCAST_GROUND );}for( Int index = blockFirst[ block ]; index < blockFirst[ block ] + blockSizes[ block ]; index++ ){@@ -10897,20 +10949,26 @@ void InGameUI::drawDirectorBroadcast( void )const Int cardLeft = rowLeft + cardLefts[ index ];const Int textLeft = cardLeft + cardPad;const Int numberEnd = cardLeft + cardWidth - cardPad;- TheDisplay->drawFillRect( cardLeft, cardsTop, cardWidth, cardHeight, BROADCAST_PANEL );- drawBroadcastSwatch( cardLeft, cardsTop, cardWidth, strip, row.color );- Int top = cardsTop + strip + halfPad;- row.name->draw( textLeft, top, ObserverCamera_readableColor( row.color ), BROADCAST_GROUND );- top += nameHeight;- row.side->draw( textLeft, top, BROADCAST_MUTED, BROADCAST_GROUND );- top += sideHeight;- Int numberWidth = 0, numberTall = 0, labelWidth = 0;- row.cash->getSize( &numberWidth, &numberTall );- row.cash->draw( textLeft, top + numberHeight - numberTall, BROADCAST_INK, BROADCAST_GROUND );+ TheDisplay->drawFillRect( cardLeft, blockCardsTop, cardWidth, cardHeight, BROADCAST_PANEL );+ drawBroadcastSwatch( cardLeft, blockCardsTop, cardWidth, strip, row.color );+ Int top = blockCardsTop + strip + halfPad;+ Int numberWidth = 0, numberTall = 0;+ row.name->getSize( &numberWidth, &numberTall );+ row.name->draw( textLeft, compact ? top + textHeight - numberTall : top, ObserverCamera_readableColor( row.color ), BROADCAST_GROUND );+ if( !compact )+ {+ top += nameHeight;+ row.side->draw( textLeft, top, BROADCAST_MUTED, BROADCAST_GROUND );+ top += sideHeight;+ }+ const Int moneyBottom = compact ? top + textHeight : top + numberHeight;row.army->getSize( &numberWidth, &numberTall );- row.army->draw( numberEnd - numberWidth, top + numberHeight - numberTall, BROADCAST_INK, BROADCAST_GROUND );- armyHead->getSize( &labelWidth, &labelHeight );- armyHead->draw( numberEnd - numberWidth - halfPad - labelWidth, top + numberHeight - labelHeight, BROADCAST_MUTED, BROADCAST_GROUND );+ row.army->draw( numberEnd - numberWidth, moneyBottom - numberTall, BROADCAST_INK, BROADCAST_GROUND );+ if( compact )+ continue;+ armyHead->draw( numberEnd - numberWidth - halfPad - armyLabelWidth, moneyBottom - labelHeight, BROADCAST_MUTED, BROADCAST_GROUND );+ row.cash->getSize( &numberWidth, &numberTall );+ row.cash->draw( textLeft, moneyBottom - numberTall, BROADCAST_INK, BROADCAST_GROUND );}}@@ -10944,6 +11002,13 @@ void InGameUI::drawDirectorBroadcast( void )bar.hi.y = height;TheObserverCamera.addBroadcast( bar );TheObserverCamera.setBroadcastTop( (Real)( height + pad ) );+ static Int loggedHeight = -1;+ if( height != loggedHeight )+ {+ loggedHeight = height;+ DEBUG_LOG(( "OBSCAM frame %u score bar %d x %d, %d row(s), size %d (name %d, detail %d points), card %d of %d\n", TheGameLogic->getFrame(),+ barWidth, height, lines, step, BROADCAST_CARD_NAME_POINTS[ step ], BROADCAST_CARD_DETAIL_POINTS[ step ], cardWidth, cardWidths[ step ] ));+ }// a split's plate a pane, faded in and out with the panes; the opening's are each pane's ownconst Real shown = TheObserverCamera.getPaneProgress();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cppindex 1d89fb53b..235b8277b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp@@ -97,6 +97,12 @@ static const Real DIRECTOR_PAN_SECONDS = 1.4f;/// how long the director's height takes to settle on a new place's: the view's own settle took a/// third of a second, and a camera gliding in over seconds stepped back up in that thirdstatic const Real DIRECTOR_HEIGHT_SECONDS = 1.6f;+/// the score bar sets this many players' cards and more in two rows: eight in one were 6 pixel text+/// at 720p+static const Int CARD_TWO_ROWS_FROM = 5;+/// the longest a split stays up, from when it opened; a planned one was held 5300 frames on an+/// eight-player map while pane 0 went from fight to fight beside it+static const UnsignedInt SPLIT_MOST_FRAMES = 18 * LOGICFRAMES_PER_SECOND;/// how long after the panes are gone the hand-over is logged a line a framestatic const UnsignedInt HANDOVER_LOG_FRAMES = 45;/// a zoom moving more than this share of itself between two updates is logged as a jump@@ -656,6 +662,30 @@ Int ObserverCamera_cardRow( const std::vector< Int > &sizes, Int cardWidth, Intreturn at;}+//-------------------------------------------------------------------------------------------------+std::vector< Int > ObserverCamera_cardRows( const std::vector< Int > &sizes )+{+ std::vector< Int > rows( sizes.size(), 0 );+ Int cards = 0;+ for( size_t block = 0; block < sizes.size(); block++ )+ cards += sizes[ block ];+ if( cards < CARD_TWO_ROWS_FROM )+ return rows;+ // blocks in order into the first row until it holds half the cards, the rest into the second; a+ // block that would carry the first row further past half than it is short goes down instead+ Int first = 0;+ Bool second = FALSE;+ for( size_t block = 0; block < sizes.size(); block++ )+ {+ if( block > 0 && !second && first + sizes[ block ] - cards / 2 > cards / 2 - first )+ second = TRUE;+ rows[ block ] = second ? 1 : 0;+ if( !second )+ first += sizes[ block ];+ }+ return rows;+}+//-------------------------------------------------------------------------------------------------Int ObserverCamera_cardStep( const std::vector< Int > &sizes, const Int *cardWidths, const Int *cardGaps,const Int *versusWidths, Int steps, Int room )@@ -1202,7 +1232,10 @@ void ObserverCamera::reset( void )m_lastZoom = 0.0f;m_lastCut = FALSE;m_handoverLogUntil = 0;+ m_paneLookFrame = 0;+ m_paneLookStepMost[ 0 ] = m_paneLookStepMost[ 1 ] = 0.0f;m_paneSurvivor = 0;+ m_spentMoment = -1;m_survivorHandover = FALSE;m_drivenTo.zero();m_lastUpdate = 0;@@ -1785,7 +1818,8 @@ void ObserverCamera::updateSplit( void )const Bool handedOver = m_split && within( m_place, m_secondPlace, sameGround );const Bool mayPlan = m_placeKind != PLACE_SIGHT && ( m_split || firstLasts );const Int planned = mayPlan ? ObserverCamera_plannedSecond( m_timeline, m_place, frame, searched, m_split ) : -1;- const Bool plannedSplit = planned >= 0;+ // a planned moment whose split was ended early does not open another+ const Bool plannedSplit = planned >= 0 && planned != m_spentMoment;if( plannedSplit && frame < m_timeline[ planned ].start && ( secondHeat <= 0.0f || !within( second, m_timeline[ planned ].place, sameGround ) ) )second = m_timeline[ planned ].place;else if( m_split && secondHeat <= 0.0f )@@ -1814,6 +1848,21 @@ void ObserverCamera::updateSplit( void )if( split && !m_split && !plannedSplit && timelineKnown )split = firstLasts && ObserverCamera_fightLasts( m_timeline, shown, frame, heldTo, &m_place );split = split && !handedOver && apart > needed * SPLIT_SAME_GROUND_SHARE;+ // a split goes out the usual way when it has been up long enough, when the director has taken pane+ // 0 to another fight (pane 0 keeps the one it had until the panes are gone, see chooseTarget), and+ // when the second fight is now somewhere else. Pane 0 retargeted under a split it never left, and a+ // pre-roll fifteen frames into one moved it 2900 units while it slid in+ const Bool upTooLong = m_split && since >= SPLIT_MOST_FRAMES;+ const Bool paneZeroLeft = m_split && !handedOver && !within( m_place, m_panesLeftPlace, sameGround );+ const Bool paneOneLeft = m_split && !within( shown, m_secondPlace, sameGround );+ if( split && ( upTooLong || paneZeroLeft || paneOneLeft ) )+ {+ DEBUG_LOG(( "OBSCAM frame %u split ends:%s%s%s\n", frame, upTooLong ? " up too long" : "",+ paneZeroLeft ? " the director went elsewhere" : "", paneOneLeft ? " the second fight is elsewhere" : "" ));+ split = FALSE;+ if( planned >= 0 )+ m_spentMoment = planned;+ }if( split != m_split ){DEBUG_LOG(( "OBSCAM frame %u split %s, first heat %.1f, second (%.0f,%.0f) heat %.1f, %.0f apart of %.0f needed, screen %.0f%s\n",@@ -1901,7 +1950,10 @@ void ObserverCamera::advancePanes( UnsignedInt frame )}break;case PANES_RADAR_OUT:- if( elapsed >= PANE_RADAR_FRAMES )+ // a split that ended before its panes came takes the radar back without bringing them in+ if( !m_intro && !m_split )+ next = PANES_RADAR_IN;+ else if( elapsed >= PANE_RADAR_FRAMES )next = PANES_IN;break;case PANES_IN:@@ -2715,6 +2767,14 @@ Bool ObserverCamera::chooseTarget( const ViewLocation ¤t, ViewLocation *taconst Bool panesUp = m_panePhase == PANES_IN || panesSettled() || m_panePhase == PANES_OUT;if( panesUp && ( leaving || ( !m_split && !m_intro ) ) )place = m_panesLeftPlace;+ else if( panesUp && m_split && !m_intro && !within( place, m_panesLeftPlace, m_splitApart * SPLIT_SAME_GROUND_SHARE ) )+ {+ // updateSplit ends a split whose pane 0 the director takes elsewhere before this is reached; a+ // place that still moves this far under panes would be a jump, so pane 0 stays and says so+ DEBUG_LOG(( "OBSCAM frame %u pane 0 would jump to (%.0f,%.0f) under a split, held at (%.0f,%.0f)\n", TheGameLogic->getFrame(),+ place.x, place.y, m_panesLeftPlace.x, m_panesLeftPlace.y ));+ place = m_panesLeftPlace;+ }elsem_panesLeftPlace = place;// while there are panes each one keeps what it shows inside the map itself; the whole screen's@@ -2733,10 +2793,40 @@ Bool ObserverCamera::chooseTarget( const ViewLocation ¤t, ViewLocation *ta//-------------------------------------------------------------------------------------------------void ObserverCamera::logHandover( const ViewLocation &step, const ViewLocation &placed ){+ // the panes moving, and HANDOVER_LOG_FRAMES after; held still, once a second. A split held 5300+ // frames wrote a line every one of themconst UnsignedInt frame = TheGameLogic->getFrame();- if( m_panePhase != PANES_NONE )+ // inside a split no pane jumps: each pane's largest subject step a logic frame, written when the+ // panes are gone, says whether one did. The subject and not the look point: a pane sliding off the+ // screen's edge keeps its subject on its circle's centre, and the look under that perspective swung+ // 89 units in a frame while the picture moved evenly. The radar sliding is not the panes+ const Bool panesShown = m_paneCount >= 2 && m_panePhase != PANES_RADAR_IN && m_panePhase != PANES_RADAR_OUT;+ if( panesShown && frame != m_paneLookFrame )+ {+ const Coord2D looks[ 2 ] = { { step.getPosition().x, step.getPosition().y },+ { m_paneGlide[ 1 ].getPosition().x, m_paneGlide[ 1 ].getPosition().y } };+ for( Int pane = 0; pane < 2; pane++ )+ {+ if( m_paneLookFrame != 0 )+ {+ const Real dx = looks[ pane ].x - m_paneLookLast[ pane ].x;+ const Real dy = looks[ pane ].y - m_paneLookLast[ pane ].y;+ m_paneLookStepMost[ pane ] = max( m_paneLookStepMost[ pane ], sqrtf( dx * dx + dy * dy ) / ( frame - m_paneLookFrame ) );+ }+ m_paneLookLast[ pane ] = looks[ pane ];+ }+ m_paneLookFrame = frame;+ }+ else if( !panesShown && m_paneLookFrame != 0 )+ {+ DEBUG_LOG(( "OBSCAM frame %u panes down, largest subject step a frame: pane 0 %.1f, pane 1 %.1f\n", frame,+ m_paneLookStepMost[ 0 ], m_paneLookStepMost[ 1 ] ));+ m_paneLookFrame = 0;+ m_paneLookStepMost[ 0 ] = m_paneLookStepMost[ 1 ] = 0.0f;+ }+ if( m_panePhase != PANES_NONE && m_panePhase != PANES_HELD )m_handoverLogUntil = frame + HANDOVER_LOG_FRAMES;- if( frame >= m_handoverLogUntil )+ if( frame >= m_handoverLogUntil && ( m_panePhase != PANES_HELD || frame % LOGICFRAMES_PER_SECOND != 0 ) )return;TheTacticalView->aimCamera();Coord3D world = step.getPosition();diff --git a/GeneralsMD/Code/Tests/test_observer_camera.inc b/GeneralsMD/Code/Tests/test_observer_camera.incindex 7394279d0..2055dd5ba 100644--- a/GeneralsMD/Code/Tests/test_observer_camera.inc+++ b/GeneralsMD/Code/Tests/test_observer_camera.inc@@ -882,6 +882,39 @@ TEST(the_directors_height_eases_to_a_new_place_and_cuts_with_a_cut)CHECK_NEAR( velocity, 0.0f, 0.0001f );}+TEST(the_score_bar_takes_two_rows_from_five_players_with_blocks_kept_whole)+{+ std::vector< Int > sizes( 4, 1 );+ std::vector< Int > rows = ObserverCamera_cardRows( sizes );+ for( size_t block = 0; block < rows.size(); block++ )+ CHECK_EQ( rows[ block ], 0 );+ // eight alone: four and four+ sizes.assign( 8, 1 );+ rows = ObserverCamera_cardRows( sizes );+ for( size_t block = 0; block < rows.size(); block++ )+ CHECK_EQ( rows[ block ], block < 4 ? 0 : 1 );+ // 4v4 and 4v1: a team to a row+ sizes.assign( 2, 4 );+ rows = ObserverCamera_cardRows( sizes );+ CHECK_EQ( rows[ 0 ], 0 );+ CHECK_EQ( rows[ 1 ], 1 );+ sizes[ 1 ] = 1;+ rows = ObserverCamera_cardRows( sizes );+ CHECK_EQ( rows[ 1 ], 1 );+ // 1v1v1v1v2: three cards up, the last single and the pair down+ sizes.assign( 4, 1 );+ sizes.push_back( 2 );+ rows = ObserverCamera_cardRows( sizes );+ CHECK_EQ( rows[ 2 ], 0 );+ CHECK_EQ( rows[ 3 ], 1 );+ CHECK_EQ( rows[ 4 ], 1 );+ // 2v2v2: four up, two down+ sizes.assign( 3, 2 );+ rows = ObserverCamera_cardRows( sizes );+ CHECK_EQ( rows[ 1 ], 0 );+ CHECK_EQ( rows[ 2 ], 1 );+}+TEST(the_score_bar_sets_every_side_in_one_row_and_fits_eight_players){// 4v1: four cards with three gaps, a "vs", one card