Example #1
0
        static public 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 <= 0 || CharMgr.NameIsUsed(CharName))
            {
                Bad = 1;
            }

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

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

            Out.WriteString(CharName, 30);
            Out.WriteString(UserName, 20);
            Out.WriteByte(Bad);
            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(0);
            cclient.SendTCP(Out);
        }
Example #2
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);
        }
Example #3
0
        static public void F_RENAME_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            packet.Skip(3);

            string OldName = packet.GetString(24);
            string NewName = packet.GetString(24);

            Log.Success("F_RENAME_CHARACTER", "Renaming: '" + OldName + "' To: '" + NewName + "'");

            if (NewName.Length > 2 && !CharMgr.NameIsUsed(NewName))
            {
                Character Char = CharMgr.GetCharacter(OldName);

                if (Char == null || Char.AccountId != cclient._Account.AccountId)
                {
                    Log.Error("CharacterRename", "Hack: Tried to rename character which account dosen't own");
                    cclient.Disconnect();
                    return;
                }

                Char.Name = NewName;
                CharMgr.Database.SaveObject(Char);

                // Wrong response? Perhaps needs to send F_REQUEST_CHAR_RESPONSE again.
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
            else
            {
                // Wrong response?
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
        }
Example #4
0
        static public void F_CREATE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;
            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);

            if (!CharMgr.NameIsUsed(Name))
            {
                CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career);
                if (CharInfo == null)
                {
                    Log.Error("ON_CREATE", "Can not find career :" + Info.career);
                    return;
                }

                Log.Success("OnCreate", "Creating new Character : " + Name);

                Character Char = new Character();
                Char.AccountId  = cclient._Account.AccountId;
                Char.bTraits    = Traits;
                Char.Career     = Info.career;
                Char.CareerLine = CharInfo.CareerLine;
                Char.ModelId    = Info.model;
                Char.Name       = Name;
                Char.Race       = Info.race;
                Char.Realm      = CharInfo.Realm;
                Char.RealmId    = Program.Rm.RealmId;
                Char.Sex        = Info.sex;

                if (!CharMgr.CreateChar(Char))
                {
                    Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!");
                    return;
                }

                Character_items      Citm  = null;
                CharacterInfo_item[] Items = CharMgr.GetCharacterInfoItem(Char.CareerLine);

                for (int i = 0; i < Items.Length; ++i)
                {
                    if (Items[i] == null)
                    {
                        continue;
                    }

                    Citm             = new Character_items();
                    Citm.Counts      = Items[i].Count;
                    Citm.CharacterId = Char.CharacterId;
                    Citm.Entry       = Items[i].Entry;
                    Citm.ModelId     = Items[i].ModelId;
                    Citm.SlotId      = Items[i].SlotId;
                    CharMgr.CreateItem(Citm);
                }

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

                CharMgr.Database.AddObject(CInfo);

                Char.Value = new Character_value[1] {
                    CInfo
                };
            }


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

            Out.WritePascalString(cclient._Account.Username);
            cclient.SendTCP(Out);
        }
Example #5
0
        static public void F_CREATE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;
            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);

            if (Name.Length > 2 && !CharMgr.NameIsUsed(Name))
            {
                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();
                    Char.AccountId    = cclient._Account.AccountId;
                    Char.bTraits      = Traits;
                    Char.Career       = Info.career;
                    Char.CareerLine   = CharInfo.CareerLine;
                    Char.ModelId      = Info.model;
                    Char.Name         = Name;
                    Char.Race         = Info.race;
                    Char.Realm        = CharInfo.Realm;
                    Char.RealmId      = Program.Rm.RealmId;
                    Char.Sex          = Info.sex;
                    Char.FirstConnect = true;

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

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

                            Citm             = new Character_item();
                            Citm.Counts      = Itm.Count;
                            Citm.CharacterId = Char.CharacterId;
                            Citm.Entry       = Itm.Entry;
                            Citm.ModelId     = Itm.ModelId;
                            Citm.SlotId      = Itm.SlotId;
                            CharMgr.CreateItem(Citm);
                        }

                        Character_value CInfo = new Character_value();
                        CInfo.CharacterId = Char.CharacterId;
                        CInfo.Level       = 1;
                        CInfo.Money       = 0;
                        CInfo.Online      = false;
                        CInfo.RallyPoint  = CharInfo.RallyPt;
                        CInfo.RegionId    = CharInfo.Region;
                        CInfo.Renown      = 0;
                        CInfo.RenownRank  = 1;
                        CInfo.RestXp      = 0;
                        CInfo.Skills      = CharInfo.Skills;
                        CInfo.Speed       = 100;
                        CInfo.WorldO      = CharInfo.WorldO;
                        CInfo.WorldX      = CharInfo.WorldX;
                        CInfo.WorldY      = CharInfo.WorldY;
                        CInfo.WorldZ      = CharInfo.WorldZ;
                        CInfo.Xp          = 0;
                        CInfo.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"));

                        Char.Value = CInfo;

                        PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);
                        Out.WritePascalString(cclient._Account.Username);
                        cclient.SendPacket(Out);
                    }
                }
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
        }
Example #6
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       = 0,
                            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);
            }
        }