Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
e76c109f
Commit
e76c109f
authored
Jul 06, 2015
by
Zach
Browse files
Merge pull request #1217 from ZeldaZach/fix_cheat
Prevent Hash Collision
parents
29b83c37
339db24b
Changes
1
Hide whitespace changes
Inline
Side-by-side
common/decklist.cpp
View file @
e76c109f
...
...
@@ -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
<
QString
>
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
<
InnerDecklistNode
*>
(
root
->
at
(
i
));
for
(
int
j
=
0
;
j
<
node
->
size
();
j
++
)
{
DecklistCardNode
*
card
=
dynamic_cast
<
DecklistCardNode
*>
(
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
<
DecklistCardNode
*>
(
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
();
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment