diff --git a/src/game/g_net.pas b/src/game/g_net.pas
index 20da332414e4bbf5b80ceaf66c0f74ea112f167e..907a5beefd437b163adaf1ef934dbc29c55fee58 100644 (file)
--- a/src/game/g_net.pas
+++ b/src/game/g_net.pas
NET_STATE_AUTH = 1;
NET_STATE_GAME = 2;
+ NET_CONNECT_TIMEOUT = 1000 * 10;
+
BANLIST_FILENAME = 'banlist.txt';
NETDUMP_FILENAME = 'netdump';
g_main, g_game, g_language, g_weapons, utils, ctypes;
var
- g_Net_DownloadTimeoutMs: Single;
+ g_Net_DownloadTimeout: Single;
{ /// SERVICE FUNCTIONS /// }
function g_Net_Connect(IP: string; Port: enet_uint16): Boolean;
var
OuterLoop: Boolean;
+ TimeoutTime, T: Int64;
begin
if NetMode <> NET_NONE then
begin
Exit;
end;
+ // предупредить что ждем слишком долго через N секунд
+ TimeoutTime := GetTimer() + NET_CONNECT_TIMEOUT;
+
OuterLoop := True;
while OuterLoop do
begin
end;
end;
+ T := GetTimer();
+ if T > TimeoutTime then
+ begin
+ TimeoutTime := T + NET_CONNECT_TIMEOUT * 100; // одного предупреждения хватит
+ g_Console_Add(_lc[I_NET_MSG_TIMEOUT_WARN], True);
+ g_Console_Add(Format(_lc[I_NET_MSG_PORTS], [Integer(Port), Integer(NET_PING_PORT)]), True);
+ end;
+
ProcessLoading(true);
if e_KeyPressed(IK_SPACE) or e_KeyPressed(IK_ESCAPE) or e_KeyPressed(VK_ESCAPE) or
end;
g_Console_Add(_lc[I_NET_MSG_ERROR] + _lc[I_NET_ERR_TIMEOUT], True);
+ g_Console_Add(Format(_lc[I_NET_MSG_PORTS], [Integer(Port), Integer(NET_PING_PORT)]), True);
if NetPeer <> nil then enet_peer_reset(NetPeer);
if NetHost <> nil then
begin
FillChar(ev, SizeOf(ev), 0);
stream := nil;
repeat
- status := enet_host_service(NetHost, @ev, Trunc(g_Net_DownloadTimeoutMs * 1000));
+ status := enet_host_service(NetHost, @ev, Trunc(g_Net_DownloadTimeout * 1000));
if status > 0 then
begin
case ev.kind of
{$ENDIF}
initialization
- conRegVar('cl_downloadtimeout', @g_Net_DownloadTimeoutMs, 0.0, 1000000.0, '', 'timeout in seconds, 0 to disable it');
- g_Net_DownloadTimeoutMs := 60;
+ conRegVar('cl_downloadtimeout', @g_Net_DownloadTimeout, 0.0, 1000000.0, '', 'timeout in seconds, 0 to disable it');
+ g_Net_DownloadTimeout := 60;
NetIn.Alloc(NET_BUFSIZE);
NetOut.Alloc(NET_BUFSIZE);
finalization