From b871b8e74cb379b1abb6798be93f0d44629d668d Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 30 Nov 2022 18:50:18 +0000 Subject: [PATCH] Validate lient is in-world before accepting join/invite request --- VpSharp/src/InviteRequest.cs | 8 +++++++- VpSharp/src/JoinRequest.cs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/VpSharp/src/InviteRequest.cs b/VpSharp/src/InviteRequest.cs index b61ce3b..da4d384 100644 --- a/VpSharp/src/InviteRequest.cs +++ b/VpSharp/src/InviteRequest.cs @@ -1,4 +1,5 @@ -using VpSharp.Entities; +using VpSharp.Entities; +using VpSharp.Exceptions; using VpSharp.Internal; namespace VpSharp; @@ -73,6 +74,11 @@ public sealed class InviteRequest : IEquatable /// public Task AcceptAsync(bool suppressTeleport = false) { + if (_client.CurrentAvatar is null) + { + throw new NotInWorldException(); + } + lock (_client.Lock) { _ = Native.vp_invite_accept(_client.NativeInstanceHandle, _requestId); diff --git a/VpSharp/src/JoinRequest.cs b/VpSharp/src/JoinRequest.cs index a3ff415..8590f69 100644 --- a/VpSharp/src/JoinRequest.cs +++ b/VpSharp/src/JoinRequest.cs @@ -1,4 +1,5 @@ using VpSharp.Entities; +using VpSharp.Exceptions; using VpSharp.Extensions; using VpSharp.Internal; @@ -67,7 +68,12 @@ public sealed class JoinRequest : IEquatable ThrowHelper.ThrowNotInWorldException(); } - location ??= _client.CurrentAvatar!.Location; + if (_client.CurrentAvatar is null) + { + throw new NotInWorldException(); + } + + location ??= _client.CurrentAvatar.Location; string worldName = location.Value.World.Name; (double x, double y, double z) = location.Value.Position; (double pitch, double yaw, double _) = location.Value.Rotation.ToEulerAngles();