From 386e7da89e7b040df7b39222013f97ec968a40a4 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:43:55 +0200 Subject: [PATCH 1/3] refactor(view): Remove friends from ViewLocation class --- Core/GameEngine/Include/GameClient/View.h | 9 +++------ Core/GameEngine/Source/GameClient/View.cpp | 10 +++++----- .../Source/GameClient/MessageStream/LookAtXlat.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Core/GameEngine/Include/GameClient/View.h b/Core/GameEngine/Include/GameClient/View.h index 8d937507f00..13b2e78310d 100644 --- a/Core/GameEngine/Include/GameClient/View.h +++ b/Core/GameEngine/Include/GameClient/View.h @@ -339,9 +339,6 @@ class View : public Snapshot // ------------------------------------------------------------------------------------------------ class ViewLocation { - friend class View; - friend class LookAtTranslator; - protected: Bool m_valid; ///< Is this location valid Coord3D m_pos; ///< Position of this view, in world coordinates @@ -353,28 +350,28 @@ class ViewLocation ViewLocation() { - m_valid = FALSE; + m_valid = false; m_pos.zero(); m_angle = 0.0f; m_pitch = 0.0f; m_zoom = 0.0f; } - const Coord3D& getPosition() const { return m_pos; } Bool isValid() const { return m_valid; } + const Coord3D& getPosition() const { return m_pos; } Real getAngle() const { return m_angle; } Real getPitch() const { return m_pitch; } Real getZoom() const { return m_zoom; } void init(Real x, Real y, Real z, Real angle, Real pitch, Real zoom) { + m_valid = true; m_pos.x = x; m_pos.y = y; m_pos.z = z; m_angle = angle; m_pitch = pitch; m_zoom = zoom; - m_valid = true; } }; diff --git a/Core/GameEngine/Source/GameClient/View.cpp b/Core/GameEngine/Source/GameClient/View.cpp index 5b36c14ea15..10945559379 100644 --- a/Core/GameEngine/Source/GameClient/View.cpp +++ b/Core/GameEngine/Source/GameClient/View.cpp @@ -215,12 +215,12 @@ void View::getLocation( ViewLocation *location ) */ void View::setLocation( const ViewLocation *location ) { - if ( location->m_valid ) + if ( location->isValid() ) { - setPosition(&location->m_pos); - setAngle(location->m_angle); - setPitch(location->m_pitch); - setZoom(location->m_zoom); + setPosition(&location->getPosition()); + setAngle(location->getAngle()); + setPitch(location->getPitch()); + setZoom(location->getZoom()); forceRedraw(); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp index 9a5be199f0c..133903eae5e 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp @@ -532,10 +532,10 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage ViewLocation currentView; TheTacticalView->getLocation(¤tView); GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_SET_REPLAY_CAMERA ); - msg->appendLocationArgument( currentView.m_pos ); - msg->appendRealArgument( currentView.m_angle ); - msg->appendRealArgument( currentView.m_pitch ); - msg->appendRealArgument( currentView.m_zoom ); + msg->appendLocationArgument( currentView.getPosition() ); + msg->appendRealArgument( currentView.getAngle() ); + msg->appendRealArgument( currentView.getPitch() ); + msg->appendRealArgument( currentView.getZoom() ); msg->appendIntegerArgument( (Int)TheMouse->getMouseCursor() ); msg->appendPixelArgument( m_currentPos ); } From afcf6b8157e48fe8a39690a31e5d547f97417edf Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Thu, 2 Apr 2026 20:22:30 +0200 Subject: [PATCH 2/3] Change ViewLocation member variable visibility --- Core/GameEngine/Include/GameClient/View.h | 69 ++++++++++++----------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/Core/GameEngine/Include/GameClient/View.h b/Core/GameEngine/Include/GameClient/View.h index 13b2e78310d..8eb96ce97aa 100644 --- a/Core/GameEngine/Include/GameClient/View.h +++ b/Core/GameEngine/Include/GameClient/View.h @@ -339,40 +339,41 @@ class View : public Snapshot // ------------------------------------------------------------------------------------------------ class ViewLocation { - protected: - Bool m_valid; ///< Is this location valid - Coord3D m_pos; ///< Position of this view, in world coordinates - Real m_angle; ///< Angle at which view has been rotated about the Z axis - Real m_pitch; ///< Angle at which view has been rotated about the Y axis - Real m_zoom; ///< Current zoom value - - public: - - ViewLocation() - { - m_valid = false; - m_pos.zero(); - m_angle = 0.0f; - m_pitch = 0.0f; - m_zoom = 0.0f; - } - - Bool isValid() const { return m_valid; } - const Coord3D& getPosition() const { return m_pos; } - Real getAngle() const { return m_angle; } - Real getPitch() const { return m_pitch; } - Real getZoom() const { return m_zoom; } - - void init(Real x, Real y, Real z, Real angle, Real pitch, Real zoom) - { - m_valid = true; - m_pos.x = x; - m_pos.y = y; - m_pos.z = z; - m_angle = angle; - m_pitch = pitch; - m_zoom = zoom; - } +public: + + ViewLocation() + { + m_valid = false; + m_pos.zero(); + m_angle = 0.0f; + m_pitch = 0.0f; + m_zoom = 0.0f; + } + + Bool isValid() const { return m_valid; } + const Coord3D& getPosition() const { return m_pos; } + Real getAngle() const { return m_angle; } + Real getPitch() const { return m_pitch; } + Real getZoom() const { return m_zoom; } + + void init(Real x, Real y, Real z, Real angle, Real pitch, Real zoom) + { + m_valid = true; + m_pos.x = x; + m_pos.y = y; + m_pos.z = z; + m_angle = angle; + m_pitch = pitch; + m_zoom = zoom; + } + +private: + + Bool m_valid; ///< Is this location valid + Coord3D m_pos; ///< Position of this view, in world coordinates + Real m_angle; ///< Angle at which view has been rotated about the Z axis + Real m_pitch; ///< Angle at which view has been rotated about the Y axis + Real m_zoom; ///< Current zoom value }; // TheSuperHackers @feature bobtista 31/01/2026 From 4a18f630c5901f7f315511d8bfb91d171ab9e355 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Thu, 2 Apr 2026 20:23:06 +0200 Subject: [PATCH 3/3] Replicate in Generals --- .../Source/GameClient/MessageStream/LookAtXlat.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp index 9f0ba7839e5..484f7df7c54 100644 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp @@ -533,10 +533,10 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage ViewLocation currentView; TheTacticalView->getLocation(¤tView); GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_SET_REPLAY_CAMERA ); - msg->appendLocationArgument( currentView.m_pos ); - msg->appendRealArgument( currentView.m_angle ); - msg->appendRealArgument( currentView.m_pitch ); - msg->appendRealArgument( currentView.m_zoom ); + msg->appendLocationArgument( currentView.getPosition() ); + msg->appendRealArgument( currentView.getAngle() ); + msg->appendRealArgument( currentView.getPitch() ); + msg->appendRealArgument( currentView.getZoom() ); msg->appendIntegerArgument( (Int)TheMouse->getMouseCursor() ); msg->appendPixelArgument( m_currentPos ); }