mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-28 09:33:55 -07:00
fixed packet length calculation bug, re-enabled deck selection
This commit is contained in:
parent
314f17091d
commit
38e4781624
7 changed files with 30 additions and 11 deletions
|
|
@ -267,6 +267,15 @@ DeckList::DeckList(DeckList *other)
|
|||
updateDeckHash();
|
||||
}
|
||||
|
||||
DeckList::DeckList(const QString &nativeString)
|
||||
: SerializableItem("cockatrice_deck"), currentZone(0), currentSideboardPlan(0)
|
||||
{
|
||||
root = new InnerDecklistNode;
|
||||
|
||||
QXmlStreamReader xml(nativeString);
|
||||
loadFromXml(&xml);
|
||||
}
|
||||
|
||||
DeckList::~DeckList()
|
||||
{
|
||||
delete root;
|
||||
|
|
@ -360,6 +369,16 @@ void DeckList::loadFromXml(QXmlStreamReader *xml)
|
|||
updateDeckHash();
|
||||
}
|
||||
|
||||
QString DeckList::writeToString_Native()
|
||||
{
|
||||
QString result;
|
||||
QXmlStreamWriter xml(&result);
|
||||
xml.writeStartDocument();
|
||||
write(&xml);
|
||||
xml.writeEndDocument();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DeckList::loadFromFile_Native(QIODevice *device)
|
||||
{
|
||||
QXmlStreamReader xml(device);
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ public:
|
|||
static const QStringList fileNameFilters;
|
||||
DeckList();
|
||||
DeckList(DeckList *other);
|
||||
DeckList(const QString &nativeString);
|
||||
~DeckList();
|
||||
QString getName() const { return name; }
|
||||
QString getComments() const { return comments; }
|
||||
|
|
@ -151,7 +152,7 @@ public:
|
|||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
void loadFromXml(QXmlStreamReader *xml);
|
||||
|
||||
QString writeToString_Native();
|
||||
bool loadFromFile_Native(QIODevice *device);
|
||||
bool saveToFile_Native(QIODevice *device);
|
||||
bool loadFromStream_Plain(QTextStream &stream);
|
||||
|
|
|
|||
|
|
@ -708,17 +708,15 @@ ResponseCode Server_ProtocolHandler::cmdDeckSelect(const Command_DeckSelect &cmd
|
|||
return RespFunctionNotAllowed;
|
||||
|
||||
DeckList *deck;
|
||||
if (cmd.deck_id() == -1) {
|
||||
// if (!cmd->getDeck())
|
||||
// return RespInvalidData;
|
||||
// deck = new DeckList(cmd->getDeck());
|
||||
} else {
|
||||
if (cmd.has_deck_id()) {
|
||||
try {
|
||||
deck = getDeckFromDatabase(cmd.deck_id());
|
||||
} catch(ResponseCode r) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
} else
|
||||
deck = new DeckList(QString::fromStdString(cmd.deck()));
|
||||
|
||||
player->setDeck(deck);
|
||||
|
||||
game->sendGameEvent(new Event_PlayerPropertiesChanged(player->getPlayerId(), player->getProperties()), new Context_DeckSelect(deck->getDeckHash()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue