More features

This commit is contained in:
gamer147
2026-05-23 14:18:01 -04:00
parent b2024af852
commit 6b70850b7b
59 changed files with 862 additions and 42033 deletions

View File

@@ -1,25 +1,15 @@
using System.Collections.Concurrent;
using System.Globalization;
using Microsoft.Extensions.Caching.Memory;
using Steamworks;
namespace SVSim.EmulatedEntrypoint.Services;
public class SteamSessionService : IDisposable
{
private readonly ConcurrentDictionary<string, ulong> _validatedSessionTickets;
private readonly ConcurrentDictionary<string, ulong> _validatedSessionTickets = new();
private readonly object _initLock = new();
private bool _steamInitialized;
private const int ShadowVerseAppId = 453480;
public SteamSessionService()
{
_validatedSessionTickets = new ConcurrentDictionary<string, ulong>();
SteamServer.Init(ShadowVerseAppId, new SteamServerInit
{
GamePort = default,
QueryPort = default
});
}
/// <summary>
/// Validates if a given session ticket is valid, and matches up with the given steamid.
@@ -34,6 +24,8 @@ public class SteamSessionService : IDisposable
return storedSteamId == steamId;
}
EnsureSteamInitialized();
List<byte> ticketBytes = new List<byte>();
for (int i = 0; i < ticket.Length; i += 2)
{
@@ -45,12 +37,30 @@ public class SteamSessionService : IDisposable
{
_validatedSessionTickets.TryAdd(ticket, steamId);
}
return steamCheckResults;
}
private void EnsureSteamInitialized()
{
if (_steamInitialized) return;
lock (_initLock)
{
if (_steamInitialized) return;
SteamServer.Init(ShadowVerseAppId, new SteamServerInit
{
GamePort = default,
QueryPort = default
});
_steamInitialized = true;
}
}
public void Dispose()
{
SteamServer.Shutdown();
if (_steamInitialized)
{
SteamServer.Shutdown();
}
}
}
}