قديم 2019-08-19, 04:04 AM
المشاركة 2
Hassan Emprator
.:: عضو خبير ::.
  • غير متواجد
افتراضي رد: مشكلة في الوار دروب
جرب بدل دا بي العندك كلاس wardrobe
كود:
using ProtoBuf;
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Collections.Concurrent;
using System.Text;
using System.Threading.Tasks;

namespace 
MrHassan.Network.GamePackets
{
    public 
sealed class CoatStorage
    
{
        public 
CoatStorage() { }
        public 
bool Read(byte[] packet)
        {
            
using (var memoryStream = new MemoryStream(packet))
            {
                
Info Serializer.DeserializeWithLengthPrefix<CoatStorageProto>(memoryStreamPrefixStyle.Fixed32);
            }
            return 
true;
        }
        public 
void Handle(Client.GameState client)
        {
            switch (
Info.ActionId)
            {
                case 
Action.Combine:
                    {
                        
ConquerItem ItemInInventory null;
                        
ConquerItem ItemInSystem null;
                        if (
client.Inventory.TryGetItem((uint)Info.ItemIdout ItemInInventory))
                        {
                            if (
client.Entity.StorageItems.TryGetValue((uint)Info.ItemGuidout ItemInSystem))
                            {
                                
ItemInSystem.Minutes += ItemInInventory.Minutes;
                                
Database.ConquerItemTable.UpdateMinutes(ItemInSystem);
                                if (
ItemInSystem.Minutes != 0)
                                {
                                    
uint num;
                                    if (
DateTime.Now >= ItemInSystem.TimeStamp.AddMinutes(ItemInSystem.Minutes))
                                    {
                                        
Database.ConquerItemTable.DeleteItem(ItemInSystem.UID);
                                    }
                                    else
                                    {
                                        
TimeSpan span = new TimeSpan(ItemInSystem.TimeStamp.AddMinutes(ItemInSystem.Minutes).Ticks);
                                        
TimeSpan span2 = new TimeSpan(DateTime.Now.Ticks);
                                        
num = (uint)(span.TotalSeconds span2.TotalSeconds);
                                        
ItemInSystem.TimeLeftInMinutes num;
                                    }
                                }

                                
client.Inventory.Remove(ItemInInventoryGame.Enums.ItemUse.Remove);
                                var 
proto = new CoatStorageProto();
                                
proto.ActionId Action.Combine;
                                
proto.ItemGuid Info.ItemGuid;
                                
proto.ItemId = (int)ItemInSystem.ID;
                                
proto.AddItem(ItemInSystem1);
                                
client.Send(FinalizeProtoBuf(proto));
                            }
                        }
                        break;

                    }
                case 
Action.Equipcheck:
                    
ConquerItem myItem;
                    if (
client.Inventory.TryGetItem(Info.ItemGuidout myItem))
                    {
                        var 
packet FinalizeProtoBuf(new CoatStorageProto()
                        {
                            
ActionId Info.ActionId,
                            
ItemGuid Info.ItemGuid,
                        });
                        
client.Send(packet);
                    }
                    break;
                case 
Action.Addtowardrobe:
                    {
                        if (!
CanEquip(Infoclient))
                        {
                            if (
client.Inventory.TryGetItem(Info.ItemGuidout myItem))
                            {
                                if (!
client.Entity.StorageItems.ContainsKey(myItem.UID))
                                    
client.Entity.StorageItems.Add(myItem.UIDmyItem);
                                
myItem.InWardrobe true;
                                
Database.ConquerItemTable.UpdateWardrobe(myItem.InWardrobemyItem.UID);
                                
client.Inventory.Remove(myItemGame.Enums.ItemUse.None);
                            }
                            break;
                        }
                        if (
client.Entity.StorageItems.TryGetValue(Info.ItemGuidout myItem))
                        {

                            foreach (var 
i in client.Entity.StorageItems.Values)
                            {
                                if (
i.Position == (byte)PacketHandler.GetPositionFromID(myItem.ID))
                                {
                                    if (
client.Equipment.TryGetItem((byte)i.Position) != null)
                                        
client.Equipment.Remove((byte)i.Positiontrue);
                                    
i.Position 0;
                                    
Database.ConquerItemTable.UpdateLocation(iclient);
                                }
                            }
                            
myItem.Position = (byte)PacketHandler.GetPositionFromID(myItem.ID);

                            if (!
client.Equipment.Add(myItem))
                            {
                                
client.Equipment.Remove((byte)myItem.Positiontrue);
                            }
                            var 
iu = new ItemUsage(true);
                            
iu.ID ItemUsage.Unknown5;
                            
iu.UID myItem.UID;
                            
iu.dwParam myItem.Position;
                            
client.Send(iu.ToArray());

                            
ClientEquip equips = new ClientEquip();
                            
equips.DoEquips(client);
                            
client.Send(equips.ToArray());

                            
Database.ConquerItemTable.UpdateLocation(myItemclient);
                            
client.Equipment.UpdateEntityPacket();
                            
client.Send(FinalizeProtoBuf(new CoatStorageProto()
                            {
                                
ActionId Info.ActionId,
                                
ItemGuid Info.ItemGuid,
                                
ItemId = (int)myItem.ID
                            
}));
                        }
                        else if (
client.Inventory.TryGetItem(Info.ItemGuidout myItem))
                        {
                            
client.Entity.StorageItems.Add(myItem.UIDmyItem);
                            
myItem.InWardrobe true;
                            
Database.ConquerItemTable.UpdateWardrobe(myItem.InWardrobemyItem.UID);
                            
client.Inventory.Remove(myItemGame.Enums.ItemUse.None);
                            
client.Send(FinalizeProtoBuf(new CoatStorageProto()
                            {
                                
ActionId Info.ActionId,
                                
ItemGuid Info.ItemGuid,
                                
ItemId = (int)myItem.ID
                            
}));
                            foreach (var 
i in client.Entity.StorageItems.Values)
                            {
                                if (
i.Position != && i.Position == (byte)PacketHandler.GetPositionFromID(myItem.ID))
                                {
                                    if (
client.Equipment.TryGetItem((byte)i.Position) != null)
                                        
client.Equipment.Remove((byte)i.Positiontrue);
                                    
i.Position 0;
                                    
Database.ConquerItemTable.UpdateLocation(iclient);
                                }
                            }
                            
myItem.Position = (byte)PacketHandler.GetPositionFromID(myItem.ID);

                            if (!
client.Equipment.Add(myItem))
                            {
                                
client.Equipment.Remove((byte)myItem.Positiontrue);

                            }
                            var 
iu = new ItemUsage(true);
                            
iu.ID ItemUsage.Unknown5;
                            
iu.UID myItem.UID;
                            
iu.dwParam myItem.Position;
                            
client.Send(iu.ToArray());

                            
ClientEquip equips = new ClientEquip();
                            
equips.DoEquips(client);
                            
client.Send(equips.ToArray());

                            
Database.ConquerItemTable.UpdateLocation(myItemclient);
                            
client.Equipment.UpdateEntityPacket();
                        }
                        break;
                    }
                case 
Action.Takeoff:
                    if (
client.Entity.StorageItems.TryGetValue(Info.ItemGuidout myItem))
                    {
                        
client.Send(FinalizeProtoBuf(new CoatStorageProto()
                        {
                            
ActionId Info.ActionId,
                            
ItemGuid Info.ItemGuid,
                            
ItemId = (int)myItem.ID
                        
}));

                        var 
pos = (byte)PacketHandler.GetPositionFromID(myItem.ID);
                        
client.Equipment.Remove(postrue);
                        
ClientEquip equips = new ClientEquip();
                        
equips.DoEquips(client);
                        if (
pos == 17)
                            
equips.SteedArmor 0;
                        else 
equips.Garment 0;
                        
client.Send(equips.ToArray());
                        
client.Equipment.UpdateEntityPacket();

                    }
                    break;
                case 
Action.Retrieve:
                    if (
client.Entity.StorageItems.TryGetValue(Info.ItemGuidout myItem) && client.Inventory.Count 40)
                    {
                        var 
pos = (byte)PacketHandler.GetPositionFromID(myItem.ID);
                        
client.Entity.StorageItems.Remove(myItem.UID);
                        
myItem.InWardrobe false;
                        
Database.ConquerItemTable.UpdateWardrobe(myItem.InWardrobemyItem.UID);
                        
client.Send(FinalizeProtoBuf(new CoatStorageProto()
                        {
                            
ActionId Info.ActionId,
                            
ItemGuid Info.ItemGuid,
                            
ItemId = (int)myItem.ID
                        
}));
                        
client.Inventory.Add(myItemGame.Enums.ItemUse.Move);
                        
ClientEquip equips = new ClientEquip();
                        
equips.DoEquips(client);
                        if (
pos == 17)
                            
equips.SteedArmor 0;
                        else 
equips.Garment 0;
                        
client.Send(equips.ToArray());
                        
client.Equipment.UpdateEntityPacket();
                    }
                    break;
            }
            new 
TitleStorage().CheckTitles(client);
        }

        private 
bool CanEquip(CoatStorageProto InfoClient.GameState client)
        {
            
ConquerItem myItem;

            if (
client.Inventory.TryGetItem(Info.ItemGuidout myItem) ||
            
client.Entity.StorageItems.TryGetValue(Info.ItemGuidout myItem) ||
            
client.Equipment.TryGetItem(Info.ItemGuidout myItem))
            {
                var 
dbInfo Database.ConquerItemInformation.BaseInformations.ContainsKey(myItem.ID) ?
                
Database.ConquerItemInformation.BaseInformations[myItem.ID] : null;
                if (
dbInfo == null)
                    return 
false;
                
bool isSteedArmor PacketHandler.GetPositionFromID(myItem.ID) == PacketHandler.Positions.SteedArmor;
                
bool CanEquipSteedArmor isSteedArmor && client.Entity.SubClasses.Classes.ContainsKey(9)
                    && 
client.Entity.SubClasses.Classes[9].Phase >= Database.ConquerItemInformation.BaseInformations[myItem.ID].Proficiency;

                if (!
isSteedArmor)
                {
                    var 
charSex = (client.Entity.Body == 1003 || client.Entity.Body == 1004) ? "Male" "Female";
                    if ((
dbInfo.Gender == charSex != "Male" dbInfo.Gender == false charSex != "Female"))
                    {
                        return 
false;
                    }
                }
                else if (
isSteedArmor && !CanEquipSteedArmor) return false;
            }
            else return 
false;
            return 
true;
        }

        private 
byte[] FinalizeProtoBuf(CoatStorageProto coatStorageProto)
        {
            
using (var memoryStream = new MemoryStream())
            {
                
Serializer.SerializeWithLengthPrefix(memoryStreamcoatStorageProtoPrefixStyle.Fixed32);
                var 
pkt = new byte[memoryStream.Length];
                
memoryStream.ToArray().CopyTo(pkt0);
                
Writer.Write((ushort)memoryStream.Length0pkt);
                
Writer.Write((ushort)33002pkt);

                return 
pkt;
            }
        }
        public 
void Login(Client.GameState client)
        {
            var 
pkt = new CoatStorageProto();
            foreach (var 
item in client.Entity.StorageItems.Values)
            {
                
pkt.AddItem(item,
                    
client.Entity.StorageItems.Values.Where(=> i.ID == item.ID).Count());
                
client.Send(FinalizeProtoBuf(pkt));

                if (
item.Position != 0)
                {
                    
client.Equipment.Add(item);

                    var 
iu = new ItemUsage(true);
                    
iu.ID ItemUsage.Unknown5;
                    
iu.UID item.UID;
                    
iu.dwParam item.Position;
                    
client.Send(iu.ToArray());

                    
ClientEquip equips = new ClientEquip();
                    
equips.DoEquips(client);
                    
client.Send(equips.ToArray());

                    
Database.ConquerItemTable.UpdateLocation(itemclient);
                    
client.Equipment.UpdateEntityPacket();
                }

            }
            var 
currentGarment client.Equipment.TryGetItem((byte)PacketHandler.Positions.Garment);
            if (
currentGarment != null && !client.Entity.StorageItems.ContainsKey(currentGarment.UID))
            {
                
client.Entity.StorageItems.Add(currentGarment.UIDcurrentGarment);
                
pkt.AddItem(currentGarment,
                    
client.Entity.StorageItems.Values.Where(=> i.ID == currentGarment.ID).Count());
                
pkt.Item.Equipped true;
                
client.Send(FinalizeProtoBuf(pkt));
            }
            var 
currentMountArmor client.Equipment.TryGetItem((byte)PacketHandler.Positions.SteedArmor);
            if (
currentMountArmor != null && !client.Entity.StorageItems.ContainsKey(currentMountArmor.UID))
            {
                
client.Entity.StorageItems.Add(currentMountArmor.UIDcurrentMountArmor);
                
pkt.AddItem(currentMountArmor,
                    
client.Entity.StorageItems.Values.Where(=> i.ID == currentMountArmor.ID).Count());
                
pkt.Item.Equipped true;
                
client.Send(FinalizeProtoBuf(pkt));
            }

        }


        public 
CoatStorageProto Info;

        public 
enum Action int
        
{
            
/// <summary>
            /// Load items in storage ...
            /// </summary>
            
Login 0,
            
Equipcheck 1,
            
Retrieve 2,
            
Combine 4,
            
Addtowardrobe 5,
            
Takeoff 6,
            
dwParam 7,
        }
    }
    [
ProtoContract]
    public class 
CoatStorageProto
    
{
        [
ProtoMember(1IsRequired true)]
        public 
CoatStorage.Action ActionId;
        [
ProtoMember(2IsRequired true)]
        public 
uint ItemGuid;
        [
ProtoMember(3IsRequired true)]
        public 
int ItemId;
        [
ProtoMember(4IsRequired true)]
        public 
int Junk;
        [
ProtoMember(5IsRequired true)]
        public 
ItemStorage Item;
        public 
void AddItem(ConquerItem itemint stack)
        {
            
Item = new ItemStorage();
            
Item.ItemUID item.UID;
            
Item.ItemID = (int)item.ID;
            
Item.Maximumdurability Item.Minimumdurability item.MaximDurability;
            
Item.Stack stack;
            
Item.FirstSocket = (int)item.SocketOne;
            
Item.SecondSocket = (int)item.SocketTwo;
            
Item.Plus item.Plus;
            
Item.Protection item.Bless;
            
Item.Bound item.Bound;
            
Item.Health item.Enchant;
            
Item.SocketProgress = (int)item.SocketProgress;
            
Item.Effect item.Effect;
            
Item.Color item.Color;
            
Item.CraftProgress = (int)item.PlusProgress;
            
Item.Locked item.Lock == true false;
            
Item.Suspicious false;
            
Item.Inscribed false;
            
Item.dwParam7 0;
            
Item.Equipped item.Position != 0;
            
Item.dwParam15 0;
            
Item.Time 0;
            
Item.SubTime 0;
        }

    }
    [
ProtoContract]
    public class 
ItemStorage
    
{
        [
ProtoMember(1IsRequired true)]
        public 
uint ItemUID;
        [
ProtoMember(2IsRequired true)]
        public 
int ItemID;
        [
ProtoMember(3IsRequired true)]
        public 
int SocketProgress;
        [
ProtoMember(4IsRequired true)]
        public 
int FirstSocket;
        [
ProtoMember(5IsRequired true)]
        public 
int SecondSocket;
        [
ProtoMember(6IsRequired true)]
        public 
Game.Enums.ItemEffect Effect;
        [
ProtoMember(7IsRequired true)]
        public 
int dwParam7;
        [
ProtoMember(8IsRequired true)]
        public 
int Plus;
        [
ProtoMember(9IsRequired true)]
        public 
int Protection;
        [
ProtoMember(10IsRequired true)]
        public 
bool Bound;
        [
ProtoMember(11IsRequired true)]
        public 
int Health;
        [
ProtoMember(12IsRequired true)]
        public 
bool Equipped;
        [
ProtoMember(13IsRequired true)]
        public 
bool Suspicious;
        [
ProtoMember(14IsRequired true)]
        public 
bool Locked;
        [
ProtoMember(15IsRequired true)]
        public 
int dwParam15;
        [
ProtoMember(16IsRequired true)]
        public 
Game.Enums.Color Color;
        [
ProtoMember(17IsRequired true)]
        public 
int CraftProgress;
        
/// <summary>
        /// Inscribed in guild arsenal 
        /// This class is for wardrobe items which are garments or mount armors so this filed is always false
        /// </summary>
        
[ProtoMember(18IsRequired true)]
        public 
bool Inscribed;
        
/// <summary>
        /// Time left in seconds !
        /// </summary>
        
[ProtoMember(19IsRequired true)]
        public 
int Time;
        
/// <summary>
        /// Time left in minutes (if item not activated only)
        /// </summary>
        
[ProtoMember(20IsRequired true)]
        public 
int SubTime;
        [
ProtoMember(21IsRequired true)]
        public 
int Stack;
        [
ProtoMember(22IsRequired true)]
        public 
int Minimumdurability;
        [
ProtoMember(23IsRequired true)]
        public 
int Maximumdurability;
    }
    public static class 
Storage
    
{
        private static 
string Path Constants.DataHolderPath "Storage.ini";

        public static 
void Read(out StorageInfo storageInfo)
        {
            
storageInfo = new StorageInfo();
            var 
reader = new IniFile(Path);
            {
                
storageInfo.Count reader.ReadInt32("Storage""StorageTypeCount"0);
                
storageInfo.Storages = new StorageInfo.Storage[storageInfo.Count];
                for (
int i 0storageInfo.Counti++)
                {
                    var 
mySection = (1).ToString();
                    
storageInfo.Storages[i] = new StorageInfo.Storage();
                    
storageInfo.Storages[i].Type reader.ReadInt32(mySection"Type"0);
                    
storageInfo.Storages[i].UnitCount reader.ReadInt32(mySection"UnitCount"0);
                    
storageInfo.Storages[i].ViewType reader.ReadInt32(mySection"ViewType"0);
                    
storageInfo.Storages[i].Units = new StorageInfo.Storage.Unit[storageInfo.Storages[i].UnitCount];
                    for (
int u 0storageInfo.Storages[i].UnitCountu++)
                    {
                        var 
unitSection mySection "-" + (1).ToString();
                        
storageInfo.Storages[i].Units[u] = new StorageInfo.Storage.Unit();
                        
storageInfo.Storages[i].Units[u].ID reader.ReadInt32(unitSection"ID"0);
                        
storageInfo.Storages[i].Units[u].AniSection reader.ReadString(unitSection"AniSection");
                        
storageInfo.Storages[i].Units[u].GetWayType3 reader.ReadInt32(unitSection"GetWayType3"0);
                        
storageInfo.Storages[i].Units[u].GetWayText3 reader.ReadString(unitSection"GetWayText3");
                        
storageInfo.Storages[i].Units[u].Param reader.ReadString(unitSection"Param");
                        
storageInfo.Storages[i].Units[u].Intro reader.ReadString(unitSection"Intro");
                    }

                }
            }
            
//Console.WriteLine("Storages loaded");
        
}
    }
    [
StructLayout(LayoutKind.Sequential)]
    public class 
StorageInfo
    
{
        public 
int Count;
        public 
Storage[] Storages;
        public class 
Storage
        
{
            public 
int Type;
            public 
int UnitCount;
            public 
int ViewType;
            public 
Unit[] Units;
            public class 
Unit
            
{
                public 
int ID;
                public 
string AniSection;
                public 
int GetWayType3;
                public 
string GetWayText3;
                public 
string Param;
                public 
string Intro;
            }
        }
        public 
Storage GetStorageByType(int Type)
        {
            foreach (var 
storage in Storages)
                if (
storage != null && storage.Type == Type)
                    return 
storage;
            return 
null;
        }
        public 
Storage.Unit GetUnitByID(int IDStorage _storage null)
        {
            if (
_storage != null)
            {
                foreach (var 
unit in _storage.Units)
                    if (
unit.ID == ID)
                        return 
unit;
            }
            else
            {
                foreach (var 
storage in Storages)
                    if (
storage != null)
                        foreach (var 
unit in storage.Units)
                            if (
unit.ID == ID)
                                return 
unit;
            }
            return 
null;
        }
    }
    public 
sealed class StorageManager
    
{
        public static 
StorageInfo Info;

        public static 
void Load()
        {
            try
            {
                
Storage.Read(out Info);
            }
            catch (
Exception e)
            {
                
Console.WriteLine(e);
            }
        }

        public static 
T Wing<T>(int _typeint _id)
        {
            
object value null;
            
int trash 0;
            if (
typeof(T) == typeof(bool))
            {
                
value int.TryParse(Info.GetUnitByID(_idInfo.GetStorageByType(_type)).Paramout trash);
            }
            else if (
typeof(T) == typeof(int))
            {
                var 
myType _type.ToString();
                var 
myID _id.ToString();


                while (
myID.Length 4)
                    
myID "0" myID;
                
value int.Parse(myType myID);
            }
            else
                throw new 
Exception("Unknow type : " typeof(T).Name);
            return (
T)Convert.ChangeType(valuetypeof(T));
        }

       public static 
int GetTitlePoints(short _typeshort _id)     
        {     
            if (
_type == && _id == 1000)     
                return 
150;     
            else if (
_type == 2018 && _id == 1)     
                return 
500;     
            else if (
_type == 2001 && _id == 2)     
                return 
300;     
            else if (
_type == 2002 && _id == 3)     
                return 
150;     
            else if (
_type == 2003 && _id == 4)     
                return 
300;     
            else if (
_type == 2004 && _id == 5)     
                return 
150;     
            else if (
_type == 2005 && _id == 6)     
                return 
150;     
            else if (
_type == 2006 && _id == 7)     
                return 
150;     
            else if (
_type == 2020 && _id == 2020)     
                return 
300;     
            else if (
_type == 2021 && _id == 2021)     
                return 
200;     
            else if (
_type == 2022 && _id == 2022)     
                return 
100;     
            else if (
_type == 2023 && _id == 2023)     
                return 
300;     
            else if (
_type == 2024 && _id == 2024)     
                return 
200;     
            else if (
_type == 2025 && _id == 2025)     
                return 
100;     
            else if (
_type == 2028 && _id == 2028)     
                return 
150;     
            else if (
_type == 2029 && _id == 2029)     
                return 
300;     
            else if (
_type == 2030 && _id == 2030)     
                return 
100;     
            else if (
_type == 2031 && _id == 2031)     
                return 
200;     
            else if (
_type == 6009 && _id == 6009)     
                return 
300;     
            else if (
_type == 6007 && _id == 6007)     
                return 
300;     
            else if (
_type == 6008 && _id == 6008)     
                return 
300;     
            else if (
_type == 2026 && _id == 2026)     
                return 
100;     
            else if (
_type == 2027 && _id == 2027)     
                return 
300;     
            else if (
_type == 2032 && _id == 2032)     
                return 
300;     
            else if (
_type == 2033 && _id == 2033)     
                return 
300;     
            else if (
_type == 6011 && _id == 6011)     
                return 
300;     
            else if (
_type == 2034 && _id == 2034)     
                return 
300;     
            else if (
_type == 2013 && _id == 14)     
                return 
300;     
            else if (
_type == 2014 && _id == 15)     
                return 
300;     
            else if (
_type == 2015 && _id == 16)     
                return 
300;     
            else if (
_type == 2016 && _id == 17)     
                return 
300;     
            else if (
_type == 2035 && _id == 2035)     
                return 
300;     
            else if (
_type == 2036 && _id == 2036)     
                return 
300;     
            else if (
_type == 2037 && _id == 2037)     
                return 
300;     
            else if (
_type == 2038 && _id == 2038)     
                return 
300;     
            else if (
_type == 2039 && _id == 2039)     
                return 
300;     
            else if (
_type == 2040 && _id == 2040)     
                return 
100;     
            else if (
_type == 2041 && _id == 2041)     
                return 
100;     
            else if (
_type == 2044 && _id == 2044)     
                return 
100;     
            else if (
_type == 2045 && _id == 2045)     
                return 
100;     
            else if (
_type == 6012 && _id == 6012)     
                return 
100;     
            else if (
_type == 2050 && _id == 2050)     
                return 
100;     
            else if (
_type == 2051 && _id == 2051)     
                return 
100;     
            else if (
_type == 2052 && _id == 2052)     
                return 
100;     
            else if (
_type == 2053 && _id == 2053)     
                return 
150;     
            else if (
_type == 2054 && _id == 2054)     
                return 
150;     
            else if (
_type == 2057 && _id == 2057)     
                return 
150;     
            else if (
_type == 2056 && _id == 2056)     
                return 
100;     
            else if (
_type == 2046 && _id == 2046)     
                return 
150;     
            else if (
_type == 2047 && _id == 2047)     
                return 
150;     
            else if (
_type == 2048 && _id == 2048)     
                return 
150;     
            else if (
_type == 2049 && _id == 2049)     
                return 
150;     
            else if (
_type == 2059 && _id == 2059)     
                return 
100;     
            else if (
_type == 2060 && _id == 2060)     
                return 
150;     
            else if (
_type == 2061 && _id == 2061)     
                return 
150;     
            else if (
_type == 2062 && _id == 2062)     
                return 
150;     
            else if (
_type == 6013 && _id == 6013)     
                return 
100;     
            else if (
_type == 6014 && _id == 6014)     
                return 
150;     
            else if (
_type == 6015 && _id == 6015)     
                return 
150;     
            else if (
_type == 6016 && _id == 6016)     
                return 
150;     
            else if (
_type == 6017 && _id == 6017)     
                return 
150;     
            else if (
_type == 2063 && _id == 2063)     
                return 
150;     
            else if (
_type == 2064 && _id == 2064)     
                return 
150;     
            else if (
_type == 2065 && _id == 2065)     
                return 
150;     
            return 
0;     
        
       }
        public static 
T Title<T>(int _typeint _id)
        {
            
object value null;
            
int trash 0;
            if (
typeof(T) == typeof(bool))
            {
                
value = !int.TryParse(Info.GetUnitByID(_idInfo.GetStorageByType(_type)).Paramout trash);
            }
            else if (
typeof(T) == typeof(int))
            {
                var 
myType _type.ToString();
                var 
myID _id.ToString();

                while (
myID.Length 4)
                    
myID "0" myID;
                
value int.Parse(myType myID);
            }
            else
                throw new 
Exception("Unknow type : " typeof(T).Name);
            return (
T)Convert.ChangeType(valuetypeof(T));
        }
    }
    public 
sealed class TitleStorage
    
{
        public 
TitleStorage() { }
        public 
bool Read(byte[] packet)
        {
            
using (var memoryStream = new MemoryStream(packet))
            {
                
Info Serializer.DeserializeWithLengthPrefix<TitleStorageProto>(memoryStreamPrefixStyle.Fixed32);
            }
            return 
true;
        }
        private 
bool CollectedRandMonkey(Client.GameState client)
        {
            return 
client.Entity.StorageItems.Values.Where(=> MonkeysValues.Contains(p.ID)).ToList().Count true false;
        }
        private 
bool CollectedCelestialFox(Client.GameState client)
        {
            return 
client.Entity.StorageItems.Values.Where(=> p.ID == 200595).ToList().Count true false;
        }
        private 
bool CollectedCelestialFoxFantasy(Client.GameState client)
        {
            return 
client.Entity.StorageItems.Values.Where(=> p.ID == 200596).ToList().Count true false;
        }
        List<
uintMonkeysValues = new List<uint>()
        {
            
200553,
            
200554,
            
200555,
            
200556,
            
200557,
            
200558,
            
200559,
            
200560
        
};
        private 
bool Collected8TypesMonkey(Client.GameState client)
        {
            List<
uintIDs = new List<uint>();
            var 
Dict client.Entity.StorageItems.Values.ToList();
            for (
int x 0Dict.Countx++)
            {
                if (
MonkeysValues.Contains(Dict[x].ID) && !IDs.Contains(Dict[x].ID))
                {
                    
IDs.Add(Dict[x].ID);
                }
            }
            return 
IDs.Count == true false;
        }
        private 
bool CollectedMonkey(Client.GameState clientuint ID)
        {
            return 
client.Entity.StorageItems.Values.Where(=> p.ID == ID).ToList().Count true false;
        }
        public 
void CheckTitles(Client.GameState client)
        {
            if (
client.Entity.haveallTitles) { GetAll(client); return; }
            
#region Titles And Wings Equips
            #region Wings
            #region Union Emperor
            
if (client.Union != null)
                if (
client.Union.IsKingdom())
                    if (
client.Union.IsLeader(client.Entity.UID))
                        new 
TitleStorage().AddTitle(client40011000false);
                    else
                        new 
TitleStorage().RemoveTitle(client40011000false);
                else
                    new 
TitleStorage().RemoveTitle(client40011000false);
            else
                new 
TitleStorage().RemoveTitle(client40011000false);
            
#endregion
            #region The Champion Of Elite Pk Tournament
            
if (client.Entity.Titles.ContainsKey(TitlePacket.Titles.ElitePKChamption_High))
            {
                
DateTime date DateTime.Now;
                for (
int i DateTime.Now.Day31i++)
                {
                    
date = new DateTime(DateTime.Now.YearDateTime.Now.Monthi);
                    if (
date.DayOfWeek == DayOfWeek.Friday)
                    {
                        
date = new DateTime(DateTime.Now.YearDateTime.Now.Monthi19550);
                        break;
                    }
                }
                if (
date.Day == DateTime.Now.Day && date.Hour == DateTime.Now.Hour && date.Year == DateTime.Now.Year && date.Minute == date.Minute && DateTime.Now.DayOfWeek != DayOfWeek.Friday)
                {
                    for (
int i 131i++)
                    {
                        
date = new DateTime(DateTime.Now.YearDateTime.Now.Month 1i);
                        if (
date.DayOfWeek == DayOfWeek.Friday)
                        {
                            
date = new DateTime(DateTime.Now.YearDateTime.Now.Month 1i19550);
                            break;
                        }
                    }
                }
                
TimeSpan timespan date DateTime.Now;
                
int time = (int)(timespan.TotalSeconds);
                new 
TitleStorage().AddTitle(client600120falsetime);
            }
            else
                new 
TitleStorage().RemoveTitle(client600120false);
            
#endregion
            #region Own a 5-star garment
            
if (Database.WardrobeTable.AmountStarGarments(client5) >= 1)
            {
                new 
TitleStorage().AddTitle(client600322false);
            }
            else
                new 
TitleStorage().RemoveTitle(client600322false);
            
#endregion
            #region Own a 5-star Mount armor
            
if (Database.WardrobeTable.AmountStarMounts(client5) >= 1)
            {
                new 
TitleStorage().AddTitle(client600423false);
            }
            else
                new 
TitleStorage().RemoveTitle(client600423false);
            
#endregion
            #region Prestige Score reaches 600,000
            
if (client.Entity.TotalPerfectionScore >= 600000)
            {
                new 
TitleStorage().AddTitle(client20262026false);
            }
            else
                new 
TitleStorage().RemoveTitle(client20262026false);
            
#endregion
            #region Stars Score reaches 324
            
if (client.Equipment.TotalStars >= 324)
            {
                new 
TitleStorage().AddTitle(client60076007false);
            }
            else
                new 
TitleStorage().RemoveTitle(client60076007false);
            
#endregion
            #region Stars Score reaches 216
            
if (client.Equipment.TotalStars >= 216)
            {
                new 
TitleStorage().AddTitle(client60086008false);
            }
            else
                new 
TitleStorage().RemoveTitle(client60086008false);
            
#endregion
            #endregion
            #region Titles
            #region Union Emperor
            
if (client.Union != null)
                if (
client.Union.IsKingdom())
                    if (
client.Union.IsLeader(client.Entity.UID))
                        new 
TitleStorage().AddTitle(client11000false);
                    else
                        new 
TitleStorage().RemoveTitle(client11000false);
                else
                    new 
TitleStorage().RemoveTitle(client11000false);
            else
                new 
TitleStorage().RemoveTitle(client11000false);
            
#endregion
            #region VIP
            
if (client.Entity.VIPLevel 0)
            {
                switch (
client.Entity.VIPLevel)
                {
                    case 
1:
                    case 
2:
                    case 
3:
                    case 
4:
                        {
                            new 
TitleStorage().AddTitle(client20302030false);
                            break;
                        }
                    case 
5:
                    case 
6:
                        {
                            new 
TitleStorage().AddTitle(client20292029false);
                            break;
                        }
                    case 
7:
                        {
                            new 
TitleStorage().AddTitle(client20312031false);
                            break;
                        }
                }
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client20302030false);
                new 
TitleStorage().RemoveTitle(client20292029false);
                new 
TitleStorage().RemoveTitle(client20312031false);
            }
            
#endregion
            #region CollectedRandMonkey
            
if (CollectedRandMonkey(client))
            {
                new 
TitleStorage().AddTitle(client201314false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client201314false);
            }
            
#endregion
            #region Collect 8 kinds of permanent saint monkeys (can be activated via the Wardrobe after the event)
            
if (Collected8TypesMonkey(client))
            {
                new 
TitleStorage().AddTitle(client201617false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client201617false);
            }
            
#endregion
            #region Collect a permanent Solar Monkey
            
if (CollectedMonkey(client200559))
            {
                new 
TitleStorage().AddTitle(client201415false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client201415false);
            }
            
#endregion
            #region Collect a permanent Lunar Monkey
            
if (CollectedMonkey(client200560))
            {
                new 
TitleStorage().AddTitle(client201516false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client201516false);
            }
            
#endregion
            #region Tulip
            
if (client.Entity.MyFlowers != null && client.Entity.MyFlowers.RankTuilps == 1)
            {
                new 
TitleStorage().AddTitle(client60056005false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client60056005false);
            }
            
#endregion
            #region The Total Score of Chi Study Reaches 1.600 Points
            
if (client.ChiData.DragonPoints == 400 && client.ChiData.PhoenixPoints == 400 && client.ChiData.TigerPoints == 400 && client.ChiData.TurtlePoints == 400)
            {
                new 
TitleStorage().AddTitle(client20181false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client20181false);
            }
            
#endregion
            #region Prestige Score reaches 400,000
            
if (client.Entity.TotalPerfectionScore >= 400000)
            {
                new 
TitleStorage().AddTitle(client20272027false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client20272027false);
            }
            
#endregion
            #region The Total Score Of Jiang hu training reaches 81,000 points(Title)
            
if (client.Entity.MyJiang != null && client.Entity.MyJiang.Inner_Strength >= 81000)
            {
                new 
TitleStorage().AddTitle(client20045false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client20045false);
            }
            
#endregion
            #region Complete 320 Achievement
            
if (client.Entity.MyAchievement.Count(client.Entity.UID) >= 320)
            {
                new 
TitleStorage().AddTitle(client20012false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client20012false);
            }
            
#endregion
            #region Own 5 garments of 4-star or 5-star
            
if (Database.WardrobeTable.AmountStarGarments(client4) >= 5)
            {
                new 
TitleStorage().AddTitle(client20056false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client20056false);
            }
            
#endregion
            #region Own 5 Mount of 4-star or 5-star
            
if (Database.WardrobeTable.AmountStarMounts(client4) >= 5)
            {
                new 
TitleStorage().AddTitle(client20067false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client20067false);
            }
            
#endregion
            #region CelestialFox(200595)
            
if (CollectedCelestialFox(client))
            {
                new 
TitleStorage().AddTitle(client20502050false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client20502050false);
            }
            
#endregion
            #region CelestialFox(Fantasy)(200596)
            
if (CollectedCelestialFoxFantasy(client))
            {
                new 
TitleStorage().AddTitle(client20512051false);
            }
            else
            {
                new 
TitleStorage().RemoveTitle(client20512051false);
            }
            
#endregion
            #endregion
            #endregion
            #region GM
            /*if (client.Account.State == Database.AccountTable.AccountState.GameMaster)
            {
                foreach (var title in Database.WardrobeTable.Titles.Values)
                {
                    AddTitle(client, (short)title.Type, (short)title.ID);
                }
            }*/
            #endregion
        
}
        public 
void Login(Client.GameState clientbool Crossed falsestring val "")
        {
            if (!
Crossed)
            {
                
CheckTitles(client);
                
using (var cmd = new Database.MySqlCommand(Database.MySqlCommandType.SELECT).Select("entities").Where("UID"client.Account.EntityID))
                
using (var reader = new Database.MySqlReader(cmd))
                {
                    if (
reader.Read())
                    {
                        if (
reader.ReadString("Wardrobe") != "")
                        {
                            if (
reader.ReadString("Wardrobe").Contains("~"))
                            {
                                var 
wing reader.ReadString("Wardrobe").Split('~')[0];
                                
int type Convert.ToInt32(wing.Split('-')[0]);
                                
int id Convert.ToInt32(wing.Split('-')[1]);
                                if (
client.Entity.Wings.ContainsKey((uint)type) && client.Entity.Wings.ContainsValue((uint)id))
                                {
                                    var 
pkt = new TitleStorageProto()
                                    {
                                        
ActionId Action.Update,
                                        
Points client.Entity.UTitlePoints,
                                        
Type type,
                                        
Id id,
                                        
Value = new TitleValue()
                                        {
                                            
Type type,
                                            
Id id,
                                            
Equipped true
                                        
}
                                    };
                                    
client.Send(FinalizeProtoBuf(pkt));
                                    
client.Entity.EquippedWing StorageManager.Wing<int>(typeid);
                                    
client.Entity.NowEquippedWing.Clear();
                                    
client.Entity.NowEquippedWing.Add(type "~" id);
                                }
                                var 
title reader.ReadString("Wardrobe").Split('~')[1];
                                
int type2 Convert.ToInt32(title.Split('-')[0]);
                                
int id2 Convert.ToInt32(title.Split('-')[1]);
                                if (
client.Entity.WTitles.ContainsKey((uint)type2) && client.Entity.WTitles.ContainsValue((uint)id2))
                                {
                                    var 
pkt = new TitleStorageProto()
                                    {
                                        
ActionId Action.Update,
                                        
Points client.Entity.UTitlePoints,
                                        
Type type2,
                                        
Id id2,
                                        
Value = new TitleValue()
                                        {
                                            
Type type2,
                                            
Id id2,
                                            
Equipped true
                                        
}
                                    };
                                    
client.Send(FinalizeProtoBuf(pkt));
                                    
client.Entity.EquippedTitle StorageManager.Title<int>(type2id2);
                                    
client.Entity.NowEquippedTitle.Clear();
                                    
client.Entity.NowEquippedTitle.Add(type2 "~" id2);
                                }
                            }
                        }

                    }
                }
            }
            else
            {
                if (
val != "")
                {
                    if (
val.Contains("~"))
                    {
                        
CheckTitles(client);
                        var 
wing val.Split('~')[0];
                        
int type Convert.ToInt32(wing.Split('-')[0]);
                        
int id Convert.ToInt32(wing.Split('-')[1]);
                        var 
pkt = new TitleStorageProto()
                        {
                            
ActionId Action.Update,
                            
Points client.Entity.UTitlePoints,
                            
Type type,
                            
Id id,
                            
Value = new TitleValue()
                            {
                                
Type type,
                                
Id id,
                                
Equipped true
                            
}
                        };
                        
client.Send(FinalizeProtoBuf(pkt));
                        
client.Entity.EquippedWing StorageManager.Wing<int>(typeid);
                        
client.Entity.NowEquippedWing.Clear();
                        
client.Entity.NowEquippedWing.Add(type "~" id);

                        var 
title val.Split('~')[1];
                        
int type2 Convert.ToInt32(title.Split('-')[0]);
                        
int id2 Convert.ToInt32(title.Split('-')[1]);
                        
pkt.Type type2;
                        
pkt.Id id2;
                        
pkt.Value.Type type2;
                        
pkt.Value.Id id2;
                        
client.Send(FinalizeProtoBuf(pkt));
                        
client.Entity.EquippedTitle StorageManager.Title<int>(type2id2);
                        
client.Entity.NowEquippedTitle.Clear();
                        
client.Entity.NowEquippedTitle.Add(type2 "~" id2);
                    }
                }
            }

        }
        public 
void Handle(Client.GameState client)
        {
            switch (
Info.ActionId)
            {
                case 
Action.Unequip:
                    {
                        if (
StorageManager.Wing<bool>(Info.TypeInfo.Id))
                        {
                            
client.Entity.EquippedWing 0;
                            
client.Entity.NowEquippedWing.Clear();
                        }
                        else if (
StorageManager.Title<bool>(Info.TypeInfo.Id))
                        {
                            
client.Entity.EquippedTitle 0;
                            
client.Entity.NowEquippedTitle.Clear();
                        }
                        
client.Send(FinalizeProtoBuf(Info));
                        break;
                    }
                case 
Action.Equip:
                    {
                        if (
client.Entity.UTitlePoints StorageManager.GetTitlePoints((short)Info.Type, (short)Info.Id))
                            break;
                        if (
StorageManager.Wing<bool>(Info.TypeInfo.Id))
                        {
                            
client.Entity.EquippedWing StorageManager.Wing<int>(Info.TypeInfo.Id);
                            
client.Entity.NowEquippedWing.Clear();
                            
client.Entity.NowEquippedWing.Add(Info.Type "~" Info.Id);
                        }
                        else if (
StorageManager.Title<bool>(Info.TypeInfo.Id))
                        {
                            
client.Entity.EquippedTitle StorageManager.Title<int>(Info.TypeInfo.Id);
                            
client.Entity.NowEquippedTitle.Clear();
                            
client.Entity.NowEquippedTitle.Add(Info.Type "~" Info.Id);
                        }

                        
Info = new TitleStorageProto()
                        {
                            
ActionId Action.Equip,
                            
Points client.Entity.UTitlePoints,
                            
Type Info.Type,
                            
Id Info.Id,
                        };

                        
client.Send(FinalizeProtoBuf(Info));
                        break;
                    }
            }
            new 
TitleStorage().CheckTitles(client);
        }
        public 
void GetAll(Client.GameState client)
        {
            foreach (var 
title in Database.WardrobeTable.Titles.Values)
            {
                
AddTitle(client, (short)title.Type, (short)title.IDfalse);
            }
            
client.Entity.haveallTitles true;
        }
        public 
void AddTitle(Client.GameState clientshort _typeshort _idbool equipped falseint TimeInSeconds 0)
        {
            if (
StorageManager.Wing<bool>(_type_id))
            {
                if (!
client.Entity.Wings.ContainsValue((uint)_id))
                    
client.Entity.Wings.Add((uint)_type, (uint)_id);
                else return;
            }
            else
            {
                if (!
client.Entity.WTitles.ContainsValue((uint)_id))
                    
client.Entity.WTitles.Add((uint)_type, (uint)_id);
                else return;
            }
            
client.Entity.UTitlePoints += StorageManager.GetTitlePoints(_type_id);
            var 
pkt = new TitleStorageProto()
            {
                
ActionId Action.Update,
                
Points client.Entity.UTitlePoints,
                
Value = new TitleValue()
                {
                    
Type _type,
                    
Id _id,
                    
Equipped equipped,
                    
Time TimeInSeconds,
                }
            };

            
client.Send(FinalizeProtoBuf(pkt));
            if (
equipped)
            {
                if (
StorageManager.Wing<bool>(_type_id))
                {
                    
client.Entity.EquippedWing StorageManager.Wing<int>(_type_id);
                    
client.Entity.NowEquippedWing.Clear();
                    
client.Entity.NowEquippedWing.Add(_type "~" _id);
                }
                else if (
StorageManager.Title<bool>(_type_id))
                {
                    
client.Entity.EquippedTitle StorageManager.Title<int>(_type_id);
                    
client.Entity.NowEquippedTitle.Clear();
                    
client.Entity.NowEquippedTitle.Add(_type "~" _id);
                }
            }
        }
        public 
void RemoveTitle(Client.GameState clientshort _typeshort _idbool equipped false)
        {
            if (
StorageManager.Wing<bool>(_type_id))
            {
                if (
client.Entity.Wings.ContainsValue((uint)_id))
                {
                    
client.Entity.Wings.Remove((uint)_type);
                    if (
client.Entity.EquippedWing == StorageManager.Wing<int>(_type_id))
                    {
                        
client.Entity.EquippedWing 0;
                        
client.Entity.NowEquippedWing.Clear();

                        var 
pkt = new TitleStorageProto()
                        {
                            
ActionId Action.Unequip,
                            
Id _id,
                            
Type _type,
                            
Points client.Entity.UTitlePoints,
                            
Value = new TitleValue()
                            {
                                
Type _type,
                                
Id _id,
                                
Equipped false
                            
}

                        };
                        
client.Send(FinalizeProtoBuf(pkt));

                    }
                    
client.Entity.UTitlePoints -= StorageManager.GetTitlePoints(_type_id);
                    var 
pkt2 = new TitleStorageProto()
                    {
                        
ActionId Action.RemoveTitle,
                        
Id _id,
                        
Type _type,
                        
Points client.Entity.UTitlePoints,
                        
Value = new TitleValue()
                        {
                            
Type _type,
                            
Id _id,
                            
Equipped false
                        
}
                    };
                    
client.Send(FinalizeProtoBuf(pkt2));
                }
                else return;
            }
            else
            {
                if (
client.Entity.WTitles.ContainsValue((uint)_id))
                {
                    
client.Entity.WTitles.Remove((uint)_type);
                    if (
client.Entity.EquippedTitle == StorageManager.Title<int>(_type_id))
                    {
                        
client.Entity.EquippedTitle 0;
                        
client.Entity.NowEquippedTitle.Clear();
                        var 
pkt = new TitleStorageProto()
                        {
                            
ActionId Action.Unequip,
                            
Id _id,
                            
Type _type,
                            
Points client.Entity.UTitlePoints,
                            
Value = new TitleValue()
                            {
                                
Type _type,
                                
Id _id,
                                
Equipped false
                            
}
                        };
                        
client.Send(FinalizeProtoBuf(pkt));
                    }
                    
client.Entity.UTitlePoints -= StorageManager.GetTitlePoints(_type_id);
                    var 
pkt2 = new TitleStorageProto()
                    {
                        
ActionId Action.RemoveTitle,
                        
Id _id,
                        
Type _type,
                        
Points client.Entity.UTitlePoints,
                        
Value = new TitleValue()
                        {
                            
Type _type,
                            
Id _id,
                            
Equipped false
                        
}
                    };
                    
client.Send(FinalizeProtoBuf(pkt2));
                }
                else return;
            }
        }
        public 
byte[] FinalizeProtoBuf(TitleStorageProto titleStorageProto)
        {
            
using (var memoryStream = new MemoryStream())
            {
                
Serializer.SerializeWithLengthPrefix(memoryStreamtitleStorageProtoPrefixStyle.Fixed32);
                var 
pkt = new byte[memoryStream.Length];
                
memoryStream.ToArray().CopyTo(pkt0);
                
Writer.Write((ushort)memoryStream.Length0pkt);
                
Writer.Write((ushort)33012pkt);

                return 
pkt;
            }
        }


        public 
TitleStorageProto Info;
        [
Flags]
        public 
enum Action int
        
{
            
Update 0,
            
UseTitle 1,
            
RemoveTitle 3,
            
Equip 4,
            
Unequip 5,
        }
    }
    [
ProtoContract]
    public class 
TitleStorageProto
    
{
        [
ProtoMember(1IsRequired true)]
        public 
TitleStorage.Action ActionId;
        [
ProtoMember(2IsRequired true)]
        public 
int Points;
        [
ProtoMember(3IsRequired true)]
        public 
int Type;
        [
ProtoMember(4IsRequired true)]
        public 
int Id;
        [
ProtoMember(5IsRequired true)]
        public 
TitleValue Value;
    }
    [
ProtoContract]
    public class 
TitleValue
    
{
        [
ProtoMember(1IsRequired true)]
        public 
int Type;
        [
ProtoMember(2IsRequired true)]
        public 
int Id;
        [
ProtoMember(3IsRequired true)]
        public 
bool Equipped;
        [
ProtoMember(4IsRequired true)]
        public 
int Time;
    }




قديم 2019-08-19, 04:06 AM
المشاركة 3
LyokaWarior
.:: عضو نشيط ::.
  • غير متواجد
افتراضي رد: مشكلة في الوار دروب
بــووص ع كــوود التســيــف اوو بـدل الكــلأأس !!

بــااي#

قديم 2019-08-19, 04:16 AM
المشاركة 4
manshestar
.:: عضو نشيط ::.
  • غير متواجد
افتراضي رد: مشكلة في الوار دروب
جرب بدل دا بي العندك كلاس wardrobe
كود:
using protobuf;
using system;
using system.runtime.interopservices;
using system.collections.generic;
using system.io;
using system.linq;
using system.collections.concurrent;
using system.text;
using system.threading.tasks;

namespace 
mrhassan.network.gamepackets
{
    public 
sealed class coatstorage
    
{
        public 
coatstorage() { }
        public 
bool read(byte[] packet)
        {
            
using (var memorystream = new memorystream(packet))
            {
                
info serializer.deserializewithlengthprefix<coatstorageproto>(memorystreamprefixstyle.fixed32);
            }
            return 
true;
        }
        public 
void handle(client.gamestate client)
        {
            switch (
info.actionid)
            {
                case 
action.combine:
                    {
                        
conqueritem itemininventory null;
                        
conqueritem iteminsystem null;
                        if (
client.inventory.trygetitem((uint)info.itemidout itemininventory))
                        {
                            if (
client.entity.storageitems.trygetvalue((uint)info.itemguidout iteminsystem))
                            {
                                
iteminsystem.minutes += itemininventory.minutes;
                                
database.conqueritemtable.updateminutes(iteminsystem);
                                if (
iteminsystem.minutes != 0)
                                {
                                    
uint num;
                                    if (
datetime.now >= iteminsystem.timestamp.addminutes(iteminsystem.minutes))
                                    {
                                        
database.conqueritemtable.deleteitem(iteminsystem.uid);
                                    }
                                    else
                                    {
                                        
timespan span = new timespan(iteminsystem.timestamp.addminutes(iteminsystem.minutes).ticks);
                                        
timespan span2 = new timespan(datetime.now.ticks);
                                        
num = (uint)(span.totalseconds span2.totalseconds);
                                        
iteminsystem.timeleftinminutes num;
                                    }
                                }

                                
client.inventory.remove(itemininventorygame.enums.itemuse.remove);
                                var 
proto = new coatstorageproto();
                                
proto.actionid action.combine;
                                
proto.itemguid info.itemguid;
                                
proto.itemid = (int)iteminsystem.id;
                                
proto.additem(iteminsystem1);
                                
client.send(finalizeprotobuf(proto));
                            }
                        }
                        break;

                    }
                case 
action.equipcheck:
                    
Conqueritem myitem;
                    if (
client.inventory.trygetitem(info.itemguidout myitem))
                    {
                        var 
packet finalizeprotobuf(new coatstorageproto()
                        {
                            
actionid info.actionid,
                            
itemguid info.itemguid,
                        });
                        
client.send(packet);
                    }
                    break;
                case 
action.addtowardrobe:
                    {
                        if (!
canequip(infoclient))
                        {
                            if (
client.inventory.trygetitem(info.itemguidout myitem))
                            {
                                if (!
client.entity.storageitems.containskey(myitem.uid))
                                    
client.entity.storageitems.add(myitem.uidmyitem);
                                
myitem.inwardrobe true;
                                
database.conqueritemtable.updatewardrobe(myitem.inwardrobemyitem.uid);
                                
client.inventory.remove(myitemgame.enums.itemuse.none);
                            }
                            break;
                        }
                        if (
client.entity.storageitems.trygetvalue(info.itemguidout myitem))
                        {

                            foreach (var 
i in client.entity.storageitems.values)
                            {
                                if (
i.position == (byte)packethandler.getpositionfromid(myitem.id))
                                {
                                    if (
client.equipment.trygetitem((byte)i.position) != null)
                                        
client.equipment.remove((byte)i.positiontrue);
                                    
i.position 0;
                                    
database.conqueritemtable.updatelocation(iclient);
                                }
                            }
                            
myitem.position = (byte)packethandler.getpositionfromid(myitem.id);

                            if (!
client.equipment.add(myitem))
                            {
                                
client.equipment.remove((byte)myitem.positiontrue);
                            }
                            var 
iu = new itemusage(true);
                            
iu.id itemusage.unknown5;
                            
iu.uid myitem.uid;
                            
iu.dwparam myitem.position;
                            
client.send(iu.toarray());

                            
clientequip equips = new clientequip();
                            
equips.doequips(client);
                            
client.send(equips.toarray());

                            
database.conqueritemtable.updatelocation(myitemclient);
                            
client.equipment.updateentitypacket();
                            
client.send(finalizeprotobuf(new coatstorageproto()
                            {
                                
actionid info.actionid,
                                
itemguid info.itemguid,
                                
itemid = (int)myitem.id
                            
}));
                        }
                        else if (
client.inventory.trygetitem(info.itemguidout myitem))
                        {
                            
client.entity.storageitems.add(myitem.uidmyitem);
                            
myitem.inwardrobe true;
                            
database.conqueritemtable.updatewardrobe(myitem.inwardrobemyitem.uid);
                            
client.inventory.remove(myitemgame.enums.itemuse.none);
                            
client.send(finalizeprotobuf(new coatstorageproto()
                            {
                                
actionid info.actionid,
                                
itemguid info.itemguid,
                                
itemid = (int)myitem.id
                            
}));
                            foreach (var 
i in client.entity.storageitems.values)
                            {
                                if (
i.position != && i.position == (byte)packethandler.getpositionfromid(myitem.id))
                                {
                                    if (
client.equipment.trygetitem((byte)i.position) != null)
                                        
client.equipment.remove((byte)i.positiontrue);
                                    
i.position 0;
                                    
database.conqueritemtable.updatelocation(iclient);
                                }
                            }
                            
myitem.position = (byte)packethandler.getpositionfromid(myitem.id);

                            if (!
client.equipment.add(myitem))
                            {
                                
client.equipment.remove((byte)myitem.positiontrue);

                            }
                            var 
iu = new itemusage(true);
                            
iu.id itemusage.unknown5;
                            
iu.uid myitem.uid;
                            
iu.dwparam myitem.position;
                            
client.send(iu.toarray());

                            
clientequip equips = new clientequip();
                            
equips.doequips(client);
                            
client.send(equips.toarray());

                            
database.conqueritemtable.updatelocation(myitemclient);
                            
client.equipment.updateentitypacket();
                        }
                        break;
                    }
                case 
action.takeoff:
                    If (
client.entity.storageitems.trygetvalue(info.itemguidout myitem))
                    {
                        
client.send(finalizeprotobuf(new coatstorageproto()
                        {
                            
actionid info.actionid,
                            
itemguid info.itemguid,
                            
itemid = (int)myitem.id
                        
}));

                        var 
pos = (byte)packethandler.getpositionfromid(myitem.id);
                        
client.equipment.remove(postrue);
                        
clientequip equips = new clientequip();
                        
equips.doequips(client);
                        if (
pos == 17)
                            
equips.steedarmor 0;
                        else 
equips.garment 0;
                        
client.send(equips.toarray());
                        
client.equipment.updateentitypacket();

                    }
                    break;
                case 
action.retrieve:
                    If (
client.entity.storageitems.trygetvalue(info.itemguidout myitem) && client.inventory.count 40)
                    {
                        var 
pos = (byte)packethandler.getpositionfromid(myitem.id);
                        
client.entity.storageitems.remove(myitem.uid);
                        
myitem.inwardrobe false;
                        
database.conqueritemtable.updatewardrobe(myitem.inwardrobemyitem.uid);
                        
client.send(finalizeprotobuf(new coatstorageproto()
                        {
                            
actionid info.actionid,
                            
itemguid info.itemguid,
                            
itemid = (int)myitem.id
                        
}));
                        
client.inventory.add(myitemgame.enums.itemuse.move);
                        
clientequip equips = new clientequip();
                        
equips.doequips(client);
                        if (
pos == 17)
                            
equips.steedarmor 0;
                        else 
equips.garment 0;
                        
client.send(equips.toarray());
                        
client.equipment.updateentitypacket();
                    }
                    break;
            }
            new 
titlestorage().checktitles(client);
        }

        private 
bool canequip(coatstorageproto infoclient.gamestate client)
        {
            
conqueritem myitem;

            if (
client.inventory.trygetitem(info.itemguidout myitem) ||
            
client.entity.storageitems.trygetvalue(info.itemguidout myitem) ||
            
client.equipment.trygetitem(info.itemguidout myitem))
            {
                var 
dbinfo database.conqueriteminformation.baseinformations.containskey(myitem.id) ?
                
Database.conqueriteminformation.baseinformations[myitem.id] : Null;
                if (
dbinfo == null)
                    return 
false;
                
bool issteedarmor packethandler.getpositionfromid(myitem.id) == packethandler.positions.steedarmor;
                
bool canequipsteedarmor issteedarmor && client.entity.subclasses.classes.containskey(9)
                    && 
client.entity.subclasses.classes[9].phase >= database.conqueriteminformation.baseinformations[myitem.id].proficiency;

                if (!
issteedarmor)
                {
                    var 
charsex = (client.entity.body == 1003 || client.entity.body == 1004) ? "male" "female";
                    if ((
dbinfo.gender == Charsex != "male" Dbinfo.gender == False Charsex != "female"))
                    {
                        return 
false;
                    }
                }
                else if (
issteedarmor && !canequipsteedarmor) return false;
            }
            else return 
false;
            return 
true;
        }

        private 
byte[] finalizeprotobuf(coatstorageproto coatstorageproto)
        {
            
using (var memorystream = new memorystream())
            {
                
serializer.serializewithlengthprefix(memorystreamcoatstorageprotoprefixstyle.fixed32);
                var 
pkt = new byte[memorystream.length];
                
memorystream.toarray().copyto(pkt0);
                
writer.write((ushort)memorystream.length0pkt);
                
writer.write((ushort)33002pkt);

                return 
pkt;
            }
        }
        public 
void login(client.gamestate client)
        {
            var 
pkt = new coatstorageproto();
            foreach (var 
item in client.entity.storageitems.values)
            {
                
pkt.additem(item,
                    
client.entity.storageitems.values.where(=> i.id == item.id).count());
                
client.send(finalizeprotobuf(pkt));

                if (
item.position != 0)
                {
                    
client.equipment.add(item);

                    var 
iu = new itemusage(true);
                    
iu.id itemusage.unknown5;
                    
iu.uid item.uid;
                    
iu.dwparam item.position;
                    
client.send(iu.toarray());

                    
clientequip equips = new clientequip();
                    
equips.doequips(client);
                    
client.send(equips.toarray());

                    
database.conqueritemtable.updatelocation(itemclient);
                    
client.equipment.updateentitypacket();
                }

            }
            var 
currentgarment client.equipment.trygetitem((byte)packethandler.positions.garment);
            if (
currentgarment != null && !client.entity.storageitems.containskey(currentgarment.uid))
            {
                
client.entity.storageitems.add(currentgarment.uidcurrentgarment);
                
pkt.additem(currentgarment,
                    
client.entity.storageitems.values.where(=> i.id == currentgarment.id).count());
                
pkt.item.equipped true;
                
client.send(finalizeprotobuf(pkt));
            }
            var 
currentmountarmor client.equipment.trygetitem((byte)packethandler.positions.steedarmor);
            if (
currentmountarmor != null && !client.entity.storageitems.containskey(currentmountarmor.uid))
            {
                
client.entity.storageitems.add(currentmountarmor.uidcurrentmountarmor);
                
pkt.additem(currentmountarmor,
                    
client.entity.storageitems.values.where(=> i.id == currentmountarmor.id).count());
                
pkt.item.equipped true;
                
client.send(finalizeprotobuf(pkt));
            }

        }


        public 
coatstorageproto info;

        public 
enum action Int
        
{
            
/// <summary>
            /// load items in storage ...
            /// </summary>
            
login 0,
            
equipcheck 1,
            
retrieve 2,
            
combine 4,
            
addtowardrobe 5,
            
takeoff 6,
            
dwparam 7,
        }
    }
    [
protocontract]
    public class 
coatstorageproto
    
{
        [
protomember(1isrequired true)]
        public 
coatstorage.action actionid;
        [
protomember(2isrequired true)]
        public 
uint itemguid;
        [
protomember(3isrequired true)]
        public 
int itemid;
        [
protomember(4isrequired true)]
        public 
int junk;
        [
protomember(5isrequired true)]
        public 
itemstorage item;
        public 
void additem(conqueritem itemint stack)
        {
            
item = new itemstorage();
            
item.itemuid item.uid;
            
item.itemid = (int)item.id;
            
item.maximumdurability item.minimumdurability item.maximdurability;
            
item.stack stack;
            
item.firstsocket = (int)item.socketone;
            
item.secondsocket = (int)item.sockettwo;
            
item.plus item.plus;
            
item.protection item.bless;
            
item.bound item.bound;
            
item.health item.enchant;
            
item.socketprogress = (int)item.socketprogress;
            
item.effect item.effect;
            
item.color item.color;
            
item.craftprogress = (int)item.plusprogress;
            
item.locked item.lock == True False;
            
item.suspicious false;
            
item.inscribed false;
            
item.dwparam7 0;
            
item.equipped item.position != 0;
            
item.dwparam15 0;
            
item.time 0;
            
item.subtime 0;
        }

    }
    [
protocontract]
    public class 
itemstorage
    
{
        [
protomember(1isrequired true)]
        public 
uint itemuid;
        [
protomember(2isrequired true)]
        public 
int itemid;
        [
protomember(3isrequired true)]
        public 
int socketprogress;
        [
protomember(4isrequired true)]
        public 
int firstsocket;
        [
protomember(5isrequired true)]
        public 
int secondsocket;
        [
protomember(6isrequired true)]
        public 
game.enums.itemeffect effect;
        [
protomember(7isrequired true)]
        public 
int dwparam7;
        [
protomember(8isrequired true)]
        public 
int plus;
        [
protomember(9isrequired true)]
        public 
int protection;
        [
protomember(10isrequired true)]
        public 
bool bound;
        [
protomember(11isrequired true)]
        public 
int health;
        [
protomember(12isrequired true)]
        public 
bool equipped;
        [
protomember(13isrequired true)]
        public 
bool suspicious;
        [
protomember(14isrequired true)]
        public 
bool locked;
        [
protomember(15isrequired true)]
        public 
int dwparam15;
        [
protomember(16isrequired true)]
        public 
game.enums.color color;
        [
protomember(17isrequired true)]
        public 
int craftprogress;
        
/// <summary>
        /// inscribed in guild arsenal 
        /// this class is for wardrobe items which are garments or mount armors so this filed is always false
        /// </summary>
        
[protomember(18isrequired true)]
        public 
bool inscribed;
        
/// <summary>
        /// time left in seconds !
        /// </summary>
        
[protomember(19isrequired true)]
        public 
int time;
        
/// <summary>
        /// time left in minutes (if item not activated only)
        /// </summary>
        
[protomember(20isrequired true)]
        public 
int subtime;
        [
protomember(21isrequired true)]
        public 
int stack;
        [
protomember(22isrequired true)]
        public 
int minimumdurability;
        [
protomember(23isrequired true)]
        public 
int maximumdurability;
    }
    public static class 
storage
    
{
        private static 
string path constants.dataholderpath "storage.ini";

        public static 
void read(out storageinfo storageinfo)
        {
            
storageinfo = new storageinfo();
            var 
reader = new inifile(path);
            {
                
storageinfo.count reader.readint32("storage""storagetypecount"0);
                
storageinfo.storages = new storageinfo.storage[storageinfo.count];
                for (
int i 0storageinfo.counti++)
                {
                    var 
mysection = (1).tostring();
                    
storageinfo.storages[i] = new storageinfo.storage();
                    
storageinfo.storages[i].type reader.readint32(mysection"type"0);
                    
storageinfo.storages[i].unitcount reader.readint32(mysection"unitcount"0);
                    
storageinfo.storages[i].viewtype reader.readint32(mysection"viewtype"0);
                    
storageinfo.storages[i].units = new storageinfo.storage.unit[storageinfo.storages[i].unitcount];
                    for (
int u 0storageinfo.storages[i].unitcountu++)
                    {
                        var 
unitsection mysection "-" + (1).tostring();
                        
storageinfo.storages[i].units[u] = new storageinfo.storage.unit();
                        
storageinfo.storages[i].units[u].id reader.readint32(unitsection"id"0);
                        
storageinfo.storages[i].units[u].anisection reader.readstring(unitsection"anisection");
                        
storageinfo.storages[i].units[u].getwaytype3 reader.readint32(unitsection"getwaytype3"0);
                        
storageinfo.storages[i].units[u].getwaytext3 reader.readstring(unitsection"getwaytext3");
                        
storageinfo.storages[i].units[u].param reader.readstring(unitsection"param");
                        
storageinfo.storages[i].units[u].intro reader.readstring(unitsection"intro");
                    }

                }
            }
            
//console.writeline("storages loaded");
        
}
    }
    [
structlayout(layoutkind.sequential)]
    public class 
storageinfo
    
{
        public 
int count;
        public 
storage[] storages;
        public class 
storage
        
{
            public 
int type;
            public 
int unitcount;
            public 
int viewtype;
            public 
unit[] units;
            public class 
unit
            
{
                public 
int id;
                public 
string anisection;
                public 
int getwaytype3;
                public 
string getwaytext3;
                public 
string param;
                public 
string intro;
            }
        }
        public 
storage getstoragebytype(int type)
        {
            foreach (var 
storage in storages)
                if (
storage != null && storage.type == type)
                    return 
storage;
            return 
null;
        }
        public 
storage.unit getunitbyid(int idstorage _storage null)
        {
            if (
_storage != null)
            {
                foreach (var 
unit in _storage.units)
                    if (
unit.id == id)
                        return 
unit;
            }
            else
            {
                foreach (var 
storage in storages)
                    if (
storage != null)
                        foreach (var 
unit in storage.units)
                            if (
unit.id == id)
                                return 
unit;
            }
            return 
null;
        }
    }
    public 
sealed class storagemanager
    
{
        public static 
storageinfo info;

        public static 
void load()
        {
            try
            {
                
storage.read(out info);
            }
            catch (
exception e)
            {
                
console.writeline(e);
            }
        }

        public static 
t wing<t>(int _typeint _id)
        {
            
object value null;
            
int trash 0;
            if (
typeof(t) == typeof(bool))
            {
                
value int.tryparse(info.getunitbyid(_idinfo.getstoragebytype(_type)).paramout trash);
            }
            else if (
typeof(t) == typeof(int))
            {
                var 
mytype _type.tostring();
                var 
myid _id.tostring();


                while (
myid.length 4)
                    
myid "0" myid;
                
value int.parse(mytype myid);
            }
            else
                throw new 
exception("unknow type : " typeof(t).name);
            return (
t)convert.changetype(valuetypeof(t));
        }

       public static 
int gettitlepoints(short _typeshort _id)     
        {     
            if (
_type == && _id == 1000)     
                return 
150;     
            else if (
_type == 2018 && _id == 1)     
                return 
500;     
            else if (
_type == 2001 && _id == 2)     
                return 
300;     
            else if (
_type == 2002 && _id == 3)     
                return 
150;     
            else if (
_type == 2003 && _id == 4)     
                return 
300;     
            else if (
_type == 2004 && _id == 5)     
                return 
150;     
            else if (
_type == 2005 && _id == 6)     
                return 
150;     
            else if (
_type == 2006 && _id == 7)     
                return 
150;     
            else if (
_type == 2020 && _id == 2020)     
                return 
300;     
            else if (
_type == 2021 && _id == 2021)     
                return 
200;     
            else if (
_type == 2022 && _id == 2022)     
                return 
100;     
            else if (
_type == 2023 && _id == 2023)     
                return 
300;     
            else if (
_type == 2024 && _id == 2024)     
                return 
200;     
            else if (
_type == 2025 && _id == 2025)     
                return 
100;     
            else if (
_type == 2028 && _id == 2028)     
                return 
150;     
            else if (
_type == 2029 && _id == 2029)     
                return 
300;     
            else if (
_type == 2030 && _id == 2030)     
                return 
100;     
            else if (
_type == 2031 && _id == 2031)     
                return 
200;     
            else if (
_type == 6009 && _id == 6009)     
                return 
300;     
            else if (
_type == 6007 && _id == 6007)     
                return 
300;     
            else if (
_type == 6008 && _id == 6008)     
                return 
300;     
            else if (
_type == 2026 && _id == 2026)     
                return 
100;     
            else if (
_type == 2027 && _id == 2027)     
                return 
300;     
            else if (
_type == 2032 && _id == 2032)     
                return 
300;     
            else if (
_type == 2033 && _id == 2033)     
                return 
300;     
            else if (
_type == 6011 && _id == 6011)     
                return 
300;     
            else if (
_type == 2034 && _id == 2034)     
                return 
300;     
            else if (
_type == 2013 && _id == 14)     
                return 
300;     
            else if (
_type == 2014 && _id == 15)     
                return 
300;     
            else if (
_type == 2015 && _id == 16)     
                return 
300;     
            else if (
_type == 2016 && _id == 17)     
                return 
300;     
            else if (
_type == 2035 && _id == 2035)     
                return 
300;     
            else if (
_type == 2036 && _id == 2036)     
                return 
300;     
            else if (
_type == 2037 && _id == 2037)     
                return 
300;     
            else if (
_type == 2038 && _id == 2038)     
                return 
300;     
            else if (
_type == 2039 && _id == 2039)     
                return 
300;     
            else if (
_type == 2040 && _id == 2040)     
                return 
100;     
            else if (
_type == 2041 && _id == 2041)     
                return 
100;     
            else if (
_type == 2044 && _id == 2044)     
                return 
100;     
            else if (
_type == 2045 && _id == 2045)     
                return 
100;     
            else if (
_type == 6012 && _id == 6012)     
                return 
100;     
            else if (
_type == 2050 && _id == 2050)     
                return 
100;     
            else if (
_type == 2051 && _id == 2051)     
                return 
100;     
            else if (
_type == 2052 && _id == 2052)     
                return 
100;     
            else if (
_type == 2053 && _id == 2053)     
                return 
150;     
            else if (
_type == 2054 && _id == 2054)     
                return 
150;     
            else if (
_type == 2057 && _id == 2057)     
                return 
150;     
            else if (
_type == 2056 && _id == 2056)     
                return 
100;     
            else if (
_type == 2046 && _id == 2046)     
                return 
150;     
            else if (
_type == 2047 && _id == 2047)     
                return 
150;     
            else if (
_type == 2048 && _id == 2048)     
                return 
150;     
            else if (
_type == 2049 && _id == 2049)     
                return 
150;     
            else if (
_type == 2059 && _id == 2059)     
                return 
100;     
            else if (
_type == 2060 && _id == 2060)     
                return 
150;     
            else if (
_type == 2061 && _id == 2061)     
                return 
150;     
            else if (
_type == 2062 && _id == 2062)     
                return 
150;     
            else if (
_type == 6013 && _id == 6013)     
                return 
100;     
            else if (
_type == 6014 && _id == 6014)     
                return 
150;     
            else if (
_type == 6015 && _id == 6015)     
                return 
150;     
            else if (
_type == 6016 && _id == 6016)     
                return 
150;     
            else if (
_type == 6017 && _id == 6017)     
                return 
150;     
            else if (
_type == 2063 && _id == 2063)     
                return 
150;     
            else if (
_type == 2064 && _id == 2064)     
                return 
150;     
            else if (
_type == 2065 && _id == 2065)     
                return 
150;     
            return 
0;     
        
       }
        public static 
t title<t>(int _typeint _id)
        {
            
object value null;
            
int trash 0;
            if (
typeof(t) == typeof(bool))
            {
                
value = !int.tryparse(info.getunitbyid(_idinfo.getstoragebytype(_type)).paramout trash);
            }
            else if (
typeof(t) == typeof(int))
            {
                var 
mytype _type.tostring();
                var 
myid _id.tostring();

                while (
myid.length 4)
                    
myid "0" myid;
                
value int.parse(mytype myid);
            }
            else
                throw new 
exception("unknow type : " typeof(t).name);
            return (
t)convert.changetype(valuetypeof(t));
        }
    }
    public 
sealed class titlestorage
    
{
        public 
titlestorage() { }
        public 
bool read(byte[] packet)
        {
            
using (var memorystream = new memorystream(packet))
            {
                
info serializer.deserializewithlengthprefix<titlestorageproto>(memorystreamprefixstyle.fixed32);
            }
            return 
true;
        }
        private 
bool collectedrandmonkey(client.gamestate client)
        {
            return 
client.entity.storageitems.values.where(=> monkeysvalues.contains(p.id)).tolist().count True False;
        }
        private 
bool collectedcelestialfox(client.gamestate client)
        {
            return 
client.entity.storageitems.values.where(=> p.id == 200595).tolist().count True False;
        }
        private 
bool collectedcelestialfoxfantasy(client.gamestate client)
        {
            return 
client.entity.storageitems.values.where(=> p.id == 200596).tolist().count True False;
        }
        list<
uintmonkeysvalues = new list<uint>()
        {
            
200553,
            
200554,
            
200555,
            
200556,
            
200557,
            
200558,
            
200559,
            
200560
        
};
        private 
bool collected8typesmonkey(client.gamestate client)
        {
            list<
uintids = new list<uint>();
            var 
dict client.entity.storageitems.values.tolist();
            for (
int x 0dict.countx++)
            {
                if (
monkeysvalues.contains(dict[x].id) && !ids.contains(dict[x].id))
                {
                    
ids.add(dict[x].id);
                }
            }
            return 
ids.count == True False;
        }
        private 
bool collectedmonkey(client.gamestate clientuint id)
        {
            return 
client.entity.storageitems.values.where(=> p.id == id).tolist().count True False;
        }
        public 
void checktitles(client.gamestate client)
        {
            if (
client.entity.havealltitles) { getall(client); return; }
            
#region titles and wings equips
            #region wings
            #region union emperor
            
if (client.union != null)
                if (
client.union.iskingdom())
                    if (
client.union.isleader(client.entity.uid))
                        new 
titlestorage().addtitle(client40011000false);
                    else
                        new 
titlestorage().removetitle(client40011000false);
                else
                    new 
titlestorage().removetitle(client40011000false);
            else
                new 
titlestorage().removetitle(client40011000false);
            
#endregion
            #region the champion of elite pk tournament
            
if (client.entity.titles.containskey(titlepacket.titles.elitepkchamption_high))
            {
                
datetime date datetime.now;
                for (
int i datetime.now.day31i++)
                {
                    
date = new datetime(datetime.now.yeardatetime.now.monthi);
                    if (
date.dayofweek == dayofweek.friday)
                    {
                        
date = new datetime(datetime.now.yeardatetime.now.monthi19550);
                        break;
                    }
                }
                if (
date.day == datetime.now.day && date.hour == datetime.now.hour && date.year == datetime.now.year && date.minute == date.minute && datetime.now.dayofweek != dayofweek.friday)
                {
                    for (
int i 131i++)
                    {
                        
date = new datetime(datetime.now.yeardatetime.now.month 1i);
                        if (
date.dayofweek == dayofweek.friday)
                        {
                            
date = new datetime(datetime.now.yeardatetime.now.month 1i19550);
                            break;
                        }
                    }
                }
                
timespan timespan date datetime.now;
                
int time = (int)(timespan.totalseconds);
                new 
titlestorage().addtitle(client600120falsetime);
            }
            else
                new 
titlestorage().removetitle(client600120false);
            
#endregion
            #region own a 5-star garment
            
if (database.wardrobetable.amountstargarments(client5) >= 1)
            {
                new 
titlestorage().addtitle(client600322false);
            }
            else
                new 
titlestorage().removetitle(client600322false);
            
#endregion
            #region own a 5-star mount armor
            
if (database.wardrobetable.amountstarmounts(client5) >= 1)
            {
                new 
titlestorage().addtitle(client600423false);
            }
            else
                new 
titlestorage().removetitle(client600423false);
            
#endregion
            #region prestige score reaches 600,000
            
if (client.entity.totalperfectionscore >= 600000)
            {
                new 
titlestorage().addtitle(client20262026false);
            }
            else
                new 
titlestorage().removetitle(client20262026false);
            
#endregion
            #region stars score reaches 324
            
if (client.equipment.totalstars >= 324)
            {
                new 
titlestorage().addtitle(client60076007false);
            }
            else
                new 
titlestorage().removetitle(client60076007false);
            
#endregion
            #region stars score reaches 216
            
if (client.equipment.totalstars >= 216)
            {
                new 
titlestorage().addtitle(client60086008false);
            }
            else
                new 
titlestorage().removetitle(client60086008false);
            
#endregion
            #endregion
            #region titles
            #region union emperor
            
if (client.union != null)
                if (
client.union.iskingdom())
                    if (
client.union.isleader(client.entity.uid))
                        new 
titlestorage().addtitle(client11000false);
                    else
                        new 
titlestorage().removetitle(client11000false);
                else
                    new 
titlestorage().removetitle(client11000false);
            else
                new 
titlestorage().removetitle(client11000false);
            
#endregion
            #region vip
            
if (client.entity.viplevel 0)
            {
                switch (
client.entity.viplevel)
                {
                    case 
1:
                    Case 
2:
                    Case 
3:
                    Case 
4:
                        {
                            new 
titlestorage().addtitle(client20302030false);
                            break;
                        }
                    case 
5:
                    Case 
6:
                        {
                            new 
titlestorage().addtitle(client20292029false);
                            break;
                        }
                    case 
7:
                        {
                            new 
titlestorage().addtitle(client20312031false);
                            break;
                        }
                }
            }
            else
            {
                new 
titlestorage().removetitle(client20302030false);
                new 
titlestorage().removetitle(client20292029false);
                new 
titlestorage().removetitle(client20312031false);
            }
            
#endregion
            #region collectedrandmonkey
            
if (collectedrandmonkey(client))
            {
                new 
titlestorage().addtitle(client201314false);
            }
            else
            {
                new 
titlestorage().removetitle(client201314false);
            }
            
#endregion
            #region collect 8 kinds of permanent saint monkeys (can be activated via the wardrobe after the event)
            
if (collected8typesmonkey(client))
            {
                new 
titlestorage().addtitle(client201617false);
            }
            else
            {
                new 
titlestorage().removetitle(client201617false);
            }
            
#endregion
            #region collect a permanent solar monkey
            
if (collectedmonkey(client200559))
            {
                new 
titlestorage().addtitle(client201415false);
            }
            else
            {
                new 
titlestorage().removetitle(client201415false);
            }
            
#endregion
            #region collect a permanent lunar monkey
            
if (collectedmonkey(client200560))
            {
                new 
titlestorage().addtitle(client201516false);
            }
            else
            {
                new 
titlestorage().removetitle(client201516false);
            }
            
#endregion
            #region tulip
            
if (client.entity.myflowers != null && client.entity.myflowers.ranktuilps == 1)
            {
                new 
titlestorage().addtitle(client60056005false);
            }
            else
            {
                new 
titlestorage().removetitle(client60056005false);
            }
            
#endregion
            #region the total score of chi study reaches 1.600 points
            
if (client.chidata.dragonpoints == 400 && client.chidata.phoenixpoints == 400 && client.chidata.tigerpoints == 400 && client.chidata.turtlepoints == 400)
            {
                new 
titlestorage().addtitle(client20181false);
            }
            else
            {
                new 
titlestorage().removetitle(client20181false);
            }
            
#endregion
            #region prestige score reaches 400,000
            
if (client.entity.totalperfectionscore >= 400000)
            {
                new 
titlestorage().addtitle(client20272027false);
            }
            else
            {
                new 
titlestorage().removetitle(client20272027false);
            }
            
#endregion
            #region the total score of jiang hu training reaches 81,000 points(title)
            
if (client.entity.myjiang != null && client.entity.myjiang.inner_strength >= 81000)
            {
                new 
titlestorage().addtitle(client20045false);
            }
            else
            {
                new 
titlestorage().removetitle(client20045false);
            }
            
#endregion
            #region complete 320 achievement
            
if (client.entity.myachievement.count(client.entity.uid) >= 320)
            {
                new 
titlestorage().addtitle(client20012false);
            }
            else
            {
                new 
titlestorage().removetitle(client20012false);
            }
            
#endregion
            #region own 5 garments of 4-star or 5-star
            
if (database.wardrobetable.amountstargarments(client4) >= 5)
            {
                new 
titlestorage().addtitle(client20056false);
            }
            else
            {
                new 
titlestorage().removetitle(client20056false);
            }
            
#endregion
            #region own 5 mount of 4-star or 5-star
            
if (database.wardrobetable.amountstarmounts(client4) >= 5)
            {
                new 
titlestorage().addtitle(client20067false);
            }
            else
            {
                new 
titlestorage().removetitle(client20067false);
            }
            
#endregion
            #region celestialfox(200595)
            
if (collectedcelestialfox(client))
            {
                new 
titlestorage().addtitle(client20502050false);
            }
            else
            {
                new 
titlestorage().removetitle(client20502050false);
            }
            
#endregion
            #region celestialfox(fantasy)(200596)
            
if (collectedcelestialfoxfantasy(client))
            {
                new 
titlestorage().addtitle(client20512051false);
            }
            else
            {
                new 
titlestorage().removetitle(client20512051false);
            }
            
#endregion
            #endregion
            #endregion
            #region gm
            /*if (client.account.state == database.accounttable.accountstate.gamemaster)
            {
                foreach (var title in database.wardrobetable.titles.values)
                {
                    addtitle(client, (short)title.type, (short)title.id);
                }
            }*/
            #endregion
        
}
        public 
void login(client.gamestate clientbool crossed falsestring val "")
        {
            if (!
crossed)
            {
                
checktitles(client);
                
using (var cmd = new database.mysqlcommand(database.mysqlcommandtype.select).select("entities").where("uid"client.account.entityid))
                
using (var reader = new database.mysqlreader(cmd))
                {
                    if (
reader.read())
                    {
                        if (
reader.readstring("wardrobe") != "")
                        {
                            if (
reader.readstring("wardrobe").contains("~"))
                            {
                                var 
wing reader.readstring("wardrobe").split('~')[0];
                                
int type convert.toint32(wing.split('-')[0]);
                                
int id convert.toint32(wing.split('-')[1]);
                                if (
client.entity.wings.containskey((uint)type) && client.entity.wings.containsvalue((uint)id))
                                {
                                    var 
pkt = new titlestorageproto()
                                    {
                                        
actionid action.update,
                                        
points client.entity.utitlepoints,
                                        
type type,
                                        
id id,
                                        
value = new titlevalue()
                                        {
                                            
type type,
                                            
id id,
                                            
equipped true
                                        
}
                                    };
                                    
client.send(finalizeprotobuf(pkt));
                                    
client.entity.equippedwing storagemanager.wing<int>(typeid);
                                    
client.entity.nowequippedwing.clear();
                                    
client.entity.nowequippedwing.add(type "~" id);
                                }
                                var 
title reader.readstring("wardrobe").split('~')[1];
                                
int type2 convert.toint32(title.split('-')[0]);
                                
int id2 convert.toint32(title.split('-')[1]);
                                if (
client.entity.wtitles.containskey((uint)type2) && client.entity.wtitles.containsvalue((uint)id2))
                                {
                                    var 
pkt = new titlestorageproto()
                                    {
                                        
actionid action.update,
                                        
points client.entity.utitlepoints,
                                        
type type2,
                                        
id id2,
                                        
value = new titlevalue()
                                        {
                                            
type type2,
                                            
id id2,
                                            
equipped true
                                        
}
                                    };
                                    
client.send(finalizeprotobuf(pkt));
                                    
client.entity.equippedtitle storagemanager.title<int>(type2id2);
                                    
client.entity.nowequippedtitle.clear();
                                    
client.entity.nowequippedtitle.add(type2 "~" id2);
                                }
                            }
                        }

                    }
                }
            }
            else
            {
                if (
val != "")
                {
                    if (
val.contains("~"))
                    {
                        
checktitles(client);
                        var 
wing val.split('~')[0];
                        
int type convert.toint32(wing.split('-')[0]);
                        
int id convert.toint32(wing.split('-')[1]);
                        var 
pkt = new titlestorageproto()
                        {
                            
actionid action.update,
                            
points client.entity.utitlepoints,
                            
type type,
                            
id id,
                            
value = new titlevalue()
                            {
                                
type type,
                                
id id,
                                
equipped true
                            
}
                        };
                        
client.send(finalizeprotobuf(pkt));
                        
client.entity.equippedwing storagemanager.wing<int>(typeid);
                        
client.entity.nowequippedwing.clear();
                        
client.entity.nowequippedwing.add(type "~" id);

                        var 
title val.split('~')[1];
                        
int type2 convert.toint32(title.split('-')[0]);
                        
int id2 convert.toint32(title.split('-')[1]);
                        
pkt.type type2;
                        
pkt.id id2;
                        
pkt.value.type type2;
                        
pkt.value.id id2;
                        
client.send(finalizeprotobuf(pkt));
                        
client.entity.equippedtitle storagemanager.title<int>(type2id2);
                        
client.entity.nowequippedtitle.clear();
                        
client.entity.nowequippedtitle.add(type2 "~" id2);
                    }
                }
            }

        }
        public 
void handle(client.gamestate client)
        {
            switch (
info.actionid)
            {
                case 
action.unequip:
                    {
                        if (
storagemanager.wing<bool>(info.typeinfo.id))
                        {
                            
client.entity.equippedwing 0;
                            
client.entity.nowequippedwing.clear();
                        }
                        else if (
storagemanager.title<bool>(info.typeinfo.id))
                        {
                            
client.entity.equippedtitle 0;
                            
client.entity.nowequippedtitle.clear();
                        }
                        
client.send(finalizeprotobuf(info));
                        break;
                    }
                case 
action.equip:
                    {
                        if (
client.entity.utitlepoints storagemanager.gettitlepoints((short)info.type, (short)info.id))
                            break;
                        if (
storagemanager.wing<bool>(info.typeinfo.id))
                        {
                            
client.entity.equippedwing storagemanager.wing<int>(info.typeinfo.id);
                            
client.entity.nowequippedwing.clear();
                            
client.entity.nowequippedwing.add(info.type "~" info.id);
                        }
                        else if (
storagemanager.title<bool>(info.typeinfo.id))
                        {
                            
client.entity.equippedtitle storagemanager.title<int>(info.typeinfo.id);
                            
client.entity.nowequippedtitle.clear();
                            
client.entity.nowequippedtitle.add(info.type "~" info.id);
                        }

                        
info = new titlestorageproto()
                        {
                            
actionid action.equip,
                            
points client.entity.utitlepoints,
                            
type info.type,
                            
id info.id,
                        };

                        
client.send(finalizeprotobuf(info));
                        break;
                    }
            }
            new 
titlestorage().checktitles(client);
        }
        public 
void getall(client.gamestate client)
        {
            foreach (var 
title in database.wardrobetable.titles.values)
            {
                
addtitle(client, (short)title.type, (short)title.idfalse);
            }
            
client.entity.havealltitles true;
        }
        public 
void addtitle(client.gamestate clientshort _typeshort _idbool equipped falseint timeinseconds 0)
        {
            if (
storagemanager.wing<bool>(_type_id))
            {
                if (!
client.entity.wings.containsvalue((uint)_id))
                    
client.entity.wings.add((uint)_type, (uint)_id);
                else return;
            }
            else
            {
                if (!
client.entity.wtitles.containsvalue((uint)_id))
                    
client.entity.wtitles.add((uint)_type, (uint)_id);
                else return;
            }
            
client.entity.utitlepoints += storagemanager.gettitlepoints(_type_id);
            var 
pkt = new titlestorageproto()
            {
                
actionid action.update,
                
points client.entity.utitlepoints,
                
value = new titlevalue()
                {
                    
type _type,
                    
id _id,
                    
equipped equipped,
                    
time timeinseconds,
                }
            };

            
client.send(finalizeprotobuf(pkt));
            if (
equipped)
            {
                if (
storagemanager.wing<bool>(_type_id))
                {
                    
client.entity.equippedwing storagemanager.wing<int>(_type_id);
                    
client.entity.nowequippedwing.clear();
                    
client.entity.nowequippedwing.add(_type "~" _id);
                }
                else if (
storagemanager.title<bool>(_type_id))
                {
                    
client.entity.equippedtitle storagemanager.title<int>(_type_id);
                    
client.entity.nowequippedtitle.clear();
                    
client.entity.nowequippedtitle.add(_type "~" _id);
                }
            }
        }
        public 
void removetitle(client.gamestate clientshort _typeshort _idbool equipped false)
        {
            if (
storagemanager.wing<bool>(_type_id))
            {
                if (
client.entity.wings.containsvalue((uint)_id))
                {
                    
client.entity.wings.remove((uint)_type);
                    if (
client.entity.equippedwing == storagemanager.wing<int>(_type_id))
                    {
                        
client.entity.equippedwing 0;
                        
client.entity.nowequippedwing.clear();

                        var 
pkt = new titlestorageproto()
                        {
                            
actionid action.unequip,
                            
id _id,
                            
type _type,
                            
points client.entity.utitlepoints,
                            
value = new titlevalue()
                            {
                                
type _type,
                                
id _id,
                                
equipped false
                            
}

                        };
                        
client.send(finalizeprotobuf(pkt));

                    }
                    
client.entity.utitlepoints -= storagemanager.gettitlepoints(_type_id);
                    var 
pkt2 = new titlestorageproto()
                    {
                        
actionid action.removetitle,
                        
id _id,
                        
type _type,
                        
points client.entity.utitlepoints,
                        
value = new titlevalue()
                        {
                            
type _type,
                            
id _id,
                            
equipped false
                        
}
                    };
                    
client.send(finalizeprotobuf(pkt2));
                }
                else return;
            }
            else
            {
                if (
client.entity.wtitles.containsvalue((uint)_id))
                {
                    
client.entity.wtitles.remove((uint)_type);
                    if (
client.entity.equippedtitle == storagemanager.title<int>(_type_id))
                    {
                        
client.entity.equippedtitle 0;
                        
client.entity.nowequippedtitle.clear();
                        var 
pkt = new titlestorageproto()
                        {
                            
actionid action.unequip,
                            
id _id,
                            
type _type,
                            
points client.entity.utitlepoints,
                            
value = new titlevalue()
                            {
                                
type _type,
                                
id _id,
                                
equipped false
                            
}
                        };
                        
client.send(finalizeprotobuf(pkt));
                    }
                    
client.entity.utitlepoints -= storagemanager.gettitlepoints(_type_id);
                    var 
pkt2 = new titlestorageproto()
                    {
                        
actionid action.removetitle,
                        
id _id,
                        
type _type,
                        
points client.entity.utitlepoints,
                        
value = new titlevalue()
                        {
                            
type _type,
                            
id _id,
                            
equipped false
                        
}
                    };
                    
client.send(finalizeprotobuf(pkt2));
                }
                else return;
            }
        }
        public 
byte[] finalizeprotobuf(titlestorageproto titlestorageproto)
        {
            
using (var memorystream = new memorystream())
            {
                
serializer.serializewithlengthprefix(memorystreamtitlestorageprotoprefixstyle.fixed32);
                var 
pkt = new byte[memorystream.length];
                
memorystream.toarray().copyto(pkt0);
                
writer.write((ushort)memorystream.length0pkt);
                
writer.write((ushort)33012pkt);

                return 
pkt;
            }
        }


        public 
titlestorageproto info;
        [
flags]
        public 
enum action Int
        
{
            
update 0,
            
usetitle 1,
            
removetitle 3,
            
equip 4,
            
unequip 5,
        }
    }
    [
protocontract]
    public class 
titlestorageproto
    
{
        [
protomember(1isrequired true)]
        public 
titlestorage.action actionid;
        [
protomember(2isrequired true)]
        public 
int points;
        [
protomember(3isrequired true)]
        public 
int type;
        [
protomember(4isrequired true)]
        public 
int id;
        [
protomember(5isrequired true)]
        public 
titlevalue value;
    }
    [
protocontract]
    public class 
titlevalue
    
{
        [
protomember(1isrequired true)]
        public 
int type;
        [
protomember(2isrequired true)]
        public 
int id;
        [
protomember(3isrequired true)]
        public 
bool equipped;
        [
protomember(4isrequired true)]
        public 
int time;
    }



جربت للاسف نفس المشكلة و خت الكلاس من سورس مستر باندا نفس المشكلة ثواني هنزل صورة المشكلة لما بجيب جرمنت و البسه و اقفل الاكونت بيحصل ايرور في القنصل ثواني هورهولك

قديم 2019-08-19, 04:19 AM
المشاركة 5
manshestar
.:: عضو نشيط ::.
  • غير متواجد
افتراضي رد: مشكلة في الوار دروب
دي صورة المشكلة الي بتحصل لما بلبس جرمنت و اقفل الاكونت بيظهر الايرور ده في القنصل

قديم 2019-08-19, 04:25 AM
المشاركة 6
Hassan Emprator
.:: عضو خبير ::.
  • غير متواجد
افتراضي رد: مشكلة في الوار دروب
دي صورة المشكلة الي بتحصل لما بلبس جرمنت و اقفل الاكونت بيظهر الايرور ده في القنصل
تمام يحبي هتبحث عن الفويد دا


كود:
public static void SaveJiangHu(Client.GameState client

هتبدله بي دا

لما تضضيف دا الايرور هيتحل


كود:
public static void SaveJiangHu(Client.GameState client)
        {
            try
            {
                
MemoryStream stream = new MemoryStream();
                
BinaryWriter writer = new BinaryWriter(stream);
                
client.Entity.MyJiang.Serialize(writer);
                
///////////                    
                
string SQL "UPDATE `jiang` SET Powers=@Powers,OwnName=@OwnName,CustomizedName=@CustomizedName where UID = " client.Entity.UID " ;";
                
byte[] rawData stream.ToArray();
                
using (var conn DataHolder.MySqlConnection)
                {
                    
conn.Open();
                    
using (var cmd = new MySql.Data.MySqlClient.MySqlCommand())
                    {
                        
cmd.Connection conn;
                        
cmd.CommandText SQL;
                        
cmd.Parameters.AddWithValue("@Powers"rawData);
                        
cmd.Parameters.AddWithValue("@OwnName"client.Entity.MyJiang.OwnName);
                        
cmd.Parameters.AddWithValue("@CustomizedName"client.Entity.MyJiang.CustomizedName);
                        
cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (
Exception e)
            {
                
Console.WriteLine(e);
            }

        } 


قديم 2019-08-19, 04:30 AM
المشاركة 7
manshestar
.:: عضو نشيط ::.
  • غير متواجد
افتراضي رد: مشكلة في الوار دروب
تمام يحبي هتبحث عن الفويد دا


كود:
public static void savejianghu(client.gamestate client

هتبدله بي دا

لما تضضيف دا الايرور هيتحل


كود:
public static void savejianghu(client.gamestate client)
        {
            try
            {
                
memorystream stream = new memorystream();
                
binarywriter writer = new binarywriter(stream);
                
client.entity.myjiang.serialize(writer);
                
///////////                    
                
string sql "update `jiang` set powers=@powers,ownname=@ownname,customizedname=@customizedname where uid = " client.entity.uid " ;";
                
byte[] rawdata stream.toarray();
                
using (var conn dataholder.mysqlconnection)
                {
                    
conn.open();
                    
using (var cmd = new mysql.data.mysqlclient.mysqlcommand())
                    {
                        
cmd.connection conn;
                        
cmd.commandtext sql;
                        
cmd.parameters.addwithvalue("@powers"rawdata);
                        
cmd.parameters.addwithvalue("@ownname"client.entity.myjiang.ownname);
                        
cmd.parameters.addwithvalue("@customizedname"client.entity.myjiang.customizedname);
                        
cmd.executenonquery();
                    }
                }
            }
            catch (
exception e)
            {
                
console.writeline(e);
            }

        } 

هو ده نفس الي عندي ع فكرة يا حسن

قديم 2019-08-19, 04:32 AM
المشاركة 8
Hassan Emprator
.:: عضو خبير ::.
  • غير متواجد
افتراضي رد: مشكلة في الوار دروب
هو ده نفس الي عندي ع فكرة يا حسن
اصل انت الي في الصوره دا ايرورو في سطر 283 وي السطرو وداني للفويت دا وعا فكره دا ايرور في الجيانغ ملوش دعوه بي الوار دروب

قديم 2019-08-19, 04:33 AM
المشاركة 9
manshestar
.:: عضو نشيط ::.
  • غير متواجد
افتراضي رد: مشكلة في الوار دروب
اصل انت الي في الصوره دا ايرورو في سطر 283 وي السطرو وداني للفويت دا وعا فكره دا ايرور في الجيانغ ملوش دعوه بي الوار دروب
يا حبيبي عارف انا قصدي بقولك ان الكود الي انت بعته هو هو الي موجود في الفويد بالظبط و علشان بردو اكملها حطيط نفس الكود بتاعك و نفس الحوار المشكلة ان الاكواد مفهاش اي اختلاف


العلامات المرجعية



الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1)
 

الانتقال السريع



الساعة الآن 09:09 PM

Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.