Пример #1
0
        public static void HandleTeleport(Session session, params string[] parameters)
        {
            session.PausePcapPlayback();
            int?teleportID = null;

            if (parameters?.Length > 0)
            {
                // If we fail to get a valid int, we will continue with null (which means "next instance");
                if (int.TryParse(parameters[0], out int teleportIndex))
                {
                    teleportID = teleportIndex;
                }
            }

            bool teleportFound = PCapReader.DoTeleport(teleportID);

            if (teleportFound)
            {
                Console.WriteLine($"Advancing to next teleport session, entry {PCapReader.CurrentPcapRecordStart}");
            }
            else
            {
                Console.WriteLine("Sorry, there were no additional teleport events in this pcap.");
            }
            session.RestartPcapPlayback();
        }
Пример #2
0
        public static void HandlePcapSetLogin(Session session, params string[] parameters)
        {
            if (parameters?.Length != 1)
            {
                if (PCapReader.LoginInstances > 0)
                {
                    Console.WriteLine(
                        $"\n{PCapReader.LoginInstances} unique login events detected. Please specify a login to use using the command 'pcap-login <login-#>', where <login-#> is 1 to {PCapReader.LoginInstances}\n");
                }
                else
                {
                    Console.WriteLine(
                        "\nNo login events detected. We cannot play back this pcap at this time, sorry.\n");
                }

                return;
            }

            if (int.TryParse(parameters[0], out int loginID))
            {
                PCapReader.SetLoginInstance(loginID);
                Console.WriteLine(
                    $"Login instance set. Pcap will play records {PCapReader.StartRecordIndex}  to {PCapReader.EndRecordIndex - 1}");
                Console.WriteLine(
                    $"Instance has {PCapReader.TeleportIndexes[loginID].Count} teleports. Use @teleport in-game to advance to next, or @teleport <index> to select a specific one.");
                PCapReader.GetPcapDuration();
            }
            else
            {
                Console.WriteLine("Unable to set login instance.");
            }
        }
Пример #3
0
        public static void HandleLoadPcap(Session session, params string[] parameters)
        {
            // pcap-load "D:\Asheron's Call\Log Files\PCAP Part 1\AC1Live-The-Ripley-Collection-part01\AC1Live-The-Ripley-Collection\aclog pcaps\pkt_2017-1-9_1484023507_log.pcap"
            // pcap-load "D:\ACE\Logs\PCAP Part 1\AC1Live-The-Ripley-Collection-part01\AC1Live-The-Ripley-Collection\aclog pcaps\pkt_2017-1-9_1484023507_log.pcap"

            string pcapFileName;

            if (parameters?.Length != 1)
            {
                Console.WriteLine("pcap-load <full-path-to-pcap-file>");
                return;
            }

            pcapFileName = parameters[0];

            // Check if file exists!
            if (!System.IO.File.Exists(pcapFileName))
            {
                Console.WriteLine($"Could not find pcap file to load: {pcapFileName}");
                return;
            }

            bool abort = false;

            Console.WriteLine($"Loading pcap...");

            //List<PacketRecord> records = PCapReader.LoadPcap(pcapFileName, true, ref abort);
            PCapReader.LoadPcap(pcapFileName, true, ref abort);

            Console.WriteLine($"Pcap Loaded with {PCapReader.Records.Count} records.");

            if (PCapReader.LoginInstances > 0)
            {
                Console.WriteLine($"\n{PCapReader.LoginInstances} unique login events detected.");
                if (PCapReader.LoginInstances > 1)
                {
                    Console.WriteLine(
                        $"Please specify a login to use using the command 'pcap-login <login-#>', where <login-#> is 1 to {PCapReader.LoginInstances}\n");
                }
                Console.WriteLine("Login set to first instance.");
                Console.WriteLine(
                    $"Instance has {PCapReader.TeleportIndexes[1].Count} teleports. Use @teleport in-game to advance to next, or @teleport <index> to select a specific one.");

                Console.WriteLine($"StartRecordIndex: {PCapReader.StartRecordIndex}");
                Console.WriteLine($"EndRecordIndex: {(PCapReader.EndRecordIndex - 1)}");
            }
            else
            {
                Console.WriteLine(
                    "\nNo login events detected. We will attempt to join this pcap already in progress.\n");
                Console.WriteLine(
                    $"Instance has {PCapReader.TeleportIndexes[0].Count} teleports. Use @teleport in-game to advance to next, or @teleport <index> to select a specific one.");
            }

            Console.WriteLine("");
        }
Пример #4
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.ProcessExit        += new EventHandler(OnProcessExit);

            // Init our text encoding options. This will allow us to use more than standard ANSI text, which the client also supports.
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

            var logRepository = LogManager.GetRepository(System.Reflection.Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));

            // Do system specific initializations here
            try
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    // On many windows systems, the default resolution for Thread.Sleep is 15.6ms. This allows us to command a tighter resolution
                    MM_BeginPeriod(1);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }

            Console.WriteLine("Starting PCAP Player...");
            Console.Title = @"PCAP Player";

            Console.WriteLine("Initializing ConfigManager...");
            ConfigManager.Initialize();

            Console.WriteLine("Initializing ServerManager...");
            ServerManager.Initialize();

            //log.Info("Initializing DatManager...");
            //DatManager.Initialize(ConfigManager.Config.Server.DatFilesDirectory, true);

            //log.Info("Initializing DatabaseManager...");
            //DatabaseManager.Initialize();

            //log.Info("Starting DatabaseManager...");
            //DatabaseManager.Start();

            Console.WriteLine("Starting PropertyManager...");
            PropertyManager.Initialize();

            //log.Info("Initializing GuidManager...");
            //GuidManager.Initialize();

            //log.Info("Precaching World Database Disabled...");

            Console.WriteLine("Initializing PlayerManager...");
            PlayerManager.Initialize();

            //log.Info("Initializing HouseManager...");
            //HouseManager.Initialize();

            Console.WriteLine("Initializing InboundMessageManager...");
            InboundMessageManager.Initialize();

            Console.WriteLine("Initializing SocketManager...");
            SocketManager.Initialize();

            Console.WriteLine("Initializing WorldManager...");
            WorldManager.Initialize();

            Console.WriteLine("Initializing PCapReader...");
            PCapReader.Initialize();

            log.Info("Initializing EventManager...");
            EventManager.Initialize();

            WorldManager.Open(null);

            // This should be last
            Console.WriteLine("Initializing CommandManager...");
            CommandManager.Initialize();
        }
Пример #5
0
        public static void HandleLoadPcap(Session session, params string[] parameters)
        {
            // pcap-load "D:\Asheron's Call\Log Files\PCAP Part 1\AC1Live-The-Ripley-Collection-part01\AC1Live-The-Ripley-Collection\aclog pcaps\pkt_2017-1-9_1484023507_log.pcap"
            // pcap-load "D:\ACE\Logs\PCAP Part 1\AC1Live-The-Ripley-Collection-part01\AC1Live-The-Ripley-Collection\aclog pcaps\pkt_2017-1-9_1484023507_log.pcap"

            string pcapFileName;

            if (parameters?.Length != 1)
            {
                Console.WriteLine("pcap-load <full-path-to-pcap-file>");
                return;
            }

            pcapFileName = parameters[0];

            // Check if file exists!
            if (!System.IO.File.Exists(pcapFileName))
            {
                Console.WriteLine($"Could not find pcap file to load: {pcapFileName}");
                return;
            }

            bool abort = false;

            Console.WriteLine($"Loading pcap...");

            //List<PacketRecord> records = PCapReader.LoadPcap(pcapFileName, true, ref abort);
            PCapReader.LoadPcap(pcapFileName, true, ref abort);

            Console.WriteLine($"Pcap Loaded with {PCapReader.Records.Count} records.");

            if (PCapReader.LoginInstances > 0)
            {
                Console.WriteLine($"\n{PCapReader.LoginInstances} unique login events detected.");
                if (PCapReader.LoginInstances > 1)
                {
                    Console.WriteLine($"Please specify a login to use using the command 'pcap-login <login-#>', where <login-#> is 1 to {PCapReader.LoginInstances}\n");
                }
                Console.WriteLine("Login set to first instance.");

                if (PCapReader.TeleportIndexes.ContainsKey(1))
                {
                    Console.WriteLine($"Instance has {PCapReader.TeleportIndexes[1].Count} teleports. Use @teleport in-game to advance to next, or @teleport <index> to select a specific one.");
                    Console.WriteLine($"\nUse `list` to display a detailed breackdown of all login instances and teleports.\n");
                }
                else
                {
                    Console.WriteLine($"Instance has no teleports.");
                }

                Console.WriteLine($"StartRecordIndex: {PCapReader.StartRecordIndex}");
                Console.WriteLine($"EndRecordIndex: {(PCapReader.EndRecordIndex - 1)}");
            }
            else
            {
                Console.WriteLine("\nNo login events detected. We will attempt to join this pcap already in progress.\n");
                if (PCapReader.TeleportIndexes.ContainsKey(0))
                {
                    Console.WriteLine($"Instance has {PCapReader.TeleportIndexes[0].Count} teleports. Use @teleport in-game to advance to next, or @teleport <index> to select a specific one.");
                    Console.WriteLine($"\nUse `list` to display a detailed breackdown of teleports.\n");
                }
                else
                {
                    Console.WriteLine($"Instance has no teleports.");
                }
            }

            var port = Common.ConfigManager.Config.Server.Network.Port;

            Console.WriteLine($"\nTo connect, enter the following command at the Command Prompt in your Asheron's Call folder, or use a launcher to connect using any username and password combination.\n\n    acclient.exe -h 127.0.0.1:{port} -a USER -v PASS\n");
        }
Пример #6
0
        public static void HandleTeleportList(Session session, params string[] parameters)
        {
            if (PCapReader.PcapMarkers.Count > 0)
            {
                Console.WriteLine("Help: [Type] [instance], [pcap line number], [timespan from login HH:MM:ss] - [Approx Location]");
                DungeonList dungeons      = new DungeonList();
                var         teleportIndex = 0;
                for (var i = 0; i < PCapReader.PcapMarkers.Count; i++)
                {
                    var pcapMarker = PCapReader.PcapMarkers[i];
                    var line       = pcapMarker.LineNumber;

                    CM_Movement.Position?pos;
                    if ((i + 1) < PCapReader.PcapMarkers.Count)
                    {
                        pos = PCapReader.GetDetailedLocationInfo(line, PCapReader.PcapMarkers[i + 1].LineNumber);
                    }
                    else
                    {
                        pos = PCapReader.GetDetailedLocationInfo(line, PCapReader.EndRecordIndex);
                    }

                    // Set default as "unknown"
                    string loc = "Unable to determine location.";
                    if (pos != null)
                    {
                        // convert the "Position" to a "Position"
                        var acePos = new Position(
                            pos.objcell_id,
                            new System.Numerics.Vector3(pos.x, pos.y, pos.z),
                            new System.Numerics.Quaternion(pos.qw, pos.qx, pos.qy, pos.qz)
                            );
                        var coords = Entity.PositionExtensions.GetMapCoordStr(acePos);
                        if (coords != null)
                        {
                            loc = coords;
                        }
                        else
                        {
                            // Are we in a dungeon?
                            if ((pos.objcell_id & 0xFFFF) >= 0x100)
                            {
                                var landblock = pos.objcell_id >> 16;
                                loc = $"Unable to determine dungeon location (0x{landblock:X4}).";
                                string dungeonName = dungeons.GetDungeonName(landblock);
                                if (dungeonName != "")
                                {
                                    loc = dungeonName;
                                }
                            }
                        }
                    }


                    switch (pcapMarker.Type)
                    {
                    case MarkerType.Login:
                        //Console.WriteLine($"Login/Initial Position: {loc}");
                        Console.WriteLine($"Player Login {pcapMarker.LoginInstance}, line {pcapMarker.LineNumber} - {loc}");
                        teleportIndex = 1;
                        break;

                    case MarkerType.Teleport:
                        string time = PCapReader.GetPcapTime(pcapMarker);
                        Console.WriteLine($"  Teleport {teleportIndex++}, line {pcapMarker.LineNumber}, {time} - {loc}");
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine("Sorry, there are no login or teleport events in this pcap.");
            }
            Console.WriteLine();
        }