public static void SubPasswordDelRequest(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            packet.Skip(4);
            var pass = packet.ReadString(10).Trim('\0');

            var syncServer = client.Metadata["syncServer"] as SyncReceiver;
            var checksub   = SubpassManagement.CheckSubPw(syncServer, client.AccountID, pass);

            var tries = 0;

            builder.New(0x410);
            {
                if (checksub)
                {
                    client.Metadata["subTries"] = 0;
                    builder += 1;          // success
                    builder += (byte)0x00; // failed times
                }
                else
                {
                    client.Metadata["subTries"] = (int)client.Metadata["subTries"] + 1;
                    tries    = (int)client.Metadata["subTries"];
                    builder += 0;           // failed
                    builder += (byte)tries; // failed times
                }
                builder += 1;
            }

            client.Send(builder, "SubPasswordDelRequest");

            if ((int)client.Metadata["subTries"] > 3)
            {
                client.Disconnect();
            }
        }
Example #2
0
        public static void SubPasswordSet(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var pass = packet.ReadString(10).Trim('\0');

            packet.Skip(5);
            var question = packet.ReadInt();
            var answer   = packet.ReadString(16).Trim('\0');

            packet.Skip(112);
            var changeSub = packet.ReadInt();

            var syncServer = client.Metadata["syncServer"] as SyncReceiver;

            if (changeSub == 0)
            {
                SubpassManagement.SetSubPass(syncServer, client.AccountID, pass, question, answer);
            }
            else
            {
                SubpassManagement.SetSubPass(syncServer, client.AccountID, pass, -1, string.Empty);
            }

            builder.New(0x406);
            {
                builder += 1;
                builder += 0;
                builder += 1;
                builder += 0;
            }

            SubpassManagement.SetSubPassTime(syncServer, client.AccountID, 0);
            client.Send(builder, "SubPasswordSet");
        }
Example #3
0
        public static void CharacterDeleteCheckSubPassword(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var subpw = packet.ReadString(10).Trim('\0');

            var syncServer = client.Metadata["syncServer"] as SyncReceiver;
            var verify     = SubpassManagement.CheckSubPw(syncServer, client.AccountID, subpw);
            var tries      = 0;

            builder.New(0x870);
            {
                if (verify)
                {
                    client.Metadata["subTries"] = 0;
                    builder += 1;           // success
                    builder += (byte)0;     // failed times
                }
                else
                {
                    client.Metadata["subTries"] = (int)client.Metadata["subTries"] + 1;
                    tries    = (int)client.Metadata["subTries"];
                    builder += 0;           // failed
                    builder += (byte)tries; // failed times
                }
            }

            client.Send(builder, "CharacterDeleteCheckSubPassword");

            if ((int)client.Metadata["subTries"] > 3)
            {
                client.Disconnect();
            }
        }
Example #4
0
        public static void SubPasswordDel(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var syncServer = client.Metadata["syncServer"] as SyncReceiver;

            SubpassManagement.RemoveSubPass(syncServer, client.AccountID);

            builder.New(0x412);
            {
                builder += 1;
                builder += 1;
            }

            client.Send(builder, "SubPasswordDel");
        }
        public static void SubPasswordFindRequest(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var syncServer = client.Metadata["syncServer"] as SyncReceiver;

            var questionID = SubpassManagement.GetSubPassQuestion(syncServer, client.AccountID);

            builder.New(0x40C);
            {
                builder += questionID;
                builder += questionID;
                builder += 1;
            }

            client.Send(builder, "SubPasswordFindRequest");
        }
        public static void SubPasswordChangeQA(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            packet.Skip(4);
            var question = packet.ReadInt();
            var answer   = packet.ReadString(16).Trim('\0');

            var syncServer = client.Metadata["syncServer"] as SyncReceiver;

            SubpassManagement.SetSubPass(syncServer, client.AccountID, string.Empty, question, answer);

            builder.New(0x416);
            {
                builder += 1;
                builder += 1;
            }

            client.Send(builder, "SubPasswordChangeQA");
        }
Example #7
0
        public static void SubPasswordCheckRequest(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var syncServer = client.Metadata["syncServer"] as SyncReceiver;

            var subpass = SubpassManagement.GetSubPassTime(syncServer, client.AccountID);

            builder.New(0x408);
            {
                if (subpass)
                {
                    builder += 0;   // dont need verification
                }
                else
                {
                    builder += 1;   // need verification
                }
            }

            client.Send(builder, "SubPasswordCheckRequest");
        }
Example #8
0
        public static void GetCharacters(PacketReader packet, PacketBuilder builder, ClientHandler client, EventHandler events)
        {
            var server     = (int)client.Metadata["server"];
            var syncServer = client.Metadata["syncServer"] as SyncReceiver;
            var id         = Authentication.GetUser(syncServer, (ulong)client.Metadata["magic"]);


            if (id <= 0)
            {
                client.Disconnect();
                Log.Notice("Client disconnected!");
                return;
            }


            client.AccountID = id;

            var characters = CharacterManagement.GetCharacters(syncServer, server, id);
            var subpass    = SubpassManagement.GetSubpass(syncServer, id);
            var slotorder  = CharacterManagement.GetSlotOrder(syncServer, server, id);

            if (slotorder == -1)
            {
                slotorder = 0x00123456;
            }

            client.Metadata["slotorder"] = slotorder;

            builder.New(0x85);
            {
                if (!subpass)
                {
                    builder += 0;   // not exist
                }
                else
                {
                    builder += 1;   // exists
                }
                builder += new byte[9];
                builder += (byte)1;
                builder += 0;       // selected char id
                builder += slotorder;
                builder += 8;       //open 7th and 8th slot

                for (int i = 0; i < characters.Length; i++)
                {
                    var charId = characters[i].id;
                    var style  = (uint)characters[i]._class;
                    style += (uint)(characters[i].face << 8);
                    style += (uint)(characters[i].colour << 13);
                    style += (uint)(characters[i].hair << 17);
                    style += (!characters[i].gender) ? 0 : (uint)(1 << 26);

                    TimeSpan date = (characters[i].created - new DateTime(1970, 1, 1, 0, 0, 0));

                    var eq        = characters[i].equipment;
                    int head      = (eq.head != null) ? (int)(BitConverter.ToUInt32(eq.head, 0) + (eq.head[0x02] * 0x2000)) : (ushort)0;
                    int body      = (eq.body != null) ? (int)(BitConverter.ToUInt32(eq.body, 0) + (eq.body[0x02] * 0x2000)) : (ushort)0;
                    int hands     = (eq.hands != null) ? (int)(BitConverter.ToUInt32(eq.hands, 0) + (eq.hands[0x02] * 0x2000)) : (ushort)0;
                    int feet      = (eq.feet != null) ? (int)(BitConverter.ToUInt32(eq.feet, 0) + (eq.feet[0x02] * 0x2000)) : (ushort)0;
                    int righthand = (eq.righthand != null) ? (int)(BitConverter.ToUInt32(eq.righthand, 0) + (eq.righthand[0x02] * 0x2000)) : (ushort)0;
                    int lefthand  = (eq.lefthand != null) ? (int)(BitConverter.ToUInt32(eq.lefthand, 0) + (eq.lefthand[0x02] * 0x2000)) : (ushort)0;
                    int back      = (eq.back != null) ? (int)(BitConverter.ToUInt32(eq.back, 0) + (eq.back[0x02] * 0x2000)) : (ushort)0;

                    builder += charId;
                    builder += (long)date.TotalSeconds;     // created
                    builder += style;
                    builder += characters[i].level;
                    builder += 1;
                    builder += 0;
                    builder += 0;
                    builder += (byte)0;
                    builder += characters[i].map;
                    builder += (ushort)characters[i].x;
                    builder += (ushort)characters[i].y;

                    builder += (long)head;
                    builder += (long)0;
                    builder += (long)body;
                    builder += (long)0;
                    builder += (long)hands;
                    builder += (long)0;
                    builder += (long)feet;
                    builder += (long)0;
                    builder += (long)righthand;
                    builder += (long)0;
                    builder += (long)lefthand;
                    builder += (long)0;
                    builder += (long)back;
                    builder += (long)0;

                    builder += new byte[588];

                    builder += (byte)(characters[i].name.Length + 1);
                    builder += characters[i].name;
                    builder += 0;
                    builder += 0;
                    builder += (byte)0;
                }
            }

            client.Send(builder, "GetMyChartr");
            Authentication.UpdateOnline(syncServer, id, true);
        }