diff --git a/common/database.cpp b/common/database.cpp index 3052fd722..63982568b 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -2288,3 +2288,22 @@ uint64_t Database::GetNextTableId(const std::string &table_name) return 1; } + +void Database::ConvertInventoryToNewUniqueId() +{ + LogInfo("Converting inventory entries with NULL item_unique_id"); + auto results = InventoryRepository::GetWhere(*this, "`item_unique_id` IS NULL"); + + if (results.empty()) { + return; + } + + TransactionBegin(); + for (auto &r: results) { + r.item_unique_id = EQ::UniqueHashGenerator::generate(); + } + + InventoryRepository::ReplaceMany(*this, results); + TransactionCommit(); + LogInfo("Converted {} records", results.size()); +} \ No newline at end of file diff --git a/common/database.h b/common/database.h index 9b81f66a0..3a372eec9 100644 --- a/common/database.h +++ b/common/database.h @@ -278,6 +278,7 @@ public: void Decode(std::string &in); uint64_t GetNextTableId(const std::string& table_name); + void ConvertInventoryToNewUniqueId(); private: Mutex Mvarcache; diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 95ff53cdc..26f7a38f7 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -717,6 +717,8 @@ bool SharedDatabase::GetInventory(Client *c) inst->SetOrnamentationIDFile(ornament_idfile); inst->SetOrnamentHeroModel(item->HerosForgeModel); + //Mass conversion handled by world + //This remains as a backup. Should not be required. if (row.item_unique_id.empty()) { inst->CreateUniqueID(); row.item_unique_id = inst->GetUniqueID(); diff --git a/loginserver/main.cpp b/loginserver/main.cpp index 9047db8c8..a3181a0b7 100644 --- a/loginserver/main.cpp +++ b/loginserver/main.cpp @@ -15,6 +15,9 @@ #include "../common/database.h" #include "../common/events/player_event_logs.h" #include "../common/zone_store.h" +#include "../common/evolving_items.h" +#include "../common/content/world_content_service.h" + #include #include #include diff --git a/world/world_boot.cpp b/world/world_boot.cpp index 19667927c..ee13ab7a3 100644 --- a/world/world_boot.cpp +++ b/world/world_boot.cpp @@ -295,6 +295,8 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv) database.ClearBuyerDetails(); LogInfo("Clearing buyer table details"); + database.ConvertInventoryToNewUniqueId(); + if (RuleB(Bots, Enabled)) { LogInfo("Clearing [bot_pet_buffs] table of stale entries"); database.QueryDatabase(