Skip to content

Commit 5a1df38

Browse files
authored
[Fix] Parcel Delivery Updates for two edge cases (#4753)
- Properly send an item via parcel that has 0 charges
1 parent 8cd7148 commit 5a1df38

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

zone/parcels.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void Client::SendBulkParcels()
5858
p.second.aug_slot_6
5959
));
6060
if (inst) {
61-
inst->SetCharges(p.second.quantity > 0 ? p.second.quantity : 1);
61+
inst->SetCharges(p.second.quantity);
6262
inst->SetMerchantCount(1);
6363
inst->SetMerchantSlot(p.second.slot_id);
6464
if (inst->IsStackable()) {
@@ -161,7 +161,7 @@ void Client::SendParcel(Parcel_Struct &parcel_in)
161161
p.aug_slot_6
162162
));
163163
if (inst) {
164-
inst->SetCharges(p.quantity > 0 ? p.quantity : 1);
164+
inst->SetCharges(p.quantity);
165165
inst->SetMerchantCount(1);
166166
inst->SetMerchantSlot(p.slot_id);
167167
if (inst->IsStackable()) {
@@ -272,6 +272,10 @@ void Client::SendParcelStatus()
272272

273273
void Client::DoParcelSend(const Parcel_Struct *parcel_in)
274274
{
275+
if (IsCasting()) {
276+
StopCasting();
277+
}
278+
275279
auto send_to_client = CharacterParcelsRepository::GetParcelCountAndCharacterName(database, parcel_in->send_to);
276280
auto merchant = entity_list.GetMob(parcel_in->npc_id);
277281
if (!merchant) {
@@ -382,7 +386,7 @@ void Client::DoParcelSend(const Parcel_Struct *parcel_in)
382386
quantity = parcel_in->quantity;
383387
}
384388
else {
385-
quantity = inst->GetCharges() > 0 ? inst->GetCharges() : parcel_in->quantity;
389+
quantity = inst->GetCharges() >= 0 ? inst->GetCharges() : parcel_in->quantity;
386390
}
387391

388392
CharacterParcelsRepository::CharacterParcels parcel_out{};
@@ -434,13 +438,13 @@ void Client::DoParcelSend(const Parcel_Struct *parcel_in)
434438
cpc.aug_slot_5 = augs.at(4);
435439
cpc.aug_slot_6 = augs.at(5);
436440
}
437-
cpc.quantity = kv.second->GetCharges() > 0 ? kv.second->GetCharges() : 1;
441+
cpc.quantity = kv.second->GetCharges() >= 0 ? kv.second->GetCharges() : 1;
438442
all_entries.push_back(cpc);
439443
}
440444
CharacterParcelsContainersRepository::InsertMany(database, all_entries);
441445
}
442446

443-
RemoveItemBySerialNumber(inst->GetSerialNumber(), parcel_out.quantity);
447+
RemoveItemBySerialNumber(inst->GetSerialNumber(), parcel_out.quantity == 0 ? 1 : parcel_out.quantity);
444448
std::unique_ptr<EQApplicationPacket> outapp(new EQApplicationPacket(OP_ShopSendParcel));
445449
QueuePacket(outapp.get());
446450

@@ -642,9 +646,9 @@ void Client::DoParcelRetrieve(const ParcelRetrieve_Struct &parcel_in)
642646
if (p != m_parcels.end()) {
643647
uint32 item_id = parcel_in.parcel_item_id;
644648
uint32 item_quantity = p->second.quantity;
645-
if (!item_id || !item_quantity) {
649+
if (!item_id) {
646650
LogError(
647-
"Attempt to retrieve parcel with erroneous item id or quantity for client character id {}.",
651+
"Attempt to retrieve parcel with erroneous item id for client character id {}.",
648652
CharacterID()
649653
);
650654
SendParcelRetrieveAck();

0 commit comments

Comments
 (0)