Possibly fix #1598
This commit is contained in:
parent
7e6972a358
commit
25d77fb64a
4 changed files with 14 additions and 5 deletions
|
@ -19,6 +19,10 @@ if(POLICY CMP0048)
|
|||
cmake_policy(SET CMP0048 OLD)
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0064)
|
||||
cmake_policy(SET CMP0064 OLD)
|
||||
endif()
|
||||
|
||||
set(PROJECT_NAME "Cockatrice")
|
||||
|
||||
# Default to "Release" build type
|
||||
|
|
|
@ -603,8 +603,11 @@ Response::ResponseCode Server_ProtocolHandler::cmdJoinRoom(const Command_JoinRoo
|
|||
joinMessageEvent.set_message_type(Event_RoomSay::Welcome);
|
||||
rc.enqueuePostResponseItem(ServerMessage::ROOM_EVENT, r->prepareRoomEvent(joinMessageEvent));
|
||||
|
||||
ServerInfo_ChatMessage chatMessage; for (int i = 0; i < r->chatHistory.size(); ++i) {
|
||||
chatMessage = r->chatHistory.at(i);
|
||||
QReadLocker chatHistoryLocker(&r->historyLock);
|
||||
QList<ServerInfo_ChatMessage> chatHistory = r->getChatHistory();
|
||||
ServerInfo_ChatMessage chatMessage;
|
||||
for (int i = 0; i < chatHistory.size(); ++i) {
|
||||
chatMessage = chatHistory.at(i);
|
||||
qDebug() << QString::fromStdString(chatMessage.message()).simplified();
|
||||
Event_RoomSay roomChatHistory;
|
||||
roomChatHistory.set_message(chatMessage.sender_name() + ": " + chatMessage.message());
|
||||
|
|
|
@ -236,7 +236,6 @@ void Server_Room::say(const QString &userName, const QString &s, bool sendToIsl)
|
|||
sendRoomEvent(prepareRoomEvent(event), sendToIsl);
|
||||
|
||||
if (chatHistorySize != 0) {
|
||||
|
||||
ServerInfo_ChatMessage chatMessage;
|
||||
QDateTime dateTime = dateTime.currentDateTimeUtc();
|
||||
QString dateTimeString = dateTime.toString();
|
||||
|
@ -244,10 +243,12 @@ void Server_Room::say(const QString &userName, const QString &s, bool sendToIsl)
|
|||
chatMessage.set_sender_name(userName.toStdString());
|
||||
chatMessage.set_message(s.simplified().toStdString());
|
||||
|
||||
historyLock.lockForWrite();
|
||||
if (chatHistory.size() >= chatHistorySize)
|
||||
chatHistory.removeAt(0);
|
||||
|
||||
chatHistory << chatMessage;
|
||||
historyLock.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,12 +42,13 @@ private:
|
|||
QMap<int, ServerInfo_Game> externalGames;
|
||||
QMap<QString, Server_ProtocolHandler *> users;
|
||||
QMap<QString, ServerInfo_User_Container> externalUsers;
|
||||
QList<ServerInfo_ChatMessage> chatHistory;
|
||||
private slots:
|
||||
void broadcastGameListUpdate(const ServerInfo_Game &gameInfo, bool sendToIsl = true);
|
||||
public:
|
||||
mutable QReadWriteLock usersLock;
|
||||
mutable QReadWriteLock gamesLock;
|
||||
QList<ServerInfo_ChatMessage> chatHistory;
|
||||
mutable QReadWriteLock historyLock;
|
||||
Server_Room(int _id, int _chatHistorySize, const QString &_name, const QString &_description, const QString &_permissionLevel, bool _autoJoin, const QString &_joinMessage, const QStringList &_gameTypes, Server *parent );
|
||||
~Server_Room();
|
||||
int getId() const { return id; }
|
||||
|
@ -63,7 +64,7 @@ public:
|
|||
const ServerInfo_Room &getInfo(ServerInfo_Room &result, bool complete, bool showGameTypes = false, bool includeExternalData = true) const;
|
||||
int getGamesCreatedByUser(const QString &name) const;
|
||||
QList<ServerInfo_Game> getGamesOfUser(const QString &name) const;
|
||||
QList<ServerInfo_ChatMessage> getChatHistory() { return chatHistory; }
|
||||
QList<ServerInfo_ChatMessage> & getChatHistory() { return chatHistory; }
|
||||
|
||||
void addClient(Server_ProtocolHandler *client);
|
||||
void removeClient(Server_ProtocolHandler *client);
|
||||
|
|
Loading…
Reference in a new issue