#include "MotdMgr.h"
◆ CreateWorldPacket()
WorldPacket MotdMgr::CreateWorldPacket |
( |
std::string |
motd | ) |
|
|
private |
144{
145
147
148 motd = motd
149 + "@|" + "cf" +"fF" + "F4" +"A2" + "DT" + "hi" + "s "
150 + "se" + "rv" +"er" + " r" +"un" + "s " + "on" + " Az"
151 + "er" + "ot" +"hC" + "or" +"e|" + "r " + "|c" + "ff"
152 + "3C" + "E7" +"FF" + "ww" +"w." + "az" + "er" + "ot"
153 + "hc" + "or" +"e." + "or" +"g|r";
154
155
156 std::vector<std::string_view> motdTokens =
Acore::Tokenize(motd,
'@',
true);
157 data <<
uint32(motdTokens.size());
158
159 for (std::string_view token : motdTokens)
160 data << token;
161
162 return data;
163}
std::uint32_t uint32
Definition Define.h:107
Definition WorldPacket.h:26
@ SMSG_MOTD
Definition Opcodes.h:859
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition Tokenize.cpp:20
References SMSG_MOTD, and Acore::Tokenize().
Referenced by SetMotd().
◆ GetMotd()
Get the current Message of the Day.
124{
125
126 auto it = MotdMap.find(locale);
127 if (it != MotdMap.end())
128 return it->second.c_str();
129
131}
@ LOCALE_enUS
Definition Common.h:66
References LOCALE_enUS.
◆ GetMotdPacket()
Returns the current motd packet for the given locale.
134{
135
136 auto it = MotdPackets.find(locale);
137 if (it != MotdPackets.end())
138 return &it->second;
139
141}
References LOCALE_enUS.
◆ instance()
37{
40}
static MotdMgr * instance()
Definition MotdMgr.cpp:36
References instance().
Referenced by instance().
◆ LoadMotd()
void MotdMgr::LoadMotd |
( |
| ) |
|
Load Message of the Day.
52{
54
59
60 if (result)
61 {
62 Field* fields = result->Fetch();
63 std::string motd = fields[0].
Get<std::string>();
64
66
68 }
69 else
70 {
71 LOG_INFO(
"server.loading",
">> Loaded 0 motd definitions. DB table `motd` is empty for this realm!");
72 LOG_INFO(
"server.loading",
">> Loaded 0 motd locale definitions. DB table `motd` needs an entry to be able to load DB table `motd_locale`!");
74 }
75
78}
#define sConfigMgr
Definition Config.h:74
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition DatabaseEnv.cpp:22
std::int32_t int32
Definition Define.h:103
#define LOG_INFO(filterType__,...)
Definition Log.h:165
@ LOGIN_SEL_MOTD
Definition LoginDatabase.h:101
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
void LoadMotdLocale()
Definition MotdMgr.cpp:80
void SetMotd(std::string motd, LocaleConstant locale)
Set a new Message of the Day.
Definition MotdMgr.cpp:42
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
References Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LoadMotdLocale(), LOCALE_enUS, LOG_INFO, LOGIN_SEL_MOTD, LoginDatabase, sConfigMgr, PreparedStatementBase::SetData(), and SetMotd().
◆ LoadMotdLocale()
void MotdMgr::LoadMotdLocale |
( |
| ) |
|
|
private |
81{
84 LOG_INFO(
"server.loading",
"Loading Motd locale...");
85
90
91 if (result)
92 {
93 do
94 {
95 Field* fields = result->Fetch();
96
97 std::string locale = fields[0].
Get<std::string>();
98 std::string localizedText = fields[1].
Get<std::string>();
99
101 {
102 LOG_ERROR(
"server.loading",
"DB table `motd_localized` has invalid locale ({}), skipped.", locale);
103 continue;
104 }
105
108 continue;
109
110 SetMotd(localizedText, localeId);
111 ++count;
112 } while (result->NextRow());
113 }
114 else
115 {
116 LOG_INFO(
"server.loading",
">> Loaded 0 motd locale definitions. DB table `motd_localized` is empty for this realm!");
118 }
119
121}
LocaleConstant GetLocaleByName(const std::string &name)
Definition Common.cpp:42
bool IsLocaleValid(std::string const &locale)
Definition Common.cpp:33
LocaleConstant
Definition Common.h:65
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
@ LOGIN_SEL_MOTD_LOCALE
Definition LoginDatabase.h:102
References Field::Get(), GetLocaleByName(), getMSTime(), GetMSTimeDiffToNow(), IsLocaleValid(), LOCALE_enUS, LOG_ERROR, LOG_INFO, LOGIN_SEL_MOTD_LOCALE, LoginDatabase, sConfigMgr, PreparedStatementBase::SetData(), and SetMotd().
Referenced by LoadMotd().
◆ SetMotd()
Set a new Message of the Day.
43{
44
46
47 MotdMap[locale] = motd;
49}
#define sScriptMgr
Definition ScriptMgr.h:727
WorldPacket CreateWorldPacket(std::string motd)
Definition MotdMgr.cpp:143
References CreateWorldPacket(), and sScriptMgr.
Referenced by LoadMotd(), and LoadMotdLocale().
The documentation for this class was generated from the following files: