private static void GetInstance()
 {
     if (instance == null)
     {
         instance = new PlayerLoggingUDPClient();
     }
 }
Beispiel #2
0
        private void P99LogMonitor_OnNewLineCaptured(string text)
        {
            Map aMap = (Map)mapTabs.TabPages["youTab"].Controls["zoneMap"];

            string line;

            string[] blockDelim = { "\n\0" };
            string[] splitDelim = { "] " };
            string   newZone    = "You have entered ";
            string   location   = "Your Location is ";

            string[] tempLocation;
            foreach (string split in text.Split(blockDelim, StringSplitOptions.None))
            {
                line = split.Split(splitDelim, StringSplitOptions.None)[1];
                if (line.StartsWith(newZone))
                {
                    zone = line.Remove(0, newZone.Length);
                    zone = zone.TrimEnd('.');
                    PlayerManagement.GetPlayer(toonName).Zone = zone;
                    //  Load map using zone
                    Invoke(new MethodInvoker(delegate() { LoadMap(); }));
                }
                else if (line.StartsWith(location))
                {
                    if (toonName == null)
                    {
                        return;
                    }
                    tempLocation = line.Remove(0, location.Length).Split(',');
                    PlayerManagement.GetPlayer(toonName).SetLocation(double.Parse(tempLocation[1]), double.Parse(tempLocation[0]));
                    PlayerLoggingUDPClient.Send('L', PlayerManagement.GetPlayer(toonName));
                }
            }
        }
Beispiel #3
0
        private void P99LogMonitor_OnNewFileCaptured(string filename)
        {
            Map aMap = (Map)mapTabs.TabPages["youTab"].Controls["zoneMap"];

            string[] fileSplit = filename.Split('_');

            if (toonName != null)
            {
                PlayerManagement.RemovePlayer(toonName);
                PlayerLoggingUDPClient.Send('R', PlayerManagement.GetPlayer(toonName));
            }

            toonName = fileSplit[fileSplit.Length - 2];

            //  Open a stream using the changed file.
            FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            //  We need to read in reverse to find the "Welcome to Everquest!" session start key;
            string line = "";

            string[] splitDelim = { "] " };
            string   lookFor    = "You have entered ";

            using (StreamReader sr = new StreamReader(fs))
            {
                while (!sr.EndOfStream)
                {
                    line = sr.ReadLine();
                    if (line == "")
                    {
                        continue;
                    }
                    line = line.Split(splitDelim, StringSplitOptions.None)[1];

                    if (line.StartsWith(lookFor))
                    {
                        zone = line.Remove(0, lookFor.Length);
                        zone = zone.TrimEnd('.');
                    }
                }
                //  Load map based on zone name.
                Invoke(new MethodInvoker(delegate() { LoadMap(); }));
                logMonitorStatus.Text = "Monitor Status: Can't find zone map " + zone;
                fs.Seek(0, SeekOrigin.End);
            }
            PlayerManagement.AddPlayer(toonName, zone);
            PlayerLoggingUDPClient.Send('A', PlayerManagement.GetPlayer(toonName));
        }
Beispiel #4
0
        private void shareLocationBox_Click(object sender, EventArgs e)
        {
            if (!shareLocationBox.Checked)
            {
                //  Connect to server
                string[] hostandport = connectionInfo.Text.Split(':');

                try
                {
                    PlayerLoggingUDPClient.StartClient(hostandport[0], int.Parse(hostandport[1]));
                    shareLocationBox.Checked = true;
                    connectionStatus.Text    = "Connection Status: Connected";

                    if (toonName != null)
                    {
                        if (PlayerManagement.GetPlayer(toonName) != null)
                        {
                            PlayerLoggingUDPClient.Send('A', PlayerManagement.GetPlayer(toonName));
                        }
                    }
                }
                catch (Exception)
                {
                    shareLocationBox.Checked = false;
                    connectionStatus.Text    = "Connection Status: Connection Refused.";
                }
            }
            else
            {
                if (toonName != null)
                {
                    if (PlayerManagement.GetPlayer(toonName) != null)
                    {
                        PlayerLoggingUDPClient.Send('R', PlayerManagement.GetPlayer(toonName));
                    }
                }
                PlayerLoggingUDPClient.StopClient();
                shareLocationBox.Checked = false;
                connectionStatus.Text    = "Connection Status: Disconnected.";
            }
        }