Skip to content

Commit 0508be4

Browse files
authored
refactor(view): Remove friends from ViewLocation class (#2516)
1 parent 6014188 commit 0508be4

4 files changed

Lines changed: 48 additions & 50 deletions

File tree

Core/GameEngine/Include/GameClient/View.h

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -339,43 +339,41 @@ class View : public Snapshot
339339
// ------------------------------------------------------------------------------------------------
340340
class ViewLocation
341341
{
342-
friend class View;
343-
friend class LookAtTranslator;
344-
345-
protected:
346-
Bool m_valid; ///< Is this location valid
347-
Coord3D m_pos; ///< Position of this view, in world coordinates
348-
Real m_angle; ///< Angle at which view has been rotated about the Z axis
349-
Real m_pitch; ///< Angle at which view has been rotated about the Y axis
350-
Real m_zoom; ///< Current zoom value
351-
352-
public:
353-
354-
ViewLocation()
355-
{
356-
m_valid = FALSE;
357-
m_pos.zero();
358-
m_angle = 0.0f;
359-
m_pitch = 0.0f;
360-
m_zoom = 0.0f;
361-
}
362-
363-
const Coord3D& getPosition() const { return m_pos; }
364-
Bool isValid() const { return m_valid; }
365-
Real getAngle() const { return m_angle; }
366-
Real getPitch() const { return m_pitch; }
367-
Real getZoom() const { return m_zoom; }
368-
369-
void init(Real x, Real y, Real z, Real angle, Real pitch, Real zoom)
370-
{
371-
m_pos.x = x;
372-
m_pos.y = y;
373-
m_pos.z = z;
374-
m_angle = angle;
375-
m_pitch = pitch;
376-
m_zoom = zoom;
377-
m_valid = true;
378-
}
342+
public:
343+
344+
ViewLocation()
345+
{
346+
m_valid = false;
347+
m_pos.zero();
348+
m_angle = 0.0f;
349+
m_pitch = 0.0f;
350+
m_zoom = 0.0f;
351+
}
352+
353+
Bool isValid() const { return m_valid; }
354+
const Coord3D& getPosition() const { return m_pos; }
355+
Real getAngle() const { return m_angle; }
356+
Real getPitch() const { return m_pitch; }
357+
Real getZoom() const { return m_zoom; }
358+
359+
void init(Real x, Real y, Real z, Real angle, Real pitch, Real zoom)
360+
{
361+
m_valid = true;
362+
m_pos.x = x;
363+
m_pos.y = y;
364+
m_pos.z = z;
365+
m_angle = angle;
366+
m_pitch = pitch;
367+
m_zoom = zoom;
368+
}
369+
370+
private:
371+
372+
Bool m_valid; ///< Is this location valid
373+
Coord3D m_pos; ///< Position of this view, in world coordinates
374+
Real m_angle; ///< Angle at which view has been rotated about the Z axis
375+
Real m_pitch; ///< Angle at which view has been rotated about the Y axis
376+
Real m_zoom; ///< Current zoom value
379377
};
380378

381379
// TheSuperHackers @feature bobtista 31/01/2026

Core/GameEngine/Source/GameClient/View.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ void View::getLocation( ViewLocation *location )
215215
*/
216216
void View::setLocation( const ViewLocation *location )
217217
{
218-
if ( location->m_valid )
218+
if ( location->isValid() )
219219
{
220-
setPosition(&location->m_pos);
221-
setAngle(location->m_angle);
222-
setPitch(location->m_pitch);
223-
setZoom(location->m_zoom);
220+
setPosition(&location->getPosition());
221+
setAngle(location->getAngle());
222+
setPitch(location->getPitch());
223+
setZoom(location->getZoom());
224224
forceRedraw();
225225
}
226226

Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,10 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
533533
ViewLocation currentView;
534534
TheTacticalView->getLocation(&currentView);
535535
GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_SET_REPLAY_CAMERA );
536-
msg->appendLocationArgument( currentView.m_pos );
537-
msg->appendRealArgument( currentView.m_angle );
538-
msg->appendRealArgument( currentView.m_pitch );
539-
msg->appendRealArgument( currentView.m_zoom );
536+
msg->appendLocationArgument( currentView.getPosition() );
537+
msg->appendRealArgument( currentView.getAngle() );
538+
msg->appendRealArgument( currentView.getPitch() );
539+
msg->appendRealArgument( currentView.getZoom() );
540540
msg->appendIntegerArgument( (Int)TheMouse->getMouseCursor() );
541541
msg->appendPixelArgument( m_currentPos );
542542
}

GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,10 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
532532
ViewLocation currentView;
533533
TheTacticalView->getLocation(&currentView);
534534
GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_SET_REPLAY_CAMERA );
535-
msg->appendLocationArgument( currentView.m_pos );
536-
msg->appendRealArgument( currentView.m_angle );
537-
msg->appendRealArgument( currentView.m_pitch );
538-
msg->appendRealArgument( currentView.m_zoom );
535+
msg->appendLocationArgument( currentView.getPosition() );
536+
msg->appendRealArgument( currentView.getAngle() );
537+
msg->appendRealArgument( currentView.getPitch() );
538+
msg->appendRealArgument( currentView.getZoom() );
539539
msg->appendIntegerArgument( (Int)TheMouse->getMouseCursor() );
540540
msg->appendPixelArgument( m_currentPos );
541541
}

0 commit comments

Comments
 (0)