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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gamenetwork): judge a stall before showing the disconnect screen
Olcay Seygan8d93609d1ec8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d62790c2e..766668a18 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -211,6 +211,13 @@ map. Ctrl+A is still everything at once.back. The game already reset it every frame, but the reset read the wrong register to decide whatto write. It now reads the right one, and there are tests that break the machine's maths onpurpose and prove the reset puts it back.+- **The disconnect screen stops interrupting games that are merely slow.** In a big eight-player+ match the game routinely waits a few seconds for everyone's orders, and five seconds of that used+ to be enough to throw the disconnect screen over the top of the battle — with a vote attached that+ could end with somebody kicked out of a game nobody had left. The game now checks whether anyone+ has actually stopped talking before it does that. If everybody is still sending, it waits and+ catches up. If a player really has gone quiet, the screen comes up as before, and there is a+ hard limit so a genuinely wedged game still gives you the screen rather than hanging forever.## Sharper textures, for freediff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex 7e4033003..eddfaa70d 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -463,6 +463,8 @@ public:UnsignedInt m_networkKeepAliveDelay; ///< The number of seconds between when the connections to each player send a keep-alive packet.UnsignedInt m_networkRunAheadSlack; ///< The amount of slack in the run ahead value. This is the percentage of the calculated run ahead that is added.UnsignedInt m_networkDisconnectTime; ///< The number of milliseconds between when the game gets stuck on a frame for a network stall and when the disconnect dialog comes up.+ 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_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.diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/ConnectionManager.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/ConnectionManager.hindex 83f0aa425..32a63b9a7 100644--- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/ConnectionManager.h+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/ConnectionManager.h@@ -144,6 +144,12 @@ public:void debugPrintConnectionCommands();#endif+ /* How long since anything at all arrived that originated with this player - a command, an ack,+ a keep-alive. A stalled game where this is small for everyone is slow; one where it is large+ for somebody is a disconnect. See StallJudgement.h. */+ UnsignedInt getTimeSinceLastPacketFrom( Int slot ) const;+ UnsignedInt getWorstSilenceMS( void ) const;+// For disconnect blame assignmentUnsignedInt getPingFrame();Int getPingsSent();@@ -206,6 +212,9 @@ private:// yup.Real m_latencyAverages[MAX_SLOTS];Int m_fpsAverages[MAX_SLOTS];++ /* Wall clock of the last thing we heard from each player, zero for "nothing yet". */+ time_t m_lastHeardFrom[MAX_SLOTS];Int m_minFpsPlayer;Int m_minFps;UnsignedInt m_smallestPacketArrivalCushion;diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/StallJudgement.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/StallJudgement.hnew file mode 100644index 000000000..fc8f27d54--- /dev/null+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/StallJudgement.h@@ -0,0 +1,73 @@+/*+** Command & Conquer Generals Zero Hour(tm)+** Copyright 2025 Electronic Arts Inc.+**+** This program is free software: you can redistribute it and/or modify+** it under the terms of the GNU General Public License as published by+** the Free Software Foundation, either version 3 of the License, or+** (at your option) any later version.+**+** This program is distributed in the hope that it will be useful,+** but WITHOUT ANY WARRANTY; without even the implied warranty of+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+** GNU General Public License for more details.+**+** You should have received a copy of the GNU General Public License+** along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++// FILE: StallJudgement.h /////////////////////////////////////////////////////////////////////////+// Desc: Telling a slow game apart from a broken one.+///////////////////////////////////////////////////////////////////////////////////////////////////++#pragma once++#ifndef _STALL_JUDGEMENT_H_+#define _STALL_JUDGEMENT_H_++#include "Lib/BaseType.h"++/* The game stops on a frame it has not got everyone's commands for. That is normal - it happens+ for a moment on any link with jitter - and the disconnect screen is the opposite of harmless:+ it takes over the display, starts a vote and can end with somebody dropped. So it must not be+ the answer to "we waited a while".++ Two different things look identical from inside the logic loop:++ - a player has gone away. Nothing arrives from them: no commands, no acks, no keep-alives.+ - the game is merely slow. Packets from everyone keep arriving; the frame we need has not+ been assembled yet because somebody's machine, or the link, is behind.++ The first needs the disconnect screen. The second needs to be left alone; showing the screen+ there converts a two-second hitch into an interruption and a wrongful vote. Telling them apart+ needs one more number than EA used: how long it has been since anything at all arrived from the+ quietest player. */++enum StallVerdict+{+ STALL_RUNNING = 0, ///< not stalled long enough to care+ STALL_WAITING, ///< stalled, but everyone is still talking to us: slow, not broken+ STALL_SILENT, ///< stalled, and somebody has stopped talking: this is a disconnect+ STALL_WEDGED, ///< stalled far past any plausible hitch, whoever is still talking+};++/**+ * Decide what a stall means.+ *+ * @param stallMS how long the logic frame has failed to advance+ * @param worstSilenceMS the longest any connected player has gone without sending us anything+ * @param disconnectMS how long a stall may last before it is worth explaining (the+ * NetworkDisconnectTime knob)+ * @param silenceMS how long a player may say nothing before we call them gone+ * @param wedgedMS the ceiling: past this the screen comes up regardless, because a+ * game this far behind will not catch up on its own+ */+StallVerdict judgeStall( UnsignedInt stallMS, UnsignedInt worstSilenceMS,+ UnsignedInt disconnectMS, UnsignedInt silenceMS, UnsignedInt wedgedMS );++/** TRUE for the two verdicts that warrant taking over the screen. */+Bool stallNeedsDisconnectScreen( StallVerdict verdict );++const char *stallVerdictName( StallVerdict verdict );++#endif // _STALL_JUDGEMENT_H_diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex 82d0f7c91..0bb22d67f 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -501,6 +501,8 @@ GlobalData* GlobalData::m_theOriginal = NULL;{ "NetworkRunAheadSlack", INI::parseInt, NULL, offsetof(GlobalData, m_networkRunAheadSlack) },{ "NetworkKeepAliveDelay", INI::parseInt, NULL, offsetof(GlobalData, m_networkKeepAliveDelay) },{ "NetworkDisconnectTime", INI::parseInt, NULL, offsetof(GlobalData, m_networkDisconnectTime) },+ { "NetworkPlayerSilenceTime", INI::parseInt, NULL, offsetof(GlobalData, m_networkPlayerSilenceTime) },+ { "NetworkStallCeilingTime", INI::parseInt, NULL, offsetof(GlobalData, m_networkStallCeilingTime) },{ "NetworkPlayerTimeoutTime", INI::parseInt, NULL, offsetof(GlobalData, m_networkPlayerTimeoutTime) },{ "NetworkDisconnectScreenNotifyTime", INI::parseInt, NULL, offsetof(GlobalData, m_networkDisconnectScreenNotifyTime) },@@ -962,7 +964,15 @@ GlobalData::GlobalData()m_networkCushionHistoryLength = 10;m_networkRunAheadSlack = 10;m_networkKeepAliveDelay = 20;- m_networkDisconnectTime = 5000;+ /* 5000 was EA's. With the stall judgement in DisconnectManager::update the screen no longer+ comes up on duration alone, so this is now only the point at which we start asking whether+ anybody has gone quiet - and 5s of stall is common on a loaded machine in an eight player+ game. 8s costs nothing when the link really is dead, because the silence test decides. */+ m_networkDisconnectTime = 8000;+ /* Longer than the 8s keep-alive round: a player who is merely stalled still answers on that+ schedule, so anything under it would call a slow player a disconnected one. */+ m_networkPlayerSilenceTime = 12000;+ m_networkStallCeilingTime = 20000;m_networkPlayerTimeoutTime = 60000;m_networkDisconnectScreenNotifyTime = 15000;diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cppindex 6c91e8483..d53a99db2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp@@ -42,6 +42,7 @@#include "GameClient/GameText.h"#include "GameClient/MessageBox.h"#include "GameNetwork/ConnectionManager.h"+#include "GameNetwork/StallJudgement.h"#include "GameNetwork/LANAPICallbacks.h"#include "GameNetwork/NAT.h"#include "GameNetwork/NetCommandWrapperList.h"@@ -131,6 +132,7 @@ ConnectionManager::ConnectionManager(void){for (Int i = 0; i < MAX_SLOTS; ++i) {m_frameData[i] = NULL;+ m_lastHeardFrom[i] = 0;}m_transport = NULL;m_disconnectManager = NULL;@@ -171,6 +173,12 @@ void ConnectionManager::init()}m_relayedCommands->reset();+ /* A new game starts with nobody having been heard from yet, or the silence carried over from+ the last one would be counted against them. */+ for (i = 0; i < MAX_SLOTS; ++i) {+ m_lastHeardFrom[i] = 0;+ }+m_localSlot = -1;#ifdef MEMORYPOOL_DEBUGTheMemoryPoolFactory->debugSetInitFillerIndex(m_localSlot);@@ -373,6 +381,14 @@ void ConnectionManager::doRelay() {while (cmd != NULL) {//DEBUG_LOG(("ConnectionManager::doRelay() - Looking at a command of type %s\n",//GetAsciiNetCommandType(cmd->getCommand()->getNetCommandType()).str()));++ /* Note that we have heard from whoever originated this, relayed or not. Any command+ will do - the point is only that the player still exists. See StallJudgement.h. */+ UnsignedInt fromSlot = cmd->getCommand()->getPlayerID();+ if (fromSlot < MAX_SLOTS) {+ m_lastHeardFrom[fromSlot] = timeGetTime();+ }+if (CommandRequiresAck(cmd->getCommand())) {ackCommand(cmd, m_localSlot);}@@ -2322,6 +2338,46 @@ Int ConnectionManager::getSlotAverageFPS(Int slot) {return m_fpsAverages[slot];}+/**+ * How long since anything at all arrived that originated with this player. Zero for a slot we+ * have no connection to, and for one we have never heard from - in both cases there is nothing+ * to hold against them.+ */+UnsignedInt ConnectionManager::getTimeSinceLastPacketFrom( Int slot ) const+{+ if ((slot < 0) || (slot >= MAX_SLOTS))+ return 0;+ if (m_connections[slot] == NULL)+ return 0;+ if (m_lastHeardFrom[slot] == 0)+ return 0;++ time_t now = timeGetTime();+ if (now <= m_lastHeardFrom[slot])+ return 0;++ return (UnsignedInt)(now - m_lastHeardFrom[slot]);+}++/**+ * The longest any connected player has gone without sending us anything. This is the number that+ * separates "the game is slow" from "somebody has gone away" - see StallJudgement.h.+ */+UnsignedInt ConnectionManager::getWorstSilenceMS( void ) const+{+ UnsignedInt worst = 0;+ for (Int i = 0; i < MAX_SLOTS; ++i)+ {+ if (i == (Int)m_localSlot)+ continue; // we always hear ourselves++ UnsignedInt silence = getTimeSinceLastPacketFrom( i );+ if (silence > worst)+ worst = silence;+ }+ return worst;+}+#if defined(_DEBUG) || defined(_INTERNAL)void ConnectionManager::debugPrintConnectionCommands() {DEBUG_LOG(("ConnectionManager::debugPrintConnectionCommands - begin commands\n"));diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cppindex a9bc389df..26ef54d66 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp@@ -30,6 +30,7 @@#include "GameClient/InGameUI.h"#include "GameLogic/GameLogic.h"#include "GameNetwork/DisconnectManager.h"+#include "GameNetwork/StallJudgement.h"#include "GameNetwork/NetworkInterface.h"#include "GameNetwork/NetworkUtil.h"#include "GameNetwork/GameSpy/PingThread.h"@@ -111,8 +112,24 @@ void DisconnectManager::update(ConnectionManager *conMgr) {// the last one we had the commands ready for.if (TheGameLogic->getFrame() == m_lastFrame) {time_t curTime = timeGetTime();- if ((curTime - m_lastFrameTime) > TheGlobalData->m_networkDisconnectTime) {- if (m_disconnectState == DISCONNECTSTATETYPE_SCREENOFF) {+ UnsignedInt stallMS = (UnsignedInt)(curTime - m_lastFrameTime);++ /* EA popped the disconnect screen on stall duration alone, so a slow machine or a jittery+ link produced the same interruption as a player pulling their cable out. Ask whether+ anyone has actually gone quiet before taking over the screen; when everybody is still+ sending, the game is behind, not broken, and it will catch up. See StallJudgement.h. */+ StallVerdict verdict = judgeStall( stallMS, conMgr->getWorstSilenceMS(),+ TheGlobalData->m_networkDisconnectTime,+ TheGlobalData->m_networkPlayerSilenceTime,+ TheGlobalData->m_networkStallCeilingTime );++ if (verdict != STALL_RUNNING) {+ /* Keep-alives go out for every kind of stall: they are how the other machines learn that+ we are still here, and holding them back while we wait would make our own silence the+ thing that triggers their disconnect screen. */+ if (stallNeedsDisconnectScreen( verdict ) && m_disconnectState == DISCONNECTSTATETYPE_SCREENOFF) {+ DEBUG_LOG(("DisconnectManager::update - disconnect screen on after %d ms stalled, %d ms of silence: %s\n",+ stallMS, conMgr->getWorstSilenceMS(), stallVerdictName( verdict ) ));turnOnScreen(conMgr);}sendKeepAlive(conMgr);diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cppindex 9711bae2d..955dc3854 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp@@ -356,6 +356,8 @@ void Network::init()DEBUG_LOG(("NetworkRunAheadSlack: %d\n", TheGlobalData->m_networkRunAheadSlack));DEBUG_LOG(("NetworkKeepAliveDelay: %d\n", TheGlobalData->m_networkKeepAliveDelay));DEBUG_LOG(("NetworkDisconnectTime: %d\n", TheGlobalData->m_networkDisconnectTime));+ 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(("NetworkDisconnectScreenNotifyTime: %d\n", TheGlobalData->m_networkDisconnectScreenNotifyTime));DEBUG_LOG(("Other network stuff:\n"));diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/StallJudgement.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/StallJudgement.cppnew file mode 100644index 000000000..98cc9395f--- /dev/null+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/StallJudgement.cpp@@ -0,0 +1,66 @@+/*+** Command & Conquer Generals Zero Hour(tm)+** Copyright 2025 Electronic Arts Inc.+**+** This program is free software: you can redistribute it and/or modify+** it under the terms of the GNU General Public License as published by+** the Free Software Foundation, either version 3 of the License, or+** (at your option) any later version.+**+** This program is distributed in the hope that it will be useful,+** but WITHOUT ANY WARRANTY; without even the implied warranty of+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+** GNU General Public License for more details.+**+** You should have received a copy of the GNU General Public License+** along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++// FILE: StallJudgement.cpp ///////////////////////////////////////////////////////////////////////+// Desc: Telling a slow game apart from a broken one.+///////////////////////////////////////////////////////////////////////////////////////////////////++#include "PreRTS.h"+#include "GameNetwork/StallJudgement.h"++/* No engine dependencies on purpose: this is the whole decision, and a test can drive it through+ every case in a millisecond instead of waiting out real stalls on a real network. */++StallVerdict judgeStall( UnsignedInt stallMS, UnsignedInt worstSilenceMS,+ UnsignedInt disconnectMS, UnsignedInt silenceMS, UnsignedInt wedgedMS )+{+ /* Short stalls are the normal state of a lockstep game and get no opinion at all. */+ if( stallMS <= disconnectMS )+ return STALL_RUNNING;++ /* Somebody has stopped sending. This is the case the disconnect screen was written for, and+ the sooner it comes up the sooner the remaining players can vote and carry on. */+ if( worstSilenceMS >= silenceMS )+ return STALL_SILENT;++ /* Everyone is still talking to us, so nobody has dropped - but a stall this long is not going+ to resolve itself either, and the player deserves to be told rather than left staring at a+ frozen battlefield. */+ if( stallMS >= wedgedMS )+ return STALL_WEDGED;++ /* Stalled, and every player is still sending. Slow, not broken: wait. */+ return STALL_WAITING;+}++Bool stallNeedsDisconnectScreen( StallVerdict verdict )+{+ return verdict == STALL_SILENT || verdict == STALL_WEDGED;+}++const char *stallVerdictName( StallVerdict verdict )+{+ switch( verdict )+ {+ case STALL_RUNNING: return "running";+ case STALL_WAITING: return "slow, everyone still sending";+ case STALL_SILENT: return "a player has gone quiet";+ case STALL_WEDGED: return "stalled past any plausible hitch";+ }+ return "unknown";+}diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 94cddd070..882773409 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -31,6 +31,7 @@#include "GameLogic/CRCSnapshotRing.h"#include "GameNetwork/GameDataMatch.h"#include "GameLogic/FPUControl.h"+#include "GameNetwork/StallJudgement.h"#include <float.h>#include "GameClient/Water.h"#include "GameLogic/Module/PhysicsUpdate.h"@@ -2138,3 +2139,96 @@ TEST(setfpmode_leaves_the_exception_mask_in_a_known_state)_controlfp( entry, _MCW_PC | _MCW_RC | _MCW_EM );}++// ---------------------------------------------------------------------------------------------+// The disconnect screen's decision (MULTIPLAYER 2.3). DisconnectManager::update used to bring+// the screen up on stall duration alone, which cannot tell a slow game from a broken one.+// ---------------------------------------------------------------------------------------------++// the thresholds the shipped GlobalData defaults use, so the witnesses below describe the game+static const UnsignedInt DISCONNECT_MS = 8000;+static const UnsignedInt SILENCE_MS = 12000;+static const UnsignedInt WEDGED_MS = 20000;++static StallVerdict judge( UnsignedInt stallMS, UnsignedInt silenceMS )+{+ return judgeStall( stallMS, silenceMS, DISCONNECT_MS, SILENCE_MS, WEDGED_MS );+}++TEST(judgestall_a_short_stall_is_not_a_disconnect)+{+ // the common case: the game is waiting on a frame and everybody is still sending+ CHECK_EQ( (int)judge( 0, 0 ), (int)STALL_RUNNING );+ CHECK_EQ( (int)judge( 4000, 500 ), (int)STALL_RUNNING );+ CHECK_EQ( (int)judge( DISCONNECT_MS, 500 ), (int)STALL_RUNNING ); // boundary is exclusive++ // and a short stall stays running even if somebody has been quiet a while: below the+ // disconnect time we do not look at silence at all, because we are not stalled yet+ CHECK_EQ( (int)judge( 1000, 30000 ), (int)STALL_RUNNING );++ CHECK( !stallNeedsDisconnectScreen( STALL_RUNNING ) );+}++TEST(judgestall_a_long_stall_with_everyone_talking_is_only_slow)+{+ // this is the case EA got wrong: 5s of no frame progress, but packets are still arriving from+ // every player, so the game is behind and will catch up. No screen, no vote, no drop.+ CHECK_EQ( (int)judge( DISCONNECT_MS + 1, 0 ), (int)STALL_WAITING );+ CHECK_EQ( (int)judge( 15000, 3000 ), (int)STALL_WAITING );+ CHECK_EQ( (int)judge( WEDGED_MS - 1, SILENCE_MS - 1 ), (int)STALL_WAITING );++ CHECK( !stallNeedsDisconnectScreen( STALL_WAITING ) );+}++TEST(judgestall_silence_from_a_player_is_a_disconnect)+{+ // stalled, and somebody has stopped sending entirely - that is what the screen is for+ CHECK_EQ( (int)judge( DISCONNECT_MS + 1, SILENCE_MS ), (int)STALL_SILENT );+ CHECK_EQ( (int)judge( 9000, 60000 ), (int)STALL_SILENT );++ CHECK( stallNeedsDisconnectScreen( STALL_SILENT ) );+}++TEST(judgestall_silence_shorter_than_the_keepalive_round_is_not_silence)+{+ // ConnectionManager::doKeepAlive walks one slot per second and resets at MAX_SLOTS, so a+ // player who is merely stalled themselves still only reaches us every 8s. The silence+ // threshold has to sit above that or the fix would call a slow player a disconnected one.+ CHECK( SILENCE_MS > 8000 );+ CHECK_EQ( (int)judge( 19000, 8000 ), (int)STALL_WAITING );+ CHECK_EQ( (int)judge( 19000, 11999 ), (int)STALL_WAITING );+}++TEST(judgestall_a_stall_past_the_ceiling_gives_up_anyway)+{+ // packets are arriving but the frame has not moved in 20 seconds: whatever is wrong, it is+ // not going to fix itself, and refusing to ever show the screen would hang the game forever+ CHECK_EQ( (int)judge( WEDGED_MS, 0 ), (int)STALL_WEDGED );+ CHECK_EQ( (int)judge( 120000, 0 ), (int)STALL_WEDGED );++ CHECK( stallNeedsDisconnectScreen( STALL_WEDGED ) );++ // silence still wins over the ceiling: the report should name the real cause+ CHECK_EQ( (int)judge( 120000, SILENCE_MS ), (int)STALL_SILENT );+}++TEST(judgestall_the_verdict_is_monotonic_in_the_stall_time)+{+ // once the screen is warranted, waiting longer must never take it back away again+ Bool seenScreen = FALSE;+ for( UnsignedInt ms = 0; ms <= 40000; ms += 250 )+ {+ Bool needs = stallNeedsDisconnectScreen( judge( ms, 30000 ) );+ if( needs )+ seenScreen = TRUE;+ else+ CHECK( !seenScreen );+ }+ CHECK( seenScreen );++ // every verdict has a name for the log+ CHECK( strlen( stallVerdictName( STALL_RUNNING ) ) > 0 );+ CHECK( strlen( stallVerdictName( STALL_WAITING ) ) > 0 );+ CHECK( strlen( stallVerdictName( STALL_SILENT ) ) > 0 );+ CHECK( strlen( stallVerdictName( STALL_WEDGED ) ) > 0 );+}