DEADSOFTWARE

Game: Warn about ports;
authorfgsfds <pvt.fgsfds@gmail.com>
Wed, 21 Aug 2019 14:42:35 +0000 (17:42 +0300)
committerfgsfds <pvt.fgsfds@gmail.com>
Wed, 21 Aug 2019 14:42:35 +0000 (17:42 +0300)
draw console messages on loading screen

src/game/g_console.pas
src/game/g_language.pas
src/game/g_net.pas
src/game/g_window.pas

index 53f1c4f1a9998d3c328b2f8fd29be4c4a52e720c..5953403c7dd3aa4f4e714d7e1a99de1e927fb770 100644 (file)
@@ -39,7 +39,7 @@ uses
 
 procedure g_Console_Init;
 procedure g_Console_Update;
 
 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);
 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;
 
   until not cbufLineUp(sp, ep);
 end;
 
-procedure g_Console_Draw();
+procedure g_Console_Draw(MessagesOnly: Boolean = False);
 var
   CWidth, CHeight: Byte;
   mfW, mfH: Word;
 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 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
   if gChatShow then
   begin
     if ChatTop then
index 08d315ef1aca69a36369aabd699d50c35d9f1a5e..f622d64be69d1e0d9be4c3120528b4789cfa62ac 100644 (file)
@@ -350,6 +350,8 @@ type
     I_NET_MSG_CLIENT_DONE,
     I_NET_MSG_CLIENT_DISC,
     I_NET_MSG_KICK,
     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,
 
     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 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 íå íàéäåíà. Ñêà÷èâàåì ñ ñåðâåðà...'),
 
     ('NET MAP DL',                     'Map %s not found. Downloading from the server...',
                                        'Êàðòà %s íå íàéäåíà. Ñêà÷èâàåì ñ ñåðâåðà...'),
index 0f3df0f81f384348afba14eeaa326f3ce4ff6f42..907a5beefd437b163adaf1ef934dbc29c55fee58 100644 (file)
@@ -63,6 +63,8 @@ const
   NET_STATE_AUTH = 1;
   NET_STATE_GAME = 2;
 
   NET_STATE_AUTH = 1;
   NET_STATE_GAME = 2;
 
+  NET_CONNECT_TIMEOUT = 1000 * 10;
+
   BANLIST_FILENAME = 'banlist.txt';
   NETDUMP_FILENAME = 'netdump';
 
   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;
 function g_Net_Connect(IP: string; Port: enet_uint16): Boolean;
 var
   OuterLoop: Boolean;
+  TimeoutTime, T: Int64;
 begin
   if NetMode <> NET_NONE then
   begin
 begin
   if NetMode <> NET_NONE then
   begin
@@ -804,6 +807,9 @@ begin
     Exit;
   end;
 
     Exit;
   end;
 
+  // предупредить что ждем слишком долго через N секунд
+  TimeoutTime := GetTimer() + NET_CONNECT_TIMEOUT;
+
   OuterLoop := True;
   while OuterLoop do
   begin
   OuterLoop := True;
   while OuterLoop do
   begin
@@ -823,6 +829,14 @@ begin
       end;
     end;
 
       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
     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);
   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
   if NetPeer <> nil then enet_peer_reset(NetPeer);
   if NetHost <> nil then
   begin
index d790c4f852c9f468bd51c39ba4a9fd1b221faa20..88b229aa220b888697903da121c21f01e0bbe0f4 100644 (file)
@@ -829,6 +829,7 @@ begin
       e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
 
       DrawLoadingStat();
       e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
 
       DrawLoadingStat();
+      g_Console_Draw(True);
       SwapBuffers();
     end;
   end;
       SwapBuffers();
     end;
   end;