DEADSOFTWARE

Game: Weapon autoswitch by travi$
[d2df-sdl.git] / src / game / g_netmsg.pas
index 84dbeaa360d7b89dcf8babfa9fb8bdeba02131d2..3701038e76d8f3063378d92364612cdbab798973 100644 (file)
@@ -435,6 +435,13 @@ begin
       Exit;
     end;
 
+  if (C^.Player <> 0) then
+  begin
+    // already received info
+    g_Net_Penalize(C, 'client info spam');
+    Exit;
+  end;
+
   Color.R := R;
   Color.B := B;
   Color.G := G;
@@ -448,6 +455,7 @@ begin
 
   C^.Player := PID;
   C^.WaitForFirstSpawn := false;
+  C^.AuthTime := 0;
 
   g_Console_Add(Format(_lc[I_PLAYER_JOIN], [PName]), True);
   e_WriteLog('NET: Client ' + PName + ' [' + IntToStr(C^.ID) +
@@ -2439,6 +2447,7 @@ var
   PID: Word;
   Pl: TPlayer;
   I, OldFire: Integer;
+  checkWeapon: Boolean;
   OldJet, Flam: Boolean;
   NewTeam: Byte;
 begin
@@ -2460,8 +2469,19 @@ begin
     NewTeam := M.ReadByte();
 
     for I := WP_FIRST to WP_LAST do
-      FWeapon[I] := (M.ReadByte() <> 0);
-
+    begin
+      checkWeapon := (M.ReadByte() <> 0);
+      if ( ((PID = gPlayer1.UID) or ( (gPlayer2 <> nil) and (PID = gPlayer2.UID))) and (I <> WEAPON_PISTOL) and (I <> WEAPON_KASTET ) and (gWeaponAutoswitch = True)) then
+      begin
+        if ( (checkWeapon = True) and (FWeapon[I] = False) ) then
+        begin
+          FWeapon[I] := True;
+          if (PID = gPlayer1.UID) then gSelectWeapon[0, I] := True
+          else gSelectWeapon[1, I] := True;
+        end;
+      end;
+      FWeapon[I] := checkWeapon;
+    end;
     for I := A_BULLETS to A_HIGH do
       FAmmo[I] := M.ReadWord();