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 Nov 19, 2024
2 parents 31da6ee + 01787fe commit faac178
Show file tree
Hide file tree
Showing 17 changed files with 618 additions and 10 deletions.
3 changes: 2 additions & 1 deletion api/AltV.Net.CApi.Generator/TypeRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public static class TypeRegistry
{ "ClrDiscordUser*", "nint" },
{ "ClrConfigNodeData*", "nint" },
{ "ClrAmmoFlags*", "nint" },
{ "ClrDecoration**", "nint" }
{ "ClrDecoration**", "nint" },
{ "aabb_t&", "AABB*" },
};
}
36 changes: 36 additions & 0 deletions api/AltV.Net.CApi/Data/AABB.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Runtime.InteropServices;

namespace AltV.Net.Data
{
[StructLayout(LayoutKind.Sequential)]
public struct AABB : IEquatable<AABB>
{
public static AABB Zero = new AABB(Position.Zero, Position.Zero);

public Position Min;
public Position Max;

public AABB(Position min, Position max)
{
Min = min;
Max = max;
}

public override string ToString()
{
return $"AABB(min: {Min}, max: {Max})";
}

public override bool Equals(object obj)
{
return obj is AABB other && Equals(other);
}

public bool Equals(AABB other)
{
return Min.Equals(other.Min) && Max.Equals(other.Max);
}

public override int GetHashCode() => HashCode.Combine(Min.GetHashCode(), Max.GetHashCode());
}
}
154 changes: 152 additions & 2 deletions api/AltV.Net.CApi/Libraries/ClientLibrary.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api/AltV.Net.CApi/Libraries/ServerLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public unsafe interface IServerLibrary

public unsafe class ServerLibrary : IServerLibrary
{
public readonly uint Methods = 1779;
public readonly uint Methods = 1809;
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 @@ -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 != 11629663074568386340UL) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 10075699596264467259UL) 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
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 = 1779;
public readonly uint Methods = 1809;
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 != 11629663074568386340UL) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 10075699596264467259UL) 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
2 changes: 2 additions & 0 deletions api/AltV.Net.Client/Alt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public static bool GetBaseObjectById(BaseObjectType type, uint id, [MaybeNullWhe
public static LocalStorage LocalStorage => CoreImpl.LocalStorage;
public static Voice Voice => CoreImpl.Voice;
public static FocusData FocusData => CoreImpl.FocusData;

public static Interior? GetInterior(uint interiorId) => CoreImpl.GetInterior(interiorId);

public static HandlingData? GetHandlingByModelHash(uint modelHash) => CoreImpl.GetHandlingByModelHash(modelHash);
public static WeaponData? GetWeaponDataByWeaponHash(uint weaponHash) => CoreImpl.GetWeaponDataByWeaponHash(weaponHash);
Expand Down
5 changes: 5 additions & 0 deletions api/AltV.Net.Client/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ public IntPtr CreateMarkerPtr(out uint id, MarkerType type, Position pos, Rgba c
{
return new HandlingData(this, modelHash);
}

public Interior GetInterior(uint interiorId)
{
return new Interior(this, interiorId);
}

public AudioCategory GetAudioCategoryByName(string audioCategory)
{
Expand Down
15 changes: 15 additions & 0 deletions api/AltV.Net.Client/Elements/Data/IInterior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using AltV.Net.Data;

namespace AltV.Net.Client.Elements.Data;

public interface IInterior
{
IInteriorRoom GetRoomByIndex(uint roomIndex);
IInteriorRoom GetRoomByHash(uint roomHash);
IInteriorPortal GetPortalByIndex(uint portalIndex);
ushort RoomCount { get; }
ushort PortalCount { get; }
Position Position { get; }
Rotation Rotation { get; }
AABB EntitiesExtents { get; }
}
22 changes: 22 additions & 0 deletions api/AltV.Net.Client/Elements/Data/IInteriorPortal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using AltV.Net.Data;

namespace AltV.Net.Client.Elements.Data;

public interface IInteriorPortal
{
uint Index { get; }
ushort CornerCount { get; }
Position GetCornerPosition(uint cornerIndex);
IInteriorRoom RoomFrom { get; set; }
IInteriorRoom RoomTo { get; set; }
int Flag { get; set; }

ushort EntityCount { get; }
uint GetEntityArcheType(uint entityIndex);
int GetEntityFlag(uint entityIndex);
void SetEntityFlag(uint entityIndex, int flag);
Position GetEntityPosition(uint entityIndex);
Rotation GetEntityRotation(uint entityIndex);

void SetCornerPosition(uint cornerIndex, Position position);
}
13 changes: 13 additions & 0 deletions api/AltV.Net.Client/Elements/Data/IInteriorRoom.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using AltV.Net.Data;

namespace AltV.Net.Client.Elements.Data;

public interface IInteriorRoom
{
uint Index { get; }
string Name { get; }
uint NameHash { get; }
int Flag { get; set; }
uint Timecycle { get; set; }
AABB Extents { get; set; }
}
87 changes: 87 additions & 0 deletions api/AltV.Net.Client/Elements/Data/Interior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using AltV.Net.Data;

namespace AltV.Net.Client.Elements.Data;

public class Interior : IInterior
{
private readonly ICore _core;
private readonly uint _interiorId;

internal Interior(ICore core, uint interiorId)
{
_core = core;
_interiorId = interiorId;
}

public IInteriorRoom GetRoomByIndex(uint roomIndex)
{
return new InteriorRoom(_core, _interiorId, roomIndex, true);
}

public IInteriorRoom GetRoomByHash(uint roomHash)
{
return new InteriorRoom(_core, _interiorId, roomHash, false);
}

public IInteriorPortal GetPortalByIndex(uint portalIndex)
{
return new InteriorPortal(_core, _interiorId, portalIndex);
}

public ushort RoomCount
{
get
{
unsafe
{
return _core.Library.Client.Interior_GetRoomCount(_interiorId);
}
}
}

public ushort PortalCount
{
get
{
unsafe
{
return _core.Library.Client.Interior_GetPortalCount(_interiorId);
}
}
}

public Position Position
{
get
{
unsafe
{
return _core.Library.Client.Interior_GetPosition(_interiorId);
}
}
}

public Rotation Rotation
{
get
{
unsafe
{
return _core.Library.Client.Interior_GetPosition(_interiorId);
}
}
}

public AABB EntitiesExtents
{
get
{
unsafe
{
var interiorExtentInfo = AABB.Zero;
_core.Library.Client.Interior_GetEntitiesExtents(_interiorId, &interiorExtentInfo);
return interiorExtentInfo;
}
}
}
}
Loading

0 comments on commit faac178

Please sign in to comment.