/** * We use reflection to calculate the field offsets since there's no public Machina DLL we could link * against. I want to avoid copying the relevant structures so reflection is the last option left. * * IMPORTANT: Remove the parsing code, once the parser parses the network packet and provides * an event or log line for it. */ public static void Init() { try { var mach = Assembly.Load("Machina.FFXIV"); MessageType = mach.GetType("Machina.FFXIV.Headers.Server_MessageType"); var ActorControl142 = mach.GetType("Machina.FFXIV.Headers.Server_ActorControl142"); ActorControl142_Size = Marshal.SizeOf(ActorControl142); var headerOffset = GetOffset(ActorControl142, "MessageHeader"); var msgHeader = ActorControl142.GetField("MessageHeader").FieldType; MessageType_Offset = headerOffset + GetOffset(msgHeader, "MessageType"); ActorID_Offset = headerOffset + GetOffset(msgHeader, "ActorID"); Category_Offset = GetOffset(ActorControl142, "category"); Param1_Offset = GetOffset(ActorControl142, "param1"); ActorControl142_Opcode = GetOpcode("ActorControl142"); #if DEBUG Registry.Resolve <ILogger>().Log(LogLevel.Debug, $"ActorControl142 = {ActorControl142_Opcode.ToString("x")}"); #endif FFXIVRepository.RegisterNetworkParser(Parse); } catch (Exception e) { Registry.Resolve <ILogger>().Log(LogLevel.Error, Resources.NetworkParserInitException, e); } }
/** * We use reflection to calculate the field offsets since there's no public Machina DLL we could link * against. I want to avoid copying the relevant structures so reflection is the last option left. * * IMPORTANT: Remove the parsing code, once the parser parses the network packet and provides * an event or log line for it. */ public static void Init() { try { var mach = Assembly.Load("Machina.FFXIV"); var ActorControl142 = mach.GetType("Machina.FFXIV.Headers.Server_ActorControl142"); ActorControl142_Size = Marshal.SizeOf(ActorControl142); var headerOffset = GetOffset(ActorControl142, "MessageHeader"); var msgHeader = ActorControl142.GetField("MessageHeader").FieldType; MessageType_Offset = headerOffset + GetOffset(msgHeader, "MessageType"); ActorID_Offset = headerOffset + GetOffset(msgHeader, "ActorID"); Category_Offset = GetOffset(ActorControl142, "category"); Param1_Offset = GetOffset(ActorControl142, "param1"); ActorControl142_Type = (ushort)GetEnumValue(msgHeader.GetField("MessageType").FieldType, "ActorControl142"); FFXIVRepository.RegisterNetworkParser(Parse); } catch (Exception e) { Registry.Resolve <ILogger>().Log(LogLevel.Error, Resources.NetworkParserInitException, e); } }