aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Chat/Chat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Chat/Chat.cpp')
-rw-r--r--src/server/game/Chat/Chat.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 20468af0511..7518b80050d 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -42,27 +42,30 @@ static Optional<std::vector<ChatCommand>> commandTableCache;
std::vector<ChatCommand> const& ChatHandler::getCommandTable()
{
if (!commandTableCache)
- {
- // We need to initialize this at top since SetDataForCommandInTable
- // calls getCommandTable() recursively.
- commandTableCache = sScriptMgr->GetChatCommands();
+ InitializeCommandTable();
+
+ return *commandTableCache;
+}
+
+void ChatHandler::InitializeCommandTable()
+{
+ // We need to initialize this at top since SetDataForCommandInTable
+ // calls getCommandTable() recursively.
+ commandTableCache = sScriptMgr->GetChatCommands();
- WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_COMMANDS);
- PreparedQueryResult result = WorldDatabase.Query(stmt);
- if (result)
+ WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_COMMANDS);
+ PreparedQueryResult result = WorldDatabase.Query(stmt);
+ if (result)
+ {
+ do
{
- do
- {
- Field* fields = result->Fetch();
- std::string name = fields[0].GetString();
+ Field* fields = result->Fetch();
+ std::string name = fields[0].GetString();
- SetDataForCommandInTable(*commandTableCache, name.c_str(), fields[1].GetUInt16(), fields[2].GetString(), name);
- }
- while (result->NextRow());
+ SetDataForCommandInTable(*commandTableCache, name.c_str(), fields[1].GetUInt16(), fields[2].GetString(), name);
}
+ while (result->NextRow());
}
-
- return *commandTableCache;
}
void ChatHandler::invalidateCommandTable()