Fix team files and settings not saving properly, and remove FileEngine stuff from DLC
This is done by using absolute paths and removing physfs://
--- a/QTfrontend/game.cpp Tue Mar 27 04:39:31 2018 +0200
+++ b/QTfrontend/game.cpp Tue Mar 27 17:32:23 2018 +0200
@@ -536,7 +536,7 @@
void HWGame::sendCampaignVar(const QByteArray &varToSend)
{
QString varToFind = QString::fromUtf8(varToSend);
- QSettings teamfile(QString("physfs://Teams/%1.hwt").arg(campaignTeam), QSettings::IniFormat, 0);
+ QSettings teamfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(campaignTeam), QSettings::IniFormat, 0);
teamfile.setIniCodec("UTF-8");
QString varValue = teamfile.value("Campaign " + campaign + "/" + varToFind, "").toString();
QByteArray command;
@@ -553,7 +553,7 @@
QString varToWrite = QString::fromUtf8(varVal.left(i));
QString varValue = QString::fromUtf8(varVal.mid(i + 1));
- QSettings teamfile(QString("physfs://Teams/%1.hwt").arg(campaignTeam), QSettings::IniFormat, 0);
+ QSettings teamfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(campaignTeam), QSettings::IniFormat, 0);
teamfile.setIniCodec("UTF-8");
teamfile.setValue("Campaign " + campaign + "/" + varToWrite, varValue);
}
--- a/QTfrontend/team.cpp Tue Mar 27 04:39:31 2018 +0200
+++ b/QTfrontend/team.cpp Tue Mar 27 17:32:23 2018 +0200
@@ -171,7 +171,7 @@
bool HWTeam::loadFromFile()
{
- QSettings teamfile(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name)), QSettings::IniFormat, 0);
+ QSettings teamfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name)), QSettings::IniFormat, 0);
teamfile.setIniCodec("UTF-8");
m_name = teamfile.value("Team/Name", m_name).toString();
m_grave = teamfile.value("Team/Grave", "Statue").toString();
@@ -204,7 +204,7 @@
bool HWTeam::fileExists()
{
- QFile f(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name)));
+ QFile f(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name)));
return f.exists();
}
@@ -220,7 +220,7 @@
{
if(m_isNetTeam)
return false;
- QFile cfgfile(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name)));
+ QFile cfgfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name)));
cfgfile.remove();
return true;
}
@@ -229,12 +229,12 @@
{
if (OldTeamName != m_name)
{
- QFile cfgfile(QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(OldTeamName)));
+ QFile cfgfile(QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(OldTeamName)));
cfgfile.remove();
OldTeamName = m_name;
}
- QString fileName = QString("physfs://Teams/%1.hwt").arg(DataManager::safeFileName(m_name));
+ QString fileName = QString(cfgdir->absolutePath() + "/Teams/%1.hwt").arg(DataManager::safeFileName(m_name));
DataManager::ensureFileExists(fileName);
QSettings teamfile(fileName, QSettings::IniFormat, 0);
teamfile.setIniCodec("UTF-8");
--- a/QTfrontend/ui/page/pagedata.cpp Tue Mar 27 04:39:31 2018 +0200
+++ b/QTfrontend/ui/page/pagedata.cpp Tue Mar 27 17:32:23 2018 +0200
@@ -31,8 +31,6 @@
#include "pagedata.h"
#include "databrowser.h"
#include "hwconsts.h"
-#include "DataManager.h"
-#include "FileEngine.h"
QLayout * PageDataDownload::bodyLayoutDefinition()
{
@@ -197,9 +195,6 @@
out.write(reply->readAll());
out.close();
-
- // now mount it
- FileEngineHandler::mount(fileName);
}
}
@@ -229,7 +224,6 @@
if (m_contentDownloaded)
{
m_contentDownloaded = false;
- //DataManager::instance().reload();
}
}
--- a/QTfrontend/util/DataManager.cpp Tue Mar 27 04:39:31 2018 +0200
+++ b/QTfrontend/util/DataManager.cpp Tue Mar 27 17:32:23 2018 +0200
@@ -172,11 +172,11 @@
{
if(m_settingsFileName.isEmpty())
{
- QFile settingsFile("physfs://settings.ini");
+ QFile settingsFile(cfgdir->absoluteFilePath("settings.ini"));
if(!settingsFile.exists())
{
- QFile oldSettingsFile("physfs://hedgewars.ini");
+ QFile oldSettingsFile(cfgdir->absoluteFilePath("hedgewars.ini"));
settingsFile.open(QFile::WriteOnly);
settingsFile.close();