- Better syncing stattrak
This commit is contained in:
Dawid Bepierszcz
2024-10-18 23:40:44 +02:00
parent c43f4bde80
commit 2bc53cd3c0
7 changed files with 37 additions and 79 deletions

View File

@@ -6,7 +6,6 @@ using CounterStrikeSharp.API.Modules.Timers;
using CounterStrikeSharp.API.Modules.Utils;
using Microsoft.Extensions.Logging;
using System.Collections.Concurrent;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
namespace WeaponPaints
@@ -518,21 +517,7 @@ namespace WeaponPaints
return viewModel.Value == null ? null : viewModel.Value;
}
public static unsafe T[] GetFixedArray<T>(nint pointer, string @class, string member, int length) where T : CHandle<CBaseViewModel>
{
var ptr = pointer + Schema.GetSchemaOffset(@class, member);
var references = MemoryMarshal.CreateSpan(ref ptr, length);
var values = new T[length];
for (var i = 0; i < length; i++)
{
values[i] = (T)Activator.CreateInstance(typeof(T), references[i])!;
}
return values;
}
private float ViewAsFloat(uint value)
private static float ViewAsFloat(uint value)
{
return BitConverter.Int32BitsToSingle((int)value);
}