Skip to content

Commit

Permalink
Merge branch 'release' into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed May 14, 2024
2 parents 1646e52 + 819bb37 commit d65694b
Show file tree
Hide file tree
Showing 71 changed files with 875 additions and 387 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
* @fabianterhorst
* @fabianterhorst @doxoh
/docs/ @lhoerion
!/docs/*.md @lhoerion
!/docs/*.yml @lhoerion
/docs/filterConfig.yml @lhoerion
/api/AltV.Net.Async.CodeGen/ @zziger
/api/AltV.Net.Client/ @zziger @juztim
/api/AltV.Net.Async.CodeGen/ @zziger @doxoh
/api/AltV.Net.Client/ @zziger @juztim @doxoh
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ jobs:
echo "branch=${build_info%%/*}" >> $GITHUB_OUTPUT
echo "version=${build_info##*/}" >> $GITHUB_OUTPUT
echo "sdk_commit=$(cat ./modules/sdk_version.txt)" >> $GITHUB_OUTPUT
- run: npm i @altmp/upload-tool@latest
- run: npm i @altmp/upload-tool@latest [email protected]
- run: npx alt-upload linux coreclr-module/$BRANCH/x64_linux $VERSION $SDK_VERSION
working-directory: ./modules
env:
Expand Down
4 changes: 2 additions & 2 deletions api/AltV.Net.Async.CodeGen/AltV.Net.Async.CodeGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<Authors>AltMp</Authors>
<Description>AltV .NET Core Async CodeGen</Description>
<Copyright>AltMp</Copyright>
<PackageProjectUrl>https://github.com/FabianTerhorst/coreclr-module</PackageProjectUrl>
<RepositoryUrl>https://github.com/FabianTerhorst/coreclr-module</RepositoryUrl>
<PackageProjectUrl>https://github.com/altmp/coreclr-module</PackageProjectUrl>
<RepositoryUrl>https://github.com/altmp/coreclr-module</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>altv gta bridge</PackageTags>
<PackageVersion>1.0.0</PackageVersion>
Expand Down
26 changes: 26 additions & 0 deletions api/AltV.Net.Async/AltAsync.RegisterEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ public static void RegisterEvents(object target)
ScriptFunction scriptFunction;
switch (scriptEventType)
{
case ScriptEventType.BaseObjectCreate:
{
scriptFunction = ScriptFunction.Create(eventMethodDelegate,
new[] { typeof(IBaseObject) }, isAsync: true);
if (scriptFunction == null) return;
OnBaseObjectCreate += (baseObject) =>
{
var currScriptFunction = scriptFunction.Clone();
currScriptFunction.Set(baseObject);
return currScriptFunction.CallAsync();
};
break;
}
case ScriptEventType.BaseObjectRemove:
{
scriptFunction = ScriptFunction.Create(eventMethodDelegate,
new[] { typeof(IBaseObject) }, isAsync: true);
if (scriptFunction == null) return;
OnBaseObjectRemove += (baseObject) =>
{
var currScriptFunction = scriptFunction.Clone();
currScriptFunction.Set(baseObject);
return currScriptFunction.CallAsync();
};
break;
}
case ScriptEventType.Checkpoint:
{
scriptFunction = ScriptFunction.Create(eventMethodDelegate,
Expand Down
12 changes: 12 additions & 0 deletions api/AltV.Net.Async/AltAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ public static event CheckpointAsyncDelegate OnCheckpoint
remove => Core.CheckpointAsyncEventHandler.Remove(value);
}

public static event BaseObjectCreateAsyncDelegate OnBaseObjectCreate
{
add => Core.BaseObjectCreateAsyncEventHandler.Add(value);
remove => Core.BaseObjectCreateAsyncEventHandler.Remove(value);
}

public static event BaseObjectRemoveAsyncDelegate OnBaseObjectRemove
{
add => Core.BaseObjectRemoveAsyncEventHandler.Add(value);
remove => Core.BaseObjectRemoveAsyncEventHandler.Remove(value);
}

public static event PlayerConnectAsyncDelegate OnPlayerConnect
{
add => Core.PlayerConnectAsyncEventHandler.Add(value);
Expand Down
4 changes: 2 additions & 2 deletions api/AltV.Net.Async/AltV.Net.Async.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<Authors>AltMp</Authors>
<Description>AltV .NET Core Async Server Api</Description>
<Copyright>AltMp</Copyright>
<PackageProjectUrl>https://github.com/FabianTerhorst/coreclr-module</PackageProjectUrl>
<RepositoryUrl>https://github.com/FabianTerhorst/coreclr-module</RepositoryUrl>
<PackageProjectUrl>https://github.com/altmp/coreclr-module</PackageProjectUrl>
<RepositoryUrl>https://github.com/altmp/coreclr-module</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>altv gta bridge</PackageTags>
<PackageVersion>1.0.0</PackageVersion>
Expand Down
39 changes: 34 additions & 5 deletions api/AltV.Net.Async/AsyncCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ internal readonly AsyncEventHandler<PlayerChangeVehicleSeatAsyncDelegate>
internal readonly AsyncEventHandler<PlayerDisconnectAsyncDelegate> PlayerDisconnectAsyncEventHandler =
new(EventType.PLAYER_DISCONNECT);

internal readonly AsyncEventHandler<BaseObjectCreateAsyncDelegate> BaseObjectCreateAsyncEventHandler =
new();

internal readonly AsyncEventHandler<BaseObjectRemoveAsyncDelegate> BaseObjectRemoveAsyncEventHandler =
new();

internal readonly AsyncEventHandler<PlayerRemoveAsyncDelegate> PlayerRemoveAsyncEventHandler =
new();

Expand Down Expand Up @@ -357,6 +363,27 @@ await PlayerDisconnectAsyncEventHandler.CallAsync(@delegate =>
);
}

public override void OnCreateBaseObjectEvent(IBaseObject baseObject)
{
base.OnCreateBaseObjectEvent(baseObject);
if (!BaseObjectCreateAsyncEventHandler.HasEvents()) return;
Task.Run(async () =>
{
await BaseObjectCreateAsyncEventHandler.CallAsync(@delegate =>
@delegate(baseObject));
});
}
public override void OnRemoveBaseObjectEvent(IBaseObject baseObject)
{
base.OnRemoveBaseObjectEvent(baseObject);
if (!BaseObjectRemoveAsyncEventHandler.HasEvents()) return;
Task.Run(async () =>
{
await BaseObjectRemoveAsyncEventHandler.CallAsync(@delegate =>
@delegate(baseObject));
});
}

public override void OnPlayerRemoveEvent(IPlayer player)
{
base.OnPlayerRemoveEvent(player);
Expand Down Expand Up @@ -968,13 +995,13 @@ public override void OnPlayerStopTalkingEvent(IPlayer player)
});
}

public override void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, IntPtr[] args, ushort answerId, bool async)
public override void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, object[] objects, ushort answerId, bool async)
{
if (!UnansweredServerRpcRequest.Contains(answerId))
{
UnansweredServerRpcRequest.Add(answerId);
}
base.OnScriptRPCEvent(eventpointer, target, name, args, answerId, true);
base.OnScriptRPCEvent(eventpointer, target, name, objects, answerId, true);

if (UnansweredServerRpcRequest.Contains(answerId))
{
Expand All @@ -985,13 +1012,15 @@ public override void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, strin
}

if (!ScriptRpcAsyncEventHandler.HasEvents()) return;
Task.Run(async () =>

var task = Task.Run(async () =>
{
var mValues = MValueConst.CreateFrom(this, args);
var clientScriptRPCEvent = new AsyncScriptRpcEvent(target, answerId);
await ScriptRpcAsyncEventHandler.CallAsync(@delegate => @delegate(clientScriptRPCEvent, target, name, mValues.Select(x => x.ToObject()).ToArray(), answerId));
await ScriptRpcAsyncEventHandler.CallAsync(@delegate => @delegate(clientScriptRPCEvent, target, name, objects, answerId));
});

Task.WaitAll(task);

if (UnansweredServerRpcRequest.Contains(answerId))
{
target.EmitRPCAnswer(answerId, null, "Answer not handled");
Expand Down
2 changes: 1 addition & 1 deletion api/AltV.Net.Async/Elements/Entities/AsyncBaseObject.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
Expand Down
2 changes: 2 additions & 0 deletions api/AltV.Net.Async/Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public delegate Task PlayerHealAsyncDelegate(IPlayer target, ushort oldHealth, u

public delegate Task PlayerDisconnectAsyncDelegate(IPlayer player, string reason);

public delegate Task BaseObjectCreateAsyncDelegate(IBaseObject baseObject);
public delegate Task BaseObjectRemoveAsyncDelegate(IBaseObject baseObject);
public delegate Task PlayerRemoveAsyncDelegate(IPlayer player);

public delegate Task VehicleRemoveAsyncDelegate(IVehicle vehicle);
Expand Down
2 changes: 1 addition & 1 deletion api/AltV.Net.CApi.Generator/TypeRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;

namespace AltV.Net.CApi.Generator;

Expand Down
8 changes: 4 additions & 4 deletions api/AltV.Net.CApi/AltV.Net.CApi.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Authors>FabianTerhorst</Authors>
<Authors>FabianTerhorst,Doxoh</Authors>
<Description>AltV .NET CApi</Description>
<Copyright>FabianTerhorst</Copyright>
<PackageProjectUrl>https://github.com/FabianTerhorst/coreclr-module</PackageProjectUrl>
<RepositoryUrl>https://github.com/FabianTerhorst/coreclr-module</RepositoryUrl>
<Copyright>FabianTerhorst,Doxoh</Copyright>
<PackageProjectUrl>https://github.com/altmp/coreclr-module</PackageProjectUrl>
<RepositoryUrl>https://github.com/altmp/coreclr-module</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>altv gta bridge gta5 gtav colshape</PackageTags>
<PackageVersion>1.0.0</PackageVersion>
Expand Down
6 changes: 6 additions & 0 deletions api/AltV.Net.CApi/Data/Position.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Drawing;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
Expand Down Expand Up @@ -105,6 +106,11 @@ public float Distance(Position b)
return MathF.Sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
}

public Position ToRadians()
{
return new Position((X * MathF.PI) / 180, (Y * MathF.PI) / 180, (Z * MathF.PI) / 180);
}

public static Position operator +(Position a, Position b) => new Position(a.X + b.X, a.Y + b.Y, a.Z + b.Z);

public static Position operator -(Position a, Position b) => new Position(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
Expand Down
5 changes: 5 additions & 0 deletions api/AltV.Net.CApi/Data/Rotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public bool Equals(Rotation other)
return Roll.Equals(other.Roll) && Pitch.Equals(other.Pitch) && Yaw.Equals(other.Yaw);
}

public Rotation ToRadians()
{
return new Rotation((Roll * MathF.PI) / 180, (Pitch * MathF.PI) / 180, (Yaw * MathF.PI) / 180);
}

public override int GetHashCode() => HashCode.Combine(Roll.GetHashCode(), Pitch.GetHashCode(), Yaw.GetHashCode());
}
}
18 changes: 9 additions & 9 deletions api/AltV.Net.CApi/Events/ClientEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ namespace AltV.Net.CApi.ClientEvents

public delegate void PlayerSpawnModuleDelegate();
public delegate void PlayerDisconnectModuleDelegate();
public delegate void PlayerEnterVehicleModuleDelegate(IntPtr pointer, byte seat);
public delegate void PlayerLeaveVehicleModuleDelegate(IntPtr pointer, byte seat);
public delegate void PlayerChangeVehicleSeatModuleDelegate(IntPtr pointer, byte oldSeat, byte newSeat);
public delegate void PlayerChangeAnimationModuleDelegate(IntPtr pointer, uint oldDict, uint newDict, uint oldName, uint newName);
public delegate void PlayerChangeInteriorModuleDelegate(IntPtr pointer, uint oldIntLoc, uint newIntLoc);
public delegate void PlayerEnterVehicleModuleDelegate(IntPtr baseObject, BaseObjectType type, byte seat);
public delegate void PlayerLeaveVehicleModuleDelegate(IntPtr baseObject, BaseObjectType type, byte seat);
public delegate void PlayerChangeVehicleSeatModuleDelegate(IntPtr pointer, BaseObjectType type, byte oldSeat, byte newSeat);
public delegate void PlayerChangeAnimationModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldDict, uint newDict, uint oldName, uint newName);
public delegate void PlayerChangeInteriorModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldIntLoc, uint newIntLoc);
public delegate void PlayerWeaponShootModuleDelegate(uint weapon, ushort totalAmmo, ushort ammoInClip);
public delegate void PlayerWeaponChangeModuleDelegate(uint oldWeapon, uint newWeapon);

public delegate void GameEntityCreateModuleDelegate(IntPtr pointer, byte type);
public delegate void GameEntityDestroyModuleDelegate(IntPtr pointer, byte type);
public delegate void GameEntityCreateModuleDelegate(IntPtr pointer, BaseObjectType type);
public delegate void GameEntityDestroyModuleDelegate(IntPtr pointer, BaseObjectType type);

public delegate void AnyResourceErrorModuleDelegate(string name);
public delegate void AnyResourceStartModuleDelegate(string name);
Expand Down Expand Up @@ -78,8 +78,8 @@ public delegate void CheckpointModuleDelegate(IntPtr colShapePointer, IntPtr tar
public delegate void EntityHitEntityModuleDelegate(IntPtr targetPointer, BaseObjectType targetType, IntPtr damagerPointer,
BaseObjectType damagerType, uint weaponHash);

public delegate void PlayerStartEnterVehicleModuleDelegate(IntPtr targetPointer, IntPtr player, byte seat);
public delegate void PlayerStartLeaveVehicleModuleDelegate(IntPtr targetPointer, IntPtr player, byte seat);
public delegate void PlayerStartEnterVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player, BaseObjectType playerType, byte seat);
public delegate void PlayerStartLeaveVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player, BaseObjectType playerType, byte seat);

public delegate void PlayerBulletHitModuleDelegate(uint weapon, IntPtr victimPointer, BaseObjectType victimType,
Position pos);
Expand Down
4 changes: 2 additions & 2 deletions api/AltV.Net.CApi/Libraries/ClientLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ public unsafe interface IClientLibrary

public unsafe class ClientLibrary : IClientLibrary
{
public readonly uint Methods = 1770;
public readonly uint Methods = 1773;
public delegate* unmanaged[Cdecl]<nint, nint, void> Audio_AddOutput { get; }
public delegate* unmanaged[Cdecl]<nint, nint> Audio_GetBaseObject { get; }
public delegate* unmanaged[Cdecl]<nint, double> Audio_GetCurrentTime { get; }
Expand Down Expand Up @@ -3573,7 +3573,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 != 18234026019486245283UL) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 78812385462098472UL) 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
Loading

0 comments on commit d65694b

Please sign in to comment.