|
المشاركات 483 |
+التقييم 0.24 |
تاريخ التسجيل May 2019 |
الاقامة |
نظام التشغيل |
رقم العضوية 145 |
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Alaxx.Database
{
public class CMsgExchangeItems
{
public uint ID;
public uint ItemID;
public uint UnKnown;
public uint Remaining;
public bool Bound;
public uint NeededItemID;
public uint NeddedItemCount;
}
public static class CMsgExchangueShopFile
{
public static Dictionary<uint, CMsgExchangeItems> Items;
public static void Load()
{
string[] text = File.ReadAllLines(Constants.DataHolderPath + "exchange_shop_goods.txt");
Items = new Dictionary<uint, CMsgExchangeItems>();
CMsgExchangeItems Item;
for (int x = 0; x < text.Length; x++)
{
string line = text[x];
string[] split = line.Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
Item = new CMsgExchangeItems();
Item.ID = uint.Parse(split[0]);
Item.ItemID = uint.Parse(split[1]);
Item.UnKnown = uint.Parse(split[2]);
Item.Remaining = uint.Parse(split[3]);
Item.Bound = uint.Parse(split[4]) != 0 ? true : false;
Item.NeededItemID = uint.Parse(split[5]);
Item.NeddedItemCount = uint.Parse(split[6]);
if (!Items.ContainsKey(Item.ID))
{
Items.Add(Item.ID, Item);
}
}
}
}
}
namespace Alaxx.Network.GamePackets
{
using ProtoBuf;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public unsafe class CMsgExchangeShop
{
private byte[] _packet;
public CMsgExchangeShop(byte[] incoming)
{
_packet = incoming;
}
public bool Read()
{
try
{
var dePacket = new byte[_packet.Length - 8];
for (int i = 0; i < dePacket.Length; i++)
{
dePacket[i] = _packet[i];
}
Data = Serializer.DeserializeWithLengthPrefix<ProtoExchangeShop>(new System.IO.MemoryStream(dePacket), PrefixStyle.Fixed32);
return true;
}
catch
{
return false;
}
}
public ProtoExchangeShop Data;
public static implicit operator byte[](CMsgExchangeShop packet)
{
return packet._packet;
}
public static byte[] FinalizeProtoBuf(ProtoExchangeShop ExchangeShopArgs)
{
using (var memoryStream = new MemoryStream())
{
Serializer.SerializeWithLengthPrefix(memoryStream, ExchangeShopArgs, PrefixStyle.Fixed32);
var pkt = new byte[8 + memoryStream.Length];
memoryStream.ToArray().CopyTo(pkt, 0);
Writer.WriteUshort((ushort)memoryStream.Length, 0, pkt);
Writer.WriteUshort(2441, 2, pkt);
return pkt;
}
}
}
[ProtoContract]
public class ProtoExchangeShop
{
[ProtoMember(1, IsRequired = true)]
public uint ShopID;
[ProtoMember(2, IsRequired = true)]
public uint Action;
[ProtoMember(3, IsRequired = true)]
public uint TimeIn;
[ProtoMember(4, IsRequired = true)]
public uint TimeInSeconds;
}
}
using CMsgConquer.Client;
using CMsgConquer.Database;
using ProtoBuf;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Alaxx.Network.GamePackets
{
public class CMsgExchangeShopRespond
{
private byte[] _packet;
public CMsgExchangeShopRespond(byte[] incoming)
{
int newLegnth = incoming.Length - 12;
byte[] Incoming = new byte[newLegnth];
Array.Copy(incoming, 4, Incoming, 0, Incoming.Length);
_packet = Incoming;
}
public ExchangeShopRespondProto Data = null;
public void Handle(GameClient client)
{
uint[] ptr = Read7BitEncodedInt(_packet);
int index = 0;
Data = new ExchangeShopRespondProto();
Data.ShopID = ptr[index];
index++;
Data.Action = ptr[index];
index++;
Data.Amount = ptr[index];
index++;
Data.ItemID = ptr[index];
if (Data != null)
{
if (CMsgExchangueShopFile.Items.ContainsKey(Data.ItemID))
{
CMsgExchangeItems Item = null;
CMsgExchangueShopFile.Items.TryGetValue(Data.ItemID, out Item);
if (Item == null)
return;
if (Data.Amount > Item.Remaining)
return;
uint Count = Item.NeddedItemCount * Data.Amount;
uint PriceItem = Item.NeededItemID;
if (client.Inventory.Contains(PriceItem, Count))
{
if (client.Inventory.Remove(PriceItem, Count))
{
client.Inventory.Add(Item.ItemID, 0, (byte)Data.Amount, Item.Bound);
}
}
}
}
}
public static uint[] Read7BitEncodedInt(byte[] buffer)
{
List<uint> ptr2 = new List<uint>();
for (int i = 0; i < buffer.Length; )
{
if (i + 2 <= buffer.Length)
{
int tmp = buffer[i++];
if (tmp % 8 == 0)
while (true)
{
if (i + 1 > buffer.Length) break;
tmp = buffer[i++];
if (tmp < 128)
{
ptr2.Add((uint)tmp);
break;
}
else
{
int result = tmp & 0x7f;
if ((tmp = buffer[i++]) < 128)
{
result |= tmp << 7;
ptr2.Add((uint)result);
break;
}
else
{
result |= (tmp & 0x7f) << 7;
if ((tmp = buffer[i++]) < 128)
{
result |= tmp << 14;
ptr2.Add((uint)result);
break;
}
else
{
result |= (tmp & 0x7f) << 14;
if ((tmp = buffer[i++]) < 128)
{
result |= tmp << 21;
ptr2.Add((uint)result);
break;
}
else
{
result |= (tmp & 0x7f) << 21;
result |= (tmp = buffer[i++]) << 28;
ptr2.Add((uint)result);
break;
}
}
}
}
}
}
else break;
}
return ptr2.ToArray();
}
}
public class ExchangeShopRespondProto
{
public uint ShopID;
public uint Action;
public uint Amount;
public uint ItemID;
public uint U1;
public uint U2;
}
}
1@@3300036@@1@@1@@0@@3300035@@1000@@0@@0@@0@@0@@0@@0@@
2@@3300045@@1@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@
3@@3300049@@1@@1@@0@@3300035@@188@@0@@0@@0@@0@@0@@0@@
4@@3300056@@1@@1@@0@@3300035@@188@@0@@0@@0@@0@@0@@0@@
5@@3008727@@1@@3@@0@@3300035@@50@@0@@0@@0@@0@@0@@0@@
6@@3300050@@1@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@
7@@729242@@1@@100@@1@@3300035@@299@@0@@0@@0@@0@@0@@0@@
8@@3300051@@1@@100@@0@@3300035@@10@@0@@0@@0@@0@@0@@0@@
9@@3300052@@1@@10@@0@@3300035@@100@@0@@0@@0@@0@@0@@0@@
10@@730001@@1@@100@@1@@3300035@@10@@0@@0@@0@@0@@0@@0@@
11@@730003@@1@@10@@1@@3300035@@120@@0@@0@@0@@0@@0@@0@@
12@@3004895@@1@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@
13@@3004898@@1@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@
14@@3004897@@1@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@
15@@3004896@@1@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@
17@@3004247@@1@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@
18@@3004248@@1@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@
19@@3008058@@1@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@
20@@3300036@@2@@1@@0@@3300035@@1000@@0@@0@@0@@0@@0@@0@@
21@@3300045@@2@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@
22@@3300049@@2@@1@@0@@3300035@@188@@0@@0@@0@@0@@0@@0@@
23@@3300056@@2@@1@@0@@3300035@@188@@0@@0@@0@@0@@0@@0@@
24@@3008727@@2@@3@@0@@3300035@@50@@0@@0@@0@@0@@0@@0@@
25@@3300050@@2@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@
26@@729242@@2@@100@@1@@3300035@@299@@0@@0@@0@@0@@0@@0@@
27@@3300051@@2@@100@@0@@3300035@@10@@0@@0@@0@@0@@0@@0@@
28@@3300052@@2@@10@@0@@3300035@@100@@0@@0@@0@@0@@0@@0@@
29@@730001@@2@@100@@1@@3300035@@10@@0@@0@@0@@0@@0@@0@@
30@@730003@@2@@10@@1@@3300035@@120@@0@@0@@0@@0@@0@@0@@
31@@3004895@@2@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@
32@@3004898@@2@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@
33@@3004897@@2@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@
34@@3004896@@2@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@
35@@3004247@@2@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@
36@@3004248@@2@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@
37@@3008058@@2@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@
case 50:
{
var shop = new ProtoExchangeShop()
{
ShopID = 19424,
Action = 1,
TimeIn = 1714178,
TimeInSeconds = 46389,
};
client.Send(CMsgExchangeShop.FinalizeProtoBuf(shop));
break;
الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
مشكله في شوب exchange | neno2052 | مشكلات السيرفيرات كونكر الشخصيه | 16 | 2019-11-26 01:33 AM |
مشكله اضافه شوب exchange لسورس رايزو | neno2052 | مشكلات السيرفيرات كونكر الشخصيه | 3 | 2019-09-04 08:10 PM |