Esempio n. 1
0
        public override void OnLoad()
        {
            _Client.State = (int)eClientState.WorldEnter;

            if (!_Inited)
            {
                EvtInterface.Obj = this;
                EvtInterface.AddEventNotify("Playing", Save);
                EvtInterface.Start();

                ItmInterface.Load(CharMgr.GetItemChar(_Info.CharacterId));
                StsInterface.Load(CharMgr.GetCharacterInfoStats(_Info.CareerLine, _Value.Level));
                QtsInterface.Load(this._Info.Quests);
                TokInterface.Load(_Info.Toks);
                SocInterface.Load(_Info.Socials);
                AbtInterface.Load();
                StsInterface.ApplyStats();

                SetLevel(_Value.Level);
                SetRenownLevel(_Value.RenownRank);
                SetOffset((UInt16)(_Value.WorldX >> 12), (UInt16)(_Value.WorldY >> 12));
                _Inited = true;
            }

            base.OnLoad();

            StartInit();
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public Dictionary <byte, UInt16> ApplyLevel()
        {
            Dictionary <byte, UInt16> Diff = new Dictionary <byte, ushort>();

            CharacterInfo_stats[] NewStats = CharMgr.GetCharacterInfoStats(_Info.CareerLine, _Value.Level);
            if (NewStats == null || NewStats.Length <= 0)
            {
                return(Diff);
            }

            foreach (CharacterInfo_stats Stat in NewStats)
            {
                UInt16 Base = StsInterface.GetBaseStat(Stat.StatId);

                if (Stat.StatValue > Base)
                {
                    Diff.Add(Stat.StatId, (ushort)(Stat.StatValue - Base));
                }

                StsInterface.SetBaseStat(Stat.StatId, Stat.StatValue);
            }

            StsInterface.ApplyStats();
            return(Diff);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        //public bool LoadExisting(Item_Info info, ushort slotId, ushort count, Item itm)
        //{
        //    Info = info;

        //    if (info == null)
        //        return false;

        //    if (count <= 0)
        //        count = 1;

        //    _SlotId = slotId;
        //    _ModelId = info.ModelId;
        //    _Count = count;

        //    Player player = Owner as Player;

        //    if (player != null)
        //    {
        //        CharMgr.CreateItem(itm.CharSaveInfo);

        //        if (info.SpellId != 0)
        //            player.AbtInterface.AssignItemCooldown(this);
        //    }

        //    return true;
        //}

        public void Delete()
        {
            if (CharSaveInfo != null)
            {
                CharMgr.DeleteItem(CharSaveInfo);
            }
        }
Esempio n. 6
0
        public void Ignore(string name)
        {
            if (name.Length <= 0 || name.Equals(_player.Name, StringComparison.OrdinalIgnoreCase))
            {
                _player.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_SN_FRIENDSLIST_ERR_ADD_SELF);
                return;
            }

            string charName    = Player.AsCharacterName(name);
            uint   characterId = CharMgr.GetCharacterId(charName);

            // Character didn't exist
            if (characterId == 0)
            {
                _player.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND);
                return;
            }
            bool applyIgnore = true;

            lock (_ignoreCharacterIds)
                if (_ignoreCharacterIds.ContainsKey(characterId))
                {
                    applyIgnore = false;
                }

            if (applyIgnore)
            {
                AddIgnore(characterId, name);
            }
            else
            {
                RemoveIgnore(characterId, name);
            }
        }
Esempio n. 7
0
 public void Delete()
 {
     if (CharItem != null)
     {
         CharMgr.DeleteItem(CharItem);
     }
 }
Esempio n. 8
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);
        }
Esempio n. 9
0
        static public void F_DUMP_ARENAS_LARGE(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.HasAccount())
            {
                cclient.Disconnect();
                return;
            }

            byte      CharacterSlot = packet.GetUint8();
            Character Char          = CharMgr.GetAccountChar(cclient._Account.AccountId).GetCharacterBySlot(CharacterSlot);

            if (Char == null)
            {
                Log.Error("F_DUMP_ARENAS_LARGE", "Can not find character on slot : " + CharacterSlot);
                cclient.Disconnect();
                return;
            }

            if (cclient.Plr == null)
            {
                cclient.Plr = Player.CreatePlayer(cclient, Char);
            }

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

            Out.WriteUInt16(0x0608); // TODO
            Out.Fill(0, 20);
            Out.WriteString("38699", 5);
            Out.WriteString("38700", 5);
            Out.WriteString("0.0.0.0", 20);
            cclient.SendTCP(Out);
        }
Esempio n. 10
0
 static public void PlayerStuck(Player Plr, string Text)
 {
     if (!Plr.CbtInterface.IsFighting())
     {
         CharacterInfo Info = CharMgr.GetCharacterInfo(Plr._Info.Career);
         Plr.Teleport((ushort)Info.ZoneId, (uint)Info.WorldX, (uint)Info.WorldY, (ushort)Info.WorldZ, (ushort)Info.WorldO);
     }
 }
Esempio n. 11
0
        public void AddFriend(string Name)
        {
            Player Plr = GetPlayer();

            if (Plr == null)
            {
                return;
            }

            Name = Name.ToLower();

            if (Name.Length <= 0 || Name.ToLower() == Plr.Name.ToLower())
            {
                Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_FRIENDSLIST_ERR_ADD_SELF);
                return;
            }

            Character_social Social = GetSocial(Name);

            if (Social != null && Social.Friend > 0)
            {
                Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_FRIENDSLIST_ERR_EXISTS);
                return;
            }

            Character Char = CharMgr.GetCharacter(Name);

            if (Char == null)
            {
                Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND);
                return;
            }

            EventInterface Event = null;

            if (Social != null)
            {
                Social.Friend = 1;
                CharMgr.Database.SaveObject(Social);

                Event = EventInterface.GetEventInterface((uint)Social.DistCharacterId);
            }
            else
            {
                Social                 = new Character_social();
                Social.CharacterId     = Plr._Info.CharacterId;
                Social.DistName        = Char.Name;
                Social.DistCharacterId = Char.CharacterId;
                Social.Friend          = 1;
                Social.Ignore          = 0;
                CharMgr.Database.AddObject(Social);

                Event = Load(Social);
            }

            SendFriends(Social);
            Plr.SendLocalizeString(Char.Name, GameData.Localized_text.TEXT_SN_FRIENDSLIST_ADD_SUCCESS);
        }
Esempio n. 12
0
        public static void F_DUMP_ARENAS_LARGE(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.HasAccount())
            {
                cclient.Disconnect("No Account in F_DUMP_ARENAS_LARGE");
                return;
            }

            if (Program.Rm.OnlinePlayers >= Program.Rm.MaxPlayers && cclient._Account.GmLevel < 1)
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_LOGINQUEUE);
                client.SendPacket(Out);
                return;
            }

            byte      CharacterSlot = packet.GetUint8();
            Character Char          = CharMgr.GetAccountChar(cclient._Account.AccountId).GetCharacterBySlot(CharacterSlot);

            if (Char == null)
            {
                Log.Error("F_DUMP_ARENAS_LARGE", "Can not find character on slot : " + CharacterSlot);
                cclient.Disconnect("Character not found in F_DUMP_ARENAS_LARGE");
                return;
            }

            {
                if (cclient.Plr == null)
                {
                    cclient.Plr = Player.CreatePlayer(cclient, Char);
                }

                if (cclient.Plr == null)
                {
                    cclient.Disconnect("NULL Player from CreatePlayer?");
                    return;
                }

                if (cclient.Plr.Client != cclient)
                {
                    cclient.Plr.Client?.Disconnect("Ghost client");
                    cclient.Plr.Destroy();
                    cclient.Disconnect("Player already exists");

                    return;
                }

                PacketOut Out = new PacketOut((byte)Opcodes.F_WORLD_ENTER, 64);
                Out.WriteUInt16(0x0608); // TODO
                Out.Fill(0, 20);
                Out.WriteString("38699", 5);
                Out.WriteString("38700", 5);
                Out.WriteString("0.0.0.0", 20);
                cclient.SendPacket(Out);
            }
        }
Esempio n. 13
0
        public override void Save()
        {
            List <Item> Itms = Items.ToList();

            Itms.AddRange(BuyBack.ToList());

            if (Obj.IsPlayer())
            {
                CharMgr.SaveItems(GetPlayer()._Info.CharacterId, Itms.ToArray());
            }
        }
Esempio n. 14
0
        public Character_items Create(int CharacterId)
        {
            CharItem             = new Character_items();
            CharItem.CharacterId = CharacterId;
            CharItem.Counts      = _Count;
            CharItem.Entry       = Info.Entry;
            CharItem.ModelId     = _ModelId;
            CharItem.SlotId      = _SlotId;
            CharMgr.CreateItem(CharItem);

            return(CharItem);
        }
        public static void CheckAuctionExpiry(object arg)
        {
            int removeCount = 0;

            long expireTimeStart = TCPManager.GetTimeStamp() - (60 * 60 * 24 * 30);

            lock (Auctions)
            {
                for (int i = 0; i < Auctions.Count; ++i)
                {
                    if (Auctions[i].StartTime >= expireTimeStart)
                    {
                        continue;
                    }

                    Auction auction = Auctions[i];

                    if (auction.Item == null)
                    {
                        auction.Item = ItemService.GetItem_Info(auction.ItemId);
                    }

                    if (auction.Item != null)
                    {
                        // return item to lister
                        Character_mail expireMail = new Character_mail
                        {
                            Guid         = CharMgr.GenerateMailGuid(),
                            CharacterId  = auction.SellerId,
                            ReceiverName = auction.Seller.Name,
                            SendDate     = (uint)TCPManager.GetTimeStamp(),
                            AuctionType  = 3,
                            Content      = auction.Item.Name,
                            Money        = 0,
                            Opened       = false
                        };

                        expireMail.Items.Add(new MailItem(auction.ItemId, auction._Talismans, auction.PrimaryDye, auction.SecondaryDye, auction.Count));

                        CharMgr.AddMail(expireMail);
                    }

                    CharMgr.Database.DeleteObject(auction);
                    Auctions.RemoveAt(i);

                    ++removeCount;

                    --i;
                }

                Log.Info("Auction House", $"Removed {removeCount} expired {(removeCount == 1 ? "auction": "auctions")}.");
            }
        }
        public static void SendCOD(string receiverName, Player sender, uint amount)
        {
            Character receiver = CharMgr.GetCharacter(receiverName, false);

            // Sender may have deleted character, oh well. No one gets the money.
            if (receiver == null)
            {
                return;
            }

            sender.MlInterface.SendMail(receiver, "COD Payment", "Here is your COD payment", amount, false);
        }
Esempio n. 17
0
        public override void SendInteract(Player player, InteractMenu menu)
        {
            uint itemid = 0;

            switch (Bannertyp)
            {
            case 0: itemid = (uint)(RealmStandard == Realms.REALMS_REALM_DESTRUCTION ? 187704 : 187701); break;

            case 1: itemid = (uint)(RealmStandard == Realms.REALMS_REALM_DESTRUCTION ? 187705 : 187702); break;

            case 2: itemid = (uint)(RealmStandard == Realms.REALMS_REALM_DESTRUCTION ? 187706 : 187703); break;
            }


            if (player == Owner)
            {
                if (player.ItmInterface.GetItemInSlot(14) == null)
                {
                    player.ItmInterface.CreateItem(ItemService.GetItem_Info(itemid), 1, 14);
                    player.ItmInterface.SendEquipped(player);
                    player.ItmInterface.SendEquipped(null);
                }
                else
                {
                    player.ItmInterface.CreateItem(ItemService.GetItem_Info(itemid), 1);
                }
            }
            else if (player.Realm == RealmStandard)
            {
                Character_mail Mail = new Character_mail();
                Mail.Guid              = CharMgr.GenerateMailGuid();
                Mail.CharacterId       = Owner.CharacterId;
                Mail.CharacterIdSender = player.CharacterId;
                Mail.SenderName        = player.Name;
                Mail.ReceiverName      = Owner.Name;
                Mail.SendDate          = (uint)TCPManager.GetTimeStamp();
                Mail.Title             = "Guild Standard";
                Mail.Content           = "Found your Guild Standard";
                Mail.Money             = 0;
                Mail.Opened            = false;
                Mail.Items.Add(new MailItem(itemid, 1));
                CharMgr.AddMail(Mail);
            }
            else
            {
                player.AddRenown(600, false);
            }


            player.PlantedStandard = null;
            Dispose();
        }
Esempio n. 18
0
        public void RemoveFriend(string name)
        {
            uint characterId = CharMgr.GetCharacterId(Player.AsCharacterName(name));

            Character_social social;

            lock (_friendCharacterIds)
                _friendCharacterIds.TryGetValue(characterId, out social);

            if (social == null)
            {
                _player.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND);
                return;
            }

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

            Out.WriteUInt16(0);
            Out.WriteByte((byte)SocialListType.SOCIAL_FRIEND);
            Out.WriteByte(1); // Count
            Out.WriteByte(1);
            Out.WriteUInt32(social.DistCharacterId);

            _player.SendPacket(Out);

            _player.SendLocalizeString(social.DistName, ChatLogFilters.CHATLOGFILTERS_SAY, Localized_text.TEXT_SN_FRIEND_REMOVE);

            if (social.Ignore > 0)
            {
                social.Friend = 0;
                CharMgr.Database.SaveObject(social);
            }
            else
            {
                lock (_player.Info.Socials)
                {
                    if (_player.Info.Socials.Contains(social))
                    {
                        _player.Info.Socials.Remove(social);
                    }
                }
                CharMgr.Database.DeleteObject(social);
            }

            lock (_friendCharacterIds)
                _friendCharacterIds.Remove(social.DistCharacterId);

            //CharMgr.Database.ForceSave();
        }
Esempio n. 19
0
        public CharacterItem CreateCharSaveInfo(uint characterId)
        {
            CharSaveInfo = new CharacterItem
            {
                CharacterId   = characterId,
                Counts        = _Count,
                Entry         = Info.Entry,
                ModelId       = _ModelId,
                SlotId        = _SlotId,
                PrimaryDye    = 0,
                SecondaryDye  = 0,
                BoundtoPlayer = false
            };
            CharMgr.CreateItem(CharSaveInfo);

            return(CharSaveInfo);
        }
        public void TakeLoot(Player plr)
        {
            Character chara = CharMgr.GetCharacter(plr.CharacterId, false);

            MailItem items = GenerateBag(chara.CharacterId);

            ItemResult result = plr.ItmInterface.CreateItem(ItemService.GetItem_Info(items.id), 1, items.talisman, items.primary_dye, items.secondary_dye, false);

            if (result == ItemResult.RESULT_OK)
            {
                _lootBags.Remove(plr.CharacterId);
            }
            else if (result == ItemResult.RESULT_MAX_BAG)
            {
                plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_OVERAGE_CANT_LOOT);
            }
        }
        /// <summary>
        /// Removes or returns an expired mail.
        /// </summary>
        private static void MailExpired(Character_mail mail)
        {
            if (mail.AuctionType != 0 || (mail.Money == 0 && mail.Items.Count == 0))
            {
                CharMgr.DeleteMail(mail);
                return;
            }

            Character receiver = CharMgr.GetCharacter(mail.SenderName, false);

            if (receiver != null)
            {
                ReturnMail(mail);
            }
            else
            {
                CharMgr.DeleteMail(mail);
            }
        }
Esempio n. 22
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.WritePascalString(cclient._Account.Username);
            cclient.SendTCP(Out);
        }
        /// <summary>
        /// Returns an expired mail to its sender.
        /// </summary>
        private static MailResult ReturnMail(Character_mail mail)
        {
            // Can't return auction mail.
            if (mail.AuctionType != 0)
            {
                return(MailResult.TEXT_MAIL_RESULT11);
            }

            Character receiver = CharMgr.GetCharacter(mail.SenderName, false);

            // No one to return mail to.
            if (receiver == null)
            {
                return(MailResult.TEXT_MAIL_RESULT11);
            }

            // If mail is COD, remove the COD requirement and remove the money.
            if (mail.Cr)
            {
                mail.Cr    = false;
                mail.Money = 0;
            }

            CharMgr.DeleteMail(mail);

            Character_mail returnMail = new Character_mail
            {
                // Sender -> Reciever, Reciever -> Sender
                Guid              = CharMgr.GenerateMailGuid(),
                CharacterId       = mail.CharacterIdSender,
                CharacterIdSender = mail.CharacterId,
                SenderName        = mail.ReceiverName,
                ReceiverName      = mail.SenderName,
                Content           = "Your mail expired and has been returned to you.",
                ReadDate          = 0,
                SendDate          = (uint)TCPManager.GetTimeStamp(),
                Opened            = false
            };

            CharMgr.AddMail(returnMail);

            return(MailResult.TEXT_MAIL_UNK);
        }
Esempio n. 24
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 == 0 && !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);
            }
        }
        public override void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            try
            {
                foreach (KeyValuePair <uint, GoldBag> loot in _lootBags)
                {
                    Character_mail mail = new Character_mail
                    {
                        Guid         = CharMgr.GenerateMailGuid(),
                        CharacterId  = loot.Key,
                        SenderName   = "Public Quest",
                        ReceiverName = loot.Value.plrName,
                        SendDate     = (uint)TCPManager.GetTimeStamp(),
                        Title        = "Public Quest Loot",
                        Content      = "You won a Public Quest Loot Bag",
                        Money        = 0,
                        Opened       = false
                    };

                    //Mail.CharacterIdSender = plr.CharacterId;
                    MailItem item = GenerateBag(loot.Key);
                    if (item != null)
                    {
                        mail.Items.Add(item);
                        CharMgr.AddMail(mail);
                    }
                }
            }
            catch (NullReferenceException)
            {
                Log.Error("GoldChest", "Failed to mail loot.");
            }

            _lootBags = new Dictionary <uint, GoldBag>();

            base.Dispose();
        }
Esempio n. 26
0
        public static void F_DELETE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            byte Slot = packet.GetUint8();

            if (cclient._Account == null)
            {
                cclient.Disconnect("Null Account in F_DELETE_CHARACTER");
                return;
            }

            CharMgr.RemoveCharacter(Slot, cclient);

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

            Out.FillString(cclient._Account.Username, 21);
            Out.Fill(0, 3);
            cclient.SendPacket(Out);
        }
        public void SendMail(Character receiver, string subject, string message, uint money, bool cashOnDelivery, List <ushort> itemSlots = null)
        {
            Player sender = (Player)_Owner;

            Character_mail cMail = new Character_mail
            {
                Guid              = CharMgr.GenerateMailGuid(),
                CharacterId       = receiver.CharacterId,
                CharacterIdSender = sender.CharacterId,
                SenderName        = sender.Info.Name,
                ReceiverName      = receiver.Name,
                SendDate          = (uint)TCPManager.GetTimeStamp(),
                Title             = subject,
                Content           = message,
                Money             = money,
                Cr     = cashOnDelivery,
                Opened = false
            };

            if (itemSlots != null)
            {
                foreach (ushort itmslot in itemSlots)
                {
                    Item itm = sender.ItmInterface.GetItemInSlot(itmslot);
                    // This should never happen, double check.
                    if (itm != null && itm.Info != null)
                    {
                        cMail.Items.Add(new MailItem(itm.Info.Entry, itm.GetTalismans(), itm.GetPrimaryDye(), itm.GetSecondaryDye(), itm.Count));
                        sender.ItmInterface.DeleteItem(itmslot, itm.Count);
                        itm.Owner = null;
                    }
                }
            }

            SendResult(MailResult.TEXT_MAIL_RESULT4);

            CharMgr.AddMail(cMail);

            _nextSend = (uint)TCPManager.GetTimeStamp() + 5;
        }
Esempio n. 28
0
        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);
        }
Esempio n. 29
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);
            }
        }
Esempio n. 30
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);
            }
        }