From 21c1f6665989f2087e79148cc9cb198c58495c9a Mon Sep 17 00:00:00 2001 From: MrS-ibra Date: Sat, 31 Jan 2026 06:49:51 +0300 Subject: [PATCH] Prevent observing for non-host players when observers are disabled by host 2 --- .../GUI/GUICallbacks/Menus/QuitMenu.cpp | 8 ------ .../Source/GameLogic/System/GameLogic.cpp | 25 +++++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp index f60ccdded2..a6ee10bd72 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp @@ -53,7 +53,6 @@ #include "GameClient/GameWindowTransitions.h" #include "GameClient/DisconnectMenu.h" #include "GameLogic/ScriptEngine.h" -#include "GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h" @@ -193,13 +192,6 @@ static void surrenderQuitMenu() msg->appendBooleanArgument(TRUE); TheInGameUI->setClientQuiet( TRUE ); - - // If observers are disabled and we are not the host, exit game instead of observing - if (TheNGMPGame && !TheNGMPGame->getAllowObservers() && !TheNGMPGame->amIHost()) - { - TheGameLogic->exitGame(); - return; - } } static void restartMissionMenu() diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index bc1d8ff1c3..07df946a36 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -4011,6 +4011,31 @@ void GameLogic::update(void) TheLocomotorStore->UPDATE(); TheVictoryConditions->UPDATE(); + // When observers are disabled by host on GO, remove the non host player from game 10 seconds after they are defeated + static int observerKickCountdown = -1; + Player* localPlayer = ThePlayerList->getLocalPlayer(); + + if (TheNGMPGame && !TheNGMPGame->getAllowObservers() && !TheNGMPGame->amIHost() && + TheGameLogic->getGameMode() == GAME_INTERNET && TheGameLogic->getFrame() > 1 && + localPlayer && TheVictoryConditions->hasSinglePlayerBeenDefeated(localPlayer)) + { + if (observerKickCountdown < 0) + observerKickCountdown = LOGICFRAMES_PER_SECOND * 10; + + if (observerKickCountdown > 0) + { + observerKickCountdown--; + } + else { + TheGameLogic->exitGame(); // Time's up. kick the player + observerKickCountdown = -1; + return; + } + } + else { + observerKickCountdown = -1; + } + { //Handle disabled statii (and re-enable objects once frame matches) for (Object* obj = m_objList; obj; obj = obj->getNextObject())