diff --git a/src/Transmogrification.cpp b/src/Transmogrification.cpp index 8f5631a4..4b773021 100644 --- a/src/Transmogrification.cpp +++ b/src/Transmogrification.cpp @@ -1247,6 +1247,29 @@ bool Transmogrification::IsPlusFeatureEligible(ObjectGuid const &playerGuid, uin return false; } +void Transmogrification::LoadCollections() +{ + if (sTransmogrification->GetUseCollectionSystem()) + { + LOG_INFO("module", "Loading transmog appearance collection cache...."); + uint32 collectedAppearanceCount = 0; + QueryResult result = CharacterDatabase.Query("SELECT account_id, item_template_id FROM custom_unlocked_appearances"); + if (result) + { + do + { + uint32 accountId = (*result)[0].Get(); + uint32 itemId = (*result)[1].Get(); + if (sTransmogrification->AddCollectedAppearance(accountId, itemId)) + collectedAppearanceCount++; + + } while (result->NextRow()); + } + + LOG_INFO("module", "Loaded {} collected appearances into cache", collectedAppearanceCount); + } +} + bool Transmogrification::GetEnableTransmogInfo() const { return EnableTransmogInfo; diff --git a/src/Transmogrification.h b/src/Transmogrification.h index 409e357e..ca516677 100644 --- a/src/Transmogrification.h +++ b/src/Transmogrification.h @@ -149,6 +149,7 @@ class Transmogrification void LoadPlayerSets(ObjectGuid pGUID); void UnloadPlayerSets(ObjectGuid pGUID); + void LoadCollections(); #endif bool EnableTransmogInfo; diff --git a/src/cs_transmog.cpp b/src/cs_transmog.cpp index fbd72629..d578bbbe 100644 --- a/src/cs_transmog.cpp +++ b/src/cs_transmog.cpp @@ -41,11 +41,12 @@ class transmog_commandscript : public CommandScript static ChatCommandTable transmogTable = { - { "add", addCollectionTable }, - { "", HandleDisableTransMogVisual, SEC_PLAYER, Console::No }, - { "sync", HandleSyncTransMogCommand, SEC_PLAYER, Console::No }, - { "portable", HandleTransmogPortableCommand, SEC_PLAYER, Console::No }, - { "interface", HandleInterfaceOption, SEC_PLAYER, Console::No } + { "add", addCollectionTable }, + { "", HandleDisableTransMogVisual, SEC_PLAYER, Console::No }, + { "sync", HandleSyncTransMogCommand, SEC_PLAYER, Console::No }, + { "portable", HandleTransmogPortableCommand, SEC_PLAYER, Console::No }, + { "interface", HandleInterfaceOption, SEC_PLAYER, Console::No }, + { "reload", HandleReloadTransmogConfig, SEC_ADMINISTRATOR, Console::Yes} }; static ChatCommandTable commandTable = @@ -315,6 +316,15 @@ class transmog_commandscript : public CommandScript handler->SendSysMessage(enable ? LANG_CMD_TRANSMOG_VENDOR_INTERFACE_ENABLE : LANG_CMD_TRANSMOG_VENDOR_INTERFACE_DISABLE); return true; } + + static bool HandleReloadTransmogConfig(ChatHandler* handler) + { + sTransmogrification->LoadConfig(true); + handler->SendSysMessage("Transmog configs reloaded."); + sTransmogrification->LoadCollections(); + handler->SendSysMessage("Transmog collections reloaded."); + return true; + } }; void AddSC_transmog_commandscript() diff --git a/src/transmog_scripts.cpp b/src/transmog_scripts.cpp index 451327e0..8d8c18bc 100644 --- a/src/transmog_scripts.cpp +++ b/src/transmog_scripts.cpp @@ -1222,26 +1222,8 @@ class WS_Transmogrification : public WorldScript void OnAfterConfigLoad(bool reload) override { - sT->LoadConfig(reload); - if (sT->GetUseCollectionSystem()) - { - LOG_INFO("module", "Loading transmog appearance collection cache...."); - uint32 collectedAppearanceCount = 0; - QueryResult result = CharacterDatabase.Query("SELECT account_id, item_template_id FROM custom_unlocked_appearances"); - if (result) - { - do - { - uint32 accountId = (*result)[0].Get(); - uint32 itemId = (*result)[1].Get(); - if (sT->AddCollectedAppearance(accountId, itemId)) - { - collectedAppearanceCount++; - } - } while (result->NextRow()); - } - LOG_INFO("module", "Loaded {} collected appearances into cache", collectedAppearanceCount); - } + if (!reload) + sT->LoadCollections(); } void OnStartup() override