mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
Merge branch 'master' into mod_notify_onbanwarn
This commit is contained in:
commit
3ed3919349
60 changed files with 2474 additions and 1644 deletions
|
|
@ -86,6 +86,8 @@ void Server_AbstractUserInterface::joinPersistentGames(ResponseContainer &rc)
|
|||
QMutexLocker gameLocker(&game->gameMutex);
|
||||
|
||||
Server_Player *player = game->getPlayers().value(pr.getPlayerId());
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
player->setUserInterface(this);
|
||||
playerAddedToGame(game->getGameId(), room->getId(), player->getPlayerId());
|
||||
|
|
|
|||
|
|
@ -147,7 +147,12 @@ int Server_CardZone::getFreeGridColumn(int x, int y, const QString &cardName, bo
|
|||
if (x == -1) {
|
||||
if (!dontStackSameName && freePilesMap[y].contains(cardName)) {
|
||||
x = (freePilesMap[y].value(cardName) / 3) * 3;
|
||||
if (!coordMap.contains(x))
|
||||
|
||||
if(coordMap.contains(x) &&
|
||||
(coordMap[x]->getFaceDown() ||
|
||||
!coordMap[x]->getAttachedCards().isEmpty())) {
|
||||
// don't pile up on: 1. facedown cards 2. cards with attached cards
|
||||
} else if (!coordMap.contains(x))
|
||||
return x;
|
||||
else if (!coordMap.contains(x + 1))
|
||||
return x + 1;
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
|||
QString clientId = QString::fromStdString(cmd.clientid()).simplified();
|
||||
QString clientVersion = QString::fromStdString(cmd.clientver()).simplified();
|
||||
|
||||
if (userName.isEmpty() || (userInfo != 0))
|
||||
if (userInfo != 0)
|
||||
return Response::RespContextError;
|
||||
|
||||
// check client feature set against server feature set
|
||||
|
|
@ -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…
Add table
Add a link
Reference in a new issue