[Cleanup] Convert DeleteItemInInventory quantity to int16. (#1767)

* [Cleanup] Convert DeleteItemInInventory quantity to int16.

* Type conversion.
This commit is contained in:
Kinglykrab 2021-11-16 08:52:22 -05:00 committed by GitHub
parent bf8a0328b3
commit 3efd9c7f60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 81 additions and 189 deletions

View File

@ -399,7 +399,7 @@ bool EQ::InventoryProfile::SwapItem(
} }
// Remove item from inventory (with memory delete) // Remove item from inventory (with memory delete)
bool EQ::InventoryProfile::DeleteItem(int16 slot_id, uint8 quantity) { bool EQ::InventoryProfile::DeleteItem(int16 slot_id, int16 quantity) {
// Pop item out of inventory map (or queue) // Pop item out of inventory map (or queue)
ItemInstance *item_to_delete = PopItem(slot_id); ItemInstance *item_to_delete = PopItem(slot_id);

View File

@ -132,7 +132,7 @@ namespace EQ
bool SwapItem(int16 source_slot, int16 destination_slot, SwapItemFailState& fail_state, uint16 race_id = 0, uint8 class_id = 0, uint16 deity_id = 0, uint8 level = 0); bool SwapItem(int16 source_slot, int16 destination_slot, SwapItemFailState& fail_state, uint16 race_id = 0, uint8 class_id = 0, uint16 deity_id = 0, uint8 level = 0);
// Remove item from inventory // Remove item from inventory
bool DeleteItem(int16 slot_id, uint8 quantity = 0); bool DeleteItem(int16 slot_id, int16 quantity = 0);
// Checks All items in a bag for No Drop // Checks All items in a bag for No Drop
bool CheckNoDrop(int16 slot_id, bool recurse = true); bool CheckNoDrop(int16 slot_id, bool recurse = true);

View File

@ -8501,7 +8501,7 @@ void Client::Consume(const EQ::ItemData *item, uint8 type, int16 slot, bool auto
LogFood("Consuming food, points added to hunger_level: [{}] - current_hunger: [{}]", increase, m_pp.hunger_level); LogFood("Consuming food, points added to hunger_level: [{}] - current_hunger: [{}]", increase, m_pp.hunger_level);
DeleteItemInInventory(slot, 1, false); DeleteItemInInventory(slot, 1);
if (!auto_consume) // no message if the client consumed for us if (!auto_consume) // no message if the client consumed for us
entity_list.MessageCloseString(this, true, 50, 0, EATING_MESSAGE, GetName(), item->Name); entity_list.MessageCloseString(this, true, 50, 0, EATING_MESSAGE, GetName(), item->Name);
@ -8516,7 +8516,7 @@ void Client::Consume(const EQ::ItemData *item, uint8 type, int16 slot, bool auto
m_pp.thirst_level += increase; m_pp.thirst_level += increase;
DeleteItemInInventory(slot, 1, false); DeleteItemInInventory(slot, 1);
LogFood("Consuming drink, points added to thirst_level: [{}] current_thirst: [{}]", increase, m_pp.thirst_level); LogFood("Consuming drink, points added to thirst_level: [{}] current_thirst: [{}]", increase, m_pp.thirst_level);
@ -10285,7 +10285,7 @@ void Client::RemoveItem(uint32 item_id, uint32 quantity)
{ EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END }, { EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END },
{ EQ::invbag::SHARED_BANK_BAGS_BEGIN, EQ::invbag::SHARED_BANK_BAGS_END }, { EQ::invbag::SHARED_BANK_BAGS_BEGIN, EQ::invbag::SHARED_BANK_BAGS_END },
}; };
int removed_count = 0; int16 removed_count = 0;
const size_t size = sizeof(slots) / sizeof(slots[0]); const size_t size = sizeof(slots) / sizeof(slots[0]);
for (int slot_index = 0; slot_index < size; ++slot_index) { for (int slot_index = 0; slot_index < size; ++slot_index) {
for (int slot_id = slots[slot_index][0]; slot_id <= slots[slot_index][1]; ++slot_id) { for (int slot_id = slots[slot_index][0]; slot_id <= slots[slot_index][1]; ++slot_id) {
@ -10295,13 +10295,13 @@ void Client::RemoveItem(uint32 item_id, uint32 quantity)
item = GetInv().GetItem(slot_id); item = GetInv().GetItem(slot_id);
if (item && item->GetID() == item_id) { if (item && item->GetID() == item_id) {
int charges = item->IsStackable() ? item->GetCharges() : 0; int16 charges = item->IsStackable() ? item->GetCharges() : 0;
int stack_size = std::max(charges, 1); int16 stack_size = std::max(charges, static_cast<int16>(1));
if ((removed_count + stack_size) <= quantity) { if ((removed_count + stack_size) <= quantity) {
removed_count += stack_size; removed_count += stack_size;
DeleteItemInInventory(slot_id, charges, true); DeleteItemInInventory(slot_id, charges, true);
} else { } else {
int amount_left = (quantity - removed_count); int16 amount_left = (quantity - removed_count);
if (amount_left > 0 && stack_size >= amount_left) { if (amount_left > 0 && stack_size >= amount_left) {
removed_count += amount_left; removed_count += amount_left;
DeleteItemInInventory(slot_id, amount_left, true); DeleteItemInInventory(slot_id, amount_left, true);

View File

@ -301,8 +301,8 @@ public:
uint16 FindTraderItem(int32 SerialNumber,uint16 Quantity); uint16 FindTraderItem(int32 SerialNumber,uint16 Quantity);
uint32 FindTraderItemSerialNumber(int32 ItemID); uint32 FindTraderItemSerialNumber(int32 ItemID);
EQ::ItemInstance* FindTraderItemBySerialNumber(int32 SerialNumber); EQ::ItemInstance* FindTraderItemBySerialNumber(int32 SerialNumber);
void FindAndNukeTraderItem(int32 item_id,uint16 quantity,Client* customer,uint16 traderslot); void FindAndNukeTraderItem(int32 item_id,int16 quantity,Client* customer,uint16 traderslot);
void NukeTraderItem(uint16 slot, int16 charges, uint16 quantity, Client* customer, uint16 traderslot, int32 uniqueid, int32 itemid = 0); void NukeTraderItem(uint16 slot, int16 charges, int16 quantity, Client* customer, uint16 traderslot, int32 uniqueid, int32 itemid = 0);
void ReturnTraderReq(const EQApplicationPacket* app,int16 traderitemcharges, uint32 itemid = 0); void ReturnTraderReq(const EQApplicationPacket* app,int16 traderitemcharges, uint32 itemid = 0);
void TradeRequestFailed(const EQApplicationPacket* app); void TradeRequestFailed(const EQApplicationPacket* app);
void BuyTraderItem(TraderBuy_Struct* tbs,Client* trader,const EQApplicationPacket* app); void BuyTraderItem(TraderBuy_Struct* tbs,Client* trader,const EQApplicationPacket* app);
@ -919,7 +919,7 @@ public:
bool PutItemInInventory(int16 slot_id, const EQ::ItemInstance& inst, bool client_update = false); bool PutItemInInventory(int16 slot_id, const EQ::ItemInstance& inst, bool client_update = false);
bool PushItemOnCursor(const EQ::ItemInstance& inst, bool client_update = false); bool PushItemOnCursor(const EQ::ItemInstance& inst, bool client_update = false);
void SendCursorBuffer(); void SendCursorBuffer();
void DeleteItemInInventory(int16 slot_id, int8 quantity = 0, bool client_update = false, bool update_db = true); void DeleteItemInInventory(int16 slot_id, int16 quantity = 0, bool client_update = false, bool update_db = true);
int CountItem(uint32 item_id); int CountItem(uint32 item_id);
void RemoveItem(uint32 item_id, uint32 quantity = 1); void RemoveItem(uint32 item_id, uint32 quantity = 1);
bool SwapItem(MoveItem_Struct* move_in); bool SwapItem(MoveItem_Struct* move_in);
@ -973,7 +973,7 @@ public:
//remove charges/multiple objects from inventory: //remove charges/multiple objects from inventory:
//bool DecreaseByType(uint32 type, uint8 amt); //bool DecreaseByType(uint32 type, uint8 amt);
bool DecreaseByID(uint32 type, uint8 amt); bool DecreaseByID(uint32 type, int16 quantity);
uint8 SlotConvert2(uint8 slot); //Maybe not needed. uint8 SlotConvert2(uint8 slot); //Maybe not needed.
void Escape(); //AA Escape void Escape(); //AA Escape
void DisenchantSummonedBags(bool client_update = true); void DisenchantSummonedBags(bool client_update = true);

View File

@ -2278,7 +2278,7 @@ void Client::Handle_OP_AdventureMerchantSell(const EQApplicationPacket *app)
if (!inst->IsStackable()) if (!inst->IsStackable())
{ {
DeleteItemInInventory(ams_in->slot, 0, false); DeleteItemInInventory(ams_in->slot);
} }
else else
{ {
@ -2293,7 +2293,7 @@ void Client::Handle_OP_AdventureMerchantSell(const EQApplicationPacket *app)
return; return;
} }
DeleteItemInInventory(ams_in->slot, ams_in->charges, false); DeleteItemInInventory(ams_in->slot, ams_in->charges);
price *= ams_in->charges; price *= ams_in->charges;
} }
@ -2764,7 +2764,7 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app)
if (!inst->IsStackable()) if (!inst->IsStackable())
{ {
DeleteItemInInventory(sell->slot_id, 0, false); DeleteItemInInventory(sell->slot_id);
} }
else else
{ {
@ -2779,7 +2779,7 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app)
return; return;
} }
DeleteItemInInventory(sell->slot_id, sell->charges, false); DeleteItemInInventory(sell->slot_id, sell->charges);
cost *= sell->charges; cost *= sell->charges;
} }
@ -9057,48 +9057,6 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app)
{ {
LogDebug("Error: unknown item->Click.Type ([{}])", item->Click.Type); LogDebug("Error: unknown item->Click.Type ([{}])", item->Click.Type);
} }
else
{
/*
//This is food/drink - consume it
if (item->ItemType == EQ::item::ItemTypeFood && m_pp.hunger_level < 5000)
{
Consume(item, item->ItemType, slot_id, false);
}
else if (item->ItemType == EQ::item::ItemTypeDrink && m_pp.thirst_level < 5000)
{
Consume(item, item->ItemType, slot_id, false);
}
else if (item->ItemType == EQ::item::ItemTypeAlcohol)
{
#if EQDEBUG >= 1
LogDebug("Drinking Alcohol from slot:[{}]", slot_id);
#endif
// This Seems to be handled in OP_DeleteItem handling
//DeleteItemInInventory(slot_id, 1, false);
//entity_list.MessageCloseString(this, true, 50, 0, DRINKING_MESSAGE, GetName(), item->Name);
//Should add intoxication level to the PP at some point
//CheckIncreaseSkill(ALCOHOL_TOLERANCE, nullptr, 25);
}
EQApplicationPacket *outapp2 = nullptr;
outapp2 = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct));
Stamina_Struct* sta = (Stamina_Struct*)outapp2->pBuffer;
if (m_pp.hunger_level > 6000)
sta->food = 6000;
if (m_pp.thirst_level > 6000)
sta->water = 6000;
sta->food = m_pp.hunger_level;
sta->water = m_pp.thirst_level;
QueuePacket(outapp2);
safe_delete(outapp2);
*/
}
} }
else else
{ {
@ -13413,26 +13371,14 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
// end QS code // end QS code
// Now remove the item from the player, this happens regardless of outcome // Now remove the item from the player, this happens regardless of outcome
if (!inst->IsStackable()) DeleteItemInInventory(
this->DeleteItemInInventory(mp->itemslot, 0, false); mp->itemslot,
else { (
// HACK: DeleteItemInInventory uses int8 for quantity type. There is no consistent use of types in code in this path so for now iteratively delete from inventory. !inst->IsStackable() ?
if (mp->quantity > 255) { 0 :
uint32 temp = mp->quantity; mp->quantity
while (temp > 255 && temp != 0) { )
// Delete chunks of 255 );
this->DeleteItemInInventory(mp->itemslot, 255, false);
temp -= 255;
}
if (temp != 0) {
// Delete remaining
this->DeleteItemInInventory(mp->itemslot, temp, false);
}
}
else {
this->DeleteItemInInventory(mp->itemslot, mp->quantity, false);
}
}
//This forces the price to show up correctly for charged items. //This forces the price to show up correctly for charged items.

View File

@ -1093,7 +1093,7 @@ void Client::SendCursorBuffer()
} }
// Remove item from inventory // Remove item from inventory
void Client::DeleteItemInInventory(int16 slot_id, int8 quantity, bool client_update, bool update_db) { void Client::DeleteItemInInventory(int16 slot_id, int16 quantity, bool client_update, bool update_db) {
#if (EQDEBUG >= 5) #if (EQDEBUG >= 5)
LogDebug("DeleteItemInInventory([{}], [{}], [{}])", slot_id, quantity, (client_update) ? "true":"false"); LogDebug("DeleteItemInInventory([{}], [{}], [{}])", slot_id, quantity, (client_update) ? "true":"false");
#endif #endif
@ -2503,67 +2503,14 @@ void Client::DyeArmorBySlot(uint8 slot, uint8 red, uint8 green, uint8 blue, uint
SendWearChange(slot); SendWearChange(slot);
} }
#if 0 bool Client::DecreaseByID(uint32 type, int16 quantity) {
bool Client::DecreaseByItemType(uint32 type, uint8 amt) {
const ItemData* TempItem = 0;
EQ::ItemInstance* ins;
int x;
for(x=EQ::legacy::POSSESSIONS_BEGIN; x <= EQ::legacy::POSSESSIONS_END; x++)
{
TempItem = 0;
ins = GetInv().GetItem(x);
if (ins)
TempItem = ins->GetItem();
if (TempItem && TempItem->ItemType == type)
{
if (ins->GetCharges() < amt)
{
amt -= ins->GetCharges();
DeleteItemInInventory(x,amt,true);
}
else
{
DeleteItemInInventory(x,amt,true);
amt = 0;
}
if (amt < 1)
return true;
}
}
for(x=EQ::legacy::GENERAL_BAGS_BEGIN; x <= EQ::legacy::GENERAL_BAGS_END; x++)
{
TempItem = 0;
ins = GetInv().GetItem(x);
if (ins)
TempItem = ins->GetItem();
if (TempItem && TempItem->ItemType == type)
{
if (ins->GetCharges() < amt)
{
amt -= ins->GetCharges();
DeleteItemInInventory(x,amt,true);
}
else
{
DeleteItemInInventory(x,amt,true);
amt = 0;
}
if (amt < 1)
return true;
}
}
return false;
}
#endif
bool Client::DecreaseByID(uint32 type, uint8 amt) {
const EQ::ItemData* TempItem = nullptr; const EQ::ItemData* TempItem = nullptr;
EQ::ItemInstance* ins = nullptr; EQ::ItemInstance* ins = nullptr;
int x; int x;
int num = 0; int num = 0;
for (x = EQ::invslot::POSSESSIONS_BEGIN; x <= EQ::invslot::POSSESSIONS_END; ++x) { for (x = EQ::invslot::POSSESSIONS_BEGIN; x <= EQ::invslot::POSSESSIONS_END; ++x) {
if (num >= amt) if (num >= quantity)
break; break;
if (((uint64)1 << x) & GetInv().GetLookup()->PossessionsBitmask == 0) if (((uint64)1 << x) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue; continue;
@ -2577,7 +2524,7 @@ bool Client::DecreaseByID(uint32 type, uint8 amt) {
} }
for (x = EQ::invbag::GENERAL_BAGS_BEGIN; x <= EQ::invbag::GENERAL_BAGS_END; ++x) { for (x = EQ::invbag::GENERAL_BAGS_BEGIN; x <= EQ::invbag::GENERAL_BAGS_END; ++x) {
if (num >= amt) if (num >= quantity)
break; break;
if ((((uint64)1 << (EQ::invslot::GENERAL_BEGIN + ((x - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT))) & GetInv().GetLookup()->PossessionsBitmask) == 0) if ((((uint64)1 << (EQ::invslot::GENERAL_BEGIN + ((x - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT))) & GetInv().GetLookup()->PossessionsBitmask) == 0)
continue; continue;
@ -2591,7 +2538,7 @@ bool Client::DecreaseByID(uint32 type, uint8 amt) {
} }
for (x = EQ::invbag::CURSOR_BAG_BEGIN; x <= EQ::invbag::CURSOR_BAG_END; ++x) { for (x = EQ::invbag::CURSOR_BAG_BEGIN; x <= EQ::invbag::CURSOR_BAG_END; ++x) {
if (num >= amt) if (num >= quantity)
break; break;
TempItem = nullptr; TempItem = nullptr;
@ -2602,12 +2549,12 @@ bool Client::DecreaseByID(uint32 type, uint8 amt) {
num += ins->GetCharges(); num += ins->GetCharges();
} }
if (num < amt) if (num < quantity)
return false; return false;
for (x = EQ::invslot::POSSESSIONS_BEGIN; x <= EQ::invslot::POSSESSIONS_END; ++x) { for (x = EQ::invslot::POSSESSIONS_BEGIN; x <= EQ::invslot::POSSESSIONS_END; ++x) {
if (amt < 1) if (quantity < 1)
break; break;
if (((uint64)1 << x) & GetInv().GetLookup()->PossessionsBitmask == 0) if (((uint64)1 << x) & GetInv().GetLookup()->PossessionsBitmask == 0)
continue; continue;
@ -2619,18 +2566,18 @@ bool Client::DecreaseByID(uint32 type, uint8 amt) {
if (TempItem && TempItem->ID != type) if (TempItem && TempItem->ID != type)
continue; continue;
if (ins->GetCharges() < amt) { if (ins->GetCharges() < quantity) {
amt -= ins->GetCharges(); quantity -= ins->GetCharges();
DeleteItemInInventory(x, amt, true); DeleteItemInInventory(x, quantity, true);
} }
else { else {
DeleteItemInInventory(x, amt, true); DeleteItemInInventory(x, quantity, true);
amt = 0; quantity = 0;
} }
} }
for (x = EQ::invbag::GENERAL_BAGS_BEGIN; x <= EQ::invbag::GENERAL_BAGS_END; ++x) { for (x = EQ::invbag::GENERAL_BAGS_BEGIN; x <= EQ::invbag::GENERAL_BAGS_END; ++x) {
if (amt < 1) if (quantity < 1)
break; break;
if ((((uint64)1 << (EQ::invslot::GENERAL_BEGIN + ((x - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT))) & GetInv().GetLookup()->PossessionsBitmask) == 0) if ((((uint64)1 << (EQ::invslot::GENERAL_BEGIN + ((x - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT))) & GetInv().GetLookup()->PossessionsBitmask) == 0)
continue; continue;
@ -2642,18 +2589,18 @@ bool Client::DecreaseByID(uint32 type, uint8 amt) {
if (TempItem && TempItem->ID != type) if (TempItem && TempItem->ID != type)
continue; continue;
if (ins->GetCharges() < amt) { if (ins->GetCharges() < quantity) {
amt -= ins->GetCharges(); quantity -= ins->GetCharges();
DeleteItemInInventory(x, amt, true); DeleteItemInInventory(x, quantity, true);
} }
else { else {
DeleteItemInInventory(x, amt, true); DeleteItemInInventory(x, quantity, true);
amt = 0; quantity = 0;
} }
} }
for (x = EQ::invbag::CURSOR_BAG_BEGIN; x <= EQ::invbag::CURSOR_BAG_END; ++x) { for (x = EQ::invbag::CURSOR_BAG_BEGIN; x <= EQ::invbag::CURSOR_BAG_END; ++x) {
if (amt < 1) if (quantity < 1)
break; break;
TempItem = nullptr; TempItem = nullptr;
@ -2663,13 +2610,13 @@ bool Client::DecreaseByID(uint32 type, uint8 amt) {
if (TempItem && TempItem->ID != type) if (TempItem && TempItem->ID != type)
continue; continue;
if (ins->GetCharges() < amt) { if (ins->GetCharges() < quantity) {
amt -= ins->GetCharges(); quantity -= ins->GetCharges();
DeleteItemInInventory(x, amt, true); DeleteItemInInventory(x, quantity, true);
} }
else { else {
DeleteItemInInventory(x, amt, true); DeleteItemInInventory(x, quantity, true);
amt = 0; quantity = 0;
} }
} }
@ -2906,7 +2853,7 @@ void Client::RemoveNoRent(bool client_update)
auto inst = m_inv[slot_id]; auto inst = m_inv[slot_id];
if(inst && !inst->GetItem()->NoRent) { if(inst && !inst->GetItem()->NoRent) {
LogInventory("NoRent Timer Lapse: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id); LogInventory("NoRent Timer Lapse: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id);
DeleteItemInInventory(slot_id, 0, false); // Can't delete from client Bank slots DeleteItemInInventory(slot_id); // Can't delete from client Bank slots
} }
} }
@ -2918,7 +2865,7 @@ void Client::RemoveNoRent(bool client_update)
auto inst = m_inv[slot_id]; auto inst = m_inv[slot_id];
if(inst && !inst->GetItem()->NoRent) { if(inst && !inst->GetItem()->NoRent) {
LogInventory("NoRent Timer Lapse: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id); LogInventory("NoRent Timer Lapse: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id);
DeleteItemInInventory(slot_id, 0, false); // Can't delete from client Bank Container slots DeleteItemInInventory(slot_id); // Can't delete from client Bank Container slots
} }
} }
@ -2926,7 +2873,7 @@ void Client::RemoveNoRent(bool client_update)
auto inst = m_inv[slot_id]; auto inst = m_inv[slot_id];
if(inst && !inst->GetItem()->NoRent) { if(inst && !inst->GetItem()->NoRent) {
LogInventory("NoRent Timer Lapse: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id); LogInventory("NoRent Timer Lapse: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id);
DeleteItemInInventory(slot_id, 0, false); // Can't delete from client Shared Bank slots DeleteItemInInventory(slot_id); // Can't delete from client Shared Bank slots
} }
} }
@ -2934,7 +2881,7 @@ void Client::RemoveNoRent(bool client_update)
auto inst = m_inv[slot_id]; auto inst = m_inv[slot_id];
if(inst && !inst->GetItem()->NoRent) { if(inst && !inst->GetItem()->NoRent) {
LogInventory("NoRent Timer Lapse: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id); LogInventory("NoRent Timer Lapse: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id);
DeleteItemInInventory(slot_id, 0, false); // Can't delete from client Shared Bank Container slots DeleteItemInInventory(slot_id); // Can't delete from client Shared Bank Container slots
} }
} }

View File

@ -2379,17 +2379,17 @@ XS(XS_Client_DeleteItemInInventory); /* prototype to pass -Wmissing-prototypes *
XS(XS_Client_DeleteItemInInventory) { XS(XS_Client_DeleteItemInInventory) {
dXSARGS; dXSARGS;
if (items < 2 || items > 4) if (items < 2 || items > 4)
Perl_croak(aTHX_ "Usage: Client::DeleteItemInInventory(THIS, int16 slot_id, [int8 quantity = 0], [bool client_update = false])"); // @categories Inventory and Items Perl_croak(aTHX_ "Usage: Client::DeleteItemInInventory(THIS, int16 slot_id, [int16 quantity = 0], [bool client_update = false])"); // @categories Inventory and Items
{ {
Client *THIS; Client *THIS;
int16 slot_id = (int16) SvIV(ST(1)); int16 slot_id = (int16) SvIV(ST(1));
int8 quantity; int16 quantity;
bool client_update; bool client_update;
VALIDATE_THIS_IS_CLIENT; VALIDATE_THIS_IS_CLIENT;
if (items < 3) if (items < 3)
quantity = 0; quantity = 0;
else { else {
quantity = (int8) SvIV(ST(2)); quantity = (int16) SvIV(ST(2));
} }
if (items < 4) if (items < 4)
@ -2638,14 +2638,14 @@ XS(XS_Client_DecreaseByID); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_DecreaseByID) { XS(XS_Client_DecreaseByID) {
dXSARGS; dXSARGS;
if (items != 3) if (items != 3)
Perl_croak(aTHX_ "Usage: Client::DecreaseByID(THIS, uint32 type, unit8 amount)"); // @categories Script Utility Perl_croak(aTHX_ "Usage: Client::DecreaseByID(THIS, uint32 type, int16 quantity)"); // @categories Script Utility
{ {
Client *THIS; Client *THIS;
bool RETVAL; bool RETVAL;
uint32 type = (uint32) SvUV(ST(1)); uint32 type = (uint32) SvUV(ST(1));
uint8 amt = (uint8) SvUV(ST(2)); int16 quantity = (int16) SvIV(ST(2));
VALIDATE_THIS_IS_CLIENT; VALIDATE_THIS_IS_CLIENT;
RETVAL = THIS->DecreaseByID(type, amt); RETVAL = THIS->DecreaseByID(type, quantity);
ST(0) = boolSV(RETVAL); ST(0) = boolSV(RETVAL);
sv_2mortal(ST(0)); sv_2mortal(ST(0));
} }

View File

@ -622,7 +622,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
if(IsClient()){ if(IsClient()){
EQ::ItemInstance* transI = CastToClient()->GetInv().GetItem(EQ::invslot::slotCursor); EQ::ItemInstance* transI = CastToClient()->GetInv().GetItem(EQ::invslot::slotCursor);
if (transI && transI->IsClassCommon() && transI->IsStackable()){ if (transI && transI->IsClassCommon() && transI->IsStackable()){
uint32 fcharges = transI->GetCharges(); int16 fcharges = transI->GetCharges();
//Does it sound like meat... maybe should check if it looks like meat too... //Does it sound like meat... maybe should check if it looks like meat too...
if(strstr(transI->GetItem()->Name, "meat") || if(strstr(transI->GetItem()->Name, "meat") ||
strstr(transI->GetItem()->Name, "Meat") || strstr(transI->GetItem()->Name, "Meat") ||
@ -636,8 +636,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
else{ else{
Message(Chat::Red, "You can only transmute flesh to bone."); Message(Chat::Red, "You can only transmute flesh to bone.");
} }
} } else{
else{
Message(Chat::Red, "You can only transmute flesh to bone."); Message(Chat::Red, "You can only transmute flesh to bone.");
} }
} }

View File

@ -1373,7 +1373,7 @@ uint16 Client::FindTraderItem(int32 SerialNumber, uint16 Quantity){
return 0; return 0;
} }
void Client::NukeTraderItem(uint16 Slot,int16 Charges,uint16 Quantity,Client* Customer,uint16 TraderSlot, int32 SerialNumber, int32 itemid) { void Client::NukeTraderItem(uint16 Slot,int16 Charges,int16 Quantity,Client* Customer,uint16 TraderSlot, int32 SerialNumber, int32 itemid) {
if(!Customer) if(!Customer)
return; return;
@ -1451,7 +1451,7 @@ void Client::TraderUpdate(uint16 SlotID,uint32 TraderID){
safe_delete(outapp); safe_delete(outapp);
} }
void Client::FindAndNukeTraderItem(int32 SerialNumber, uint16 Quantity, Client* Customer, uint16 TraderSlot){ void Client::FindAndNukeTraderItem(int32 SerialNumber, int16 Quantity, Client* Customer, uint16 TraderSlot){
const EQ::ItemInstance* item= nullptr; const EQ::ItemInstance* item= nullptr;
bool Stackable = false; bool Stackable = false;

View File

@ -138,20 +138,20 @@ void Client::DoTributeUpdate() {
uint32 tid = m_pp.tributes[r].tribute; uint32 tid = m_pp.tributes[r].tribute;
if(tid == TRIBUTE_NONE) { if(tid == TRIBUTE_NONE) {
if (m_inv[EQ::invslot::TRIBUTE_BEGIN + r]) if (m_inv[EQ::invslot::TRIBUTE_BEGIN + r])
DeleteItemInInventory(EQ::invslot::TRIBUTE_BEGIN + r, 0, false); DeleteItemInInventory(EQ::invslot::TRIBUTE_BEGIN + r);
continue; continue;
} }
if(tribute_list.count(tid) != 1) { if(tribute_list.count(tid) != 1) {
if (m_inv[EQ::invslot::TRIBUTE_BEGIN + r]) if (m_inv[EQ::invslot::TRIBUTE_BEGIN + r])
DeleteItemInInventory(EQ::invslot::TRIBUTE_BEGIN + r, 0, false); DeleteItemInInventory(EQ::invslot::TRIBUTE_BEGIN + r);
continue; continue;
} }
//sanity check //sanity check
if(m_pp.tributes[r].tier >= MAX_TRIBUTE_TIERS) { if(m_pp.tributes[r].tier >= MAX_TRIBUTE_TIERS) {
if (m_inv[EQ::invslot::TRIBUTE_BEGIN + r]) if (m_inv[EQ::invslot::TRIBUTE_BEGIN + r])
DeleteItemInInventory(EQ::invslot::TRIBUTE_BEGIN + r, 0, false); DeleteItemInInventory(EQ::invslot::TRIBUTE_BEGIN + r);
m_pp.tributes[r].tier = 0; m_pp.tributes[r].tier = 0;
continue; continue;
} }
@ -165,7 +165,7 @@ void Client::DoTributeUpdate() {
if(inst == nullptr) if(inst == nullptr)
continue; continue;
PutItemInInventory(EQ::invslot::TRIBUTE_BEGIN + r, *inst, false); PutItemInInventory(EQ::invslot::TRIBUTE_BEGIN + r, *inst);
SendItemPacket(EQ::invslot::TRIBUTE_BEGIN + r, inst, ItemPacketTributeItem); SendItemPacket(EQ::invslot::TRIBUTE_BEGIN + r, inst, ItemPacketTributeItem);
safe_delete(inst); safe_delete(inst);
} }
@ -173,7 +173,7 @@ void Client::DoTributeUpdate() {
//unequip tribute items... //unequip tribute items...
for (r = 0; r < EQ::invtype::TRIBUTE_SIZE; r++) { for (r = 0; r < EQ::invtype::TRIBUTE_SIZE; r++) {
if (m_inv[EQ::invslot::TRIBUTE_BEGIN + r]) if (m_inv[EQ::invslot::TRIBUTE_BEGIN + r])
DeleteItemInInventory(EQ::invslot::TRIBUTE_BEGIN + r, 0, false); DeleteItemInInventory(EQ::invslot::TRIBUTE_BEGIN + r);
} }
} }
CalcBonuses(); CalcBonuses();
@ -261,10 +261,10 @@ int32 Client::TributeItem(uint32 slot, uint32 quantity) {
if(inst->IsStackable()) { if(inst->IsStackable()) {
if(inst->GetCharges() < (int32)quantity) //dont have enough.... if(inst->GetCharges() < (int32)quantity) //dont have enough....
return(0); return(0);
DeleteItemInInventory(slot, quantity, false); DeleteItemInInventory(slot, quantity);
} else { } else {
quantity = 1; quantity = 1;
DeleteItemInInventory(slot, 0, false); DeleteItemInInventory(slot);
} }
pts *= quantity; pts *= quantity;