X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=blobdiff_plain;f=src%2Fgame%2Fg_net.pas;h=907a5beefd437b163adaf1ef934dbc29c55fee58;hp=0f3df0f81f384348afba14eeaa326f3ce4ff6f42;hb=683e1735a7efbf7342dec58a49d7f559a1e75fea;hpb=3cc441c62f499313c45dab584bd0901bc819ee7c diff --git a/src/game/g_net.pas b/src/game/g_net.pas index 0f3df0f..907a5be 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -63,6 +63,8 @@ const NET_STATE_AUTH = 1; NET_STATE_GAME = 2; + NET_CONNECT_TIMEOUT = 1000 * 10; + BANLIST_FILENAME = 'banlist.txt'; NETDUMP_FILENAME = 'netdump'; @@ -756,6 +758,7 @@ end; function g_Net_Connect(IP: string; Port: enet_uint16): Boolean; var OuterLoop: Boolean; + TimeoutTime, T: Int64; begin if NetMode <> NET_NONE then begin @@ -804,6 +807,9 @@ begin Exit; end; + // предупредить что ждем слишком долго через N секунд + TimeoutTime := GetTimer() + NET_CONNECT_TIMEOUT; + OuterLoop := True; while OuterLoop do begin @@ -823,6 +829,14 @@ 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 @@ -831,6 +845,7 @@ begin 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