コード例 #1
0
ファイル: Item.cs プロジェクト: wardev1/WarEmu-1
        public Character_item Create(UInt32 CharacterId)
        {
            CharItem             = new Character_item();
            CharItem.CharacterId = CharacterId;
            CharItem.Counts      = _Count;
            CharItem.Entry       = Info.Entry;
            CharItem.ModelId     = _ModelId;
            CharItem.SlotId      = _SlotId;
            CharMgr.CreateItem(CharItem);

            return(CharItem);
        }
コード例 #2
0
        static public void DeleteItem(Character_item Itm)
        {
            //Log.Info("DeleteItem", "Guid=" + Itm.Guid + ",CharId=" + Itm.CharacterId);

            lock (_Items)
            {
                if (_CharItems.ContainsKey(Itm.CharacterId))
                {
                    _CharItems[Itm.CharacterId].Remove(Itm);
                }

                _Items[Itm.Guid] = null;
            }

            CharMgr.Database.DeleteObject(Itm);
        }
コード例 #3
0
ファイル: Item.cs プロジェクト: wardev1/WarEmu-1
        public bool Load(Character_item Item)
        {
            if (Item == null)
            {
                return(false);
            }

            Info = WorldMgr.GetItem_Info(Item.Entry);
            if (Info == null)
            {
                Log.Error("ItemInterface", "Load : Info==null,Entry=" + Item.Entry);
                return(false);
            }

            CharItem = Item;
            return(true);
        }
コード例 #4
0
        static public bool CreateItem(Character_item Item)
        {
            lock (_Items)
            {
                for (int i = 0; i < _Items.Length; ++i)
                {
                    if (_Items[i] == null)
                    {
                        Item.Guid = i;
                        LoadItem(Item);
                        Database.AddObject(Item);
                        return(true);
                    }
                }
            }

            Log.Error("CreateItem", "Maximum number of items reaches !");
            return(false);
        }
コード例 #5
0
        static public void LoadItem(Character_item CharItem)
        {
            lock (_Items)
            {
                _Items[CharItem.Guid] = CharItem;

                if (!_CharItems.ContainsKey(CharItem.CharacterId))
                {
                    _CharItems.Add(CharItem.CharacterId, new List <Character_item>()
                    {
                        CharItem
                    });
                }
                else
                {
                    _CharItems[CharItem.CharacterId].Add(CharItem);
                }
            }
        }
コード例 #6
0
        static public IList <Character_mail> GetCharMail(UInt32 characterId)
        {
            IList <Character_mail> Mails = Database.SelectObjects <Character_mail>(string.Format("CharacterId = {0}", characterId));

            if (Mails != null)
            {
                foreach (Character_mail Mail in Mails)
                {
                    foreach (uint Guid in Mail.ItemsReq)
                    {
                        Character_item Req = _Items[Guid];
                        if (Req != null)
                        {
                            Mail.ItemsReqInfo.Add(Req);
                        }
                    }
                }
            }

            return(Mails);
        }
コード例 #7
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());
        }
コード例 #8
0
ファイル: MailHandlers.cs プロジェクト: wardev1/WarEmu-1
        static public void F_MAIL(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
            {
                return;
            }

            Player Plr = cclient.Plr;

            byte Type = packet.GetUint8();

            switch (Type)
            {
            case 0:     // Mailbox closed
            {
            } break;

            case 1:     // Mail sent
            {
                Plr.MlInterface.BuildMail(packet);
            } break;

            case 2:     // Open mail
            case 3:     // Return mail
            case 4:     // Delete mail
            case 5:     // Mark as read/unread
            case 7:     // Take Item
            case 8:     // Take money
            {
                byte   Page = packet.GetUint8();
                UInt32 Guid = ByteOperations.ByteSwap.Swap(packet.GetUint32());

                Character_mail Mail = Plr.MlInterface.GetMail(Guid);

                switch (Type)
                {
                case 2:
                    if (!Mail.Opened)
                    {
                        Mail.Opened = true;
                        CharMgr.SaveMail(Mail);
                        Plr.MlInterface.SendMailCounts();
                        Plr.MlInterface.SendMailBox();
                    }
                    Plr.MlInterface.SendMail(Mail);
                    break;

                case 3:
                    //TODO
                    Plr.MlInterface.SendResult(GameData.MailResult.TEXT_MAIL_RESULT11);
                    break;

                case 4:
                    Plr.MlInterface.RemoveMail(Mail);
                    Plr.MlInterface.SendMailCounts();
                    Plr.MlInterface.SendMailBox();
                    break;

                case 5:
                    packet.Skip(4);
                    Mail.Opened = (packet.GetUint8() == 1);
                    CharMgr.SaveMail(Mail);
                    Plr.MlInterface.SendMailCounts();
                    Plr.MlInterface.SendMailBox();
                    break;

                case 7:
                    packet.Skip(4);
                    byte itemnum = packet.GetUint8();
                    if (Mail.ItemsReqInfo.Count < itemnum + 1)
                    {
                        return;
                    }

                    UInt16 FreeSlot = Plr.ItmInterface.GetFreeInventorySlot();
                    if (FreeSlot == 0)
                    {
                        Plr.SendLocalizeString("", GameData.Localized_text.TEXT_OVERAGE_CANT_TAKE_ATTACHMENTS);
                        return;
                    }

                    Character_item item = Mail.ItemsReqInfo.ElementAt(itemnum);
                    Plr.ItmInterface.CreateItem(item.Entry, item.Counts);
                    Mail.ItemsReqInfo.Remove(item);

                    CharMgr.SaveMail(Mail);
                    Plr.MlInterface.SendMailUpdate(Mail);
                    Plr.MlInterface.SendMail(Mail);
                    break;

                case 8:
                    if (Mail.Money > 0)
                    {
                        Plr.AddMoney(Mail.Money);
                        Mail.Money = 0;
                    }
                    // Take as many items as you can before inventory is full
                    foreach (Character_item curritem in Mail.ItemsReqInfo.ToArray())
                    {
                        UInt16 Slot = Plr.ItmInterface.GetFreeInventorySlot();
                        if (Slot == 0)
                        {
                            Plr.SendLocalizeString("", GameData.Localized_text.TEXT_OVERAGE_CANT_TAKE_ATTACHMENTS);
                            break;
                        }
                        Plr.ItmInterface.CreateItem(curritem.Entry, curritem.Counts);
                        Mail.ItemsReqInfo.Remove(curritem);
                    }
                    CharMgr.SaveMail(Mail);
                    Plr.MlInterface.SendMailUpdate(Mail);
                    Plr.MlInterface.SendMail(Mail);
                    break;
                }
            }
            break;
            }
        }
コード例 #9
0
ファイル: CharacterHandlers.cs プロジェクト: wardev1/WarEmu-1
        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);
            }
        }