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
feat(gameclient): director never misses a special power, flags upgrades
Olcay Seygan50cf6fe9048e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 34ea72bea..122836474 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -759,11 +759,11 @@ A third pass went through the generals' powers, promotions and unit abilities.- Every row and every countdown stands in real metal, cut from the same tray the general's powers sit in down in the corner - the side your command bar is showing. Watching a match there is no bar of your own, so the superweapon countdowns used to fall back to a flat black box for the whole match; now they wear the metal of the player you are watching, and follow it when you switch seats.- Watching, the command bar is down to the radar. The list of players it held is the board on the right and the Tab scoreboard now. Pick a player to follow in the camera panel and you are looking at him, his money and his side's steel, the way his button in the list did; pick nobody for everybody. Picking drops whatever you had selected, so the promotions on screen are that player's and not the owner of the tank you last clicked. The portrait panel in the right corner comes up when you select something and goes when you click empty ground, so an empty match leaves the bottom of the screen to the battle.- 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 eight seconds, leaves after four for one two and a half times the size, and after twenty seconds on the same fight, or as soon as the fight has burnt down to half of what it was, 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 nine 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 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 eight seconds, leaves after four for one two and a half times the size, and after twenty seconds on the same fight, or as soon as the fight has burnt down to half of what it was, 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. For a nuke the camera goes straight to the target and waits there 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 nine 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.- The Director stands further back. It used to frame the unit the shots came from and miss the tanks fighting just beside it; now it watches every place from 200 paces over your own height, so the whole fight and what is around it are on the screen. Its climbs and descents take a couple of seconds and ease in and out, and gliding over hills no longer pumps the picture in and out over every ridge. A superweapon or a general's power is one shot now: when the screen split to show the silo and the target, the camera used to drop low when the split closed and then spend ten seconds climbing back up, and it comes out of the split at the height it was heading for.- 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 that meet round the radar, two players on a diagonal and four on an X, each picture on that player's base. Every picture gets the same share of the screen, whatever its shape: the lines used to stand at a fixed 45 degrees, and on a 16:9 screen three players got a sliver of 14% at the top and two big halves below, and at 21:9 the sliver was 10%. Now each has a third. 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 the screen's 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. In its corner the radar sits flush against the bottom and left of the picture with a thin gold edge on its top and right only, where it used to stand in a heavy frame a few pixels in from the corner. 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. While the screen is split the score bar slides up off the top with the radar's slide, so the pictures have the whole screen, and it comes back down when they go; it hangs in the radar's own frame, a thin gold edge on a soft blue halo down its sides and along its foot. 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 77 rows of a 720p picture for a 1v1 where its first cut took 126: the general or difficulty stands at the right end of the name's line instead of on a line of its own, and the clock, the armies' bar and the colour strip along each card are thinner. A player's name past about fourteen letters ends in an ellipsis, so one player called thirty letters long no longer widens every card on the bar or runs into the general beside his own. The plates over the opening's and a split's pictures and the Defeated and Victory banners cut a long name the same way, each to the room it has; a computer player's general is always written out whole. 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 94 rows of a 720p picture, a 4v4 with its two team names 130. 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. In a two-player film each half of the split belongs to one player for the whole match, the first player in the upper left and his opponent in the lower right from the opening's two bases on, each half on wherever that player's own guns are firing or, when they are quiet, on his base and his army; the screen used to show whichever two fights were hottest, often both in one player's half, and a 1v1 now splits about every twenty seconds where an earlier rule had cut it to a few times a match. The radar draws a view box for each half while the screen is cut, where it used to mark only the upper left one.-- The film shows who fired what. When a player uses a general's power, a small flag drops out from under his card in the score bar carrying the power's icon, hangs there four seconds and pulls back up; a superweapon's flag is edged in gold. A power gets its flag only once it hits somebody, the same rule the camera follows, so an Air Force general's spy satellite never hangs one, and a player who fires two in quick succession has them wait their turn under his card. A player knocked out no longer blinks out of the bar. His card flashes red with a line drawn through his name, and a second later it closes while the cards beside it slide into the room it leaves, where the whole row used to jump on the frame he lost. At the same moment a banner opens across the lower part of the picture with his name and general under a red Defeated. The match no longer cuts off on the frame the last card falls, either: the film runs three and a half seconds past the decision, so the last defeat plays out and the winner's banner comes up in gold beneath it.+- The film shows who fired what. When a player uses a general's power, a small flag drops out from under his card in the score bar carrying the power's icon, hangs there four seconds and pulls back up; a superweapon's flag is edged in gold. Every power a player fires gets its flag the moment he fires it, the command centre's spy satellite included, so a power with nothing to film still shows on the bar, and a player who fires two in quick succession has them wait their turn under his card. An upgrade he finishes buying drops its own flag the same way, behind any power waiting there. A power that lands takes the camera straight away: the Director used to finish the four seconds it gives any shot first, and in the first cup film a spy satellite was on screen three seconds late. With the first run's notes the camera is already waiting where the power will land before it is fired. A superweapon is filmed where it hits, not in its silo. Two powers landing far apart at once split the screen, one half each, however recently the last split went: fights still split only rarely. A power holds the camera thirty seconds at most; a particle cannon fired into the middle of the map kept it there for eight minutes in the first cup film while every other power went by unfilmed, because the battle round its target never stopped. Riflemen shooting at riflemen count for a quarter of what they did, so a small infantry skirmish rarely takes the camera from tanks, buildings or a power. The single view no longer carries an "X vs Y" plate under the score bar; the halves of a split and the opening keep theirs. A player knocked out no longer blinks out of the bar. His card flashes red with a line drawn through his name, and a second later it closes while the cards beside it slide into the room it leaves, where the whole row used to jump on the frame he lost. At the same moment a banner opens across the lower part of the picture with his name and general under a red Defeated. The match no longer cuts off on the frame the last card falls, either: the film runs three and a half seconds past the decision, so the last defeat plays out and the winner's banner comes up in gold beneath it.- 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 3daf7b74b..056797fcd 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h@@ -22,9 +22,11 @@// The mode and the followed player are picked apart, from two lists. Free is the camera in the// watcher's own hands. Director goes to the fight of the last few seconds with the most at stake,// each hit counted by what the thing hit cost and more for a kill or a superweapon, and stays there-// a while before it looks for a bigger fight. A special power used anywhere outranks any fight: a-// superweapon is shown leaving its silo, then where it lands until the dust settles, a laser-// followed along its sweep. The camera glides between places on a spring and only cuts across+// a while before it looks for a bigger fight. A special power used anywhere outranks any fight and+// takes the camera at once: it is shown where it lands until the dust settles, for 30 seconds at the+// most, a laser followed along its sweep, and two landing far apart at once split a recording's+// picture a pane each. Hits on infantry count for a quarter, so a skirmish of riflemen rarely+// takes the camera from tanks or buildings. The camera glides between places on a spring and only cuts across// most of a map, and stops short of a place that would put ground off the map on the screen. Over// a wide fight it rises above the watcher's own height, which the wheel still moves, and comes back// down to it when the camera goes elsewhere or is taken back. With no fight on it goes round the armies on the@@ -73,9 +75,10 @@ struct DirectorHeatclass Player;class SpecialPowerTemplate;class ThingTemplate;+class UpgradeTemplate;/// a special power used lately: who used it, where it was fired from, where it lands, and until which-/// logic frame it is worth watching. A superweapon is shown leaving its silo before its target+/// logic frame it is worth watchingstruct DirectorEvent{UnsignedInt id;@@ -91,10 +94,10 @@ struct DirectorEventconst ThingTemplate *sourceThing; ///< what it was fired from};-/// -directorrecord's broadcast shows some things one at a time from a queue: a special power's flag-/// under its player's card in the score bar, and a defeated player's banner. start is the logic frame-/// it began to come in, 0 while it waits behind another; leaving the frame it began to go, 0 while it-/// holds. A defeat's banner has no power+/// -directorrecord's broadcast shows some things one at a time from a queue: a special power's or a+/// bought upgrade's flag under its player's card in the score bar, and a defeated player's banner.+/// start is the logic frame it began to come in, 0 while it waits behind another; leaving the frame it+/// began to go, 0 while it holds. A defeat's banner has neither power nor upgradestruct DirectorShowing{Int player;@@ -103,6 +106,7 @@ struct DirectorShowingBool superweapon;UnsignedInt start;UnsignedInt leaving;+ const UpgradeTemplate *upgrade;};/// one logic frame of such a queue: the first in it comes in over moveFrames, holds holdAlone frames@@ -176,9 +180,10 @@ Bool ObserverCamera_fightLasts( const std::vector< DirectorMoment > &timeline, c/// of the match, not by itself, and is counted as lasting, so a last battle that got hot is filmed/// rather than skipped as a fizzlevoid ObserverCamera_closeTimeline( std::vector< DirectorMoment > &moments, UnsignedInt end );-/// the moment the director goes to wait at on frame: of the fights worth filming and the superweapons-/// that begin within the pre-roll after frame, a superweapon first and then the hottest, leaving out-/// any within apart of taken, the place another pane already shows (NULL for none). -1 for none+/// the moment the director goes to wait at on frame: of the moments worth filming that begin within the+/// pre-roll after frame, a superweapon first, then any other special power, then the hottest fight,+/// leaving out any within apart of taken, the place another pane already shows (NULL for none). A+/// power is waited for where it lands. -1 for noneInt ObserverCamera_prerollMoment( const std::vector< DirectorMoment > &timeline, UnsignedInt frame, const Coord2D *taken, Real apart );/// whether the fight going on at place on frame is one the scouting pass saw fizzle, which the/// director does not cut to. FALSE where the pass saw nothing, so a match it did not scout is@@ -209,26 +214,26 @@ Real ObserverCamera_heatAround( const std::vector< DirectorHeat > &hits, const C/// peakHere is the hottest the place has been while held, and a place burnt down from it lets go soonerBool ObserverCamera_shouldMove( Real heatHere, Real heatThere, UnsignedInt framesHere, Real peakHere );/// what one recent hit counts for: more the dearer the thing hit, more again if it died or is a-/// superweapon-Real ObserverCamera_hitWeight( Int cost, Bool killed, Bool superweapon );+/// superweapon, and a quarter of that for infantry+Real ObserverCamera_hitWeight( Int cost, Bool killed, Bool superweapon, Bool infantry );/// what one thing is worth looking at with no fight on: its cost, doubled while it marches or is/// being built, halved for a building that is only standing there, tripled for a superweaponReal ObserverCamera_sightWeight( Int cost, Bool structure, Bool busy, Bool superweapon );/// the best place among the sights away from the ones in seen; FALSE when every sight was seenBool ObserverCamera_nextSight( const std::vector< DirectorHeat > &sights, const std::vector< Coord2D > &seen, Coord2D *place );-/// where an event is best watched on a frame: a superweapon's silo for its first few seconds, then-/// where it lands-Coord2D ObserverCamera_eventPlace( const DirectorEvent &event, UnsignedInt frame );/// whether the director stays on the event it is showing, current, rather than go to best, the-/// biggest one it may show now. best is NULL when none may be shown: narrowed to a player whose-/// things round the target are all gone, the current one is filtered out and is still kept-Bool ObserverCamera_stayOnEvent( const DirectorEvent *current, const DirectorEvent *best, UnsignedInt held );+/// biggest and latest one it may show now: it stays while best lands in the same picture or weighs+/// less, and goes at once, settled or not, to a power as big landing anywhere else. best is NULL when+/// none may be shown: narrowed to a player whose things round the target are all gone, the current+/// one is filtered out and is still kept+Bool ObserverCamera_stayOnEvent( const DirectorEvent *current, const DirectorEvent *best );/// whether owner using power on target at frame is more of event, a use still shown, rather than a new oneBool ObserverCamera_sameUse( const DirectorEvent &event, const Player *owner, const SpecialPowerTemplate *power, const Coord2D &target,UnsignedInt frame );-/// whether an event takes the camera from a fight or a sight held for held frames. A superweapon-/// still on its way out of the silo goes at once, or the launch is over before the settle is-Bool ObserverCamera_eventCutsIn( const DirectorEvent &event, UnsignedInt frame, UnsignedInt held );+/// the frame an event shown until until is kept to when something more happens at it on frame: a few+/// seconds past frame, never past EVENT_MOST_FRAMES after it began. Kept going by every hit round its+/// target, a particle cannon fired into the middle of a map held the camera there for eight minutes+UnsignedInt ObserverCamera_eventKeptTo( const DirectorEvent &event, UnsignedInt frame, UnsignedInt more );/// how widely the hits within DIRECTOR_GATHER_RADIUS of a place lie round it, by weightReal ObserverCamera_spreadAround( const std::vector< DirectorHeat > &hits, const Coord2D &around );/// how much higher than the watcher's own the director takes the camera over a fight this spread@@ -413,6 +418,9 @@ public:/// a superweapon is hitting the ground here this frame, a beam or a warhead. Keeps the event it/// belongs to going a few seconds more, and with follow the event's target moves with itvoid noteSuperweaponHit( const Player *owner, const Coord3D *at, Bool follow );+ /// a player finished buying an upgrade, for himself or for one of his things: -directorrecord hangs+ /// its flag under his card. Logic tells, and never asks back+ void noteUpgrade( const Player *owner, const UpgradeTemplate *upgrade );/// the watcher's own height back on the view, if the director had raised it over a fightvoid releaseHeight( void );@@ -447,10 +455,9 @@ public:/// how far the gold lines have drawn out on the settled panes, 0 to 1, not easedReal getLineProgress( void ) const { return m_lineProgress; }/// who a split's pane shows: everybody dealing or taking hits in its fight, and in a match of two- /// the pane's own player whatever he does; 0 when nobody is+ /// the pane's own player whatever he does, or for a pane a special power holds the player who used+ /// it; 0 when nobody isPlayerMaskType getPaneSides( Int pane ) const;- /// who the director's fight on the whole screen is between; 0 when it shows no fight- PlayerMaskType getPlaceSides( void ) const;/// the panes are the match's opening, each one player's: his index, and the point over his command/// centre his plate hangs from, on the ground where his things crowd when he has noneBool isIntro( void ) const { return m_intro; }@@ -501,6 +508,7 @@ private:void pickIntroBases( void );Region2D mapRegion( void ) const;Bool updateSplit( void );+ Bool updateEventSplit( void );Bool updateSideSplit( void );/// everybody dealing or taking the last scan's hits in the fight at subjectPlayerMaskType sidesAround( const Coord2D &subject ) const;@@ -580,6 +588,9 @@ private:Real m_placeHeight; ///< how much higher than the watcher's own the place is watched fromReal m_placePeak; ///< the hottest the fight held has been since the director came to itUnsignedInt m_placeEvent; ///< the id of the event the place is, while it is one+ UnsignedInt m_eventSecond; ///< another event landing far from that one at the same time, 0 for none; the split's pane 1+ Bool m_eventSplit; ///< the split up is the two events', which no rest or hold of a fight's split keeps down+ PlayerMaskType m_eventPaneSides[ 2 ]; ///< who used each of those twostd::vector< Coord2D > m_seen; ///< the last few sights, oldest first, not gone back to while there is anotherstd::vector< DirectorEvent > m_events; ///< the special powers still worth watching, oldest firstUnsignedInt m_nextEventId;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 3253af4a7..64f4f448b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -10695,8 +10695,6 @@ static const Color BROADCAST_DEFEAT = GameMakeColor( 0xb8, 0x26, 0x1f, 255 );static const Int BROADCAST_BANNER_POINTS = 16;static const Int BROADCAST_BANNER_WORD_POINTS = 12;static const Real BROADCAST_BANNER_FOOT = 0.7f;-/// the whole screen's "X vs Y" plate comes and goes over this many logic frames-static const Real BROADCAST_WHOLE_PLATE_FADE_FRAMES = 15.0f;/** A banner's height with title over under, its rule included. */static Int broadcastBannerHeight( const BroadcastPlate &title, const BroadcastPlate &under )@@ -11053,8 +11051,8 @@ void InGameUI::layOutBroadcast( const std::vector< SpectatorStats > &players, co* 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- * two sides play so the side ahead is the one past it. A special power a player used drops its icon- * in a flag from under his card. A player who loses has his card flash red and struck through, then+ * two sides play so the side ahead is the one past it. A special power a player used, or an upgrade+ * he bought, drops its icon in a flag from under his card. A player who loses has his card flash red and struck through, then* it closes while the others slide to where they stand without it, and his banner comes up across* the lower picture; once the match is decided the winner's comes up under the last. While* a split is up each pane carries a plate in the top of its circle, inside its wedge and clear of@@ -11196,7 +11194,7 @@ void InGameUI::drawDirectorBroadcast( void )const DirectorShowing *flag = TheObserverCamera.getPowerFlag( from.players[ index ].player->getPlayerIndex(), &drop );if( flag == NULL || drop <= 0.0f )continue;- const Image *icon = superweaponCameo( flag->power );+ const Image *icon = flag->upgrade != NULL ? flag->upgrade->getButtonImage() : superweaponCameo( flag->power );if( icon == NULL && flag->sourceThing != NULL )icon = flag->sourceThing->getButtonImage();if( icon == NULL || icon->getImageHeight() <= 0 )@@ -11409,8 +11407,8 @@ void InGameUI::drawDirectorBroadcast( void )from.cardWidth, from.fullCardWidth ));}- // a split's plate a pane, faded in and out with the panes, and with no panes the director's fight's- // on the whole screen under the score bar; the opening's are each pane's own+ // a split's plate a pane, faded in and out with the panes; the opening's are each pane's own. The+ // whole screen has none: the score bar over it already names every sideconst Real paneShown = TheObserverCamera.getPaneProgress();const Int panes = TheObserverCamera.isIntro() ? 0 : TheObserverCamera.getDrawnPaneCount();DisplayString *versus = broadcastText( "versus", UnicodeString( u"vs" ), BROADCAST_WORDS, broadcastPoints( BROADCAST_SIDE_POINTS ), FALSE );@@ -11441,17 +11439,16 @@ void InGameUI::drawDirectorBroadcast( void )}return plate;};- // each plate's sides are logged when they change, the whole screen's last, so a film's plates can- // be counted- static PlayerMaskType loggedSides[ OBSERVER_MOST_PANES + 1 ];+ // each plate's sides are logged when they change, so a film's plates can be counted+ static PlayerMaskType loggedSides[ OBSERVER_MOST_PANES ];auto placePlate = [ & ]( Int slot, PlayerMaskType sides, const BroadcastPlate &plate, Int plateLeft, Int plateTop, Int plateWidth,Int plateHeight, Real shown ){if( sides != loggedSides[ slot ] ){loggedSides[ slot ] = sides;- DEBUG_LOG(( "OBSCAM frame %u %s plate %d, %d name(s)%s\n", frame, slot < OBSERVER_MOST_PANES ? "pane" : "whole screen",- slot, (Int)( plate.pieces.size() + 1 ) / 2, plate.pieces.size() > 1 ? ", vs" : "" ));+ DEBUG_LOG(( "OBSCAM frame %u pane plate %d, %d name(s)%s\n", frame, slot, (Int)( plate.pieces.size() + 1 ) / 2,+ plate.pieces.size() > 1 ? ", vs" : "" ));}drawBroadcastPlate( plate, plateLeft, plateTop, shown );IRegion2D drawn;@@ -11478,30 +11475,6 @@ void InGameUI::drawDirectorBroadcast( void )const Int plateTop = REAL_TO_INT( ObserverCamera_paneLabelTop( centre, radius, (Real)plateWidth, (Real)plateHeight ) );placePlate( pane, sides, plate, REAL_TO_INT( centre.x ) - plateWidth / 2, plateTop, plateWidth, plateHeight, paneShown );}- // the whole screen's plate names a fight between two sides or more, fades in over the panes' slide- // and out again keeping the names it had- static PlayerMaskType wholeSides = 0;- static Real wholeShown = 0.0f;- static Real wholeShownAt = 0.0f;- const Real picture = GameEngine_pictureFrame();- const PlayerMaskType placeSides = panes == 1 ? TheObserverCamera.getPlaceSides() : 0;- const Bool fightShown = sidesPlate( placeSides ).pieces.size() > 1;- if( fightShown )- wholeSides = placeSides;- const Real wholeStep = max( picture - wholeShownAt, 0.0f ) / BROADCAST_WHOLE_PLATE_FADE_FRAMES;- wholeShownAt = picture;- wholeShown = fightShown ? min( wholeShown + wholeStep, 1.0f ) : max( wholeShown - wholeStep, 0.0f );- if( wholeShown > 0.0f )- {- const BroadcastPlate plate = sidesPlate( wholeSides );- Int plateWidth = 0, plateHeight = 0;- broadcastPlateSize( plate, &plateWidth, &plateHeight );- placePlate( OBSERVER_MOST_PANES, wholeSides, plate, ( TheDisplay->getWidth() - plateWidth ) / 2, barFoot, plateWidth, plateHeight,- wholeShown );- }- else- loggedSides[ OBSERVER_MOST_PANES ] = 0;-// a defeated player's banner across the lower picture, the broadcast's red in its tab, and once the// match is decided the winner's under it in gold. A banner names the player in his colour, under it// his general or difficulty and his teamdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cppindex 86b9e56b7..4bc1e472e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp@@ -30,6 +30,7 @@#include "Common/Science.h"#include "Common/SpecialPower.h"#include "Common/ThingTemplate.h"+#include "Common/Upgrade.h"#include "GameClient/Display.h"#include "GameClient/Drawable.h"#include "GameClient/GameClient.h"@@ -82,15 +83,19 @@ static const Real EVENT_SUPERWEAPON_WEIGHT = 5.0f;/// missiles take a while to arrive, a bomber longer to fly instatic const UnsignedInt EVENT_FRAMES = 12 * LOGICFRAMES_PER_SECOND;static const UnsignedInt EVENT_SUPERWEAPON_FRAMES = 20 * LOGICFRAMES_PER_SECOND;-/// how long a superweapon is shown at its silo before the camera goes to where it will land+/// hits at an event's target in its first seconds are the fight that was there before it, not its ownstatic const UnsignedInt EVENT_LAUNCH_FRAMES = 4 * LOGICFRAMES_PER_SECOND;/// the camera stays this long after the last hit at an event's target, for the cloud and the firesstatic const UnsignedInt EVENT_AFTERMATH_FRAMES = 5 * LOGICFRAMES_PER_SECOND;+/// and never longer than this after it began, however much goes on hitting round the target+static const UnsignedInt EVENT_MOST_FRAMES = 30 * LOGICFRAMES_PER_SECOND;/// a hit on a thing that cost this much counts twice what a free one doesstatic const Real DIRECTOR_COST_PER_WEIGHT = 500.0f;/// a kill counts this many times a hit, and anything on a superweapon this many times againstatic const Real DIRECTOR_KILL_FACTOR = 2.0f;static const Real DIRECTOR_SUPERWEAPON_FACTOR = 3.0f;+/// and a hit on infantry this share of it: a few riflemen trading shots took the camera from tanks+static const Real DIRECTOR_INFANTRY_FACTOR = 0.25f;/// with no fight on, how long the director looks at one army, base or building sitestatic const UnsignedInt DIRECTOR_SIGHT_FRAMES = 9 * LOGICFRAMES_PER_SECOND;/// how many of the last sights the director will not go back to while there is another@@ -262,13 +267,26 @@ static Bool sameFight( const Coord2D &a, const Coord2D &b )}//--------------------------------------------------------------------------------------------------Real ObserverCamera_hitWeight( Int cost, Bool killed, Bool superweapon )+/** A power the player fires rather than one of his units: a superweapon, a general's power, or one+ * fired from a building, the command centre's spy satellite. NULL, a warhead no power sent, is none. */+//-------------------------------------------------------------------------------------------------+static Bool playersPower( const SpecialPowerTemplate *power, const ThingTemplate *sourceThing, Bool superweapon )+{+ if( power == NULL )+ return FALSE;+ return superweapon || power->getRequiredScience() != SCIENCE_INVALID || ( sourceThing != NULL && sourceThing->isKindOf( KINDOF_STRUCTURE ) );+}++//-------------------------------------------------------------------------------------------------+Real ObserverCamera_hitWeight( Int cost, Bool killed, Bool superweapon, Bool infantry ){Real weight = 1.0f + cost / DIRECTOR_COST_PER_WEIGHT;if( killed )weight *= DIRECTOR_KILL_FACTOR;if( superweapon )weight *= DIRECTOR_SUPERWEAPON_FACTOR;+ if( infantry )+ weight *= DIRECTOR_INFANTRY_FACTOR;return weight;}@@ -363,14 +381,6 @@ Bool ObserverCamera_shouldMove( Real heatHere, Real heatThere, UnsignedInt framereturn heatThere > heatHere * margin;}-//--------------------------------------------------------------------------------------------------Coord2D ObserverCamera_eventPlace( const DirectorEvent &event, UnsignedInt frame )-{- if( event.superweapon && frame < event.since + EVENT_LAUNCH_FRAMES && !sameFight( event.source, event.target ) )- return event.source;- return event.target;-}-//-------------------------------------------------------------------------------------------------Bool ObserverCamera_sameUse( const DirectorEvent &event, const Player *owner, const SpecialPowerTemplate *power, const Coord2D &target,UnsignedInt frame )@@ -379,17 +389,19 @@ Bool ObserverCamera_sameUse( const DirectorEvent &event, const Player *owner, co}//--------------------------------------------------------------------------------------------------Bool ObserverCamera_stayOnEvent( const DirectorEvent *current, const DirectorEvent *best, UnsignedInt held )+Bool ObserverCamera_stayOnEvent( const DirectorEvent *current, const DirectorEvent *best ){if( current == NULL )return FALSE;- return best == NULL || best == current || !ObserverCamera_shouldMove( current->weight, best->weight, held, current->weight );+ if( best == NULL || best == current || sameFight( best->target, current->target ) )+ return TRUE;+ return best->weight < current->weight;}//--------------------------------------------------------------------------------------------------Bool ObserverCamera_eventCutsIn( const DirectorEvent &event, UnsignedInt frame, UnsignedInt held )+UnsignedInt ObserverCamera_eventKeptTo( const DirectorEvent &event, UnsignedInt frame, UnsignedInt more ){- return held >= DIRECTOR_SETTLE_FRAMES || ( event.superweapon && frame < event.since + EVENT_LAUNCH_FRAMES );+ return min( max( event.until, frame + more ), event.since + EVENT_MOST_FRAMES );}//-------------------------------------------------------------------------------------------------@@ -1290,16 +1302,16 @@ Int ObserverCamera_prerollMoment( const std::vector< DirectorMoment > &timeline,for( size_t index = 0; index < timeline.size(); index++ ){const DirectorMoment &moment = timeline[ index ];- if( moment.start <= frame || moment.start > frame + DIRECTOR_PREROLL_FRAMES )+ if( moment.start <= frame || moment.start > frame + DIRECTOR_PREROLL_FRAMES || !ObserverCamera_worthFilming( moment ) )continue;- if( moment.power ? !moment.superweapon : !ObserverCamera_worthFilming( moment ) )- continue;- if( taken != NULL && within( moment.place, *taken, apart ) )+ if( taken != NULL && within( moment.power ? moment.target : moment.place, *taken, apart ) )continue;if( best >= 0 ){const DirectorMoment &held = timeline[ best ];- const Bool better = moment.superweapon != held.superweapon ? moment.superweapon : moment.peak > held.peak;+ const Int rank = ( moment.superweapon ? 2 : 0 ) + ( moment.power ? 1 : 0 );+ const Int heldRank = ( held.superweapon ? 2 : 0 ) + ( held.power ? 1 : 0 );+ const Bool better = rank != heldRank ? rank > heldRank : moment.peak > held.peak;if( !better )continue;}@@ -1544,6 +1556,9 @@ void ObserverCamera::reset( void )m_placeKind = PLACE_SIGHT;m_placeHeight = 0.0f;m_placeEvent = 0;+ m_eventSecond = 0;+ m_eventSplit = FALSE;+ m_eventPaneSides[ 0 ] = m_eventPaneSides[ 1 ] = 0;m_placeMoment = -1;m_skippedFight.x = m_skippedFight.y = 0.0f;m_seen.clear();@@ -1625,6 +1640,12 @@ void ObserverCamera::reset( void )void ObserverCamera::noteSpecialPower( const Player *owner, const Coord3D *from, const Coord3D *at, Bool superweapon,const SpecialPowerTemplate *power, const ThingTemplate *sourceThing ){+ // a power with no place of its own, one aimed at a unit or at nothing, is shown where it was used+ // from when it is the player's; a unit's own ability, a hacker's or a sniper's, is no event+ if( at == NULL && !playersPower( power, sourceThing, superweapon ) )+ return;+ if( at == NULL )+ at = from;const UnsignedInt frame = TheGameLogic->getFrame();dropOldEvents( frame );@@ -1637,7 +1658,7 @@ void ObserverCamera::noteSpecialPower( const Player *owner, const Coord3D *from,{if( ObserverCamera_sameUse( m_events[ index ], owner, power, target, frame ) ){- m_events[ index ].until = max( m_events[ index ].until, frame + ( superweapon ? EVENT_SUPERWEAPON_FRAMES : EVENT_FRAMES ) );+ m_events[ index ].until = ObserverCamera_eventKeptTo( m_events[ index ], frame, superweapon ? EVENT_SUPERWEAPON_FRAMES : EVENT_FRAMES );return;}}@@ -1660,8 +1681,11 @@ void ObserverCamera::noteSpecialPower( const Player *owner, const Coord3D *from,event.power = power;event.sourceThing = sourceThing;m_events.push_back( event );- if( event.landed )- noteFlag( event );+ // its flag goes up as it is used, whether or not it lands: a scan's flag is all there is of it+ noteFlag( event );+ if( TheGlobalData->m_directorRecord && power != NULL )+ DEBUG_LOG(( "OBSCAM frame %u special power %u %s used by player %d at (%.0f,%.0f)%s%s\n", frame, event.id, power->getName().str(),+ owner->getPlayerIndex(), target.x, target.y, superweapon ? ", superweapon" : "", event.landed ? ", lands" : ", waits for a hit" ));if( !TheGlobalData->m_directorScoutFile.isEmpty() ){@@ -1693,7 +1717,7 @@ void ObserverCamera::noteSuperweaponHit( const Player *owner, const Coord3D *at,if( follow )event.target = where;- event.until = max( event.until, frame + EVENT_AFTERMATH_FRAMES );+ event.until = ObserverCamera_eventKeptTo( event, frame, EVENT_AFTERMATH_FRAMES );return;}@@ -1703,17 +1727,33 @@ void ObserverCamera::noteSuperweaponHit( const Player *owner, const Coord3D *at,}//--------------------------------------------------------------------------------------------------/** A power that landed hangs its flag under its player's card: a superweapon, or a general's power,- * one a promotion bought. A unit's own ability, a sniper's shot or a hacker's, is neither. */+/** A power used hangs its flag under its player's card when it is the player's, not a unit's: a+ * superweapon, a general's power one a promotion bought, or one a building fires, the command+ * centre's spy satellite. A unit's own ability, a sniper's shot or a hacker's, is none of them. It+ * goes ahead of any upgrade still waiting, which a Hard AI buys a dozen of in a minute. *///-------------------------------------------------------------------------------------------------void ObserverCamera::noteFlag( const DirectorEvent &event ){- if( !TheGlobalData->m_directorRecord || event.power == NULL )- return;- if( !event.superweapon && event.power->getRequiredScience() == SCIENCE_INVALID )+ if( !TheGlobalData->m_directorRecord || !playersPower( event.power, event.sourceThing, event.superweapon ) )return;const Int index = event.owner->getPlayerIndex();- const DirectorShowing flag = { index, event.power, event.sourceThing, event.superweapon, 0, 0 };+ const DirectorShowing flag = { index, event.power, event.sourceThing, event.superweapon, 0, 0, NULL };+ std::vector< DirectorShowing > &flags = m_flags[ index ];+ std::vector< DirectorShowing >::iterator waiting = flags.begin();+ while( waiting != flags.end() && ( waiting->start != 0 || waiting->upgrade == NULL ) )+ ++waiting;+ flags.insert( waiting, flag );+}++//-------------------------------------------------------------------------------------------------+/** Called from the logic on every machine, like noteSpecialPower, and only adds to the flags. */+//-------------------------------------------------------------------------------------------------+void ObserverCamera::noteUpgrade( const Player *owner, const UpgradeTemplate *upgrade )+{+ if( !TheGlobalData->m_directorRecord || upgrade->getButtonImage() == NULL )+ return;+ const Int index = owner->getPlayerIndex();+ const DirectorShowing flag = { index, NULL, NULL, FALSE, 0, 0, upgrade };m_flags[ index ].push_back( flag );}@@ -1741,7 +1781,7 @@ void ObserverCamera::updateBroadcastMoments( UnsignedInt frame )m_collapseFrame[ index ] = ObserverCamera_collapseFrom( frame, m_lastCollapse );m_lastCollapse = m_collapseFrame[ index ];m_flags[ index ].clear();- const DirectorShowing banner = { index, NULL, NULL, FALSE, 0, 0 };+ const DirectorShowing banner = { index, NULL, NULL, FALSE, 0, 0, NULL };m_defeatBanners.push_back( banner );DEBUG_LOG(( "OBSCAM frame %u defeat: player %d '%s' (%s), card struck, collapses at frame %u\n", frame, index,WideCharAsUtf8( player->getPlayerDisplayName().str() ).str(), WideCharAsUtf8( player->getPlayerTemplate()->getDisplayName().str() ).str(),@@ -1764,8 +1804,9 @@ void ObserverCamera::updateBroadcastMoments( UnsignedInt frame )if( !ObserverCamera_advanceShowing( m_flags[ index ], frame, FLAG_MOVE_FRAMES, FLAG_HOLD_FRAMES, FALSE ) )continue;const DirectorShowing &flag = m_flags[ index ].front();- DEBUG_LOG(( "OBSCAM frame %u power flag under player %d's card: %s%s, %d waiting\n", frame, index, flag.power->getName().str(),- flag.superweapon ? " (superweapon)" : "", (Int)m_flags[ index ].size() - 1 ));+ DEBUG_LOG(( "OBSCAM frame %u %s flag under player %d's card: %s%s, %d waiting\n", frame, flag.upgrade != NULL ? "upgrade" : "power", index,+ flag.upgrade != NULL ? flag.upgrade->getUpgradeName().str() : flag.power->getName().str(), flag.superweapon ? " (superweapon)" : "",+ (Int)m_flags[ index ].size() - 1 ));}}@@ -2210,6 +2251,8 @@ Real ObserverCamera::splitApart( const Coord2D &second ) const//-------------------------------------------------------------------------------------------------Bool ObserverCamera::updateSplit( void ){+ if( updateEventSplit() )+ return FALSE;if( m_sidePlayers[ 0 ] != NULL )return updateSideSplit();const UnsignedInt frame = TheGameLogic->getFrame();@@ -2305,6 +2348,47 @@ Bool ObserverCamera::updateSplit( void )return FALSE;}+//-------------------------------------------------------------------------------------------------+/** -directorrecord: two special powers landing far apart at once split the picture, pane 0 on the one+ * directorPlace shows and pane 1 on the other, at once and however recently the last split went;+ * the rests and holds keep only fights from splitting too often. A split already up for a fight+ * is taken over where it stands. It goes when either power is over. TRUE while it decides the+ * split, which no fight's rule then looks at. */+//-------------------------------------------------------------------------------------------------+Bool ObserverCamera::updateEventSplit( void )+{+ DirectorEvent *second = m_eventSecond != 0 && m_placeValid && m_placeKind == PLACE_EVENT ? findEvent( m_eventSecond ) : NULL;+ if( second == NULL && !m_eventSplit )+ return FALSE;+ const UnsignedInt frame = TheGameLogic->getFrame();+ if( second == NULL )+ {+ // the director already on pane 1's power keeps pane 1's picture as the panes go+ m_paneSurvivor = within( m_place, m_secondPlace, m_splitApart * SPLIT_SAME_GROUND_SHARE ) && !m_intro ? 1 : 0;+ DEBUG_LOG(( "OBSCAM frame %u split off, a special power of the two is over%s\n", frame, m_paneSurvivor == 1 ? ", pane 1 stays" : "" ));+ m_split = FALSE;+ m_eventSplit = FALSE;+ m_splitChanged = frame;+ return TRUE;+ }+ const DirectorEvent *first = findEvent( m_placeEvent );+ if( !m_eventSplit || !m_split )+ {+ m_splitApart = splitApart( second->target );+ DEBUG_LOG(( "OBSCAM frame %u split on for two special powers, pane 0 power %u at (%.0f,%.0f), pane 1 power %u at (%.0f,%.0f), %.0f apart of %.0f needed%s\n",+ frame, first->id, m_place.x, m_place.y, second->id, second->target.x, second->target.y,+ sqrtf( distanceSquared( m_place, second->target ) ), m_splitApart, m_split ? ", over the split up" : "" ));+ m_eventSplit = TRUE;+ m_split = TRUE;+ m_splitChanged = frame;+ m_paneSurvivor = 0;+ }+ m_secondPlace = second->target;+ m_eventPaneSides[ 0 ] = first->owner->getPlayerMask();+ m_eventPaneSides[ 1 ] = second->owner->getPlayerMask();+ return TRUE;+}+//-------------------------------------------------------------------------------------------------/** -directorrecord in a match of two: a pane each player, pane 0 always the opening's pane 0 player* and pane 1 the other, so the two sides keep their halves of the screen from the opening on. What@@ -2859,17 +2943,13 @@ PlayerMaskType ObserverCamera::sidesAround( const Coord2D &subject ) constPlayerMaskType ObserverCamera::getPaneSides( Int pane ) const{// a match of two names each pane's own player, and whoever he is fighting there: named alone, the- // "X vs Y" plate never showed in a 1v1 film- const PlayerMaskType own = m_sidePlayers[ 0 ] != NULL && pane < 2 ? m_sidePlayers[ pane ]->getPlayerMask() : 0;+ // "X vs Y" plate never showed in a 1v1 film. Two powers' panes name who used each+ PlayerMaskType own = m_sidePlayers[ 0 ] != NULL && pane < 2 ? m_sidePlayers[ pane ]->getPlayerMask() : 0;+ if( m_eventSplit && pane < 2 )+ own = m_eventPaneSides[ pane ];return own | sidesAround( pane == 0 ? m_panesLeftPlace : m_secondPlace );}-//--------------------------------------------------------------------------------------------------PlayerMaskType ObserverCamera::getPlaceSides( void ) const-{- return m_placeValid && m_placeKind == PLACE_FIGHT ? sidesAround( m_place ) : 0;-}-//-------------------------------------------------------------------------------------------------Int ObserverCamera::getIntroPlayerIndex( Int pane ) const{@@ -2953,7 +3033,7 @@ void ObserverCamera::scout( void )hit.position.x = obj->getPosition()->x;hit.position.y = obj->getPosition()->y;hit.weight = ObserverCamera_hitWeight( obj->getTemplate()->friend_getBuildCost(), obj->isEffectivelyDead(),- obj->isKindOf( KINDOF_FS_SUPERWEAPON ) );+ obj->isKindOf( KINDOF_FS_SUPERWEAPON ), obj->isKindOf( KINDOF_INFANTRY ) );hits.push_back( hit );}ObserverCamera_markLandings( m_scouted, hits, frame );@@ -3111,7 +3191,7 @@ Bool ObserverCamera::directorPlace( const Player *narrowTo, Coord2D *place )if( !mine && ( body->getLastDamageInfo()->in.m_sourcePlayerMask & narrowTo->getPlayerMask() ) == 0 )continue;- heat.weight = ObserverCamera_hitWeight( cost, obj->isEffectivelyDead(), superweapon );+ heat.weight = ObserverCamera_hitWeight( cost, obj->isEffectivelyDead(), superweapon, obj->isKindOf( KINDOF_INFANTRY ) );hits.push_back( heat );// -directorrecord's split counts only fights, and its labels name who is in them@@ -3152,6 +3232,7 @@ Bool ObserverCamera::directorPlace( const Player *narrowTo, Coord2D *place )// land on his things count, the way only his fights dodropOldEvents( frame );DirectorEvent *best = NULL;+ std::vector< DirectorEvent * > landed;for( size_t index = 0; index < m_events.size(); index++ ){DirectorEvent &event = m_events[ index ];@@ -3160,36 +3241,59 @@ Bool ObserverCamera::directorPlace( const Player *narrowTo, Coord2D *place )continue;// hits at the target keep it going: the missiles arriving, the bombs, the fires afterif( frame >= event.since + EVENT_LAUNCH_FRAMES && ObserverCamera_heatAround( hits, event.target, &middle ) > 0.0f )- event.until = max( event.until, frame + EVENT_AFTERMATH_FRAMES );+ event.until = ObserverCamera_eventKeptTo( event, frame, EVENT_AFTERMATH_FRAMES );if( !event.landed && ObserverCamera_heatAround( fights, event.target, &middle ) > 0.0f )- {event.landed = TRUE;- noteFlag( event );- }if( !event.landed )continue;+ landed.push_back( &event );if( best == NULL || event.weight >= best->weight )best = &event;}+ // a power takes the camera from anything the moment it lands, settled or not: waiting out the+ // settle, S1-A1 showed special power 3 three seconds after it hit. Two at once each keep their pane+ // while both go on, the one shown first in pane 0 and the new one in pane 1; the heavier taking pane+ // 0 would swap the two panes' pictures+ const Bool splits = TheGlobalData->m_directorRecord && narrowTo == NULL;DirectorEvent *current = m_placeValid && m_placeKind == PLACE_EVENT ? findEvent( m_placeEvent ) : NULL;- if( ObserverCamera_stayOnEvent( current, best, held ) )- {- m_place = ObserverCamera_eventPlace( *current, frame );- *place = m_place;- return TRUE;- }- // an event that just ended hands straight over to the next; anything else is given its settle- // first, except a superweapon still leaving its silo- if( best != NULL && ( sideSplit || !m_placeValid || m_placeKind == PLACE_EVENT || ObserverCamera_eventCutsIn( *best, frame, held ) ) )- {- DEBUG_LOG(( "OBSCAM frame %u director to special power %u at (%.0f,%.0f)%s%s\n", frame, best->id,- best->target.x, best->target.y, best->superweapon ? " superweapon" : "", sideSplit ? ", out of the split" : "" ));- m_place = ObserverCamera_eventPlace( *best, frame );+ DirectorEvent *second = m_eventSplit && current != NULL ? findEvent( m_eventSecond ) : NULL;+ const Bool bestSplitsOff = splits && current != NULL && best != NULL && best != current+ && !within( best->target, current->target, splitApart( best->target ) );+ DirectorEvent *shown = NULL;+ if( second != NULL || bestSplitsOff || ObserverCamera_stayOnEvent( current, best ) )+ shown = current;+ else if( best != NULL )+ {+ DEBUG_LOG(( "OBSCAM frame %u director to special power %u %s at (%.0f,%.0f)%s%s\n", frame, best->id,+ best->power != NULL ? best->power->getName().str() : "warhead", best->target.x, best->target.y,+ best->superweapon ? " superweapon" : "", sideSplit ? ", out of the split" : "" ));m_placeKind = PLACE_EVENT;m_placeHeight = 0.0f;m_placeEvent = best->id;m_placeSince = frame;m_placeValid = TRUE;+ shown = best;+ }+ m_eventSecond = 0;+ if( shown != NULL )+ {+ m_place = shown->target;+ // -directorrecord: another power landing far from it at the same time gets a pane of its own,+ // whatever keeps fights from splitting+ if( splits )+ {+ if( second != NULL && within( second->target, m_place, splitApart( second->target ) * SPLIT_SAME_GROUND_SHARE ) )+ second = NULL;+ if( second == NULL && bestSplitsOff )+ second = best;+ for( size_t index = 0; index < landed.size() && second == NULL; index++ )+ {+ DirectorEvent *other = landed[ index ];+ if( other != shown && !within( other->target, m_place, splitApart( other->target ) ) )+ second = other;+ }+ m_eventSecond = second != NULL ? second->id : 0;+ }*place = m_place;return TRUE;}@@ -3220,11 +3324,13 @@ Bool ObserverCamera::directorPlace( const Player *narrowTo, Coord2D *place )const DirectorMoment &moment = m_timeline[ upcoming ];Coord2D middle;const Real heatHere = m_placeValid && m_placeKind == PLACE_FIGHT ? ObserverCamera_heatAround( hits, m_place, &middle ) : 0.0f;- if( moment.superweapon || heatHere <= 0.0f || ( held >= DIRECTOR_SETTLE_FRAMES && moment.peak > heatHere * DIRECTOR_SWITCH_MARGIN ) )+ if( moment.power || heatHere <= 0.0f || ( held >= DIRECTOR_SETTLE_FRAMES && moment.peak > heatHere * DIRECTOR_SWITCH_MARGIN ) ){+ // a power is waited for where it lands, not where it is fired from+ const Coord2D &waitAt = moment.power ? moment.target : moment.place;DEBUG_LOG(( "OBSCAM frame %u pre-roll to %s at frame %u (%.0f,%.0f) peak %.1f\n", frame,- moment.superweapon ? "superweapon" : "fight", moment.start, moment.place.x, moment.place.y, moment.peak ));- m_place = moment.place;+ moment.superweapon ? "superweapon" : moment.power ? "special power" : "fight", moment.start, waitAt.x, waitAt.y, moment.peak ));+ m_place = waitAt;m_placeKind = PLACE_UPCOMING;m_placeHeight = 0.0f;m_placeMoment = upcoming;@@ -3333,10 +3439,11 @@ 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 ) )+ else if( panesUp && m_split && !m_intro && !m_eventSplit && !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+ // place that still moves this far under panes would be a jump, so pane 0 stays and says so. Two+ // special powers taking over a split up go to where they land, jump or notDEBUG_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;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cppindex 4e9b252c8..d01b9f2b3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp@@ -571,10 +571,10 @@ void SpecialPowerModule::aboutToDoSpecialPower( const Coord3D *location )getSpecialPowerModuleData()->m_specialPowerTemplate->getName(),getObject()->getID());- // the observer's director camera goes to see it; this only tells the client- if( location != NULL )- TheObserverCamera.noteSpecialPower( getObject()->getControllingPlayer(), getObject()->getPosition(), location,- getObject()->isKindOf( KINDOF_FS_SUPERWEAPON ), getSpecialPowerModuleData()->m_specialPowerTemplate, getObject()->getTemplate() );+ // the observer's director camera goes to see it, a power aimed at a unit or at nothing included+ // (location NULL); this only tells the client+ TheObserverCamera.noteSpecialPower( getObject()->getControllingPlayer(), getObject()->getPosition(), location,+ getObject()->isKindOf( KINDOF_FS_SUPERWEAPON ), getSpecialPowerModuleData()->m_specialPowerTemplate, getObject()->getTemplate() );// Let EVA do her thingSpecialPowerType type = getSpecialPowerModuleData()->m_specialPowerTemplate->getSpecialPowerType();diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cppindex b91362e0c..08e7419f0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp@@ -48,6 +48,7 @@#include "GameClient/Eva.h"#include "GameClient/GameText.h"#include "GameClient/InGameUI.h"+#include "GameClient/ObserverCamera.h"#include "GameLogic/GameLogic.h"#include "GameLogic/Module/CreateModule.h"@@ -1026,6 +1027,9 @@ UpdateSleepTime ProductionUpdate::update( void )upgrade->getUpgradeName(),us->getID());+ // a recording's broadcast hangs the upgrade's flag under the player's card; this only tells the client+ TheObserverCamera.noteUpgrade( player, upgrade );+// print a message to the local player, if it wants oneif( us->isLocallyControlled() && !upgrade->getDisplayNameLabel().isEmpty() ){diff --git a/GeneralsMD/Code/Tests/test_observer_camera.inc b/GeneralsMD/Code/Tests/test_observer_camera.incindex cd51a3004..9994b9af8 100644--- a/GeneralsMD/Code/Tests/test_observer_camera.inc+++ b/GeneralsMD/Code/Tests/test_observer_camera.inc@@ -67,28 +67,6 @@ TEST(the_director_leaves_early_for_a_much_bigger_fight_and_late_for_any_bigger_oCHECK( !ObserverCamera_shouldMove( 4.0f, 5.0f, tired, 4.0f ) );}-TEST(the_director_shows_a_superweapon_leaving_its_silo_then_where_it_lands)-{- DirectorEvent nuke;- nuke.id = 1;- nuke.owner = NULL;- nuke.source.x = 500.0f;- nuke.source.y = 500.0f;- nuke.target.x = 3000.0f;- nuke.target.y = 2000.0f;- nuke.since = 1000;- nuke.until = 2000;- nuke.weight = 5.0f;- nuke.superweapon = TRUE;- CHECK_NEAR( ObserverCamera_eventPlace( nuke, 1001 ).x, 500.0f, 0.001f );- CHECK_NEAR( ObserverCamera_eventPlace( nuke, 1000 + 10 * LOGICFRAMES_PER_SECOND ).x, 3000.0f, 0.001f );-- // a bomber's strike has nothing worth seeing where it was ordered from- DirectorEvent strike = nuke;- strike.superweapon = FALSE;- CHECK_NEAR( ObserverCamera_eventPlace( strike, 1001 ).x, 3000.0f, 0.001f );-}-TEST(the_director_goes_where_more_is_at_stake_not_where_more_was_hit){// six rifles plinked at one end, two Overlords killed at the other@@ -98,17 +76,52 @@ TEST(the_director_goes_where_more_is_at_stake_not_where_more_was_hit)for( Int each = 0; each < 2; each++ ){DirectorHeat hit = directorHit( 3000.0f + each * 10.0f, 3000.0f );- hit.weight = ObserverCamera_hitWeight( 2000, TRUE, FALSE );+ hit.weight = ObserverCamera_hitWeight( 2000, TRUE, FALSE, FALSE );hits.push_back( hit );}for( Int each = 0; each < 6; each++ )- hits[ each ].weight = ObserverCamera_hitWeight( 225, FALSE, FALSE );+ hits[ each ].weight = ObserverCamera_hitWeight( 225, FALSE, FALSE, FALSE );Coord2D place;Real heat = 0.0f;CHECK( ObserverCamera_hottestPlace( hits, &place, &heat ) );CHECK_NEAR( place.y, 3000.0f, 0.001f );- CHECK( ObserverCamera_hitWeight( 5000, FALSE, TRUE ) > ObserverCamera_hitWeight( 5000, FALSE, FALSE ) );+ CHECK( ObserverCamera_hitWeight( 5000, FALSE, TRUE, FALSE ) > ObserverCamera_hitWeight( 5000, FALSE, FALSE, FALSE ) );+}++TEST(a_skirmish_of_riflemen_does_not_take_the_camera_from_two_tanks)+{+ // eight riflemen shot at, two of them killed, against two tanks hit once each+ std::vector< DirectorHeat > hits;+ for( Int each = 0; each < 8; each++ )+ {+ DirectorHeat hit = directorHit( 1000.0f + each * 10.0f, 1000.0f );+ hit.weight = ObserverCamera_hitWeight( 225, each < 2, FALSE, TRUE );+ hits.push_back( hit );+ }+ for( Int each = 0; each < 2; each++ )+ {+ DirectorHeat hit = directorHit( 3000.0f + each * 10.0f, 3000.0f );+ hit.weight = ObserverCamera_hitWeight( 900, FALSE, FALSE, FALSE );+ hits.push_back( hit );+ }+ Coord2D place;+ Real heat = 0.0f;+ CHECK( ObserverCamera_hottestPlace( hits, &place, &heat ) );+ CHECK_NEAR( place.y, 3000.0f, 0.001f );+}++TEST(a_special_power_holds_the_camera_thirty_seconds_at_the_most)+{+ DirectorEvent cannon;+ cannon.since = 1000;+ cannon.until = 1000 + 20 * LOGICFRAMES_PER_SECOND;+ // a hit at the target keeps it five seconds past the hit+ CHECK_EQ( ObserverCamera_eventKeptTo( cannon, 1000 + 18 * LOGICFRAMES_PER_SECOND, 5 * LOGICFRAMES_PER_SECOND ),+ 1000u + 23 * LOGICFRAMES_PER_SECOND );+ // and never past 30 seconds from the launch: the fight round S1-A1's middle kept one for eight minutes+ CHECK_EQ( ObserverCamera_eventKeptTo( cannon, 1000 + 400 * LOGICFRAMES_PER_SECOND, 5 * LOGICFRAMES_PER_SECOND ),+ 1000u + 30 * LOGICFRAMES_PER_SECOND );}TEST(the_director_with_no_fight_goes_round_the_sights_and_never_parks)@@ -164,15 +177,26 @@ TEST(the_director_keeps_its_event_when_none_may_be_shown_any_more)// narrowed to a player whose things at the target all died, the event it shows is filtered out// and nothing is left to compare it with; this read a NULL best and crashedconst DirectorEvent nuke = directorEvent( 1, 5.0f, TRUE );- CHECK( ObserverCamera_stayOnEvent( &nuke, NULL, 0 ) );- CHECK( ObserverCamera_stayOnEvent( &nuke, &nuke, 0 ) );- CHECK( !ObserverCamera_stayOnEvent( NULL, &nuke, 0 ) );- CHECK( !ObserverCamera_stayOnEvent( NULL, NULL, 0 ) );-- // a bomber's strike gives way to a superweapon once it has settled, not before- const DirectorEvent strike = directorEvent( 2, 1.0f, FALSE );- CHECK( ObserverCamera_stayOnEvent( &strike, &nuke, LOGICFRAMES_PER_SECOND ) );- CHECK( !ObserverCamera_stayOnEvent( &strike, &nuke, 7 * LOGICFRAMES_PER_SECOND ) );+ CHECK( ObserverCamera_stayOnEvent( &nuke, NULL ) );+ CHECK( ObserverCamera_stayOnEvent( &nuke, &nuke ) );+ CHECK( !ObserverCamera_stayOnEvent( NULL, &nuke ) );+ CHECK( !ObserverCamera_stayOnEvent( NULL, NULL ) );+}++TEST(a_new_power_landing_elsewhere_takes_the_camera_at_once)+{+ DirectorEvent nuke = directorEvent( 1, 5.0f, TRUE );+ nuke.target.x = 5000.0f;+ DirectorEvent strike = directorEvent( 2, 1.0f, FALSE );+ DirectorEvent scan = directorEvent( 3, 1.0f, FALSE );+ scan.target.x = 3500.0f;+ // a superweapon takes the camera from a strike at once, and a strike never takes it from one+ CHECK( !ObserverCamera_stayOnEvent( &strike, &nuke ) );+ CHECK( ObserverCamera_stayOnEvent( &nuke, &strike ) );+ // a power as big elsewhere goes at once; one landing in the picture already shown does not move it+ CHECK( !ObserverCamera_stayOnEvent( &strike, &scan ) );+ scan.target.x = 3100.0f;+ CHECK( ObserverCamera_stayOnEvent( &strike, &scan ) );}TEST(one_use_of_a_power_is_one_event_and_another_power_or_player_is_new)@@ -200,18 +224,6 @@ TEST(one_use_of_a_power_is_one_event_and_another_power_or_player_is_new)CHECK( !ObserverCamera_sameUse( used, one, NULL, beside, 1500 ) );}-TEST(a_superweapon_leaving_its_silo_takes_the_camera_before_the_settle_is_up)-{- const DirectorEvent nuke = directorEvent( 1, 5.0f, TRUE );- const DirectorEvent strike = directorEvent( 2, 1.0f, FALSE );- const UnsignedInt justArrived = LOGICFRAMES_PER_SECOND;- CHECK( ObserverCamera_eventCutsIn( nuke, 1001, justArrived ) );- CHECK( !ObserverCamera_eventCutsIn( strike, 1001, justArrived ) );- // once the missile is out of the silo the nuke waits for the settle like anything else- CHECK( !ObserverCamera_eventCutsIn( nuke, 1000 + 5 * LOGICFRAMES_PER_SECOND, justArrived ) );- CHECK( ObserverCamera_eventCutsIn( strike, 1001, 7 * LOGICFRAMES_PER_SECOND ) );-}-TEST(the_director_rises_over_a_wide_fight_and_not_over_a_tight_one){std::vector< DirectorHeat > tight;@@ -971,6 +983,8 @@ TEST(the_director_goes_to_wait_for_a_fight_four_seconds_before_it_starts_superwetimeline.push_back( scoutedFight( 1010, 1030, 5000.0f, 5000.0f, 2.0f ) );timeline.push_back( scoutedPower( 1020, 6000.0f, 1000.0f, FALSE ) );timeline.push_back( scoutedPower( 1100, 6000.0f, 3000.0f, TRUE ) );+ // a power the scout never saw land, a scan, is not waited for+ timeline[ 3 ].peak = 0.0f;const UnsignedInt preroll = 4 * LOGICFRAMES_PER_SECOND;CHECK_EQ( ObserverCamera_prerollMoment( timeline, 1000 - preroll - 1, NULL, 660.0f ), -1 );CHECK_EQ( ObserverCamera_prerollMoment( timeline, 1000 - preroll, NULL, 660.0f ), 0 );@@ -980,6 +994,13 @@ TEST(the_director_goes_to_wait_for_a_fight_four_seconds_before_it_starts_superweCHECK_EQ( ObserverCamera_prerollMoment( timeline, 1100 - preroll, NULL, 660.0f ), 4 );// one that has started is no longer waited forCHECK_EQ( ObserverCamera_prerollMoment( timeline, 1100, NULL, 660.0f ), -1 );+ // a power that landed is waited for ahead of any fight, a superweapon still ahead of it+ timeline[ 3 ].peak = 1.0f;+ CHECK_EQ( ObserverCamera_prerollMoment( timeline, 1050 - preroll, NULL, 660.0f ), 3 );+ CHECK_EQ( ObserverCamera_prerollMoment( timeline, 1100 - preroll, NULL, 660.0f ), 4 );+ // and is passed over where another pane already shows its target, not where it was fired from+ Coord2D taken = { 7500.0f, 1000.0f };+ CHECK_EQ( ObserverCamera_prerollMoment( timeline, 1050 - preroll, &taken, 660.0f ), 1 );}TEST(the_director_does_not_wait_for_the_fight_the_other_pane_already_shows)