diff --git a/src/game/g_net.pas b/src/game/g_net.pas
index fbc85eec75c06e797d0a006a452f9c33f9e16cbe..98ca2ab33d8b0d31f15a1e6880f2301d576c5807 100644 (file)
--- a/src/game/g_net.pas
+++ b/src/game/g_net.pas
NetGotEverything: Boolean = False;
NetGotKeys: Boolean = False;
NetGotEverything: Boolean = False;
NetGotKeys: Boolean = False;
+ NetDeafLevel: Integer = 0;
+
{$IFDEF USE_MINIUPNPC}
NetPortForwarded: Word = 0;
NetPongForwarded: Boolean = False;
{$IFDEF USE_MINIUPNPC}
NetPortForwarded: Word = 0;
NetPongForwarded: Boolean = False;
uses
SysUtils,
uses
SysUtils,
- e_input, e_res,
+ e_input, e_res, g_options,
g_nethandler, g_netmsg, g_netmaster, g_player, g_window, g_console,
g_nethandler, g_netmsg, g_netmaster, g_player, g_window, g_console,
- g_main, g_game, g_language, g_weapons, ctypes, g_system, g_map;
+ g_game, g_language, g_weapons, ctypes, g_system, g_map;
const
FILE_CHUNK_SIZE = 8192;
const
FILE_CHUNK_SIZE = 8192;
end;
procedure g_Net_InitLowLevel ();
end;
procedure g_Net_InitLowLevel ();
+ var v: ENetVersion;
begin
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;
if enet_init_success then raise Exception.Create('wuta?!');
enet_init_success := (enet_initialize() = 0);
end;
NetAddr.host := IPAddr;
NetAddr.port := Port;
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
NetHost := enet_host_create(@NetAddr, NET_MAXCLIENTS, NET_CHANS, 0, 0);
if (NetHost = nil) then
Exit;
end;
Exit;
end;
+ if NetForwardPorts then NetPortThread := BeginThread(ForwardThread);
+
NetPongSock := enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM);
if NetPongSock <> ENET_SOCKET_NULL then
begin
NetPongSock := enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM);
if NetPongSock <> ENET_SOCKET_NULL then
begin
Ping: array [0..9] of Byte;
NPl: Byte;
begin
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;
Buf.data := Addr(Ping[0]);
Buf.dataLength := 2+8;
NetOut.Clear();
NetOut.Write(Byte(Ord('D')));
NetOut.Write(Byte(Ord('F')));
NetOut.Clear();
NetOut.Write(Byte(Ord('D')));
NetOut.Write(Byte(Ord('F')));
- NetOut.Write(NetPort);
+ NetOut.Write(NetHost.address.port);
NetOut.Write(ClTime);
TMasterHost.writeInfo(NetOut);
NPl := 0;
NetOut.Write(ClTime);
TMasterHost.writeInfo(NetOut);
NPl := 0;
end;
// предупредить что ждем слишком долго через N секунд
end;
// предупредить что ждем слишком долго через N секунд
- TimeoutTime := sys_GetTicks() + NET_CONNECT_TIMEOUT;
+ TimeoutTime := GetTickCount64() + NET_CONNECT_TIMEOUT;
OuterLoop := True;
while OuterLoop do
OuterLoop := True;
while OuterLoop do
end;
end;
end;
end;
- T := sys_GetTicks();
+ T := GetTickCount64();
if T > TimeoutTime then
begin
TimeoutTime := T + NET_CONNECT_TIMEOUT * 100; // одного предупреждения хватит
if T > TimeoutTime then
begin
TimeoutTime := T + NET_CONNECT_TIMEOUT * 100; // одного предупреждения хватит
begin
Result := False;
begin
Result := False;
- if NetPortForwarded = NetPort then
+ if NetHost = nil then
+ exit;
+
+ if NetPortForwarded = NetHost.address.port then
begin
Result := True;
exit;
begin
Result := True;
exit;
exit;
end;
exit;
end;
- StrPort := IntToStr(NetPort);
+ StrPort := IntToStr(NetHost.address.port);
I := UPNP_AddPortMapping(
Urls.controlURL, Addr(data.first.servicetype[1]),
PChar(StrPort), PChar(StrPort), Addr(LanAddr[0]), PChar('D2DF'),
I := UPNP_AddPortMapping(
Urls.controlURL, Addr(data.first.servicetype[1]),
PChar(StrPort), PChar(StrPort), Addr(LanAddr[0]), PChar('D2DF'),
if I <> 0 then
begin
if I <> 0 then
begin
- conwritefln('forwarding port %d failed: error %d', [NetPort, I]);
+ conwritefln('forwarding port %d failed: error %d', [NetHost.address.port, I]);
FreeUPNPDevList(DevList);
FreeUPNPUrls(@Urls);
exit;
FreeUPNPDevList(DevList);
FreeUPNPUrls(@Urls);
exit;
end;
end;
end;
end;
- conwritefln('forwarded port %d successfully', [NetPort]);
+ conwritefln('forwarded port %d successfully', [NetHost.address.port]);
NetIGDControl := AnsiString(Urls.controlURL);
NetIGDService := data.first.servicetype;
NetIGDControl := AnsiString(Urls.controlURL);
NetIGDService := data.first.servicetype;
- NetPortForwarded := NetPort;
+ NetPortForwarded := NetHost.address.port;
FreeUPNPDevList(DevList);
FreeUPNPUrls(@Urls);
FreeUPNPDevList(DevList);
FreeUPNPUrls(@Urls);
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_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');
conRegVar('sv_forwardports', @NetForwardPorts, '', 'forward server port using miniupnpc (requires server restart)');
conRegVar('sv_rcon', @NetAllowRCON, '', 'enable remote console');