This commit is contained in:
2026-02-16 15:53:20 -05:00
parent 3b8f32c19b
commit acbefc568c
4 changed files with 51 additions and 16 deletions

View File

@@ -5,12 +5,8 @@ using Newtonsoft.Json;
using Photon.Realtime;
using PhotonLogger.Core;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using static UnityEngine.UIElements.UIR.Implementation.UIRStylePainter;
namespace PhotonLogger.Patches;
@@ -20,7 +16,7 @@ internal class SerializableOperationResponse
public byte OperationCode { get; set; }
public short ReturnCode { get; set; }
public string DebugMessage { get; set; }
public NonAllocDictionary<byte, object> Parameters { get; set; }
public Dictionary<byte, object> Parameters { get; set; }
}
[HarmonyPatch]
@@ -28,18 +24,21 @@ public class OperationResponsePatch
{
static MethodInfo TargetMethod() => AccessTools.Method(typeof(LoadBalancingClient), nameof(LoadBalancingClient.OnOperationResponse));
static void Postfix(ref OperationResponse operationResponse)
static void Postfix(ref OperationResponse operationResponse, ref LoadBalancingClient __instance)
{
var newMsg = new Message
{
Time = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
Type = MessageType.OperationResponse,
Server = __instance.CurrentServerAddress,
Data = new SerializableOperationResponse
{
OperationCode = operationResponse.OperationCode,
ReturnCode = operationResponse.ReturnCode,
DebugMessage = operationResponse.DebugMessage,
Parameters = operationResponse.Parameters.paramDict
Parameters = OperationNormalizer.NormalizeDictionaryValues(
new Dictionary<byte, object>(operationResponse.Parameters.paramDict)
)
}
};
@@ -62,12 +61,13 @@ public class OperationRequestDictPatch
{
static MethodInfo TargetMethod() => typeof(PhotonPeer).GetRuntimeMethod("SendOperation", [ typeof(byte), typeof(Dictionary<byte, object>), typeof(SendOptions) ]);
static void Postfix(ref byte operationCode, ref Dictionary<byte, object> operationParameters)
static void Postfix(ref byte operationCode, ref Dictionary<byte, object> operationParameters, ref PhotonPeer __instance)
{
var newMsg = new Message
{
Time = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
Type = MessageType.OperationRequest,
Server = __instance.ServerAddress,
Data = new SerializableOperationRequest
{
OperationCode = operationCode,
@@ -87,16 +87,19 @@ public class OperationRequestParamDictPatch
{
static MethodInfo TargetMethod() => typeof(PhotonPeer).GetRuntimeMethod("SendOperation", [ typeof(byte), typeof(ParameterDictionary), typeof(SendOptions) ]);
static void Postfix(ref byte operationCode, ref ParameterDictionary operationParameters)
static void Postfix(ref byte operationCode, ref ParameterDictionary operationParameters, ref PhotonPeer __instance)
{
var newMsg = new Message
{
Time = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
Type = MessageType.OperationRequest,
Server = __instance.ServerAddress,
Data = new SerializableOperationRequest
{
OperationCode = operationCode,
Parameters = new Dictionary<byte, object>(operationParameters.paramDict)
Parameters = OperationNormalizer.NormalizeDictionaryValues(
new Dictionary<byte, object>(operationParameters.paramDict)
)
}
};