Beispiel #1
0
        static public void OnReceive(PacketIn packet)
        {
            lock (packet)
            {
                packet.Size   = packet.GetUint32();
                packet.Opcode = packet.GetUint8();

                Handle(packet);
            }
        }
Beispiel #2
0
        public static void OnReceive(PacketIn packet)
        {
            lock (packet)
            {
                packet.Size   = packet.GetUint32();
                packet.Opcode = packet.GetUint8();
                _logger.Debug($"OnReceive Packet size : {packet.Size} opCode : {packet.Opcode}");

                Handle(packet);
            }
        }
Beispiel #3
0
        public static void Handle(PacketIn packet)
        {
            if (!Enum.IsDefined(typeof(Opcodes), (byte)packet.Opcode))
            {
                Print($"Invalid opcode : {packet.Opcode.ToString("X02")}");
                return;
            }

            _logger.Trace($"HandlePacket{packet}");

            switch ((Opcodes)packet.Opcode)
            {
            case Opcodes.LCR_CHECK:

                byte Result = packet.GetUint8();

                switch ((CheckResult)Result)
                {
                case CheckResult.LAUNCHER_OK:
                    Start();
                    break;

                case CheckResult.LAUNCHER_VERSION:
                    string Message = packet.GetString();
                    Print(Message);
                    Close();
                    break;

                case CheckResult.LAUNCHER_FILE:

                    string File = packet.GetString();
                    byte[] Bt   = Encoding.ASCII.GetBytes(File);

                    FileInfo   Info = new FileInfo("mythloginserviceconfig.xml");
                    FileStream Str  = Info.Create();
                    Str.Write(Bt, 0, Bt.Length);          // Bt is sent from the server (configs/mythloginserviceconfig.xml) - it overwrites the file on the client side.
                    Str.Close();
                    break;
                }
                break;

            case Opcodes.LCR_START:

                ApocLauncher.Acc.ReceiveStart();

                byte response = packet.GetUint8();
                _logger.Debug($"HandlePacket. Response Code : {response}");

                if (response == 1)     //invalud user/pass
                {
                    _logger.Warn($"Invalid User / Pass");
                    ApocLauncher.Acc.sendUI("Invalid User / Pass");

                    return;
                }
                else if (response == 2)     //banned
                {
                    _logger.Warn($"Account is banned");
                    ApocLauncher.Acc.sendUI("Account is banned");

                    return;
                }
                else if (response == 3)     //account not active
                {
                    _logger.Warn($"Account is not active");
                    ApocLauncher.Acc.sendUI("Account is not active");

                    return;
                }
                else if (response > 3)
                {
                    _logger.Error($"Unknown Response");
                    ApocLauncher.Acc.sendUI("Unknown Response");

                    return;
                }
                else
                {
                    authToken = packet.GetString();
                    _logger.Info($"Authentication Token Received : {authToken}");
                    try
                    {
                        var warDirectory = Directory.GetParent(Application.StartupPath);
                        ApocLauncher.Acc.sendUI("Patching..");
                        patchExe();
                        UpdateWarData();
                        ApocLauncher.Acc.sendUI("Patched. Starting WAR.exe");

                        _logger.Info($"Double checking mythlogin file exists.");
                        if (!File.Exists(Application.StartupPath + "\\mythloginserviceconfig.xml"))
                        {
                            _logger.Warn($"{Application.StartupPath + "\\mythloginserviceconfig.xml"} does not exist.");
                            ApocLauncher.Acc.sendUI("Cannot locate mythloginserviceconfig.xml");
                            return;
                        }
                        // Use world.myp to determine whether we are in the correct directory.
                        if (!File.Exists(warDirectory.FullName + "\\world.myp"))
                        {
                            _logger.Warn($"{warDirectory.FullName + "\\world.myp"} does not exist.");
                            ApocLauncher.Acc.sendUI("Is your launcher in the Launcher folder?");
                            return;
                        }

                        _logger.Info($"Starting Client {warDirectory.FullName}\\WAR.exe");

                        if (ApocLauncher.Acc.AllowWarClientLaunch)
                        {
                            Process process = new Process
                            {
                                StartInfo =
                                {
                                    WorkingDirectory = warDirectory.FullName,
                                    FileName         = "WAR.exe",
                                    Arguments        = " --acctname=" + Convert.ToBase64String(Encoding.ASCII.GetBytes(User)) + " --sesstoken=" +
                                                       Convert.ToBase64String(Encoding.ASCII.GetBytes(authToken))
                                }
                            };
                            _logger.Info($"Starting process WAR.exe (in {warDirectory})");
                            process.Start();
                            Directory.SetCurrentDirectory(warDirectory.FullName);
                        }
                        else
                        {
                            _logger.Info($"Not launching WAR.Exe (in {warDirectory}) " + " --acctname=" + Convert.ToBase64String(Encoding.ASCII.GetBytes(User)) + " --sesstoken=" +
                                         Convert.ToBase64String(Encoding.ASCII.GetBytes(authToken)));
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.Info($"Failed to start Client {e.ToString()}");
                        ApocLauncher.Acc.sendUI("Failed to start client.");
                    }
                }

                break;

            case Opcodes.LCR_INFO:
            {
                _logger.Info($"Processing LCR_INFO : Number Realms : {packet.GetUint8()} Name : {packet.GetString()} Parsed : {packet.GetParsedString()}");
            }
            break;

            case Opcodes.LCR_CREATE:

                byte respons = packet.GetUint8();
                _logger.Debug($"HandlePacket. Response Code : {respons}");

                if (respons == 0)     //invalud user/pass
                {
                    _logger.Warn($"Account Name busy!");
                    ApocLauncher.Acc.sendUI("Account Name busy!");

                    return;
                }
                else if (respons == 1)     //success
                {
                    _logger.Warn($"Account created!");
                    ApocLauncher.Acc.sendUI("Account created!");
                    return;
                }
                else if (respons == 2)     //banned
                {
                    _logger.Warn($"Account is banned!");
                    ApocLauncher.Acc.sendUI("Account is banned!");

                    return;
                }


                break;
            }
        }
Beispiel #4
0
        public static void OnReceive(PacketIn packet)
        {
            lock (packet)
            {
                packet.Size = packet.GetUint32();
                packet.Opcode = packet.GetUint8();

                Handle(packet);
            }
        }
Beispiel #5
0
        public static void Handle(PacketIn packet)
        {
            if(!Enum.IsDefined(typeof(Opcodes),(byte)packet.Opcode))
            {
                Print("Invalid opcode : " + packet.Opcode.ToString("X02"));
                return;
            }

            switch((Opcodes)packet.Opcode)
            {
                case Opcodes.LCR_CHECK:

                    byte Result = packet.GetUint8();

                    switch((CheckResult)Result)
                    {
                        case CheckResult.LAUNCHER_OK:
                            Start();
                            break;
                        case CheckResult.LAUNCHER_VERSION:
                            string Message = packet.GetString();
                            Print(Message);
                            Close();
                            break;
                        case CheckResult.LAUNCHER_FILE:

                            string File = packet.GetString();
                            byte[] Bt = ASCIIEncoding.ASCII.GetBytes(File);

                            FileInfo Info = new FileInfo("mythloginserviceconfig.xml");
                            FileStream Str = Info.Create();
                            Str.Write(Bt, 0, Bt.Length);
                            Str.Close();
                            break;
                    }
                    break;

                case Opcodes.LCR_START:

                    Accueil.Acc.ReceiveStart();

                    byte Res = packet.GetUint8();

                    if (Res >= 1)
                    {
                        Print("Error : wrong account !\n\r");
                        return;
                    }
                    else
                    {
                        Auth = packet.GetString();
                        Print("Lancement avec : " + Auth);
                        try
                        {
                            // Je Fawk | 13 April 2014 | Modified to game folder path taken from from Accueil
                            string CurrentDir = Accueil.pathToGameFolder;
                            #region Old code
                            //string CurrentDir = Directory.GetCurrentDirectory();
                            #endregion Old code
                            patchExe();
                            UpdateWarData();
                            Process Pro = new Process();
                            Pro.StartInfo.FileName = "WAR.exe";
                            Pro.StartInfo.Arguments = " --acctname=" + System.Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(User)) + " --sesstoken=" + System.Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(Auth));
                            Pro.Start();
                            Directory.SetCurrentDirectory(CurrentDir);
                        }
                        catch (Exception e)
                        {
                            Print(e.ToString());
                        }
                    }

                    break;

                case Opcodes.LCR_INFO:
                    {
                        Accueil.Acc.ClearRealms();
                        byte RealmsCount = packet.GetUint8();
                        for (byte i = 0; i < RealmsCount; ++i)
                        {
                            bool Online = packet.GetUint8() > 0;
                            string Name = packet.GetString();
                            UInt32 OnlinePlayers = packet.GetUint32();
                            UInt32 OrderCount = packet.GetUint32();
                            UInt32 DestructionCount = packet.GetUint32();

                            Accueil.Acc.AddRealm(Name, Online, OnlinePlayers, DestructionCount, DestructionCount);

                        }
                    }break;
            }
        }
Beispiel #6
0
        static public void Handle(PacketIn packet)
        {
            if (!Enum.IsDefined(typeof(Opcodes), (byte)packet.Opcode))
            {
                Print("Invalid opcode : " + packet.Opcode.ToString("X02"));
                return;
            }

            switch ((Opcodes)packet.Opcode)
            {
            case Opcodes.LCR_CHECK:

                byte Result = packet.GetUint8();

                switch ((CheckResult)Result)
                {
                case CheckResult.LAUNCHER_OK:
                    Start();
                    break;

                case CheckResult.LAUNCHER_VERSION:
                    string Message = packet.GetString();
                    Print(Message);
                    Close();
                    break;

                case CheckResult.LAUNCHER_FILE:

                    string File = packet.GetString();
                    byte[] Bt   = ASCIIEncoding.ASCII.GetBytes(File);

                    FileInfo   Info = new FileInfo("mythloginserviceconfig.xml");
                    FileStream Str  = Info.Create();
                    Str.Write(Bt, 0, Bt.Length);
                    Str.Close();
                    break;
                }
                break;

            case Opcodes.LCR_START:

                Accueil.Acc.ReceiveStart();

                byte Res = packet.GetUint8();

                if (Res >= 1)
                {
                    Print("Error : wrong account !\n\r");
                    return;
                }
                else
                {
                    Auth = packet.GetString();
                    Print("Lancement avec : " + Auth);
                    try
                    {
                        string CurrentDir = Directory.GetCurrentDirectory();
                        patchExe();
                        UpdateWarData();
                        Process Pro = new Process();
                        Pro.StartInfo.FileName  = "WAR.exe";
                        Pro.StartInfo.Arguments = " --acctname=" + System.Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(User)) + " --sesstoken=" + System.Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(Auth));
                        Pro.Start();
                        Directory.SetCurrentDirectory(CurrentDir);
                    }
                    catch (Exception e)
                    {
                        Print(e.ToString());
                    }
                }

                break;

            case Opcodes.LCR_INFO:
            {
                Accueil.Acc.ClearRealms();
                byte RealmsCount = packet.GetUint8();
                for (byte i = 0; i < RealmsCount; ++i)
                {
                    bool   Online           = packet.GetUint8() > 0;
                    string Name             = packet.GetString();
                    UInt32 OnlinePlayers    = packet.GetUint32();
                    UInt32 OrderCount       = packet.GetUint32();
                    UInt32 DestructionCount = packet.GetUint32();

                    Accueil.Acc.AddRealm(Name, Online, OnlinePlayers, DestructionCount, DestructionCount);
                }
            } break;
            }
        }
Beispiel #7
0
        public static void Handle(PacketIn packet)
        {
            if (!Enum.IsDefined(typeof(Opcodes), (byte)packet.Opcode))
            {
                Print("Invalid opcode : " + packet.Opcode.ToString("X02"));
                return;
            }

            _logger.Debug($"HandlePacket{packet}");

            switch ((Opcodes)packet.Opcode)
            {
            case Opcodes.LCR_CHECK:

                byte Result = packet.GetUint8();

                switch ((CheckResult)Result)
                {
                case CheckResult.LAUNCHER_OK:
                    Start();
                    break;

                case CheckResult.LAUNCHER_VERSION:
                    string Message = packet.GetString();
                    Print(Message);
                    Close();
                    break;

                case CheckResult.LAUNCHER_FILE:

                    string File = packet.GetString();
                    byte[] Bt   = Encoding.ASCII.GetBytes(File);

                    FileInfo   Info = new FileInfo("mythloginserviceconfig.xml");
                    FileStream Str  = Info.Create();
                    Str.Write(Bt, 0, Bt.Length);          // Bt is sent from the server (configs/mythloginserviceconfig.xml) - it overwrites the file on the client side.
                    Str.Close();
                    break;
                }
                break;

            case Opcodes.LCR_START:

                Accueil.Acc.ReceiveStart();

                byte response = packet.GetUint8();
                _logger.Debug($"HandlePacket. Response Code : {response}");

                if (response == 1)     //invalud user/pass
                {
                    _logger.Warn($"Invalid User / Pass");
                    Accueil.Acc.statusStrip1.Items[1].Text = $@"Invalid User / Pass";
                    return;
                }
                else if (response == 2)     //banned
                {
                    _logger.Warn($"Account is banned");
                    Accueil.Acc.statusStrip1.Items[1].Text = $@"Account is banned";
                    return;
                }
                else if (response == 3)     //account not active
                {
                    _logger.Warn($"Account is not active");
                    Accueil.Acc.statusStrip1.Items[1].Text = $@"Account is not active";
                    return;
                }
                else if (response > 3)
                {
                    _logger.Error($"Unknown Response");
                    Accueil.Acc.statusStrip1.Items[1].Text = $@"Unknown Response";
                    return;
                }
                else
                {
                    authToken = packet.GetString();
                    _logger.Info($"Authentication Token Received : {authToken}");
                    Accueil.Acc.statusStrip1.Items[1].Text = $@"Starting Client..";
                    try
                    {
                        string CurrentDir = Directory.GetCurrentDirectory();
                        patchExe();
                        UpdateWarData();

                        _logger.Info($"Starting Client {CurrentDir}\\WAR.exe");

                        Process Pro = new Process();
                        Pro.StartInfo.FileName  = "WAR.exe";
                        Pro.StartInfo.Arguments = " --acctname=" + Convert.ToBase64String(Encoding.ASCII.GetBytes(User)) + " --sesstoken=" + Convert.ToBase64String(Encoding.ASCII.GetBytes(authToken));
                        _logger.Info($"Starting process WAR.exe");
                        Pro.Start();
                        Directory.SetCurrentDirectory(CurrentDir);
                    }
                    catch (Exception e)
                    {
                        _logger.Info($"Failed to start Client {e.ToString()}");
                        Print(e.ToString());
                    }
                }

                break;

            case Opcodes.LCR_INFO:
            {
                _logger.Info($"Processing LCR_INFO : Number Realms : {packet.GetUint8()} Name : {packet.GetString()} Parsed : {packet.GetParsedString()}");

                //Accueil.Acc.ClearRealms();
                //byte RealmsCount = packet.GetUint8();
                //for (byte i = 0; i < RealmsCount; ++i)
                //{
                //    bool Online = packet.GetUint8() > 0;
                //    string Name = packet.GetString();
                //    uint OnlinePlayers = packet.GetUint32();
                //    uint OrderCount = packet.GetUint32();
                //    uint DestructionCount = packet.GetUint32();

                //    //Accueil.Acc.AddRealm(Name, Online, OnlinePlayers, OrderCount, DestructionCount);

                //}
            } break;
            }
        }