Move conversion to world

This commit is contained in:
Mitch Freeman 2025-04-25 23:34:18 -03:00
parent d87d1dfb1d
commit 3c4cc74a54
5 changed files with 27 additions and 0 deletions

View File

@ -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());
}

View File

@ -278,6 +278,7 @@ public:
void Decode(std::string &in);
uint64_t GetNextTableId(const std::string& table_name);
void ConvertInventoryToNewUniqueId();
private:
Mutex Mvarcache;

View File

@ -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();

View File

@ -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 <time.h>
#include <stdlib.h>
#include <string>

View File

@ -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(