1
0
mirror of https://github.com/oliverbooth/VpSharp synced 2024-11-10 03:55:41 +00:00

Use built-in nint keyword over IntPtr CLR type

This commit is contained in:
Oliver Booth 2022-11-29 18:40:26 +00:00
parent a91ac7d7fa
commit 36c0845fbe
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
22 changed files with 109 additions and 112 deletions

View File

@ -148,7 +148,7 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
lock (_client.Lock)
{
IntPtr handle = _client.NativeInstanceHandle;
nint handle = _client.NativeInstanceHandle;
vp_double_set(handle, FloatAttribute.ClickHitX, x);
vp_double_set(handle, FloatAttribute.ClickHitY, y);
@ -337,7 +337,7 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
await _client.EnterAsync(world);
}
IntPtr handle = _client.NativeInstanceHandle;
nint handle = _client.NativeInstanceHandle;
if (this == _client.CurrentAvatar)
{

View File

@ -53,7 +53,7 @@ public class VirtualParadiseModelObject : VirtualParadiseObject
lock (Client.Lock)
{
IntPtr handle = Client.NativeInstanceHandle;
nint handle = Client.NativeInstanceHandle;
_ = vp_int_set(handle, IntegerAttribute.ObjectId, Id);
builder.ApplyChanges();
@ -75,7 +75,7 @@ public class VirtualParadiseModelObject : VirtualParadiseObject
}
/// <inheritdoc />
protected internal override void ExtractFromInstance(IntPtr handle)
protected internal override void ExtractFromInstance(nint handle)
{
Action = vp_string(handle, StringAttribute.ObjectAction);
Description = vp_string(handle, StringAttribute.ObjectDescription);

View File

@ -105,7 +105,7 @@ public sealed class VirtualParadiseModelObjectBuilder : VirtualParadiseObjectBui
internal void ApplyChanges()
{
IntPtr handle = Client.NativeInstanceHandle;
nint handle = Client.NativeInstanceHandle;
if (Action is { } action)
{

View File

@ -224,10 +224,10 @@ public abstract class VirtualParadiseObject : IEquatable<VirtualParadiseObject>
Owner = virtualParadiseObject.Owner;
}
protected internal virtual void ExtractFromInstance(IntPtr handle)
protected internal virtual void ExtractFromInstance(nint handle)
{
var data = Span<byte>.Empty;
IntPtr dataPtr = vp_data(handle, DataAttribute.ObjectData, out int length);
nint dataPtr = vp_data(handle, DataAttribute.ObjectData, out int length);
if (length > 0)
{

View File

@ -182,7 +182,7 @@ public sealed class VirtualParadiseUser : IEquatable<VirtualParadiseUser>
}
// ReSharper disable InconsistentlySynchronizedField
IntPtr handle = _client.NativeInstanceHandle;
nint handle = _client.NativeInstanceHandle;
TaskCompletionSource<ReasonCode> taskCompletionSource;
lock (_client.Lock)

View File

@ -14,39 +14,39 @@ internal static class Native
public static extern int vp_init(int version = NativeSdkVersion);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr vp_create(ref NetConfig net_config);
public static extern nint vp_create(ref NetConfig net_config);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_destroy(IntPtr instance);
public static extern int vp_destroy(nint instance);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_connect_universe(IntPtr instance,
public static extern int vp_connect_universe(nint instance,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string host,
int port);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_login(IntPtr instance,
public static extern int vp_login(nint instance,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string username,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string password,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string botname);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_wait(IntPtr instance, int milliseconds);
public static extern int vp_wait(nint instance, int milliseconds);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_enter(IntPtr instance,
public static extern int vp_enter(nint instance,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string world_name);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_leave(IntPtr instance);
public static extern int vp_leave(nint instance);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_say(
IntPtr instance,
nint instance,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string message);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_console_message(IntPtr instance,
public static extern int vp_console_message(nint instance,
int session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string message,
@ -56,83 +56,83 @@ internal static class Native
byte blue);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_event_set(IntPtr instance,
public static extern int vp_event_set(nint instance,
[MarshalAs(UnmanagedType.I4)] NativeEvent event_name,
[MarshalAs(UnmanagedType.FunctionPtr)] NativeEventHandler @event);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_callback_set(IntPtr instance,
public static extern int vp_callback_set(nint instance,
[MarshalAs(UnmanagedType.I4)] NativeCallback callbackname,
[MarshalAs(UnmanagedType.FunctionPtr)] NativeCallbackHandler callback);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_state_change(IntPtr instance);
public static extern int vp_state_change(nint instance);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_int(IntPtr instance, [MarshalAs(UnmanagedType.I4)] IntegerAttribute attr);
public static extern int vp_int(nint instance, [MarshalAs(UnmanagedType.I4)] IntegerAttribute attr);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern float vp_float(IntPtr instance, [MarshalAs(UnmanagedType.I4)] FloatAttribute attr);
public static extern float vp_float(nint instance, [MarshalAs(UnmanagedType.I4)] FloatAttribute attr);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern double vp_double(IntPtr instance, [MarshalAs(UnmanagedType.I4)] FloatAttribute attr);
public static extern double vp_double(nint instance, [MarshalAs(UnmanagedType.I4)] FloatAttribute attr);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToManaged))]
public static extern string vp_string(IntPtr instance, [MarshalAs(UnmanagedType.I4)] StringAttribute attr);
public static extern string vp_string(nint instance, [MarshalAs(UnmanagedType.I4)] StringAttribute attr);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr vp_data(IntPtr instance, [MarshalAs(UnmanagedType.I4)] DataAttribute attr, out int length);
public static extern nint vp_data(nint instance, [MarshalAs(UnmanagedType.I4)] DataAttribute attr, out int length);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_int_set(IntPtr instance,
public static extern int vp_int_set(nint instance,
[MarshalAs(UnmanagedType.I4)] IntegerAttribute name,
int value);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_float_set(IntPtr instance,
public static extern int vp_float_set(nint instance,
[MarshalAs(UnmanagedType.I4)] FloatAttribute name,
float value);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_double_set(IntPtr instance,
public static extern int vp_double_set(nint instance,
[MarshalAs(UnmanagedType.I4)] FloatAttribute attr,
double value);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern void vp_string_set(IntPtr instance,
public static extern void vp_string_set(nint instance,
StringAttribute name,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string str);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_data_set(IntPtr instance,
public static extern int vp_data_set(nint instance,
[MarshalAs(UnmanagedType.I4)] DataAttribute name,
int length,
byte[] data);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_query_cell(IntPtr instance, int x, int z);
public static extern int vp_query_cell(nint instance, int x, int z);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_query_cell_revision(IntPtr instance, int x, int z, int revision);
public static extern int vp_query_cell_revision(nint instance, int x, int z, int revision);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_object_add(IntPtr instance);
public static extern int vp_object_add(nint instance);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_object_load(IntPtr instance);
public static extern int vp_object_load(nint instance);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_object_bump_begin(IntPtr instance, int object_id, int session_to);
public static extern int vp_object_bump_begin(nint instance, int object_id, int session_to);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_object_bump_end(IntPtr instance, int object_id, int session_to);
public static extern int vp_object_bump_end(nint instance, int object_id, int session_to);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_object_change(IntPtr instance);
public static extern int vp_object_change(nint instance);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_object_click(IntPtr instance,
public static extern int vp_object_click(nint instance,
int object_id,
int session_to,
float hit_x,
@ -140,40 +140,40 @@ internal static class Native
float hit_z);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_object_delete(IntPtr instance, int object_id);
public static extern int vp_object_delete(nint instance, int object_id);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_object_get(IntPtr instance, int object_id);
public static extern int vp_object_get(nint instance, int object_id);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_world_list(IntPtr instance, int time);
public static extern int vp_world_list(nint instance, int time);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_user_attributes_by_id(IntPtr instance, int user_id);
public static extern int vp_user_attributes_by_id(nint instance, int user_id);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_user_attributes_by_name(IntPtr instance,
public static extern int vp_user_attributes_by_name(nint instance,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string name);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_friends_get(IntPtr instance);
public static extern int vp_friends_get(nint instance);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_friend_add_by_name(IntPtr instance,
public static extern int vp_friend_add_by_name(nint instance,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string name);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_friend_delete(IntPtr instance, int friend_user_id);
public static extern int vp_friend_delete(nint instance, int friend_user_id);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_terrain_query(IntPtr instance, int tile_x, int tile_z, int[,] revision);
public static extern int vp_terrain_query(nint instance, int tile_x, int tile_z, int[,] revision);
// [DllImport(VpSdkLibrary, CallingConvention=CallingConvention.Cdecl)] public static extern int vp_terrain_node_set(IntPtr instance, int tile_x, int tile_z, int node_x, int node_z, struct vp_terrain_cell_t* cells);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_avatar_click(IntPtr instance, int avatar_session);
public static extern int vp_avatar_click(nint instance, int avatar_session);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_teleport_avatar(IntPtr instance,
public static extern int vp_teleport_avatar(nint instance,
int target_session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string world,
float x,
@ -183,16 +183,16 @@ internal static class Native
float pitch);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_url_send(IntPtr instance,
public static extern int vp_url_send(nint instance,
int session_id,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string url,
[MarshalAs(UnmanagedType.I4)] UriTarget url_target);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_join(IntPtr instance, int user_id);
public static extern int vp_join(nint instance, int user_id);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_join_accept(IntPtr instance,
public static extern int vp_join_accept(nint instance,
int requestId,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string world,
double x,
@ -202,28 +202,28 @@ internal static class Native
float pitch);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_join_decline(IntPtr instance, int requestId);
public static extern int vp_join_decline(nint instance, int requestId);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_world_permission_user_set(IntPtr instance,
public static extern int vp_world_permission_user_set(nint instance,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string permission,
int user_id,
int enable);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_world_permission_session_set(IntPtr instance,
public static extern int vp_world_permission_session_set(nint instance,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string permission,
int session_id,
int enable);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_world_setting_set(IntPtr instance,
public static extern int vp_world_setting_set(nint instance,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string setting,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string value,
int session_to);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_invite(IntPtr instance,
public static extern int vp_invite(nint instance,
int user_id,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string world,
double x,
@ -233,11 +233,11 @@ internal static class Native
float pitch);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_invite_accept(IntPtr instance, int invitation_id);
public static extern int vp_invite_accept(nint instance, int invitation_id);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_invite_decline(IntPtr instance, int invitation_id);
public static extern int vp_invite_decline(nint instance, int invitation_id);
[DllImport(VpSdkLibrary, CallingConvention = CallingConvention.Cdecl)]
public static extern int vp_net_notify(IntPtr vpConnection, int type, int status);
public static extern int vp_net_notify(nint vpConnection, int type, int status);
}

View File

@ -3,4 +3,4 @@
namespace VpSharp.Internal;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void NativeCallbackHandler(IntPtr sender, [MarshalAs(UnmanagedType.I4)] ReasonCode reason, int reference);
internal delegate void NativeCallbackHandler(nint sender, [MarshalAs(UnmanagedType.I4)] ReasonCode reason, int reference);

View File

@ -3,4 +3,4 @@
namespace VpSharp.Internal;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void NativeEventHandler(IntPtr sender);
internal delegate void NativeEventHandler(nint sender);

View File

@ -12,5 +12,5 @@ internal struct NetConfig
public SocketReceiveFunction Receive;
public SocketTimeoutFunction Timeout;
public SocketWaitFunction Wait;
public IntPtr Context;
public nint Context;
}

View File

@ -3,7 +3,4 @@
namespace VpSharp.Internal;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int SocketConnectFunction(
IntPtr socket,
IntPtr host, //[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringToNative))] string host,
ushort port);
internal delegate int SocketConnectFunction(nint socket, nint host, ushort port);

View File

@ -3,4 +3,4 @@
namespace VpSharp.Internal;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate IntPtr SocketCreateFunction(IntPtr connection, IntPtr context);
internal delegate nint SocketCreateFunction(nint connection, nint context);

View File

@ -3,4 +3,4 @@
namespace VpSharp.Internal;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void SocketDestroyFunction(IntPtr socket);
internal delegate void SocketDestroyFunction(nint socket);

View File

@ -3,4 +3,4 @@
namespace VpSharp.Internal;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int SocketReceiveFunction(IntPtr socket, IntPtr data, uint length);
internal delegate int SocketReceiveFunction(nint socket, nint data, uint length);

View File

@ -3,4 +3,4 @@
namespace VpSharp.Internal;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int SocketSendFunction(IntPtr socket, IntPtr data, uint length);
internal delegate int SocketSendFunction(nint socket, nint data, uint length);

View File

@ -3,4 +3,4 @@
namespace VpSharp.Internal;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int SocketTimeoutFunction(IntPtr socket, int seconds);
internal delegate int SocketTimeoutFunction(nint socket, int seconds);

View File

@ -3,4 +3,4 @@
namespace VpSharp.Internal;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int SocketWaitFunction(IntPtr context, int duration);
internal delegate int SocketWaitFunction(nint context, int duration);

View File

@ -16,7 +16,7 @@ internal sealed class Utf8StringToNative : ICustomMarshaler
{
}
public void CleanUpNativeData(IntPtr pNativeData)
public void CleanUpNativeData(nint pNativeData)
{
Marshal.FreeHGlobal(pNativeData);
}
@ -26,16 +26,16 @@ internal sealed class Utf8StringToNative : ICustomMarshaler
return -1;
}
public IntPtr MarshalManagedToNative(object managedObj)
public nint MarshalManagedToNative(object managedObj)
{
byte[] utf8Data = Encoding.UTF8.GetBytes((string)managedObj);
IntPtr buffer = Marshal.AllocHGlobal(utf8Data.Length + 1);
nint buffer = Marshal.AllocHGlobal(utf8Data.Length + 1);
Marshal.Copy(utf8Data, 0, buffer, utf8Data.Length);
Marshal.WriteByte(buffer, utf8Data.Length, 0);
return buffer;
}
public object MarshalNativeToManaged(IntPtr pNativeData)
public object MarshalNativeToManaged(nint pNativeData)
{
throw new NotImplementedException();
}

View File

@ -38,7 +38,7 @@ public sealed partial class VirtualParadiseClient
});
}
private VirtualParadiseAvatar ExtractAvatar(IntPtr sender)
private VirtualParadiseAvatar ExtractAvatar(nint sender)
{
lock (Lock)
{

View File

@ -11,7 +11,7 @@ public sealed partial class VirtualParadiseClient
internal object Lock { get; } = new();
internal IntPtr NativeInstanceHandle { get; private set; }
internal nint NativeInstanceHandle { get; private set; }
private void Initialize()
{

View File

@ -38,7 +38,7 @@ public sealed partial class VirtualParadiseClient
vp_callback_set(NativeInstanceHandle, nativeCallback, handler);
}
private async void OnObjectGetNativeCallback(IntPtr sender, ReasonCode reason, int reference)
private async void OnObjectGetNativeCallback(nint sender, ReasonCode reason, int reference)
{
if (!_objectCompletionSources.TryGetValue(reference, out TaskCompletionSource<(ReasonCode, VirtualParadiseObject)>? taskCompletionSource))
{
@ -49,22 +49,22 @@ public sealed partial class VirtualParadiseClient
taskCompletionSource.SetResult((reason, virtualParadiseObject));
}
private void OnLoginNativeCallback(IntPtr sender, ReasonCode reason, int reference)
private void OnLoginNativeCallback(nint sender, ReasonCode reason, int reference)
{
_loginCompletionSource?.SetResult(reason);
}
private void OnEnterNativeCallback(IntPtr sender, ReasonCode reason, int reference)
private void OnEnterNativeCallback(nint sender, ReasonCode reason, int reference)
{
_enterCompletionSource?.SetResult(reason);
}
private void OnConnectUniverseNativeCallback(IntPtr sender, ReasonCode reason, int reference)
private void OnConnectUniverseNativeCallback(nint sender, ReasonCode reason, int reference)
{
_connectCompletionSource?.SetResult(reason);
}
private void OnWorldListNativeCallback(IntPtr sender, ReasonCode reason, int reference)
private void OnWorldListNativeCallback(nint sender, ReasonCode reason, int reference)
{
_worldListChannel?.Writer.Complete();
}

View File

@ -1,4 +1,4 @@
using System.Collections.Concurrent;
using System.Collections.Concurrent;
using System.Drawing;
using System.Numerics;
using System.Threading.Channels;
@ -50,7 +50,7 @@ public sealed partial class VirtualParadiseClient
vp_event_set(NativeInstanceHandle, nativeEvent, handler);
}
private void OnChatNativeEvent(IntPtr sender)
private void OnChatNativeEvent(nint sender)
{
VirtualParadiseMessage message;
@ -87,7 +87,7 @@ public sealed partial class VirtualParadiseClient
}
}
private async void OnAvatarAddNativeEvent(IntPtr sender)
private async void OnAvatarAddNativeEvent(nint sender)
{
VirtualParadiseAvatar avatar = ExtractAvatar(sender);
avatar = AddOrUpdateAvatar(avatar);
@ -97,7 +97,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(AvatarJoined, args);
}
private void OnAvatarChangeNativeEvent(IntPtr sender)
private void OnAvatarChangeNativeEvent(nint sender)
{
int session;
int type;
@ -140,7 +140,7 @@ public sealed partial class VirtualParadiseClient
}
}
private void OnAvatarDeleteNativeEvent(IntPtr sender)
private void OnAvatarDeleteNativeEvent(nint sender)
{
int session;
@ -156,7 +156,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(AvatarLeft, args);
}
private async void OnObjectNativeEvent(IntPtr sender)
private async void OnObjectNativeEvent(nint sender)
{
int session;
@ -185,7 +185,7 @@ public sealed partial class VirtualParadiseClient
}
}
private async void OnObjectChangeNativeEvent(IntPtr sender)
private async void OnObjectChangeNativeEvent(nint sender)
{
int objectId;
int session;
@ -217,7 +217,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(ObjectChanged, args);
}
private async void OnObjectDeleteNativeEvent(IntPtr sender)
private async void OnObjectDeleteNativeEvent(nint sender)
{
int objectId;
int session;
@ -229,7 +229,7 @@ public sealed partial class VirtualParadiseClient
}
VirtualParadiseAvatar? avatar = GetAvatar(session);
VirtualParadiseObject virtualParadiseObject;
VirtualParadiseObject? virtualParadiseObject;
try
{
@ -240,13 +240,13 @@ public sealed partial class VirtualParadiseClient
virtualParadiseObject = null;
}
_objects.TryRemove(objectId, out VirtualParadiseObject _);
_objects.TryRemove(objectId, out VirtualParadiseObject? _);
var args = new ObjectDeletedEventArgs(avatar, objectId, virtualParadiseObject);
var args = new ObjectDeletedEventArgs(avatar!, objectId, virtualParadiseObject!);
RaiseEvent(ObjectDeleted, args);
}
private async void OnObjectClickNativeEvent(IntPtr sender)
private async void OnObjectClickNativeEvent(nint sender)
{
Vector3d clickPoint;
int objectId;
@ -269,7 +269,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(ObjectClicked, args);
}
private async void OnWorldListNativeEvent(IntPtr sender)
private async void OnWorldListNativeEvent(nint sender)
{
VirtualParadiseWorld world;
@ -292,7 +292,7 @@ public sealed partial class VirtualParadiseClient
}
}
private void OnWorldSettingNativeEvent(IntPtr sender)
private void OnWorldSettingNativeEvent(nint sender)
{
lock (Lock)
{
@ -302,12 +302,12 @@ public sealed partial class VirtualParadiseClient
}
}
private void OnWorldSettingsChangedNativeEvent(IntPtr sender)
private void OnWorldSettingsChangedNativeEvent(nint sender)
{
_worldSettingsCompletionSource.SetResult();
}
private async void OnFriendNativeEvent(IntPtr sender)
private async void OnFriendNativeEvent(nint sender)
{
int userId;
@ -320,7 +320,7 @@ public sealed partial class VirtualParadiseClient
_friends.AddOrUpdate(userId, user, (_, _) => user);
}
private void OnWorldDisconnectNativeEvent(IntPtr sender)
private void OnWorldDisconnectNativeEvent(nint sender)
{
DisconnectReason reason;
lock (Lock)
@ -332,7 +332,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(WorldServerDisconnected, args);
}
private void OnUniverseDisconnectNativeEvent(IntPtr sender)
private void OnUniverseDisconnectNativeEvent(nint sender)
{
DisconnectReason reason;
lock (Lock)
@ -344,7 +344,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(UniverseServerDisconnected, args);
}
private void OnUserAttributesNativeEvent(IntPtr sender)
private void OnUserAttributesNativeEvent(nint sender)
{
int userId;
VirtualParadiseUser user;
@ -375,7 +375,7 @@ public sealed partial class VirtualParadiseClient
}
}
private void OnQueryCellEndNativeEvent(IntPtr sender)
private void OnQueryCellEndNativeEvent(nint sender)
{
Cell cell;
@ -393,7 +393,7 @@ public sealed partial class VirtualParadiseClient
}
}
private void OnAvatarClickNativeEvent(IntPtr sender)
private void OnAvatarClickNativeEvent(nint sender)
{
int session, clickedSession;
Vector3d clickPoint;
@ -415,7 +415,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(AvatarClicked, args);
}
private async void OnTeleportNativeEvent(IntPtr sender)
private async void OnTeleportNativeEvent(nint sender)
{
int session;
string worldName;
@ -446,7 +446,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(Teleported, args);
}
private async void OnObjectBumpEndNativeEvent(IntPtr sender)
private async void OnObjectBumpEndNativeEvent(nint sender)
{
int session;
int objectId;
@ -464,7 +464,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(ObjectBump, args);
}
private void OnUrlNativeEvent(IntPtr sender)
private void OnUrlNativeEvent(nint sender)
{
int session;
string url;
@ -488,7 +488,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(UriReceived, args);
}
private async void OnObjectBumpBeginNativeEvent(IntPtr sender)
private async void OnObjectBumpBeginNativeEvent(nint sender)
{
int session;
int objectId;
@ -506,7 +506,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(ObjectBump, args);
}
private async void OnJoinNativeEvent(IntPtr sender)
private async void OnJoinNativeEvent(nint sender)
{
int requestId;
int userId;
@ -525,7 +525,7 @@ public sealed partial class VirtualParadiseClient
RaiseEvent(JoinRequestReceived, args);
}
private async void OnInviteNativeEvent(IntPtr sender)
private async void OnInviteNativeEvent(nint sender)
{
Vector3d position;
Quaternion rotation;

View File

@ -146,7 +146,7 @@ public sealed partial class VirtualParadiseClient
});
}
private async Task<VirtualParadiseObject> ExtractObjectAsync(IntPtr sender)
private async Task<VirtualParadiseObject> ExtractObjectAsync(nint sender)
{
var type = (ObjectType) vp_int(sender, IntegerAttribute.ObjectType);
int id = vp_int(sender, IntegerAttribute.ObjectId);