X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_net.pas;h=45f507a53dcccadfe604224d5fccaa1f90f7666d;hb=847038a14751d192fcc4af172d7a963e28144c72;hp=07d9713477ed7da1251d54bfffac53b3cfd5d9b7;hpb=10f31fd950820bcd8b83aec43debcfc260b714b2;p=d2df-sdl.git diff --git a/src/game/g_net.pas b/src/game/g_net.pas index 07d9713..45f507a 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -21,7 +21,7 @@ uses e_log, e_msg, utils, ENet, Classes, md5, MAPDEF{$IFDEF USE_MINIUPNPC}, miniupnpc;{$ELSE};{$ENDIF} const - NET_PROTOCOL_VER = 185; + NET_PROTOCOL_VER = 186; NET_MAXCLIENTS = 24; NET_CHANS = 12; @@ -172,6 +172,8 @@ var NetGotEverything: Boolean = False; NetGotKeys: Boolean = False; + NetDeafLevel: Integer = 0; + {$IFDEF USE_MINIUPNPC} NetPortForwarded: Word = 0; NetPongForwarded: Boolean = False; @@ -271,7 +273,10 @@ begin end; procedure g_Net_InitLowLevel (); + var v: ENetVersion; begin + v := enet_linked_version(); + e_LogWritefln('ENet Version: %s.%s.%s', [ENET_VERSION_GET_MAJOR(v), ENET_VERSION_GET_MINOR(v), ENET_VERSION_GET_PATCH(v)]); if enet_init_success then raise Exception.Create('wuta?!'); enet_init_success := (enet_initialize() = 0); end; @@ -1492,8 +1497,6 @@ begin NetAddr.host := IPAddr; NetAddr.port := Port; - if NetForwardPorts then NetPortThread := BeginThread(ForwardThread); - NetHost := enet_host_create(@NetAddr, NET_MAXCLIENTS, NET_CHANS, 0, 0); if (NetHost = nil) then @@ -1504,6 +1507,8 @@ begin Exit; end; + if NetForwardPorts then NetPortThread := BeginThread(ForwardThread); + NetPongSock := enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM); if NetPongSock <> ENET_SOCKET_NULL then begin @@ -1606,7 +1611,7 @@ var Ping: array [0..9] of Byte; NPl: Byte; begin - if NetPongSock = ENET_SOCKET_NULL then Exit; + if (NetPongSock = ENET_SOCKET_NULL) or (NetHost = nil) then Exit; Buf.data := Addr(Ping[0]); Buf.dataLength := 2+8; @@ -2238,6 +2243,9 @@ var begin Result := False; + if NetHost = nil then + exit; + if NetPortForwarded = NetHost.address.port then begin Result := True; @@ -2436,6 +2444,7 @@ initialization conRegVar('cl_interp', @NetInterpLevel, '', 'net player interpolation steps'); conRegVar('cl_last_ip', @NetClientIP, '', 'address of the last you have connected to'); conRegVar('cl_last_port', @NetClientPort, '', 'port of the last server you have connected to'); + conRegVar('cl_deafen', @NetDeafLevel, '', 'filter server messages (0-3)'); conRegVar('sv_forwardports', @NetForwardPorts, '', 'forward server port using miniupnpc (requires server restart)'); conRegVar('sv_rcon', @NetAllowRCON, '', 'enable remote console');