Skip to content

Commit 891b38c

Browse files
committed
merge dev into rc
2 parents c4d2123 + a8de0d5 commit 891b38c

File tree

29 files changed

+400
-71
lines changed

29 files changed

+400
-71
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ on:
22
push:
33
tags:
44
- '*.*.*'
5-
- '*.*.*-*'
5+
- '*.*.*-*.*'
66
jobs:
77
fetch-nethost-linux:
88
runs-on: ubuntu-22.04

api/AltV.Net.Async/AsyncCore.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,14 +869,14 @@ public override void OnGivePedScriptedTaskEvent(IntPtr eventPointer, IPlayer sou
869869
}
870870

871871
public override void OnPlayerConnectDeniedEvent(PlayerConnectDeniedReason reason, string name, string ip, ulong passwordHash,
872-
bool isDebug, string branch, uint majorVersion, string cdnUrl, long discordId)
872+
bool isDebug, string branch, ushort versionMajor, ushort versionMinor, string cdnUrl, long discordId)
873873
{
874-
base.OnPlayerConnectDeniedEvent(reason, name, ip, passwordHash, isDebug, branch, majorVersion, cdnUrl, discordId);
874+
base.OnPlayerConnectDeniedEvent(reason, name, ip, passwordHash, isDebug, branch, versionMajor, versionMinor, cdnUrl, discordId);
875875

876876
if (!PlayerConnectDeniedAsyncEventHandler.HasEvents()) return;
877877
Task.Run(async () =>
878878
{
879-
await PlayerConnectDeniedAsyncEventHandler.CallAsync(@delegate => @delegate(reason, name, ip, passwordHash, isDebug, branch, majorVersion, cdnUrl, discordId));
879+
await PlayerConnectDeniedAsyncEventHandler.CallAsync(@delegate => @delegate(reason, name, ip, passwordHash, isDebug, branch, versionMajor, versionMinor, cdnUrl, discordId));
880880
});
881881
}
882882

api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,31 @@ public string Branch
9696
}
9797
}
9898
}
99-
public uint Build
99+
100+
public ushort VersionMajor
101+
{
102+
get
103+
{
104+
lock (ConnectionInfo)
105+
{
106+
if (!AsyncContext.CheckIfExistsOrCachedNullable(ConnectionInfo)) return default;
107+
return ConnectionInfo.VersionMajor;
108+
}
109+
}
110+
}
111+
112+
public ushort VersionMinor
100113
{
101114
get
102115
{
103116
lock (ConnectionInfo)
104117
{
105118
if (!AsyncContext.CheckIfExistsOrCachedNullable(ConnectionInfo)) return default;
106-
return ConnectionInfo.Build;
119+
return ConnectionInfo.VersionMinor;
107120
}
108121
}
109122
}
123+
110124
public string CdnUrl
111125
{
112126
get

api/AltV.Net.Async/Elements/Entities/AsyncVehicle.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Diagnostics.CodeAnalysis;
44
using System.Numerics;
5+
using AltV.Net.CApi.Data;
56
using AltV.Net.Data;
67
using AltV.Net.Elements.Entities;
78
using AltV.Net.Enums;
@@ -1993,6 +1994,24 @@ public List<PlayerSeat> Passengers
19931994
}
19941995
}
19951996

1997+
public void SetBage(string textureDictionary, string texture, VehicleBadgePosition[] vehicleBadgePosition)
1998+
{
1999+
lock (Vehicle)
2000+
{
2001+
if (!AsyncContext.CheckIfExistsOrCachedNullable(Vehicle)) return;
2002+
Vehicle.SetBage(textureDictionary, texture, vehicleBadgePosition);
2003+
}
2004+
}
2005+
2006+
public void SetBage(uint textureDictionary, uint texture, VehicleBadgePosition[] vehicleBadgePosition)
2007+
{
2008+
lock (Vehicle)
2009+
{
2010+
if (!AsyncContext.CheckIfExistsOrCachedNullable(Vehicle)) return;
2011+
Vehicle.SetBage(textureDictionary, texture, vehicleBadgePosition);
2012+
}
2013+
}
2014+
19962015
[Obsolete("Use new async API instead")]
19972016
public IVehicle ToAsync(IAsyncContext asyncContext)
19982017
{

api/AltV.Net.Async/Events/Events.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace AltV.Net.Async.Events
1414
public delegate Task PlayerConnectAsyncDelegate(IPlayer player, string reason);
1515

1616
public delegate Task PlayerConnectDeniedAsyncDelegate(PlayerConnectDeniedReason reason, string name, string ip,
17-
ulong passwordHash, bool isDebug, string branch, uint majorVersion, string cdnUrl, long discordId);
17+
ulong passwordHash, bool isDebug, string branch, ushort versionMajor, ushort versionMinor, string cdnUrl, long discordId);
1818

1919
public delegate Task ResourceEventAsyncDelegate(INativeResource resource);
2020

api/AltV.Net.CApi.Generator/Program.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ private static string GetCMethodDelegateType(CMethod method)
1515
var args = string.Join("", method.Params.Select(p => p.Type + ", "));
1616
return $"delegate* unmanaged[Cdecl{noGc}]<{args}{method.ReturnType}>";
1717
}
18-
18+
1919
private static string GetCMethodArgs(CMethod method)
2020
{
2121
return string.Join(", ", method.Params.Select(p => p.Type + " " + p.Name));
2222
}
2323

2424
public static void Generate()
2525
{
26-
var libOutputPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, "../../../../AltV.Net.CApi/Libraries");
26+
var libOutputPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, "../../../../AltV.Net.CApi/Libraries");
2727
var tableOutputPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, "../../../../../runtime/c-api/func_table.cpp");
2828

2929
var tableHashes = new StringBuilder();
@@ -40,31 +40,32 @@ public static void Generate()
4040
collisionFound = true;
4141
Console.WriteLine("Colliding methods: " + string.Join(",", collision.Select(e => e.Name)));
4242
}
43-
43+
4444
if (collisionFound) throw new Exception("Collision found!");
4545

4646
var capiHash = FnvHash.Generate(string.Join(";", parsedMethods.Select(e => e.Hash)));
47-
47+
4848
foreach (var group in parsedMethods.OrderBy(e => e.Name).GroupBy(e => e.Target))
4949
{
5050
#region C# bindings
5151
var target = group.Key.ForceCapitalize();
52-
52+
5353
var methods = string.Join("\n", group.Where(e => !e.OnlyManual)
5454
.Select(e => $" public {GetCMethodDelegateType(e)} {e.Name} {{ get; }}"));
55-
55+
5656
// todo add docs link to the exception
5757
var fallbacks = string.Join("\n", group.Where(e => !e.OnlyManual)
5858
.Select(e => $" [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate {e.ReturnType} {e.Name}Delegate({GetCMethodArgs(e)});\n"
5959
+ $" private static {e.ReturnType} {e.Name}Fallback({GetCMethodArgs(e)}) => throw new Exceptions.OutdatedSdkException(\"{e.Name}\", \"{e.Name} SDK method is outdated. Please update your module nuget\");"));
60-
60+
6161
var loads = string.Join("\n", group.Where(e => !e.OnlyManual)
6262
.Select(e => $" {e.Name} = ({GetCMethodDelegateType(e)}) GetUnmanagedPtr<{e.Name}Delegate>(funcTable, {e.Hash}UL, {e.Name}Fallback);"));
63-
63+
6464
var output = new StringBuilder();
6565

6666
output.Append("// ReSharper disable InconsistentNaming\n");
6767
output.Append("using AltV.Net.Data;\n");
68+
output.Append("using AltV.Net.CApi.Data;\n");
6869
output.Append("using System.Numerics;\n");
6970
output.Append("using System.Runtime.InteropServices;\n");
7071
output.Append("using AltV.Net.Elements.Args;\n");
@@ -100,21 +101,21 @@ public static void Generate()
100101

101102
File.WriteAllText(Path.Combine(libOutputPath, $"{target}Library.cs"), output.ToString());
102103
#endregion
103-
104+
104105
#region Func table
105106

106107
if (group.Key != "SHARED")
107108
{
108109
tableHashes.Append($" #ifdef ALT_{group.Key}_API\n");
109110
tablePointers.Append($" #ifdef ALT_{group.Key}_API\n");
110111
}
111-
112+
112113
foreach (var e in group)
113114
{
114115
tableHashes.Append($" {e.Hash}UL,\n");
115116
tablePointers.Append($" (void*) {e.Name},\n");
116117
}
117-
118+
118119
if (group.Key != "SHARED")
119120
{
120121
tableHashes.Append($" #endif\n");
@@ -125,13 +126,13 @@ public static void Generate()
125126

126127
var table = new StringBuilder();
127128
table.Append("#include \"func_table.h\"\n\n");
128-
129+
129130
table.Append($"inline uint64_t capiHash = {capiHash}UL;\n");
130131
table.Append("inline uint64_t capiHashes[] = {\n");
131132
table.Append(" 0,\n");
132133
table.Append(tableHashes);
133134
table.Append("};\n\n");
134-
135+
135136
table.Append("inline void* capiPointers[] = {\n");
136137
table.Append(" (void*) &capiHash,\n");
137138
table.Append(tablePointers);
@@ -145,10 +146,10 @@ public static void Generate()
145146
table.Append(" };\n");
146147
table.Append(" return &data;\n");
147148
table.Append("}");
148-
149+
149150
File.WriteAllText(tableOutputPath, table.ToString());
150-
}
151-
151+
}
152+
152153
public static void Main()
153154
{
154155
Generate();

api/AltV.Net.CApi.Generator/TypeRegistry.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ public static class TypeRegistry
123123
{ "rotation_t", "Rotation" },
124124
{ "alt::Rotation", "Rotation" },
125125

126+
{ "vehicleBadgePosition_t[]", "VehicleBadgePosition[]" },
127+
126128
{ "cloth_t&", "Cloth*" },
127129
{ "cloth_t", "Cloth" },
128130
{ "dlccloth_t&", "DlcCloth*" },
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Numerics;
2+
using System.Runtime.InteropServices;
3+
4+
namespace AltV.Net.CApi.Data;
5+
6+
[StructLayout(LayoutKind.Sequential)]
7+
public struct VehicleBadgePosition : IEquatable<VehicleBadgePosition>
8+
{
9+
public VehicleBadgePosition(bool active, byte alpha, float size, short boneIndex, Vector3 offset, Vector3 direction, Vector3 side)
10+
{
11+
Active = active ? (byte)1 : (byte)0;
12+
Alpha = alpha;
13+
Size = size;
14+
BoneIndex = boneIndex;
15+
Offset = offset;
16+
Direction = direction;
17+
Side = side;
18+
}
19+
20+
public byte Active { get; set; } = 0;
21+
public byte Alpha { get; set; } = 255;
22+
public float Size { get; set; } = 1f;
23+
public short BoneIndex { get; set; } = 0;
24+
public Vector3 Offset { get; set; } = new(0, 0, 0);
25+
public Vector3 Direction { get; set; } = new(0, 0, 0);
26+
public Vector3 Side { get; set; } = new(0, 0, 0);
27+
28+
public bool Equals(VehicleBadgePosition other)
29+
{
30+
return Active == other.Active && Alpha == other.Alpha && Size.Equals(other.Size) && BoneIndex == other.BoneIndex && Offset.Equals(other.Offset) && Direction.Equals(other.Direction) && Side.Equals(other.Side);
31+
}
32+
33+
public override bool Equals(object? obj)
34+
{
35+
return obj is VehicleBadgePosition other && Equals(other);
36+
}
37+
38+
public override int GetHashCode() => HashCode.Combine(Active.GetHashCode(), Alpha.GetHashCode(), Size.GetHashCode(), BoneIndex.GetHashCode(), Offset.GetHashCode(), Direction.GetHashCode(), Side.GetHashCode());
39+
}

0 commit comments

Comments
 (0)