Example #1
0
        private void messageReceived(Message message)
        {
            try
            {
                //Message does not contain our length, add it to see the full packet
                byte[] data = new byte[message.Data.Count];
                Array.Copy(message.Data.Array, 0, data, 2, message.Data.Count - 2);
                data[0] = (byte) (((short) message.Data.Count) & 255);
                data[1] = (byte)(((short)message.Data.Count) >> 8);
                if (message.Direction == MessageDirection.ClientToServer)
                {
                    Packet_old tmpPacket = new Packet_old(Direction.CS, message.OpCode, data, false);
                    mainWindow.pp.AppendPacket(tmpPacket);
                }
                else
                {
                    Packet_old tmpPacket = new Packet_old(Direction.SC, message.OpCode, data, false);
                    mainWindow.pp.AppendPacket(tmpPacket);
                }
            }
            catch (Exception ex)
            {

                mainWindow.SetText("device_OnPacketArrival failure. \n Message:" + ex);
            }
        }
        static void teraSniffer_MessageReceived(Tera.Message message)
        {
            //Message does not contain our length, add it to see the full packet
            byte[] data = new byte[message.Data.Count];
            Array.Copy(message.Data.Array, 0, data, 2, message.Data.Count - 2);
            data[0] = (byte)(((short)message.Data.Count) & 255);
            data[1] = (byte)(((short)message.Data.Count) >> 8);

            if (message.Direction == MessageDirection.ServerToClient)
            {
                Packet_old tmpPacket = new Packet_old(Direction.SC, message.OpCode, data, false); //**********************//

                DataParser.StoreLastPacket(tmpPacket.OpCode, tmpPacket.HexShortText);
                DataParser.StoreLastMessage(message);
            }
        }
Example #3
0
        private void HandleMessageReceived(Message obj)
        {
            var message = _messageFactory.Create(obj);
            _entityTracker.Update(message);

            var skillResultMessage = message as EachSkillResultServerMessage;
            if (!DamageTracker.IsArchived && //don't process while viewing a past encounter
                skillResultMessage != null && !skillResultMessage.IsUseless &&//stuff like warrior DFA
                (DamageTracker.FirstAttack != null || (!skillResultMessage.IsHeal && skillResultMessage.Amount > 0)) &&//only record first hit is it's a damage hit (heals occurring outside of fights)
                !(skillResultMessage.Target.Equals(skillResultMessage.Source) && !skillResultMessage.IsHeal))//disregard damage dealt to self (gunner self destruct)
            {
                var skillResult = new SkillResult(skillResultMessage, _entityTracker, _playerTracker, _teraData.SkillDatabase);
                DamageTracker.Update(skillResult);
            }
        }
Example #4
0
        private void HandleMessageReceived(Message obj)
        {
            var message = _messageFactory.Create(obj);

            if (DamageTracker.IsArchived)
            {
                var npcOccupier = message as SNpcOccupierInfo;
                if (npcOccupier != null)
                {
                    Entity ent = _entityTracker.GetOrPlaceholder(npcOccupier.NPC);
                    if (ent is NpcEntity)
                    {
                        var npce = ent as NpcEntity;
                        if (npce.Info.Boss && npcOccupier.Target != EntityId.Empty)
                        {
                            CasualMessenger.Instance.ResetPlayerStats(true); //Stop viewing saved encounter on boss aggro
                        }
                    }
                    return;
                }
            }

            _entityTracker?.Update(message);
            var skillResultMessage = message as EachSkillResultServerMessage;
            if (skillResultMessage != null)
            {
                if (skillResultMessage.IsValid(DamageTracker))
                {
                    var skillResult = new SkillResult(skillResultMessage, _entityTracker, _playerTracker, _teraData.SkillDatabase, null, _abnormalityTracker);
                    CheckUpdate(skillResult);
                }
                return;
            }
            _playerTracker?.UpdateParty(message);
            _abnormalityTracker?.Update(message);
            var despawnNpc = message as SDespawnNpc;
            if (despawnNpc != null)
            {
                Entity ent = _entityTracker.GetOrPlaceholder(despawnNpc.Npc);
                if (ent is NpcEntity)
                {
                    var npce = ent as NpcEntity;
                    if (npce.Info.Boss && despawnNpc.Dead && !DamageTracker.IsArchived)
                    {   //no need to do something if we didn't count any skill against this boss
                        if (DamageTracker.StatsByUser.SelectMany(x => x.SkillLog).Any(x => x.Target == npce))
                        {
                            DamageTracker.PrimaryTarget = npce; //Name encounter with the last dead boss
                            DamageTracker.IsPrimaryTargetDead = despawnNpc.Dead;

                            //determine type
                            ExportType exportType = ExportType.None;
                            if (SettingsHelper.Instance.Settings.ExcelExport)
                                exportType = exportType | ExportType.Excel;
                            if (SettingsHelper.Instance.Settings.SiteExport)
                                exportType = exportType | ExportType.Upload;

                            if (exportType != ExportType.None)
                                DataExporter.ToTeraDpsApi(exportType, DamageTracker, _teraData);
                            if (AutosaveEncounters)
                                ResetDamageTracker(new ResetPlayerStatsMessage { ShouldSaveCurrent = true });
                        }
                    }
                }
                return;
            }

            var sLogin = message as LoginServerMessage;
            if (sLogin != null)
            {
                if (_needInit)
                {
                    Server = BasicTeraData.Servers.GetServer(sLogin.ServerId, Server);
                    _messageFactory.Version = Server.Region;
                    Logger.Info($"Logged in to server {Server.Name}.");
                    _teraData = BasicTeraData.DataForRegion(Server.Region);
                    _entityTracker = new EntityTracker(_teraData.NpcDatabase);
                    _playerTracker = new PlayerTracker(_entityTracker, BasicTeraData.Servers);
                    _abnormalityTracker = new AbnormalityTracker(_entityTracker, _playerTracker, _teraData.HotDotDatabase, _abnormalityStorage, CheckUpdate);
                    _entityTracker.Update(message);
                    _needInit = false;
                }
                _abnormalityStorage.EndAll(message.Time.Ticks);
                _abnormalityTracker = new AbnormalityTracker(_entityTracker, _playerTracker, _teraData.HotDotDatabase, _abnormalityStorage, CheckUpdate);
                return;
            }
            var cVersion = message as C_CHECK_VERSION;
            if (cVersion != null)
            {
                var opCodeNamer =
                    new OpCodeNamer(Path.Combine(BasicTeraData.ResourceDirectory,
                        $"opcodes/{cVersion.Versions[0]}.txt"));
                _messageFactory = new MessageFactory(opCodeNamer, Server.Region);
                return;
            }
        }
 public CustomReader(Tera.Message message)
     : base(GetStream(message), Encoding.Unicode)
 {
     Message = message;
 }
 private static MemoryStream GetStream(Tera.Message message)
 {
     return(new MemoryStream(message.Payload.Array, message.Payload.Offset, message.Payload.Count, false, true));
 }
Example #7
0
        private void HandleMessageReceived(Message obj)
        {
            var message = _messageFactory.Create(obj);
            _entityTracker.Update(message);

            var skillResultMessage = message as EachSkillResultServerMessage;
            if (SettingsHelper.Instance.Settings.InactivityResetDuration > 0
                && _inactivityTimer.Elapsed > TimeSpan.FromSeconds(SettingsHelper.Instance.Settings.InactivityResetDuration)
                && skillResultMessage.IsValid())
            {
                ResetDamageTracker();
            }
            if (!DamageTracker.IsArchived && skillResultMessage.IsValid(DamageTracker)) //don't process while viewing a past encounter
            {
                var skillResult = new SkillResult(skillResultMessage, _entityTracker, _playerTracker, _teraData.SkillDatabase);
                DamageTracker.Update(skillResult);
                if (!skillResult.IsHeal && skillResult.Amount > 0)
                    _inactivityTimer.Restart();
                PlayerCount = DamageTracker.StatsByUser.Count;
            }
        }