[Fix] Fix issue where Lore groundspawn pickups will desync ROF2+ (#2929)

* [Fix] Fix issue where Lore groundspawn pickups will desync ROF2+

* Update object.cpp
This commit is contained in:
Chris Miles 2023-02-14 04:36:22 -06:00 committed by GitHub
parent ccf8504dec
commit 665e336946
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -498,16 +498,20 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
}
if (m_type == OT_DROPPEDITEM) {
bool cursordelete = false;
bool duplicate_lore = false;
if (m_inst && sender) {
// if there is a lore conflict, delete the offending item from the server inventory
// the client updates itself and takes care of sending "duplicate lore item" messages
auto item = m_inst->GetItem();
if (sender->CheckLoreConflict(item)) {
duplicate_lore = true;
int16 loreslot = sender->GetInv().HasItem(item->ID, 0, invWhereBank);
if (loreslot != INVALID_INDEX) // if the duplicate is in the bank, delete it.
if (loreslot != INVALID_INDEX) { // if the duplicate is in the bank, delete it.
sender->DeleteItemInInventory(loreslot);
else
cursordelete = true; // otherwise, we delete the new one
}
else {
cursordelete = true;
} // otherwise, we delete the new one
}
if (item->RecastDelay) {
@ -560,8 +564,9 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
sender->DiscoverItem(item->ID);
}
if(cursordelete) // delete the item if it's a duplicate lore. We have to do this because the client expects the item packet
sender->DeleteItemInInventory(EQ::invslot::slotCursor);
if (cursordelete) { // delete the item if it's a duplicate lore. We have to do this because the client expects the item packet
sender->DeleteItemInInventory(EQ::invslot::slotCursor, 1, true);
}
sender->DropItemQS(m_inst, true);
@ -581,8 +586,18 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
// Remove object
content_db.DeleteObject(m_id);
if(!m_ground_spawn)
if (!m_ground_spawn) {
entity_list.RemoveEntity(GetID());
}
// we have to delete the entity on click or the client desyncs
// this is a way to immediately respawn the groundspawn after killing it and
// deleting the item from the player
// I believe older clients somehow sent this automatically but we are no longer with ROF2+
if (duplicate_lore) {
sender->Message(Chat::Yellow, "Duplicate lore item detected");
respawn_timer.Trigger();
}
} else {
// Tradeskill item
auto outapp = new EQApplicationPacket(OP_ClickObjectAction, sizeof(ClickObjectAction_Struct));