Skip to content

Commit 01c40bc

Browse files
authored
feat: move collections away from worldserver config reload (#219)
1 parent 949cdfb commit 01c40bc

File tree

4 files changed

+41
-25
lines changed

4 files changed

+41
-25
lines changed

src/Transmogrification.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,29 @@ bool Transmogrification::IsPlusFeatureEligible(ObjectGuid const &playerGuid, uin
12471247
return false;
12481248
}
12491249

1250+
void Transmogrification::LoadCollections()
1251+
{
1252+
if (sTransmogrification->GetUseCollectionSystem())
1253+
{
1254+
LOG_INFO("module", "Loading transmog appearance collection cache....");
1255+
uint32 collectedAppearanceCount = 0;
1256+
QueryResult result = CharacterDatabase.Query("SELECT account_id, item_template_id FROM custom_unlocked_appearances");
1257+
if (result)
1258+
{
1259+
do
1260+
{
1261+
uint32 accountId = (*result)[0].Get<uint32>();
1262+
uint32 itemId = (*result)[1].Get<uint32>();
1263+
if (sTransmogrification->AddCollectedAppearance(accountId, itemId))
1264+
collectedAppearanceCount++;
1265+
1266+
} while (result->NextRow());
1267+
}
1268+
1269+
LOG_INFO("module", "Loaded {} collected appearances into cache", collectedAppearanceCount);
1270+
}
1271+
}
1272+
12501273
bool Transmogrification::GetEnableTransmogInfo() const
12511274
{
12521275
return EnableTransmogInfo;

src/Transmogrification.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class Transmogrification
149149

150150
void LoadPlayerSets(ObjectGuid pGUID);
151151
void UnloadPlayerSets(ObjectGuid pGUID);
152+
void LoadCollections();
152153
#endif
153154

154155
bool EnableTransmogInfo;

src/cs_transmog.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ class transmog_commandscript : public CommandScript
4141

4242
static ChatCommandTable transmogTable =
4343
{
44-
{ "add", addCollectionTable },
45-
{ "", HandleDisableTransMogVisual, SEC_PLAYER, Console::No },
46-
{ "sync", HandleSyncTransMogCommand, SEC_PLAYER, Console::No },
47-
{ "portable", HandleTransmogPortableCommand, SEC_PLAYER, Console::No },
48-
{ "interface", HandleInterfaceOption, SEC_PLAYER, Console::No }
44+
{ "add", addCollectionTable },
45+
{ "", HandleDisableTransMogVisual, SEC_PLAYER, Console::No },
46+
{ "sync", HandleSyncTransMogCommand, SEC_PLAYER, Console::No },
47+
{ "portable", HandleTransmogPortableCommand, SEC_PLAYER, Console::No },
48+
{ "interface", HandleInterfaceOption, SEC_PLAYER, Console::No },
49+
{ "reload", HandleReloadTransmogConfig, SEC_ADMINISTRATOR, Console::Yes}
4950
};
5051

5152
static ChatCommandTable commandTable =
@@ -315,6 +316,15 @@ class transmog_commandscript : public CommandScript
315316
handler->SendSysMessage(enable ? LANG_CMD_TRANSMOG_VENDOR_INTERFACE_ENABLE : LANG_CMD_TRANSMOG_VENDOR_INTERFACE_DISABLE);
316317
return true;
317318
}
319+
320+
static bool HandleReloadTransmogConfig(ChatHandler* handler)
321+
{
322+
sTransmogrification->LoadConfig(true);
323+
handler->SendSysMessage("Transmog configs reloaded.");
324+
sTransmogrification->LoadCollections();
325+
handler->SendSysMessage("Transmog collections reloaded.");
326+
return true;
327+
}
318328
};
319329

320330
void AddSC_transmog_commandscript()

src/transmog_scripts.cpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,26 +1222,8 @@ class WS_Transmogrification : public WorldScript
12221222

12231223
void OnAfterConfigLoad(bool reload) override
12241224
{
1225-
sT->LoadConfig(reload);
1226-
if (sT->GetUseCollectionSystem())
1227-
{
1228-
LOG_INFO("module", "Loading transmog appearance collection cache....");
1229-
uint32 collectedAppearanceCount = 0;
1230-
QueryResult result = CharacterDatabase.Query("SELECT account_id, item_template_id FROM custom_unlocked_appearances");
1231-
if (result)
1232-
{
1233-
do
1234-
{
1235-
uint32 accountId = (*result)[0].Get<uint32>();
1236-
uint32 itemId = (*result)[1].Get<uint32>();
1237-
if (sT->AddCollectedAppearance(accountId, itemId))
1238-
{
1239-
collectedAppearanceCount++;
1240-
}
1241-
} while (result->NextRow());
1242-
}
1243-
LOG_INFO("module", "Loaded {} collected appearances into cache", collectedAppearanceCount);
1244-
}
1225+
if (!reload)
1226+
sT->LoadCollections();
12451227
}
12461228

12471229
void OnStartup() override

0 commit comments

Comments
 (0)