|
المشاركات 32 |
+التقييم 0.03 |
تاريخ التسجيل Jul 2021 |
الاقامة |
نظام التشغيل |
رقم العضوية 3935 |
using System;
using System.Linq;
using Rayzo.Network.GamePackets;
using System.Collections.Generic;
using Rayzo.Game;
using Rayzo.Network;
namespace Rayzo.Database
{
public class ConquerItemTable
{
#region Blob
#region Main
public Network.GamePackets.ConquerItem ReadItem(System.IO.BinaryReader reader)
{
Network.GamePackets.ConquerItem item = new ConquerItem(true);
item.ID = reader.ReadUInt32();//4
item.UID = reader.ReadUInt32();//8
item.Durability = reader.ReadUInt16();//10
item.MaximDurability = reader.ReadUInt16();//12
item.Position = reader.ReadUInt16();//14
item.SocketProgress = reader.ReadUInt32();//18
item.PlusProgress = reader.ReadUInt32();//22
item.SocketOne = (Game.Enums.Gem)reader.ReadUInt16();//24
item.SocketTwo = (Game.Enums.Gem)reader.ReadUInt16();//26
item.Effect = (Game.Enums.ItemEffect)reader.ReadUInt16();//28
item.Mode = Game.Enums.ItemMode.Default;
item.Plus = reader.ReadByte();//29
item.Bless = reader.ReadByte();//30
item.Bound = reader.ReadBoolean();//31
item.Enchant = reader.ReadByte();//32
item.Lock = reader.ReadByte();//33
item.UnlockEnd = DateTime.FromBinary(reader.ReadInt64());//41
item.Suspicious = reader.ReadBoolean();//42
item.SuspiciousStart = DateTime.FromBinary(reader.ReadInt64());//50
item.Color = (Game.Enums.Color)reader.ReadUInt32();//54
if ((byte)item.Color > 9 || (byte)item.Color < 2)
item.Color = (Game.Enums.Color)Kernel.Random.Next(2, 8);
item.Warehouse = reader.ReadUInt16();//56
item.StackSize = reader.ReadUInt16();//58
if (item.Lock == 2)
if (DateTime.Now >= item.UnlockEnd)
item.Lock = 0;
return item;
}
#endregion
#region other
public void WriteItem(System.IO.BinaryWriter writer, Network.GamePackets.ConquerItem item)
{
writer.Write(item.ID); //= reader.ReadUInt32();
writer.Write(item.UID);
writer.Write(item.Durability);
writer.Write(item.MaximDurability);
writer.Write(item.Position);
writer.Write(item.SocketProgress);
writer.Write(item.PlusProgress);
writer.Write((ushort)item.SocketOne);
writer.Write((ushort)item.SocketTwo);
writer.Write((ushort)item.Effect);
writer.Write(item.Plus);
writer.Write(item.Bless);
writer.Write(item.Bound);
writer.Write(item.Enchant);
writer.Write(item.Lock);
writer.Write(item.UnlockEnd.Ticks);
writer.Write(item.Suspicious);
writer.Write(item.SuspiciousStart.Ticks);
writer.Write((uint)item.Color);
writer.Write(item.Warehouse);
writer.Write(item.StackSize);
// writer.Write((uint)(item.NextGreen | (item.NextBlue << 8) | (item.NextRed << 16)));
}
public static byte[] GetItemsAraay(Client.GameState client)
{
uint count = (uint)(client.Inventory.Count + client.Equipment.Count);
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
writer.Write(count);
foreach (var item in client.Inventory.Objects)
new ConquerItemTable().WriteItem(writer, item);
foreach (var item in client.Equipment.GetCollection())
new ConquerItemTable().WriteItem(writer, item);
return stream.ToArray();
}
#endregion
#endregion
public static void UpdatePointsRune(ConquerItem Item)
{
UpdateData(Item, "PointsRune", Item.PointsRune);
UpdateData(Item, "Points27_9", Item.PointsLevel);
UpdateData(Item, "Skill0_40", Item.Skill0_40);
}
public static ConquerItem LoadItem(uint OwnerUId, uint Position)
{
ConquerItem item = null;
using (var cn = new MySql.Data.MySqlClient.MySqlConnection(DataHolder.MySqlConnection.ConnectionString))
using (var cm = new MySql.Data.MySqlClient.MySqlCommand("SELECT * FROM items WHERE EntityID = @u AND Position =@p", cn))
{
cn.Open();
cm.Parameters.AddWithValue("@u", OwnerUId);
cm.Parameters.AddWithValue("@p", Position);
using (MySql.Data.MySqlClient.MySqlDataReader rdr = cm.ExecuteReader())
if (rdr.Read())
item = deserialzeItem(rdr);
}
return item;
}
public static ConquerItem deserialzeItem(MySql.Data.MySqlClient.MySqlDataReader reader)
{
ConquerItem item = new Network.GamePackets.ConquerItem(true);
item.ID = reader.GetUInt32("Id");
item.UID = reader.GetUInt32("Uid");
item.Stars = (byte)reader.GetUInt32("Stars");
item.Owner = reader.GetString("Owner");
item.OwnerUID = reader.GetUInt32("OwnerUID");
item.PerfectionProgress = reader.GetUInt32("PerfectionProgress");
item.Signature = reader.GetString("Signature");
item.Durability = reader.GetUInt16("Durability");
if (item.ID == 750000)
{
item.MaximDurability = reader.GetUInt16("MaximDurability");
}
else
{
item.MaximDurability = reader.GetUInt16("MaximDurability");
item.Durability = item.MaximDurability;
}
item.Position = reader.GetUInt16("Position");
item.SocketProgress = reader.GetUInt32("SocketProgress");
item.PlusProgress = reader.GetUInt32("PlusProgress");
item.SocketOne = (Game.Enums.Gem)reader.GetUInt16("SocketOne");
item.SocketTwo = (Game.Enums.Gem)reader.GetUInt16("SocketTwo");
item.Effect = (Game.Enums.ItemEffect)reader.GetUInt16("Effect");
item.Mode = Game.Enums.ItemMode.Default;
item.Plus = (byte)(reader.GetUInt16("Plus"));
item.Bless = (byte)(reader.GetUInt16("Bless"));
if (item.Bless > 7 && item.Plus >= 12)
{
item.Bless = 7;
item.Plus = 12;
item.Mode = Game.Enums.ItemMode.Update;
Database.ConquerItemTable.UpdateBless(item);
Database.ConquerItemTable.UpdatePlus(item);
}
item.Bound = reader.GetBoolean("Bound");
item.Enchant = (byte)(reader.GetUInt16("Enchant"));
item.Lock = (byte)(reader.GetUInt16("Locked"));
item.UnlockEnd = DateTime.FromBinary(reader.GetInt64("UnlockEnd"));
item.Suspicious = reader.GetBoolean("Suspicious");
item.SuspiciousStart = DateTime.FromBinary(reader.GetInt64("SuspiciousStart"));
item.Color = (Game.Enums.Color)reader.GetUInt32("Color");
item.Warehouse = reader.GetUInt16("Warehouse");
item.Anima = reader.GetUInt32("Anima");
item.StackSize = reader.GetUInt16("StackSize");
item.SuspiciousStart = DateTime.FromBinary(reader.GetInt64("SuspiciousStart"));
if (item.StackSize > 10)
item.StackSize = 0;
item.RefineItem = reader.GetUInt32("RefineryItem");
if (item.ID == 300000)
{
uint NextSteedColor = reader.GetUInt32("NextSteedColor");
item.NextGreen = (byte)(NextSteedColor & 0xFF);
item.NextBlue = (byte)((NextSteedColor >> 8) & 0xFF);
item.NextRed = (byte)((NextSteedColor >> 16) & 0xFF);
}
Int64 rTime = reader.GetInt64("RefineryTime");
if (item.RefineItem > 0 && rTime != 0)
{
item.RefineryTime = DateTime.FromBinary(rTime);
if (DateTime.Now > item.RefineryTime)
{
item.RefineryTime = new DateTime(0);
item.RefineItem = 0;
}
}
if (item.Stars > 54)
{
item.Stars = 54;
ConquerItemTable.UpdatePerfection(item);
}
if (item.Lock == 2)
if (DateTime.Now >= item.UnlockEnd)
item.Lock = 0;
return item;
}
public static void UpdateItemID(ConquerItem Item)
{
UpdateData(Item, "ID", Item.ID);
}
public static void UpdatePerfectionRank(ConquerItem Item)
{
UpdateData(Item, "Rank", Item.PerfectionRank);
}
public static void UpdateAnima(ConquerItem Item)
{
UpdateData(Item, "Anima", Item.Anima);
}
public static void LoadItems(Client.GameState client)
{
client.Entity.StorageItems = new Dictionary<uint, ConquerItem>();
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 (!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.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;
UpdateSockets(item);
}
}
#region Checking Wind & Tower & Fan & Crop
/*if (PacketHandler.IsWing(item.ID))
{
if (item.SocketOne != Enums.Gem.EmptySocket || item.SocketOne != Enums.Gem.NoSocket)
{
if (item.SocketOne != Enums.Gem.NormalThunderGem || item.SocketOne != Enums.Gem.RefinedThunderGem || item.SocketOne != Enums.Gem.SuperThunderGem)
{
item.SocketOne = Enums.Gem.EmptySocket;
}
if (item.SocketTwo != Enums.Gem.EmptySocket || item.SocketTwo != Enums.Gem.NoSocket)
{
if (item.SocketTwo != Enums.Gem.NormalGloryGem || item.SocketTwo != Enums.Gem.RefinedGloryGem || item.SocketTwo != Enums.Gem.SuperGloryGem)
{
item.SocketTwo = Enums.Gem.EmptySocket;
}
}
Database.ConquerItemTable.UpdateSockets(item);
}
if (item.Bless > 1)
{
item.Bless = 1; Database.ConquerItemTable.UpdateBless(item);
}
}
if (PacketHandler.IsTower(item.ID))
{
if (item.SocketOne != Enums.Gem.EmptySocket || item.SocketOne != Enums.Gem.NoSocket)
{
if (item.SocketOne != Enums.Gem.NormalGloryGem || item.SocketOne != Enums.Gem.RefinedGloryGem || item.SocketOne != Enums.Gem.SuperGloryGem)
{
item.SocketOne = Enums.Gem.EmptySocket;
}
if (item.SocketTwo != Enums.Gem.EmptySocket || item.SocketTwo != Enums.Gem.NoSocket)
{
if (item.SocketTwo != Enums.Gem.NormalGloryGem || item.SocketTwo != Enums.Gem.RefinedGloryGem || item.SocketTwo != Enums.Gem.SuperGloryGem)
{
item.SocketTwo = Enums.Gem.EmptySocket;
}
}
Database.ConquerItemTable.UpdateSockets(item);
}
if (item.Bless > 1)
{
item.Bless = 1;
Database.ConquerItemTable.UpdateBless(item);
}
}
if (PacketHandler.IsFan(item.ID))
{
if (item.SocketOne != Enums.Gem.EmptySocket || item.SocketOne != Enums.Gem.NoSocket)
{
if (item.SocketOne != Enums.Gem.NormalThunderGem || item.SocketOne != Enums.Gem.RefinedThunderGem || item.SocketOne != Enums.Gem.SuperThunderGem)
{
item.SocketOne = Enums.Gem.EmptySocket;
}
if (item.SocketTwo != Enums.Gem.EmptySocket || item.SocketTwo != Enums.Gem.NoSocket)
{
if (item.SocketTwo != Enums.Gem.NormalThunderGem || item.SocketTwo != Enums.Gem.RefinedThunderGem || item.SocketTwo != Enums.Gem.SuperThunderGem)
{
item.SocketTwo = Enums.Gem.EmptySocket;
}
}
Database.ConquerItemTable.UpdateSockets(item);
}
if (item.Bless > 1)
{
item.Bless = 1;
Database.ConquerItemTable.UpdateBless(item);
}
}
if (PacketHandler.IsCrop(item.ID))
{
if (item.SocketTwo != Enums.Gem.NoSocket)
{
item.SocketTwo = Enums.Gem.NoSocket;
if (item.SocketTwo != Enums.Gem.NoSocket)
item.SocketTwo = Enums.Gem.NoSocket;
Database.ConquerItemTable.UpdateSockets(item);
}
if (item.Bless > 1)
{
item.Bless = 1;
Database.ConquerItemTable.UpdateBless(item);
}
}*/
#endregion
#region*WareHouse
if (item.Warehouse == 0)//mr.ServerProject
{
switch (item.Position)
{
case 0:
{
if (item.InWardrobe)
client.Entity.StorageItems.Add(item.UID, item);
else
{
client.Inventory.Add(item, Game.Enums.ItemUse.None);
break;
}
break;
}
case 101:
case 102:
case 103:
case 104:
case 105:
case 121:
case 122:
case 123:
case 124:
case 125:
case 211:
{
if (item.Position == 101)
{
client.Entity.Sacrifice = reader.ReadUInt16("Skill0_40");
item.Skill0_40 = reader.ReadUInt16("Skill0_40");
}
item.SkillID = RuneItems.RuneSkillID(item.ID);
client.Entity.RuneItem.Add(item.UID, item);
item.Mode = Game.Enums.ItemMode.Default;
item.Send(client);
ItemUsage ItemRune = new ItemUsage(true);
ItemRune.UID = item.UID;
ItemRune.ID = 61;
client.Send(ItemRune);
break;
}
default:
{
if (item.Position > 40) 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);
UpdatePosition(item);
}
}
break;
}
}
}
else
{
if (item != null)
{
Rayzo.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((Rayzo.Game.ConquerStructures.Warehouse.WarehouseID)(uint)item.Warehouse, new Rayzo.Game.ConquerStructures.Warehouse(client, (Rayzo.Game.ConquerStructures.Warehouse.WarehouseID)(uint)item.Warehouse));
client.Warehouses[(Rayzo.Game.ConquerStructures.Warehouse.WarehouseID)(uint)whID].Add(item);
}
}
}
}
#endregion*WareHouse*
if (item.TimeActive)
{
if (DateTime.Now >= item.EndTimeOn)
{
DeleteItem(item.UID);
}
}
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)
{
ConquerItem item = new ConquerItem(true);
item.ID = reader.ReadUInt32("Id");
item.UID = reader.ReadUInt32("Uid");
item.MaximDurability = reader.ReadUInt16("MaximDurability");
item.Durability = reader.ReadUInt16("Durability");
item.Position = reader.ReadUInt16("Position");
item.SocketProgress = reader.ReadUInt32("SocketProgress");
item.SocketOne = (Game.Enums.Gem)reader.ReadUInt16("SocketOne");
item.SocketTwo = (Game.Enums.Gem)reader.ReadUInt16("SocketTwo");
item.Effect = (Game.Enums.ItemEffect)reader.ReadUInt16("Effect");
item.Mode = Game.Enums.ItemMode.Default;
item.Agate = reader.ReadString("Agate");
item.Anima = reader.ReadUInt32("Anima");
item.Signature = reader.ReadString("Signature");
item.Stars = reader.ReadByte("Stars");
item.PerfectionProgress = reader.ReadUInt32("PerfectionProgress");
item.Owner = reader.ReadString("Owner");
item.OwnerUID = reader.ReadUInt32("OwnerUID");
item.Plus = reader.ReadByte("Plus");
item.PlusProgress = reader.ReadUInt32("PlusProgress");
item.Bless = reader.ReadByte("Bless");
item.PointsRune = reader.ReadUInt32("PointsRune");
item.PointsLevel = reader.ReadUInt32("Points27_9");
string[] Runes = reader.ReadString("Runes").Split('~');
uint Vl = Convert.ToUInt32(Runes[0]);
uint V2 = Convert.ToUInt32(Runes[1]);
uint V3 = Convert.ToUInt32(Runes[2]);
uint V4 = Convert.ToUInt32(Runes[3]);
uint V5 = Convert.ToUInt32(Runes[4]);
uint V6 = Convert.ToUInt32(Runes[4]);
uint V7 = Convert.ToUInt32(Runes[4]);
uint V8 = Convert.ToUInt32(Runes[4]);
uint V9 = Convert.ToUInt32(Runes[4]);
item.Runes = new uint[9] { Vl, V2, V3, V4, V5, V6, V7, V8, V9 };
if (item.ID == 720828)
{
string str = reader.ReadString("Agate");
uint key = 0;
string[] strArray = str.Split(new[] { '#' });
foreach (string str2 in strArray)
{
if (str2.Length > 6)
{
item.Agate_map.Add(key, str2);
key++;
}
}
}
//item.TimeStamp = DateTime.FromBinary(reader.ReadInt64("TimeStamp"));
//item.Seconds = reader.ReadUInt64("MinutesLeft");
item.InWardrobe = reader.ReadBoolean("InWardrobe");
item.Bound = reader.ReadBoolean("Bound");
item.Enchant = reader.ReadByte("Enchant");
item.Lock = reader.ReadByte("Locked");
item.UnlockEnd = DateTime.FromBinary(reader.ReadInt64("UnlockEnd"));
item.Suspicious = reader.ReadBoolean("Suspicious");
item.SuspiciousStart = DateTime.FromBinary(reader.ReadInt64("SuspiciousStart"));
item.Warehouse = reader.ReadUInt32("Warehouse");
item.StackSize = reader.ReadUInt16("StackSize");
item.RefineItem = reader.ReadUInt32("RefineryItem");
if (item.ID == 300000)
{
uint nextSteedColor = reader.ReadUInt32("NextSteedColor");
item.NextGreen = (byte)(nextSteedColor & 0xFF);
item.NextBlue = (byte)((nextSteedColor >> 8) & 0xFF);
item.NextRed = (byte)((nextSteedColor >> 16) & 0xFF);
}
Int64 rTime = reader.ReadInt64("RefineryTime");
if (item.RefineItem > 0 && rTime != 0)
{
item.RefineryTime = DateTime.FromBinary(rTime);
if (DateTime.Now > item.RefineryTime)
{
item.RefineryTime = new DateTime(0);
item.RefineItem = 0;
}
}
if (item.Lock == 2)
if (DateTime.Now >= item.UnlockEnd)
item.Lock = 0;
return item;
}
public static void UpdateDurabilityItem2(ConquerItem Item, uint ItemID)
{
if (Item != null)
{
using (var cmd = new MySqlCommand(MySqlCommandType.Update))
cmd.Update("items").Set("Durability", (long)Item.Durability).Where("UID", (long)Item.UID).And("ID", (long)ItemID).Execute();
}
}
public static void SetDurabilityItem0(ConquerItem Item)
{
using (MySql.Data.MySqlClient.MySqlConnection connection = DataHolder.MySqlConnection)
{
connection.Open();
using (var cmd = new MySqlCommand(MySqlCommandType.Update))
cmd.Update("items").Set("Durability", (long)0L).Where("UID", (long)Item.UID).Execute(connection);
connection.Close();
}
}
public static void HandleInscribing(ConquerItem item, Client.GameState client, bool detained = false)
{
if (client.Entity.GuildID != 0)
{
if (client.Guild != null)
{
int itemPosition = Network.PacketHandler.ArsenalPosition(item.ID);
if (itemPosition != -1)
{
var arsenal = client.Guild.Arsenals[itemPosition];
if (arsenal.Unlocked)
{
if (arsenal.ItemDictionary.ContainsKey(item.UID))
{
var arsenalItem = arsenal.ItemDictionary[item.UID];
arsenalItem.Update(item, client);
item.Inscribed = true;
client.ArsenalDonations[itemPosition] += arsenalItem.DonationWorth;
}
}
}
}
}
}
public static ConquerItem LoadItem(uint UID)
{
using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("items").Where("UID", UID))
using (var reader = new MySqlReader(cmd))
if (reader.Read())
return deserialzeItem(reader);
return new ConquerItem(true);
}
public static void UpdatePerfection(ConquerItem Item)
{
UpdateData(Item, "PerfectionProgress", Item.PerfectionProgress);
UpdateData(Item, "Stars", Item.Stars);
UpdateData(Item, "Owner", Item.Owner);
UpdateData(Item, "OwnerUID", Item.OwnerUID);
UpdateData(Item, "Signature", Item.Signature);
}
public static void AddItem(ref ConquerItem Item, Client.GameState client)
{
try
{
uint v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0,v6 = 0,v7 = 0,v8 = 0,v9 = 0;
if (Item.Runes.Length >= 1)
v1 = Item.Runes[0];
if (Item.Runes.Length >= 2)
v2 = Item.Runes[1];
if (Item.Runes.Length >= 3)
v3 = Item.Runes[2];
if (Item.Runes.Length >= 4)
v4 = Item.Runes[3];
if (Item.Runes.Length >= 5)
v5 = Item.Runes[4];
if (Item.Runes.Length >= 6)
v6 = Item.Runes[5];
if (Item.Runes.Length >= 7)
v7 = Item.Runes[6];
if (Item.Runes.Length >= 8)
v8 = Item.Runes[7];
if (Item.Runes.Length >= 9)
v9 = Item.Runes[8];
using (var cmd = new MySqlCommand(MySqlCommandType.INSERT).Insert("items"))
cmd.Insert("ID", Item.ID).Insert("UID", Item.UID)
.Insert("Plus", Item.Plus).Insert("Bless", Item.Bless)
.Insert("Enchant", Item.Enchant).Insert("SocketOne", (byte)Item.SocketOne)
.Insert("SocketTwo", (byte)Item.SocketTwo).Insert("Durability", Item.Durability)
.Insert("MaximDurability", Item.MaximDurability).Insert("SocketProgress", Item.SocketProgress)
.Insert("PlusProgress", Item.PlusProgress).Insert("Effect", (ushort)Item.Effect)
.Insert("TimeStamp", Item.EndTimeOn.ToBinary()).Insert("MinutesLeft", (byte)(Item.TimeActive ? 1 : 0))
.Insert("Bound", Item.Bound).Insert("DayStamp", Item.DayStamp.Ticks).Insert("Days", Item.Days).Insert("Locked", Item.Lock).Insert("UnlockEnd", Item.UnlockEnd.Ticks)
.Insert("Suspicious", Item.Suspicious).Insert("SuspiciousStart", Item.SuspiciousStart.Ticks)
.Insert("Color", (ushort)Item.Color).Insert("Position", Item.Position).Insert("StackSize", Item.StackSize)
.Insert("RefineryItem", Item.RefineItem).Insert("RefineryTime", Item.RefineryTime.Ticks).Insert("EntityID", client.Entity.UID)
.Insert("Warehouse", Item.Warehouse)
.Insert("Anima", Item.Anima)
.Insert("Runes", v1 + "~" + v2 + "~" + v3 + "~" + v4 + "~" + v5).Execute();
}
catch (Exception e)
{
Console.WriteLine(e);
DeleteItem(Item.UID);
AddItem(ref Item, client);
}
}
private static void UpdateData(ConquerItem Item, string column, object value)
{
UpdateData(Item.UID, column, value);
}
private static void UpdateData(uint UID, string column, object value)
{
using (var cmd = new MySqlCommand(MySqlCommandType.Update))
cmd.Update("items").Set(column, value.ToString())
.Where("UID", UID).Execute();
}
public static void UpdateBless(ConquerItem Item)
{
UpdateData(Item, "Bless", Item.Bless);
}
public static void UpdateRefineryItem(ConquerItem Item)
{
UpdateData(Item, "RefineryItem", Item.RefineItem);
}
public static void UpdateRefineryTime(ConquerItem Item)
{
UpdateData(Item, "RefineryTime", Item.RefineryTime.Ticks);
}
public static void UpdateTimeStamp(ConquerItem Item)
{
UpdateData(Item, "TimeStamp", Item.EndTimeOn.ToBinary());
UpdateData(Item, "MinutesLeft", (byte)(Item.TimeActive ? 1 : 0));
}
public static void UpdateItemAgate(ConquerItem Item)
{
string agate = "";
if (Item.ID == 720828)
{
foreach (string coord in Item.Agate_map.Values)
{
agate += coord + "#";
UpdateData(Item, "agate", agate);
}
}
}
public static void UpdateWardrobe(bool inWardrobe, uint UID)
{
using (MySqlCommand command = new MySqlCommand(MySqlCommandType.Update))
{
command.Update("items")
.Set("InWardrobe", inWardrobe)
.Where("UID", UID).Execute();
}
}
public static void UpdateColor(ConquerItem Item)
{
UpdateData(Item, "Color", (uint)Item.Color);
}
public static void UpdateStack(ConquerItem Item)
{
UpdateData(Item, "StackSize", Item.StackSize);
}
public static void UpdateEnchant(ConquerItem Item)
{
UpdateData(Item, "Enchant", Item.Enchant);
}
public static void UpdateLock(ConquerItem Item)
{
UpdateData(Item, "Locked", Item.Lock);
UpdateData(Item, "UnlockEnd", Item.UnlockEnd.ToBinary());
}
public static void UpdateSockets(ConquerItem Item)
{
UpdateData(Item, "SocketOne", (byte)Item.SocketOne);
UpdateData(Item, "SocketTwo", (byte)Item.SocketTwo);
}
public static void UpdateSocketProgress(ConquerItem Item)
{
UpdateData(Item, "SocketProgress", Item.SocketProgress);
}
public static void UpdateNextSteedColor(ConquerItem Item)
{
UpdateData(Item, "NextSteedColor", Item.NextGreen | (Item.NextBlue << 8) | (Item.NextRed << 16));
}
public static void UpdateDurabilityItem(ConquerItem Item)
{
UpdateData(Item, "Durability", Item.Durability);
}
public static void UpdateLocation(ConquerItem Item, Client.GameState client)
{
if (IsThere(Item.UID))
{
using (var cmd = new MySqlCommand(MySqlCommandType.Update))
cmd.Update("items").Set("EntityID", client.Entity.UID)
.Set("Position", Item.Position).Set("Warehouse", (uint)Item.Warehouse)
.Where("UID", Item.UID).Execute();
}
else
{
using (var cmd = new MySqlCommand(MySqlCommandType.INSERT).Insert("items"))
cmd.Insert("ID", Item.ID).Insert("UID", Item.UID)
.Insert("Plus", Item.Plus).Insert("Bless", Item.Bless)
.Insert("Enchant", Item.Enchant).Insert("SocketOne", (byte)Item.SocketOne)
.Insert("SocketTwo", (byte)Item.SocketTwo).Insert("Durability", Item.Durability)
.Insert("MaximDurability", Item.MaximDurability).Insert("SocketProgress", Item.SocketProgress)
.Insert("PlusProgress", Item.PlusProgress).Insert("Effect", (ushort)Item.Effect)
.Insert("Bound", Item.Bound).Insert("DayStamp", Item.DayStamp.ToString()).Insert("Days", Item.Days).Insert("Locked", Item.Lock).Insert("UnlockEnd", Item.UnlockEnd.Ticks)
.Insert("Suspicious", Item.Suspicious).Insert("SuspiciousStart", Item.SuspiciousStart.Ticks)
.Insert("Color", (ushort)Item.Color).Insert("Position", Item.Position).Insert("StackSize", Item.StackSize)
.Insert("RefineryItem", Item.RefineItem).Insert("RefineryTime", Item.RefineryTime.Ticks).Insert("EntityID", client.Entity.UID)
.Execute();
}
}
public static void UpdatePosition(ConquerItem Item)
{
using (var cmd = new MySqlCommand(MySqlCommandType.Update))
cmd.Update("items").Set("Position", Item.Position).Set("Warehouse", Item.Warehouse)
.Where("UID", Item.UID).Execute();
}
public static void UpdatePlus(ConquerItem Item)
{
UpdateData(Item, "Plus", Item.Plus);
}
public static void UpdateBound(ConquerItem Item)
{
UpdateData(Item, "Bound", 0);
}
public static void UpdatePlusProgress(ConquerItem Item)
{
UpdateData(Item, "PlusProgress", Item.PlusProgress);
}
public static void UpdateItemID(ConquerItem Item, Client.GameState client)
{
UpdateData(Item, "ID", Item.ID);
}
public static void RemoveItem(uint UID)
{
using (var cmd = new MySqlCommand(MySqlCommandType.Update))
cmd.Update("items").Set("EntityID", 0)
.Set("Position", 0).Where("UID", UID).Execute();
}
public static void DeleteItem(uint UID)
{
using (var cmd = new MySqlCommand(MySqlCommandType.DELETE))
cmd.Delete("items", "UID", UID).Execute();
}
public static void ClearPosition(uint EntityID, byte position)
{
using (var cmd = new MySqlCommand(MySqlCommandType.Update))
cmd.Update("items").Set("EntityID", 0).Set("Position", 0)
.Where("EntityID", EntityID).And("Position", position).Execute();
}
public static void RefineryUpdate(ConquerItem Item, Client.GameState client)
{
}
public static void ClearNulledItems()
{
Dictionary<uint, int> dict = new Dictionary<uint, int>();
using (var c = new MySqlCommand(MySqlCommandType.SELECT).Select("detaineditems"))
using (var r = c.CreateReader())
while (r.Read())
dict[r.ReadUInt32("ItemUID")] = 0;
using (var c = new MySqlCommand(MySqlCommandType.SELECT).Select("claimitems"))
using (var r = c.CreateReader())
while (r.Read())
dict[r.ReadUInt32("ItemUID")] = 0;
var array = dict.Keys.ToArray();
foreach (var item in array)
using (var cmd = new MySqlCommand(MySqlCommandType.Update).Update("items")
.Set("entityid", 1).Where("entityid", 0).And("uid", item))
cmd.Execute();
using (var cmd = new MySqlCommand(MySqlCommandType.DELETE).Delete("items", "entityid", 0))
cmd.Execute();
}
public static bool IsThere(uint uid)
{
MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT);
command.Select("items").Where("UID", (long)uid);
MySqlReader reader = new MySqlReader(command);
if (reader.Read())
{
// Reader.Close();
//// Reader.Dispose();
return true;
}
// Reader.Close();
//// Reader.Dispose();
return false;
}
public static void Update_Free(ConquerItem Item, Client.GameState client)
{
MySqlCommand command = new MySqlCommand(MySqlCommandType.Update);
command.Update("items").Set("EntityID", client.Entity.UID).Set("DayStamp", Item.DayStamp.Ticks).Set("Days", Item.Days).Where("UID", Item.UID).Execute();
}
internal static bool IsTwoHand(uint p)
{
throw new NotImplementedException();
}
}
}
أفضل جواب - كتبه shehabdasten |
خلاص لقيته يا شباب شكرا |
if (item.TimeActive)
{
if (DateTime.Now >= item.EndTimeOn)
{
DeleteItem(item.UID);
}
}
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++;
}
}
}
}
}
}
if (item.ID == 720828)
{
string str = reader.ReadString("Agate");
uint key = 0;
string[] strArray = str.Split(new[] { '#' });
foreach (string str2 in strArray)
{
if (str2.Length > 6)
{
item.Agate_map.Add(key, str2);
key++;
}
}
}
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
مشكلة في سورس رايزو | Avengers-Co | مشكلات السيرفيرات كونكر الشخصيه | 5 | 2020-03-21 05:28 PM |
مشكلة فى سورس رايزو | nova | مشكلات السيرفيرات كونكر الشخصيه | 1 | 2019-11-22 06:00 PM |
مشكلة فى سورس رايزو | nova | مشكلات السيرفيرات كونكر الشخصيه | 1 | 2019-11-22 06:00 PM |
مشكلة فى سورس رايزو | nova | مشكلات السيرفيرات كونكر الشخصيه | 3 | 2019-11-22 02:11 PM |
مشكلة في سورس رايزو | manshestar | مشكلات السيرفيرات كونكر الشخصيه | 3 | 2019-07-27 03:43 PM |