daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void DeckList::updateDeckHash()
  2. {
  3.     QStringList cardList;
  4.     for (int i = 0; i < root->size(); i++) {
  5.         InnerDecklistNode *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
  6.         for (int j = 0; j < node->size(); j++) {
  7.             DecklistCardNode *card = dynamic_cast<DecklistCardNode *>(node->at(j));
  8.             for (int k = 0; k < card->getNumber(); ++k)
  9.                 cardList.append((node->getName() == "side" ? "SB:" : "") + card->getName().toLower());
  10.         }
  11.     }
  12.     cardList.sort();
  13.     QByteArray deckHashArray = QCryptographicHash::hash(cardList.join(";").toUtf8(), QCryptographicHash::Sha1);
  14.     quint64 number = (((quint64) (unsigned char) deckHashArray[0]) << 32)
  15.                     + (((quint64) (unsigned char) deckHashArray[1]) << 24)
  16.                     + (((quint64) (unsigned char) deckHashArray[2] << 16))
  17.                     + (((quint64) (unsigned char) deckHashArray[3]) << 8)
  18.                     + (quint64) (unsigned char) deckHashArray[4];
  19.     deckHash = QString::number(number, 32).rightJustified(8, '0');
  20.    
  21.     emit deckHashChanged();
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top