mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-09 03:23:24 -08:00
Merge 2916fa45af into 7a7c535158
This commit is contained in:
commit
28706b5b8d
10 changed files with 937 additions and 2 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include "tree/inner_deck_list_node.h"
|
||||
|
||||
#include <QAnyStringView>
|
||||
#include <QCryptographicHash>
|
||||
#include <QDebug>
|
||||
#include <QSet>
|
||||
#include <QSharedPointer>
|
||||
|
|
@ -478,6 +479,16 @@ void DeckList::refreshDeckHash()
|
|||
cachedDeckHash = QString();
|
||||
}
|
||||
|
||||
QString DeckList::contentHash(const QString &nativeDeck)
|
||||
{
|
||||
return QString::fromLatin1(QCryptographicHash::hash(nativeDeck.toUtf8(), QCryptographicHash::Sha1).toHex());
|
||||
}
|
||||
|
||||
QString DeckList::getContentHash() const
|
||||
{
|
||||
return contentHash(writeToString_Native());
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls a given function on each card in the deck.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -297,6 +297,16 @@ public:
|
|||
/** @name Deck identity */
|
||||
///@{
|
||||
QString getDeckHash() const;
|
||||
/**
|
||||
* @brief SHA-1 of a native deck string, covering everything the card hash
|
||||
* ignores (name, printings, banner, tokens, comments, sideboard plans).
|
||||
*
|
||||
* Deck-collection sync hashes the exact string it sends or receives, so both
|
||||
* peers compare the same bytes.
|
||||
*/
|
||||
static QString contentHash(const QString &nativeDeck);
|
||||
/** @brief contentHash() of this deck's native serialisation. */
|
||||
QString getContentHash() const;
|
||||
void refreshDeckHash();
|
||||
///@}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue