1
0
mirror of https://github.com/oliverbooth/VpSharp synced 2024-11-10 02:35:42 +00:00

Validate lient is in-world before accepting join/invite request

This commit is contained in:
Oliver Booth 2022-11-30 18:50:18 +00:00
parent fd52361a5e
commit b871b8e74c
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
2 changed files with 14 additions and 2 deletions

View File

@ -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<InviteRequest>
/// </param>
public Task AcceptAsync(bool suppressTeleport = false)
{
if (_client.CurrentAvatar is null)
{
throw new NotInWorldException();
}
lock (_client.Lock)
{
_ = Native.vp_invite_accept(_client.NativeInstanceHandle, _requestId);

View File

@ -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<JoinRequest>
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();