Skip to content

Commit

Permalink
Merge branch 'rc' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Aug 20, 2024
2 parents 80cdced + 5e0b72d commit 41d34ee
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 69 deletions.
109 changes: 67 additions & 42 deletions api/AltV.Net.CApi/Libraries/ClientLibrary.cs

Large diffs are not rendered by default.

14 changes: 7 additions & 7 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 @@ -488,7 +488,7 @@ public unsafe interface IServerLibrary

public unsafe class ServerLibrary : IServerLibrary
{
public readonly uint Methods = 1774;
public readonly uint Methods = 1779;
public delegate* unmanaged[Cdecl]<nint, nint, void> BaseObject_DeleteSyncedMetaData { get; }
public delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void> BaseObject_SetMultipleSyncedMetaData { get; }
public delegate* unmanaged[Cdecl]<nint, nint, nint, void> BaseObject_SetSyncedMetaData { 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 != 4464148992254491289UL) 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
4 changes: 2 additions & 2 deletions api/AltV.Net.CApi/Libraries/SharedLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ public unsafe interface ISharedLibrary

public unsafe class SharedLibrary : ISharedLibrary
{
public readonly uint Methods = 1774;
public readonly uint Methods = 1779;
public delegate* unmanaged[Cdecl]<nint, uint> Audio_GetID { get; }
public delegate* unmanaged[Cdecl]<nint, uint> AudioAttachedOutput_GetID { get; }
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetID { get; }
Expand Down 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 != 4464148992254491289UL) 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
26 changes: 20 additions & 6 deletions api/AltV.Net.Client/Elements/Data/Handling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,31 @@ public float DriveBiasFront
}
}

public float Acceleration
public float DriveBiasRear
{
get
{
unsafe
{
return core.Library.Client.Vehicle_Handling_GetAcceleration(vehiclePointer);
return core.Library.Client.Vehicle_Handling_GetDriveBiasRear(vehiclePointer);
}
}
set
{
unsafe
{
core.Library.Client.Vehicle_Handling_SetAcceleration(vehiclePointer, value);
core.Library.Client.Vehicle_Handling_SetDriveBiasRear(vehiclePointer, value);
}
}
}

[Obsolete("Use DriveBiasRear instead")]
public float Acceleration
{
get => this.DriveBiasRear;
set => this.DriveBiasRear = value;
}

public uint InitialDriveGears
{
get
Expand Down Expand Up @@ -336,24 +343,31 @@ public float InitialDriveForce
}
}

public float DriveMaxFlatVel
public float InitialDriveMaxVel
{
get
{
unsafe
{
return core.Library.Client.Vehicle_Handling_GetDriveMaxFlatVel(vehiclePointer);
return core.Library.Client.Vehicle_Handling_GetInitialDriveMaxVel(vehiclePointer);
}
}
set
{
unsafe
{
core.Library.Client.Vehicle_Handling_SetDriveMaxFlatVel(vehiclePointer, value);
core.Library.Client.Vehicle_Handling_SetInitialDriveMaxVel(vehiclePointer, value);
}
}
}

[Obsolete("Use InitialDriveMaxVel instead")]
public float DriveMaxFlatVel
{
get => this.InitialDriveMaxVel;
set => this.InitialDriveMaxVel = value;
}

public float InitialDriveMaxFlatVel
{
get
Expand Down
26 changes: 20 additions & 6 deletions api/AltV.Net.Client/Elements/Data/HandlingData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,24 +208,31 @@ public float DriveBiasFront
}
}

public float Acceleration
public float DriveBiasRear
{
get
{
unsafe
{
return core.Library.Client.Handling_GetAcceleration(modelHash);
return core.Library.Client.Handling_GetDriveBiasRear(modelHash);
}
}
set
{
unsafe
{
core.Library.Client.Handling_SetAcceleration(modelHash, value);
core.Library.Client.Handling_SetDriveBiasRear(modelHash, value);
}
}
}

[Obsolete("Use DriveBiasRear instead")]
public float Acceleration
{
get => this.DriveBiasRear;
set => this.DriveBiasRear = value;
}

public uint InitialDriveGears
{
get
Expand Down Expand Up @@ -316,24 +323,31 @@ public float InitialDriveForce
}
}

public float DriveMaxFlatVel
public float InitialDriveMaxVel
{
get
{
unsafe
{
return core.Library.Client.Handling_GetDriveMaxFlatVel(modelHash);
return core.Library.Client.Handling_GetInitialDriveMaxVel(modelHash);
}
}
set
{
unsafe
{
core.Library.Client.Handling_SetDriveMaxFlatVel(modelHash, value);
core.Library.Client.Handling_SetInitialDriveMaxVel(modelHash, value);
}
}
}

[Obsolete("Use InitialDriveMaxVel instead")]
public float DriveMaxFlatVel
{
get => this.InitialDriveMaxVel;
set => this.InitialDriveMaxVel = value;
}

public float InitialDriveMaxFlatVel
{
get
Expand Down
4 changes: 4 additions & 0 deletions api/AltV.Net.Client/Elements/Data/IHandlingData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ public interface IHandlingData
float PercentSubmerged { get; set; }
float PercentSubmergedRatio { get; set; }
float DriveBiasFront { get; set; }
float DriveBiasRear { get; set; }
[Obsolete("Use DriveBiasRear instead")]
float Acceleration { get; set; }
uint InitialDriveGears { get; set; }
float DriveInertia { get; set; }
float ClutchChangeRateScaleUpShift { get; set; }
float ClutchChangeRateScaleDownShift { get; set; }
float InitialDriveForce { get; set; }
float InitialDriveMaxVel { get; set; }
[Obsolete("Use InitialDriveMaxVel instead")]
float DriveMaxFlatVel { get; set; }
float InitialDriveMaxFlatVel { get; set; }
float BrakeForce { get; set; }
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

0 comments on commit 41d34ee

Please sign in to comment.