]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix mouse rotator error spam (#39071)
authorTayrtahn <tayrtahn@gmail.com>
Sat, 19 Jul 2025 23:16:40 +0000 (19:16 -0400)
committerGitHub <noreply@github.com>
Sat, 19 Jul 2025 23:16:40 +0000 (01:16 +0200)
Ignore mouse rotation requests when the player is switching controlled entity

Content.Client/MouseRotator/MouseRotatorSystem.cs
Content.Shared/MouseRotator/MouseRotatorComponent.cs
Content.Shared/MouseRotator/SharedMouseRotatorSystem.cs

index 18d60d9a7b9d0515a2e9764b5770bf1992a63214..2ee6e43368fbfcbb9b9daf394819fc54b1acdd26 100644 (file)
@@ -57,7 +57,8 @@ public sealed class MouseRotatorSystem : SharedMouseRotatorSystem
                 rotation += 2 * Math.PI;
             RaisePredictiveEvent(new RequestMouseRotatorRotationEvent
             {
-                Rotation = rotation
+                Rotation = rotation,
+                User = GetNetEntity(player)
             });
 
             return;
@@ -77,7 +78,8 @@ public sealed class MouseRotatorSystem : SharedMouseRotatorSystem
 
         RaisePredictiveEvent(new RequestMouseRotatorRotationEvent
         {
-            Rotation = angle
+            Rotation = angle,
+            User = GetNetEntity(player)
         });
     }
 }
index 2844b3cb8b56d971f3ed8f71aac632507c4a4a46..1f399b31f9cb6da5679f93a571e3ea738006f39d 100644 (file)
@@ -48,4 +48,5 @@ public sealed partial class MouseRotatorComponent : Component
 public sealed class RequestMouseRotatorRotationEvent : EntityEventArgs
 {
     public Angle Rotation;
+    public NetEntity? User;
 }
index 9663b3363d1cba82859a30657abd4149c1dc1b8f..dadf59cea877f6a925364a2d18bca6ea97963ab4 100644 (file)
@@ -47,6 +47,11 @@ public abstract class SharedMouseRotatorSystem : EntitySystem
 
     private void OnRequestRotation(RequestMouseRotatorRotationEvent msg, EntitySessionEventArgs args)
     {
+        // Ignore the request if the requested entity is not the user's attached entity.
+        // This can happen when a player switches controlled entities while rotating.
+        if (args.SenderSession.AttachedEntity != GetEntity(msg.User))
+            return;
+
         if (args.SenderSession.AttachedEntity is not { } ent
             || !TryComp<MouseRotatorComponent>(ent, out var rotator))
         {