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
872177a5
Commit
872177a5
authored
Jun 23, 2015
by
Fabio Bas
Browse files
Card images blacklist; changed fallback urls
parent
0c24f48a
Changes
3
Show whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabase.cpp
View file @
872177a5
#include
"carddatabase.h"
#include
"settingscache.h"
#include
<QCryptographicHash>
#include
<QDir>
#include
<QDirIterator>
#include
<QFile>
...
...
@@ -212,6 +213,9 @@ CardSet *PictureToLoad::getCurrentSet() const
return
0
;
}
QStringList
PictureLoader
::
md5Blacklist
=
QStringList
()
<<
"db0c48db407a907c16ade38de048a441"
;
// card back returned by gatherer when card is not found
PictureLoader
::
PictureLoader
(
const
QString
&
__picsPath
,
bool
_picDownload
,
bool
_picDownloadHq
,
QObject
*
parent
)
:
QObject
(
parent
),
_picsPath
(
__picsPath
),
picDownload
(
_picDownload
),
picDownloadHq
(
_picDownloadHq
),
...
...
@@ -413,6 +417,18 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
}
const
QByteArray
&
picData
=
reply
->
peek
(
reply
->
size
());
//peek is used to keep the data in the buffer for use by QImageReader
// check if the image is blacklisted
QString
md5sum
=
QCryptographicHash
::
hash
(
picData
,
QCryptographicHash
::
Md5
).
toHex
();
if
(
md5Blacklist
.
contains
(
md5sum
))
{
qDebug
()
<<
"Picture downloaded, but blacklisted ("
<<
md5sum
<<
"), will consider it as not found"
;
picDownloadFailed
();
reply
->
deleteLater
();
startNextPicDownload
();
return
;
}
QImage
testImage
;
QImageReader
imgReader
;
...
...
cockatrice/src/carddatabase.h
View file @
872177a5
...
...
@@ -94,6 +94,7 @@ private:
bool
picDownload
,
picDownloadHq
,
downloadRunning
,
loadQueueRunning
;
void
startNextPicDownload
();
QString
getPicUrl
();
static
QStringList
md5Blacklist
;
public:
PictureLoader
(
const
QString
&
__picsPath
,
bool
_picDownload
,
bool
_picDownloadHq
,
QObject
*
parent
=
0
);
~
PictureLoader
();
...
...
cockatrice/src/settingscache.h
View file @
872177a5
...
...
@@ -3,10 +3,11 @@
#include
<QObject>
// the falbacks are used for cards without a muid
#define PIC_URL_DEFAULT "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!cardid!&type=card"
#define PIC_URL_FALLBACK "http://gatherer.wizards.com/Handlers/Image.ashx?
multiverseid=!cardid
!&type=card"
#define PIC_URL_FALLBACK "http://gatherer.wizards.com/Handlers/Image.ashx?
name=!name
!&type=card"
#define PIC_URL_HQ_DEFAULT "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!cardid!&type=card"
#define PIC_URL_HQ_FALLBACK "http://gatherer.wizards.com/Handlers/Image.ashx?
multiverseid=!cardid
!&type=card"
#define PIC_URL_HQ_FALLBACK "http://gatherer.wizards.com/Handlers/Image.ashx?
name=!name
!&type=card"
// size should be a multiple of 64
#define PIXMAPCACHE_SIZE_DEFAULT 2047
#define PIXMAPCACHE_SIZE_MIN 64
...
...
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