From: Ketmar Dark Date: Wed, 16 Oct 2019 19:10:30 +0000 (+0300) Subject: net: enet+shitdoze == clusterfuck; added workaround for `enet_host_service()` (and... X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=a50544067b99f65e2b4882366521287607dd892f;p=d2df-sdl.git net: enet+shitdoze == clusterfuck; added workaround for `enet_host_service()` (and comment about it) --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 3356c80..2226565 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -4630,6 +4630,9 @@ begin OuterLoop := True; while OuterLoop do begin + // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html + // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure. + // thank you, enet. let's ignore failures altogether then. while (enet_host_service(NetHost, @NetEvent, 50) > 0) do begin if (NetEvent.kind = ENET_EVENT_TYPE_RECEIVE) then diff --git a/src/game/g_net.pas b/src/game/g_net.pas index b2543fb..261df8c 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -251,6 +251,11 @@ procedure g_Net_DeinitLowLevel (); implementation +// *enet_host_service()* +// fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html +// tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure. +// thank you, enet. let's ignore failures altogether then. + uses SysUtils, e_input, g_nethandler, g_netmsg, g_netmaster, g_player, g_window, g_console, @@ -767,13 +772,15 @@ begin ett := getNewTimeoutEnd(); repeat status := enet_host_service(NetHost, @ev, 300); + { if (status < 0) then begin g_Console_Add(_lc[I_NET_MSG_ERROR] + _lc[I_NET_ERR_CONN] + ' network error', True); Result := -1; exit; end; - if (status = 0) then + } + if (status <= 0) then begin // check for timeout ct := GetTimerMS(); @@ -946,13 +953,15 @@ begin ett := getNewTimeoutEnd(); repeat status := enet_host_service(NetHost, @ev, 300); + { if (status < 0) then begin g_Console_Add(_lc[I_NET_MSG_ERROR] + _lc[I_NET_ERR_CONN] + ' network error', True); Result := -1; exit; end; - if (status = 0) then + } + if (status <= 0) then begin // check for timeout ct := GetTimerMS(); @@ -1128,13 +1137,15 @@ begin repeat //stx := -GetTimerMS(); status := enet_host_service(NetHost, @ev, 300); + { if (status < 0) then begin g_Console_Add(_lc[I_NET_MSG_ERROR] + _lc[I_NET_ERR_CONN] + ' network error', True); Result := -1; exit; end; - if (status = 0) then + } + if (status <= 0) then begin // check for timeout ct := GetTimerMS(); diff --git a/src/game/g_netmaster.pas b/src/game/g_netmaster.pas index e696d87..95fbb5f 100644 --- a/src/game/g_netmaster.pas +++ b/src/game/g_netmaster.pas @@ -238,6 +238,9 @@ begin ct := GetTimerMS(); if (ct < stt) or (ct-stt >= 1500) then break; + // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html + // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure. + // thank you, enet. let's ignore failures altogether then. sres := enet_host_service(NetMHost, @NetMEvent, 100); // if (sres < 0) then break; if (sres <= 0) then continue; @@ -1145,6 +1148,9 @@ begin mlist[f].pulse(); end; + // fuck! https://www.mail-archive.com/enet-discuss@cubik.org/msg00852.html + // tl;dr: on shitdows, we can get -1 sometimes, and it is *NOT* a failure. + // thank you, enet. let's ignore failures altogether then. sres := enet_host_service(NetMHost, @NetMEvent, timeout); while (sres > 0) do begin