DEADSOFTWARE

network: server is weapon authority!
authorKetmar Dark <ketmar@ketmar.no-ip.org>
Tue, 2 Oct 2018 03:17:54 +0000 (06:17 +0300)
committerKetmar Dark <ketmar@ketmar.no-ip.org>
Tue, 2 Oct 2018 03:18:12 +0000 (06:18 +0300)
src/game/g_netmsg.pas
src/game/g_player.pas

index f235035fbda6d740146eb383d07d4e66e740948f..e9cc68c2ee55ac7fcb0067073ed725ecdedd6e9e 100644 (file)
@@ -464,7 +464,7 @@ begin
       writeln('HOST PLRPOS: got: currweap=', CurrWeap, '; curfrm=', gTime, '; netweap=', newweapon, '; oldweap=', CurrWeap);
 {$ENDIF}
       //NetForceWeap := newweapon;
-      SetWeapon(newweapon);
+      SetWeaponHost(newweapon);
     end;
     //e_WriteLog(Format('R:ws=%d', [WeaponSelect]), MSG_WARNING);
     if Direction <> TDirection(Dir) then
@@ -2150,7 +2150,7 @@ begin
     if (gTime >= NetForceWeapFIdx) then
     begin
       //NetForceWeap := newweapon;
-      SetWeapon(newweapon);
+      SetWeaponHost(newweapon);
     end;
     //SetWeapon(M.ReadByte());
 
index 0565c75b2761056ab75ca321ac9c3d6c556cd480..66f0099063c3027084c4b32418d174acf77ed4e3 100644 (file)
@@ -280,7 +280,7 @@ type
     procedure   ReleaseKeysNoWeapon();
     procedure   SetModel(ModelName: String);
     procedure   SetColor(Color: TRGB);
-    procedure   SetWeapon(W: Byte);
+    procedure   SetWeaponHost(W: Byte);
     function    IsKeyPressed(K: Byte): Boolean;
     function    GetKeys(): Byte;
     function    PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean; virtual;
@@ -3887,9 +3887,12 @@ begin
   FNextWeap := $4000;
 end;
 
-// used by network layer
-procedure TPlayer.SetWeapon(W: Byte);
+// used exclusively by network layer
+procedure TPlayer.SetWeaponHost(W: Byte);
 begin
+  if (W > High(FWeapon)) then exit;
+  if (not FWeapon[W]) then exit; // server is authority!
+
   if FCurrWeap <> W then
     if (W = WEAPON_SAW) then
       FSawSoundSelect.PlayAt(FObj.X, FObj.Y);