AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
MotdMgr Class Reference

#include "MotdMgr.h"

Public Member Functions

void SetMotd (std::string motd)
 Set a new Message of the Day.
 
void LoadMotd ()
 Load Message of the Day.
 
char const * GetMotd ()
 Get the current Message of the Day.
 
WorldPacket const * GetMotdPacket ()
 Get the motd packet to send at login.
 

Static Public Member Functions

static MotdMgrinstance ()
 

Detailed Description

Member Function Documentation

◆ GetMotd()

char const * MotdMgr::GetMotd ( )

Get the current Message of the Day.

98{
99 return FormattedMotd.c_str();
100}
std::string FormattedMotd
Definition: MotdMgr.cpp:31

◆ GetMotdPacket()

WorldPacket const * MotdMgr::GetMotdPacket ( )

Get the motd packet to send at login.

103{
104 return &MotdPacket;
105}
WorldPacket MotdPacket
Definition: MotdMgr.cpp:30

◆ instance()

MotdMgr * MotdMgr::instance ( )
static
35{
36 static MotdMgr instance;
37 return &instance;
38}
Definition: MotdMgr.h:27
static MotdMgr * instance()
Definition: MotdMgr.cpp:34

References instance().

Referenced by instance().

◆ LoadMotd()

void MotdMgr::LoadMotd ( )

Load Message of the Day.

65{
66 uint32 oldMSTime = getMSTime();
67
68 uint32 realmId = sConfigMgr->GetOption<int32>("RealmID", 0);
70 stmt->SetData(0, realmId);
71 PreparedQueryResult result = LoginDatabase.Query(stmt);
72 std::string motd;
73
74 if (result)
75 {
76 Field* fields = result->Fetch();
77 motd = fields[0].Get<std::string>();
78 }
79 else
80 {
81 LOG_WARN("server.loading", ">> Loaded 0 motd definitions. DB table `motd` is empty for this realm!");
82 LOG_INFO("server.loading", " ");
83 }
84
85 motd = /* fctlsup << //0x338// "63"+"cx""d2"+"1e""dd"+"cx""ds"+"ce""dd"+"ce""7D"+ << */ motd
86 /*"d3"+"ce"*/ + "@|" + "cf" +/*"as"+"k4"*/"fF" + "F4" +/*"d5"+"f3"*/"A2" + "DT"/*"F4"+"Az"*/ + "hi" + "s "
87 /*"fd"+"hy"*/ + "se" + "rv" +/*"nh"+"k3"*/"er" + " r" +/*"x1"+"A2"*/"un" + "s "/*"F2"+"Ay"*/ + "on" + " Az"
88 /*"xs"+"5n"*/ + "er" + "ot" +/*"xs"+"A2"*/"hC" + "or" +/*"a4"+"f3"*/"e|" + "r "/*"f2"+"A2"*/ + "|c" + "ff"
89 /*"5g"+"A2"*/ + "3C" + "E7" +/*"k5"+"AX"*/"FF" + "ww" +/*"sx"+"Gj"*/"w." + "az"/*"a1"+"vf"*/ + "er" + "ot"
90 /*"ds"+"sx"*/ + "hc" + "or" +/*"F4"+"k5"*/"e." + "or" +/*"po"+"xs"*/"g|r"/*"F4"+"p2"+"o4"+"A2"+"i2"*/;;
91 MotdMgr::SetMotd(motd);
92
93 LOG_INFO("server.loading", ">> Loaded Motd Definitions in {} ms", GetMSTimeDiffToNow(oldMSTime));
94 LOG_INFO("server.loading", " ");
95}
#define sConfigMgr
Definition: Config.h:95
std::int32_t int32
Definition: Define.h:104
std::uint32_t uint32
Definition: Define.h:108
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ LOGIN_SEL_MOTD
Definition: LoginDatabase.h:99
Definition: PreparedStatement.h:158
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
void SetMotd(std::string motd)
Set a new Message of the Day.
Definition: MotdMgr.cpp:40

References Field::Get(), getMSTime(), GetMSTimeDiffToNow(), LOG_INFO, LOG_WARN, LOGIN_SEL_MOTD, LoginDatabase, sConfigMgr, and SetMotd().

◆ SetMotd()

void MotdMgr::SetMotd ( std::string  motd)

Set a new Message of the Day.

41{
42 // scripts may change motd
43 sScriptMgr->OnMotdChange(motd);
44
45 WorldPacket data(SMSG_MOTD); // new in 2.0.1
46
47 std::vector<std::string_view> motdTokens = Acore::Tokenize(motd, '@', true);
48 data << uint32(motdTokens.size()); // line count
49
50 for (std::string_view token : motdTokens)
51 data << token;
52
53 MotdPacket = data;
54
55 if (!motdTokens.size())
56 return;
57
58 std::ostringstream oss;
59 std::copy(motdTokens.begin(), motdTokens.end() - 1, std::ostream_iterator<std::string_view>(oss, "\n"));
60 oss << *(motdTokens.end() - 1); // copy back element
61 FormattedMotd = oss.str();
62}
#define sScriptMgr
Definition: ScriptMgr.h:698
@ SMSG_MOTD
Definition: Opcodes.h:859
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition: Tokenize.cpp:20
Definition: WorldPacket.h:27

References SMSG_MOTD, sScriptMgr, and Acore::Tokenize().

Referenced by LoadMotd().