From 67aba2648cbd4309bbaef80174a1e1e29e01003a Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Wed, 25 Oct 2017 10:32:48 +0200 Subject: [PATCH 1/2] Fix download freezes (well, most of them) --- src/d_clisrv.c | 21 ++++++++++++--------- src/i_tcp.c | 3 +-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 312a308a1..374cb75f1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3120,16 +3120,19 @@ static boolean SV_AddWaitingPlayers(void) { newplayer = true; - // search for a free playernum - // we can't use playeringame since it is not updated here - for (; newplayernum < MAXPLAYERS; newplayernum++) - { - for (n = 0; n < MAXNETNODES; n++) - if (nodetoplayer[n] == newplayernum || nodetoplayer2[n] == newplayernum) + if (netgame) + newplayernum = node; // OMFG SAY WELCOME TO TEH NEW HACK FOR FIX FIL DOWNLOAD!!1! + else + // search for a free playernum + // we can't use playeringame since it is not updated here + for (; newplayernum < MAXPLAYERS; newplayernum++) + { + for (n = 0; n < MAXNETNODES; n++) + if (nodetoplayer[n] == newplayernum || nodetoplayer2[n] == newplayernum) + break; + if (n == MAXNETNODES) break; - if (n == MAXNETNODES) - break; - } + } // should never happen since we check the playernum // before accepting the join diff --git a/src/i_tcp.c b/src/i_tcp.c index c65a536a8..0063dedd7 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -498,8 +498,7 @@ static void cleanupnodes(void) // Why can't I start at zero? for (j = 1; j < MAXNETNODES; j++) - //if (!(nodeingame[j] || SV_SendingFile(j))) - if (!nodeingame[j]) + if (!(nodeingame[j] || SV_SendingFile(j))) nodeconnected[j] = false; } From c8e9e779e7c3bd4362e97a3f1cc98d7eedd2e923 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Mon, 18 Dec 2017 21:35:02 +0100 Subject: [PATCH 2/2] Add a short comment to explain the newplayernum hack --- src/d_clisrv.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 374cb75f1..88e8da2d6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3121,8 +3121,57 @@ static boolean SV_AddWaitingPlayers(void) newplayer = true; if (netgame) + // !!!!!!!!! EXTREMELY SUPER MEGA GIGA ULTRA ULTIMATELY TERRIBLY IMPORTANT !!!!!!!!! + // + // The line just after that comment is an awful, horrible, terrible, TERRIBLE hack. + // + // Basically, the fix I did in order to fix the download freezes happens + // to cause situations in which a player number does not match + // the node number associated to that player. + // That is totally normal, there is absolutely *nothing* wrong with that. + // Really. Player 7 being tied to node 29, for instance, is totally fine. + // + // HOWEVER. A few (broken) parts of the netcode do the TERRIBLE mistake + // of mixing up the concepts of node and player, resulting in + // incorrect handling of cases where a player is tied to a node that has + // a different number (which is a totally normal case, or at least should be). + // This incorrect handling can go as far as literally + // anyone from joining your server at all, forever. + // + // Given those two facts, there are two options available + // in order to let this download freeze fix be: + // 1) Fix the broken parts that assume a node is a player or similar bullshit. + // 2) Change the part this comment is located at, so that any player who joins + // is given the same number as their associated node. + // + // No need to say, 1) is by far the obvious best, whereas 2) is a terrible hack. + // Unfortunately, after trying 1), I most likely didn't manage to find all + // of those broken parts, and thus 2) has become the only safe option that remains. + // + // So I did this hack. + // + // If it isn't clear enough, in order to get rid of this ugly hack, + // you will have to fix all parts of the netcode that + // make a confusion between nodes and players. + // + // And if it STILL isn't clear enough, a node and a player + // is NOT the same thing. Never. NEVER. *NEVER*. + // + // And if someday you make the terrible mistake of + // daring to have the unforgivable idea to try thinking + // that a node might possibly be the same as a player, + // or that a player should have the same number as its node, + // be sure that I will somehow know about it and + // hunt you down tirelessly and make you regret it, + // even if you live on the other side of the world. + // + // TODO: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + // \todo >>>>>>>>>> Remove this horrible hack as soon as possible <<<<<<<<<< + // TODO: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + // + // !!!!!!!!! EXTREMELY SUPER MEGA GIGA ULTRA ULTIMATELY TERRIBLY IMPORTANT !!!!!!!!! newplayernum = node; // OMFG SAY WELCOME TO TEH NEW HACK FOR FIX FIL DOWNLOAD!!1! - else + else // Don't use the hack if we don't have to // search for a free playernum // we can't use playeringame since it is not updated here for (; newplayernum < MAXPLAYERS; newplayernum++)