From: fgsfds Date: Wed, 21 Aug 2019 14:42:35 +0000 (+0300) Subject: Game: Warn about ports; X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=683e1735a7efbf7342dec58a49d7f559a1e75fea Game: Warn about ports; draw console messages on loading screen --- diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 53f1c4f..5953403 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -39,7 +39,7 @@ uses procedure g_Console_Init; procedure g_Console_Update; -procedure g_Console_Draw; +procedure g_Console_Draw (MessagesOnly: Boolean = False); procedure g_Console_Char (C: AnsiChar); procedure g_Console_Control (K: Word); procedure g_Console_Process (L: AnsiString; quiet: Boolean=false); @@ -1092,7 +1092,7 @@ begin until not cbufLineUp(sp, ep); end; -procedure g_Console_Draw(); +procedure g_Console_Draw(MessagesOnly: Boolean = False); var CWidth, CHeight: Byte; mfW, mfH: Word; @@ -1109,6 +1109,8 @@ begin if MsgArray[a].Time > 0 then e_TextureFontPrintFmt(0, offset_y + CHeight * a, MsgArray[a].Msg, gStdFont, True); + if MessagesOnly then Exit; + if gChatShow then begin if ChatTop then diff --git a/src/game/g_language.pas b/src/game/g_language.pas index 08d315e..f622d64 100644 --- a/src/game/g_language.pas +++ b/src/game/g_language.pas @@ -350,6 +350,8 @@ type I_NET_MSG_CLIENT_DONE, I_NET_MSG_CLIENT_DISC, I_NET_MSG_KICK, + I_NET_MSG_PORTS, + I_NET_MSG_TIMEOUT_WARN, I_NET_MAP_DL, I_NET_WAD_DL, @@ -1265,6 +1267,10 @@ const 'Îòêëþ÷åíèå âûïîëíåíî.'), ('NET MSG KICK', 'You were dropped from the game! Reason: ', 'Âàñ âûáðîñèëî ñ ñåðâåðà! Ïðè÷èíà: '), + ('NET MSG PORTS', 'Make sure ports %d and %d are forwarded on the server.', + 'Ñïðîñèòå àäìèíà, ïðîáðîñèë ëè îí ïîðòû %d è %d íà ðîóòåðå.'), + ('NET MSG TIMEOUT WARN', 'Connection is taking too long.', + 'Ñåðâåð íå îòâå÷àåò óæå äîâîëüíî äîëãî.'), ('NET MAP DL', 'Map %s not found. Downloading from the server...', 'Êàðòà %s íå íàéäåíà. Ñêà÷èâàåì ñ ñåðâåðà...'), 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 diff --git a/src/game/g_window.pas b/src/game/g_window.pas index d790c4f..88b229a 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -829,6 +829,7 @@ begin e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); DrawLoadingStat(); + g_Console_Draw(True); SwapBuffers(); end; end;