Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameclient): a director split pane per player and a radar box per pane
Olcay Seygan39dce60f7606
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.hindex 073156f58..0a882561f 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ObserverCamera.h@@ -185,12 +185,9 @@ Bool ObserverCamera_fizzles( const std::vector< DirectorMoment > &timeline, cons/// a fight worth filming beginning within SPLIT_LEAD_FRAMES after frame, or with keeping, the split up/// already, one going on at frame, more than apart from first: the hottest such, -1 for none. A/// fight already going is not split for anew: where it began is only a guess at where it is now, and-/// a fight that had wandered off left pane 1 on empty ground. With homes, on another player's ground-/// than first, as ObserverCamera_secondPlace+/// a fight that had wandered off left pane 1 on empty groundInt ObserverCamera_plannedSecond( const std::vector< DirectorMoment > &timeline, const Coord2D &first, UnsignedInt frame, Real apart,- Bool keeping, const Coord2D *homes, Int homeCount );-/// whose ground place is on: the index of the nearest of count homes, each player's base at the start-Int ObserverCamera_groundOf( const Coord2D &place, const Coord2D *homes, Int count );+ Bool keeping );/// a moment as one line of the timeline file, and back; FALSE for a line that is not oneAsciiString ObserverCamera_formatMoment( const DirectorMoment &moment );Bool ObserverCamera_parseMoment( const char *line, DirectorMoment *moment );@@ -248,11 +245,18 @@ ViewLocation ObserverCamera_approach( const ViewLocation &from, const ViewLocati/// gathers and slows over about 1.6 s; a cut takes it there at onceReal ObserverCamera_easeHeight( Real from, Real to, Real *velocity, Real elapsedSeconds, Bool cut );/// -directorrecord's second fight: the hottest place among the hits more than needed from first, so-/// the two halves of a split screen never show the same ground. With two homes or more it is also on-/// another player's ground than first, so a split shows the other side: in a 1v1 the two fights had-/// both been in one player's half, his base beside his own army. FALSE when nothing such was hit-Bool ObserverCamera_secondPlace( const std::vector< DirectorHeat > &hits, const Coord2D &first, Real needed, const Coord2D *homes,- Int homeCount, Coord2D *place, Real *heat );+/// the two halves of a split screen never show the same ground. FALSE when nothing that far was hit+Bool ObserverCamera_secondPlace( const std::vector< DirectorHeat > &hits, const Coord2D &first, Real needed, Coord2D *place, Real *heat );+/// -directorrecord's split in a match of two, a pane each player: what one player is doing is the hits+/// his own fire made (sources[] has him), and with none anywhere his own sights, his base and his army+/// on the move. fighting says which+void ObserverCamera_sideCandidates( const std::vector< DirectorHeat > &hits, const std::vector< PlayerMaskType > &sources,+ const std::vector< DirectorHeat > &sights, const std::vector< PlayerMaskType > &owners, PlayerMaskType side,+ std::vector< DirectorHeat > *candidates, Bool *fighting );+/// a place for each of the two players from his candidates, more than apart from each other.+/// Whichever player's hottest place is taken first, the other's is the hottest of his beyond it; of+/// the two ways round, the one whose cooler pane is hotter. FALSE, both heats 0, when there are none+Bool ObserverCamera_sidePlaces( const std::vector< DirectorHeat > *candidates, Real apart, Coord2D *places, Real *heats );/// whether the recording's picture is split, given whether it is now, how far apart the two places/// are against the needed distance, and how long ago it last went on or off: on, after a rest, for a/// second fight more than needed away that is big on its own and next to a first one; held through@@ -445,6 +449,8 @@ public:const Coord3D &getIntroMark( Int pane ) const { return m_paneMark[ pane ]; }Bool isDrawingSecond( void ) const { return m_drawingPane != 0; }Int getDrawingPane( void ) const { return m_drawingPane; }+ /// the camera a pane past the first draws from; pane 0's is the view's own+ const ViewLocation &getPaneView( Int pane ) const { return m_paneView[ pane ]; }/// the view moved to a pane's camera for one draw, and put back after itvoid beginPanePass( Int pane );void endPanePass( void );@@ -487,7 +493,8 @@ private:void logHandover( const ViewLocation &step, const ViewLocation &placed );void pickIntroBases( void );Region2D mapRegion( void ) const;- void updateSplit( void );+ Bool updateSplit( void );+ Bool updateSideSplit( void );void measureScreenGround( void );Real paneGround( const Coord2D &subject ) const;Real splitApart( const Coord2D &second ) const;@@ -575,6 +582,11 @@ private:std::vector< DirectorHeat > m_fights; ///< the last scan's hits one player dealt another he is at war with; the split counts only thesestd::vector< PlayerMaskType > m_fightSides; ///< and the two players each of them was between+ std::vector< PlayerMaskType > m_fightSources; ///< and the player who dealt each of them+ std::vector< DirectorHeat > m_sights; ///< the last scan's things worth seeing, unhurt or not+ std::vector< PlayerMaskType > m_sightOwners; ///< and whose each of them is, 0 for nobody's+ const Player *m_sidePlayers[ 2 ]; ///< a match of two: the opening's pane players, each split's pane 0 and pane 1 follow the same one+ Coord2D m_sideFirst; ///< where pane 0's player is, the place the director holds while that split is upstd::vector< IRegion2D > m_broadcast; ///< the rectangles the broadcast drew over pane 0 this frameReal m_broadcastTop; ///< the rows the score bar tookReal m_screenGround; ///< the ground the whole picture spans across its middle row, last measured with no panes up@@ -616,8 +628,6 @@ private:Real m_cornerRadarSlide;IRegion2D m_radarFrame;const Player *m_panePlayers[ OBSERVER_MOST_PANES ]; ///< the intro's player for each pane- Coord2D m_homes[ OBSERVER_MOST_PANES ]; ///< each opening player's base, whose ground a split's second fight must not share with the first- Int m_homeCount;Coord2D m_paneSubject[ OBSERVER_MOST_PANES ]; ///< what each pane past the first looks atCoord3D m_paneMark[ OBSERVER_MOST_PANES ]; ///< the top of each opening player's command centreViewLocation m_paneGlide[ OBSERVER_MOST_PANES ]; ///< where each pane's subject glide has got todiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cppindex 1eaa6dc1e..39ab30485 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/ObserverCamera.cpp@@ -516,40 +516,58 @@ Real ObserverCamera_easeHeight( Real from, Real to, Real *velocity, Real elapsed}//--------------------------------------------------------------------------------------------------Int ObserverCamera_groundOf( const Coord2D &place, const Coord2D *homes, Int count )+Bool ObserverCamera_secondPlace( const std::vector< DirectorHeat > &hits, const Coord2D &first, Real needed, Coord2D *place, Real *heat ){- Int nearest = 0;- Real nearestSquared = 0.0f;- for( Int home = 0; home < count; home++ )+ std::vector< DirectorHeat > apart;+ for( size_t index = 0; index < hits.size(); index++ ){- const Real dx = homes[ home ].x - place.x;- const Real dy = homes[ home ].y - place.y;- const Real squared = dx * dx + dy * dy;- if( home == 0 || squared < nearestSquared )- {- nearest = home;- nearestSquared = squared;- }+ const Real dx = hits[ index ].position.x - first.x;+ const Real dy = hits[ index ].position.y - first.y;+ if( dx * dx + dy * dy > needed * needed )+ apart.push_back( hits[ index ] );}- return nearest;+ return ObserverCamera_hottestPlace( apart, place, heat );}//--------------------------------------------------------------------------------------------------Bool ObserverCamera_secondPlace( const std::vector< DirectorHeat > &hits, const Coord2D &first, Real needed, const Coord2D *homes,- Int homeCount, Coord2D *place, Real *heat )+void ObserverCamera_sideCandidates( const std::vector< DirectorHeat > &hits, const std::vector< PlayerMaskType > &sources,+ const std::vector< DirectorHeat > &sights, const std::vector< PlayerMaskType > &owners, PlayerMaskType side,+ std::vector< DirectorHeat > *candidates, Bool *fighting ){- const Int firstGround = ObserverCamera_groundOf( first, homes, homeCount );- std::vector< DirectorHeat > apart;+ candidates->clear();for( size_t index = 0; index < hits.size(); index++ )+ if( ( sources[ index ] & side ) != 0 )+ candidates->push_back( hits[ index ] );+ *fighting = !candidates->empty();+ if( *fighting )+ return;+ for( size_t index = 0; index < sights.size(); index++ )+ if( ( owners[ index ] & side ) != 0 )+ candidates->push_back( sights[ index ] );+}++//-------------------------------------------------------------------------------------------------+Bool ObserverCamera_sidePlaces( const std::vector< DirectorHeat > *dealt, Real apart, Coord2D *places, Real *heats )+{+ heats[ 0 ] = heats[ 1 ] = 0.0f;+ for( Int lead = 0; lead < 2; lead++ ){- const Real dx = hits[ index ].position.x - first.x;- const Real dy = hits[ index ].position.y - first.y;- if( homeCount >= 2 && ObserverCamera_groundOf( hits[ index ].position, homes, homeCount ) == firstGround )+ const Int other = 1 - lead;+ Coord2D tried[ 2 ];+ Real triedHeat[ 2 ] = { 0.0f, 0.0f };+ if( !ObserverCamera_hottestPlace( dealt[ lead ], &tried[ lead ], &triedHeat[ lead ] ) )continue;- if( dx * dx + dy * dy > needed * needed )- apart.push_back( hits[ index ] );+ if( !ObserverCamera_secondPlace( dealt[ other ], tried[ lead ], apart, &tried[ other ], &triedHeat[ other ] ) )+ continue;+ if( min( triedHeat[ 0 ], triedHeat[ 1 ] ) <= min( heats[ 0 ], heats[ 1 ] ) )+ continue;+ for( Int side = 0; side < 2; side++ )+ {+ places[ side ] = tried[ side ];+ heats[ side ] = triedHeat[ side ];+ }}- return ObserverCamera_hottestPlace( apart, place, heat );+ return heats[ 0 ] > 0.0f;}//-------------------------------------------------------------------------------------------------@@ -1304,9 +1322,8 @@ Bool ObserverCamera_fightLasts( const std::vector< DirectorMoment > &timeline, c//-------------------------------------------------------------------------------------------------Int ObserverCamera_plannedSecond( const std::vector< DirectorMoment > &timeline, const Coord2D &first, UnsignedInt frame, Real apart,- Bool keeping, const Coord2D *homes, Int homeCount )+ Bool keeping ){- const Int firstGround = ObserverCamera_groundOf( first, homes, homeCount );Int best = -1;for( size_t index = 0; index < timeline.size(); index++ ){@@ -1317,8 +1334,6 @@ Int ObserverCamera_plannedSecond( const std::vector< DirectorMoment > &timeline,continue;if( within( fight.place, first, apart ) )continue;- if( homeCount >= 2 && ObserverCamera_groundOf( fight.place, homes, homeCount ) == firstGround )- continue;if( best < 0 || fight.peak > timeline[ best ].peak )best = (Int)index;}@@ -1517,6 +1532,11 @@ void ObserverCamera::reset( void )m_winnerFrame = 0;m_fights.clear();m_fightSides.clear();+ m_fightSources.clear();+ m_sights.clear();+ m_sightOwners.clear();+ m_sidePlayers[ 0 ] = m_sidePlayers[ 1 ] = NULL;+ m_sideFirst.x = m_sideFirst.y = 0.0f;m_broadcast.clear();m_broadcastTop = 0.0f;m_screenGround = 0.0f;@@ -1531,7 +1551,6 @@ void ObserverCamera::reset( void )m_introDone = FALSE;m_introGlide = FALSE;m_panesLeftPlace.x = m_panesLeftPlace.y = 0.0f;- m_homeCount = 0;m_paneCount = 0;m_paneProgress = 0.0f;m_lineProgress = 0.0f;@@ -1548,7 +1567,6 @@ void ObserverCamera::reset( void ){m_paneRays[ pane ] = 0.0f;m_panePlayers[ pane ] = NULL;- m_homes[ pane ].x = m_homes[ pane ].y = 0.0f;m_paneSubject[ pane ].x = m_paneSubject[ pane ].y = 0.0f;m_paneMark[ pane ].x = m_paneMark[ pane ].y = m_paneMark[ pane ].z = 0.0f;m_paneCentres[ pane ].x = m_paneCentres[ pane ].y = 0.0f;@@ -2160,8 +2178,10 @@ Real ObserverCamera::splitApart( const Coord2D &second ) const* going up, or a dozer clearing trees, is no reason to split. A special power the director is* showing counts as a fight beside it. *///--------------------------------------------------------------------------------------------------void ObserverCamera::updateSplit( void )+Bool ObserverCamera::updateSplit( void ){+ if( m_sidePlayers[ 0 ] != NULL )+ return updateSideSplit();const UnsignedInt frame = TheGameLogic->getFrame();if( m_paneCount < 2 )measureScreenGround();@@ -2174,7 +2194,7 @@ void ObserverCamera::updateSplit( void )const Real searched = m_split ? m_splitApart : splitApart( m_place );Coord2D second = { 0.0f, 0.0f };Real secondHeat = 0.0f;- ObserverCamera_secondPlace( m_fights, m_place, searched, m_homes, m_homeCount, &second, &secondHeat );+ ObserverCamera_secondPlace( m_fights, m_place, searched, &second, &secondHeat );if( secondHeat > 0.0f && ObserverCamera_fizzles( m_timeline, second, frame ) )secondHeat = 0.0f;// with a timeline a split is decided before it opens: pane 0 needs a fight the scouting pass saw@@ -2192,7 +2212,7 @@ void ObserverCamera::updateSplit( void )const Real sameGround = searched * SPLIT_SAME_GROUND_SHARE;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, m_homes, m_homeCount ) : -1;+ const Int planned = mayPlan ? ObserverCamera_plannedSecond( m_timeline, m_place, frame, searched, m_split ) : -1;// a planned moment whose split was ended early does not open anotherconst Bool plannedSplit = planned >= 0 && planned != m_spentMoment;if( plannedSplit && frame < m_timeline[ planned ].start && ( secondHeat <= 0.0f || !within( second, m_timeline[ planned ].place, sameGround ) ) )@@ -2240,9 +2260,8 @@ void ObserverCamera::updateSplit( void )}if( split != m_split ){- DEBUG_LOG(( "OBSCAM frame %u split %s, first (%.0f,%.0f) heat %.1f on home %d's ground, second (%.0f,%.0f) heat %.1f on home %d's, %.0f apart of %.0f needed, screen %.0f%s\n",- frame, split ? "on" : "off", m_place.x, m_place.y, firstHeat, ObserverCamera_groundOf( m_place, m_homes, m_homeCount ), shown.x, shown.y,- secondHeat, ObserverCamera_groundOf( shown, m_homes, m_homeCount ), apart, needed, m_screenGround, plannedSplit ? ", planned" : "" ));+ DEBUG_LOG(( "OBSCAM frame %u split %s, first heat %.1f, second (%.0f,%.0f) heat %.1f, %.0f apart of %.0f needed, screen %.0f%s\n",+ frame, split ? "on" : "off", firstHeat, shown.x, shown.y, secondHeat, apart, needed, m_screenGround, plannedSplit ? ", planned" : "" ));m_split = split;m_splitChanged = frame;m_splitApart = needed;@@ -2253,6 +2272,93 @@ void ObserverCamera::updateSplit( void )}if( m_split )m_secondPlace = shown;+ return FALSE;+}++//-------------------------------------------------------------------------------------------------+/** -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+ * a player is doing is where his own fire falls, or with none his base and his army on the move.+ * The split is up whenever the two are far enough apart, the opening's panes handing straight over+ * to it, and the director follows pane 0's player while it is. It goes when a pane's player turns+ * to something somewhere else, when the two come together (one fight both are in, which the whole+ * screen shows), or after SPLIT_MOST_FRAMES with a fight in it and twice that without, so the+ * director gets its turn. TRUE when it moved the director. */+//-------------------------------------------------------------------------------------------------+Bool ObserverCamera::updateSideSplit( void )+{+ const UnsignedInt frame = TheGameLogic->getFrame();+ if( m_paneCount < 2 )+ measureScreenGround();+ std::vector< DirectorHeat > candidates[ 2 ];+ Bool fighting[ 2 ];+ for( Int side = 0; side < 2; side++ )+ ObserverCamera_sideCandidates( m_fights, m_fightSources, m_sights, m_sightOwners, m_sidePlayers[ side ]->getPlayerMask(),+ &candidates[ side ], &fighting[ side ] );+ Coord2D places[ 2 ];+ places[ 0 ] = m_sideFirst;+ places[ 1 ] = m_secondPlace;+ Real heats[ 2 ];+ const Real searched = m_split ? m_splitApart : SPLIT_APART;+ const Bool found = ObserverCamera_sidePlaces( candidates, searched, places, heats );+ const Real ax = places[ 1 ].x - places[ 0 ].x;+ const Real ay = places[ 1 ].y - places[ 0 ].y;+ const Real apart = sqrtf( ax * ax + ay * ay );+ const Real needed = m_split ? m_splitApart : max( SPLIT_APART, max( paneGround( places[ 0 ] ), paneGround( places[ 1 ] ) ) );+ const UnsignedInt since = frame >= m_splitChanged ? frame - m_splitChanged : 0;+ const Real sameGround = needed * SPLIT_SAME_GROUND_SHARE;++ Bool split = found && apart > needed && ( m_split || since >= SPLIT_REST_FRAMES );+ if( m_split && since >= SPLIT_LEAST_FRAMES )+ {+ const Bool fight = fighting[ 0 ] || fighting[ 1 ];+ const Bool upTooLong = since >= ( fight ? SPLIT_MOST_FRAMES : 2 * SPLIT_MOST_FRAMES );+ const Bool paneZeroLeft = found && !within( places[ 0 ], m_sideFirst, sameGround );+ const Bool paneOneLeft = found && !within( places[ 1 ], 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 ? " pane 0's player turned elsewhere" : "", paneOneLeft ? " pane 1's player turned elsewhere" : "" ));+ split = FALSE;+ }+ }+ else if( m_split )+ split = TRUE;++ if( split != m_split )+ {+ DEBUG_LOG(( "OBSCAM frame %u split %s, pane 0 player %d %s (%.0f,%.0f) heat %.1f, pane 1 player %d %s (%.0f,%.0f) heat %.1f, %.0f apart of %.0f needed%s\n",+ frame, split ? "on" : "off", m_sidePlayers[ 0 ]->getPlayerIndex(), fighting[ 0 ] ? "fighting" : "sights", places[ 0 ].x, places[ 0 ].y,+ heats[ 0 ], m_sidePlayers[ 1 ]->getPlayerIndex(), fighting[ 1 ] ? "fighting" : "sights", places[ 1 ].x, places[ 1 ].y, heats[ 1 ],+ apart, needed, m_intro ? ", from the opening" : "" ));+ m_split = split;+ m_splitChanged = frame;+ m_splitApart = needed;+ m_paneSurvivor = 0;+ if( split )+ {+ m_sideFirst = places[ 0 ];+ m_secondPlace = places[ 1 ];+ }+ }+ if( !m_split )+ return FALSE;+ // each pane follows its player once his place has moved a little, the way the director follows,+ // and only within the split's same ground: further is a cut, which chooseTarget refuses pane 0, and+ // following it anyway left pane 0 held on the old ground for 360 frames while the place it was+ // compared against had already gone+ if( !within( places[ 0 ], m_sideFirst, DIRECTOR_FOLLOW_SLACK ) && within( places[ 0 ], m_sideFirst, sameGround ) )+ m_sideFirst = places[ 0 ];+ if( !within( places[ 1 ], m_secondPlace, DIRECTOR_FOLLOW_SLACK ) && within( places[ 1 ], m_secondPlace, sameGround ) )+ m_secondPlace = places[ 1 ];+ if( within( m_place, m_sideFirst, DIRECTOR_FOLLOW_SLACK ) )+ return FALSE;+ m_place = m_sideFirst;+ m_placeKind = fighting[ 0 ] ? PLACE_FIGHT : PLACE_SIGHT;+ m_placePeak = heats[ 0 ];+ m_placeSince = frame;+ m_placeValid = TRUE;+ return TRUE;}//-------------------------------------------------------------------------------------------------@@ -2341,6 +2447,16 @@ void ObserverCamera::advancePanes( UnsignedInt frame )next = PANES_HELD;break;case PANES_HELD:+ // a match of two whose split is already up keeps the opening's panes: the same player in the+ // same pane, from his base to whatever he does next+ if( m_intro && elapsed >= PANE_INTRO_FRAMES && m_split && m_sidePlayers[ 0 ] != NULL )+ {+ DEBUG_LOG(( "OBSCAM frame %u the opening's panes stay as the split\n", frame ));+ m_intro = FALSE;+ // from what each pane shows now, so neither cuts; updateSideSplit follows from there+ m_sideFirst = m_paneSubject[ 0 ];+ m_secondPlace = m_paneSubject[ 1 ];+ }if( m_intro ? elapsed >= PANE_INTRO_FRAMES : !m_split )next = PANES_UNDRAW;// the opening ends on pane 0's base and the director stays there until something happens;@@ -2514,10 +2630,13 @@ void ObserverCamera::pickIntroBases( void )m_paneMark[ pane ].y = m_paneSubject[ pane ].y;m_paneMark[ pane ].z = TheTerrainLogic->getGroundHeight( m_paneSubject[ pane ].x, m_paneSubject[ pane ].y );}- for( Int pane = 0; pane < m_paneCount; pane++ )- m_homes[ pane ] = m_paneSubject[ pane ];- m_homeCount = m_paneCount;- DEBUG_LOG(( "OBSCAM frame %u %d homes, a split's second fight on another's ground\n", TheGameLogic->getFrame(), m_homeCount ));+ if( m_paneCount == 2 )+ {+ m_sidePlayers[ 0 ] = m_panePlayers[ 0 ];+ m_sidePlayers[ 1 ] = m_panePlayers[ 1 ];+ DEBUG_LOG(( "OBSCAM frame %u splits follow player %d in pane 0 and player %d in pane 1\n", TheGameLogic->getFrame(),+ m_sidePlayers[ 0 ]->getPlayerIndex(), m_sidePlayers[ 1 ]->getPlayerIndex() ));+ }}//-------------------------------------------------------------------------------------------------@@ -2689,6 +2808,9 @@ void ObserverCamera::getPaneCircle( Int pane, Coord2D *centre, Real *radius ) co//-------------------------------------------------------------------------------------------------PlayerMaskType ObserverCamera::getPaneSides( Int pane ) const{+ // a match of two names each pane's own player+ if( m_sidePlayers[ 0 ] != NULL && pane < 2 )+ return m_sidePlayers[ pane ]->getPlayerMask();const Coord2D &subject = pane == 0 ? m_panesLeftPlace : m_secondPlace;PlayerMaskType sides = 0;for( size_t index = 0; index < m_fights.size(); index++ )@@ -2904,6 +3026,8 @@ Bool ObserverCamera::directorPlace( const Player *narrowTo, Coord2D *place )std::vector< DirectorHeat > hits;std::vector< DirectorHeat > fights;std::vector< PlayerMaskType > sides;+ std::vector< PlayerMaskType > sources;+ std::vector< PlayerMaskType > sightOwners;std::vector< DirectorHeat > sights;for( Object *obj = TheGameLogic->getFirstObject(); obj != NULL; obj = obj->getNextObject() ){@@ -2921,6 +3045,9 @@ Bool ObserverCamera::directorPlace( const Player *narrowTo, Coord2D *place )const Bool busy = marching || obj->testStatus( OBJECT_STATUS_UNDER_CONSTRUCTION );heat.weight = ObserverCamera_sightWeight( cost, obj->isKindOf( KINDOF_STRUCTURE ), busy, superweapon );sights.push_back( heat );+ // a neutral thing with a price, a civilian building, has no player and is nobody's sight+ const Player *owner = obj->getControllingPlayer();+ sightOwners.push_back( owner != NULL ? owner->getPlayerMask() : 0 );}// a thing with no body module takes no damage, so it has no hits to count@@ -2942,9 +3069,19 @@ Bool ObserverCamera::directorPlace( const Player *narrowTo, Coord2D *place )continue;fights.push_back( heat );sides.push_back( between );+ sources.push_back( body->getLastDamageInfo()->in.m_sourcePlayerMask );}m_fights = fights;m_fightSides = sides;+ m_fightSources = sources;+ m_sights = sights;+ m_sightOwners = sightOwners;+ // a split a pane each player holds the director on pane 0's player; updateSideSplit moves it+ if( m_split && m_sidePlayers[ 0 ] != NULL && narrowTo == NULL )+ {+ *place = m_place;+ return TRUE;+ }Coord2D hottest;Real hottestHeat = 0.0f;@@ -3131,8 +3268,8 @@ Bool ObserverCamera::chooseTarget( const ViewLocation ¤t, ViewLocation *taCoord2D place;if( !directorPlace( narrowTo, &place ) )return FALSE;- if( TheGlobalData->m_directorRecord && m_placeScanned == TheGameLogic->getFrame() )- updateSplit();+ if( TheGlobalData->m_directorRecord && m_placeScanned == TheGameLogic->getFrame() && updateSplit() )+ place = m_place;// the opening shows the first player's base in pane 0. Pane 0 keeps its place until the panes// have gone: a split ends when the director moves onto the second fight, and pane 0 going there at// once showed that fight twice while pane 1 slid outdiff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.hindex 77506a59c..8c347c6ca 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h@@ -96,6 +96,8 @@ protected:void cacheLandmarks( void ); ///< rebuild the landmark list from both object listsvoid collectLandmarks( const RadarObject *listHead ); ///< add the landmarks of one list to the cachevoid drawViewBox( Int pixelX, Int pixelY, Int width, Int height ); ///< draw view box+ void drawPaneBox( Int pane, Int pixelX, Int pixelY, Int width, Int height ); ///< -directorrecord: one pane's view box+ void drawBoxLines( const ICoord2D *corners ); ///< a view box's lines through its four corners in pixelsvoid buildTerrainTexture( TerrainLogic *terrain ); ///< create the terrain texture of the radarvoid drawIcons( Int pixelX, Int pixelY, Int width, Int height ); ///< draw all of the radar iconsvoid renderObjectList( const RadarObject *listHead, TextureClass *texture, Bool calcHero = FALSE ); ///< render an object list to the texture@@ -134,6 +136,7 @@ protected://Bool m_reconstructViewBox; ///< true when we need to reconstruct the boxICoord2D m_viewBox[ 4 ]; ///< radar cell points for the 4 corners of view box+ Int m_viewBoxesDrawn; ///< how many view boxes the last draw had, one a -directorrecord pane// By value, not by pointer into the object. The list is rebuilt every OVERLAY_REFRESH_RATE// frames and read on every one of them, so a hero killed in between left a pointer into adiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cppindex f6ce53e3c..2bd6c8dc6 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp@@ -426,24 +426,6 @@ void W3DRadar::drawViewBox( Int pixelX, Int pixelY, Int width, Int height )ICoord2D ulRadar;Coord3D ulWorld;ICoord2D ulStart = { 0, 0 };- ICoord2D start, end;- ICoord2D clipStart, clipEnd;- Real lineWidth = 1.0f;- Color topColor = GameMakeColor( 225, 225, 0, 255 );- Color bottomColor = GameMakeColor( 158, 158, 0, 255 );-- //- // setup the clipping region ... note that this clipping region is not over just the- // radar image area ... it's in the WHOLE window available for the radar- //- IRegion2D clipRegion;- ICoord2D radarWindowSize, radarWindowScreenPos;- m_radarWindow->winGetSize( &radarWindowSize.x, &radarWindowSize.y );- m_radarWindow->winGetScreenPosition( &radarWindowScreenPos.x, &radarWindowScreenPos.y );- clipRegion.lo.x = radarWindowScreenPos.x;- clipRegion.lo.y = radarWindowScreenPos.y;- clipRegion.hi.x = radarWindowScreenPos.x + radarWindowSize.x;- clipRegion.hi.y = radarWindowScreenPos.y + radarWindowSize.y;// convert top left of screen into world positionTheTacticalView->getOrigin( &ulScreen.x, &ulScreen.y );@@ -468,43 +450,87 @@ void W3DRadar::drawViewBox( Int pixelX, Int pixelY, Int width, Int height )// (upper left, upper right, lower right, lower left)//ICoord2D radar;-- // top line- start = ulStart;- radar.x = ulRadar.x + m_viewBox[ 1 ].x;- radar.y = ulRadar.y + m_viewBox[ 1 ].y;- radarToPixel( &radar, &end, pixelX, pixelY, width, height );- if( ClipLine2D( &start, &end, &clipStart, &clipEnd, &clipRegion ) )- TheDisplay->drawLine( clipStart.x, clipStart.y, clipEnd.x, clipEnd.y,- lineWidth, topColor );-- // right line- start = end;- radar.x += m_viewBox[ 2 ].x;- radar.y += m_viewBox[ 2 ].y;- radarToPixel( &radar, &end, pixelX, pixelY, width, height );- if( ClipLine2D( &start, &end, &clipStart, &clipEnd, &clipRegion ) )- TheDisplay->drawLine( clipStart.x, clipStart.y, clipEnd.x, clipEnd.y,- lineWidth, topColor, bottomColor );-- // bottom line- start = end;- radar.x += m_viewBox[ 3 ].x;- radar.y += m_viewBox[ 3 ].y;- radarToPixel( &radar, &end, pixelX, pixelY, width, height );- if( ClipLine2D( &start, &end, &clipStart, &clipEnd, &clipRegion ) )- TheDisplay->drawLine( clipStart.x, clipStart.y, clipEnd.x, clipEnd.y,- lineWidth, bottomColor );-- // left line- start = end;- end = ulStart;- if( ClipLine2D( &start, &end, &clipStart, &clipEnd, &clipRegion ) )- TheDisplay->drawLine( clipStart.x, clipStart.y, clipEnd.x, clipEnd.y,- lineWidth, bottomColor, topColor );+ ICoord2D corners[ 4 ];+ corners[ 0 ] = ulStart;+ radar = ulRadar;+ for( Int corner = 1; corner < 4; corner++ )+ {+ radar.x += m_viewBox[ corner ].x;+ radar.y += m_viewBox[ corner ].y;+ radarToPixel( &radar, &corners[ corner ], pixelX, pixelY, width, height );+ }+ drawBoxLines( corners );} // end drawViewBox+//-------------------------------------------------------------------------------------------------+/** The view box's four lines through corners in pixels, upper left, upper right, lower right and+ * lower left, clipped to the whole window available for the radar and not just its image */+//-------------------------------------------------------------------------------------------------+void W3DRadar::drawBoxLines( const ICoord2D *corners )+{+ const Real lineWidth = 1.0f;+ const Color topColor = GameMakeColor( 225, 225, 0, 255 );+ const Color bottomColor = GameMakeColor( 158, 158, 0, 255 );+ // each line's colour at its start and its end: the top light, the bottom dark, the sides between+ const Color fromColor[ 4 ] = { topColor, topColor, bottomColor, bottomColor };+ const Color toColor[ 4 ] = { topColor, bottomColor, bottomColor, topColor };++ IRegion2D clipRegion;+ ICoord2D radarWindowSize, radarWindowScreenPos;+ m_radarWindow->winGetSize( &radarWindowSize.x, &radarWindowSize.y );+ m_radarWindow->winGetScreenPosition( &radarWindowScreenPos.x, &radarWindowScreenPos.y );+ clipRegion.lo.x = radarWindowScreenPos.x;+ clipRegion.lo.y = radarWindowScreenPos.y;+ clipRegion.hi.x = radarWindowScreenPos.x + radarWindowSize.x;+ clipRegion.hi.y = radarWindowScreenPos.y + radarWindowSize.y;++ for( Int line = 0; line < 4; line++ )+ {+ ICoord2D start = corners[ line ];+ ICoord2D end = corners[ ( line + 1 ) % 4 ];+ ICoord2D clipStart, clipEnd;+ if( ClipLine2D( &start, &end, &clipStart, &clipEnd, &clipRegion ) )+ TheDisplay->drawLine( clipStart.x, clipStart.y, clipEnd.x, clipEnd.y, lineWidth, fromColor[ line ], toColor[ line ] );+ }+}++//-------------------------------------------------------------------------------------------------+/** -directorrecord's box for one pane: the square round the circle the pane fits its subject in,+ * put on the ground through that pane's own camera. The view is moved to a pane past the first+ * for the four corners and put back, the way GameClient's pane pass moves it for a draw */+//-------------------------------------------------------------------------------------------------+void W3DRadar::drawPaneBox( Int pane, Int pixelX, Int pixelY, Int width, Int height )+{+ Coord2D centre;+ Real radius = 0.0f;+ TheObserverCamera.getPaneCircle( pane, ¢re, &radius );+ ViewLocation own;+ if( pane != 0 )+ {+ TheTacticalView->getLocation( &own );+ TheTacticalView->setLocation( &TheObserverCamera.getPaneView( pane ) );+ }+ const Real sideX[ 4 ] = { -1.0f, 1.0f, 1.0f, -1.0f };+ const Real sideY[ 4 ] = { -1.0f, -1.0f, 1.0f, 1.0f };+ ICoord2D corners[ 4 ];+ for( Int corner = 0; corner < 4; corner++ )+ {+ ICoord2D screen;+ screen.x = REAL_TO_INT( centre.x + sideX[ corner ] * radius );+ screen.y = REAL_TO_INT( centre.y + sideY[ corner ] * radius );+ Coord3D world;+ TheTacticalView->screenToWorldAtZ( &screen, &world, getTerrainAverageZ() );+ ICoord2D radar;+ radar.x = world.x / ( m_mapExtent.width() / RADAR_CELL_WIDTH );+ radar.y = world.y / ( m_mapExtent.height() / RADAR_CELL_HEIGHT );+ radarToPixel( &radar, &corners[ corner ], pixelX, pixelY, width, height );+ }+ if( pane != 0 )+ TheTacticalView->setLocation( &own );+ drawBoxLines( corners );+}+// ------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------void W3DRadar::drawSingleBeaconEvent( Int pixelX, Int pixelY, Int width, Int height, Int index )@@ -991,6 +1017,7 @@ W3DRadar::W3DRadar( void )m_textureHeight = RADAR_CELL_HEIGHT;m_reconstructViewBox = TRUE;+ m_viewBoxesDrawn = 1;for( Int i = 0; i < 4; i++ ){@@ -1603,8 +1630,21 @@ void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height )if( m_reconstructViewBox )reconstructViewBox();+ // -directorrecord's panes, the opening's included, each get a box of their own; the one view box+ // stood for pane 0 alone while the other half of the screen showed somewhere else+ const Int boxes = TheGlobalData->m_directorRecord ? TheObserverCamera.getDrawnPaneCount() : 1;+ if( boxes != m_viewBoxesDrawn )+ {+ DEBUG_LOG(( "RADAR frame %u %d view boxes\n", TheGameLogic->getFrame(), boxes ));+ m_viewBoxesDrawn = boxes;+ }+// draw the view region on top of the radar reconstructing if necessary- drawViewBox( ul.x, ul.y, scaledWidth, scaledHeight );+ if( boxes < 2 )+ drawViewBox( ul.x, ul.y, scaledWidth, scaledHeight );+ else+ for( Int pane = 0; pane < boxes; pane++ )+ drawPaneBox( pane, ul.x, ul.y, scaledWidth, scaledHeight );} // end drawdiff --git a/GeneralsMD/Code/Tests/test_observer_camera.inc b/GeneralsMD/Code/Tests/test_observer_camera.incindex d3f45007c..8e3d92b9a 100644--- a/GeneralsMD/Code/Tests/test_observer_camera.inc+++ b/GeneralsMD/Code/Tests/test_observer_camera.inc@@ -340,49 +340,86 @@ TEST(the_recording_splits_for_a_second_fight_far_from_the_first_and_never_for_thCoord2D second;Real heat = 0.0f;const Real needed = 660.0f;- CHECK( !ObserverCamera_secondPlace( hits, first, needed, NULL, 0, &second, &heat ) );+ CHECK( !ObserverCamera_secondPlace( hits, first, needed, &second, &heat ) );for( Int each = 0; each < 3; each++ )hits.push_back( directorHit( 3000.0f, 3000.0f + each * 20.0f ) );- CHECK( ObserverCamera_secondPlace( hits, first, needed, NULL, 0, &second, &heat ) );+ CHECK( ObserverCamera_secondPlace( hits, first, needed, &second, &heat ) );CHECK_NEAR( heat, 3.0f, 0.001f );CHECK_NEAR( second.x, 3000.0f, 0.001f );CHECK_NEAR( second.y, 3020.0f, 0.001f );// a picture that spans more ground wants the second fight further off- CHECK( !ObserverCamera_secondPlace( hits, first, 3000.0f, NULL, 0, &second, &heat ) );+ CHECK( !ObserverCamera_secondPlace( hits, first, 3000.0f, &second, &heat ) );}-TEST(the_recording_splits_onto_the_other_players_ground)+TEST(the_recording_splits_a_match_of_two_into_a_pane_each_player){- // S1-A1 on Tournament Desert: USA's base in the south, China's in the north- Coord2D homes[ 2 ];- homes[ 0 ].x = 1011.0f;- homes[ 0 ].y = 2103.0f;- homes[ 1 ].x = 1005.0f;- homes[ 1 ].y = 584.0f;- CHECK_EQ( ObserverCamera_groundOf( homes[ 0 ], homes, 2 ), 0 );- CHECK_EQ( ObserverCamera_groundOf( homes[ 1 ], homes, 2 ), 1 );-- // frame 25816: the director at USA's west edge, a hotter fight further up in USA's half and a- // smaller one in China's. Pane 1 had taken the hotter one, two USA fights side by side- Coord2D first;- first.x = 421.0f;- first.y = 2225.0f;+ const PlayerMaskType sides[ 2 ] = { 1 << 2, 1 << 3 };std::vector< DirectorHeat > hits;+ std::vector< PlayerMaskType > sources;+ // one fight at 1000,1000 where both fire, player 0 the hotter therefor( Int each = 0; each < 4; each++ )- hits.push_back( directorHit( 1074.0f + each * 20.0f, 1632.0f ) );+ {+ hits.push_back( directorHit( 1000.0f + each * 20.0f, 1000.0f ) );+ sources.push_back( sides[ 0 ] );+ }+ for( Int each = 0; each < 3; each++ )+ {+ hits.push_back( directorHit( 1000.0f, 1020.0f + each * 20.0f ) );+ sources.push_back( sides[ 1 ] );+ }+ // each player's base, his sights while he fires at nothing+ std::vector< DirectorHeat > sights;+ std::vector< PlayerMaskType > owners;+ sights.push_back( directorHit( 500.0f, 4000.0f ) );+ owners.push_back( sides[ 0 ] );+ sights.push_back( directorHit( 4000.0f, 500.0f ) );+ owners.push_back( sides[ 1 ] );+ Coord2D places[ 2 ];+ Real heats[ 2 ];+ Bool fighting[ 2 ];+ auto pairUp = [ & ]( const std::vector< DirectorHeat > &fights ) -> Bool+ {+ std::vector< DirectorHeat > candidates[ 2 ];+ for( Int side = 0; side < 2; side++ )+ ObserverCamera_sideCandidates( fights, sources, sights, owners, sides[ side ], &candidates[ side ], &fighting[ side ] );+ return ObserverCamera_sidePlaces( candidates, 660.0f, places, heats );+ };++ // before anybody fires, a pane each base+ const std::vector< DirectorHeat > none;+ CHECK( pairUp( none ) );+ CHECK( !fighting[ 0 ] );+ CHECK_NEAR( places[ 0 ].x, 500.0f, 0.001f );+ CHECK_NEAR( places[ 1 ].x, 4000.0f, 0.001f );++ // both players in one place is no split+ CHECK( !pairUp( hits ) );+ CHECK( fighting[ 0 ] && fighting[ 1 ] );+ CHECK_NEAR( heats[ 1 ], 0.0f, 0.001f );++ // player 1 also fires far off: player 0's pane keeps the first fight, player 1's takes his otherfor( Int each = 0; each < 2; each++ )- hits.push_back( directorHit( 1284.0f + each * 20.0f, 564.0f ) );- Coord2D second;- Real heat = 0.0f;- CHECK( ObserverCamera_secondPlace( hits, first, 859.0f, NULL, 0, &second, &heat ) );- CHECK_NEAR( second.y, 1632.0f, 0.001f );- CHECK( ObserverCamera_secondPlace( hits, first, 859.0f, homes, 2, &second, &heat ) );- CHECK_NEAR( second.y, 564.0f, 0.001f );- CHECK_NEAR( heat, 2.0f, 0.001f );- // nothing on China's ground: no split at all rather than a second USA fight- hits.resize( 4 );- CHECK( !ObserverCamera_secondPlace( hits, first, 859.0f, homes, 2, &second, &heat ) );+ {+ hits.push_back( directorHit( 3000.0f, 3000.0f + each * 20.0f ) );+ sources.push_back( sides[ 1 ] );+ }+ CHECK( pairUp( hits ) );+ CHECK_NEAR( places[ 0 ].y, 1000.0f, 0.001f );+ CHECK_NEAR( places[ 1 ].x, 3000.0f, 0.001f );+ CHECK_NEAR( heats[ 0 ], 4.0f, 0.001f );+ CHECK_NEAR( heats[ 1 ], 2.0f, 0.001f );++ // player 0 firing far off instead, and hotter there than player 1 elsewhere: the panes keep their+ // players, player 1 on the first fight and player 0 on his own far one+ sources[ 7 ] = sources[ 8 ] = sides[ 0 ];+ hits.push_back( directorHit( 3000.0f, 3040.0f ) );+ sources.push_back( sides[ 0 ] );+ CHECK( pairUp( hits ) );+ CHECK_NEAR( places[ 0 ].x, 3000.0f, 0.001f );+ CHECK_NEAR( places[ 1 ].y, 1040.0f, 0.001f );+ CHECK_NEAR( heats[ 0 ], 3.0f, 0.001f );+ CHECK_NEAR( heats[ 1 ], 3.0f, 0.001f );}TEST(the_recording_splits_for_a_big_second_fight_holds_it_and_rests_after)@@ -452,7 +489,7 @@ TEST(the_recording_splits_only_beside_a_real_fight)first.x = first.y = 1000.0f;Coord2D second;Real heat = 0.0f;- CHECK( !ObserverCamera_secondPlace( none, first, 660.0f, NULL, 0, &second, &heat ) );+ CHECK( !ObserverCamera_secondPlace( none, first, 660.0f, &second, &heat ) );}static Real paneArea( const Real *rays, Int count, Int pane, Int width, Int height )@@ -939,12 +976,12 @@ TEST(the_recording_splits_before_a_known_second_fight_far_from_the_first)first.x = first.y = 1000.0f;// three seconds ahead: at four pane 1 sat on an empty bridgeconst UnsignedInt lead = 3 * LOGICFRAMES_PER_SECOND;- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 1000 - lead - 1, 660.0f, FALSE, NULL, 0 ), -1 );- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 1000 - lead, 660.0f, FALSE, NULL, 0 ), 0 );- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 1500, 660.0f, TRUE, NULL, 0 ), 0 );- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 1501, 660.0f, TRUE, NULL, 0 ), -1 );+ CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 1000 - lead - 1, 660.0f, FALSE ), -1 );+ CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 1000 - lead, 660.0f, FALSE ), 0 );+ CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 1500, 660.0f, TRUE ), 0 );+ CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 1501, 660.0f, TRUE ), -1 );// the fight 4243 away is too near once the picture is so wide a split wants 4300- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 1000 - lead, 4300.0f, FALSE, NULL, 0 ), -1 );+ CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 1000 - lead, 4300.0f, FALSE ), -1 );}TEST(a_split_is_planned_only_beside_a_fight_that_outlasts_its_least_hold)@@ -981,31 +1018,10 @@ TEST(the_recording_splits_ahead_for_a_fight_still_to_begin_and_not_anew_for_one_first.x = 2346.0f;first.y = 1668.0f;// a split already up keeps the fight while it lasts- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 6451, 660.0f, TRUE, NULL, 0 ), 0 );+ CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 6451, 660.0f, TRUE ), 0 );// none up: where it began twenty seconds ago is no place to send a pane- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 6451, 660.0f, FALSE, NULL, 0 ), -1 );- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 5864, 660.0f, FALSE, NULL, 0 ), 0 );-}--TEST(the_recording_plans_its_split_onto_the_other_players_ground)-{- // the pair the scouting pass planned is held to the rule a live split keeps: the hotter fight in- // the director's own player's half loses to the smaller one in the other's- Coord2D homes[ 2 ];- homes[ 0 ].x = 1011.0f;- homes[ 0 ].y = 2103.0f;- homes[ 1 ].x = 1005.0f;- homes[ 1 ].y = 584.0f;- Coord2D first;- first.x = 421.0f;- first.y = 2225.0f;- std::vector< DirectorMoment > timeline;- timeline.push_back( scoutedFight( 1000, 1500, 1074.0f, 1632.0f, 20.0f ) );- timeline.push_back( scoutedFight( 1000, 1500, 1284.0f, 564.0f, 8.0f ) );- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 950, 859.0f, FALSE, NULL, 0 ), 0 );- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 950, 859.0f, FALSE, homes, 2 ), 1 );- timeline.pop_back();- CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 950, 859.0f, FALSE, homes, 2 ), -1 );+ CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 6451, 660.0f, FALSE ), -1 );+ CHECK_EQ( ObserverCamera_plannedSecond( timeline, first, 5864, 660.0f, FALSE ), 0 );}TEST(a_timeline_line_reads_back_as_the_moment_it_was_written_from)