Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gamenetwork): drop a silent player 30 s after going quiet

Olcay Seygancad993ba23aa
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4288fd544..228879f9f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -680,6 +680,7 @@ found and fixed — EA's own, not port damage.**
- Two players who each lost the other's last packet no longer freeze until the disconnect screen. Each asked the other to send it again, and each only resent what it had already played, which was nothing, so on a link with a tenth of a second of delay and one packet in twenty lost the match stopped for good one second in. Now the packet goes again and the match carries on.
- A match of three or more players no longer clogs up after a lost packet. When one player asked another, not the host, for a frame he had missed, the answer was acknowledged to the host instead of to the player who sent it, so that player never heard back and resent the same frame every two seconds for the rest of the match. A copy of someone else's frame could also carry the number of an order that player still had on the way, and the acknowledgement for the copy cancelled the order's own resend. Answers are acknowledged to whoever sent them now, under the number their author gave them, and a player who misses a frame asks for it on the host's measured timing instead of waiting two seconds first. Two-player games are unchanged.
- A three-player match starts sooner on a bad connection. When a frame did not arrive in time the game asked the players who had it one at a time, and the link between two non-host players timed its first guess off how long the other machine took to load the map, which is not a delay on the wire. Everyone missing is asked at once now, and loading no longer counts as a sample of the connection. At 125 ms of ping with 75 ms of jitter and 3% packet loss, the longest wait at the start of a match went from 2.7 seconds to 0.8, and from 4.1 to 1.1 with one slow-loading machine. Two-player games are unchanged.
+- A player whose game crashes or whose line dies no longer holds the rest of the room for over a minute. The disconnect screen came up after 12 seconds of silence and then started a fresh 60-second countdown, so everyone else sat for 72 seconds before the game let the player go. The countdown now runs from the last thing that player sent and lasts 30 seconds, so the match carries on about half a minute after they went quiet. A vote to drop them still works as before, and anyone still talking is never on the clock.
- A desynced match stops at once instead of playing on as two games.
- Two players on different factions can play a LAN or VPN match again. 3.0.0 and 3.0.1 put every USA against GLA, China against USA and China against GLA game out of sync in its first second, while two players of the same side played on: the mismatch check had started counting the map scripts' timers and flags, and some of those scripts follow each player's own faction, so the two machines never agreed on them. The check leaves them out again, as Zero Hour always did.
- A single lost packet no longer freezes the match for twenty seconds. The game now asks for the
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index 5f7159850..c3369b41f 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -799,6 +799,7 @@ public:
UnsignedInt m_networkPlayerSilenceTime; ///< The number of milliseconds we can go without hearing anything at all from a player before a stall is treated as a disconnect rather than a slow game.
UnsignedInt m_networkStallCeilingTime; ///< The number of milliseconds a stall can last with everyone still talking before we bring up the disconnect screen anyway.
UnsignedInt m_networkPlayerTimeoutTime; ///< The number of milliseconds between when a player's last keep alive command was recieved and when they are considered disconnected from the game.
+ UnsignedInt m_networkSilentPlayerDropTime; ///< The number of milliseconds a player can go without sending anything before the disconnect screen drops them; replaces m_networkPlayerTimeoutTime there.
UnsignedInt m_networkDisconnectScreenNotifyTime; ///< The number of milliseconds between when the disconnect screen comes up and when the other players are notified that we are on the disconnect screen.
Real m_keyboardCameraRotateSpeed; ///< How fast the camera rotates when rotated via keyboard controls.
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index 7875ef796..00348b446 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -809,6 +809,7 @@ Real RankLadder::aura( Int grade, RankAura aura ) const
{ "NetworkPlayerSilenceTime", INI::parseInt, NULL, offsetof(GlobalData, m_networkPlayerSilenceTime) },
{ "NetworkStallCeilingTime", INI::parseInt, NULL, offsetof(GlobalData, m_networkStallCeilingTime) },
{ "NetworkPlayerTimeoutTime", INI::parseInt, NULL, offsetof(GlobalData, m_networkPlayerTimeoutTime) },
+ { "NetworkSilentPlayerDropTime", INI::parseInt, NULL, offsetof(GlobalData, m_networkSilentPlayerDropTime) },
{ "NetworkDisconnectScreenNotifyTime", INI::parseInt, NULL, offsetof(GlobalData, m_networkDisconnectScreenNotifyTime) },
{ "KeyboardCameraRotateSpeed", INI::parseReal, NULL, offsetof( GlobalData, m_keyboardCameraRotateSpeed ) },
@@ -1390,6 +1391,10 @@ GlobalData::GlobalData()
m_networkPlayerSilenceTime = 12000;
m_networkStallCeilingTime = 20000;
m_networkPlayerTimeoutTime = 60000;
+ /* Retail GameData.ini sets the timeout above to 60s, and the disconnect screen counted it from
+ the moment the screen opened, so a crashed player held everyone else for 72s. The drop now
+ counts from the player's last packet and waits this long; retail sets no such key. */
+ m_networkSilentPlayerDropTime = 30000;
m_networkDisconnectScreenNotifyTime = 15000;
m_isBreakableMovie = FALSE;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp
index 7e6b262a7..524329515 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp
@@ -228,13 +228,13 @@ void DisconnectManager::updateDisconnectStatus(ConnectionManager *conMgr) {
Int slot = translatedSlotPosition(i, conMgr->getLocalPlayerID());
if (slot != -1) {
time_t curTime = Clock_Milliseconds();
- time_t newTime = TheGlobalData->m_networkPlayerTimeoutTime - (curTime - m_playerTimeouts[slot]);
+ time_t newTime = TheGlobalData->m_networkSilentPlayerDropTime - (curTime - m_playerTimeouts[slot]);
// if someone is more than 2/3 timed out, lets get our frame numbers sync'd up. Also if someone is voted out
// lets do the same thing.
if (m_haveNotifiedOtherPlayersOfCurrentFrame == FALSE) {
- if ((newTime < TheGlobalData->m_networkPlayerTimeoutTime / 3) || (isPlayerVotedOut(slot, conMgr) == TRUE)) {
+ if ((newTime < TheGlobalData->m_networkSilentPlayerDropTime / 3) || (isPlayerVotedOut(slot, conMgr) == TRUE)) {
TheNetwork->notifyOthersOfCurrentFrame();
m_haveNotifiedOtherPlayersOfCurrentFrame = TRUE;
}
@@ -566,7 +566,17 @@ void DisconnectManager::turnOnScreen(ConnectionManager *conMgr) {
m_disconnectState = DISCONNECTSTATETYPE_SCREENON;
m_lastKeepAliveSendTime = -1;
populateDisconnectScreen(conMgr);
- resetPlayerTimeouts(conMgr);
+
+ /* EA restarted every countdown here, so a player who had already been silent for the 12s it
+ takes to open this screen got the whole timeout on top. Count from their last packet
+ instead; anyone still talking reads as zero silence and starts from now as before. */
+ time_t now = Clock_Milliseconds();
+ for (Int i = 0; i < MAX_SLOTS; ++i) {
+ Int slot = translatedSlotPosition(i, conMgr->getLocalPlayerID());
+ if (slot != -1) {
+ m_playerTimeouts[slot] = now - conMgr->getTimeSinceLastPacketFrom(i);
+ }
+ }
TheDisconnectMenu->hidePacketRouterTimeout();
m_haveNotifiedOtherPlayersOfCurrentFrame = FALSE;
@@ -725,7 +735,7 @@ Bool DisconnectManager::hasPlayerTimedOut(Int slot) {
return FALSE;
}
- time_t newTime = TheGlobalData->m_networkPlayerTimeoutTime - (Clock_Milliseconds() - m_playerTimeouts[slot]);
+ time_t newTime = TheGlobalData->m_networkSilentPlayerDropTime - (Clock_Milliseconds() - m_playerTimeouts[slot]);
if (newTime <= 0) {
return TRUE;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp
index 144cf80ae..4e3c0cf32 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp
@@ -370,6 +370,7 @@ void Network::init()
DEBUG_LOG(("NetworkPlayerSilenceTime: %d\n", TheGlobalData->m_networkPlayerSilenceTime));
DEBUG_LOG(("NetworkStallCeilingTime: %d\n", TheGlobalData->m_networkStallCeilingTime));
DEBUG_LOG(("NetworkPlayerTimeoutTime: %d\n", TheGlobalData->m_networkPlayerTimeoutTime));
+ DEBUG_LOG(("NetworkSilentPlayerDropTime: %d\n", TheGlobalData->m_networkSilentPlayerDropTime));
DEBUG_LOG(("NetworkDisconnectScreenNotifyTime: %d\n", TheGlobalData->m_networkDisconnectScreenNotifyTime));
DEBUG_LOG(("Other network stuff:\n"));
DEBUG_LOG(("FRAME_DATA_LENGTH = %d\n", FRAME_DATA_LENGTH));