mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
events
This commit is contained in:
parent
29bf3d3774
commit
8b3723b871
16 changed files with 274 additions and 77 deletions
|
|
@ -1,46 +1,41 @@
|
|||
#include "server_chatchannel.h"
|
||||
#include "server_protocolhandler.h"
|
||||
|
||||
Server_ChatChannel::Server_ChatChannel(const QString &_name, const QString &_description, bool _autoJoin, const QStringList &_joinMessage)
|
||||
Server_ChatChannel::Server_ChatChannel(const QString &_name, const QString &_description, bool _autoJoin, const QString &_joinMessage)
|
||||
: name(_name), description(_description), autoJoin(_autoJoin), joinMessage(_joinMessage)
|
||||
{
|
||||
}
|
||||
|
||||
void Server_ChatChannel::addClient(Server_ProtocolHandler *client)
|
||||
{
|
||||
/* QString str = QString("chat|join_channel|%1|%2").arg(name).arg(player->getPlayerName());
|
||||
for (int i = 0; i < size(); ++i)
|
||||
at(i)->msg(str);
|
||||
|
||||
append(player);
|
||||
sendChatEvent(new Event_ChatJoinChannel(name, client->getPlayerName()));
|
||||
append(client);
|
||||
|
||||
Event_ChatListPlayers *eventCLP = new Event_ChatListPlayers(name);
|
||||
for (int i = 0; i < size(); ++i)
|
||||
player->msg(QString("chat|list_players|%1|%2").arg(name).arg(at(i)->getPlayerName()));
|
||||
for (int i = 0; i < joinMessage.size(); ++i)
|
||||
player->msg(QString("chat|server_message|%1|%2").arg(name).arg(joinMessage[i]));
|
||||
eventCLP->addPlayer(at(i)->getPlayerName());
|
||||
client->enqueueProtocolItem(eventCLP);
|
||||
|
||||
client->enqueueProtocolItem(new Event_ChatServerMessage(name, joinMessage));
|
||||
|
||||
emit channelInfoChanged();
|
||||
*/}
|
||||
}
|
||||
|
||||
void Server_ChatChannel::removeClient(Server_ProtocolHandler *client)
|
||||
{
|
||||
/* QString str = QString("chat|leave_channel|%1|%2").arg(name).arg(player->getPlayerName());
|
||||
|
||||
removeAt(indexOf(player));
|
||||
for (int i = 0; i < size(); ++i)
|
||||
at(i)->msg(str);
|
||||
|
||||
removeAt(indexOf(client));
|
||||
sendChatEvent(new Event_ChatLeaveChannel(name, client->getPlayerName()));
|
||||
emit channelInfoChanged();
|
||||
*/}
|
||||
}
|
||||
|
||||
void Server_ChatChannel::say(Server_ProtocolHandler *client, const QString &s)
|
||||
{
|
||||
/* QString str = QString("chat|say|%1|%2|%3").arg(name).arg(player->getPlayerName()).arg(s);
|
||||
for (int i = 0; i < size(); ++i)
|
||||
at(i)->msg(str);
|
||||
*/}
|
||||
|
||||
QString Server_ChatChannel::getChannelListLine() const
|
||||
{
|
||||
// return QString("chat|list_channels|%1|%2|%3|%4").arg(name).arg(description).arg(size()).arg(autoJoin ? 1 : 0);
|
||||
sendChatEvent(new Event_ChatSay(name, client->getPlayerName(), s));
|
||||
}
|
||||
|
||||
void Server_ChatChannel::sendChatEvent(ChatEvent *event)
|
||||
{
|
||||
for (int i = 0; i < size(); ++i)
|
||||
at(i)->sendProtocolItem(event, false);
|
||||
delete event;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue