From 97806acc1dbe3c79a9c1485cbdcb859b99f31497 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Tue, 31 Mar 2026 01:28:06 +0200 Subject: [PATCH 1/2] refactor(object): Replace explicit local player checks with Object::isLocallyControlled --- Core/GameEngine/Source/GameClient/SelectionInfo.cpp | 2 +- .../GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp | 4 ++-- .../Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp | 2 +- .../Source/GameLogic/Object/Contain/RiderChangeContain.cpp | 2 +- GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp | 2 +- .../Code/GameEngine/Source/GameLogic/System/GameLogic.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Core/GameEngine/Source/GameClient/SelectionInfo.cpp b/Core/GameEngine/Source/GameClient/SelectionInfo.cpp index 7558cf9380c..177139a69ee 100644 --- a/Core/GameEngine/Source/GameClient/SelectionInfo.cpp +++ b/Core/GameEngine/Source/GameClient/SelectionInfo.cpp @@ -386,7 +386,7 @@ Bool addDrawableToList( Drawable *draw, void *userData ) { const Object *obj = draw->getObject(); if (obj) - if (obj->getControllingPlayer() != ThePlayerList->getLocalPlayer()) + if (!obj->isLocallyControlled()) if (obj->getContain() && draw->getObject()->getContain()->getContainCount() > 0) return FALSE; } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp index 487c922a938..29058e1b099 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp @@ -375,7 +375,7 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control, break; // sanity check, the building must be under our control to cancel construction - if( building->getControllingPlayer() != ThePlayerList->getLocalPlayer() ) + if( !building->isLocallyControlled() ) break; // do the message @@ -490,7 +490,7 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control, break; // sanity, we must control the producer ... if this isn't true they might be hacking the game - if( producer->getControllingPlayer() != ThePlayerList->getLocalPlayer() ) + if( !producer->isLocallyControlled() ) break; // send a message to cancel that particular production entry diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp index 149a6c33549..53e8b0fca24 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp @@ -126,7 +126,7 @@ UpdateSleepTime OverchargeBehavior::update() enable( FALSE ); // do some UI info for the local user if this is theirs - if( ThePlayerList->getLocalPlayer() == us->getControllingPlayer() ) + if( us->isLocallyControlled() ) { // print msg diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp index ade81b54688..236242951e5 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp @@ -324,7 +324,7 @@ void RiderChangeContain::onRemoving( Object *rider ) if( containDraw && riderDraw ) { //Create the selection message for the rider if it's ours and SELECTED! - if( bike->getControllingPlayer() == ThePlayerList->getLocalPlayer() && containDraw->isSelected() ) + if( bike->isLocallyControlled() && containDraw->isSelected() ) { GameMessage *teamMsg = TheMessageStream->appendMessage( GameMessage::MSG_CREATE_SELECTED_GROUP ); teamMsg->appendBooleanArgument( FALSE );// not creating new team so pass false diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp index d3db0e53e6b..98daf9c2187 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -1916,7 +1916,7 @@ void Object::attemptDamage( DamageInfo *damageInfo ) getControllingPlayer() && !BitIsSet(damageInfo->in.m_sourcePlayerMask, getControllingPlayer()->getPlayerMask()) && m_radarData != nullptr && - getControllingPlayer() == ThePlayerList->getLocalPlayer() ) + isLocallyControlled() ) TheRadar->tryUnderAttackEvent( this ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index 87df153cd3f..f33cd863ecd 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -4030,7 +4030,7 @@ void GameLogic::destroyObject( Object *obj ) //Clean up special power shortcut bars if( obj->hasAnySpecialPower() ) { - if( ThePlayerList->getLocalPlayer() == obj->getControllingPlayer() ) + if( obj->isLocallyControlled() ) { TheControlBar->markUIDirty(); } From 2d0da95886584c61500e2bb626417379f936fdfa Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Tue, 31 Mar 2026 21:21:01 +0200 Subject: [PATCH 2/2] Replicated in Generals (manually). --- .../GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp | 4 ++-- .../Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp | 2 +- Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp index d42df100b2d..7081e2ad9b7 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp @@ -243,7 +243,7 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control, break; // sanity check, the building must be under our control to cancel construction - if( building->getControllingPlayer() != ThePlayerList->getLocalPlayer() ) + if( !building->isLocallyControlled() ) break; // do the message @@ -357,7 +357,7 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control, break; // sanity, we must control the producer ... if this isn't true they might be hacking the game - if( producer->getControllingPlayer() != ThePlayerList->getLocalPlayer() ) + if( !producer->isLocallyControlled() ) break; // send a message to cancel that particular production entry diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp index 6f8be9f2c4e..a27cf849529 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/OverchargeBehavior.cpp @@ -126,7 +126,7 @@ UpdateSleepTime OverchargeBehavior::update() enable( FALSE ); // do some UI info for the local user if this is theirs - if( ThePlayerList->getLocalPlayer() == us->getControllingPlayer() ) + if( us->isLocallyControlled() ) { // print msg diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp index aa1f73afdb0..1dc97a77273 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp @@ -1710,7 +1710,7 @@ void Object::attemptDamage( DamageInfo *damageInfo ) damageInfo->in.m_damageType != DAMAGE_HEALING && !BitIsSet(damageInfo->in.m_sourcePlayerMask, getControllingPlayer()->getPlayerMask()) && m_radarData != nullptr && - getControllingPlayer() == ThePlayerList->getLocalPlayer() ) + isLocallyControlled() ) TheRadar->tryUnderAttackEvent( this ); }