mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 13:16:39 +00:00
Update parcels for item_unique_id
This commit is contained in:
+5
-7
@@ -12700,13 +12700,11 @@ uint16 Client::GetSkill(EQ::skills::SkillType skill_id) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Client::RemoveItemBySerialNumber(const std::string &serial_number, uint32 quantity)
|
||||
void Client::RemoveItemBySerialNumber(const std::string &item_unique_id, uint32 quantity)
|
||||
{
|
||||
EQ::ItemInstance *item = nullptr;
|
||||
|
||||
uint32 removed_count = 0;
|
||||
|
||||
const auto& slot_ids = GetInventorySlots();
|
||||
EQ::ItemInstance *item = nullptr;
|
||||
uint32 removed_count = 0;
|
||||
const auto &slot_ids = GetInventorySlots();
|
||||
|
||||
for (const int16& slot_id : slot_ids) {
|
||||
if (removed_count == quantity) {
|
||||
@@ -12714,7 +12712,7 @@ void Client::RemoveItemBySerialNumber(const std::string &serial_number, uint32 q
|
||||
}
|
||||
|
||||
item = GetInv().GetItem(slot_id);
|
||||
if (item && item->GetSerialNumber2().compare(serial_number) == 0) {
|
||||
if (item && item->GetUniqueID().compare(item_unique_id) == 0) {
|
||||
uint32 charges = item->IsStackable() ? item->GetCharges() : 0;
|
||||
uint32 stack_size = std::max(charges, static_cast<uint32>(1));
|
||||
if ((removed_count + stack_size) <= quantity) {
|
||||
|
||||
+1
-1
@@ -1150,7 +1150,7 @@ public:
|
||||
void SetItemCooldown(uint32 item_id, bool use_saved_timer = false, uint32 in_seconds = 1);
|
||||
uint32 GetItemCooldown(uint32 item_id);
|
||||
void RemoveItem(uint32 item_id, uint32 quantity = 1);
|
||||
void RemoveItemBySerialNumber(const std::string &serial_number, uint32 quantity = 1);
|
||||
void RemoveItemBySerialNumber(const std::string &item_unique_id, uint32 quantity = 1);
|
||||
bool SwapItem(MoveItem_Struct* move_in);
|
||||
void SwapItemResync(MoveItem_Struct* move_slots);
|
||||
void PutLootInInventory(int16 slot_id, const EQ::ItemInstance &inst, LootItem** bag_item_data = 0);
|
||||
|
||||
@@ -386,7 +386,7 @@ bool Client::DoEvolveCheckProgression(EQ::ItemInstance &inst)
|
||||
|
||||
PlayerEvent::EvolveItem e{};
|
||||
|
||||
RemoveItemBySerialNumber(inst.GetSerialNumber2());
|
||||
RemoveItemBySerialNumber(inst.GetUniqueID());
|
||||
EvolvingItemsManager::Instance()->LoadPlayerEvent(inst, e);
|
||||
e.status = "Evolved Item due to obtaining progression - Old Evolve Item removed from inventory.";
|
||||
RecordPlayerEventLog(PlayerEvent::EVOLVE_ITEM, e);
|
||||
@@ -506,7 +506,7 @@ void Client::DoEvolveTransferXP(const EQApplicationPacket *app)
|
||||
|
||||
PlayerEvent::EvolveItem e{};
|
||||
|
||||
RemoveItemBySerialNumber(inst_from->GetSerialNumber2());
|
||||
RemoveItemBySerialNumber(inst_from->GetUniqueID());
|
||||
EvolvingItemsManager::Instance()->LoadPlayerEvent(*inst_from, e);
|
||||
e.status = "Transfer XP - Original FROM Evolve Item removed from inventory.";
|
||||
RecordPlayerEventLog(PlayerEvent::EVOLVE_ITEM, e);
|
||||
@@ -516,7 +516,7 @@ void Client::DoEvolveTransferXP(const EQApplicationPacket *app)
|
||||
e.status = "Transfer XP - Updated FROM item placed in inventory.";
|
||||
RecordPlayerEventLog(PlayerEvent::EVOLVE_ITEM, e);
|
||||
|
||||
RemoveItemBySerialNumber(inst_to->GetSerialNumber2());
|
||||
RemoveItemBySerialNumber(inst_to->GetUniqueID());
|
||||
EvolvingItemsManager::Instance()->LoadPlayerEvent(*inst_to, e);
|
||||
e.status = "Transfer XP - Original TO Evolve Item removed from inventory.";
|
||||
RecordPlayerEventLog(PlayerEvent::EVOLVE_ITEM, e);
|
||||
|
||||
@@ -185,7 +185,7 @@ void ShowInventory(Client *c, const Seperator *sep)
|
||||
scope_bit & peekWorld ? EQ::invslot::WORLD_BEGIN + index_main : index_main,
|
||||
linker.GenerateLink(),
|
||||
item_data->ID,
|
||||
inst_main->GetSerialNumber2().c_str(),
|
||||
inst_main->GetUniqueID().c_str(),
|
||||
inst_main->IsStackable() && inst_main->GetCharges() > 0 ?
|
||||
fmt::format(
|
||||
" (Stack of {})",
|
||||
@@ -254,7 +254,7 @@ void ShowInventory(Client *c, const Seperator *sep)
|
||||
sub_index,
|
||||
linker.GenerateLink(),
|
||||
item_data->ID,
|
||||
inst_sub->GetSerialNumber2().c_str(),
|
||||
inst_sub->GetUniqueID().c_str(),
|
||||
(
|
||||
inst_sub->IsStackable() && inst_sub->GetCharges() > 0 ?
|
||||
fmt::format(
|
||||
|
||||
+2
-2
@@ -1055,8 +1055,8 @@ bool Client::PushItemOnCursor(const EQ::ItemInstance& inst, bool client_update)
|
||||
bool Client::PutItemInInventory(int16 slot_id, const EQ::ItemInstance& inst, bool client_update) {
|
||||
LogInventory("Putting item [{}] ([{}]) into slot [{}]", inst.GetItem()->Name, inst.GetItem()->ID, slot_id);
|
||||
|
||||
if (inst.GetSerialNumber2().empty()) {
|
||||
inst.CreateSerialNumber2();
|
||||
if (inst.GetUniqueID().empty()) {
|
||||
inst.CreateUniqueID();
|
||||
}
|
||||
|
||||
if (slot_id == EQ::invslot::slotCursor) { // don't trust macros before conditional statements...
|
||||
|
||||
+21
-14
@@ -396,6 +396,7 @@ void Client::DoParcelSend(const Parcel_Struct *parcel_in)
|
||||
parcel_out.sent_date = time(nullptr);
|
||||
parcel_out.quantity = quantity;
|
||||
parcel_out.item_id = inst->GetID();
|
||||
parcel_out.item_unique_id = inst->GetUniqueID();
|
||||
parcel_out.char_id = send_to_client.at(0).char_id;
|
||||
parcel_out.slot_id = next_slot;
|
||||
parcel_out.evolve_amount = inst->GetEvolveCurrentAmount();
|
||||
@@ -433,13 +434,14 @@ void Client::DoParcelSend(const Parcel_Struct *parcel_in)
|
||||
|
||||
std::vector<CharacterParcelsContainersRepository::CharacterParcelsContainers> all_entries{};
|
||||
if (inst->IsNoneEmptyContainer()) {
|
||||
for (auto const &kv: *inst->GetContents()) {
|
||||
for (auto const &[slot, item]: *inst->GetContents()) {
|
||||
CharacterParcelsContainersRepository::CharacterParcelsContainers cpc{};
|
||||
cpc.parcels_id = result.id;
|
||||
cpc.slot_id = kv.first;
|
||||
cpc.item_id = kv.second->GetID();
|
||||
if (kv.second->IsAugmented()) {
|
||||
auto augs = kv.second->GetAugmentIDs();
|
||||
cpc.parcels_id = result.id;
|
||||
cpc.slot_id = slot;
|
||||
cpc.item_id = item->GetID();
|
||||
cpc.item_unique_id = item->GetUniqueID();
|
||||
if (item->IsAugmented()) {
|
||||
auto augs = item->GetAugmentIDs();
|
||||
cpc.aug_slot_1 = augs.at(0);
|
||||
cpc.aug_slot_2 = augs.at(1);
|
||||
cpc.aug_slot_3 = augs.at(2);
|
||||
@@ -448,14 +450,15 @@ void Client::DoParcelSend(const Parcel_Struct *parcel_in)
|
||||
cpc.aug_slot_6 = augs.at(5);
|
||||
}
|
||||
|
||||
cpc.quantity = kv.second->GetCharges() >= 0 ? kv.second->GetCharges() : 1;
|
||||
cpc.evolve_amount = kv.second->GetEvolveCurrentAmount();
|
||||
cpc.quantity = item->GetCharges() >= 0 ? item->GetCharges() : 1;
|
||||
cpc.evolve_amount = item->GetEvolveCurrentAmount();
|
||||
cpc.quantity = item->GetCharges() >= 0 ? item->GetCharges() : 1;
|
||||
all_entries.push_back(cpc);
|
||||
}
|
||||
CharacterParcelsContainersRepository::InsertMany(database, all_entries);
|
||||
}
|
||||
|
||||
RemoveItemBySerialNumber(inst->GetSerialNumber2(), parcel_out.quantity == 0 ? 1 : parcel_out.quantity);
|
||||
RemoveItemBySerialNumber(inst->GetUniqueID(), parcel_out.quantity == 0 ? 1 : parcel_out.quantity);
|
||||
std::unique_ptr<EQApplicationPacket> outapp(new EQApplicationPacket(OP_ShopSendParcel));
|
||||
QueuePacket(outapp.get());
|
||||
|
||||
@@ -477,6 +480,7 @@ void Client::DoParcelSend(const Parcel_Struct *parcel_in)
|
||||
e.from_player_name = parcel_out.from_name;
|
||||
e.to_player_name = send_to_client.at(0).character_name;
|
||||
e.item_id = parcel_out.item_id;
|
||||
e.item_unique_id = parcel_out.item_unique_id;
|
||||
e.augment_1_id = parcel_out.aug_slot_1;
|
||||
e.augment_2_id = parcel_out.aug_slot_2;
|
||||
e.augment_3_id = parcel_out.aug_slot_3;
|
||||
@@ -493,6 +497,7 @@ void Client::DoParcelSend(const Parcel_Struct *parcel_in)
|
||||
e.from_player_name = parcel_out.from_name;
|
||||
e.to_player_name = send_to_client.at(0).character_name;
|
||||
e.item_id = i.item_id;
|
||||
e.item_unique_id = i.item_unique_id;
|
||||
e.augment_1_id = i.aug_slot_1;
|
||||
e.augment_2_id = i.aug_slot_2;
|
||||
e.augment_3_id = i.aug_slot_3;
|
||||
@@ -655,8 +660,9 @@ void Client::DoParcelRetrieve(const ParcelRetrieve_Struct &parcel_in)
|
||||
}
|
||||
);
|
||||
if (p != m_parcels.end()) {
|
||||
uint32 item_id = parcel_in.parcel_item_id;
|
||||
uint32 item_quantity = p->second.quantity;
|
||||
uint32 item_id = parcel_in.parcel_item_id;
|
||||
uint32 item_quantity = p->second.quantity;
|
||||
std::string item_unique_id = p->second.item_unique_id;
|
||||
if (!item_id) {
|
||||
LogError(
|
||||
"Attempt to retrieve parcel with erroneous item id for client character id {}.",
|
||||
@@ -698,6 +704,7 @@ void Client::DoParcelRetrieve(const ParcelRetrieve_Struct &parcel_in)
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
inst->SetUniqueID(item_unique_id);
|
||||
std::vector<CharacterParcelsContainersRepository::CharacterParcelsContainers> results{};
|
||||
if (inst->IsClassBag() && inst->GetItem()->BagSlots > 0) {
|
||||
auto contents = inst->GetContents();
|
||||
@@ -722,7 +729,7 @@ void Client::DoParcelRetrieve(const ParcelRetrieve_Struct &parcel_in)
|
||||
}
|
||||
|
||||
item->SetEvolveCurrentAmount(i.evolve_amount);
|
||||
|
||||
item->SetUniqueID(i.item_unique_id);
|
||||
if (CheckLoreConflict(item->GetItem())) {
|
||||
if (RuleB(Parcel, DeleteOnDuplicate)) {
|
||||
MessageString(Chat::Yellow, PARCEL_DUPLICATE_DELETE, inst->GetItem()->Name);
|
||||
@@ -771,6 +778,7 @@ void Client::DoParcelRetrieve(const ParcelRetrieve_Struct &parcel_in)
|
||||
PlayerEvent::ParcelRetrieve e{};
|
||||
e.from_player_name = p->second.from_name;
|
||||
e.item_id = p->second.item_id;
|
||||
e.item_unique_id = p->second.item_unique_id;
|
||||
e.augment_1_id = p->second.aug_slot_1;
|
||||
e.augment_2_id = p->second.aug_slot_2;
|
||||
e.augment_3_id = p->second.aug_slot_3;
|
||||
@@ -784,6 +792,7 @@ void Client::DoParcelRetrieve(const ParcelRetrieve_Struct &parcel_in)
|
||||
for (auto const &i:results) {
|
||||
e.from_player_name = p->second.from_name;
|
||||
e.item_id = i.item_id;
|
||||
e.item_unique_id = i.item_unique_id;
|
||||
e.augment_1_id = i.aug_slot_1;
|
||||
e.augment_2_id = i.aug_slot_2;
|
||||
e.augment_3_id = i.aug_slot_3;
|
||||
@@ -793,8 +802,6 @@ void Client::DoParcelRetrieve(const ParcelRetrieve_Struct &parcel_in)
|
||||
e.quantity = i.quantity;
|
||||
e.sent_date = p->second.sent_date;
|
||||
RecordPlayerEventLog(PlayerEvent::PARCEL_RETRIEVE, e);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -1062,7 +1062,7 @@ void Client::BulkSendTraderInventory(uint32 char_id)
|
||||
)
|
||||
);
|
||||
if (inst) {
|
||||
inst->SetSerialNumber2(trader_items.at(i).item_sn);
|
||||
inst->SetUniqueID(trader_items.at(i).item_sn);
|
||||
if (trader_items.at(i).item_charges > 0) {
|
||||
inst->SetCharges(trader_items.at(i).item_charges);
|
||||
}
|
||||
@@ -1118,7 +1118,7 @@ EQ::ItemInstance *Client::FindTraderItemBySerialNumber(std::string &serial_numbe
|
||||
slot_id = EQ::InventoryProfile::CalcSlotId(i, x);
|
||||
item = GetInv().GetItem(slot_id);
|
||||
if (item) {
|
||||
if (item->GetSerialNumber2().compare(serial_number) == 0) {
|
||||
if (item->GetUniqueID().compare(serial_number) == 0) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -1155,7 +1155,7 @@ GetItems2_Struct *Client::GetTraderItems()
|
||||
|
||||
if (item) {
|
||||
gis->items[ndx] = item->GetID();
|
||||
gis->serial_number[ndx] = item->GetSerialNumber2();
|
||||
gis->serial_number[ndx] = item->GetUniqueID();
|
||||
gis->charges[ndx] = item->GetCharges() == 0 ? 1 : item->GetCharges();
|
||||
ndx++;
|
||||
}
|
||||
@@ -1177,7 +1177,7 @@ uint16 Client::FindTraderItem(std::string &serial_number, uint16 Quantity){
|
||||
|
||||
item = GetInv().GetItem(SlotID);
|
||||
|
||||
if (item && item->GetSerialNumber2().compare(serial_number) == 0 &&
|
||||
if (item && item->GetUniqueID().compare(serial_number) == 0 &&
|
||||
(item->GetCharges() >= Quantity || (item->GetCharges() <= 0 && Quantity == 1)))
|
||||
{
|
||||
return SlotID;
|
||||
@@ -1316,8 +1316,8 @@ void Client::FindAndNukeTraderItem(std::string &serial_number, int16 quantity, C
|
||||
return;
|
||||
}
|
||||
else {
|
||||
TraderRepository::UpdateQuantity(database, CharacterID(), item->GetSerialNumber2(), charges - quantity);
|
||||
NukeTraderItem(slot_id, charges, quantity, customer, trader_slot, item->GetSerialNumber2(), item->GetID());
|
||||
TraderRepository::UpdateQuantity(database, CharacterID(), item->GetUniqueID(), charges - quantity);
|
||||
NukeTraderItem(slot_id, charges, quantity, customer, trader_slot, item->GetUniqueID(), item->GetID());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1563,7 +1563,7 @@ void Client::BuyTraderItem(TraderBuy_Struct *tbs, Client *Trader, const EQApplic
|
||||
strn0cpy(outtbs->item_name, buy_item->GetItem()->Name, sizeof(outtbs->item_name));
|
||||
strn0cpy(
|
||||
outtbs->serial_number,
|
||||
buy_item->GetSerialNumber2().data(),
|
||||
buy_item->GetUniqueID().data(),
|
||||
sizeof(outtbs->serial_number)
|
||||
);
|
||||
|
||||
@@ -1690,7 +1690,7 @@ static void UpdateTraderCustomerItemsAdded(
|
||||
|
||||
inst->SetCharges(i.item_charges);
|
||||
inst->SetPrice(i.item_cost);
|
||||
inst->SetSerialNumber2(i.item_sn);
|
||||
inst->SetUniqueID(i.item_sn);
|
||||
//FIXinst->SetMerchantSlot(i.item_sn);
|
||||
if (inst->IsStackable()) {
|
||||
inst->SetMerchantCount(i.item_charges);
|
||||
@@ -1794,7 +1794,7 @@ static void UpdateTraderCustomerPriceChanged(
|
||||
continue;
|
||||
}
|
||||
|
||||
inst->SetSerialNumber2(trader_items.at(i).item_sn);
|
||||
inst->SetUniqueID(trader_items.at(i).item_sn);
|
||||
//inst->SetMerchantSlot(trader_items.at(i).item_sn);
|
||||
|
||||
LogTrading("Sending price update for [{}], Serial No. [{}] with [{}] charges",
|
||||
|
||||
+1
-1
@@ -354,7 +354,7 @@ std::unique_ptr<EQ::ItemInstance> ZoneDatabase::LoadSingleTraderItem(uint32 char
|
||||
}
|
||||
|
||||
inst->SetCharges(charges);
|
||||
inst->SetSerialNumber2(serial_number);
|
||||
inst->SetUniqueID(serial_number);
|
||||
//FIX inst->SetMerchantSlot(serial_number);
|
||||
inst->SetPrice(cost);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user