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; } }