Added messages for item equip failures

This commit is contained in:
Uleat
2017-04-02 05:06:13 -04:00
parent e5e801dad5
commit 13af1bfe6f
5 changed files with 63 additions and 19 deletions
+17 -2
View File
@@ -1793,7 +1793,8 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
// Nothing in destination slot: split stack into two
if ((int16)move_in->number_in_stack >= src_inst->GetCharges()) {
// Move entire stack
if(!m_inv.SwapItem(src_slot_id, dst_slot_id)) { return false; }
EQEmu::InventoryProfile::SwapItemFailState fail_state = EQEmu::InventoryProfile::swapInvalid;
if (!m_inv.SwapItem(src_slot_id, dst_slot_id, fail_state)) { return false; }
Log(Logs::Detail, Logs::Inventory, "Move entire stack from %d to %d with stack size %d. Dest empty.", src_slot_id, dst_slot_id, move_in->number_in_stack);
}
else {
@@ -1823,7 +1824,21 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
}
SetMaterial(dst_slot_id,src_inst->GetItem()->ID);
}
if(!m_inv.SwapItem(src_slot_id, dst_slot_id, GetRace(), GetClass(), GetDeity(), GetLevel())) { return false; }
EQEmu::InventoryProfile::SwapItemFailState fail_state = EQEmu::InventoryProfile::swapInvalid;
if (!m_inv.SwapItem(src_slot_id, dst_slot_id, fail_state, GetRace(), GetClass(), GetDeity(), GetLevel())) {
const char* fail_message = "The selected slot was invalid.";
if (fail_state == EQEmu::InventoryProfile::swapRaceClass || fail_state == EQEmu::InventoryProfile::swapDeity)
fail_message = "Your class, deity and/or race may not equip that item.";
else if (fail_state == EQEmu::InventoryProfile::swapLevel)
fail_message = "You are not sufficient level to use this item.";
if (fail_message)
Message(CC_Red, "%s", fail_message);
return false;
}
Log(Logs::Detail, Logs::Inventory, "Moving entire item from slot %d to slot %d", src_slot_id, dst_slot_id);
if (src_slot_id <= EQEmu::legacy::EQUIPMENT_END || src_slot_id == EQEmu::inventory::slotPowerSource) {
+2 -1
View File
@@ -40,7 +40,8 @@ int Lua_Inventory::PushCursor(Lua_ItemInst item) {
bool Lua_Inventory::SwapItem(int slot_a, int slot_b) {
Lua_Safe_Call_Bool();
return self->SwapItem(slot_a, slot_b);
EQEmu::InventoryProfile::SwapItemFailState fail_state = EQEmu::InventoryProfile::swapInvalid;
return self->SwapItem(slot_a, slot_b, fail_state);
}
bool Lua_Inventory::DeleteItem(int slot_id) {
+5
View File
@@ -18,6 +18,11 @@ namespace luabind {
luabind::scope lua_register_inventory();
// This class should be deprecated due to the nature of inventory actions.
// Direct manipulation of the inventory system bypasses the client management
// of database calls and can lead to lost items, duplicated items and/or
// desync'd inventories, if not handled correctly.
class Lua_Inventory : public Lua_Ptr<EQEmu::InventoryProfile>
{
typedef EQEmu::InventoryProfile NativeType;