X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_net.pas;h=fc5287a4dacc8708686611304a0a76afaa10706c;hb=331297e82162a6acd3e9e07605368e329ce66105;hp=95f8f459b862c6a0253d699b0c89715040bcb1a6;hpb=08ddabc37acc6f5655533fddefbe8a9b8ed95e76;p=d2df-sdl.git diff --git a/src/game/g_net.pas b/src/game/g_net.pas index 95f8f45..fc5287a 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -22,7 +22,7 @@ uses e_log, e_msg, ENet, Classes, MAPDEF{$IFDEF USE_MINIUPNPC}, miniupnpc;{$ELSE};{$ENDIF} const - NET_PROTOCOL_VER = 173; + NET_PROTOCOL_VER = 174; NET_MAXCLIENTS = 24; NET_CHANS = 11; @@ -44,6 +44,7 @@ const NET_CLIENT = 2; NET_BUFSIZE = $FFFF; + NET_PING_PORT = $DF2D; NET_EVERYONE = -1; @@ -146,9 +147,10 @@ var NetPongForwarded: Boolean = False; NetIGDControl: AnsiString; NetIGDService: TURLStr; - NetPortThread: TThreadID = 0; {$ENDIF} + NetPortThread: TThreadID = 0; + NetDumpFile: TStream; function g_Net_Init(): Boolean; @@ -388,7 +390,7 @@ begin if NetPongSock <> ENET_SOCKET_NULL then begin NetPongAddr.host := IPAddr; - NetPongAddr.port := Port + 1; + NetPongAddr.port := NET_PING_PORT; if enet_socket_bind(NetPongSock, @NetPongAddr) < 0 then begin enet_socket_destroy(NetPongSock); @@ -503,6 +505,7 @@ begin NetOut.Clear(); NetOut.Write(Byte(Ord('D'))); NetOut.Write(Byte(Ord('F'))); + NetOut.Write(NetPort); NetOut.Write(ClTime); g_Net_Slist_WriteInfo(); NPl := 0; @@ -531,10 +534,8 @@ begin Result := 0; if NetUseMaster then - begin g_Net_Slist_Check; - g_Net_Host_CheckPings; - end; + g_Net_Host_CheckPings; while (enet_host_service(NetHost, @NetEvent, 0) > 0) do begin @@ -815,7 +816,7 @@ begin ProcessLoading(true); - if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then + if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) then OuterLoop := False; end; @@ -978,7 +979,7 @@ begin ProcessLoading(true); - if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then + if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) or e_KeyPressed(VK_ESCAPE) then break; end; Result := msgStream; @@ -1144,7 +1145,7 @@ begin NetPongForwarded := False; NetPortForwarded := 0; - DevList := upnpDiscover(1000, nil, nil, 0, 0, Addr(Err)); + DevList := upnpDiscover(1000, nil, nil, 0, 0, 2, Addr(Err)); if DevList = nil then begin conwritefln('port forwarding failed: upnpDiscover() failed: %d', [Err]); @@ -1178,7 +1179,7 @@ begin if ForwardPongPort then begin - StrPort := IntToStr(NetPort + 1); + StrPort := IntToStr(NET_PING_PORT); I := UPNP_AddPortMapping( Urls.controlURL, Addr(data.first.servicetype[1]), PChar(StrPort), PChar(StrPort), Addr(LanAddr[0]), PChar('D2DF'),