Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Generals/Code/GameEngine/Include/GameClient/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class View : public Snapshot
virtual void setOrigin( Int x, Int y) { m_originX=x; m_originY=y;} ///< Sets location of top-left view corner on display
virtual void getOrigin( Int *x, Int *y) { *x=m_originX; *y=m_originY;} ///< Return location of top-left view corner on display

virtual void lockViewUntilFrame(UnsignedInt frame); ///< Locks the current view until the given frame is reached.
virtual void forceRedraw() = 0;

virtual void lookAt( const Coord3D *o ); ///< Center the view on the given coordinate
Expand Down Expand Up @@ -255,6 +256,8 @@ class View : public Snapshot
UnsignedInt m_id; ///< Rhe ID of this view
static UnsignedInt m_idNext; ///< Used for allocating view ID's for all views

UnsignedInt m_viewLockedUntilFrame;

Coord3D m_pos; ///< Position of this view, in world coordinates
Int m_width, m_height; ///< Dimensions of the view
Int m_originX, m_originY; ///< Location of top/left view corner
Expand Down
8 changes: 8 additions & 0 deletions Generals/Code/GameEngine/Source/GameClient/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ View::View( void )
{
//Added By Sadullah Nader
//Initialization(s) inserted
m_viewLockedUntilFrame = 0u;
m_currentHeightAboveGround = 0.0f;
m_defaultAngle = 0.0f;
m_defaultPitchAngle = 0.0f;
Expand Down Expand Up @@ -110,6 +111,8 @@ void View::reset( void )
{
// Only fixing the reported bug. Who knows what side effects resetting the rest could have.
m_zoomLimited = TRUE;

m_viewLockedUntilFrame = 0u;
}

/**
Expand All @@ -126,6 +129,11 @@ void View::zoom( Real height )
setHeightAboveGround(getHeightAboveGround() + height);
}

void View::lockViewUntilFrame(UnsignedInt frame)
{
m_viewLockedUntilFrame = frame;
}

/**
* Center the view on the given coordinate.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
loc.init(pos.x, pos.y, pos.z, angle, pitch, zoom);
TheTacticalView->setLocation( &loc );

// TheSuperHackers @fix xezon 18/09/2025 Lock the new location to avoid user input from changing the camera in this frame.
TheTacticalView->lockViewUntilFrame( getFrame() + 1 );

if (!TheLookAtTranslator->hasMouseMovedRecently())
{
TheMouse->setCursor( (Mouse::MouseCursor)(msg->getArgument( 4 )->integer) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ void W3DView::setCameraTransform( void )
{
if (TheGlobalData->m_headless)
return;

if (m_viewLockedUntilFrame > TheGameClient->getFrame())
return;

m_cameraHasMovedSinceRequest = true;
Matrix3D cameraTransform( 1 );

Expand Down
3 changes: 3 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameClient/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class View : public Snapshot
virtual void setOrigin( Int x, Int y) { m_originX=x; m_originY=y;} ///< Sets location of top-left view corner on display
virtual void getOrigin( Int *x, Int *y) { *x=m_originX; *y=m_originY;} ///< Return location of top-left view corner on display

virtual void lockViewUntilFrame(UnsignedInt frame); ///< Locks the current view until the given frame is reached.
virtual void forceRedraw() = 0;

virtual void lookAt( const Coord3D *o ); ///< Center the view on the given coordinate
Expand Down Expand Up @@ -259,6 +260,8 @@ class View : public Snapshot
UnsignedInt m_id; ///< Rhe ID of this view
static UnsignedInt m_idNext; ///< Used for allocating view ID's for all views

UnsignedInt m_viewLockedUntilFrame;

Coord3D m_pos; ///< Position of this view, in world coordinates
Int m_width, m_height; ///< Dimensions of the view
Int m_originX, m_originY; ///< Location of top/left view corner
Expand Down
8 changes: 8 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameClient/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ View::View( void )
{
//Added By Sadullah Nader
//Initialization(s) inserted
m_viewLockedUntilFrame = 0u;
m_currentHeightAboveGround = 0.0f;
m_defaultAngle = 0.0f;
m_defaultPitchAngle = 0.0f;
Expand Down Expand Up @@ -110,6 +111,8 @@ void View::reset( void )
{
// Only fixing the reported bug. Who knows what side effects resetting the rest could have.
m_zoomLimited = TRUE;

m_viewLockedUntilFrame = 0u;
}

/**
Expand All @@ -126,6 +129,11 @@ void View::zoom( Real height )
setHeightAboveGround(getHeightAboveGround() + height);
}

void View::lockViewUntilFrame(UnsignedInt frame)
{
m_viewLockedUntilFrame = frame;
}

/**
* Center the view on the given coordinate.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
loc.init(pos.x, pos.y, pos.z, angle, pitch, zoom);
TheTacticalView->setLocation( &loc );

// TheSuperHackers @fix xezon 18/09/2025 Lock the new location to avoid user input from changing the camera in this frame.
TheTacticalView->lockViewUntilFrame( getFrame() + 1 );

if (!TheLookAtTranslator->hasMouseMovedRecently())
{
TheMouse->setCursor( (Mouse::MouseCursor)(msg->getArgument( 4 )->integer) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ void W3DView::setCameraTransform( void )
{
if (TheGlobalData->m_headless)
return;

if (m_viewLockedUntilFrame > TheGameClient->getFrame())
return;

m_cameraHasMovedSinceRequest = true;
Matrix3D cameraTransform( 1 );

Expand Down
Loading