|
|
المشاركات 1,941 |
+التقييم 0.96 |
تاريخ التسجيل Apr 2019 |
الاقامة Egypt |
نظام التشغيل windows 7 |
رقم العضوية 1 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProtoBuf;
using System.IO;
namespace Conquer_Online_Server.Network.GamePackets
{
[ProtoContract]
public class ItemPacket
{
[ProtoMember(1, IsRequired = true)]
public uint UID;
[ProtoMember(2, IsRequired = true)]
public uint ID;
[ProtoMember(3, IsRequired = true)]
public uint Unknowen1;
[ProtoMember(4, IsRequired = true)]
public uint Socket1;
[ProtoMember(5, IsRequired = true)]
public uint Socket2;
[ProtoMember(6, IsRequired = true)]
public uint Unknowen4;
[ProtoMember(7, IsRequired = true)]
public uint Unknowen5;
[ProtoMember(8, IsRequired = true)]
public uint Plus;
[ProtoMember(9, IsRequired = true)]
public uint Bless;
[ProtoMember(10, IsRequired = true)]
public uint Bound;
[ProtoMember(11, IsRequired = true)]
public uint HP;
[ProtoMember(12, IsRequired = true)]
public uint Unknowen10;
[ProtoMember(13, IsRequired = true)]
public uint Unknowen11;
[ProtoMember(14, IsRequired = true)]
public uint Lock;
[ProtoMember(15, IsRequired = true)]
public uint Unknowen13;
[ProtoMember(16, IsRequired = true)]
public uint Unknowen14;
[ProtoMember(17, IsRequired = true)]
public uint Unknowen15;
[ProtoMember(18, IsRequired = true)]
public uint Unknowen16;
[ProtoMember(19, IsRequired = true)]
public uint Unknowen17;
[ProtoMember(20, IsRequired = true)]
public uint Unknowen18;
[ProtoMember(21, IsRequired = true)]
public uint Unknowen19;
[ProtoMember(22, IsRequired = true)]
public uint Dura;
[ProtoMember(23, IsRequired = true)]
public uint MaxDura;
}
[ProtoContract]
public class WarDrobePacket
{
[ProtoMember(1, IsRequired = true)]
public WarDrobe.ActionType Action;
[ProtoMember(2, IsRequired = true)]
public uint UID;
[ProtoMember(3, IsRequired = true)]
public uint Data;
[ProtoMember(4, IsRequired = true)]
public uint Unknowen;
}
[ProtoContract]
public class StoragePacket
{
[ProtoMember(1, IsRequired = true)]
public uint Action;
[ProtoMember(2, IsRequired = true)]
public uint Param;
[ProtoMember(3, IsRequired = true)]
public uint Param1;
[ProtoMember(4, IsRequired = true)]
public ulong Param2;
[ProtoMember(5, IsRequired = true)]
public ulong Param3;
}
public class WarDrobe
{
public enum ActionType : uint
{
Default = 0,
Add = 1,
Remove = 2,
Equip = 5,
UnEquip = 6
}
public ActionType Action;
public uint UID;
public uint Data;
public uint Unknowen;
public byte[] Buffer;
public WarDrobe(byte[] buff)
{
Buffer = buff;
}
public void Deserialize()
{
byte[] Packet = new byte[Buffer.Length - 12];
System.Buffer.BlockCopy(Buffer, 4, Packet, 0, Buffer.Length - 12);
var result = Serializer.Deserialize<WarDrobePacket>(new MemoryStream(Packet));
this.Action = result.Action;
this.UID = result.UID;
this.Data = result.Data;
this.Unknowen = result.Unknowen;
}
public void Serialize()
{
WarDrobePacket Packet = new WarDrobePacket();
Packet.Action = this.Action;
Packet.UID = this.UID;
Packet.Data = this.Data;
Packet.Unknowen = this.Unknowen;
byte[] buffer;
using (var ms = new MemoryStream())
{
Serializer.Serialize(ms, Packet);
buffer = ms.ToArray();
}
byte[] Array = new byte[buffer.Length + 12];
System.Buffer.BlockCopy(buffer, 0, Array, 4, buffer.Length);
Writer.WriteUInt16((ushort)(Array.Length - 8), 0, Array);
Writer.WriteUInt16(3300, 2, Array);
this.Buffer = Array;
}
public static void Process(byte[] Data, Client.GameState client)
{
WarDrobe Packet = new WarDrobe(Data);
Packet.Deserialize();
switch (Packet.Action)
{
case ActionType.Add:
{
ConquerItem item;
if (client.Inventory.TryGetItem(Packet.UID, out item))
{
if (client.WarDrobe.Add(item))
{
WarDrobe res = new WarDrobe(null);
res.Action = ActionType.Add;
res.UID = item.UID;
res.Data = item.ID;
res.Unknowen = 0;
res.Serialize();
client.Send(res.Buffer);
}
}
break;
}
case ActionType.Remove:
{
ConquerItem item = null;
if (client.WarDrobe.TryGetItem(Packet.UID, out item))
{
if (client.WarDrobe.Remove(item))
{
WarDrobe res = new WarDrobe(null);
res.Action = ActionType.Remove;
res.UID = item.UID;
res.Data = item.ID;
res.Unknowen = 0;
res.Serialize();
client.Send(res.Buffer);
}
}
break;
}
case ActionType.Equip:
{
ConquerItem item = null;
if (client.WarDrobe.TryGetItem(Packet.UID, out item))
{
if (PacketHandler.Equipable(item, client))
{
WarDrobe res = new WarDrobe(null);
res.Action = ActionType.Equip;
res.UID = item.UID;
res.Data = item.ID;
res.Unknowen = 0;
res.Serialize();
client.Send(res.Buffer);
ItemUsage usage = new ItemUsage(true);
usage.dwParam = Packet.Data;
usage.UID = Packet.UID;
PacketHandler.EquipItem(usage, client);
}
}
break;
}
case ActionType.UnEquip:
{
ConquerItem item = null;
if (client.WarDrobe.TryGetItem(Packet.UID, out item))
{
WarDrobe res = new WarDrobe(null);
res.Action = ActionType.UnEquip;
res.UID = item.UID;
res.Data = item.ID;
res.Unknowen = 0;
res.Serialize();
client.Send(res.Buffer);
ItemUsage usage = new ItemUsage(true);
usage.dwParam = Packet.Data;
PacketHandler.UnequipItem(usage, client);
}
break;
}
default:
{
client.Entity.SendSysMesage("3300: unknowen type " + Packet.Action);
break;
}
}
}
public static void SendItems(Client.GameState client)
{
var Items = client.WarDrobe.Objects.ToList();
int i = 0;
i = Items.Count;
laple_121:
byte[] buffer = null;
int done = 1;
List<ItemPacket> packets = new List<ItemPacket>();
while (i > 0 && done < 10)
{
var Wrap = client.WarDrobe.Objects[i - 1];
if (Wrap.Position == 0)
{
ItemPacket item = new ItemPacket();
item.ID = Wrap.ID;
item.Socket1 = (uint)Wrap.SocketOne;
item.Socket2 = (uint)Wrap.SocketTwo;
item.Plus = (uint)Wrap.Plus;
item.Bless = (uint)Wrap.Bless;
item.Bound = (uint)(Wrap.Bound ? 1 : 0);
item.HP = Wrap.Enchant;
item.Lock = Wrap.Lock;
item.UID = Wrap.UID;
item.Dura = Wrap.Durability;
item.MaxDura = Wrap.MaximDurability;
packets.Add(item);
}
done++;
i--;
}
WarDrobe wardrobe = new WarDrobe(null);
wardrobe.Action = ActionType.Default;
wardrobe.Unknowen = 0;
wardrobe.Serialize();
if (packets.Count > 0)
{
using (var ms = new System.IO.MemoryStream())
{
ProtoBuf.Serializer.Serialize<List<ItemPacket>>(ms, packets);
buffer = ms.ToArray();
uint value = buffer[1];
int offset = 2;
while (offset < buffer.Length)
{
buffer[offset - 2] = 42;
offset += buffer[offset - 1] + 2;
}
}
}
if (buffer != null)
{
byte[] array = new byte[wardrobe.Buffer.Length + buffer.Length];
System.Buffer.BlockCopy(wardrobe.Buffer, 0, array, 0, wardrobe.Buffer.Length);
System.Buffer.BlockCopy(buffer, 0, array, wardrobe.Buffer.Length - 8, buffer.Length);
Writer.WriteUInt16((ushort)(array.Length - 8), 0, array);
client.Send(array);
}
else
{
client.Send(wardrobe.Buffer);
}
if (i > 0)
{
goto laple_121;
}
}
}
public class Storage
{
public uint Action;
public uint Param;
public uint Param1;
public ulong Param2;
public byte[] Buffer;
public Storage(byte[] buff)
{
Buffer = buff;
}
public void Deserialize()
{
byte[] Packet = new byte[Buffer.Length - 12];
System.Buffer.BlockCopy(Buffer, 4, Packet, 0, Buffer.Length - 12);
var result = Serializer.Deserialize<StoragePacket>(new MemoryStream(Packet));
this.Action = (uint)result.Action;
this.Param = result.Param;
this.Param1 = result.Param1;
this.Param2 = result.Param2;
}
public static void Send(Client.GameState client)
{
uint Points = 0;
byte[] buffer = null;
List<StoragePacket> packets = new List<StoragePacket>();
foreach (var item in client.StorageItems.Values)
{
StoragePacket packet = new StoragePacket()
{
Action = (uint)item.Type,
Param = item.ID,
Param1 = 0,
Param2 = 0,
Param3 = 0,
};
if (client.Entity.TitleID == (uint)item.Type * 10000 + item.ID)
{
packet.Param1 = 1;
}
if (client.Entity.WingID == (uint)item.Type * 10000 + item.ID)
{
packet.Param1 = 1;
}
if (item.Type == Database.WarDrobe.StorageType.Conqueror || item.Type == Database.WarDrobe.StorageType.RisingStar)
{
Points += 300;
}
if (item.Type == Database.WarDrobe.StorageType.GrandMaster)
{
Points += 500;
}
if (item.Type == Database.WarDrobe.StorageType.Fashionist || item.Type == Database.WarDrobe.StorageType.OverLord
|| item.Type == Database.WarDrobe.StorageType.Talent
|| item.Type == Database.WarDrobe.StorageType.Victor
|| item.Type == Database.WarDrobe.StorageType.SwiftChaser)
{
Points += 150;
}
packets.Add(packet);
}
Storage wardrobe = new Storage(null);
wardrobe.Action = 0;
wardrobe.Param = Points;
wardrobe.Param1 = 0;
wardrobe.Param2 = 0;
wardrobe.Serialize();
if (packets.Count > 0)
{
using (var ms = new System.IO.MemoryStream())
{
ProtoBuf.Serializer.Serialize<List<StoragePacket>>(ms, packets);
buffer = ms.ToArray();
uint value = buffer[1];
int offset = 2;
while (offset < buffer.Length)
{
buffer[offset - 2] = 42;
offset += buffer[offset - 1] + 2;
}
}
}
if (buffer != null)
{
byte[] array = new byte[wardrobe.Buffer.Length + buffer.Length];
System.Buffer.BlockCopy(wardrobe.Buffer, 0, array, 0, wardrobe.Buffer.Length);
System.Buffer.BlockCopy(buffer, 0, array, wardrobe.Buffer.Length - 8, buffer.Length);
Writer.WriteUInt16((ushort)(array.Length - 8), 0, array);
client.Send(array);
}
else
{
client.Send(wardrobe.Buffer);
}
}
public void Serialize()
{
StoragePacket Packet = new StoragePacket();
Packet.Action = this.Action;
Packet.Param = this.Param;
Packet.Param1 = this.Param1;
Packet.Param2 = this.Param2;
byte[] buffer;
using (var ms = new MemoryStream())
{
Serializer.Serialize(ms, Packet);
buffer = ms.ToArray();
}
byte[] Array = new byte[buffer.Length + 12];
System.Buffer.BlockCopy(buffer, 0, Array, 4, buffer.Length);
Writer.WriteUInt16((ushort)(Array.Length - 8), 0, Array);
Writer.WriteUInt16(3301, 2, Array);
this.Buffer = Array;
}
public static void Process(byte[] packet, Client.GameState client)
{
Storage Packet = new Storage(packet);
Packet.Deserialize();
switch (Packet.Action)
{
case 4:
{
if (client.StorageItems.ContainsKey((Database.WarDrobe.StorageType)Packet.Param1))
{
if (Packet.Param1 == 4001 ||
Packet.Param1 == 6001 ||
Packet.Param1 == 6002 ||
Packet.Param1 == 6003 ||
Packet.Param1 == 6004)
{
client.Entity.WingID = (uint)((Packet.Param1 * 10000) + Packet.Param2);
client.Send(packet);
}
else
{
client.Entity.TitleID = (uint)((Packet.Param1 * 10000) + Packet.Param2);
client.Send(packet);
}
}
break;
}
case 5:
{
if (client.StorageItems.ContainsKey((Database.WarDrobe.StorageType)Packet.Param1))
{
if (Packet.Param1 == 4001 ||
Packet.Param1 == 6001 ||
Packet.Param1 == 6002 ||
Packet.Param1 == 6003 ||
Packet.Param1 == 6004)
{
client.Entity.WingID = 0;
client.Send(packet);
}
else
{
client.Entity.TitleID = 0;
client.Send(packet);
}
}
break;
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Conquer_Online_Server.Database
{
public class WarDrobe
{
public static Dictionary<StorageType, StorageItems> Storage = new Dictionary<StorageType, StorageItems>();
public static Dictionary<string, Wrap> Items = new Dictionary<string, Wrap>();
public static void Load()
{
string File = "database\\WrapTypeData.ini";
IniFile IniFile = new IniFile(File);
var Count = IniFile.ReadUInt32("Wrap", "WrapCount");
for (uint i = 0; i < Count; i++)
{
Wrap Wrap = new Wrap();
Wrap.ID = IniFile.ReadUInt16(i.ToString(), "WrapID");
Wrap.Type = (WrapType)IniFile.ReadByte(i.ToString(), "WrapType", 0);
Wrap.ItemID = IniFile.ReadUInt32(i.ToString(), "ItemType");
var item = Database.ConquerItemInformation.BaseInformations.Values.Where(p => p.ID == Wrap.ItemID).FirstOrDefault();
if (item != null)
{
if (!Items.ContainsKey(item.Name.ToLower()))
{
Items.Add(item.Name.ToLower(), Wrap);
}
}
else
{
Console.WriteLine("[Wrap] Couldn't Load item ID : [ " + Wrap.ItemID + " ] ! ");
}
}
LoadStorage();
}
public static void LoadStorage()
{
string File = "database\\Storage.ini";
IniFile IniFile = new IniFile(File);
var Count = IniFile.ReadUInt32("Storage", "StorageTypeCount");
for (uint i = 1; i < Count + 1; i++)
{
StorageItems item = new StorageItems();
item.Type = (StorageType)IniFile.ReadUInt16(i.ToString(), "Type");
item.ID = IniFile.ReadUInt32(i.ToString() + "-1", "ID");
Storage.Add(item.Type, item);
}
}
public struct Wrap
{
public ushort ID;
public WrapType Type;
public uint ItemID;
}
public enum WrapType : byte
{
Garment = 1,
Mount = 2
}
public struct StorageItems
{
public StorageType Type;
public uint ID;
public ulong Time;
}
public enum StorageType : uint
{
OverLord = 1,
GrandMaster = 2018,
RisingStar = 2001,
Victor = 2002,
Conqueror = 2003,
Talent = 2004,
Fashionist = 2005,
SwiftChaser = 2006,
SolarDragon = 4001,
InfernalBeast = 6001,
RadiantWings = 6002,
StarlightWings = 6003,
MoonlightWings = 6004
}
}
}
public static void LoadItems(Client.GameState client)
public static void LoadItems(Client.GameState client)
{
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("items").Where("EntityID", client.Entity.UID))
using (var reader = new MySqlReader(cmd))
{
while (reader.Read())
{
var item = deserialzeItem(reader);
if (item.IsWrap == true || item.Position == 17 || item.Position == 9)
{
if (item.IsWrap == false)
{
item.IsWrap = true;
UpdateWrap(item);
}
client.WarDrobe.Add(item);
switch (item.Position)
{
case 9:
case 17:
{
if (!client.Equipment.Free((byte)item.Position))
{
break;
}
client.Equipment.Add(item, Game.Enums.ItemUse.None);
break;
}
}
}
else
{
if (!ConquerItemInformation.BaseInformations.ContainsKey(item.ID))
continue;
HandleInscribing(item, client);
ItemAddingTable.GetAddingsForItem(item);
if ((byte)Network.PacketHandler.GetPositionFromID(item.ID) == ConquerItem.Garment || (byte)Network.PacketHandler.GetPositionFromID(item.UID) == ConquerItem.SteedCrop || (byte)Network.PacketHandler.GetPositionFromID(item.UID) == ConquerItem.SteedArmor || (byte)Network.PacketHandler.GetPositionFromID(item.UID) == ConquerItem.Bottle)
{
if (item.SocketOne != Game.Enums.Gem.NoSocket || item.SocketTwo != Game.Enums.Gem.NoSocket)
{
item.SocketOne = Game.Enums.Gem.NoSocket;
item.SocketTwo = Game.Enums.Gem.NoSocket;
}
}
#region WareHouse
if (item.Warehouse == 0)
{
switch (item.Position)
{
case 0: client.Inventory.Add(item, Game.Enums.ItemUse.None); break;
default:
if (item.Position > 29) continue;
if (client.Equipment.Free((byte)item.Position))
client.Equipment.Add(item, Game.Enums.ItemUse.None);
else
{
if (client.Inventory.Count < 40)
{
item.Position = 0;
client.Inventory.Add(item, Game.Enums.ItemUse.None);
if (client.Warehouses[ProJectJexOnline.Game.ConquerStructures.Warehouse.WarehouseID.Market].Count < 20)
client.Warehouses[ProJectJexOnline.Game.ConquerStructures.Warehouse.WarehouseID.Market].Add(item);
UpdatePosition(item);
}
}
break;
}
}
else
{
if (item != null)
{
ProJectJexOnline.Game.ConquerStructures.Warehouse.WarehouseID whID = (Game.ConquerStructures.Warehouse.WarehouseID)item.Warehouse;
if (client.Warehouses.ContainsKey(whID))
{
client.Warehouses[whID].Add(item);
}
else
{
using (var cmdx = new MySqlCommand(MySqlCommandType.SELECT).Select("items").Where("Uid", (uint)item.Warehouse))
using (var readerx = new MySqlReader(cmdx))
if (readerx.Read())
{
client.Warehouses.Add((ProJectJexOnline.Game.ConquerStructures.Warehouse.WarehouseID)(uint)item.Warehouse, new ProJectJexOnline.Game.ConquerStructures.Warehouse(client, (ProJectJexOnline.Game.ConquerStructures.Warehouse.WarehouseID)(uint)item.Warehouse));
client.Warehouses[(ProJectJexOnline.Game.ConquerStructures.Warehouse.WarehouseID)(uint)whID].Add(item);
}
}
}
}
#endregion WareHouse
if (item.ID == 720828)
{
string str = reader.ReadString("agate");
uint key = 0;
string[] strArray = str.Split(new char[] { '#' });
foreach (string str2 in strArray)
{
if (str2.Length > 6)
{
item.Agate_map.Add(key, str2);
key++;
}
}
}
}
}
}
}
public static ConquerItem deserialzeItem(MySqlReader reader)
item.IsWrap = reader.ReadBoolean("IsWrap");
item.Agate = reader.ReadString("Agate");
Database.WarDrobe.Load();
|
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
npc Wardrobe | محمد ياسر | تطوير سيرفرات كونكر | 1 | 2019-12-24 12:57 PM |
بخصوص wardrobe | midoazoz | مشكلات السيرفيرات كونكر الشخصيه | 1 | 2019-11-12 10:27 PM |
بخصوص WarDrobe | Mostafa Shalby | مشكلات السيرفيرات كونكر الشخصيه | 3 | 2019-11-02 01:58 AM |
system language | محمد ياسر | تطوير سيرفرات كونكر | 3 | 2019-06-25 05:43 PM |