|
|
BuyFromExchangeShop = 2443,
ExchangeShop = 2441,
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;
}
}
buyfromexchangeshop = 2443,
exchangeshop = 2441,
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 ( الأعضاء 0 والزوار 1) | |
|
الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
Exchange Shop | MRonlineGvrix | تطوير سيرفرات كونكر | 1 | 2020-02-05 08:27 AM |
مشكله اضافه شوب exchange لسورس رايزو | neno2052 | مشكلات السيرفيرات كونكر الشخصيه | 3 | 2019-09-04 08:10 PM |