Fix luminance: hook ServerDispatch in Startup and handle 0x02CF updates

- Move Init() and ServerDispatch hook from LoginComplete to Startup so
  event 0x0013 (character properties) is caught during login sequence
- Add handler for message 0x02CF (PrivateUpdatePropertyInt64) to capture
  runtime luminance changes when player earns/spends luminance in-game
- Uses RawData byte parsing for 0x02CF since Decal messages.xml may not
  define this message type

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
erik 2026-02-27 06:18:15 +00:00
parent ad8fb3a4ba
commit c53aa4b31b
3 changed files with 40 additions and 7 deletions

View file

@ -146,6 +146,33 @@ namespace MosswartMassacre
} }
} }
/// <summary>
/// Process message 0x02CF - PrivateUpdatePropertyInt64.
/// Sent during gameplay when an Int64 property changes (e.g., luminance earned/spent).
/// Wire format after 4-byte type header: sequence(1) + key(4) + value(8).
/// Uses RawData since Decal's messages.xml may not define this message type.
/// </summary>
internal static void ProcessPropertyInt64Update(NetworkMessageEventArgs e)
{
try
{
byte[] raw = e.Message.RawData;
if (raw.Length < 17) return; // 4 type + 1 seq + 4 key + 8 value
int key = BitConverter.ToInt32(raw, 5);
long value = BitConverter.ToInt64(raw, 9);
if (key == 6) // AvailableLuminance
luminanceEarned = value;
else if (key == 7) // MaximumLuminance
luminanceTotal = value;
}
catch (Exception ex)
{
PluginCore.WriteToChat($"[CharStats] Int64 property update error: {ex.Message}");
}
}
/// <summary> /// <summary>
/// Process game event 0x0029 - Titles list. /// Process game event 0x0029 - Titles list.
/// Extracts current title ID. /// Extracts current title ID.

View file

@ -204,6 +204,12 @@ namespace MosswartMassacre
// Note: View initialization moved to LoginComplete for VVS compatibility // Note: View initialization moved to LoginComplete for VVS compatibility
// Initialize character stats and hook ServerDispatch early
// 0x0013 (character properties with luminance) fires DURING login,
// BEFORE LoginComplete — must hook here to catch it
CharacterStats.Init();
CoreManager.Current.EchoFilter.ServerDispatch += EchoFilter_ServerDispatch;
// Enable TLS1.2 // Enable TLS1.2
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
//Enable vTank interface //Enable vTank interface
@ -414,15 +420,11 @@ namespace MosswartMassacre
WriteToChat($"[ERROR] Quest streaming initialization failed: {ex.Message}"); WriteToChat($"[ERROR] Quest streaming initialization failed: {ex.Message}");
} }
// Initialize character stats streaming // Start character stats streaming
// Note: Init() and ServerDispatch hook are in Startup() so we catch
// 0x0013 (luminance/properties) which fires BEFORE LoginComplete
try try
{ {
CharacterStats.Init();
// Subscribe to server messages for allegiance/luminance/title data
// Must be AFTER Init() to avoid Init() clearing already-captured data
CoreManager.Current.EchoFilter.ServerDispatch += EchoFilter_ServerDispatch;
// Start 10-minute character stats timer // Start 10-minute character stats timer
characterStatsTimer = new Timer(600000); // 10 minutes characterStatsTimer = new Timer(600000); // 10 minutes
characterStatsTimer.Elapsed += OnCharacterStatsUpdate; characterStatsTimer.Elapsed += OnCharacterStatsUpdate;
@ -1241,6 +1243,10 @@ namespace MosswartMassacre
CharacterStats.ProcessSetTitleMessage(e); CharacterStats.ProcessSetTitleMessage(e);
} }
} }
else if (e.Message.Type == 0x02CF) // PrivateUpdatePropertyInt64 (runtime luminance changes)
{
CharacterStats.ProcessPropertyInt64Update(e);
}
} }
catch (Exception ex) catch (Exception ex)
{ {