Skip to content

Commit 8ca1c89

Browse files
Fix for changed download URL.
1 parent f7cdd6f commit 8ca1c89

File tree

8 files changed

+55
-113
lines changed

8 files changed

+55
-113
lines changed

Schticker-Book-Rewritten.pro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ SOURCES += main.cpp\
3838
loginworker.cpp \
3939
twofactorwindow.cpp \
4040
patchworker.cpp \
41-
hashworker.cpp \
42-
filelocationchooser.cpp
41+
filelocationchooser.cpp \
42+
utilities.cpp
4343

4444
HEADERS += launcherwindow.h \
4545
globaldefines.h \
@@ -50,8 +50,8 @@ HEADERS += launcherwindow.h \
5050
loginworker.h \
5151
twofactorwindow.h \
5252
patchworker.h \
53-
hashworker.h \
54-
filelocationchooser.h
53+
filelocationchooser.h \
54+
utilities.h
5555

5656
FORMS += launcherwindow.ui \
5757
twofactorwindow.ui \

globaldefines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
#define PATCH_MANIFEST_URL "https://cdn.toontownrewritten.com/content/patchmanifest.txt"
5151

5252
//content distribution URL
53-
#define CDN_URL "https://cdn.toontownrewritten.com/content/patches/"
53+
#define CDN_URL "http://s3.amazonaws.com/download.toontownrewritten.com/patches/"

hashworker.cpp

Lines changed: 0 additions & 60 deletions
This file was deleted.

hashworker.h

Lines changed: 0 additions & 38 deletions
This file was deleted.

updateworker.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "extractionworker.h"
2424
#include "downloadworker.h"
2525
#include "patchworker.h"
26+
#include "utilities.h"
2627

2728
#include <QJsonObject>
2829
#include <QJsonArray>
@@ -35,8 +36,6 @@
3536

3637
UpdateWorker::UpdateWorker(QObject *parent) : QObject(parent)
3738
{
38-
hashWorker = new HashWorker(this);
39-
4039
QSettings settings("Shticker-Book-Rewritten", "Shticker-Book-Rewritten");
4140

4241
settings.beginGroup("FilesPath");
@@ -96,7 +95,7 @@ void UpdateWorker::patchManifestReady(QJsonDocument patchManifest)
9695
if(file.exists())
9796
{
9897
//generate the SHA1 hash of the file to compare with the patch manifest
99-
fileHash = hashWorker->getHash(localFileName);
98+
fileHash = getHash(localFileName);
10099
qDebug() << "Local file's hash is:" << fileHash;
101100

102101
//Check if the hash matches the patch manifest
@@ -129,7 +128,7 @@ void UpdateWorker::patchManifestReady(QJsonDocument patchManifest)
129128
getNewFile(patchObject["filename"].toString(), patchFileName, extractedFileName, patchObject["compPatchHash"].toString());
130129

131130
//verify the downloaded patch is good
132-
if(hashWorker->getHash(extractedFileName) == patchObject["patchHash"].toString())
131+
if(getHash(extractedFileName) == patchObject["patchHash"].toString())
133132
{
134133
qDebug() << "Downloaded patch matches manifest";
135134
}
@@ -144,7 +143,7 @@ void UpdateWorker::patchManifestReady(QJsonDocument patchManifest)
144143
hasBeenPatched = true;
145144

146145
//check if the patch updated the file fully
147-
if(hashWorker->getHash(localFileName) == fileObject["hash"].toString())
146+
if(getHash(localFileName) == fileObject["hash"].toString())
148147
{
149148
qDebug() << "File has been patched fully\n";
150149
fileIsOld = false;
@@ -167,7 +166,7 @@ void UpdateWorker::patchManifestReady(QJsonDocument patchManifest)
167166
getNewFile(fileObject["dl"].toString(), localBz2FileName, localFileName, fileObject["compHash"].toString());
168167

169168
//check to make sure it is up to date
170-
fileHash = hashWorker->getHash(localFileName);
169+
fileHash = getHash(localFileName);
171170
if(fileHash == fileObject["hash"].toString())
172171
{
173172
qDebug() << "Downloaded file's integrity has been verified\n";
@@ -188,7 +187,7 @@ void UpdateWorker::patchManifestReady(QJsonDocument patchManifest)
188187
getNewFile(fileObject["dl"].toString(), localBz2FileName, localFileName, fileObject["compHash"].toString());
189188

190189
//check to make sure it is up to date
191-
fileHash = hashWorker->getHash(localFileName);
190+
fileHash = getHash(localFileName);
192191
if(fileHash == fileObject["hash"].toString())
193192
{
194193
qDebug() << "Downloaded file's integrity has been verified\n";
@@ -269,7 +268,7 @@ void UpdateWorker::getNewFile(QString dlFile, QString localBz2FileName, QString
269268
startDownload(dlFile);
270269

271270
//make sure download succeeded, logging for debugging purposes but still extracting because TTR has been known to not update hashes
272-
QByteArray fileHash = hashWorker->getHash(localBz2FileName);
271+
QByteArray fileHash = getHash(localBz2FileName);
273272

274273
if(fileHash == compHash)
275274
{

updateworker.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#define UPDATEWORKER_H
2323

2424
#include "jsonworker.h"
25-
#include "hashworker.h"
2625

2726
#include <QObject>
2827
#include <QJsonDocument>
@@ -52,7 +51,6 @@ private slots:
5251

5352
private:
5453
JsonWorker *jsonWorker;
55-
HashWorker *hashWorker;
5654
QString filePath;
5755
QString cachePath;
5856

utilities.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "utilities.h"
2+
3+
#include<QString>
4+
#include<QFile>
5+
#include<QCryptographicHash>
6+
#include<QDebug>
7+
8+
QByteArray getHash(QString fileName)
9+
{
10+
QString hashString;
11+
QFile file(fileName);
12+
QByteArray hashArray;
13+
QCryptographicHash *sha1Hash;
14+
15+
//Attempt to open the file
16+
if(!file.open(QFile::ReadOnly))
17+
{
18+
qDebug() << "Unable to read file:" << fileName << ". Error:" << file.errorString() << "\n";
19+
}
20+
else
21+
{
22+
//Load the file's data to process
23+
QByteArray fileContents = file.readAll();
24+
25+
hashArray = sha1Hash->hash(fileContents, QCryptographicHash::Sha1);
26+
}
27+
28+
//clean up the file since we are done with it
29+
file.flush();
30+
file.close();
31+
file.deleteLater();
32+
33+
//return the checksum in hexidecimal format since that is what the manifest requires
34+
return hashArray.toHex();
35+
}

utilities.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef UTILITIES_H
2+
#define UTILITIES_H
3+
4+
#include <QByteArray>
5+
6+
QByteArray getHash(QString);
7+
8+
#endif // UTILITIES_H

0 commit comments

Comments
 (0)