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): ask every missing player at once, drop load-time rtt
Olcay Seygan4a7e0c14f344
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9116d5702..4288fd544 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -679,6 +679,7 @@ found and fixed — EA's own, not port damage.**- The readout in the top right corner now carries the frame number, and in a network game how many frames the room can still play before it has to wait on somebody, out of the input delay it is running with, plus the frame rate the slowest machine has set for everyone. "ready 4/7 room 29fps" is a healthy match; ready sitting at 0 is the stall you are about to feel.- 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 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 thediff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cppindex a4e9f3e91..6716b440c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp@@ -511,7 +511,11 @@ NetCommandRef * Connection::processAck(UnsignedShort commandID, UnsignedByte ori// Karn's rule: an ack for a command that went out more than once cannot be timed, because// there is no way to tell which of the sends it is acking. Timing it against the last send// reads far too short and would drag the timeout down exactly when the link is losing packets.- if (temp->getNumTimesSent() <= 1) {+ // Nor can a load-complete ack: it comes back when the other copy has finished loading and pumps+ // its network again, seconds later, so it times the other machine's load and not the link. Two+ // seats that are not the packet router send each other nothing else before the match, so that+ // one sample was the whole estimate and pinned their link at the 2000ms ceiling.+ if ((temp->getNumTimesSent() <= 1) && (temp->getCommand()->getNetCommandType() != NETCOMMANDTYPE_LOADCOMPLETE)) {Connection_updateRetryTimeout(lat, m_smoothedLatency, m_latencyVariance, m_retryTime);}diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cppindex 7782b6de5..5be5b3e8f 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp@@ -1772,10 +1772,22 @@ Bool ConnectionManager::allCommandsReady(UnsignedInt frame, Bool justTesting /*retryTimeoutMS = direct->getRetryTimeMS();}+ /* Ask everyone the frame is still missing from, not only the first. The loop above stops at+ the first player that is not ready, so with three or more seats a frame lost from two of+ them was asked for one seat at a time, the second only after the first had answered and a+ whole new wait had run out: 1.5 to 3 seconds frozen on frame 60 at the start of every lossy+ three-player match. The players before notReadyPlayer were ready, or the loop would have+ stopped on them. */if (shouldRequestFrameResend(stalledMS, sinceLastRequestMS, retryTimeoutMS)) {- DEBUG_LOG(("ConnectionManager::allCommandsReady - frame %d still missing from player %d after %d ms, asking again (retry timeout %d ms)\n",- frame, notReadyPlayer, stalledMS, retryTimeoutMS));- requestFrameDataResend(notReadyPlayer, frame);+ for (i = notReadyPlayer; i < MAX_SLOTS; ++i) {+ if ((m_frameData[i] == NULL) || m_frameData[i]->getIsQuitting() ||+ (m_frameData[i]->getFrameCommandCount(frame) == m_frameData[i]->getCommandCount(frame))) {+ continue;+ }+ DEBUG_LOG(("ConnectionManager::allCommandsReady - frame %d still missing from player %d after %d ms, asking again (retry timeout %d ms)\n",+ frame, i, stalledMS, retryTimeoutMS));+ requestFrameDataResend(i, frame);+ }m_resendLastRequest = now;}}