[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

@ -493,21 +493,25 @@ void Object::RandomSpawn(bool send_packet) {
bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object) bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
{ {
if(m_ground_spawn){//This is a Cool Groundspawn if(m_ground_spawn) {//This is a Cool Groundspawn
respawn_timer.Start(); respawn_timer.Start();
} }
if (m_type == OT_DROPPEDITEM) { if (m_type == OT_DROPPEDITEM) {
bool cursordelete = false; bool cursordelete = false;
bool duplicate_lore = false;
if (m_inst && sender) { if (m_inst && sender) {
// if there is a lore conflict, delete the offending item from the server inventory // 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 // the client updates itself and takes care of sending "duplicate lore item" messages
auto item = m_inst->GetItem(); auto item = m_inst->GetItem();
if(sender->CheckLoreConflict(item)) { if (sender->CheckLoreConflict(item)) {
duplicate_lore = true;
int16 loreslot = sender->GetInv().HasItem(item->ID, 0, invWhereBank); 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); sender->DeleteItemInInventory(loreslot);
else }
cursordelete = true; // otherwise, we delete the new one else {
cursordelete = true;
} // otherwise, we delete the new one
} }
if (item->RecastDelay) { if (item->RecastDelay) {
@ -560,8 +564,9 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
sender->DiscoverItem(item->ID); 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 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); sender->DeleteItemInInventory(EQ::invslot::slotCursor, 1, true);
}
sender->DropItemQS(m_inst, true); sender->DropItemQS(m_inst, true);
@ -581,8 +586,18 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
// Remove object // Remove object
content_db.DeleteObject(m_id); content_db.DeleteObject(m_id);
if(!m_ground_spawn) if (!m_ground_spawn) {
entity_list.RemoveEntity(GetID()); 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 { } else {
// Tradeskill item // Tradeskill item
auto outapp = new EQApplicationPacket(OP_ClickObjectAction, sizeof(ClickObjectAction_Struct)); auto outapp = new EQApplicationPacket(OP_ClickObjectAction, sizeof(ClickObjectAction_Struct));