Allow the server to send a global notice to all players (for example if a server reboot is going to happen). Does not work with current client version 0.6.3.
This commit is contained in:
@@ -691,9 +691,19 @@ AbstractClientStateReceiving::Process(ClientThread &client)
|
||||
NetPacketChatText::Data chatData;
|
||||
tmpPacket->ToNetPacketChatText()->GetData(chatData);
|
||||
|
||||
boost::shared_ptr<PlayerData> tmpPlayer = client.GetPlayerDataByUniqueId(chatData.playerId);
|
||||
if (tmpPlayer.get())
|
||||
client.GetCallback().SignalNetClientChatMsg(tmpPlayer->GetName(), chatData.text);
|
||||
string playerName;
|
||||
if (chatData.playerId == 0)
|
||||
{
|
||||
playerName = "(global notice)";
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::shared_ptr<PlayerData> tmpPlayer = client.GetPlayerDataByUniqueId(chatData.playerId);
|
||||
if (tmpPlayer.get())
|
||||
playerName = tmpPlayer->GetName();
|
||||
}
|
||||
if (!playerName.empty())
|
||||
client.GetCallback().SignalNetClientChatMsg(playerName, chatData.text);
|
||||
}
|
||||
else if (tmpPacket->ToNetPacketPlayerLeft())
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
|
||||
ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ConfigFile *playerConfig, AvatarManager &avatarManager)
|
||||
: m_gui(gui), m_avatarManager(avatarManager), m_playerConfig(playerConfig),
|
||||
m_curGameId(0), m_curUniquePlayerId(0), m_curSessionId(INVALID_SESSION + 1),
|
||||
m_curGameId(1), m_curUniquePlayerId(1), m_curSessionId(INVALID_SESSION + 1),
|
||||
m_statDataChanged(false), m_startTime(boost::posix_time::second_clock::local_time())
|
||||
{
|
||||
m_senderCallback.reset(new ServerSenderCallback(*this));
|
||||
@@ -259,6 +259,17 @@ ServerLobbyThread::RemovePlayer(unsigned playerId, unsigned errorCode)
|
||||
m_removePlayerList.push_back(RemovePlayerList::value_type(playerId, errorCode));
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::SendGlobalNotice(const std::string &message)
|
||||
{
|
||||
boost::shared_ptr<NetPacket> outChat(new NetPacketChatText);
|
||||
NetPacketChatText::Data outChatData;
|
||||
outChatData.playerId = 0;
|
||||
outChatData.text = message;
|
||||
static_cast<NetPacketChatText *>(outChat.get())->SetData(outChatData);
|
||||
m_gameSessionManager.SendToAllSessions(GetSender(), outChat, SessionData::Game);
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::AddComputerPlayer(boost::shared_ptr<PlayerData> player)
|
||||
{
|
||||
@@ -303,13 +314,21 @@ u_int32_t
|
||||
ServerLobbyThread::GetNextUniquePlayerId()
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_curUniquePlayerIdMutex);
|
||||
return m_curUniquePlayerId++;
|
||||
m_curUniquePlayerId++;
|
||||
if (m_curUniquePlayerId == 0) // 0 is an invalid id.
|
||||
m_curUniquePlayerId++;
|
||||
|
||||
return m_curUniquePlayerId;
|
||||
}
|
||||
|
||||
u_int32_t
|
||||
ServerLobbyThread::GetNextGameId()
|
||||
{
|
||||
return m_curGameId++;
|
||||
m_curGameId++;
|
||||
if (m_curGameId == 0) // 0 is an invalid id.
|
||||
m_curGameId++;
|
||||
|
||||
return m_curGameId;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -147,6 +147,19 @@ ServerManager::SignalIrcChatMsg(const std::string &nickName, const std::string &
|
||||
m_ircThread->SendChatMessage(statStream.str());
|
||||
}
|
||||
}
|
||||
else if (command == "msg")
|
||||
{
|
||||
while (msgStream.peek() == ' ')
|
||||
msgStream.get();
|
||||
string message(msgStream.str().substr(msgStream.tellg()));
|
||||
if (!message.empty())
|
||||
{
|
||||
GetLobbyThread().SendGlobalNotice(message);
|
||||
m_ircThread->SendChatMessage(nickName + ": Global notice sent.");
|
||||
}
|
||||
else
|
||||
m_ircThread->SendChatMessage(nickName + ": Invalid message.");
|
||||
}
|
||||
else
|
||||
m_ircThread->SendChatMessage(nickName + ": Invalid command \"" + command + "\".");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user