Skip to content

Commit 5ef3ca8

Browse files
committed
this should fix position sync not working for spectators and 079
1 parent 11aec80 commit 5ef3ca8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

LabExtended/Patches/Functions/Players/PlayerPositionSyncPatch.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ private static bool Prefix()
6868
{
6969
var player = ExPlayer.Players[x];
7070

71-
if (player?.ReferenceHub == null)
71+
if (player?.ReferenceHub == null
72+
|| player.InstanceMode == CentralAuth.ClientInstanceMode.Unverified
73+
|| player.ReferenceHub.isLocalPlayer)
7274
continue;
7375

7476
if (!player.Toggles.ShouldReceivePositions)
@@ -89,8 +91,6 @@ private static void Sync(ExPlayer receiver)
8991
ushort count = 0;
9092

9193
var customVisibilityRole = receiver.ReferenceHub.roleManager.CurrentRole as ICustomVisibilityRole;
92-
var customVisibilityRoleNull = customVisibilityRole == null;
93-
var customVisibilityRoleController = !customVisibilityRoleNull ? customVisibilityRole!.VisibilityController : null;
9494

9595
for (var x = 0; x < ExPlayer.AllCount; x++)
9696
{
@@ -110,7 +110,7 @@ private static void Sync(ExPlayer receiver)
110110
if (fpcRole == null)
111111
continue;
112112

113-
var isInvisible = customVisibilityRoleNull || !customVisibilityRoleController!.ValidateVisibility(player.ReferenceHub);
113+
var isInvisible = customVisibilityRole?.VisibilityController != null && !customVisibilityRole.VisibilityController.ValidateVisibility(player.ReferenceHub);
114114

115115
if (!isInvisible)
116116
{
@@ -187,7 +187,7 @@ private static FpcSyncData GetNewSyncData(ExPlayer receiver, ExPlayer target, Fi
187187

188188
var fpcSyncData = isInvisible
189189
? default
190-
: new FpcSyncData(prevSyncData, fpmm.SyncMovementState, fpmm.IsGrounded, fpmm.RelativePosition, fpmm.MouseLook);
190+
: new FpcSyncData(prevSyncData, fpmm.SyncMovementState, fpmm.IsGrounded, position, fpmm.MouseLook);
191191

192192
FpcServerPositionDistributor.PreviouslySent[receiver.ReferenceHub.netId][target.ReferenceHub.netId] = fpcSyncData;
193193
return fpcSyncData;

0 commit comments

Comments
 (0)