DEADSOFTWARE

Make autoswitch server-side. Add option to skip empty weapons by travi$
[d2df-sdl.git] / src / game / g_net.pas
index 54b06bf579020e5d0882bbe5b2e7946d710ce1c5..edd6024a49af09237130e98d105a0d3d0948efb9 100644 (file)
@@ -21,7 +21,7 @@ uses
   e_log, e_msg, utils, ENet, Classes, md5, MAPDEF{$IFDEF USE_MINIUPNPC}, miniupnpc;{$ELSE};{$ENDIF}
 
 const
-  NET_PROTOCOL_VER = 187;
+  NET_PROTOCOL_VER = 188;
 
   NET_MAXCLIENTS = 24;
   NET_CHANS = 12;
@@ -161,8 +161,8 @@ var
   NetAutoBanPerm:  Boolean = True;
   NetAutoBanWarn:  Boolean = False;
 
-  NetAuthTimeout:   Integer = 36 * 15;
-  NetPacketTimeout: Integer = 36 * 60;
+  NetAuthTimeout:   Integer = 15 * 1000;
+  NetPacketTimeout: Integer = 30 * 1000;
 
   NetState:      Integer = NET_STATE_NONE;
 
@@ -1678,12 +1678,12 @@ begin
       if (State = NET_STATE_AUTH) and (AuthTime > 0) and (AuthTime <= gTime) then
       begin
         g_Net_Penalize(@NetClients[ID], 'auth taking too long');
-        AuthTime := gTime + 18; // do it twice a second to give them a chance
+        AuthTime := gTime + 500; // do it twice a second to give them a chance
       end
       else if (State = NET_STATE_GAME) and (MsgTime > 0) and (MsgTime <= gTime) then
       begin
         g_Net_Penalize(@NetClients[ID], 'message timeout');
-        AuthTime := gTime + 18; // do it twice a second to give them a chance
+        AuthTime := gTime + 500; // do it twice a second to give them a chance
       end;
     end;
   end;
@@ -1710,6 +1710,12 @@ begin
     g_Player_Remove(TP.UID);
   end;
 
+  if (TC^.Peer^.data <> nil) then
+  begin
+    FreeMemory(TC^.Peer^.data);
+    TC^.Peer^.data := nil;
+  end;
+
   if (Force) then
     enet_peer_reset(TC^.Peer);
 
@@ -1725,12 +1731,6 @@ begin
   TC^.NetOut[NET_UNRELIABLE].Free();
   TC^.NetOut[NET_RELIABLE].Free();
 
-  if (NetEvent.peer^.data <> nil) then
-  begin
-    FreeMemory(NetEvent.peer^.data);
-    NetEvent.peer^.data := nil;
-  end;
-
   g_Console_Add(_lc[I_NET_MSG] + Format(_lc[I_NET_MSG_HOST_DISC], [ID]));
   Dec(NetClientCount);
 
@@ -2583,8 +2583,8 @@ initialization
   conRegVar('sv_autoban_permanent', @NetAutoBanPerm, '', 'whether autobans are permanent');
   conRegVar('sv_autoban_warn', @NetAutoBanWarn, '', 'send warnings to the client when he triggers penalties');
 
-  conRegVar('sv_auth_timeout', @NetAuthTimeout, '', 'number of frames in which connecting clients must complete auth (0 = unlimited)');
-  conRegVar('sv_packet_timeout', @NetPacketTimeout, '', 'number of frames the client must idle to be kicked (0 = unlimited)');
+  conRegVar('sv_auth_timeout', @NetAuthTimeout, '', 'number of msec in which connecting clients must complete auth (0 = unlimited)');
+  conRegVar('sv_packet_timeout', @NetPacketTimeout, '', 'number of msec the client must idle to be kicked (0 = unlimited)');
 
   conRegVar('net_master_list', @NetMasterList, '', 'list of master servers');