Skip to content

Commit 762d34c

Browse files
authored
Merge pull request #308 from MrS-ibra/disable-nonhost-observer2
Prevent observing for non-host players when observers are disabled by host 2
2 parents 67b5c8e + 21c1f66 commit 762d34c

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#include "GameClient/GameWindowTransitions.h"
5454
#include "GameClient/DisconnectMenu.h"
5555
#include "GameLogic/ScriptEngine.h"
56-
#include "GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h"
5756

5857

5958

@@ -193,13 +192,6 @@ static void surrenderQuitMenu()
193192
msg->appendBooleanArgument(TRUE);
194193

195194
TheInGameUI->setClientQuiet( TRUE );
196-
197-
// If observers are disabled and we are not the host, exit game instead of observing
198-
if (TheNGMPGame && !TheNGMPGame->getAllowObservers() && !TheNGMPGame->amIHost())
199-
{
200-
TheGameLogic->exitGame();
201-
return;
202-
}
203195
}
204196

205197
static void restartMissionMenu()

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4011,6 +4011,31 @@ void GameLogic::update(void)
40114011
TheLocomotorStore->UPDATE();
40124012
TheVictoryConditions->UPDATE();
40134013

4014+
// When observers are disabled by host on GO, remove the non host player from game 10 seconds after they are defeated
4015+
static int observerKickCountdown = -1;
4016+
Player* localPlayer = ThePlayerList->getLocalPlayer();
4017+
4018+
if (TheNGMPGame && !TheNGMPGame->getAllowObservers() && !TheNGMPGame->amIHost() &&
4019+
TheGameLogic->getGameMode() == GAME_INTERNET && TheGameLogic->getFrame() > 1 &&
4020+
localPlayer && TheVictoryConditions->hasSinglePlayerBeenDefeated(localPlayer))
4021+
{
4022+
if (observerKickCountdown < 0)
4023+
observerKickCountdown = LOGICFRAMES_PER_SECOND * 10;
4024+
4025+
if (observerKickCountdown > 0)
4026+
{
4027+
observerKickCountdown--;
4028+
}
4029+
else {
4030+
TheGameLogic->exitGame(); // Time's up. kick the player
4031+
observerKickCountdown = -1;
4032+
return;
4033+
}
4034+
}
4035+
else {
4036+
observerKickCountdown = -1;
4037+
}
4038+
40144039
{
40154040
//Handle disabled statii (and re-enable objects once frame matches)
40164041
for (Object* obj = m_objList; obj; obj = obj->getNextObject())

0 commit comments

Comments
 (0)