Beispiel #1
0
            public Logging.Log GetLog(LogBuffer logBuffer, bool withText)
            {
                var l = new Logging.Log {
                    level       = this.level,
                    time        = this.time,
                    runningTime = this.runningTime,
                };

                if (withText)
                {
                    if (strLen == 0)
                    {
                        l.text = "";
                    }
                    else
                    {
                        var str = new string('\0', strLen);

                        fixed(char *pStr = str)
                        Encoding.GetChars(logBuffer.buffer + bufOffset, bufLen, pStr, strLen);

                        l.text = str;
                    }
                }
#if DEBUG
                if (withText && l.text.GetHashCode() != hash)
                {
                    Console.CmdConsole.StdIO.Write("Log checksum failed!\n", Console.Color32.FromConsoleColor(ConsoleColor.Red));
                }
#endif
                return(l);
            }
Beispiel #2
0
        public void Add(Logging.Log log)
        {
            lock (logs) {
                var ml     = new myLog(log);
                var str    = log.text;
                var strLen = ml.strLen = str.Length;
                var bufLen = ml.bufLen = Encoding.GetByteCount(str);
                if (bufLen > bufferSize)
                {
                    return;
                }
                while (remainingSeq < bufLen)
                {
                    if (tail < head)
                    {
                        head = 0;
                    }
                    Shift();
                }
                ml.bufOffset = head;
                head        += bufLen;
                if (bufLen > 0)
                    fixed(char *pStr = str)
                    {
                        Encoding.GetBytes(pStr, strLen, buffer + ml.bufOffset, bufLen);
                    }
                logs.Enqueue(ml);
#if DEBUG
                GetLogs();
#endif
            }
        }
Beispiel #3
0
 public void log(Logging.Log log)
 {
     if (isNullLogger)
     {
         return;
     }
     _parentLogger?.log(log);
     _logged?.Invoke(log);
 }
Beispiel #4
0
            public myLog(Logging.Log log)
            {
                level       = log.level;
                time        = log.time;
                runningTime = log.runningTime;
                bufOffset   = bufLen = strLen = 0;
#if DEBUG
                hash = log.text.GetHashCode();
#endif
            }
Beispiel #5
0
 private void Logging_Logged(Logging.Log x)
 {
     lock (sw) {
         if (!running)
         {
             return;
         }
         sw.Write(x.timestamp);
         sw.WriteLine(x.text);
         Flush();
     }
 }
Beispiel #6
0
 // EVENT HANDLERS
 private void AddLogHandler(Logging.Log log)
 {
     if (log.Text == "[HumanMasterPlugin] Starting to run away")
     {
         Logger.Log("HMP's running away feature detected. Disabling FightClass");
         HMPrunningAway = true;
     }
     else if (log.Text == "[HumanMasterPlugin] Stop fleeing, allow attacks again")
     {
         Logger.Log("Reenabling FightClass");
         HMPrunningAway = false;
     }
 }
Beispiel #7
0
    private void NpcBlacklistHook(Logging.Log log)
    {
        if (log.Text.Contains("[ToTown] Go to vendor"))
        {
            vendorNpc         = log.Text.Replace("[ToTown] Go to vendor ", "");
            vendorNpc         = vendorNpc.Remove(vendorNpc.Length - 9);
            wantToHearthStone = true;
        }

        if ((log.Text.Contains("[FlightMaster] Cannot found npc ") ||
             log.Text.Contains("[FlightMaster] Cannot reach flightmaster, disable and blacklist it for 30 min.")) &&
            inRadarCombat)
        {
            lock (Taxi.TaxiList.Locker)
            {
                RadarDebug("Re-enabling taxi nodes");
                foreach (var node in Taxi.TaxiList.Nodes)
                {
                    Taxi.TaxiList.Active(node);
                }
            }
            Thread.Sleep(3000);
        }

        if (log.Text.Contains("[ToTown] Go to town") || log.Text.Contains("[Trainers] Go to"))
        {
            wantToHearthStone = true;
        }

        if (log.Text.Contains("[HumanMasterPlugin] Choosing vendor "))
        {
            HMPArrowVendor    = log.Text.Replace("[HumanMasterPlugin] Choosing vendor ", "");
            HMPArrowVendor    = HMPArrowVendor.Remove(HMPArrowVendor.IndexOf(" to buy"));
            wantToHearthStone = true;
        }

        if (inRadarCombat && (log.Text.Contains("[ToTown] Unable to reach the vendor")))
        {
            foreach (var n in NpcDB.ListNpc)
            {
                if (n.Name == vendorNpc || n.Name == HMPArrowVendor)
                {
                    Logging.WriteDebug("[Z.E.Radar] Removing " + n.Name + " from vendor Blacklist");
                    n.BlackList(-1);
                }
            }
        }
    }
Beispiel #8
0
 public Logging.Log[] GetLogs()
 {
     lock (logs) {
         int count = logs.Count;
         if (count == 0)
         {
             return(new Logging.Log[0]);
         }
         var ret = new Logging.Log[count];
         for (int i = 0; i < count; i++)
         {
             ret[i] = logs.PeekAt(i).GetLog(this, true);
         }
         return(ret);
     }
 }