mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
Core/Packets: converted SMSG_MOTD and SMSG_LOGIN_VERIFY_WORLD to packet class
This commit is contained in:
@@ -838,13 +838,10 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
|
||||
pCurrChar->GetMotionMaster()->Initialize();
|
||||
pCurrChar->SendDungeonDifficulty(false);
|
||||
|
||||
WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20);
|
||||
data << pCurrChar->GetMapId();
|
||||
data << pCurrChar->GetPositionX();
|
||||
data << pCurrChar->GetPositionY();
|
||||
data << pCurrChar->GetPositionZ();
|
||||
data << pCurrChar->GetOrientation();
|
||||
SendPacket(&data);
|
||||
WorldPackets::Character::LoginVerifyWorld loginVerifyWorld;
|
||||
loginVerifyWorld.MapID = pCurrChar->GetMapId();
|
||||
loginVerifyWorld.Pos = pCurrChar->GetPosition();
|
||||
SendPacket(loginVerifyWorld.Write());
|
||||
|
||||
// load player specific part before send times
|
||||
LoadAccountData(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_ACCOUNT_DATA), PER_CHARACTER_CACHE_MASK);
|
||||
@@ -871,42 +868,15 @@ void WorldSession::HandlePlayerLogin(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);
|
||||
TC_LOG_DEBUG("network", "WORLD: Sent motd (SMSG_MOTD)");
|
||||
|
||||
// send server info
|
||||
if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
|
||||
chH.PSendSysMessage(GitRevision::GetFullVersion());
|
||||
|
||||
TC_LOG_DEBUG("network", "WORLD: Sent server info");
|
||||
WorldPackets::System::MOTD motd;
|
||||
motd.Text = &sWorld->GetMotd();
|
||||
SendPacket(motd.Write());
|
||||
}
|
||||
|
||||
// send server info
|
||||
if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
|
||||
chH.PSendSysMessage(GitRevision::GetFullVersion());
|
||||
|
||||
//QueryResult* result = CharacterDatabase.PQuery("SELECT guildid, rank FROM guild_member WHERE guid = '%u'", pCurrChar->GetGUID().GetCounter());
|
||||
if (PreparedQueryResult resultGuild = holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_GUILD))
|
||||
{
|
||||
@@ -930,7 +900,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
|
||||
pCurrChar->SetGuildLevel(0);
|
||||
}
|
||||
|
||||
data.Initialize(SMSG_LEARNED_DANCE_MOVES, 4+4);
|
||||
WorldPacket data(SMSG_LEARNED_DANCE_MOVES, 4+4);
|
||||
data << uint64(0);
|
||||
SendPacket(&data);
|
||||
|
||||
|
||||
@@ -226,3 +226,9 @@ void WorldPackets::Character::ShowingHelm::Read()
|
||||
_worldPacket >> ShowHelm;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Character::LoginVerifyWorld::Write()
|
||||
{
|
||||
_worldPacket << int32(MapID);
|
||||
_worldPacket << Pos;
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -145,6 +145,17 @@ namespace WorldPackets
|
||||
|
||||
bool ShowHelm = false;
|
||||
};
|
||||
|
||||
class LoginVerifyWorld final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
LoginVerifyWorld() : ServerPacket(SMSG_LOGIN_VERIFY_WORLD, 4 + 4 * 4) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
int32 MapID = -1;
|
||||
TaggedPosition<Position::XYZO> Pos;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,3 +49,14 @@ WorldPacket const* WorldPackets::System::FeatureSystemStatus::Write()
|
||||
}
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::System::MOTD::Write()
|
||||
{
|
||||
ASSERT(Text);
|
||||
_worldPacket << int32(Text->size());
|
||||
|
||||
for (std::string const& line : *Text)
|
||||
_worldPacket << line;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,16 @@ namespace WorldPackets
|
||||
bool ItemRestorationButtonEnabled = false;
|
||||
bool TravelPassEnabled = false;
|
||||
};
|
||||
|
||||
class MOTD final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
MOTD() : ServerPacket(SMSG_MOTD) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
std::vector<std::string> const* Text = nullptr;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
#include "WorldSocket.h"
|
||||
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
TC_GAME_API std::atomic<bool> World::m_stopEvent(false);
|
||||
TC_GAME_API uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
|
||||
@@ -205,16 +206,18 @@ void World::SetClosed(bool val)
|
||||
sScriptMgr->OnOpenStateChange(!val);
|
||||
}
|
||||
|
||||
void World::SetMotd(const std::string& motd)
|
||||
void World::SetMotd(std::string motd)
|
||||
{
|
||||
m_motd = motd;
|
||||
/// we are using a string copy here to allow modifications in script hooks
|
||||
sScriptMgr->OnMotdChange(motd);
|
||||
|
||||
sScriptMgr->OnMotdChange(m_motd);
|
||||
_motd.clear();
|
||||
boost::split(_motd, motd, boost::is_any_of("@"));
|
||||
}
|
||||
|
||||
char const* World::GetMotd() const
|
||||
std::vector<std::string> const& World::GetMotd() const
|
||||
{
|
||||
return m_motd.c_str();
|
||||
return _motd;
|
||||
}
|
||||
|
||||
void World::TriggerGuidWarning()
|
||||
|
||||
@@ -658,9 +658,9 @@ class TC_GAME_API World
|
||||
void SetAllowMovement(bool allow) { m_allowMovement = allow; }
|
||||
|
||||
/// Set a new Message of the Day
|
||||
void SetMotd(std::string const& motd);
|
||||
void SetMotd(std::string motd);
|
||||
/// Get the current Message of the Day
|
||||
char const* GetMotd() const;
|
||||
std::vector<std::string> const& GetMotd() const;
|
||||
|
||||
/// Set the string for new characters (first login)
|
||||
void SetNewCharString(std::string const& str) { m_newCharString = str; }
|
||||
@@ -863,7 +863,7 @@ class TC_GAME_API World
|
||||
LocaleConstant m_defaultDbcLocale; // from config for one from loaded DBC locales
|
||||
uint32 m_availableDbcLocaleMask; // by loaded DBC
|
||||
bool m_allowMovement;
|
||||
std::string m_motd;
|
||||
std::vector<std::string> _motd;
|
||||
std::string m_dataPath;
|
||||
|
||||
// for max speed access
|
||||
|
||||
@@ -273,7 +273,10 @@ 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());
|
||||
std::string motd;
|
||||
for (std::string const& line : sWorld->GetMotd())
|
||||
motd += line;
|
||||
handler->PSendSysMessage(LANG_MOTD_CURRENT, motd.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,9 @@ void RASession::Start()
|
||||
TC_LOG_INFO("commands.ra", "User %s (IP: %s) authenticated correctly to RA", username.c_str(), GetRemoteIpAddress().c_str());
|
||||
|
||||
// Authentication successful, send the motd
|
||||
Send(std::string(std::string(sWorld->GetMotd()) + "\r\n").c_str());
|
||||
// Authentication successful, send the motd
|
||||
for (std::string const& line : sWorld->GetMotd())
|
||||
Send(line.c_str());
|
||||
|
||||
// Read commands
|
||||
for (;;)
|
||||
|
||||
Reference in New Issue
Block a user