Commit 35988291 authored by Waleed Khan's avatar Waleed Khan
Browse files

Merge remote-tracking branch 'upstream/master'

Some tabs to spaces, and maybe fixed to work with Qt 5.

Conflicts:
	cockatrice/src/deckstats_interface.cpp
	common/decklist.cpp
	common/decklist.h
	oracle/src/oracleimporter.cpp
parents 7cbe4101 1973df10
...@@ -14,17 +14,17 @@ Server_Arrow::Server_Arrow(int _id, Server_Card *_startCard, Server_ArrowTarget ...@@ -14,17 +14,17 @@ Server_Arrow::Server_Arrow(int _id, Server_Card *_startCard, Server_ArrowTarget
void Server_Arrow::getInfo(ServerInfo_Arrow *info) void Server_Arrow::getInfo(ServerInfo_Arrow *info)
{ {
info->set_id(id); info->set_id(id);
info->set_start_player_id(startCard->getZone()->getPlayer()->getPlayerId()); info->set_start_player_id(startCard->getZone()->getPlayer()->getPlayerId());
info->set_start_zone(startCard->getZone()->getName().toStdString()); info->set_start_zone(startCard->getZone()->getName().toStdString());
info->set_start_card_id(startCard->getId()); info->set_start_card_id(startCard->getId());
info->mutable_arrow_color()->CopyFrom(arrowColor); info->mutable_arrow_color()->CopyFrom(arrowColor);
Server_Card *targetCard = qobject_cast<Server_Card *>(targetItem); Server_Card *targetCard = qobject_cast<Server_Card *>(targetItem);
if (targetCard) { if (targetCard) {
info->set_target_player_id(targetCard->getZone()->getPlayer()->getPlayerId()); info->set_target_player_id(targetCard->getZone()->getPlayer()->getPlayerId());
info->set_target_zone(targetCard->getZone()->getName().toStdString()); info->set_target_zone(targetCard->getZone()->getName().toStdString());
info->set_target_card_id(targetCard->getId()); info->set_target_card_id(targetCard->getId());
} else } else
info->set_target_player_id(static_cast<Server_Player *>(targetItem)->getPlayerId()); info->set_target_player_id(static_cast<Server_Player *>(targetItem)->getPlayerId());
} }
...@@ -9,18 +9,18 @@ class ServerInfo_Arrow; ...@@ -9,18 +9,18 @@ class ServerInfo_Arrow;
class Server_Arrow { class Server_Arrow {
private: private:
int id; int id;
Server_Card *startCard; Server_Card *startCard;
Server_ArrowTarget *targetItem; Server_ArrowTarget *targetItem;
color arrowColor; color arrowColor;
public: public:
Server_Arrow(int _id, Server_Card *_startCard, Server_ArrowTarget *_targetItem, const color &_arrowColor); Server_Arrow(int _id, Server_Card *_startCard, Server_ArrowTarget *_targetItem, const color &_arrowColor);
int getId() const { return id; } int getId() const { return id; }
Server_Card *getStartCard() const { return startCard; } Server_Card *getStartCard() const { return startCard; }
Server_ArrowTarget *getTargetItem() const { return targetItem; } Server_ArrowTarget *getTargetItem() const { return targetItem; }
const color &getColor() const { return arrowColor; } const color &getColor() const { return arrowColor; }
void getInfo(ServerInfo_Arrow *info); void getInfo(ServerInfo_Arrow *info);
}; };
#endif #endif
#include "server_arrowtarget.h" #include "server_arrowtarget.h"
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <QObject> #include <QObject>
class Server_ArrowTarget : public QObject { class Server_ArrowTarget : public QObject {
Q_OBJECT Q_OBJECT
}; };
#endif #endif
...@@ -23,138 +23,138 @@ ...@@ -23,138 +23,138 @@
#include "pb/serverinfo_card.pb.h" #include "pb/serverinfo_card.pb.h"
Server_Card::Server_Card(QString _name, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone) Server_Card::Server_Card(QString _name, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone)
: zone(_zone), id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), tapped(false), attacking(false), facedown(false), color(QString()), power(-1), toughness(-1), annotation(QString()), destroyOnZoneChange(false), doesntUntap(false), parentCard(0) : zone(_zone), id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), tapped(false), attacking(false), facedown(false), color(QString()), power(-1), toughness(-1), annotation(QString()), destroyOnZoneChange(false), doesntUntap(false), parentCard(0)
{ {
} }
Server_Card::~Server_Card() Server_Card::~Server_Card()
{ {
// setParentCard(0) leads to the item being removed from our list, so we can't iterate properly // setParentCard(0) leads to the item being removed from our list, so we can't iterate properly
while (!attachedCards.isEmpty()) while (!attachedCards.isEmpty())
attachedCards.first()->setParentCard(0); attachedCards.first()->setParentCard(0);
if (parentCard) if (parentCard)
parentCard->removeAttachedCard(this); parentCard->removeAttachedCard(this);
} }
void Server_Card::resetState() void Server_Card::resetState()
{ {
counters.clear(); counters.clear();
setTapped(false); setTapped(false);
setAttacking(false); setAttacking(false);
power = -1; power = -1;
toughness = -1; toughness = -1;
setAnnotation(QString()); setAnnotation(QString());
setDoesntUntap(false); setDoesntUntap(false);
} }
QString Server_Card::setAttribute(CardAttribute attribute, const QString &avalue, bool allCards) QString Server_Card::setAttribute(CardAttribute attribute, const QString &avalue, bool allCards)
{ {
switch (attribute) { switch (attribute) {
case AttrTapped: { case AttrTapped: {
bool value = avalue == "1"; bool value = avalue == "1";
if (!(!value && allCards && doesntUntap)) if (!(!value && allCards && doesntUntap))
setTapped(value); setTapped(value);
break; break;
} }
case AttrAttacking: setAttacking(avalue == "1"); break; case AttrAttacking: setAttacking(avalue == "1"); break;
case AttrFaceDown: setFaceDown(avalue == "1"); break; case AttrFaceDown: setFaceDown(avalue == "1"); break;
case AttrColor: setColor(avalue); break; case AttrColor: setColor(avalue); break;
case AttrPT: setPT(avalue); return getPT(); case AttrPT: setPT(avalue); return getPT();
case AttrAnnotation: setAnnotation(avalue); break; case AttrAnnotation: setAnnotation(avalue); break;
case AttrDoesntUntap: setDoesntUntap(avalue == "1"); break; case AttrDoesntUntap: setDoesntUntap(avalue == "1"); break;
} }
return avalue; return avalue;
} }
void Server_Card::setCounter(int id, int value) void Server_Card::setCounter(int id, int value)
{ {
if (value) if (value)
counters.insert(id, value); counters.insert(id, value);
else else
counters.remove(id); counters.remove(id);
} }
void Server_Card::setPT(const QString &_pt) void Server_Card::setPT(const QString &_pt)
{ {
if (_pt.isEmpty()) { if (_pt.isEmpty()) {
power = 0; power = 0;
toughness = -1; toughness = -1;
} else { } else {
int sep = _pt.indexOf('/'); int sep = _pt.indexOf('/');
QString p1 = _pt.left(sep); QString p1 = _pt.left(sep);
QString p2 = _pt.mid(sep + 1); QString p2 = _pt.mid(sep + 1);
if (p1.isEmpty() || p2.isEmpty()) if (p1.isEmpty() || p2.isEmpty())
return; return;
if ((p1[0] == '+') || (p2[0] == '+')) { if ((p1[0] == '+') || (p2[0] == '+')) {
if (power < 0) if (power < 0)
power = 0; power = 0;
if (toughness < 0) if (toughness < 0)
toughness = 0; toughness = 0;
} }
if (p1[0] == '+') if (p1[0] == '+')
power += p1.mid(1).toInt(); power += p1.mid(1).toInt();
else else
power = p1.toInt(); power = p1.toInt();
if (p2[0] == '+') if (p2[0] == '+')
toughness += p2.mid(1).toInt(); toughness += p2.mid(1).toInt();
else else
toughness = p2.toInt(); toughness = p2.toInt();
} }
} }
QString Server_Card::getPT() const QString Server_Card::getPT() const
{ {
if (toughness < 0) if (toughness < 0)
return QString(""); return QString("");
return QString::number(power) + "/" + QString::number(toughness); return QString::number(power) + "/" + QString::number(toughness);
} }
void Server_Card::setParentCard(Server_Card *_parentCard) void Server_Card::setParentCard(Server_Card *_parentCard)
{ {
if (parentCard) if (parentCard)
parentCard->removeAttachedCard(this); parentCard->removeAttachedCard(this);
parentCard = _parentCard; parentCard = _parentCard;
if (parentCard) if (parentCard)
parentCard->addAttachedCard(this); parentCard->addAttachedCard(this);
} }
void Server_Card::getInfo(ServerInfo_Card *info) void Server_Card::getInfo(ServerInfo_Card *info)
{ {
QString displayedName = facedown ? QString() : name; QString displayedName = facedown ? QString() : name;
info->set_id(id); info->set_id(id);
info->set_name(displayedName.toStdString()); info->set_name(displayedName.toStdString());
info->set_x(coord_x); info->set_x(coord_x);
info->set_y(coord_y); info->set_y(coord_y);
if (facedown) if (facedown)
info->set_face_down(true); info->set_face_down(true);
info->set_tapped(tapped); info->set_tapped(tapped);
if (attacking) if (attacking)
info->set_attacking(true); info->set_attacking(true);
if (!color.isEmpty()) if (!color.isEmpty())
info->set_color(color.toStdString()); info->set_color(color.toStdString());
const QString ptStr = getPT(); const QString ptStr = getPT();
if (!ptStr.isEmpty()) if (!ptStr.isEmpty())
info->set_pt(ptStr.toStdString()); info->set_pt(ptStr.toStdString());
if (!annotation.isEmpty()) if (!annotation.isEmpty())
info->set_annotation(annotation.toStdString()); info->set_annotation(annotation.toStdString());
if (destroyOnZoneChange) if (destroyOnZoneChange)
info->set_destroy_on_zone_change(true); info->set_destroy_on_zone_change(true);
if (doesntUntap) if (doesntUntap)
info->set_doesnt_untap(true); info->set_doesnt_untap(true);
QMapIterator<int, int> cardCounterIterator(counters); QMapIterator<int, int> cardCounterIterator(counters);
while (cardCounterIterator.hasNext()) { while (cardCounterIterator.hasNext()) {
cardCounterIterator.next(); cardCounterIterator.next();
ServerInfo_CardCounter *counterInfo = info->add_counter_list(); ServerInfo_CardCounter *counterInfo = info->add_counter_list();
counterInfo->set_id(cardCounterIterator.key()); counterInfo->set_id(cardCounterIterator.key());
counterInfo->set_value(cardCounterIterator.value()); counterInfo->set_value(cardCounterIterator.value());
} }
if (parentCard) { if (parentCard) {
info->set_attach_player_id(parentCard->getZone()->getPlayer()->getPlayerId()); info->set_attach_player_id(parentCard->getZone()->getPlayer()->getPlayerId());
info->set_attach_zone(parentCard->getZone()->getName().toStdString()); info->set_attach_zone(parentCard->getZone()->getName().toStdString());
info->set_attach_card_id(parentCard->getId()); info->set_attach_card_id(parentCard->getId());
} }
} }
...@@ -29,68 +29,68 @@ class Server_CardZone; ...@@ -29,68 +29,68 @@ class Server_CardZone;
class ServerInfo_Card; class ServerInfo_Card;
class Server_Card : public Server_ArrowTarget { class Server_Card : public Server_ArrowTarget {
Q_OBJECT Q_OBJECT
private: private:
Server_CardZone *zone; Server_CardZone *zone;
int id; int id;
int coord_x, coord_y; int coord_x, coord_y;
QString name; QString name;
QMap<int, int> counters; QMap<int, int> counters;
bool tapped; bool tapped;
bool attacking; bool attacking;
bool facedown; bool facedown;
QString color; QString color;
int power, toughness; int power, toughness;
QString annotation; QString annotation;
bool destroyOnZoneChange; bool destroyOnZoneChange;
bool doesntUntap; bool doesntUntap;
Server_Card *parentCard; Server_Card *parentCard;
QList<Server_Card *> attachedCards; QList<Server_Card *> attachedCards;
public: public:
Server_Card(QString _name, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone = 0); Server_Card(QString _name, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone = 0);
~Server_Card(); ~Server_Card();
Server_CardZone *getZone() const { return zone; } Server_CardZone *getZone() const { return zone; }
void setZone(Server_CardZone *_zone) { zone = _zone; } void setZone(Server_CardZone *_zone) { zone = _zone; }
int getId() const { return id; } int getId() const { return id; }
int getX() const { return coord_x; } int getX() const { return coord_x; }
int getY() const { return coord_y; } int getY() const { return coord_y; }
QString getName() const { return name; } QString getName() const { return name; }
const QMap<int, int> &getCounters() const { return counters; } const QMap<int, int> &getCounters() const { return counters; }
int getCounter(int id) const { return counters.value(id, 0); } int getCounter(int id) const { return counters.value(id, 0); }
bool getTapped() const { return tapped; } bool getTapped() const { return tapped; }
bool getAttacking() const { return attacking; } bool getAttacking() const { return attacking; }
bool getFaceDown() const { return facedown; } bool getFaceDown() const { return facedown; }
QString getColor() const { return color; } QString getColor() const { return color; }
QString getPT() const; QString getPT() const;
QString getAnnotation() const { return annotation; } QString getAnnotation() const { return annotation; }
bool getDoesntUntap() const { return doesntUntap; } bool getDoesntUntap() const { return doesntUntap; }
bool getDestroyOnZoneChange() const { return destroyOnZoneChange; } bool getDestroyOnZoneChange() const { return destroyOnZoneChange; }
Server_Card *getParentCard() const { return parentCard; } Server_Card *getParentCard() const { return parentCard; }
const QList<Server_Card *> &getAttachedCards() const { return attachedCards; } const QList<Server_Card *> &getAttachedCards() const { return attachedCards; }
void setId(int _id) { id = _id; } void setId(int _id) { id = _id; }
void setCoords(int x, int y) { coord_x = x; coord_y = y; } void setCoords(int x, int y) { coord_x = x; coord_y = y; }
void setName(const QString &_name) { name = _name; } void setName(const QString &_name) { name = _name; }
void setCounter(int id, int value); void setCounter(int id, int value);
void setTapped(bool _tapped) { tapped = _tapped; } void setTapped(bool _tapped) { tapped = _tapped; }
void setAttacking(bool _attacking) { attacking = _attacking; } void setAttacking(bool _attacking) { attacking = _attacking; }
void setFaceDown(bool _facedown) { facedown = _facedown; } void setFaceDown(bool _facedown) { facedown = _facedown; }
void setColor(const QString &_color) { color = _color; } void setColor(const QString &_color) { color = _color; }
void setPT(const QString &_pt); void setPT(const QString &_pt);
void setAnnotation(const QString &_annotation) { annotation = _annotation; } void setAnnotation(const QString &_annotation) { annotation = _annotation; }
void setDestroyOnZoneChange(bool _destroy) { destroyOnZoneChange = _destroy; } void setDestroyOnZoneChange(bool _destroy) { destroyOnZoneChange = _destroy; }
void setDoesntUntap(bool _doesntUntap) { doesntUntap = _doesntUntap; } void setDoesntUntap(bool _doesntUntap) { doesntUntap = _doesntUntap; }
void setParentCard(Server_Card *_parentCard); void setParentCard(Server_Card *_parentCard);
void addAttachedCard(Server_Card *card) { attachedCards.append(card); } void addAttachedCard(Server_Card *card) { attachedCards.append(card); }
void removeAttachedCard(Server_Card *card) { attachedCards.removeAt(attachedCards.indexOf(card)); } void removeAttachedCard(Server_Card *card) { attachedCards.removeAt(attachedCards.indexOf(card)); }
void resetState(); void resetState();
QString setAttribute(CardAttribute attribute, const QString &avalue, bool allCards); QString setAttribute(CardAttribute attribute, const QString &avalue, bool allCards);
void getInfo(ServerInfo_Card *info); void getInfo(ServerInfo_Card *info);
}; };
#endif #endif
...@@ -33,48 +33,48 @@ class GameEventStorage; ...@@ -33,48 +33,48 @@ class GameEventStorage;
class Server_CardZone { class Server_CardZone {
private: private:
Server_Player *player; Server_Player *player;
QString name; QString name;
bool has_coords; bool has_coords;
ServerInfo_Zone::ZoneType type; ServerInfo_Zone::ZoneType type;
int cardsBeingLookedAt; int cardsBeingLookedAt;
QSet<int> playersWithWritePermission; QSet<int> playersWithWritePermission;
bool alwaysRevealTopCard; bool alwaysRevealTopCard;
QList<Server_Card *> cards; QList<Server_Card *> cards;
QMap<int, QMap<int, Server_Card *> > coordinateMap; // y -> (x -> card) QMap<int, QMap<int, Server_Card *> > coordinateMap; // y -> (x -> card)
QMap<int, QMultiMap<QString, int> > freePilesMap; // y -> (cardName -> x) QMap<int, QMultiMap<QString, int> > freePilesMap; // y -> (cardName -> x)
QMap<int, int> freeSpaceMap; // y -> x QMap<int, int> freeSpaceMap; // y -> x
void removeCardFromCoordMap(Server_Card *card, int oldX, int oldY); void removeCardFromCoordMap(Server_Card *card, int oldX, int oldY);
void insertCardIntoCoordMap(Server_Card *card, int x, int y); void insertCardIntoCoordMap(Server_Card *card, int x, int y);
public: public:
Server_CardZone(Server_Player *_player, const QString &_name, bool _has_coords, ServerInfo_Zone::ZoneType _type); Server_CardZone(Server_Player *_player, const QString &_name, bool _has_coords, ServerInfo_Zone::ZoneType _type);
~Server_CardZone(); ~Server_CardZone();
const QList<Server_Card *> &getCards() const { return cards; } const QList<Server_Card *> &getCards() const { return cards; }
int removeCard(Server_Card *card); int removeCard(Server_Card *card);
Server_Card *getCard(int id, int *position = NULL, bool remove = false); Server_Card *getCard(int id, int *position = NULL, bool remove = false);
int getCardsBeingLookedAt() const { return cardsBeingLookedAt; } int getCardsBeingLookedAt() const { return cardsBeingLookedAt; }
void setCardsBeingLookedAt(int _cardsBeingLookedAt) { cardsBeingLookedAt = _cardsBeingLookedAt; } void setCardsBeingLookedAt(int _cardsBeingLookedAt) { cardsBeingLookedAt = _cardsBeingLookedAt; }
bool hasCoords() const { return has_coords; } bool hasCoords() const { return has_coords; }
ServerInfo_Zone::ZoneType getType() const { return type; } ServerInfo_Zone::ZoneType getType() const { return type; }
QString getName() const { return name; } QString getName() const { return name; }
Server_Player *getPlayer() const { return player; } Server_Player *getPlayer() const { return player; }
void getInfo(ServerInfo_Zone *info, Server_Player *playerWhosAsking, bool omniscient); void getInfo(ServerInfo_Zone *info, Server_Player *playerWhosAsking, bool omniscient);
int getFreeGridColumn(int x, int y, const QString &cardName) const; int getFreeGridColumn(int x, int y, const QString &cardName) const;
bool isColumnEmpty(int x, int y) const; bool isColumnEmpty(int x, int y) const;
bool isColumnStacked(int x, int y) const; bool isColumnStacked(int x, int y) const;
void fixFreeSpaces(GameEventStorage &ges); void fixFreeSpaces(GameEventStorage &ges);
void moveCardInRow(GameEventStorage &ges, Server_Card *card, int x, int y); void moveCardInRow(GameEventStorage &ges, Server_Card *card, int x, int y);
void insertCard(Server_Card *card, int x, int y); void insertCard(Server_Card *card, int x, int y);
void updateCardCoordinates(Server_Card *card, int oldX, int oldY); void updateCardCoordinates(Server_Card *card, int oldX, int oldY);
void shuffle(); void shuffle();
void clear(); void clear();
void addWritePermission(int playerId); void addWritePermission(int playerId);
const QSet<int> &getPlayersWithWritePermission() const { return playersWithWritePermission; } const QSet<int> &getPlayersWithWritePermission() const { return playersWithWritePermission; }
bool getAlwaysRevealTopCard() const { return alwaysRevealTopCard; } bool getAlwaysRevealTopCard() const { return alwaysRevealTopCard; }
void setAlwaysRevealTopCard(bool _alwaysRevealTopCard) { alwaysRevealTopCard = _alwaysRevealTopCard; } void setAlwaysRevealTopCard(bool _alwaysRevealTopCard) { alwaysRevealTopCard = _alwaysRevealTopCard; }
}; };
#endif #endif
...@@ -12,9 +12,9 @@ Server_Counter::Server_Counter(int _id, const QString &_name, const color &_coun ...@@ -12,9 +12,9 @@ Server_Counter::Server_Counter(int _id, const QString &_name, const color &_coun
void Server_Counter::getInfo(ServerInfo_Counter *info) void Server_Counter::getInfo(ServerInfo_Counter *info)
{ {
info->set_id(id); info->set_id(id);
info->set_name(name.toStdString()); info->set_name(name.toStdString());
info->mutable_counter_color()->CopyFrom(counterColor); info->mutable_counter_color()->CopyFrom(counterColor);
info->set_radius(radius); info->set_radius(radius);
info->set_count(count); info->set_count(count);
} }
...@@ -27,22 +27,22 @@ class ServerInfo_Counter; ...@@ -27,22 +27,22 @@ class ServerInfo_Counter;
class Server_Counter { class Server_Counter {
protected: protected:
int id; int id;
QString name; QString name;
color counterColor; color counterColor;
int radius; int radius;
int count; int count;
public: public:
Server_Counter(int _id, const QString &_name, const color &_counterColor, int _radius, int _count = 0); Server_Counter(int _id, const QString &_name, const color &_counterColor, int _radius, int _count = 0);
~Server_Counter() { } ~Server_Counter() { }
int getId() const { return id; } int getId() const { return id; }
QString getName() const { return name; } QString getName() const { return name; }
const color &getColor() const { return counterColor; } const color &getColor() const { return counterColor; }
int getRadius() const { return radius; } int getRadius() const { return radius; }
int getCount() const { return count; } int getCount() const { return count; }
void setCount(int _count) { count = _count; } void setCount(int _count) { count = _count; }
void getInfo(ServerInfo_Counter *info); void getInfo(ServerInfo_Counter *info);
}; };
#endif #endif
...@@ -6,32 +6,32 @@ ...@@ -6,32 +6,32 @@
#include "server.h" #include "server.h"
class Server_DatabaseInterface : public QObject { class Server_DatabaseInterface : public QObject {
Q_OBJECT Q_OBJECT
public: public:
Server_DatabaseInterface(QObject *parent = 0) Server_DatabaseInterface(QObject *parent = 0)
: QObject(parent) { } : QObject(parent) { }
virtual AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr, int &secondsLeft) = 0; virtual AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr, int &secondsLeft) = 0;
virtual bool userExists(const QString &user) { return false; } virtual bool userExists(const QString &user) { return false; }
virtual QMap<QString, ServerInfo_User> getBuddyList(const QString &name) { return QMap<QString, ServerInfo_User>(); } virtual QMap<QString, ServerInfo_User> getBuddyList(const QString &name) { return QMap<QString, ServerInfo_User>(); }
virtual QMap<QString, ServerInfo_User> getIgnoreList(const QString &name) { return QMap<QString, ServerInfo_User>(); } virtual QMap<QString, ServerInfo_User> getIgnoreList(const QString &name) { return QMap<QString, ServerInfo_User>(); }
virtual bool isInBuddyList(const QString &whoseList, const QString &who) { return false; } virtual bool isInBuddyList(const QString &whoseList, const QString &who) { return false; }
virtual bool isInIgnoreList(const QString &whoseList, const QString &who) { return false; } virtual bool isInIgnoreList(const QString &whoseList, const QString &who) { return false; }
virtual ServerInfo_User getUserData(const QString &name, bool withId = false) = 0; virtual ServerInfo_User getUserData(const QString &name, bool withId = false) = 0;
virtual void storeGameInformation(const QString &roomName, const QStringList &roomGameTypes, const ServerInfo_Game &gameInfo, const QSet<QString> &allPlayersEver, const QSet<QString> &allSpectatorsEver, const QList<GameReplay *> &replayList) { } virtual void storeGameInformation(const QString &roomName, const QStringList &roomGameTypes, const ServerInfo_Game &gameInfo, const QSet<QString> &allPlayersEver, const QSet<QString> &allSpectatorsEver, const QList<GameReplay *> &replayList) { }
virtual DeckList *getDeckFromDatabase(int deckId, int userId) { return 0; } virtual DeckList *getDeckFromDatabase(int deckId, int userId) { return 0; }
virtual qint64 startSession(const QString &userName, const QString &address) { return 0; } virtual qint64 startSession(const QString &userName, const QString &address) { return 0; }
public slots: public slots:
virtual void endSession(qint64 sessionId) { } virtual void endSession(qint64 sessionId) { }
public: public:
virtual int getNextGameId() = 0; virtual int getNextGameId() = 0;
virtual int getNextReplayId() = 0; virtual int getNextReplayId() = 0;
virtual void clearSessionTables() { } virtual void clearSessionTables() { }
virtual void lockSessionTables() { } virtual void lockSessionTables() { }
virtual void unlockSessionTables() { } virtual void unlockSessionTables() { }
virtual bool userSessionExists(const QString &userName) { return false; } virtual bool userSessionExists(const QString &userName) { return false; }
}; };
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -3,15 +3,15 @@ ...@@ -3,15 +3,15 @@
class PlayerReference { class PlayerReference {
private: private:
int roomId; int roomId;
int gameId; int gameId;
int playerId; int playerId;
public: public:
PlayerReference(int _roomId, int _gameId, int _playerId) : roomId(_roomId), gameId(_gameId), playerId(_playerId) { } PlayerReference(int _roomId, int _gameId, int _playerId) : roomId(_roomId), gameId(_gameId), playerId(_playerId) { }
int getRoomId() const { return roomId; } int getRoomId() const { return roomId; }
int getGameId() const { return gameId; } int getGameId() const { return gameId; }
int getPlayerId() const { return playerId; } int getPlayerId() const { return playerId; }
bool operator==(const PlayerReference &other) { return ((roomId == other.roomId) && (gameId == other.gameId) && (playerId == other.playerId)); } bool operator==(const PlayerReference &other) { return ((roomId == other.roomId) && (gameId == other.gameId) && (playerId == other.playerId)); }
}; };
#endif #endif
This diff is collapsed.
...@@ -40,64 +40,64 @@ class Command_CreateGame; ...@@ -40,64 +40,64 @@ class Command_CreateGame;
class Command_JoinGame; class Command_JoinGame;
class Server_ProtocolHandler : public QObject, public Server_AbstractUserInterface { class Server_ProtocolHandler : public QObject, public Server_AbstractUserInterface {
Q_OBJECT Q_OBJECT
protected: protected:
QMap<int, Server_Room *> rooms; QMap<int, Server_Room *> rooms;
bool deleted; bool deleted;
Server_DatabaseInterface *databaseInterface; Server_DatabaseInterface *databaseInterface;
AuthenticationResult authState; AuthenticationResult authState;
bool acceptsUserListChanges; bool acceptsUserListChanges;
bool acceptsRoomListChanges; bool acceptsRoomListChanges;
virtual void logDebugMessage(const QString &message) { } virtual void logDebugMessage(const QString &message) { }
private: private:
QList<int> messageSizeOverTime, messageCountOverTime; QList<int> messageSizeOverTime, messageCountOverTime;
int timeRunning, lastDataReceived; int timeRunning, lastDataReceived;
QTimer *pingClock; QTimer *pingClock;
virtual void transmitProtocolItem(const ServerMessage &item) = 0; virtual void transmitProtocolItem(const ServerMessage &item) = 0;
Response::ResponseCode cmdPing(const Command_Ping &cmd, ResponseContainer &rc); Response::ResponseCode cmdPing(const Command_Ping &cmd, ResponseContainer &rc);
Response::ResponseCode cmdLogin(const Command_Login &cmd, ResponseContainer &rc); Response::ResponseCode cmdLogin(const Command_Login &cmd, ResponseContainer &rc);
Response::ResponseCode cmdMessage(const Command_Message &cmd, ResponseContainer &rc); Response::ResponseCode cmdMessage(const Command_Message &cmd, ResponseContainer &rc);
Response::ResponseCode cmdGetGamesOfUser(const Command_GetGamesOfUser &cmd, ResponseContainer &rc); Response::ResponseCode cmdGetGamesOfUser(const Command_GetGamesOfUser &cmd, ResponseContainer &rc);
Response::ResponseCode cmdGetUserInfo(const Command_GetUserInfo &cmd, ResponseContainer &rc); Response::ResponseCode cmdGetUserInfo(const Command_GetUserInfo &cmd, ResponseContainer &rc);
Response::ResponseCode cmdListRooms(const Command_ListRooms &cmd, ResponseContainer &rc); Response::ResponseCode cmdListRooms(const Command_ListRooms &cmd, ResponseContainer &rc);
Response::ResponseCode cmdJoinRoom(const Command_JoinRoom &cmd, ResponseContainer &rc); Response::ResponseCode cmdJoinRoom(const Command_JoinRoom &cmd, ResponseContainer &rc);
Response::ResponseCode cmdListUsers(const Command_ListUsers &cmd, ResponseContainer &rc); Response::ResponseCode cmdListUsers(const Command_ListUsers &cmd, ResponseContainer &rc);
Response::ResponseCode cmdLeaveRoom(const Command_LeaveRoom &cmd, Server_Room *room, ResponseContainer &rc); Response::ResponseCode cmdLeaveRoom(const Command_LeaveRoom &cmd, Server_Room *room, ResponseContainer &rc);
Response::ResponseCode cmdRoomSay(const Command_RoomSay &cmd, Server_Room *room, ResponseContainer &rc); Response::ResponseCode cmdRoomSay(const Command_RoomSay &cmd, Server_Room *room, ResponseContainer &rc);
Response::ResponseCode cmdCreateGame(const Command_CreateGame &cmd, Server_Room *room, ResponseContainer &rc); Response::ResponseCode cmdCreateGame(const Command_CreateGame &cmd, Server_Room *room, ResponseContainer &rc);
Response::ResponseCode cmdJoinGame(const Command_JoinGame &cmd, Server_Room *room, ResponseContainer &rc); Response::ResponseCode cmdJoinGame(const Command_JoinGame &cmd, Server_Room *room, ResponseContainer &rc);
Response::ResponseCode processSessionCommandContainer(const CommandContainer &cont, ResponseContainer &rc); Response::ResponseCode processSessionCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
virtual Response::ResponseCode processExtendedSessionCommand(int cmdType, const SessionCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; } virtual Response::ResponseCode processExtendedSessionCommand(int cmdType, const SessionCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; }
Response::ResponseCode processRoomCommandContainer(const CommandContainer &cont, ResponseContainer &rc); Response::ResponseCode processRoomCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
Response::ResponseCode processGameCommandContainer(const CommandContainer &cont, ResponseContainer &rc); Response::ResponseCode processGameCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
Response::ResponseCode processModeratorCommandContainer(const CommandContainer &cont, ResponseContainer &rc); Response::ResponseCode processModeratorCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
virtual Response::ResponseCode processExtendedModeratorCommand(int cmdType, const ModeratorCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; } virtual Response::ResponseCode processExtendedModeratorCommand(int cmdType, const ModeratorCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; }
Response::ResponseCode processAdminCommandContainer(const CommandContainer &cont, ResponseContainer &rc); Response::ResponseCode processAdminCommandContainer(const CommandContainer &cont, ResponseContainer &rc);
virtual Response::ResponseCode processExtendedAdminCommand(int cmdType, const AdminCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; } virtual Response::ResponseCode processExtendedAdminCommand(int cmdType, const AdminCommand &cmd, ResponseContainer &rc) { return Response::RespFunctionNotAllowed; }
private slots: private slots:
void pingClockTimeout(); void pingClockTimeout();
public slots: public slots:
void prepareDestroy(); void prepareDestroy();
public: public:
Server_ProtocolHandler(Server *_server, Server_DatabaseInterface *_databaseInterface, QObject *parent = 0); Server_ProtocolHandler(Server *_server, Server_DatabaseInterface *_databaseInterface, QObject *parent = 0);
~Server_ProtocolHandler(); ~Server_ProtocolHandler();
bool getAcceptsUserListChanges() const { return acceptsUserListChanges; } bool getAcceptsUserListChanges() const { return acceptsUserListChanges; }
bool getAcceptsRoomListChanges() const { return acceptsRoomListChanges; } bool getAcceptsRoomListChanges() const { return acceptsRoomListChanges; }
virtual QString getAddress() const = 0; virtual QString getAddress() const = 0;
Server_DatabaseInterface *getDatabaseInterface() const { return databaseInterface; } Server_DatabaseInterface *getDatabaseInterface() const { return databaseInterface; }
int getLastCommandTime() const { return timeRunning - lastDataReceived; } int getLastCommandTime() const { return timeRunning - lastDataReceived; }
void processCommandContainer(const CommandContainer &cont); void processCommandContainer(const CommandContainer &cont);
void sendProtocolItem(const Response &item); void sendProtocolItem(const Response &item);
void sendProtocolItem(const SessionEvent &item); void sendProtocolItem(const SessionEvent &item);
void sendProtocolItem(const GameEventContainer &item); void sendProtocolItem(const GameEventContainer &item);
void sendProtocolItem(const RoomEvent &item); void sendProtocolItem(const RoomEvent &item);
}; };
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment