Exemplo n.º 1
0
 public void ResetCache()
 {
     worldData     = null;
     perfData      = null;
     charIdData    = null;
     actorsData    = null;
     chatLogData   = null;
     chatInputData = null;
 }
Exemplo n.º 2
0
 public void MemoryLoop()
 {
     //Console.Clear();
     if (GetSignature("WORLD", out var worldSig))
     {
         SigWorldData data = (SigWorldData)worldSig.GetData(ffxivProcess);
         if (worldData == null || !data.Equals(worldData))
         {
             dataPipe.PushMessage(CreatePipeData(data));
             Console.WriteLine("World: " + data.world);
             worldData = data;
         }
     }
     if (GetSignature("PERFSTATUS", out var perfSig))
     {
         SigPerfData data = (SigPerfData)perfSig.GetData(ffxivProcess);
         if (data != null)
         {
             if (perfData == null || !data.Equals(perfData))
             {
                 dataPipe.PushMessage(CreatePipeData(data));
                 Console.WriteLine("Performance change " + data.IsUp());
                 perfData = data;
             }
         }
     }
     if (GetSignature("CHARID", out var charidSig))
     {
         SigCharIdData data = (SigCharIdData)charidSig.GetData(ffxivProcess);
         if (data != null)
         {
             if (charIdData == null || !data.Equals(charIdData))
             {
                 dataPipe.PushMessage(CreatePipeData(data));
                 Console.WriteLine("New charid: " + data.id);
                 charIdData = data;
             }
         }
     }
     if (GetSignature("CHARMAP", out var charSig))
     {
         SigActorsData data = (SigActorsData)charSig.GetData(ffxivProcess);
         if (data != null)
         {
             if (data.currentActors.Values.Count > 0)
             {
                 ActorData me = data.currentActors.First().Value;
                 //Console.WriteLine(string.Format("YOU: {0} {1}", me.name, me.id));
             }
             if (data.addedActors.Count > 0 || data.removedActors.Count > 0)
             {
                 dataPipe.PushMessage(CreatePipeData(data));
                 string added = String.Join("+", data.addedActors.Select(t => t.Value.name).ToArray());
                 Console.WriteLine(string.Format("Players: {0} new, {1} removed: {2}", data.addedActors.Count, data.removedActors.Count, added));
             }
             if (false)
             {
                 string added   = String.Join(",", data.addedActors.Select(t => t.Value.name).ToArray());
                 string current = String.Join(",", data.currentActors.Select(t => t.Value.name).ToArray());
                 string removed = String.Join(",", data.removedActors.Select(t => t.Value.name).ToArray());
                 Console.WriteLine(string.Format("--- {0} players", data.currentActors.Count()));
                 Console.WriteLine(string.Format("ADDED: {0}", added));
                 Console.WriteLine(string.Format("REMOVED: {0}", removed));
                 Console.WriteLine(string.Format("CURRENT: {0}", current));
             }
         }
     }
     if (GetSignature("CHATLOG", out var chatlogSig))
     {
         SigChatLogData data = (SigChatLogData)chatlogSig.GetData(ffxivProcess);
         if (data != null)
         {
             foreach (ChatLogItem msg in data.chatMessages)
             {
                 Console.WriteLine(msg.Line);
             }
             if (data.chatMessages.Count > 0)
             {
                 dataPipe.PushMessage(CreatePipeData(data));
                 Console.WriteLine(string.Format("Chatlog: {0} new", data.chatMessages.Count));
             }
         }
     }
 }
Exemplo n.º 3
0
        public override object GetData(HookProcess process)
        {
            var result = new SigChatLogData();

            chatReader.PreviousArrayIndex = previousArrayIndex;
            chatReader.PreviousOffset     = previousOffset;

            if (baseAddress.ToInt64() <= 20)
            {
                return(result);
            }

            List <List <byte> > buffered = new List <List <byte> >();

            try {
                chatReader.Indexes.Clear();
                chatReader.ChatLogPointers = new ChatLogPointers {
                    LineCount        = (uint)process.GetUInt(baseAddress),
                    OffsetArrayStart = process.GetUInt(baseAddress, Offsets["OffsetArrayStart"]),
                    OffsetArrayPos   = process.GetUInt(baseAddress, Offsets["OffsetArrayPos"]),
                    OffsetArrayEnd   = process.GetUInt(baseAddress, Offsets["OffsetArrayEnd"]),
                    LogStart         = process.GetUInt(baseAddress, Offsets["LogStart"]),
                    LogNext          = process.GetUInt(baseAddress, Offsets["LogNext"]),
                    LogEnd           = process.GetUInt(baseAddress, Offsets["LogEnd"]),
                };

                chatReader.EnsureArrayIndexes(process);

                // Convenience
                ChatLogPointers ptrs = chatReader.ChatLogPointers;

                var currentArrayIndex = (ptrs.OffsetArrayPos - ptrs.OffsetArrayStart) / 4;
                if (chatReader.ChatLogFirstRun)
                {
                    chatReader.ChatLogFirstRun    = false;
                    chatReader.PreviousOffset     = chatReader.Indexes[(int)currentArrayIndex - 1];
                    chatReader.PreviousArrayIndex = (int)currentArrayIndex - 1;
                }
                else
                {
                    if (currentArrayIndex < chatReader.PreviousArrayIndex)
                    {
                        buffered.AddRange(chatReader.ResolveEntries(process, chatReader.PreviousArrayIndex, 1000));
                        chatReader.PreviousOffset     = 0;
                        chatReader.PreviousArrayIndex = 0;
                    }

                    if (chatReader.PreviousArrayIndex < currentArrayIndex)
                    {
                        buffered.AddRange(chatReader.ResolveEntries(process, chatReader.PreviousArrayIndex, (int)currentArrayIndex));
                    }

                    chatReader.PreviousArrayIndex = (int)currentArrayIndex;
                }
            }
            catch (Exception ex) {
                return(null);
            }

            foreach (List <byte> bytes in buffered.Where(b => b.Count > 0))
            {
                try {
                    ChatLogItem chatLogEntry = ChatEntry.Process(bytes.ToArray());
                    if (Regex.IsMatch(chatLogEntry.Combined, @"[\w\d]{4}::?.+"))
                    {
                        result.chatMessages.Add(chatLogEntry);
                    }
                }
                catch (Exception ex) {
                }
            }

            previousArrayIndex = chatReader.PreviousArrayIndex;
            previousOffset     = chatReader.PreviousOffset;

            return(result);
        }