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): stop the retry backoff setting the length of the freeze
Olcay Seyganed69274305e8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4a3d56465..40ad5b036 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -278,6 +278,15 @@ map. Ctrl+A is still everything at once.worst moment in a match — right after someone has already dropped. The list is now read properly,and when it genuinely runs out the game says so instead of inventing somebody.+- **A dropped order used to make the game wait longer each time it went missing — up to two full+ seconds.** When a packet goes astray it is sent again, and the wait before each attempt was+ doubling: the third and fourth time the same order went missing, everybody sat there for a second+ and then two. Doubling like that is what you do to a connection that has gone away, but the+ connection has not gone away — it dropped one packet, and the whole game is standing still waiting+ for that one packet, with nothing else to send. The wait now stops growing after two steps, so the+ longest anyone stands still is well under a second, and the game still backs off enough to be+ polite to a connection that really has died — which it has its own, separate way of noticing.+## Sharper textures, for freeZero Hour shipped downscaled copies of a lot of the base game's textures, and because of the orderdiff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/Connection.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/Connection.hindex 3d0009d97..7ca907ee4 100644--- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/Connection.h+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/Connection.h@@ -62,6 +62,10 @@#define CONNECTION_MIN_RETRY_TIME 150#define CONNECTION_MAX_RETRY_TIME 2000+// How many times the per-command retry wait may double while a command goes unacked. See+// Connection_retryDelayFor - in a lockstep game this delay is the length of the freeze.+#define CONNECTION_MAX_RETRY_BACKOFF_SHIFTS 2+/*** Fold one round-trip sample into the smoothed estimate and rewrite the timeout. Jacobson/Karels:* srtt tracks the mean, rttvar the mean deviation, and the timeout sits four deviations out sodiff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cppindex e7c744f29..ab8e61956 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp@@ -69,6 +69,17 @@ void Connection_updateRetryTimeout( Real sampleMS, Real &srtt, Real &rttvar, tim* Exponential backoff on top of the connection's timeout, capped at the ceiling. numTimesSent is* how many times the command has already gone out, so 1 (a single transmission awaiting its first* retry) is the un-backed-off case.+ *+ * The number of doublings is deliberately small. Backoff exists so that a link which is genuinely+ * down is not hammered at the floor rate for as long as the disconnect timer runs, and two+ * doublings already cut that rate to a quarter. Paying for more than that is not free: this is a+ * lockstep game, so the command being retried is one the whole room is stopped on, and the delay+ * before the next attempt *is* the length of the freeze everybody sees. Four doublings put that at+ * 1.2 and then 2 seconds after only three and four losses of the same command - which a couple of+ * percent of packet loss produces routinely over a long game with eight players - and there is+ * nothing else in flight to congest with anyway, because a blocked machine has stopped generating+ * frames. Deciding that a link is actually dead is the disconnect manager's job, on its own ping+ * and its own timers, not the retry timer's.*/time_t Connection_retryDelayFor( time_t baseRetryMS, Int numTimesSent ){@@ -76,8 +87,8 @@ time_t Connection_retryDelayFor( time_t baseRetryMS, Int numTimesSent )if (backoff < 0) {backoff = 0;}- if (backoff > 4) {- backoff = 4;+ if (backoff > CONNECTION_MAX_RETRY_BACKOFF_SHIFTS) {+ backoff = CONNECTION_MAX_RETRY_BACKOFF_SHIFTS;}time_t delay = baseRetryMS << backoff;diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 2af8c8e16..923f38eb5 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -1972,13 +1972,37 @@ TEST(connection_retry_backs_off_when_a_command_keeps_going_unacked)floor rate for as long as the disconnect timer runs. */CHECK_EQ( (Int)Connection_retryDelayFor( 200, 2 ), 400 );CHECK_EQ( (Int)Connection_retryDelayFor( 200, 3 ), 800 );- CHECK_EQ( (Int)Connection_retryDelayFor( 200, 4 ), 1600 );- /* ...but never past the ceiling, however long it stays down. */- CHECK_EQ( (Int)Connection_retryDelayFor( 200, 5 ), CONNECTION_MAX_RETRY_TIME );- CHECK_EQ( (Int)Connection_retryDelayFor( 200, 50 ), CONNECTION_MAX_RETRY_TIME );+ /* ...but the doubling stops there. This is a lockstep game: the command being retried is one+ the whole room is stopped on, so this delay is the length of the freeze, and it used to reach+ 1.2 and then 2 seconds after three and four losses of the same command. Quartering the retry+ rate is all the protection a dead link needs from here; deciding a link is dead belongs to the+ disconnect manager. */+ CHECK_EQ( (Int)Connection_retryDelayFor( 200, 4 ), 800 );+ CHECK_EQ( (Int)Connection_retryDelayFor( 200, 5 ), 800 );+ CHECK_EQ( (Int)Connection_retryDelayFor( 200, 50 ), 800 );++ /* The freeze a command can cost on a link fast enough to sit on the retry floor, however many+ times in a row it is lost. */+ CHECK_EQ( (Int)Connection_retryDelayFor( CONNECTION_MIN_RETRY_TIME, 50 ),+ CONNECTION_MIN_RETRY_TIME << CONNECTION_MAX_RETRY_BACKOFF_SHIFTS );+ CHECK( (Connection_retryDelayFor( CONNECTION_MIN_RETRY_TIME, 50 ) * 1000) <+ (CONNECTION_MAX_RETRY_TIME * 1000) );++ /* A slow link still reaches the ceiling honestly - its own round trip put it there, not the+ backoff - and the ceiling still holds. */+ CHECK_EQ( (Int)Connection_retryDelayFor( 600, 3 ), 2000 );CHECK_EQ( (Int)Connection_retryDelayFor( CONNECTION_MAX_RETRY_TIME, 3 ), CONNECTION_MAX_RETRY_TIME );+ /* Monotonic, and never below the connection's own timeout. */+ for( Int sent = 0; sent < 20; ++sent )+ {+ time_t here = Connection_retryDelayFor( 200, sent );+ time_t next = Connection_retryDelayFor( 200, sent + 1 );+ CHECK( here >= 200 );+ CHECK( next >= here );+ }+/* A command that has never been sent is not a retry, and must not read as a negative shift. */CHECK_EQ( (Int)Connection_retryDelayFor( 200, 0 ), 200 );}