more ISL code, mutex fixes

This commit is contained in:
Max-Wilhelm Bruker 2012-03-12 00:36:44 +01:00
parent 0ae18d7b2e
commit 572e4eaafa
9 changed files with 107 additions and 48 deletions

View file

@ -6,7 +6,9 @@
#include <QObject>
#include <QStringList>
#include <QMutex>
#include <QMetaType>
#include "pb/serverinfo_room.pb.h"
#include "serverinfo_user_container.h"
class Server_ProtocolHandler;
class RoomEvent;
@ -19,7 +21,8 @@ class Server;
class Server_Room : public QObject {
Q_OBJECT
signals:
void roomInfoChanged();
void roomInfoChanged(ServerInfo_Room roomInfo);
void gameListChanged(ServerInfo_Game gameInfo);
private:
int id;
QString name;
@ -28,7 +31,11 @@ private:
QString joinMessage;
QStringList gameTypes;
QMap<int, Server_Game *> games;
QMap<int, ServerInfo_Game> externalGames;
QList<Server_ProtocolHandler *> userList;
QMap<QString, ServerInfo_User_Container> externalUsers;
private slots:
void broadcastGameListUpdate(ServerInfo_Game gameInfo);
public:
mutable QMutex roomMutex;
Server_Room(int _id, const QString &_name, const QString &_description, bool _autoJoin, const QString &_joinMessage, const QStringList &_gameTypes, Server *parent);
@ -41,19 +48,26 @@ public:
const QStringList &getGameTypes() const { return gameTypes; }
const QMap<int, Server_Game *> &getGames() const { return games; }
Server *getServer() const;
ServerInfo_Room getInfo(bool complete, bool showGameTypes = false, bool updating = false) const;
ServerInfo_Room getInfo(bool complete, bool showGameTypes = false, bool updating = false, bool includeExternalData = true) const;
int getGamesCreatedByUser(const QString &name) const;
QList<ServerInfo_Game> getGamesOfUser(const QString &name) const;
void addClient(Server_ProtocolHandler *client);
void removeClient(Server_ProtocolHandler *client);
void addExternalUser(const ServerInfo_User &userInfo);
void removeExternalUser(const QString &name);
void say(Server_ProtocolHandler *client, const QString &s);
void broadcastGameListUpdate(Server_Game *game);
Server_Game *createGame(const QString &description, const QString &password, int maxPlayers, const QList<int> &_gameTypes, bool onlyBuddies, bool onlyRegistered, bool spectatorsAllowed, bool spectatorsNeedPassword, bool spectatorsCanTalk, bool spectatorsSeeEverything, Server_ProtocolHandler *creator);
void addGame(Server_Game *game);
void removeGame(Server_Game *game);
void sendRoomEvent(RoomEvent *event);
void sendRoomEvent(RoomEvent *event, bool sendToIsl = true);
RoomEvent *prepareRoomEvent(const ::google::protobuf::Message &roomEvent);
};
Q_DECLARE_METATYPE(ServerInfo_Game)
Q_DECLARE_METATYPE(ServerInfo_Room)
#endif