MCPcopy Create free account
hub / github.com/EQEmu/EQEmu / PerformTradeWithClient

Method PerformTradeWithClient

zone/bot.cpp:4275–4919  ·  view source on GitHub ↗

Perfoms the actual trade action with a client bot owner

Source from the content-addressed store, hash-verified

4273
4274// Perfoms the actual trade action with a client bot owner
4275void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client* client, int16 chosen_slot)
4276{
4277 using namespace EQ;
4278
4279 struct ClientTrade {
4280 ItemInstance* trade_item_instance;
4281 int16 from_client_slot;
4282 int16 to_bot_slot = invslot::SLOT_INVALID;
4283
4284 ClientTrade(ItemInstance* item, int16 from) : trade_item_instance(item), from_client_slot(from) { }
4285 };
4286
4287 struct ClientReturn {
4288 ItemInstance* return_item_instance;
4289 int16 from_bot_slot;
4290 int16 to_client_slot = invslot::SLOT_INVALID;
4291
4292 ClientReturn(ItemInstance* item, int16 from) : return_item_instance(item), from_bot_slot(from) { }
4293 };
4294
4295 std::vector<int16> bot_equip_order;
4296
4297 if (chosen_slot != INVALID_INDEX) {
4298 bot_equip_order.emplace_back(chosen_slot);
4299 }
4300 else {
4301 for (int16 i = 0; i < invslot::EQUIPMENT_COUNT; ++i) {
4302 bot_equip_order.push_back(i);
4303 }
4304 }
4305
4306 enum { stageStackable = 0, stageEmpty, stageReplaceable };
4307
4308 if (!client) {
4309 Emote("NO CLIENT");
4310 return;
4311 }
4312
4313 if (client != GetOwner()) {
4314 client->Message(Chat::White, "You are not the owner of this bot, the trade has been cancelled.");
4315 client->ResetTrade();
4316 return;
4317 }
4318
4319 if (begin_slot_id != invslot::TRADE_BEGIN && begin_slot_id != invslot::slotCursor) {
4320 client->Message(Chat::White, "Trade request processing from illegal 'begin' slot, the trade has been cancelled.");
4321 client->ResetTrade();
4322 return;
4323 }
4324
4325 if (end_slot_id != invslot::TRADE_END && end_slot_id != invslot::slotCursor) {
4326 client->Message(Chat::White, "Trade request processing from illegal 'end' slot, the trade has been cancelled.");
4327 client->ResetTrade();
4328 return;
4329 }
4330
4331 if ((begin_slot_id == invslot::slotCursor && end_slot_id != invslot::slotCursor) || (begin_slot_id != invslot::slotCursor && end_slot_id == invslot::slotCursor)) {
4332 client->Message(Chat::White, "Trade request processing illegal slot range, the trade has been cancelled.");

Callers

nothing calls this directly

Calls 15

ClientTradeClass · 0.85
ClientReturnClass · 0.85
sizeFunction · 0.85
push_backMethod · 0.80
SetLinkTypeMethod · 0.80
SetItemInstMethod · 0.80
IsDroppableMethod · 0.80
IsType2HWeaponMethod · 0.80
IsType1HWeaponMethod · 0.80
IsTypeShieldMethod · 0.80
SendItemPacketMethod · 0.80

Tested by

no test coverage detected