|
@@ -27,7 +27,7 @@ QString getComponentNameFromId(int id) {
|
|
|
}
|
|
|
|
|
|
void PatchInstaller::createDatFile(int id, QString name, int component, QString path){
|
|
|
- datfiles[id] = *new datfile;
|
|
|
+ datfiles[id] = datfile();
|
|
|
datfiles[id].id = id;
|
|
|
datfiles[id].name = name;
|
|
|
datfiles[id].path = path;
|
|
@@ -42,7 +42,7 @@ void PatchInstaller::createDatFile(int id, QString name, int component, QString
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-QMap<int, PatchInstaller::datfile> PatchInstaller::getDatFiles(){
|
|
|
+const QMap<int, PatchInstaller::datfile>& PatchInstaller::getDatFiles(){
|
|
|
return this->datfiles;
|
|
|
}
|
|
|
|
|
@@ -73,9 +73,6 @@ void PatchInstaller::checkIfUpdatedByGame(){
|
|
|
|
|
|
PatchInstaller::~PatchInstaller() {
|
|
|
deinit();
|
|
|
- delete datfiles[0].file;
|
|
|
- delete datfiles[1].file;
|
|
|
- delete datfiles[3].file;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -98,9 +95,22 @@ bool PatchInstaller::datPathIsRelevant() {
|
|
|
}
|
|
|
|
|
|
void PatchInstaller::deinit() {
|
|
|
- datfiles[0].file->Deinit();
|
|
|
- datfiles[1].file->Deinit();
|
|
|
- datfiles[3].file->Deinit();
|
|
|
+ if (datfiles.find(0) != datfiles.end() && datfiles[0].file) {
|
|
|
+ datfiles[0].file->Deinit();
|
|
|
+ delete datfiles[0].file;
|
|
|
+ datfiles.remove(0);
|
|
|
+ }
|
|
|
+ if (datfiles.find(1) != datfiles.end() && datfiles[1].file) {
|
|
|
+ datfiles[1].file->Deinit();
|
|
|
+ delete datfiles[1].file;
|
|
|
+ datfiles.remove(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (datfiles.find(3) != datfiles.end() && datfiles[3].file) {
|
|
|
+ datfiles[3].file->Deinit();
|
|
|
+ delete datfiles[3].file;
|
|
|
+ datfiles.remove(3);
|
|
|
+ }
|
|
|
emit deinitialized();
|
|
|
}
|
|
|
|
|
@@ -440,6 +450,9 @@ void PatchInstaller::init()
|
|
|
qInfo() << "PatchInstaller: Starting initialisation of LotroDatManager";
|
|
|
qRegisterMetaType<PatchInstaller::Status>();
|
|
|
|
|
|
+
|
|
|
+ deinit();
|
|
|
+
|
|
|
|
|
|
QString game_folder = Settings::getValue("Lotro/game_path").toString();
|
|
|
QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
|
|
@@ -473,11 +486,8 @@ void PatchInstaller::startGame(bool remove_dat_files) {
|
|
|
args << "-skiprawdownload";
|
|
|
}
|
|
|
|
|
|
- datfiles[0].file->Deinit();
|
|
|
- datfiles[1].file->Deinit();
|
|
|
- datfiles[3].file->Deinit();
|
|
|
-
|
|
|
- if(remove_dat_files){
|
|
|
+ deinit();
|
|
|
+ if (remove_dat_files){
|
|
|
QFile::remove(datfiles[0].path);
|
|
|
QFile::remove(datfiles[1].path);
|
|
|
}
|
|
@@ -490,7 +500,6 @@ void PatchInstaller::startGame(bool remove_dat_files) {
|
|
|
|
|
|
qInfo() << "Starting LOTRO. Path =" << game_folder;
|
|
|
|
|
|
- deinit();
|
|
|
|
|
|
QProcess process;
|
|
|
process.startDetached(game_folder + "/LotroLauncher.exe", args, game_folder);
|