public static CombatLog CreateCombatLog(string hash, List<LogEntry> log) { var combatParser = new CombatParser(); var model = combatParser.Parse(log); combatParser.Clean(model); model.Id = hash; return model; }
private async Task Listen() { await Task.Run(() => { while (true) { using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(_pipeName, PipeDirection.In, 1, PipeTransmissionMode.Message)) { try { Logger.Debug("Waiting for client connection..."); pipeServer.WaitForConnection(); Logger.Debug("Client connected."); while (pipeServer.IsConnected) { var header = new byte[MESSAGE_HEADER_SIZE]; pipeServer.Read(header, 0, MESSAGE_HEADER_SIZE); var length = header[0]; if (length is 0) { Logger.Debug("Length of message was 0."); continue; } var array = new byte[length]; pipeServer.Read(array, 0, length); var combatEvent = CombatParser.ProcessCombat(array); var src = combatEvent.Src; var dest = combatEvent.Dst; var ev = combatEvent.Ev; if (src.Self == 1 && !combatEvent.Ev.Buff && dest.Id != 0 && ev.Iff == 1) { Logger.Debug($"{combatEvent.Id} {combatEvent.Src.Name} hit {dest.Name} for {ev.Value} with {combatEvent.SkillName}"); } //Task.Run(() => //{ // var message = array; // ProcessMessage(array); //}); } } catch (IOException e) { Logger.Debug("ERROR: {0}", e.Message); } } } }, source.Token); }
private void ProcessCombat(byte[] data) { var message = CombatParser.ProcessCombat(data); OnRawCombatEvent(new RawCombatEventArgs(message)); }
public void SetUp() { target = new CombatParser(); log = new List<LogEntry>(); h = new LogHelper(log); player = new Actor { name = "Gisben", isPlayer = true }; mob = new Actor { name = "Soa", number = 836045448947788 }; }