DEADSOFTWARE

Add flamethrower weapon, item and ammo
[d2df-sdl.git] / src / game / g_net.pas
index 74defc3d1083f613d89e67f59da2a879a4c9acc1..0ea107b875028752a826f3043227275af8a834c5 100644 (file)
@@ -1,12 +1,28 @@
+(* Copyright (C)  DooM 2D:Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$MODE DELPHI}
 unit g_net;
 
 interface
 
 uses
-  e_log, e_fixedbuffer, ENet, ENetTypes, ENetPlatform, Classes;
+  e_log, e_fixedbuffer, ENet, Classes;
 
 const
-  NET_PROTOCOL_VER = 164;
+  NET_PROTOCOL_VER = 170;
 
   NET_MAXCLIENTS = 24;
   NET_CHANS = 11;
@@ -412,7 +428,7 @@ begin
     P := enet_packet_create(Addr(NetOut.Data), NetOut.Len, F);
     if not Assigned(P) then Exit;
 
-    enet_host_widecast(NetHost, Chan, P);
+    enet_host_broadcast(NetHost, Chan, P);
   end;
 
   g_Net_Flush();
@@ -423,14 +439,15 @@ procedure g_Net_Host_CheckPings();
 var
   ClAddr: ENetAddress;
   Buf: ENetBuffer;
-  Len, ClTime: Integer;
-  Ping: array [0..5] of Byte;
+  Len: Integer;
+  ClTime: Int64;
+  Ping: array [0..9] of Byte;
   NPl: Byte;
 begin
   if NetPongSock = ENET_SOCKET_NULL then Exit;
 
   Buf.data := Addr(Ping[0]);
-  Buf.dataLength := 6;
+  Buf.dataLength := 2+8;
 
   Ping[0] := 0;
 
@@ -439,7 +456,7 @@ begin
 
   if (Ping[0] = Ord('D')) and (Ping[1] = Ord('F')) then
   begin
-    ClTime := Integer(Addr(Ping[2])^);
+    ClTime := Int64(Addr(Ping[2])^);
 
     e_Buffer_Clear(@NetOut);
     e_Buffer_Write(@NetOut, Byte(Ord('D')));
@@ -535,7 +552,7 @@ begin
       ENET_EVENT_TYPE_DISCONNECT:
       begin
         ID := Byte(NetEvent.peer^.data^);
-        if ID > High(NetClients) then Exit;     
+        if ID > High(NetClients) then Exit;
         TC := @NetClients[ID];
         if TC = nil then Exit;
 
@@ -745,7 +762,7 @@ begin
     end;
 
     ProcessLoading();
-    
+
     e_PollInput();
 
     if e_KeyPressed(IK_ESCAPE) or e_KeyPressed(IK_SPACE) then
@@ -860,7 +877,7 @@ begin
   begin
     P := enet_packet_create(@Data[0], dataLength, F);
     if not Assigned(P) then Exit;
-    enet_host_widecast(NetHost, Chan, P);
+    enet_host_broadcast(NetHost, Chan, P);
   end;
 
   enet_host_flush(NetHost);
@@ -874,6 +891,7 @@ var
   Ptr: Pointer;
   msgStream: TMemoryStream;
 begin
+  FillChar(downloadEvent, SizeOf(downloadEvent), 0);
   msgStream := nil;
   OuterLoop := True;
   while OuterLoop do