mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 00:04:48 -07:00
changed leave game shortcut, server cleanups, added max_games_per_user
This commit is contained in:
parent
d0b8c6ebd9
commit
38b31681e2
11 changed files with 85 additions and 64 deletions
|
|
@ -112,24 +112,28 @@ void Server::broadcastRoomUpdate()
|
|||
delete event;
|
||||
}
|
||||
|
||||
void Server::gameCreated(Server_Game *game)
|
||||
{
|
||||
QMutexLocker locker(&serverMutex);
|
||||
games.insert(game->getGameId(), game);
|
||||
}
|
||||
|
||||
void Server::gameClosing(int gameId)
|
||||
{
|
||||
QMutexLocker locker(&serverMutex);
|
||||
qDebug("Server::gameClosing");
|
||||
games.remove(gameId);
|
||||
}
|
||||
|
||||
void Server::addRoom(Server_Room *newRoom)
|
||||
{
|
||||
QMutexLocker locker(&serverMutex);
|
||||
rooms.insert(newRoom->getId(), newRoom);
|
||||
connect(newRoom, SIGNAL(roomInfoChanged()), this, SLOT(broadcastRoomUpdate()));
|
||||
connect(newRoom, SIGNAL(gameCreated(Server_Game *)), this, SLOT(gameCreated(Server_Game *)));
|
||||
connect(newRoom, SIGNAL(gameClosing(int)), this, SLOT(gameClosing(int)));
|
||||
}
|
||||
|
||||
int Server::getUsersCount() const
|
||||
{
|
||||
QMutexLocker locker(&serverMutex);
|
||||
return users.size();
|
||||
}
|
||||
|
||||
int Server::getGamesCount() const
|
||||
{
|
||||
int result = 0;
|
||||
QMutexLocker locker(&serverMutex);
|
||||
QMapIterator<int, Server_Room *> roomIterator(rooms);
|
||||
while (roomIterator.hasNext()) {
|
||||
Server_Room *room = roomIterator.next().value();
|
||||
QMutexLocker roomLocker(&room->roomMutex);
|
||||
result += room->getGames().size();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue