Ejemplo n.º 1
0
 bool BlacklistedIp(Player p)
 {
     foreach (string key in Blacklist.Keys)
     {
         if (!key.ToLower().Contains("ip"))
             continue;
         string[] parts = key.Split(':');
         Regex regxp = new Regex("\\A" + parts[1]);
         if (regxp.IsMatch(p.Ip))
             return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 private bool Exists(List<Player> arr, Player p)
 {
     foreach (Player i in arr)
     {
         if (p.Id == i.Id)
             return true;
     }
     return false;
 }
Ejemplo n.º 3
0
        void ReadLog(string path, bool parseAll, bool overwriteMatch, bool onlyUnique)
        {
            List<string> lines = new List<string>(File.ReadAllLines(path, Encoding.GetEncoding("Windows-1251")));

                string TimeStamp = "";
                int startline = 0;
                if (!parseAll)
                    startline = GetStartLineForLastInstance(lines);

                for (int i = startline; i < lines.Count; i++)
                {
                    string line = lines[i];
                    if (!((line.Contains("Life") || line.Contains("Dead") || line.Contains("Knockout")) && (line.Contains("Yes") || line.Contains("Disconnect"))))
                    {
                        TimeStamp = "";
                        continue;
                    }
                    if (string.IsNullOrEmpty(TimeStamp))
                        TimeStamp = line.Substring(0, 8);

                    line = line.Remove(0, 11);
                    Player player = new Player();
                    player.FromFile = Path.GetFileName(path);
                    player.TimeStamp = TimeStamp;
                    player.Name     =           GetLogElement(line, out line, false);
                    player.Id       = int.Parse(GetLogElement(line, out line, true));
                    player.Ip       =           GetLogElement(line, out line, true);
                    player.NetState =           GetLogElement(line, out line, true);
                    player.Cond     =           GetLogElement(line, out line, true);
                    player.X        = int.Parse(GetLogElement(line, out line, true));
                    player.Y        = int.Parse(GetLogElement(line, out line, true));
                    if (line.Substring(0, 10) == "Global map")
                    {
                        player.Location = GetLogElement(line, out line, false);
                        player.Map = "";
                        player.MapId = 0;
                        player.MapPid = 0;
                        player.LocationId = 0;
                        player.LocationPid = 0;
                        line = line.Trim();
                        player.Level = int.Parse(line);
                    }
                    else
                    {
                        player.Location = line.Substring(0, line.IndexOf(')')+1);
                        line = line.Remove(0, line.IndexOf(')')+1);
                        line = line.TrimStart();
                        string temp = player.Location.Substring(player.Location.IndexOf('(') + 1, player.Location.Length-player.Location.IndexOf('(') - 2);
                        temp = temp.Trim();
                        string[] vals = temp.Split(',');
                        player.LocationId = int.Parse(vals[0]);
                        player.LocationPid = int.Parse(vals[1]);

                        player.Map = line.Substring(0, line.IndexOf(')')+1);
                        line = line.Remove(0, line.IndexOf(')')+1);
                        line = line.Trim();

                        temp = player.Map.Substring(player.Map.IndexOf('(') + 1, player.Map.Length - player.Map.IndexOf('(') - 2);
                        temp = temp.Trim();
                        vals = temp.Split(',');
                        player.MapId = int.Parse(vals[0]);
                        player.MapPid = int.Parse(vals[1]);
                        player.Level = int.Parse(line);
                    }

                    if (onlyUnique)
                    {
                        if (!Exists(Players, player))
                            Players.Add(player);
                        else
                        {
                            if (overwriteMatch)
                            {
                                Players.Remove(Players.Find(x => x.Id == player.Id));
                                Players.Add(player);
                            }
                        }
                    }
                    else
                        Players.Add(player);

                }
        }
Ejemplo n.º 4
0
 private bool InTown(Player p)
 {
     int pid = p.MapPid;
     return (pid != 0) && !InBase(p) && !InEncounter(p) && !InTent(p);
 }
Ejemplo n.º 5
0
 private bool InTent(Player p)
 {
     int pid = p.MapPid;
     return (IsWithinRange(pid,287,290));
 }
Ejemplo n.º 6
0
 private bool InEncounter(Player p)
 {
     int pid = p.MapPid;
     return ((pid >= 150 && pid < 220) || (pid >= 345 && pid < 370) || (pid >= 400 && pid < 450) || (pid >= 500 && pid < 550));
 }
Ejemplo n.º 7
0
 private bool InBase(Player p)
 {
     int pid = p.LocationPid;
     return (IsWithinRange(pid, 202, 205) || IsWithinRange(pid, 207, 208) || pid == 210 || IsWithinRange(pid, 245, 246));
 }