diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 08bb0103f..13ae065be 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -747,6 +747,18 @@ std::map SharedDatabase::GetItemRecastTimestamps(uint32 char_id) return timers; // RVO or move assigned } +uint32 SharedDatabase::GetItemRecastTimestamp(uint32 char_id, uint32 recast_type) +{ + std::string query = StringFormat("SELECT timestamp FROM character_item_recast WHERE id=%u AND recast_type=%u", + char_id, recast_type); + auto results = QueryDatabase(query); + if (!results.Success() || results.RowCount() == 0) + return 0; + + auto row = results.begin(); + return static_cast(atoul(row[0])); +} + void SharedDatabase::ClearOldRecastTimestamps(uint32 char_id) { // This actually isn't strictly live-like. Live your recast timestamps are forever diff --git a/common/shareddb.h b/common/shareddb.h index 99eba666a..aef325380 100644 --- a/common/shareddb.h +++ b/common/shareddb.h @@ -71,6 +71,7 @@ class SharedDatabase : public Database bool GetInventory(uint32 char_id, Inventory* inv); bool GetInventory(uint32 account_id, char* name, Inventory* inv); std::map GetItemRecastTimestamps(uint32 char_id); + uint32 GetItemRecastTimestamp(uint32 char_id, uint32 recast_type); void ClearOldRecastTimestamps(uint32 char_id); bool SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin); diff --git a/zone/object.cpp b/zone/object.cpp index 38f4c67c4..7dd97d355 100644 --- a/zone/object.cpp +++ b/zone/object.cpp @@ -467,16 +467,21 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object) 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 - if(sender->CheckLoreConflict(m_inst->GetItem())) { - int16 loreslot = sender->GetInv().HasItem(m_inst->GetItem()->ID, 0, invWhereBank); + auto item = m_inst->GetItem(); + if(sender->CheckLoreConflict(item)) { + int16 loreslot = sender->GetInv().HasItem(item->ID, 0, invWhereBank); 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 } + if (item->RecastDelay) + m_inst->SetRecastTimestamp( + database.GetItemRecastTimestamp(sender->CharacterID(), item->RecastType)); + char buf[10]; - snprintf(buf, 9, "%u", m_inst->GetItem()->ID); + snprintf(buf, 9, "%u", item->ID); buf[9] = '\0'; std::vector args; args.push_back(m_inst);