DEADSOFTWARE

network: do not send weapon switch keys over the network, send actual selected weapon...
[d2df-sdl.git] / src / game / g_player.pas
index 4604b3c95f5a1f9ed2250ebed552b4e5ffc53f23..f9de6195596b43fa555a80dcbff9ba1d6c241388 100644 (file)
@@ -274,6 +274,7 @@ type
     function    GetRespawnPoint(): Byte;
     procedure   PressKey(Key: Byte; Time: Word = 1);
     procedure   ReleaseKeys();
+    procedure   ReleaseKeysNoWeapon();
     procedure   SetModel(ModelName: String);
     procedure   SetColor(Color: TRGB);
     procedure   SetWeapon(W: Byte);
@@ -3589,7 +3590,7 @@ end;
 
 procedure TPlayer.QueueWeaponSwitch(Weapon: Byte);
 begin
-  if g_Game_IsClient then Exit;
+  //if g_Game_IsClient then Exit;
   if Weapon > High(FWeapon) then Exit;
   FNextWeap := FNextWeap or (1 shl Weapon);
 end;
@@ -3841,13 +3842,13 @@ end;
 
 procedure TPlayer.NextWeapon();
 begin
-  if g_Game_IsClient then Exit;
+  //if g_Game_IsClient then Exit;
   FNextWeap := $8000;
 end;
 
 procedure TPlayer.PrevWeapon();
 begin
-  if g_Game_IsClient then Exit;
+  //if g_Game_IsClient then Exit;
   FNextWeap := $4000;
 end;
 
@@ -4966,6 +4967,7 @@ begin
       DoLerp(4);
 
   if NetServer then
+  begin
     if FClientID >= 0 then
     begin
       FPing := NetClients[FClientID].Peer^.lastRoundTripTime;
@@ -4978,6 +4980,7 @@ begin
       FPing := 0;
       FLoss := 0;
     end;
+  end;
 
   if FAlive and (FPunchAnim <> nil) then
     FPunchAnim.Update();
@@ -5008,8 +5011,8 @@ begin
   end;
 
   // no need to do that each second frame, weapon queue will take care of it
-  if FAlive and FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
-  if FAlive and FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
+  if FAlive and FKeys[KEY_NEXTWEAPON].Pressed {and AnyServer} then NextWeapon();
+  if FAlive and FKeys[KEY_PREVWEAPON].Pressed {and AnyServer} then PrevWeapon();
 
   if gTime mod (GAME_TICK*2) <> 0 then
   begin
@@ -5829,6 +5832,18 @@ begin
   end;
 end;
 
+procedure TPlayer.ReleaseKeysNoWeapon();
+var
+  a: Integer;
+begin
+  for a := Low(FKeys) to High(FKeys) do
+  begin
+    if (a = KEY_PREVWEAPON) or (a = KEY_NEXTWEAPON) then continue;
+    FKeys[a].Pressed := False;
+    FKeys[a].Time := 0;
+  end;
+end;
+
 procedure TPlayer.OnDamage(Angle: SmallInt);
 begin
 end;
@@ -7035,7 +7050,7 @@ begin
             end;
         end;
 
-  //HACK! (does it belongs there?)
+  //HACK! (does it belong there?)
   RealizeCurrentWeapon();
 
 // Åñëè åñòü âîçìîæíûå öåëè: