diff --git a/src/savegamegamebryo.cpp b/src/savegamegamebryo.cpp index 7b012e22..2cece4e5 100644 --- a/src/savegamegamebryo.cpp +++ b/src/savegamegamebryo.cpp @@ -117,9 +117,6 @@ SaveGameGamebryo::~SaveGameGamebryo() } - - - void SaveGameGamebryo::readSkyrimFile(QFile &saveFile) { char fileID[14]; @@ -172,6 +169,58 @@ void SaveGameGamebryo::readSkyrimFile(QFile &saveFile) } } +void SaveGameGamebryo::readFO4File(QFile &saveFile) +{ + char fileID[13]; + + saveFile.read(fileID, 12); + fileID[12] = '\0'; + if (strncmp(fileID, "FO4_SAVEGAME", 12) != 0) { + throw std::runtime_error(QObject::tr("wrong file format").toUtf8().constData()); + } + + FileSkip(saveFile); // header size + FileSkip(saveFile); // header version, -> 11 + FileRead(saveFile, m_SaveNumber); + + m_PCName = ReadFOSString(saveFile, false); + + unsigned long temp; + FileRead(saveFile, temp); // player level + m_PCLevel = static_cast(temp); + + m_PCLocation = ReadFOSString(saveFile, false); + ReadFOSString(saveFile, false); // playtime as ascii hhh.mm.ss + ReadFOSString(saveFile, false); // race name (HumanRace) + + + FileSkip(saveFile); // ??? + FileSkip(saveFile, 2); // ??? + FileSkip(saveFile, 8); // filetime + +// FileSkip(saveFile, 18); // ??? 18 bytes of data. not completely random, maybe a time stamp? maybe + + unsigned long width, height; + FileRead(saveFile, width); // 640 + FileRead(saveFile, height); // 384 + + QScopedArrayPointer buffer(new unsigned char[width * height * 4]); + saveFile.read(reinterpret_cast(buffer.data()), width * height * 4); + // 640x384 is a bit large + m_Screenshot = QImage(buffer.data(), width, height, QImage::Format_RGBA8888).scaledToWidth(320); + + FileSkip(saveFile); // form version (?) + ReadFOSString(saveFile, false); // game version + FileSkip(saveFile); // plugin info size (?) + + unsigned char pluginCount; + FileRead(saveFile, pluginCount); + + for (int i = 0; i < pluginCount; ++i) { + m_Plugins.push_back(ReadFOSString(saveFile, false)); + } +} + void SaveGameGamebryo::readESSFile(QFile &saveFile) { @@ -332,6 +381,10 @@ void SaveGameGamebryo::readFile(const QString &fileName) setCreationTime(fileName); readSkyrimFile(saveFile); } break; + case GameInfo::TYPE_FALLOUT4: { + setCreationTime(fileName); + readFO4File(saveFile); + } break; } saveFile.close(); diff --git a/src/savegamegamebyro.h b/src/savegamegamebyro.h index e08e1044..029d478f 100644 --- a/src/savegamegamebyro.h +++ b/src/savegamegamebyro.h @@ -85,6 +85,7 @@ Q_OBJECT void readESSFile(QFile &saveFile); void readFOSFile(QFile &saveFile, bool newVegas); + void readFO4File(QFile &saveFile); void readSkyrimFile(QFile &saveFile); void setCreationTime(const QString &fileName); diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index 73267f75..7f9879cf 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -77,7 +77,7 @@ void TransferSavesDialog::refreshLocalSaves() QStringList files = savesDir.entryList(QDir::Files, QDir::Time); - foreach (const QString &filename, files) { + for (const QString &filename : files) { SaveGameGamebryo *save = new SaveGameGamebryo(this, savesDir.absoluteFilePath(filename)); save->setParent(this); m_LocalSaves.push_back(save);