Exemple #1
0
        public static void F_DELETE_NAME(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            string CharName = packet.GetString(30);
            string UserName = packet.GetString(20);

            byte Bad = 0;

            if (CharName.Length < 3 || CharMgr.NameIsUsed(CharName) || !System.Text.RegularExpressions.Regex.IsMatch(CharName, @"^[a-zA-Z]+$"))
            {
                Bad = 1;
            }

            Log.Debug("F_DELETE_NAME", "Bad=" + Bad + ",Name=" + CharName);

            PacketOut Out = new PacketOut((byte)Opcodes.F_CHECK_NAME, 54);

            Out.FillString(CharName, 30);
            Out.FillString(UserName, 20);
            Out.WriteByte(Bad);
            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(0);
            cclient.SendPacket(Out);
        }
Exemple #2
0
        private PacketOut CreateVersionPacket()
        {
            PacketOut o = new PacketOut(10001);

            o.FillString("200701120", 20);
            return(o);
        }
Exemple #3
0
        static public void F_REQUEST_CHAR(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            cclient.State = (int)eClientState.CharScreen;

            UInt16 Operation = packet.GetUint16();

            if (Operation == 0x2D58)
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_REQUEST_CHAR_ERROR);
                Out.WriteByte((byte)CharMgr.GetAccountRealm(cclient._Account.AccountId));
                cclient.SendTCP(Out);
            }

            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_REQUEST_CHAR_RESPONSE);


                Out.FillString(cclient._Account.Username, 25); // account name
                Out.WriteByte(0xFF);
                Out.WriteByte(CharMgr.MAX_SLOT);               // Max characters 20
                Out.WriteUInt16(0);                            // unk
                Out.WriteByte(0);                              // name changing tokens, 1 will enable button
                Out.WriteUInt16(0);                            //unk

                byte[] Chars = CharMgr.BuildCharactersList(cclient._Account.AccountId);
                Out.Write(Chars, 0, Chars.Length);
                cclient.SendTCP(Out);
            }
        }
Exemple #4
0
        /// <summary>
        /// Lets the server know that you want the character list
        /// </summary>
        /// <returns>Nothing</returns>
        private PacketOut CreateCharacterListPacket()
        {
            PacketOut o = new PacketOut(2001);

            o.FillString(m_szAccount, 61);
            o.FinalizeLengthAndChecksum();
            return(o);
        }
Exemple #5
0
        private PacketOut CreateVersionPacket()
        {
            PacketOut o = new PacketOut(51);

            o.FillString("200701120", 20);
            o.FinalizeLengthAndChecksum();
            return(o);
        }
Exemple #6
0
        public PacketIn ProcessPacket(TCPConnection con, byte[] buf, int start, int size)
        {
            PacketIn packet = new PacketIn(buf, start, size);

            switch (packet.ID)
            {
            case 72:     // TS_AC_AES_KEY_IV
                var pAES = new AUTH_PACKETS.AES_KEY_IV(packet);
                m_pAES_KEY = m_cRSA.PrivateDecrypt(pAES.nKey, OpenSSL.Crypto.RSA.Padding.PKCS1);
                GenerateLoginPacket(m_pAES_KEY, con);
                break;

            case 10000:     // TS_AC_RESULT
                var pResult = new AUTH_PACKETS.RESULT(packet.ReadUInt16(), packet.ReadUInt16(), packet.ReadInt32());
                if (pResult.nLoginFlag == 1)
                {
                    PacketOut o = new PacketOut(10021);
                    con.SendTCP(o);
                }
                else
                {
                    m_cAuthConnection.Disconnect();
                    XLog.Log("Login failed. Result: {0} - Disconnecting...", pResult.nResult);
                }
                m_szPassword = string.Empty;
                break;

            case 10022:     // TS_AC_SERVER_LIST
                m_iAuthServerList = new AUTH_PACKETS.SERVER_LIST(packet);
                XLog.Log("Server selection. Please use /select ID to connect to one of the listed servers below.");
                for (int i = 0; i < m_iAuthServerList.count; i++)
                {
                    XLog.Log(string.Format("-> Server {0}: {1}", i + 1, m_iAuthServerList.list[i].server_name));
                }
                break;

            case 10024:     // TS_AC_SELECT_SERVER
                con.Disconnect();

                var pSelectServer = new AUTH_PACKETS.SELECT_SERVER(packet, ref m_pAES_KEY);

                Config.ConfigNet conf = new Config.ConfigNet();
                conf.Port     = m_iAuthServerList.list[m_nSelectedServerIdx].server_port;
                conf.ListenIp = System.Net.IPAddress.Parse(m_iAuthServerList.list[m_nSelectedServerIdx].server_ip);

                PacketOut oEncrypt = new PacketOut(2005);
                oEncrypt.FillString(m_szName, 61);
                oEncrypt.Write(pSelectServer.encrypted_data, 0, pSelectServer.encrypted_data.Length);
                oEncrypt.FinalizeLengthAndChecksum();
                con.Close();
                m_cClientBase.CreateGameServerSession(oEncrypt, conf, m_szName);
                break;

            default:
                break;
            }
            return(packet);
        }
Exemple #7
0
        private PacketOut CreateAESPacket()
        {
            PacketOut o = new PacketOut(71);

            m_cRSA = new OpenSSL.Crypto.RSA();
            m_cRSA.GenerateKeys(1024, 65537, null, null);
            o.WriteInt32(m_cRSA.PublicKeyAsPEM.Length);
            o.FillString(m_cRSA.PublicKeyAsPEM, m_cRSA.PublicKeyAsPEM.Length);
            return(o);
        }
Exemple #8
0
        private void GenerateLoginPacket(byte[] key, TCPConnection con)
        {
            PacketOut o = new PacketOut(10010);
            var       a = EncryptAES(key, m_szPassword);

            o.FillString(m_szName, 61);
            o.WriteInt32(a.Length);
            o.Write(a, 0, a.Length);
            o.Fill(0, 61 - a.Length);
            con.SendTCP(o);
        }
Exemple #9
0
        /// <summary>
        /// Sends a Message in game
        /// </summary>
        /// <param name="szSource">Receiver</param>
        /// <param name="szMsg">Message</param>
        /// <param name="nType">Message Type (whisper, global, advertisment, [...]</param>
        /// <returns></returns>
        public void CreateMessagePacket(string szSource, string szMsg, int nType)
        {
            PacketOut o = new PacketOut(20);

            o.FillString(szSource, 21);
            o.WriteByte(0);
            o.WriteByte((byte)szMsg.Length);
            o.WriteByte((byte)nType);
            o.WriteString(szMsg, szMsg.Length);
            o.FinalizeLengthAndChecksum();
            m_cGameConnection.SendTCP(o);
        }
Exemple #10
0
 /// <summary>
 /// Logs your character into the game
 /// </summary>
 /// <param name="nIndex">Selected Character Index</param>
 /// <returns></returns>
 public void CreateLoginPacket(int nIndex)
 {
     try {
         PacketOut oLogin = new PacketOut(1);
         oLogin.FillString(m_iGameCharacterList.nList[nIndex - 1].szName, 61);
         oLogin.WriteByte((byte)m_iGameCharacterList.nList[nIndex - 1].nRace);
         oLogin.FinalizeLengthAndChecksum();
         m_dHandles.Add(0, m_iGameCharacterList.nList[nIndex - 1].szName);
         m_cGameConnection.SendTCP(oLogin);
         XLog.AddMessage("", "", -5);   // Clear box
     }
     catch (Exception e) {
         XLog.Log("Error while logging in to the server: {0}", e.Message);
     }
 }
Exemple #11
0
        public static void F_REQUEST_CHAR(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            cclient.State = (int)eClientState.CharScreen;

            ushort Operation = packet.GetUint16();

            if (Operation == 0x2D58)
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_REQUEST_CHAR_ERROR, 1);
                Out.WriteByte((byte)CharMgr.GetAccountRealm(cclient._Account.AccountId));
                cclient.SendPacket(Out);
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_REQUEST_CHAR_RESPONSE, 64);
                Out.FillString(cclient._Account.Username, 20);
                Out.WriteUInt32(0); //RemainingLockoutTime
                Out.WriteByte(0);

                if (cclient._Account.GmLevel == 1 && !Program.Config.CreateBothRealms)
                {
                    Out.WriteByte((byte)CharMgr.GetAccountRealm(cclient._Account.AccountId));
                }
                else
                {
                    Out.WriteByte(0);
                }

                Out.WriteByte(CharMgr.MaxSlot); //Maximum Characters you can have
                Out.WriteByte(0);               //GameplayRulesetType
                Out.WriteByte(0);               //LastSwitchedToRealm
                Out.WriteByte(0);               //NumPaidNameChangesAvailable
                Out.WriteByte(0);               // unk

                byte[] Chars = CharMgr.BuildCharacters(cclient._Account.AccountId);
                Out.Write(Chars, 0, Chars.Length);

                cclient.SendPacket(Out);
            }
        }
Exemple #12
0
        static public void F_DELETE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            byte Slot = packet.GetUint8();

            if (cclient._Account == null)
            {
                cclient.Disconnect();
                return;
            }

            CharMgr.RemoveCharacter(Slot, cclient._Account.AccountId);

            PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);

            Out.FillString(cclient._Account.Username, 21);
            Out.Fill(0, 3);
            cclient.SendPacket(Out);
        }
        static public void F_RANDOM_NAME_LIST_INFO(BaseClient client, PacketIn packet)
        {
            GameClient     cclient = client as GameClient;
            RandomNameInfo Info    = BaseClient.ByteToType <RandomNameInfo>(packet);

            Random_name[] Names = CharMgr.GetRandomNames();

            PacketOut Out = new PacketOut((byte)Opcodes.F_RANDOM_NAME_LIST_INFO);

            Out.WriteByte(0);
            Out.WriteByte(Info.Unk);
            Out.WriteByte(Info.Slot);
            Out.WriteUInt16(0);
            Out.WriteByte((byte)Names.Length);

            for (int i = Names.Length - 1; i >= 0; --i)
            {
                Out.FillString(Names[i].Name, Names[i].Name.Length + 1);
            }

            cclient.SendTCP(Out);
        }
Exemple #14
0
        static public void F_REQUEST_CHAR(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            cclient.State = (int)eClientState.CharScreen;

            UInt16 Operation = packet.GetUint16();

            if (Operation == 0x2D58)
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_REQUEST_CHAR_ERROR);
                Out.WriteByte((byte)CharMgr.GetAccountRealm(cclient._Account.AccountId));
                cclient.SendPacket(Out);
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_REQUEST_CHAR_RESPONSE);
                Out.FillString(cclient._Account.Username, 21);
                Out.WriteByte(0);
                Out.WriteByte(0);
                Out.WriteByte(0);
                Out.WriteByte(4);

                if (cclient._Account.GmLevel == 0 && !Program.Config.CreateBothRealms)
                {
                    Out.WriteByte((byte)CharMgr.GetAccountRealm(cclient._Account.AccountId));
                }
                else
                {
                    Out.WriteByte(0);
                }

                byte[] Chars = CharMgr.BuildCharacters(cclient._Account.AccountId);
                Out.Write(Chars, 0, Chars.Length);
                Out.WritePacketLength();
                cclient.SendPacket(Out);
            }
        }
Exemple #15
0
        public byte[] BuildCharacters()
        {
            PacketOut Out = new PacketOut((byte)0);
            Out.Position = 0;
            Out.WriteUInt16(GetCharacterCount());

            Character Char = null;
            for (int i = 0; i < MAX_CHARS; ++i)
            {
                Char = Chars[i];

                if (Char == null)
                    Out.Write(new byte[280], 0, 280);
                else
                {
                    Out.FillString(Char.Name, 48);
                    Out.WriteByte(Char.Info[0].Level);
                    Out.WriteByte(Char.Career);
                    Out.WriteByte(Char.Realm);
                    Out.WriteByte(Char.Sex);
                    Out.WriteByte(Char.ModelId);
                    Out.WriteUInt16(Char.Info[0].ZoneId);
                    Out.Write(new byte[5], 0, 5);

                    Character_items Item = null;
                    for (UInt16 SlotId = 14; SlotId < 30; ++SlotId)
                    {
                        Item = Char.GetItemInSlot(SlotId);
                        if (Item == null)
                            Out.WriteUInt16(0);
                        else
                            Out.WriteUInt16Reverse(Item.ModelId);

                        Out.Write(new byte[6], 0, 6);
                    }

                    Out.Write(new byte[6], 0, 6);

                    for (int j = 0; j < 5; ++j)
                    {
                        Out.Write(new byte[6], 0, 6);
                        Out.WriteUInt16(0xFF00);
                    }

                    for (UInt16 SlotId = 10; SlotId < 13; ++SlotId)
                    {
                        Item = Char.GetItemInSlot(SlotId);
                        Out.WriteUInt16(0);
                        if (Item == null)
                            Out.WriteUInt16(0);
                        else
                            Out.WriteUInt16Reverse(Item.ModelId);
                    }

                    Out.Write(new byte[10], 0, 10);
                    Out.WriteUInt16(0xFF00);
                    Out.WriteByte(0);
                    Out.WriteByte(Char.Race);
                    Out.WriteUInt16(0);
                    Out.Write(Char.bTraits, 0, Char.bTraits.Length);
                    Out.Write(new byte[10], 0, 10);
                }
            }
            return Out.ToArray();
        }
        public static void SendAuctions(Player plr, string searchTerm, string sellerName, byte minLevel, byte maxLevel, byte rarity, byte career, List <byte> types, List <byte> slots, byte stat)
        {
            List <Auction> matching = new List <Auction>();
            List <Auction> toRemove = new List <Auction>();

            int count = 0;

            lock (Auctions)
            {
                foreach (Auction auct in Auctions)
                {
                    if (count < MAX_AUCTIONS_TO_SEND)
                    {
                        if (auct.Item == null)
                        {
                            auct.Item = ItemService.GetItem_Info(auct.ItemId);
                        }

                        if (auct.Item == null || auct.Seller == null)
                        {
                            toRemove.Add(auct);
                            continue;
                        }

                        // Opposite realm
                        if (auct.Realm != 0 && auct.Realm != plr.Info.Realm)
                        {
                            continue;
                        }

                        // Name mismatch
                        if (searchTerm != string.Empty && auct.Item.Name.IndexOf(searchTerm, 0, StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            continue;
                        }

                        // Not from requested seller
                        if (sellerName != string.Empty && (auct.Seller == null || auct.Seller.Name.IndexOf(sellerName, 0, StringComparison.OrdinalIgnoreCase) == -1))
                        {
                            continue;
                        }

                        // Level mismatch
                        if (minLevel != 0 && auct.Item.MinRank < minLevel)
                        {
                            continue;
                        }
                        if (maxLevel != 0 && auct.Item.MinRank > maxLevel)
                        {
                            continue;
                        }

                        // Attribute mismatch
                        if (rarity != 0 && auct.Item.Rarity != Math.Log(rarity, 2))
                        {
                            continue;
                        }
                        if (career != 0 && !plr.ItmInterface.CanUseItemType(auct.Item, 0, career))
                        {
                            continue;
                        }
                        if (types.Count != 0 && !types.Contains(auct.Item.Type))
                        {
                            continue;
                        }
                        if (slots.Count != 0 && !slots.Contains((byte)auct.Item.SlotId))
                        {
                            continue;
                        }
                        if (stat != 0 && !auct.Item._Stats.Keys.Contains(stat))
                        {
                            continue;
                        }

                        matching.Add(auct);
                        count++;
                    }
                    else
                    {
                        break;
                    }
                }

                if (toRemove.Count > 0)
                {
                    foreach (var auct in toRemove)
                    {
                        Auctions.Remove(auct);
                        CharMgr.Database.DeleteObject(auct);
                    }
                }
            }


            PacketOut Out = new PacketOut((byte)Opcodes.F_AUCTION_SEARCH_RESULT, 7 + matching.Count * 300);

            Out.WriteHexStringBytes("0000753400");
            Out.WriteByte((byte)matching.Count);// count
            Out.WriteByte(0x01);

            foreach (Auction auct in matching)
            {
                Out.WriteUInt64(auct.AuctionId); // id
                Out.WriteUInt16(1);              // part of the id?
                Out.WriteUInt16(0xA752);
                Out.WriteUInt32(0);              // unk
                Out.WriteUInt32(auct.SellPrice); // price
                Out.WriteByte(0x03);             // ??
                Out.FillString(auct.Seller == null ? "" : auct.Seller.Name + (auct.Seller.Sex == 1 ? "^F" : "^M"), 48);
                Out.WriteHexStringBytes("880E39");

                Item.BuildItem(ref Out, null, null, new MailItem(auct.ItemId, auct._Talismans, auct.PrimaryDye, auct.SecondaryDye, auct.Count), 0, auct.Count);

                if (plr != null && plr.ItmInterface != null && auct.Item != null && auct.Item.ItemSet != 0)
                {
                    plr.ItmInterface.SendItemSetInfoToPlayer(plr, auct.Item.ItemSet);
                }
            }

            plr.SendPacket(Out);
        }
Exemple #17
0
        public static byte[] BuildCharactersList(int AccountId)
        {
            Log.Debug("BuildCharactersList", "AcocuntId = " + AccountId);
            Character[] Chars = GetAccountChar(AccountId)._Chars;
            int         count = 0;

            PacketOut Out = new PacketOut(0);

            Out.Position = 0;

            Character Char = null;

            for (int k = 0; k < MAX_SLOT; ++k)
            {
                Char = Chars[k];
                if (Char != null)
                {
                    List <Character_items> Items = CharMgr.GetItemChar(Char.CharacterId);

                    /****  char slot start ****/
                    Out.FillString(Char.Name, 48);          // name
                    Out.WriteByte(Char.Value[0].Level);     // Level
                    Out.WriteByte(Char.Career);             //career
                    Out.WriteByte(Char.Realm);              // realm
                    Out.WriteByte(Char.Sex);                // gender
                    Out.WriteUInt16R(Char.ModelId);         //model id
                    Out.WriteUInt16R(Char.Value[0].ZoneId); // zone id
                    Out.Fill(0, 12);                        // unk

                    Character_items Item = null;
                    for (UInt16 SlotId = 14; SlotId < 30; ++SlotId)
                    {
                        Item = Items.Find(item => item != null && item.SlotId == SlotId);

                        if (Item == null)
                        {
                            Out.WriteInt32(0);
                            Out.WriteInt32(0);
                        }
                        else
                        {
                            Out.WriteInt32((int)Item.ModelId);
                            Out.WriteUInt16R(0); // primary dye
                            Out.WriteUInt16R(0); // secondary dye
                        }
                    }
                    Out.WriteUInt32(0x00); // 0x00000000
                    for (int i = 0; i < 4; i++)
                    {
                        Out.WriteUInt32(0xFF000000);
                        Out.WriteUInt32(0x00);
                    }
                    Out.WriteUInt32(0xFF000000);

                    //weapons
                    for (UInt16 SlotId = 10; SlotId < 13; ++SlotId)
                    {
                        Item = Items.Find(item => item != null && item.SlotId == SlotId);

                        if (Item == null)
                        {
                            Out.WriteUInt32(0);
                        }
                        else
                        {
                            Out.WriteUInt16R((ushort)Item.ModelId);
                            Out.WriteUInt16(0);
                        }
                    }
                    Out.Fill(0, 8);
                    Out.WriteUInt16(0xFF00);
                    Out.WriteByte(0);
                    Out.WriteByte(Char.Race); // char slot position
                    Out.WriteUInt16(0x00);    //unk

                    /* //Traits [8 bytes]
                     * Out.WriteByte(1); //face
                     * Out.WriteByte(4); //jewel
                     * Out.WriteByte(4); //scar
                     * Out.WriteByte(0); //hair
                     * Out.WriteByte(3); //hair color
                     * Out.WriteByte(2); //skin color
                     * Out.WriteByte(0); //eye color
                     * Out.WriteByte(5); //metal color
                     */
                    Out.Write(Char.bTraits, 0, Char.bTraits.Length);

                    Out.Fill(0, 14); //unk

                    count++;
                }
            }

            for (int i = 0; i < (MAX_SLOT - count); ++i)
            {
                Out.Write(new byte[284], 0, 284);
            }

            return(Out.ToArray());
        }
Exemple #18
0
        public byte[] BuildCharacters()
        {
            PacketOut Out = new PacketOut((byte)0);

            Out.Position = 0;
            Out.WriteUInt16(GetCharacterCount());

            Character Char = null;

            for (int i = 0; i < MAX_CHARS; ++i)
            {
                Char = Chars[i];

                if (Char == null)
                {
                    Out.Write(new byte[280], 0, 280);
                }
                else
                {
                    Out.FillString(Char.Name, 48);
                    Out.WriteByte(Char.Info[0].Level);
                    Out.WriteByte(Char.Career);
                    Out.WriteByte(Char.Realm);
                    Out.WriteByte(Char.Sex);
                    Out.WriteByte(Char.ModelId);
                    Out.WriteUInt16(Char.Info[0].ZoneId);
                    Out.Write(new byte[5], 0, 5);

                    Character_items Item = null;
                    for (UInt16 SlotId = 14; SlotId < 30; ++SlotId)
                    {
                        Item = Char.GetItemInSlot(SlotId);
                        if (Item == null)
                        {
                            Out.WriteUInt16(0);
                        }
                        else
                        {
                            Out.WriteUInt16Reverse(Item.ModelId);
                        }

                        Out.Write(new byte[6], 0, 6);
                    }

                    Out.Write(new byte[6], 0, 6);

                    for (int j = 0; j < 5; ++j)
                    {
                        Out.Write(new byte[6], 0, 6);
                        Out.WriteUInt16(0xFF00);
                    }

                    for (UInt16 SlotId = 10; SlotId < 13; ++SlotId)
                    {
                        Item = Char.GetItemInSlot(SlotId);
                        Out.WriteUInt16(0);
                        if (Item == null)
                        {
                            Out.WriteUInt16(0);
                        }
                        else
                        {
                            Out.WriteUInt16Reverse(Item.ModelId);
                        }
                    }

                    Out.Write(new byte[10], 0, 10);
                    Out.WriteUInt16(0xFF00);
                    Out.WriteByte(0);
                    Out.WriteByte(Char.Race);
                    Out.WriteUInt16(0);
                    Out.Write(Char.bTraits, 0, Char.bTraits.Length);
                    Out.Write(new byte[10], 0, 10);
                }
            }
            return(Out.ToArray());
        }
Exemple #19
0
        public static byte[] BuildCharacters(int AccountId)
        {
            Log.Debug("BuildCharacters", "AcocuntId = " + AccountId);

            Character[] Chars = GetAccountChar(AccountId)._Chars;
            UInt16      Count = 0;

            // On Compte le nombre de personnages existant du joueur
            for (UInt16 c = 0; c < Chars.Length; ++c)
            {
                if (Chars[c] != null)
                {
                    ++Count;
                }
            }

            PacketOut Out = new PacketOut(0);

            Out.Position = 0;

            Out.WriteByte(MAX_SLOT);
            Out.WriteUInt32(0xFF);
            Out.WriteByte(0x14);

            Character Char = null;

            for (int i = 0; i < MAX_SLOT; ++i)
            {
                Char = Chars[i];

                if (Char == null)
                {
                    Out.Fill(0, 284); // 284
                }
                else
                {
                    List <Character_item> Items = CharMgr.GetItemChar(Char.CharacterId);

                    Out.FillString(Char.Name, 48);
                    Out.WriteByte(Char.Value.Level);
                    Out.WriteByte(Char.Career);
                    Out.WriteByte(Char.Realm);
                    Out.WriteByte(Char.Sex);
                    Out.WriteByte(Char.ModelId);
                    Out.WriteUInt16(Char.Value.ZoneId);
                    Out.Fill(0, 5);

                    Character_item Item = null;
                    for (UInt16 SlotId = 14; SlotId < 30; ++SlotId)
                    {
                        Item = Items.Find(item => item != null && item.SlotId == SlotId);
                        if (Item == null)
                        {
                            Out.WriteUInt32(0);
                        }
                        else
                        {
                            Out.WriteUInt32R(Item.ModelId);
                        }

                        Out.Fill(0, 4);
                    }

                    Out.Fill(0, 6);

                    for (int j = 0; j < 5; ++j)
                    {
                        Out.Fill(0, 6);
                        Out.WriteUInt16(0xFF00);
                    }

                    for (UInt16 SlotId = 10; SlotId < 13; ++SlotId)
                    {
                        Item = Items.Find(item => item != null && item.SlotId == SlotId);
                        Out.WriteUInt16(0);
                        if (Item == null)
                        {
                            Out.WriteUInt16(0);
                        }
                        else
                        {
                            Out.WriteUInt16R((ushort)Item.ModelId);
                        }
                    }


                    Out.Fill(0, 10);
                    Out.WriteUInt16(0xFF00);
                    Out.WriteByte(0);
                    Out.WriteByte(Char.Race);
                    Out.WriteUInt16(0);
                    Out.Write(Char.bTraits, 0, Char.bTraits.Length);
                    Out.Fill(0, 14);// 272
                }
            }
            return(Out.ToArray());
        }
Exemple #20
0
        public static void F_CREATE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;
            CreateInfo Info;

            Info.slot     = packet.GetUint8();
            Info.race     = packet.GetUint8();
            Info.career   = packet.GetUint8();
            Info.sex      = packet.GetUint8();
            Info.model    = packet.GetUint8();
            Info.NameSize = packet.GetUint16();
            packet.Skip(2);

            byte[] traits = new byte[8];
            packet.Read(traits, 0, traits.Length);
            packet.Skip(7);

            string name = packet.GetString(Info.NameSize);

            ushort duplicate = 0;

            for (int i = 0; i < name.Length; i++)
            {
                if (i != 0)
                {
                    if (name[i] == name[i - 1])
                    {
                        duplicate++;
                    }
                    else
                    {
                        duplicate = 0;
                    }

                    if (duplicate > 3)
                    {
                        break;
                    }
                }
            }

            if (name.Length > 2 && !CharMgr.NameIsUsed(name) && CharMgr.AllowName(name) && !CharMgr.NameIsDeleted(name) && duplicate < 3)
            {
                CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career);
                if (CharInfo == null)
                {
                    Log.Error("ON_CREATE", "Can not find career :" + Info.career);
                }
                else
                {
                    //Log.Success("OnCreate", "New Character : " + Name);

                    Character Char = new Character
                    {
                        AccountId    = cclient._Account.AccountId,
                        bTraits      = traits,
                        Career       = Info.career,
                        CareerLine   = CharInfo.CareerLine,
                        ModelId      = Info.model,
                        Name         = name,
                        Race         = Info.race,
                        Realm        = CharInfo.Realm,
                        RealmId      = Program.Rm.RealmId,
                        Sex          = Info.sex,
                        FirstConnect = true
                    };

                    if (!CharMgr.CreateChar(Char))
                    {
                        Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!");
                    }
                    else
                    {
                        List <CharacterInfo_item> Items = CharMgr.GetCharacterInfoItem(Char.CareerLine);

                        foreach (CharacterInfo_item Itm in Items)
                        {
                            if (Itm == null)
                            {
                                continue;
                            }

                            CharacterItem Citm = new CharacterItem
                            {
                                Counts       = Itm.Count,
                                CharacterId  = Char.CharacterId,
                                Entry        = Itm.Entry,
                                ModelId      = Itm.ModelId,
                                SlotId       = Itm.SlotId,
                                PrimaryDye   = 0,
                                SecondaryDye = 0
                            };
                            CharMgr.CreateItem(Citm);
                        }

                        Character_value CInfo = new Character_value
                        {
                            CharacterId = Char.CharacterId,
                            Level       = 1,
                            Money       = 2000,
                            Online      = false,
                            RallyPoint  = CharInfo.RallyPt,
                            RegionId    = CharInfo.Region,
                            Renown      = 0,
                            RenownRank  = 1,
                            RestXp      = 0,
                            Skills      = CharInfo.Skills,
                            Speed       = 100,
                            PlayedTime  = 0,
                            WorldO      = CharInfo.WorldO,
                            WorldX      = CharInfo.WorldX,
                            WorldY      = CharInfo.WorldY,
                            WorldZ      = CharInfo.WorldZ,
                            Xp          = 0,
                            ZoneId      = CharInfo.ZoneId
                        };

                        CharMgr.Database.AddObject(CInfo);
                        Program.AcctMgr.UpdateRealmCharacters(Program.Rm.RealmId, (uint)CharMgr.Database.GetObjectCount <Character>(" Realm=1"), (uint)CharMgr.Database.GetObjectCount <Character>(" Realm=2"));

                        CharacterClientData clientData = new CharacterClientData {
                            CharacterId = Char.CharacterId
                        };
                        CharMgr.Database.AddObject(clientData);

                        Char.Value      = CInfo;
                        Char.ClientData = clientData;

                        PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE, 32);
                        Out.WritePascalString(cclient._Account.Username);
                        cclient.SendPacket(Out);
                    }
                }
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR, 64);
                Out.FillString(cclient._Account.Username, 24);
                Out.WriteStringBytes("You have entered a duplicate or invalid name. Please enter a new name.");
                cclient.SendPacket(Out);
            }
        }