diff --git a/common/decklist.cpp b/common/decklist.cpp index 3bf61927..478ffb28 100644 --- a/common/decklist.cpp +++ b/common/decklist.cpp @@ -726,12 +726,27 @@ bool DeckList::deleteNode(AbstractDecklistNode *node, InnerDecklistNode *rootNod void DeckList::updateDeckHash() { QStringList cardList; - for (int i = 0; i < root->size(); i++) { + bool isValidDeckList = true; + QSet hashZones, optionalZones; + + hashZones << "main" << "side"; // Zones in deck to be included in hashing process + optionalZones << "tokens"; // Optional zones in deck not included in hashing process + + for (int i = 0; i < root->size(); i++) + { InnerDecklistNode *node = dynamic_cast(root->at(i)); - for (int j = 0; j < node->size(); j++) { - DecklistCardNode *card = dynamic_cast(node->at(j)); - for (int k = 0; k < card->getNumber(); ++k) - cardList.append((node->getName() == "side" ? "SB:" : "") + card->getName().toLower()); + for (int j = 0; j < node->size(); j++) + { + if (hashZones.contains(node->getName())) // Mainboard or Sideboard + { + DecklistCardNode *card = dynamic_cast(node->at(j)); + for (int k = 0; k < card->getNumber(); ++k) + cardList.append((node->getName() == "side" ? "SB:" : "") + card->getName().toLower()); + } + else if (!optionalZones.contains(node->getName())) // Not a valid zone -> cheater? + { + isValidDeckList = false; // Deck is invalid + } } } cardList.sort(); @@ -741,7 +756,7 @@ void DeckList::updateDeckHash() + (((quint64) (unsigned char) deckHashArray[2] << 16)) + (((quint64) (unsigned char) deckHashArray[3]) << 8) + (quint64) (unsigned char) deckHashArray[4]; - deckHash = QString::number(number, 32).rightJustified(8, '0'); + deckHash = (isValidDeckList) ? QString::number(number, 32).rightJustified(8, '0') : "INVALID"; emit deckHashChanged(); }