mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-15 21:12:25 +00:00
Merchants will now keep track of charges sold to them properly so it is no longer possible to recharge items using merchants.
This commit is contained in:
parent
5a6c25887a
commit
c6377b93d5
@ -238,6 +238,14 @@ bool ItemInst::IsStackable() const
|
|||||||
return m_item->Stackable;
|
return m_item->Stackable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ItemInst::IsCharged() const
|
||||||
|
{
|
||||||
|
if(m_item->MaxCharges > 1)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Can item be equipped?
|
// Can item be equipped?
|
||||||
|
|
||||||
bool ItemInst::IsEquipable(uint16 race, uint16 class_) const
|
bool ItemInst::IsEquipable(uint16 race, uint16 class_) const
|
||||||
|
|||||||
@ -291,6 +291,7 @@ public:
|
|||||||
|
|
||||||
// Can item be stacked?
|
// Can item be stacked?
|
||||||
bool IsStackable() const;
|
bool IsStackable() const;
|
||||||
|
bool IsCharged() const;
|
||||||
|
|
||||||
// Can item be equipped by/at?
|
// Can item be equipped by/at?
|
||||||
bool IsEquipable(uint16 race, uint16 class_) const;
|
bool IsEquipable(uint16 race, uint16 class_) const;
|
||||||
|
|||||||
@ -5561,8 +5561,13 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
|||||||
Message(15,"You can only have one of a lore item.");
|
Message(15,"You can only have one of a lore item.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(tmpmer_used && (mp->quantity > prevcharges))
|
if(tmpmer_used && (mp->quantity > prevcharges || item->MaxCharges > 1))
|
||||||
mp->quantity = prevcharges;
|
{
|
||||||
|
if(prevcharges > item->MaxCharges && item->MaxCharges > 1)
|
||||||
|
mp->quantity = item->MaxCharges;
|
||||||
|
else
|
||||||
|
mp->quantity = prevcharges;
|
||||||
|
}
|
||||||
|
|
||||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ShopPlayerBuy, sizeof(Merchant_Sell_Struct));
|
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ShopPlayerBuy, sizeof(Merchant_Sell_Struct));
|
||||||
Merchant_Sell_Struct* mpo=(Merchant_Sell_Struct*)outapp->pBuffer;
|
Merchant_Sell_Struct* mpo=(Merchant_Sell_Struct*)outapp->pBuffer;
|
||||||
@ -5573,13 +5578,11 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
|||||||
|
|
||||||
int16 freeslotid=0;
|
int16 freeslotid=0;
|
||||||
int16 charges = 0;
|
int16 charges = 0;
|
||||||
if (item->Stackable) {
|
if (item->Stackable || item->MaxCharges > 1)
|
||||||
charges = mp->quantity;
|
charges = mp->quantity;
|
||||||
} else {
|
else
|
||||||
// this needs expanded to handle varying charges from the merchant,
|
|
||||||
// but will require merchantlist_temp changes amonst other things.
|
|
||||||
charges = item->MaxCharges;
|
charges = item->MaxCharges;
|
||||||
}
|
|
||||||
ItemInst* inst = database.CreateItem(item, charges);
|
ItemInst* inst = database.CreateItem(item, charges);
|
||||||
|
|
||||||
int SinglePrice = 0;
|
int SinglePrice = 0;
|
||||||
@ -5588,7 +5591,10 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
|||||||
else
|
else
|
||||||
SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate);
|
SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate);
|
||||||
|
|
||||||
mpo->price = SinglePrice * mp->quantity;
|
if(item->MaxCharges > 1)
|
||||||
|
mpo->price = SinglePrice;
|
||||||
|
else
|
||||||
|
mpo->price = SinglePrice * mp->quantity;
|
||||||
if(mpo->price < 0 )
|
if(mpo->price < 0 )
|
||||||
{
|
{
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
@ -5632,9 +5638,6 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string packet;
|
std::string packet;
|
||||||
if(mp->quantity==1 && item->MaxCharges>0 && item->MaxCharges<255)
|
|
||||||
mp->quantity=item->MaxCharges;
|
|
||||||
|
|
||||||
if (!stacked && inst) {
|
if (!stacked && inst) {
|
||||||
PutItemInInventory(freeslotid, *inst);
|
PutItemInInventory(freeslotid, *inst);
|
||||||
SendItemPacket(freeslotid, inst, ItemPacketTrade);
|
SendItemPacket(freeslotid, inst, ItemPacketTrade);
|
||||||
@ -5756,37 +5759,36 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
|
|||||||
//Message(13,"%s tells you, 'LOL NOPE'", vendor->GetName());
|
//Message(13,"%s tells you, 'LOL NOPE'", vendor->GetName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (RuleB(Merchant, UsePriceMod)){
|
|
||||||
price=(int)((item->Price*mp->quantity)*(RuleR(Merchant, BuyCostMod))*Client::CalcPriceMod(vendor,true)+0.5); // need to round up, because client does it automatically when displaying price
|
int cost_quantity = mp->quantity;
|
||||||
}
|
if(inst->IsCharged())
|
||||||
|
int cost_quantity = 1;
|
||||||
|
|
||||||
|
if (RuleB(Merchant, UsePriceMod))
|
||||||
|
price=(int)((item->Price*cost_quantity)*(RuleR(Merchant, BuyCostMod))*Client::CalcPriceMod(vendor,true)+0.5); // need to round up, because client does it automatically when displaying price
|
||||||
else
|
else
|
||||||
price=(int)((item->Price*mp->quantity)*(RuleR(Merchant, BuyCostMod))+0.5);
|
price=(int)((item->Price*cost_quantity)*(RuleR(Merchant, BuyCostMod))+0.5);
|
||||||
AddMoneyToPP(price,false);
|
AddMoneyToPP(price,false);
|
||||||
|
|
||||||
if (inst->IsStackable())
|
if (inst->IsStackable() || inst->IsCharged())
|
||||||
{
|
{
|
||||||
unsigned int i_quan = inst->GetCharges();
|
unsigned int i_quan = inst->GetCharges();
|
||||||
if (mp->quantity > i_quan)
|
if (mp->quantity > i_quan || inst->IsCharged())
|
||||||
mp->quantity = i_quan;
|
mp->quantity = i_quan;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
mp->quantity = 1;
|
mp->quantity = 1;
|
||||||
}
|
|
||||||
|
|
||||||
if (RuleB(EventLog, RecordSellToMerchant))
|
if (RuleB(EventLog, RecordSellToMerchant))
|
||||||
LogMerchant(this, vendor, mp->quantity, price, item, false);
|
LogMerchant(this, vendor, mp->quantity, price, item, false);
|
||||||
|
|
||||||
int freeslot = 0;
|
int charges = mp->quantity;
|
||||||
int charges = 0;
|
//Hack workaround so usable items with 0 charges aren't simply deleted
|
||||||
if(inst->IsStackable())
|
if(charges == 0 && item->ItemType != 11 && item->ItemType != 17 && item->ItemType != 19 && item->ItemType != 21)
|
||||||
charges = mp->quantity;
|
|
||||||
else
|
|
||||||
//charges = inst->GetCharges();
|
|
||||||
//FIXME: Temp merchant table uses 'charges' as the quantity, so doesn't properly handle charged items.
|
|
||||||
charges = 1;
|
charges = 1;
|
||||||
|
|
||||||
if((freeslot = zone->SaveTempItem(vendor->CastToNPC()->MerchantType, vendor->GetNPCTypeID(),itemid,charges,true)) > 0){
|
int freeslot = 0;
|
||||||
|
if(charges > 0 && (freeslot = zone->SaveTempItem(vendor->CastToNPC()->MerchantType, vendor->GetNPCTypeID(),itemid,charges,true)) > 0){
|
||||||
ItemInst* inst2 = inst->Clone();
|
ItemInst* inst2 = inst->Clone();
|
||||||
if (RuleB(Merchant, UsePriceMod)){
|
if (RuleB(Merchant, UsePriceMod)){
|
||||||
inst2->SetPrice(item->Price*(RuleR(Merchant, SellCostMod))*item->SellRate*Client::CalcPriceMod(vendor,false));
|
inst2->SetPrice(item->Price*(RuleR(Merchant, SellCostMod))*item->SellRate*Client::CalcPriceMod(vendor,false));
|
||||||
@ -5846,6 +5848,10 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
|
|||||||
else
|
else
|
||||||
this->DeleteItemInInventory(mp->itemslot,mp->quantity,false);
|
this->DeleteItemInInventory(mp->itemslot,mp->quantity,false);
|
||||||
|
|
||||||
|
//This forces the price to show up correctly for charged items.
|
||||||
|
if(inst->IsCharged())
|
||||||
|
mp->quantity = 1;
|
||||||
|
|
||||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ShopPlayerSell, sizeof(Merchant_Purchase_Struct));
|
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ShopPlayerSell, sizeof(Merchant_Purchase_Struct));
|
||||||
Merchant_Purchase_Struct* mco=(Merchant_Purchase_Struct*)outapp->pBuffer;
|
Merchant_Purchase_Struct* mco=(Merchant_Purchase_Struct*)outapp->pBuffer;
|
||||||
mco->npcid = vendor->GetID();
|
mco->npcid = vendor->GetID();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user