Skip to content

Commit c2a4cf9

Browse files
committed
feat(client): add pool functions
1 parent 5fd0bf7 commit c2a4cf9

File tree

7 files changed

+76
-7
lines changed

7 files changed

+76
-7
lines changed

api/AltV.Net.CApi/Libraries/ClientLibrary.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ public unsafe interface IClientLibrary
160160
public delegate* unmanaged[Cdecl]<nint, int, ushort, Vector3*, void> Core_GetPedBonePos { get; }
161161
public delegate* unmanaged[Cdecl]<nint, byte, byte> Core_GetPermissionState { get; }
162162
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetPing { get; }
163+
public delegate* unmanaged[Cdecl]<nint, nint, uint> Core_GetPoolCount { get; }
164+
public delegate* unmanaged[Cdecl]<nint, nint, nint*, uint*, void> Core_GetPoolEntities { get; }
165+
public delegate* unmanaged[Cdecl]<nint, nint, uint> Core_GetPoolSize { get; }
163166
public delegate* unmanaged[Cdecl]<nint, Vector2*, void> Core_GetScreenResolution { get; }
164167
public delegate* unmanaged[Cdecl]<nint, int*, nint> Core_GetServerIp { get; }
165168
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetServerPort { get; }
@@ -886,7 +889,7 @@ public unsafe interface IClientLibrary
886889

887890
public unsafe class ClientLibrary : IClientLibrary
888891
{
889-
public readonly uint Methods = 1752;
892+
public readonly uint Methods = 1755;
890893
public delegate* unmanaged[Cdecl]<nint, nint, void> Audio_AddOutput { get; }
891894
public delegate* unmanaged[Cdecl]<nint, nint> Audio_GetBaseObject { get; }
892895
public delegate* unmanaged[Cdecl]<nint, double> Audio_GetCurrentTime { get; }
@@ -1037,6 +1040,9 @@ public unsafe class ClientLibrary : IClientLibrary
10371040
public delegate* unmanaged[Cdecl]<nint, int, ushort, Vector3*, void> Core_GetPedBonePos { get; }
10381041
public delegate* unmanaged[Cdecl]<nint, byte, byte> Core_GetPermissionState { get; }
10391042
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetPing { get; }
1043+
public delegate* unmanaged[Cdecl]<nint, nint, uint> Core_GetPoolCount { get; }
1044+
public delegate* unmanaged[Cdecl]<nint, nint, nint*, uint*, void> Core_GetPoolEntities { get; }
1045+
public delegate* unmanaged[Cdecl]<nint, nint, uint> Core_GetPoolSize { get; }
10401046
public delegate* unmanaged[Cdecl]<nint, Vector2*, void> Core_GetScreenResolution { get; }
10411047
public delegate* unmanaged[Cdecl]<nint, int*, nint> Core_GetServerIp { get; }
10421048
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetServerPort { get; }
@@ -2059,6 +2065,12 @@ public unsafe class ClientLibrary : IClientLibrary
20592065
private static byte Core_GetPermissionStateFallback(nint _core, byte _permission) => throw new Exceptions.OutdatedSdkException("Core_GetPermissionState", "Core_GetPermissionState SDK method is outdated. Please update your module nuget");
20602066
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ushort Core_GetPingDelegate(nint _core);
20612067
private static ushort Core_GetPingFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetPing", "Core_GetPing SDK method is outdated. Please update your module nuget");
2068+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint Core_GetPoolCountDelegate(nint _core, nint _pool);
2069+
private static uint Core_GetPoolCountFallback(nint _core, nint _pool) => throw new Exceptions.OutdatedSdkException("Core_GetPoolCount", "Core_GetPoolCount SDK method is outdated. Please update your module nuget");
2070+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetPoolEntitiesDelegate(nint _core, nint _pool, nint* _poolEntities, uint* _size);
2071+
private static void Core_GetPoolEntitiesFallback(nint _core, nint _pool, nint* _poolEntities, uint* _size) => throw new Exceptions.OutdatedSdkException("Core_GetPoolEntities", "Core_GetPoolEntities SDK method is outdated. Please update your module nuget");
2072+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint Core_GetPoolSizeDelegate(nint _core, nint _pool);
2073+
private static uint Core_GetPoolSizeFallback(nint _core, nint _pool) => throw new Exceptions.OutdatedSdkException("Core_GetPoolSize", "Core_GetPoolSize SDK method is outdated. Please update your module nuget");
20622074
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetScreenResolutionDelegate(nint _core, Vector2* _out);
20632075
private static void Core_GetScreenResolutionFallback(nint _core, Vector2* _out) => throw new Exceptions.OutdatedSdkException("Core_GetScreenResolution", "Core_GetScreenResolution SDK method is outdated. Please update your module nuget");
20642076
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetServerIpDelegate(nint _core, int* _size);
@@ -3512,7 +3524,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
35123524
public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
35133525
{
35143526
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
3515-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 15809758987028017478UL) Outdated = true;
3527+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 554522947139118248UL) Outdated = true;
35163528
Audio_AddOutput = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Audio_AddOutputDelegate>(funcTable, 9914412815391408844UL, Audio_AddOutputFallback);
35173529
Audio_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<Audio_GetBaseObjectDelegate>(funcTable, 6330360502401226894UL, Audio_GetBaseObjectFallback);
35183530
Audio_GetCurrentTime = (delegate* unmanaged[Cdecl]<nint, double>) GetUnmanagedPtr<Audio_GetCurrentTimeDelegate>(funcTable, 2944324482134975819UL, Audio_GetCurrentTimeFallback);
@@ -3663,6 +3675,9 @@ public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
36633675
Core_GetPedBonePos = (delegate* unmanaged[Cdecl]<nint, int, ushort, Vector3*, void>) GetUnmanagedPtr<Core_GetPedBonePosDelegate>(funcTable, 9678094278922411472UL, Core_GetPedBonePosFallback);
36643676
Core_GetPermissionState = (delegate* unmanaged[Cdecl]<nint, byte, byte>) GetUnmanagedPtr<Core_GetPermissionStateDelegate>(funcTable, 6070013237365852957UL, Core_GetPermissionStateFallback);
36653677
Core_GetPing = (delegate* unmanaged[Cdecl]<nint, ushort>) GetUnmanagedPtr<Core_GetPingDelegate>(funcTable, 17183361268059997356UL, Core_GetPingFallback);
3678+
Core_GetPoolCount = (delegate* unmanaged[Cdecl]<nint, nint, uint>) GetUnmanagedPtr<Core_GetPoolCountDelegate>(funcTable, 10058355141969516360UL, Core_GetPoolCountFallback);
3679+
Core_GetPoolEntities = (delegate* unmanaged[Cdecl]<nint, nint, nint*, uint*, void>) GetUnmanagedPtr<Core_GetPoolEntitiesDelegate>(funcTable, 5989408698388544472UL, Core_GetPoolEntitiesFallback);
3680+
Core_GetPoolSize = (delegate* unmanaged[Cdecl]<nint, nint, uint>) GetUnmanagedPtr<Core_GetPoolSizeDelegate>(funcTable, 3048778071876483320UL, Core_GetPoolSizeFallback);
36663681
Core_GetScreenResolution = (delegate* unmanaged[Cdecl]<nint, Vector2*, void>) GetUnmanagedPtr<Core_GetScreenResolutionDelegate>(funcTable, 16078537130538515891UL, Core_GetScreenResolutionFallback);
36673682
Core_GetServerIp = (delegate* unmanaged[Cdecl]<nint, int*, nint>) GetUnmanagedPtr<Core_GetServerIpDelegate>(funcTable, 1389091625205062844UL, Core_GetServerIpFallback);
36683683
Core_GetServerPort = (delegate* unmanaged[Cdecl]<nint, ushort>) GetUnmanagedPtr<Core_GetServerPortDelegate>(funcTable, 14148467334937601992UL, Core_GetServerPortFallback);

api/AltV.Net.CApi/Libraries/ServerLibrary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ public unsafe interface IServerLibrary
482482

483483
public unsafe class ServerLibrary : IServerLibrary
484484
{
485-
public readonly uint Methods = 1752;
485+
public readonly uint Methods = 1755;
486486
public delegate* unmanaged[Cdecl]<nint, nint, void> BaseObject_DeleteSyncedMetaData { get; }
487487
public delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void> BaseObject_SetMultipleSyncedMetaData { get; }
488488
public delegate* unmanaged[Cdecl]<nint, nint, nint, void> BaseObject_SetSyncedMetaData { get; }
@@ -1896,7 +1896,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
18961896
public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
18971897
{
18981898
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
1899-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 15809758987028017478UL) Outdated = true;
1899+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 554522947139118248UL) Outdated = true;
19001900
BaseObject_DeleteSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<BaseObject_DeleteSyncedMetaDataDelegate>(funcTable, 8228424877092269355UL, BaseObject_DeleteSyncedMetaDataFallback);
19011901
BaseObject_SetMultipleSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void>) GetUnmanagedPtr<BaseObject_SetMultipleSyncedMetaDataDelegate>(funcTable, 1390762125822890831UL, BaseObject_SetMultipleSyncedMetaDataFallback);
19021902
BaseObject_SetSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, nint, void>) GetUnmanagedPtr<BaseObject_SetSyncedMetaDataDelegate>(funcTable, 8002999088966424231UL, BaseObject_SetSyncedMetaDataFallback);

api/AltV.Net.CApi/Libraries/SharedLibrary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public unsafe interface ISharedLibrary
424424

425425
public unsafe class SharedLibrary : ISharedLibrary
426426
{
427-
public readonly uint Methods = 1752;
427+
public readonly uint Methods = 1755;
428428
public delegate* unmanaged[Cdecl]<nint, uint> Audio_GetID { get; }
429429
public delegate* unmanaged[Cdecl]<nint, uint> AudioAttachedOutput_GetID { get; }
430430
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetID { get; }
@@ -1664,7 +1664,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
16641664
public SharedLibrary(Dictionary<ulong, IntPtr> funcTable)
16651665
{
16661666
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
1667-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 15809758987028017478UL) Outdated = true;
1667+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 554522947139118248UL) Outdated = true;
16681668
Audio_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<Audio_GetIDDelegate>(funcTable, 4464042055475980737UL, Audio_GetIDFallback);
16691669
AudioAttachedOutput_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioAttachedOutput_GetIDDelegate>(funcTable, 17725794901805112189UL, AudioAttachedOutput_GetIDFallback);
16701670
AudioFilter_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioFilter_GetIDDelegate>(funcTable, 8824535635529306325UL, AudioFilter_GetIDFallback);

api/AltV.Net.Client/Alt.Globals.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ public static partial class Alt
7676
public static Task<string> TakeScreenshotGameOnly() => Core.TakeScreenshotGameOnly();
7777
public static void RegisterFont(string path) => Core.RegisterFont(path);
7878

79+
public static uint GetPoolSize(string pool) => Core.GetPoolSize(pool);
80+
public static uint GetPoolCount(string pool) => Core.GetPoolCount(pool);
81+
public static uint[] GetPoolEntities(string pool) => Core.GetPoolEntities(pool);
82+
7983
public static MapZoomData GetMapZoomData(uint id) => Core.GetMapZoomData(id);
8084
public static MapZoomData GetMapZoomData(string alias) => Core.GetMapZoomData(alias);
8185
public static void ResetAllMapZoomData() => Core.ResetAllMapZoomData();

api/AltV.Net.Client/Core.Globals.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,52 @@ public IFont RegisterFont(string path)
539539
}
540540
}
541541

542+
public uint GetPoolSize(string pool)
543+
{
544+
unsafe
545+
{
546+
var pathPtr = MemoryUtils.StringToHGlobalUtf8(pool);
547+
var result = Library.Client.Core_GetPoolSize(NativePointer, pathPtr);
548+
Marshal.FreeHGlobal(pathPtr);
549+
return result;
550+
}
551+
}
552+
553+
public uint GetPoolCount(string pool)
554+
{
555+
unsafe
556+
{
557+
var pathPtr = MemoryUtils.StringToHGlobalUtf8(pool);
558+
var result = Library.Client.Core_GetPoolCount(NativePointer, pathPtr);
559+
Marshal.FreeHGlobal(pathPtr);
560+
return result;
561+
}
562+
}
563+
564+
public uint[] GetPoolEntities(string pool)
565+
{
566+
unsafe
567+
{
568+
uint size = 0;
569+
var entitiesPtr = IntPtr.Zero;
570+
var pathPtr = MemoryUtils.StringToHGlobalUtf8(pool);
571+
Library.Client.Core_GetPoolEntities(NativePointer, pathPtr, &entitiesPtr, &size);
572+
573+
var uintArray = new UIntArray
574+
{
575+
data = entitiesPtr,
576+
size = size,
577+
capacity = size
578+
};
579+
580+
var result = uintArray.ToArray();
581+
582+
Library.Shared.FreeUInt32Array(entitiesPtr);
583+
Marshal.FreeHGlobal(pathPtr);
584+
return result;
585+
}
586+
}
587+
542588
public int MsPerGameMinute
543589
{
544590
get

api/AltV.Net.Client/ICore.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,9 @@ ILocalObject CreateLocalObject(uint modelHash, Position position, Rotation rotat
212212
IntPtr CreateColShapeSpherePtr(out uint id, Vector3 position, float radius);
213213
IColShape CreateColShapeSphere(Vector3 position, float radius);
214214
IFont RegisterFont(string path);
215+
216+
uint GetPoolSize(string pool);
217+
uint GetPoolCount(string pool);
218+
uint[] GetPoolEntities(string pool);
215219
}
216220
}

runtime

0 commit comments

Comments
 (0)