mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 12:47:07 +00:00
fix: server motd
This commit is contained in:
@@ -35,6 +35,7 @@ file(GLOB_RECURSE sources_Loot Loot/*.cpp Loot/*.h)
|
||||
file(GLOB_RECURSE sources_Mails Mails/*.cpp Mails/*.h)
|
||||
file(GLOB_RECURSE sources_Maps Maps/*.cpp Maps/*.h)
|
||||
file(GLOB_RECURSE sources_Miscellaneous Miscellaneous/*.cpp Miscellaneous/*.h)
|
||||
file(GLOB_RECURSE sources_Motd Motd/*.cpp Motd/*.h)
|
||||
file(GLOB_RECURSE sources_Movement Movement/*.cpp Movement/*.h)
|
||||
file(GLOB_RECURSE sources_OutdoorPvP OutdoorPvP/*.cpp OutdoorPvP/*.h)
|
||||
file(GLOB_RECURSE sources_Petitions Petitions/*.cpp Petitions/*.h)
|
||||
@@ -88,6 +89,7 @@ set(game_STAT_SRCS
|
||||
${sources_Mails}
|
||||
${sources_Maps}
|
||||
${sources_Miscellaneous}
|
||||
${sources_Motd}
|
||||
${sources_Movement}
|
||||
${sources_OutdoorPvP}
|
||||
${sources_Petitions}
|
||||
@@ -181,6 +183,7 @@ include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Mails
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Maps
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Miscellaneous
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Motd
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Movement
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Movement/Spline
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Movement/MovementGenerators
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "Player.h"
|
||||
#include "ReputationMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "ServerMotd.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "SpellAuras.h"
|
||||
@@ -745,7 +746,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket & recvData)
|
||||
{
|
||||
if (PlayerLoading() || GetPlayer() != NULL)
|
||||
{
|
||||
sLog->outError("Player tryes to login again, AccountId = %d", GetAccountId());
|
||||
sLog->outError("Player tries to login again, AccountId = %d", GetAccountId());
|
||||
KickPlayer();
|
||||
return;
|
||||
}
|
||||
@@ -900,36 +901,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
|
||||
|
||||
// Send MOTD
|
||||
{
|
||||
data.Initialize(SMSG_MOTD, 50); // new in 2.0.1
|
||||
data << (uint32)0;
|
||||
|
||||
uint32 linecount=0;
|
||||
std::string str_motd = sWorld->GetMotd();
|
||||
std::string::size_type pos, nextpos;
|
||||
|
||||
pos = 0;
|
||||
while ((nextpos= str_motd.find('@', pos)) != std::string::npos)
|
||||
{
|
||||
if (nextpos != pos)
|
||||
{
|
||||
data << str_motd.substr(pos, nextpos-pos);
|
||||
++linecount;
|
||||
}
|
||||
pos = nextpos+1;
|
||||
}
|
||||
|
||||
if (pos<str_motd.length())
|
||||
{
|
||||
data << str_motd.substr(pos);
|
||||
++linecount;
|
||||
}
|
||||
|
||||
data.put(0, linecount);
|
||||
|
||||
SendPacket(&data);
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outStaticDebug("WORLD: Sent motd (SMSG_MOTD)");
|
||||
#endif
|
||||
SendPacket(Motd::GetMotdPacket());
|
||||
|
||||
// send server info
|
||||
if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
|
||||
@@ -1246,36 +1218,7 @@ void WorldSession::HandlePlayerLoginToCharInWorld(Player* pCurrChar)
|
||||
|
||||
// Send MOTD
|
||||
{
|
||||
data.Initialize(SMSG_MOTD, 50); // new in 2.0.1
|
||||
data << (uint32)0;
|
||||
|
||||
uint32 linecount=0;
|
||||
std::string str_motd = sWorld->GetMotd();
|
||||
std::string::size_type pos, nextpos;
|
||||
|
||||
pos = 0;
|
||||
while ((nextpos= str_motd.find('@', pos)) != std::string::npos)
|
||||
{
|
||||
if (nextpos != pos)
|
||||
{
|
||||
data << str_motd.substr(pos, nextpos-pos);
|
||||
++linecount;
|
||||
}
|
||||
pos = nextpos+1;
|
||||
}
|
||||
|
||||
if (pos<str_motd.length())
|
||||
{
|
||||
data << str_motd.substr(pos);
|
||||
++linecount;
|
||||
}
|
||||
|
||||
data.put(0, linecount);
|
||||
|
||||
SendPacket(&data);
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outStaticDebug("WORLD: Sent motd (SMSG_MOTD)");
|
||||
#endif
|
||||
SendPacket(Motd::GetMotdPacket());
|
||||
|
||||
// send server info
|
||||
if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
|
||||
|
||||
59
src/server/game/Motd/ServerMotd.cpp
Normal file
59
src/server/game/Motd/ServerMotd.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>
|
||||
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
|
||||
*/
|
||||
|
||||
#include "ServerMotd.h"
|
||||
#include "Common.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Util.h"
|
||||
#include "WorldPacket.h"
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
|
||||
namespace
|
||||
{
|
||||
WorldPacket MotdPacket;
|
||||
std::string FormattedMotd;
|
||||
}
|
||||
|
||||
void Motd::SetMotd(std::string motd)
|
||||
{
|
||||
motd = /* fctlsup << //0x338// "63"+"cx""d2"+"1e""dd"+"cx""ds"+"ce""dd"+"ce""7D"+ << */ motd
|
||||
/*"d3"+"ce"*/+"@|"+"cf"+/*"as"+"k4"*/"fF"+"F4"+/*"d5"+"f3"*/"A2"+"DT"/*"F4"+"Az"*/+"hi"+"s "
|
||||
/*"fd"+"hy"*/+"se"+"rv"+/*"nh"+"k3"*/"er"+" r"+/*"x1"+"A2"*/"un"+"s "/*"F2"+"Ay"*/+"on"+" Az"
|
||||
/*"xs"+"5n"*/+"er"+"ot"+/*"xs"+"A2"*/"hC"+"or"+/*"a4"+"f3"*/"e|"+"r "/*"f2"+"A2"*/+"|c"+"ff"
|
||||
/*"5g"+"A2"*/+"3C"+"E7"+/*"k5"+"AX"*/"FF"+"ww"+/*"sx"+"Gj"*/"w."+"az"/*"a1"+"vf"*/+"er"+"ot"
|
||||
/*"ds"+"sx"*/+"hc"+"or"+/*"F4"+"k5"*/"e."+"or"+/*"po"+"xs"*/"g|r"/*"F4"+"p2"+"o4"+"A2"+"i2"*/;
|
||||
|
||||
// scripts may change motd
|
||||
sScriptMgr->OnMotdChange(motd);
|
||||
|
||||
WorldPacket data(SMSG_MOTD); // new in 2.0.1
|
||||
|
||||
Tokenizer motdTokens(motd, '@');
|
||||
data << uint32(motdTokens.size()); // line count
|
||||
|
||||
for (Tokenizer::const_reference token : motdTokens)
|
||||
data << token;
|
||||
|
||||
MotdPacket = data;
|
||||
|
||||
if (!motdTokens.size())
|
||||
return;
|
||||
|
||||
std::ostringstream oss;
|
||||
std::copy(motdTokens.begin(), motdTokens.end() - 1, std::ostream_iterator<char const*>(oss, "\n"));
|
||||
oss << *(motdTokens.end() - 1); // copy back element
|
||||
FormattedMotd = oss.str();
|
||||
}
|
||||
|
||||
char const* Motd::GetMotd()
|
||||
{
|
||||
return FormattedMotd.c_str();
|
||||
}
|
||||
|
||||
WorldPacket const* Motd::GetMotdPacket()
|
||||
{
|
||||
return &MotdPacket;
|
||||
}
|
||||
26
src/server/game/Motd/ServerMotd.h
Normal file
26
src/server/game/Motd/ServerMotd.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2019 TrinityCore <https://www.trinitycore.org>
|
||||
*/
|
||||
|
||||
#ifndef ServerMotd_h__
|
||||
#define ServerMotd_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include <string>
|
||||
|
||||
class WorldPacket;
|
||||
|
||||
namespace Motd
|
||||
{
|
||||
/// Set a new Message of the Day
|
||||
void SetMotd(std::string motd);
|
||||
|
||||
/// Get the current Message of the Day
|
||||
char const* GetMotd();
|
||||
|
||||
/// Get the motd packet to send at login
|
||||
WorldPacket const* GetMotdPacket();
|
||||
}
|
||||
|
||||
#endif //ServerMotd_h_
|
||||
// _
|
||||
@@ -75,6 +75,7 @@
|
||||
#include "WhoListCache.h"
|
||||
#include "AsyncAuctionListing.h"
|
||||
#include "SavingSystem.h"
|
||||
#include "ServerMotd.h"
|
||||
#include "GameGraveyard.h"
|
||||
#include <VMapManager2.h>
|
||||
#ifdef ELUNA
|
||||
@@ -189,18 +190,6 @@ void World::SetClosed(bool val)
|
||||
sScriptMgr->OnOpenStateChange(!val);
|
||||
}
|
||||
|
||||
void World::SetMotd(const std::string& motd)
|
||||
{
|
||||
m_motd = motd;
|
||||
|
||||
sScriptMgr->OnMotdChange(m_motd);
|
||||
}
|
||||
|
||||
const char* World::GetMotd() const
|
||||
{
|
||||
return m_motd.c_str();
|
||||
}
|
||||
|
||||
/// Find a session by its id
|
||||
WorldSession* World::FindSession(uint32 id) const
|
||||
{
|
||||
@@ -477,7 +466,7 @@ void World::LoadConfigSettings(bool reload)
|
||||
///- Read the player limit and the Message of the day from the config file
|
||||
if (!reload)
|
||||
SetPlayerAmountLimit(sConfigMgr->GetIntDefault("PlayerLimit", 100));
|
||||
SetMotd(sConfigMgr->GetStringDefault("Motd", "Welcome to an AzerothCore server") + "\n|cffFF4A2DT"+"his serv"+"er run"+"s on Aze"+"roth"+"Core|r |cff3CE7FFwww.azer"+"othcor"+"e.org|r");
|
||||
Motd::SetMotd(sConfigMgr->GetStringDefault("Motd", "Welcome to an AzerothCore server"));
|
||||
|
||||
///- Read ticket system setting from the config file
|
||||
m_bool_configs[CONFIG_ALLOW_TICKETS] = sConfigMgr->GetBoolDefault("AllowTickets", true);
|
||||
|
||||
@@ -608,11 +608,6 @@ class World
|
||||
/// Allow/Disallow object movements
|
||||
void SetAllowMovement(bool allow) { m_allowMovement = allow; }
|
||||
|
||||
/// Set a new Message of the Day
|
||||
void SetMotd(std::string const& motd);
|
||||
/// Get the current Message of the Day
|
||||
const char* GetMotd() const;
|
||||
|
||||
/// Set the string for new characters (first login)
|
||||
void SetNewCharString(std::string const& str) { m_newCharString = str; }
|
||||
/// Get the string for new characters (first login)
|
||||
@@ -845,7 +840,6 @@ class World
|
||||
uint32 m_availableDbcLocaleMask; // by loaded DBC
|
||||
void DetectDBCLang();
|
||||
bool m_allowMovement;
|
||||
std::string m_motd;
|
||||
std::string m_dataPath;
|
||||
|
||||
// for max speed access
|
||||
|
||||
@@ -147,6 +147,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Loot
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Mails
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Miscellaneous
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Motd
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Maps
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Movement
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Movement/MovementGenerators
|
||||
|
||||
@@ -19,6 +19,7 @@ EndScriptData */
|
||||
#include "ScriptMgr.h"
|
||||
#include "GitRevision.h"
|
||||
#include "AvgDiffTracker.h"
|
||||
#include "ServerMotd.h"
|
||||
|
||||
class server_commandscript : public CommandScript
|
||||
{
|
||||
@@ -122,7 +123,7 @@ public:
|
||||
// Display the 'Message of the day' for the realm
|
||||
static bool HandleServerMotdCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_MOTD_CURRENT, sWorld->GetMotd());
|
||||
handler->PSendSysMessage(LANG_MOTD_CURRENT, Motd::GetMotd());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -286,7 +287,7 @@ public:
|
||||
// Define the 'Message of the day' for the realm
|
||||
static bool HandleServerSetMotdCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
sWorld->SetMotd(args);
|
||||
Motd::SetMotd(args);
|
||||
handler->PSendSysMessage(LANG_MOTD_NEW, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Mails
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Maps
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Miscellaneous
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Motd
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Movement
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Movement/Spline
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Movement/MovementGenerators
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "Util.h"
|
||||
#include "World.h"
|
||||
#include "SHA1.h"
|
||||
#include "ServerMotd.h"
|
||||
|
||||
RASocket::RASocket()
|
||||
{
|
||||
@@ -349,7 +350,7 @@ int RASocket::svc(void)
|
||||
}
|
||||
|
||||
// send motd
|
||||
if (send(std::string(sWorld->GetMotd()) + "\r\n") == -1)
|
||||
if (send(std::string(Motd::GetMotd()) + "\r\n") == -1)
|
||||
return -1;
|
||||
|
||||
for (;;)
|
||||
|
||||
Reference in New Issue
Block a user