Snapshot for release 2026.10.15.2 (internal 2d4b0af)
This commit is contained in:
parent
a89ae04005
commit
d5e0b50de7
224 changed files with 17914 additions and 1182 deletions
|
|
@ -29,6 +29,9 @@
|
|||
<Compile Include="..\Shared\TrackerSessionStore.cs" Link="Shared\TrackerSessionStore.cs" />
|
||||
<Compile Include="..\Shared\SessionStats.cs" Link="Shared\SessionStats.cs" />
|
||||
<Compile Include="..\Shared\SessionStatsTracker.cs" Link="Shared\SessionStatsTracker.cs" />
|
||||
<!-- One session (2026-10-13): RynthAi's session through "RynthAi.Hub" when RynthAi is loaded. -->
|
||||
<Compile Include="..\Shared\RynthAiHubApi.cs" Link="Shared\RynthAiHubApi.cs" />
|
||||
<Compile Include="..\Shared\RynthAiSessionClient.cs" Link="Shared\RynthAiSessionClient.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -10,21 +10,28 @@ namespace RynthCore.Plugin.RynthTracker;
|
|||
// luminance (with ACECustom's bank and allegiance pass-up), luminance of the last five minutes,
|
||||
// kills (including a multi-target spell's extra kills found by their corpses), XP per kill,
|
||||
// deaths and Radiance. SessionStatsTracker reads the game and keeps the session across reloads.
|
||||
//
|
||||
// One session (0.4.1, 2026-10-13): with RynthAi loaded the panel shows RynthAi's own session
|
||||
// (the Mini Remote's Session Stats, read through "RynthAi.Hub"), so the Tracker, the Mini Remote,
|
||||
// RynthOracle and RynthILT count the same session from the same start, and Reset starts that one
|
||||
// over. Without RynthAi (or before its login) the Tracker's own session, kept running all along,
|
||||
// is shown instead.
|
||||
public sealed class RynthTrackerPlugin : RynthPluginBase
|
||||
{
|
||||
internal static readonly IntPtr NamePointer = Marshal.StringToHGlobalAnsi("RynthTracker");
|
||||
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.4.0"); // previous release: 0.3.0
|
||||
internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.4.1"); // previous release: 0.4.0
|
||||
|
||||
private SessionStatsTracker? _session;
|
||||
private readonly RynthAiSessionClient _ai = new();
|
||||
private int _tickCounter;
|
||||
// Set by the engine's UI thread (Reset export), acted on by the next OnTick on the pump.
|
||||
private volatile bool _resetWanted;
|
||||
|
||||
// Written on the game thread every ~0.5s, read on the engine's UI thread.
|
||||
// Reference reads are atomic on x86 so volatile is sufficient; no lock needed.
|
||||
private volatile string _snapshot = EmptySnapshot;
|
||||
|
||||
private const string EmptySnapshot =
|
||||
"{\"ss\":0.0,\"xt\":0,\"xh\":0,\"lt\":0,\"lh\":0,\"l5\":0,\"pt\":0,\"ph\":0,\"pk\":0,"
|
||||
+ "\"kt\":0,\"kh\":0.0,\"xk\":0,\"dt\":0,\"rt\":0,\"rh\":0,\"ml\":0}";
|
||||
private const string EmptySnapshot = TrackerSnapshot.Empty;
|
||||
|
||||
public override int Initialize()
|
||||
{
|
||||
|
|
@ -33,11 +40,16 @@ public sealed class RynthTrackerPlugin : RynthPluginBase
|
|||
return 0;
|
||||
}
|
||||
|
||||
public override void OnLoginComplete() => _session?.OnLoginComplete();
|
||||
public override void OnLoginComplete()
|
||||
{
|
||||
_ai.Reset();
|
||||
_session?.OnLoginComplete();
|
||||
}
|
||||
|
||||
public override void OnLogout()
|
||||
{
|
||||
_session?.OnLogout();
|
||||
_ai.Reset();
|
||||
_snapshot = EmptySnapshot;
|
||||
}
|
||||
|
||||
|
|
@ -58,39 +70,31 @@ public sealed class RynthTrackerPlugin : RynthPluginBase
|
|||
{
|
||||
var session = _session;
|
||||
if (session == null) return;
|
||||
long nowMs = Environment.TickCount64;
|
||||
if (_resetWanted)
|
||||
{
|
||||
_resetWanted = false;
|
||||
// RynthAi's session when it is the one shown; the Tracker's own either way, so a later
|
||||
// fallback doesn't jump back to an old start.
|
||||
_ai.ResetSession(Host, nowMs);
|
||||
session.RequestReset();
|
||||
}
|
||||
session.Tick();
|
||||
if (++_tickCounter < 30) return; // rebuild every ~0.5s at 60Hz
|
||||
_tickCounter = 0;
|
||||
_snapshot = session.Active ? BuildSnapshot(session.View, DateTime.UtcNow) : EmptySnapshot;
|
||||
DateTime now = DateTime.UtcNow;
|
||||
if (_ai.TryGet(Host, nowMs, out SessionStatsV1 s))
|
||||
{
|
||||
SessionStatsMoreV1? more = _ai.TryGetMore(Host, nowMs, out SessionStatsMoreV1 m) ? m : null;
|
||||
_snapshot = TrackerSnapshot.Build(TrackerSnapshot.FromRynthAi(s, more, session.Active ? session.View : null), now);
|
||||
}
|
||||
else
|
||||
_snapshot = session.Active ? TrackerSnapshot.Build(session.View, now) : EmptySnapshot;
|
||||
}
|
||||
|
||||
internal string GetSnapshot() => _snapshot;
|
||||
|
||||
/// <summary>Called from the RynthTrackerReset export (engine UI thread): just flags a reset;
|
||||
/// the next OnTick performs it on the pump thread.</summary>
|
||||
internal void Reset() => _session?.RequestReset();
|
||||
|
||||
private static string BuildSnapshot(SessionStatsView v, DateTime now)
|
||||
{
|
||||
// The session clock runs between polls; the totals and rates are the poll's.
|
||||
double ss = Math.Max(0, (now - v.SessionStartUtc).TotalSeconds);
|
||||
var ic = System.Globalization.CultureInfo.InvariantCulture;
|
||||
return "{\"ss\":" + ss.ToString("F1", ic)
|
||||
+ ",\"xt\":" + v.Xp
|
||||
+ ",\"xh\":" + (long)v.XpPerHour
|
||||
+ ",\"lt\":" + v.Lum
|
||||
+ ",\"lh\":" + (long)v.LumPerHour
|
||||
+ ",\"l5\":" + v.LumLast5Min // luminance of the last five minutes
|
||||
+ ",\"pt\":" + v.LumPassUp // allegiance pass-up (ACECustom bank)
|
||||
+ ",\"ph\":" + (long)v.PassUpPerHour
|
||||
+ ",\"pk\":" + (v.PassUpTracked ? 1 : 0) // 1 = the bank is read, pass-up is known
|
||||
+ ",\"kt\":" + v.Kills
|
||||
+ ",\"kh\":" + v.KillsPerHour.ToString("F1", ic)
|
||||
+ ",\"xk\":" + v.XpPerKill // your kills only
|
||||
+ ",\"dt\":" + v.Deaths
|
||||
+ ",\"rt\":" + v.Rad // Radiance (Aelrynth); 0 elsewhere
|
||||
+ ",\"rh\":" + (long)v.RadPerHour
|
||||
+ ",\"ml\":" + (v.MaxLevel ? 1 : 0) // at the level cap: experience can't rise
|
||||
+ "}";
|
||||
}
|
||||
internal void Reset() => _resetWanted = true;
|
||||
}
|
||||
|
|
|
|||
60
Plugins/RynthCore.Plugin.RynthTracker/TrackerSnapshot.cs
Normal file
60
Plugins/RynthCore.Plugin.RynthTracker/TrackerSnapshot.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthTracker;
|
||||
|
||||
/// <summary>
|
||||
/// The Tracker panel's snapshot JSON, and RynthAi's session turned into the same view (2026-10-13:
|
||||
/// one session for every tracker). Pure, so RynthCore.TrackerSessionTests compiles it in directly.
|
||||
/// </summary>
|
||||
internal static class TrackerSnapshot
|
||||
{
|
||||
public const string Empty =
|
||||
"{\"ss\":0.0,\"xt\":0,\"xh\":0,\"lt\":0,\"lh\":0,\"l5\":0,\"pt\":0,\"ph\":0,\"pk\":0,"
|
||||
+ "\"kt\":0,\"kh\":0.0,\"xk\":0,\"dt\":0,\"rt\":0,\"rh\":0,\"ml\":0}";
|
||||
|
||||
/// <summary>
|
||||
/// RynthAi's session as the panel's view. The fields an older RynthAi doesn't send (no
|
||||
/// SessionStatsMore) come from the Tracker's own session when it runs, else zero.
|
||||
/// </summary>
|
||||
public static SessionStatsView FromRynthAi(SessionStatsV1 s, SessionStatsMoreV1? more, SessionStatsView? own)
|
||||
{
|
||||
var start = new DateTime(Math.Clamp(s.StartUtcTicks, 0, DateTime.MaxValue.Ticks), DateTimeKind.Utc);
|
||||
long xpPerKill = more?.XpPerKill ?? own?.XpPerKill ?? 0;
|
||||
int deaths = more?.Deaths ?? own?.Deaths ?? 0;
|
||||
long rad = more?.Rad ?? own?.Rad ?? 0;
|
||||
double radPerHour = more?.RadPerHour ?? own?.RadPerHour ?? 0;
|
||||
bool maxLevel = more is { } m ? m.MaxLevel != 0 : own?.MaxLevel ?? false;
|
||||
return new SessionStatsView(start, s.SessionSeconds, s.Xp, s.XpPerHour, s.Lum, s.LumPerHour, s.LumLast5Min,
|
||||
s.LumPassUp, s.PassUpPerHour, s.PassUpTracked != 0, (int)Math.Clamp(s.Kills, 0, int.MaxValue), s.KillsPerHour,
|
||||
xpPerKill, deaths, rad, radPerHour, maxLevel);
|
||||
}
|
||||
|
||||
/// <summary>A rate per hour as a whole number: rounded (not cut off), never negative or NaN.</summary>
|
||||
public static long PerHour(double v) => double.IsFinite(v) && v > 0 ? (long)Math.Round(v, MidpointRounding.AwayFromZero) : 0;
|
||||
|
||||
/// <summary>The panel's JSON. The session clock runs between polls; the totals and rates are the poll's.</summary>
|
||||
public static string Build(SessionStatsView v, DateTime now)
|
||||
{
|
||||
double ss = Math.Max(0, (now - v.SessionStartUtc).TotalSeconds);
|
||||
CultureInfo ic = CultureInfo.InvariantCulture;
|
||||
return "{\"ss\":" + ss.ToString("F1", ic)
|
||||
+ ",\"xt\":" + v.Xp.ToString(ic)
|
||||
+ ",\"xh\":" + PerHour(v.XpPerHour).ToString(ic)
|
||||
+ ",\"lt\":" + v.Lum.ToString(ic)
|
||||
+ ",\"lh\":" + PerHour(v.LumPerHour).ToString(ic)
|
||||
+ ",\"l5\":" + v.LumLast5Min.ToString(ic) // luminance of the last five minutes
|
||||
+ ",\"pt\":" + v.LumPassUp.ToString(ic) // allegiance pass-up (ACECustom bank)
|
||||
+ ",\"ph\":" + PerHour(v.PassUpPerHour).ToString(ic)
|
||||
+ ",\"pk\":" + (v.PassUpTracked ? 1 : 0) // 1 = the bank is read, pass-up is known
|
||||
+ ",\"kt\":" + v.Kills.ToString(ic)
|
||||
+ ",\"kh\":" + v.KillsPerHour.ToString("F1", ic)
|
||||
+ ",\"xk\":" + v.XpPerKill.ToString(ic) // your kills only
|
||||
+ ",\"dt\":" + v.Deaths.ToString(ic)
|
||||
+ ",\"rt\":" + v.Rad.ToString(ic) // Radiance (Aelrynth); 0 elsewhere
|
||||
+ ",\"rh\":" + PerHour(v.RadPerHour).ToString(ic)
|
||||
+ ",\"ml\":" + (v.MaxLevel ? 1 : 0) // at the level cap: experience can't rise
|
||||
+ "}";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue