Skip to content

Commit

Permalink
update latest sdk changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Aug 8, 2024
1 parent dd3a466 commit f743610
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion api/AltV.Net.CApi/Libraries/ClientLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3597,7 +3597,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
{
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 8028889173226987673UL) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 11629663074568386340UL) Outdated = true;
Audio_AddOutput = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Audio_AddOutputDelegate>(funcTable, 9914412815391408844UL, Audio_AddOutputFallback);
Audio_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<Audio_GetBaseObjectDelegate>(funcTable, 6330360502401226894UL, Audio_GetBaseObjectFallback);
Audio_GetCurrentTime = (delegate* unmanaged[Cdecl]<nint, double>) GetUnmanagedPtr<Audio_GetCurrentTimeDelegate>(funcTable, 2944324482134975819UL, Audio_GetCurrentTimeFallback);
Expand Down
12 changes: 6 additions & 6 deletions api/AltV.Net.CApi/Libraries/ServerLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public unsafe interface IServerLibrary
public delegate* unmanaged[Cdecl]<nint, nint, void> Core_DestroyColShape { get; }
public delegate* unmanaged[Cdecl]<nint, nint, void> Core_DestroyVehicle { get; }
public delegate* unmanaged[Cdecl]<nint, nint, void> Core_DestroyVoiceChannel { get; }
public delegate* unmanaged[Cdecl]<nint, Vector3, int, int, int, ulong, nint*, byte[], ulong, void> Core_GetClosestEntities { get; }
public delegate* unmanaged[Cdecl]<nint, Vector3, int, int, int, ulong, byte, nint*, byte[], ulong, void> Core_GetClosestEntities { get; }
public delegate* unmanaged[Cdecl]<nint, Vector3, int, int, int, ulong, ulong> Core_GetClosestEntitiesCount { get; }
public delegate* unmanaged[Cdecl]<nint, uint> Core_GetColShapeTickRate { get; }
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetConnectionInfos { get; }
Expand Down Expand Up @@ -544,7 +544,7 @@ public unsafe class ServerLibrary : IServerLibrary
public delegate* unmanaged[Cdecl]<nint, nint, void> Core_DestroyColShape { get; }
public delegate* unmanaged[Cdecl]<nint, nint, void> Core_DestroyVehicle { get; }
public delegate* unmanaged[Cdecl]<nint, nint, void> Core_DestroyVoiceChannel { get; }
public delegate* unmanaged[Cdecl]<nint, Vector3, int, int, int, ulong, nint*, byte[], ulong, void> Core_GetClosestEntities { get; }
public delegate* unmanaged[Cdecl]<nint, Vector3, int, int, int, ulong, byte, nint*, byte[], ulong, void> Core_GetClosestEntities { get; }
public delegate* unmanaged[Cdecl]<nint, Vector3, int, int, int, ulong, ulong> Core_GetClosestEntitiesCount { get; }
public delegate* unmanaged[Cdecl]<nint, uint> Core_GetColShapeTickRate { get; }
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetConnectionInfos { get; }
Expand Down Expand Up @@ -1072,8 +1072,8 @@ public unsafe class ServerLibrary : IServerLibrary
private static void Core_DestroyVehicleFallback(nint _core, nint _baseObject) => throw new Exceptions.OutdatedSdkException("Core_DestroyVehicle", "Core_DestroyVehicle SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_DestroyVoiceChannelDelegate(nint _core, nint _baseObject);
private static void Core_DestroyVoiceChannelFallback(nint _core, nint _baseObject) => throw new Exceptions.OutdatedSdkException("Core_DestroyVoiceChannel", "Core_DestroyVoiceChannel SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetClosestEntitiesDelegate(nint _core, Vector3 _position, int _range, int _dimension, int _limit, ulong _allowedTypes, nint* _entities, byte[] types, ulong _size);
private static void Core_GetClosestEntitiesFallback(nint _core, Vector3 _position, int _range, int _dimension, int _limit, ulong _allowedTypes, nint* _entities, byte[] types, ulong _size) => throw new Exceptions.OutdatedSdkException("Core_GetClosestEntities", "Core_GetClosestEntities SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetClosestEntitiesDelegate(nint _core, Vector3 _position, int _range, int _dimension, int _limit, ulong _allowedTypes, byte _order, nint* _entities, byte[] types, ulong _size);
private static void Core_GetClosestEntitiesFallback(nint _core, Vector3 _position, int _range, int _dimension, int _limit, ulong _allowedTypes, byte _order, nint* _entities, byte[] types, ulong _size) => throw new Exceptions.OutdatedSdkException("Core_GetClosestEntities", "Core_GetClosestEntities SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Core_GetClosestEntitiesCountDelegate(nint _core, Vector3 _position, int _range, int _dimension, int _limit, ulong _allowedTypes);
private static ulong Core_GetClosestEntitiesCountFallback(nint _core, Vector3 _position, int _range, int _dimension, int _limit, ulong _allowedTypes) => throw new Exceptions.OutdatedSdkException("Core_GetClosestEntitiesCount", "Core_GetClosestEntitiesCount SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint Core_GetColShapeTickRateDelegate(nint _core);
Expand Down Expand Up @@ -1917,7 +1917,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
{
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 8028889173226987673UL) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 11629663074568386340UL) Outdated = true;
BaseObject_DeleteSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<BaseObject_DeleteSyncedMetaDataDelegate>(funcTable, 8228424877092269355UL, BaseObject_DeleteSyncedMetaDataFallback);
BaseObject_SetMultipleSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void>) GetUnmanagedPtr<BaseObject_SetMultipleSyncedMetaDataDelegate>(funcTable, 1390762125822890831UL, BaseObject_SetMultipleSyncedMetaDataFallback);
BaseObject_SetSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, nint, void>) GetUnmanagedPtr<BaseObject_SetSyncedMetaDataDelegate>(funcTable, 8002999088966424231UL, BaseObject_SetSyncedMetaDataFallback);
Expand Down Expand Up @@ -1973,7 +1973,7 @@ public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
Core_DestroyColShape = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Core_DestroyColShapeDelegate>(funcTable, 16312284234900575747UL, Core_DestroyColShapeFallback);
Core_DestroyVehicle = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Core_DestroyVehicleDelegate>(funcTable, 14452794280175707515UL, Core_DestroyVehicleFallback);
Core_DestroyVoiceChannel = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Core_DestroyVoiceChannelDelegate>(funcTable, 10333270135403224879UL, Core_DestroyVoiceChannelFallback);
Core_GetClosestEntities = (delegate* unmanaged[Cdecl]<nint, Vector3, int, int, int, ulong, nint*, byte[], ulong, void>) GetUnmanagedPtr<Core_GetClosestEntitiesDelegate>(funcTable, 12057843286905322939UL, Core_GetClosestEntitiesFallback);
Core_GetClosestEntities = (delegate* unmanaged[Cdecl]<nint, Vector3, int, int, int, ulong, byte, nint*, byte[], ulong, void>) GetUnmanagedPtr<Core_GetClosestEntitiesDelegate>(funcTable, 3102729611893259067UL, Core_GetClosestEntitiesFallback);
Core_GetClosestEntitiesCount = (delegate* unmanaged[Cdecl]<nint, Vector3, int, int, int, ulong, ulong>) GetUnmanagedPtr<Core_GetClosestEntitiesCountDelegate>(funcTable, 419502286495548608UL, Core_GetClosestEntitiesCountFallback);
Core_GetColShapeTickRate = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<Core_GetColShapeTickRateDelegate>(funcTable, 12193205314801108926UL, Core_GetColShapeTickRateFallback);
Core_GetConnectionInfos = (delegate* unmanaged[Cdecl]<nint, ulong*, nint>) GetUnmanagedPtr<Core_GetConnectionInfosDelegate>(funcTable, 13972691773502904173UL, Core_GetConnectionInfosFallback);
Expand Down
2 changes: 1 addition & 1 deletion api/AltV.Net.CApi/Libraries/SharedLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
public SharedLibrary(Dictionary<ulong, IntPtr> funcTable)
{
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 8028889173226987673UL) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 11629663074568386340UL) Outdated = true;
Audio_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<Audio_GetIDDelegate>(funcTable, 4464042055475980737UL, Audio_GetIDFallback);
AudioAttachedOutput_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioAttachedOutput_GetIDDelegate>(funcTable, 17725794901805112189UL, AudioAttachedOutput_GetIDFallback);
AudioFilter_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioFilter_GetIDDelegate>(funcTable, 8824535635529306325UL, AudioFilter_GetIDFallback);
Expand Down
4 changes: 1 addition & 3 deletions api/AltV.Net.Mock/MockCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -921,9 +921,7 @@ public IEnumerable<string> GetRegisteredServerEvents()
{
throw new NotImplementedException();
}

public IBaseObject[] GetClosestEntities(Position position, int range, int dimension, int limit,
EntityType allowedTypes)
public IBaseObject[] GetClosestEntities(Position position, int range, int dimension, int limit, EntityType allowedTypes, Order order = Order.Default)
{
throw new NotImplementedException();
}
Expand Down
9 changes: 9 additions & 0 deletions api/AltV.Net/Alt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ public static Task ForEachColShapes(IAsyncBaseObjectCallback<IColShape> baseObje
public static IReadOnlyCollection<IMetric> GetAllMetrics() => Core.GetAllMetrics();
public static VoiceConnectionState GetVoiceConnectionState() => Core.GetVoiceConnectionState();

public static void SetWorldProfiler(bool state) => Core.SetWorldProfiler(state);

public static IBaseObject[] GetClosestEntities(Position position, int range, int dimension, int limit, EntityType allowedTypes, Order order = Order.Default) =>
Core.GetClosestEntities(position, range, dimension, limit, allowedTypes, order);

public static IBaseObject[] GetEntitiesInDimension(int dimension, EntityType allowedTypes) => Core.GetEntitiesInDimension(dimension, allowedTypes);

public static IBaseObject[] GetEntitiesInRange(Position position, int range, int dimension, EntityType allowedTypes) => Core.GetEntitiesInRange(position, range, dimension, allowedTypes);

public static int NetTime => Core.NetTime;

public static void AddClientConfigKey(string key) => Core.AddClientConfigKey(key);
Expand Down
4 changes: 2 additions & 2 deletions api/AltV.Net/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,15 +1211,15 @@ public void SetWorldProfiler(bool state)
}

public IBaseObject[] GetClosestEntities(Position position, int range, int dimension, int limit,
EntityType allowedTypes)
EntityType allowedTypes, Order order = Order.Default)
{
unsafe
{
CheckIfCallIsValid();
var entitiesCount = Library.Server.Core_GetClosestEntitiesCount(NativePointer, position, range, dimension, limit, (ulong)allowedTypes);
var pointers = IntPtr.Zero;
var types = new byte[entitiesCount];
Library.Server.Core_GetClosestEntities(NativePointer,position, range, dimension, limit, (ulong)allowedTypes, &pointers, types, entitiesCount);
Library.Server.Core_GetClosestEntities(NativePointer,position, range, dimension, limit, (ulong)allowedTypes, (byte)order, &pointers, types, entitiesCount);

var entityPtrArray = new IntPtr[entitiesCount];
Marshal.Copy(pointers, entityPtrArray, 0, (int) entitiesCount);
Expand Down
8 changes: 8 additions & 0 deletions api/AltV.Net/Data/Order.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace AltV.Net.Data;

public enum Order
{
Default = 0,
Asc = 1,
Desc = 2
}
2 changes: 1 addition & 1 deletion api/AltV.Net/ICore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public interface ICore : ISharedCore
IEnumerable<string> GetRegisteredServerEvents();

IBaseObject[] GetClosestEntities(Position position, int range, int dimension, int limit,
EntityType allowedTypes);
EntityType allowedTypes, Order order = Order.Default);
IBaseObject[] GetEntitiesInDimension(int dimension, EntityType allowedTypes);
IBaseObject[] GetEntitiesInRange(Position position, int range, int dimension, EntityType allowedTypes);
IBaseObject GetBaseObject(BaseObjectType type, uint id);
Expand Down
2 changes: 1 addition & 1 deletion runtime

0 comments on commit f743610

Please sign in to comment.