Commit d5c62896 authored by Max-Wilhelm Bruker's avatar Max-Wilhelm Bruker
Browse files

PB: everything compiles except for deck storage

parent 695fde75
[Dolphin] [Dolphin]
Timestamp=2009,10,26,13,45,44 Timestamp=2011,12,31,17,13,2
ViewMode=1 Version=2
[Settings]
ShowDotFiles=true
...@@ -7,32 +7,29 @@ ...@@ -7,32 +7,29 @@
#include "pb/color.pb.h" #include "pb/color.pb.h"
class Color {
private:
int value;
public:
Color(const color &other) : value(other.r() * 65536 + other.g() * 256 + other.b()) { } // TEMPORARY HACK
Color(int _value = 0) : value(_value) { }
Color(int r, int g, int b) : value(r * 65536 + g * 256 + b) { }
int getValue() const { return value; }
#ifdef QT_GUI_LIB #ifdef QT_GUI_LIB
Color(const QColor &_color) inline QColor convertColorToQColor(const color &c)
{ {
value = _color.red() * 65536 + _color.green() * 256 + _color.blue(); return QColor(c.r(), c.g(), c.b());
} }
QColor getQColor() const
{ inline color convertQColorToColor(const QColor &c)
return QColor(value / 65536, (value % 65536) / 256, value % 256); {
} color result;
result.set_r(c.red());
result.set_g(c.green());
result.set_b(c.blue());
return result;
}
#endif #endif
color get_color() const // HACK
{ inline color makeColor(int r, int g, int b)
color c; {
c.set_r(value / 65536); color result;
c.set_g((value % 65536) / 256); result.set_r(r);
c.set_b(value % 256); result.set_g(g);
return c; result.set_b(b);
} return result;
}; }
#endif #endif
\ No newline at end of file
...@@ -4,14 +4,14 @@ message Event_MoveCard { ...@@ -4,14 +4,14 @@ message Event_MoveCard {
extend GameEvent { extend GameEvent {
optional Event_MoveCard ext = 2009; optional Event_MoveCard ext = 2009;
} }
optional sint32 card_id = 1; optional sint32 card_id = 1 [default = -1];
optional string card_name = 2; optional string card_name = 2;
optional string start_zone = 3; optional string start_zone = 3;
optional sint32 position = 4; optional sint32 position = 4 [default = -1];
optional sint32 target_player_id = 5; optional sint32 target_player_id = 5 [default = -1];
optional string target_zone = 6; optional string target_zone = 6;
optional sint32 x = 7; optional sint32 x = 7 [default = -1];
optional sint32 y = 8; optional sint32 y = 8 [default = -1];
optional sint32 new_card_id = 9; optional sint32 new_card_id = 9 [default = -1];
optional bool face_down = 10; optional bool face_down = 10;
} }
...@@ -31,6 +31,6 @@ message GameEvent { ...@@ -31,6 +31,6 @@ message GameEvent {
DUMP_ZONE = 2018; DUMP_ZONE = 2018;
STOP_DUMP_ZONE = 2019; STOP_DUMP_ZONE = 2019;
} }
optional sint32 player_id = 1; optional sint32 player_id = 1 [default = -1];
extensions 100 to max; extensions 100 to max;
} }
...@@ -163,21 +163,6 @@ void SerializableItem_Bool::writeElement(QXmlStreamWriter *xml) ...@@ -163,21 +163,6 @@ void SerializableItem_Bool::writeElement(QXmlStreamWriter *xml)
xml->writeCharacters(data ? "1" : "0"); xml->writeCharacters(data ? "1" : "0");
} }
bool SerializableItem_Color::readElement(QXmlStreamReader *xml)
{
if (xml->isCharacters() && !xml->isWhitespace()) {
bool ok;
int colorValue = xml->text().toString().toInt(&ok);
data = ok ? Color(colorValue) : Color();
}
return SerializableItem::readElement(xml);
}
void SerializableItem_Color::writeElement(QXmlStreamWriter *xml)
{
xml->writeCharacters(QString::number(data.getValue()));
}
bool SerializableItem_DateTime::readElement(QXmlStreamReader *xml) bool SerializableItem_DateTime::readElement(QXmlStreamReader *xml)
{ {
if (xml->isCharacters() && !xml->isWhitespace()) { if (xml->isCharacters() && !xml->isWhitespace()) {
......
...@@ -122,20 +122,6 @@ public: ...@@ -122,20 +122,6 @@ public:
bool isEmpty() const { return data == false; } bool isEmpty() const { return data == false; }
}; };
class SerializableItem_Color : public SerializableItem {
private:
Color data;
protected:
bool readElement(QXmlStreamReader *xml);
void writeElement(QXmlStreamWriter *xml);
public:
SerializableItem_Color(const QString &_itemType, const Color &_data = Color())
: SerializableItem(_itemType), data(_data) { }
const Color &getData() { return data; }
void setData(const Color &_data) { data = _data; }
bool isEmpty() const { return data.getValue() == 0; }
};
class SerializableItem_DateTime : public SerializableItem { class SerializableItem_DateTime : public SerializableItem {
private: private:
QDateTime data; QDateTime data;
......
#ifndef SERVER_ARROW_H #ifndef SERVER_ARROW_H
#define SERVER_ARROW_H #define SERVER_ARROW_H
#include "color.h" #include "pb/color.pb.h"
class Server_Card; class Server_Card;
class Server_ArrowTarget; class Server_ArrowTarget;
...@@ -11,14 +11,14 @@ private: ...@@ -11,14 +11,14 @@ private:
int id; int id;
Server_Card *startCard; Server_Card *startCard;
Server_ArrowTarget *targetItem; Server_ArrowTarget *targetItem;
Color color; color arrowColor;
public: public:
Server_Arrow(int _id, Server_Card *_startCard, Server_ArrowTarget *_targetItem, const Color &_color) Server_Arrow(int _id, Server_Card *_startCard, Server_ArrowTarget *_targetItem, const color &_arrowColor)
: id(_id), startCard(_startCard), targetItem(_targetItem), color(_color) { } : id(_id), startCard(_startCard), targetItem(_targetItem), arrowColor(_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 color; } const color &getColor() const { return arrowColor; }
}; };
#endif #endif
...@@ -21,21 +21,21 @@ ...@@ -21,21 +21,21 @@
#define SERVER_COUNTER_H #define SERVER_COUNTER_H
#include <QString> #include <QString>
#include "color.h" #include "pb/color.pb.h"
class Server_Counter { class Server_Counter {
protected: protected:
int id; int id;
QString name; QString name;
Color color; color counterColor;
int radius; int radius;
int count; int count;
public: public:
Server_Counter(int _id, const QString &_name, const Color &_color, int _radius, int _count = 0) : id(_id), name(_name), color(_color), radius(_radius), count(_count) { } Server_Counter(int _id, const QString &_name, const color &_counterColor, int _radius, int _count = 0) : id(_id), name(_name), counterColor(_counterColor), radius(_radius), count(_count) { }
~Server_Counter() { } ~Server_Counter() { }
int getId() const { return id; } int getId() const { return id; }
QString getName() const { return name; } QString getName() const { return name; }
Color getColor() const { return color; } 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; }
......
...@@ -460,7 +460,8 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski ...@@ -460,7 +460,8 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski
ServerInfo_Player playerInfo; ServerInfo_Player playerInfo;
playerInfo.mutable_properties()->CopyFrom(player->getProperties()); playerInfo.mutable_properties()->CopyFrom(player->getProperties());
if (player == playerWhosAsking) if (player == playerWhosAsking)
playerInfo.set_deck_list(player->getDeck()->writeToString_Native().toStdString()); if (player->getDeck())
playerInfo.set_deck_list(player->getDeck()->writeToString_Native().toStdString());
QList<ServerInfo_Arrow *> arrowList; QList<ServerInfo_Arrow *> arrowList;
QMapIterator<int, Server_Arrow *> arrowIterator(player->getArrows()); QMapIterator<int, Server_Arrow *> arrowIterator(player->getArrows());
...@@ -472,7 +473,7 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski ...@@ -472,7 +473,7 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski
arrowInfo->set_start_player_id(arrow->getStartCard()->getZone()->getPlayer()->getPlayerId()); arrowInfo->set_start_player_id(arrow->getStartCard()->getZone()->getPlayer()->getPlayerId());
arrowInfo->set_start_zone(arrow->getStartCard()->getZone()->getName().toStdString()); arrowInfo->set_start_zone(arrow->getStartCard()->getZone()->getName().toStdString());
arrowInfo->set_start_card_id(arrow->getStartCard()->getId()); arrowInfo->set_start_card_id(arrow->getStartCard()->getId());
arrowInfo->mutable_arrow_color()->CopyFrom(arrow->getColor().get_color()); arrowInfo->mutable_arrow_color()->CopyFrom(arrow->getColor());
if (targetCard) { if (targetCard) {
arrowInfo->set_target_player_id(targetCard->getZone()->getPlayer()->getPlayerId()); arrowInfo->set_target_player_id(targetCard->getZone()->getPlayer()->getPlayerId());
arrowInfo->set_target_zone(targetCard->getZone()->getName().toStdString()); arrowInfo->set_target_zone(targetCard->getZone()->getName().toStdString());
...@@ -487,7 +488,7 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski ...@@ -487,7 +488,7 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski
ServerInfo_Counter *counterInfo = playerInfo.add_counter_list(); ServerInfo_Counter *counterInfo = playerInfo.add_counter_list();
counterInfo->set_id(counter->getId()); counterInfo->set_id(counter->getId());
counterInfo->set_name(counter->getName().toStdString()); counterInfo->set_name(counter->getName().toStdString());
counterInfo->mutable_counter_color()->CopyFrom(counter->getColor().get_color()); counterInfo->mutable_counter_color()->CopyFrom(counter->getColor());
counterInfo->set_radius(counter->getRadius()); counterInfo->set_radius(counter->getRadius());
counterInfo->set_count(counter->getCount()); counterInfo->set_count(counter->getCount());
} }
......
...@@ -99,14 +99,14 @@ void Server_Player::setupZones() ...@@ -99,14 +99,14 @@ void Server_Player::setupZones()
addZone(new Server_CardZone(this, "grave", false, ServerInfo_Zone::PublicZone)); addZone(new Server_CardZone(this, "grave", false, ServerInfo_Zone::PublicZone));
addZone(new Server_CardZone(this, "rfg", false, ServerInfo_Zone::PublicZone)); addZone(new Server_CardZone(this, "rfg", false, ServerInfo_Zone::PublicZone));
addCounter(new Server_Counter(0, "life", Color(255, 255, 255), 25, 20)); addCounter(new Server_Counter(0, "life", makeColor(255, 255, 255), 25, 20));
addCounter(new Server_Counter(1, "w", Color(255, 255, 150), 20, 0)); addCounter(new Server_Counter(1, "w", makeColor(255, 255, 150), 20, 0));
addCounter(new Server_Counter(2, "u", Color(150, 150, 255), 20, 0)); addCounter(new Server_Counter(2, "u", makeColor(150, 150, 255), 20, 0));
addCounter(new Server_Counter(3, "b", Color(150, 150, 150), 20, 0)); addCounter(new Server_Counter(3, "b", makeColor(150, 150, 150), 20, 0));
addCounter(new Server_Counter(4, "r", Color(250, 150, 150), 20, 0)); addCounter(new Server_Counter(4, "r", makeColor(250, 150, 150), 20, 0));
addCounter(new Server_Counter(5, "g", Color(150, 255, 150), 20, 0)); addCounter(new Server_Counter(5, "g", makeColor(150, 255, 150), 20, 0));
addCounter(new Server_Counter(6, "x", Color(255, 255, 255), 20, 0)); addCounter(new Server_Counter(6, "x", makeColor(255, 255, 255), 20, 0));
addCounter(new Server_Counter(7, "storm", Color(255, 255, 255), 20, 0)); addCounter(new Server_Counter(7, "storm", makeColor(255, 255, 255), 20, 0));
initialCards = 7; initialCards = 7;
...@@ -467,7 +467,8 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car ...@@ -467,7 +467,8 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
Event_MoveCard eventOthers; Event_MoveCard eventOthers;
eventOthers.set_start_zone(startzone->getName().toStdString()); eventOthers.set_start_zone(startzone->getName().toStdString());
eventOthers.set_target_player_id(targetzone->getPlayer()->getPlayerId()); eventOthers.set_target_player_id(targetzone->getPlayer()->getPlayerId());
eventOthers.set_target_zone(targetzone->getName().toStdString()); if (startzone != targetzone)
eventOthers.set_target_zone(targetzone->getName().toStdString());
eventOthers.set_x(newX); eventOthers.set_x(newX);
eventOthers.set_y(y); eventOthers.set_y(y);
eventOthers.set_face_down(thisCardProperties->face_down()); eventOthers.set_face_down(thisCardProperties->face_down());
......
...@@ -532,7 +532,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd ...@@ -532,7 +532,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
server->serverMutex.lock(); server->serverMutex.lock();
QList<ServerInfo_Game *> gameList;
QMapIterator<int, Server_Room *> roomIterator(server->getRooms()); QMapIterator<int, Server_Room *> roomIterator(server->getRooms());
QMutexLocker gameListLocker(&gameListMutex); QMutexLocker gameListLocker(&gameListMutex);
while (roomIterator.hasNext()) { while (roomIterator.hasNext()) {
...@@ -613,8 +612,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdGetGamesOfUser(const Command_G ...@@ -613,8 +612,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdGetGamesOfUser(const Command_G
return Response::RespNameNotFound; return Response::RespNameNotFound;
Response_GetGamesOfUser *re = new Response_GetGamesOfUser; Response_GetGamesOfUser *re = new Response_GetGamesOfUser;
QList<ServerInfo_Room *> roomList;
QList<ServerInfo_Game *> gameList;
QMapIterator<int, Server_Room *> roomIterator(server->getRooms()); QMapIterator<int, Server_Room *> roomIterator(server->getRooms());
while (roomIterator.hasNext()) { while (roomIterator.hasNext()) {
Server_Room *room = roomIterator.next().value(); Server_Room *room = roomIterator.next().value();
...@@ -1574,7 +1571,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdDumpZone(const Command_DumpZon ...@@ -1574,7 +1571,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdDumpZone(const Command_DumpZon
zoneInfo->set_with_coords(zone->hasCoords()); zoneInfo->set_with_coords(zone->hasCoords());
zoneInfo->set_card_count(numberCards < zone->cards.size() ? zone->cards.size() : numberCards); zoneInfo->set_card_count(numberCards < zone->cards.size() ? zone->cards.size() : numberCards);
QList<ServerInfo_Card *> respCardList;
for (int i = 0; (i < zone->cards.size()) && (i < numberCards || numberCards == -1); ++i) { for (int i = 0; (i < zone->cards.size()) && (i < numberCards || numberCards == -1); ++i) {
Server_Card *card = zone->cards[i]; Server_Card *card = zone->cards[i];
QString displayedName = card->getFaceDown() ? QString() : card->getName(); QString displayedName = card->getFaceDown() ? QString() : card->getName();
...@@ -1595,7 +1591,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdDumpZone(const Command_DumpZon ...@@ -1595,7 +1591,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdDumpZone(const Command_DumpZon
cardInfo->set_destroy_on_zone_change(card->getDestroyOnZoneChange()); cardInfo->set_destroy_on_zone_change(card->getDestroyOnZoneChange());
cardInfo->set_doesnt_untap(card->getDoesntUntap()); cardInfo->set_doesnt_untap(card->getDoesntUntap());
QList<ServerInfo_CardCounter *> cardCounterList;
QMapIterator<int, int> cardCounterIterator(card->getCounters()); QMapIterator<int, int> cardCounterIterator(card->getCounters());
while (cardCounterIterator.hasNext()) { while (cardCounterIterator.hasNext()) {
cardCounterIterator.next(); cardCounterIterator.next();
...@@ -1692,7 +1687,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_Reve ...@@ -1692,7 +1687,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_Reve
Event_RevealCards eventPrivate(eventOthers); Event_RevealCards eventPrivate(eventOthers);
QList<ServerInfo_Card *> respCardListPrivate, respCardListOmniscient;
for (int i = 0; i < cardsToReveal.size(); ++i) { for (int i = 0; i < cardsToReveal.size(); ++i) {
Server_Card *card = cardsToReveal[i]; Server_Card *card = cardsToReveal[i];
ServerInfo_Card *cardInfo = eventPrivate.add_cards(); ServerInfo_Card *cardInfo = eventPrivate.add_cards();
...@@ -1710,7 +1704,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_Reve ...@@ -1710,7 +1704,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_Reve
cardInfo->set_destroy_on_zone_change(card->getDestroyOnZoneChange()); cardInfo->set_destroy_on_zone_change(card->getDestroyOnZoneChange());
cardInfo->set_doesnt_untap(card->getDoesntUntap()); cardInfo->set_doesnt_untap(card->getDoesntUntap());
QList<ServerInfo_CardCounter *> cardCounterList;
QMapIterator<int, int> cardCounterIterator(card->getCounters()); QMapIterator<int, int> cardCounterIterator(card->getCounters());
while (cardCounterIterator.hasNext()) { while (cardCounterIterator.hasNext()) {
cardCounterIterator.next(); cardCounterIterator.next();
......
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