Okay finally merchant buying works -.-

This commit is contained in:
KimLS 2015-04-07 16:28:28 -07:00
parent 7341ecc185
commit 56e7d1b0dc
5 changed files with 31 additions and 14 deletions

View File

@ -506,10 +506,6 @@ bool EQEmu::Inventory::PopFromCursorBuffer() {
return false; return false;
} }
EQEmu::InventorySlot EQEmu::Inventory::PutItemInInventory(std::shared_ptr<ItemInstance> inst, bool try_worn, bool try_cursor) {
return EQEmu::InventorySlot();
}
EQEmu::InventorySlot EQEmu::Inventory::FindFreeSlot(bool for_bag, bool try_cursor, int min_size, bool is_arrow) { EQEmu::InventorySlot EQEmu::Inventory::FindFreeSlot(bool for_bag, bool try_cursor, int min_size, bool is_arrow) {
//check basic inventory //check basic inventory
for(int i = EQEmu::PersonalSlotGeneral1; i < EQEmu::PersonalSlotGeneral10; ++i) { for(int i = EQEmu::PersonalSlotGeneral1; i < EQEmu::PersonalSlotGeneral10; ++i) {

View File

@ -34,7 +34,8 @@ namespace EQEmu
InvTypeCursorBuffer, InvTypeCursorBuffer,
InvTypeTribute, InvTypeTribute,
InvTypeTrophyTribute, InvTypeTrophyTribute,
InvTypeGuildTribute InvTypeGuildTribute,
InvTypeMerchant
}; };
enum PersonaInventorySlot : int enum PersonaInventorySlot : int
@ -139,7 +140,6 @@ namespace EQEmu
bool Summon(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst); bool Summon(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst);
bool PushToCursorBuffer(std::shared_ptr<ItemInstance> inst); bool PushToCursorBuffer(std::shared_ptr<ItemInstance> inst);
bool PopFromCursorBuffer(); bool PopFromCursorBuffer();
InventorySlot PutItemInInventory(std::shared_ptr<ItemInstance> inst, bool try_worn, bool try_cursor);
InventorySlot FindFreeSlot(bool for_bag, bool try_cursor, int min_size = 0, bool is_arrow = false); InventorySlot FindFreeSlot(bool for_bag, bool try_cursor, int min_size = 0, bool is_arrow = false);
//utility //utility

View File

@ -827,7 +827,8 @@ public:
void IncStats(uint8 type,int16 increase_val); void IncStats(uint8 type,int16 increase_val);
void DropItem(int16 slot_id); void DropItem(int16 slot_id);
//New Inventory //inv2: New Inventory methods, will probably move these to Mob in a future update as there's
//little reason for them to be in client except for simplicity of implementation atm
bool SwapItem(const EQEmu::InventorySlot &src, const EQEmu::InventorySlot &dest, int number_in_stack); bool SwapItem(const EQEmu::InventorySlot &src, const EQEmu::InventorySlot &dest, int number_in_stack);
bool SummonItem(uint32 item_id, bool SummonItem(uint32 item_id,
int16 charges, int16 charges,
@ -842,6 +843,7 @@ public:
uint32 ornament_icon = 0, uint32 ornament_icon = 0,
uint32 ornament_idfile = 0, uint32 ornament_idfile = 0,
uint32 ornament_hero_model = 0); uint32 ornament_hero_model = 0);
bool PutItemInInventory(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, bool client_update = false);
// //
// class Client::TextLink // class Client::TextLink

View File

@ -12075,11 +12075,9 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
} }
if(free_slot.IsCursor()) { if(free_slot.IsCursor()) {
if(m_inventory.Get(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotCursor))) { Message(13, "You do not have room for any more items.");
Message(13, "You do not have room for any more items."); safe_delete(outapp);
safe_delete(outapp); return;
return;
}
} }
if(!stacked && !free_slot.IsValid()) if(!stacked && !free_slot.IsValid())
@ -12091,7 +12089,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
std::string packet; std::string packet;
if(!stacked && inst) { if(!stacked && inst) {
//PutItemInInventory(free_slot, inst); PutItemInInventory(free_slot, inst);
SendItemPacket(free_slot, inst, ItemPacketTrade); SendItemPacket(free_slot, inst, ItemPacketTrade);
} }
else if (!stacked){ else if (!stacked){
@ -12119,7 +12117,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
inst->SetMerchantSlot(mp->itemslot); inst->SetMerchantSlot(mp->itemslot);
inst->SetMerchantCount(new_charges); inst->SetMerchantCount(new_charges);
//SendItemPacket(mp->itemslot, inst, ItemPacketMerchant); SendItemPacket(EQEmu::InventorySlot(EQEmu::InvTypeMerchant, mp->itemslot), inst, ItemPacketMerchant);
} }
} }
safe_delete(outapp); safe_delete(outapp);

View File

@ -3353,3 +3353,24 @@ bool Client::SummonItem(uint32 item_id,
return res; return res;
} }
bool Client::PutItemInInventory(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, bool client_update) {
if(!inst)
return false;
if(!slot.IsValid()) {
return false;
}
Log.Out(Logs::Detail, Logs::Inventory, "Putting item %s (%d) into slot %s", inst->GetBaseItem()->Name, inst->GetBaseItem()->ID, slot.ToString().c_str());
if(!m_inventory.Summon(slot, inst)) {
return false;
}
if(client_update) {
SendItemPacket(slot, inst, slot.IsCursor() ? ItemPacketSummonItem : ItemPacketTrade);
}
CalcBonuses();
}