diff --git a/apps/esmtool/esmtool.cpp b/apps/esmtool/esmtool.cpp index a36996ff4f..13f222ed72 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -341,7 +341,7 @@ namespace { std::cout << "Author: " << esm.getAuthor() << '\n' << "Description: " << esm.getDesc() << '\n' - << "File format version: " << esm.getFVer() << '\n'; + << "File format version: " << esm.esmVersionF() << '\n'; std::vector masterData = esm.getGameFiles(); if (!masterData.empty()) { @@ -508,7 +508,7 @@ namespace ToUTF8::Utf8Encoder encoder(ToUTF8::calculateEncoding(info.encoding)); esm.setEncoder(&encoder); esm.setHeader(data.mHeader); - esm.setVersion(ESM::VER_13); + esm.setVersion(ESM::VER_130); esm.setRecordCount(recordCount); std::fstream save(info.outname, std::fstream::out | std::fstream::binary); diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index f8ecc67998..9b7bb11f09 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -489,7 +489,7 @@ void ContentSelectorModel::ContentModel::addFiles(const QString& path, bool newf fileReader.setEncoder(&encoder); fileReader.open(std::move(stream), filepath); file->setAuthor(QString::fromUtf8(fileReader.getAuthor().c_str())); - file->setFormat(fileReader.getFormatVersion()); + file->setFormat(QString::number(fileReader.esmVersionF())); file->setDescription(QString::fromUtf8(fileReader.getDesc().c_str())); for (const auto& master : fileReader.getGameFiles()) file->addGameFile(QString::fromUtf8(master.name.c_str())); @@ -505,11 +505,11 @@ void ContentSelectorModel::ContentModel::addFiles(const QString& path, bool newf case ESM::Format::Tes4: { ToUTF8::StatelessUtf8Encoder encoder(ToUTF8::calculateEncoding(mEncoding.toStdString())); - ESM4::Reader reader(std::move(stream), filepath, nullptr, &encoder, true); - file->setAuthor(QString::fromUtf8(reader.getAuthor().c_str())); - file->setFormat(reader.esmVersion()); - file->setDescription(QString::fromUtf8(reader.getDesc().c_str())); - for (const auto& master : reader.getGameFiles()) + ESM4::Reader fileReader(std::move(stream), filepath, nullptr, &encoder, true); + file->setAuthor(QString::fromUtf8(fileReader.getAuthor().c_str())); + file->setFormat(QString::number(fileReader.esmVersionF())); + file->setDescription(QString::fromUtf8(fileReader.getDesc().c_str())); + for (const auto& master : fileReader.getGameFiles()) file->addGameFile(QString::fromUtf8(master.name.c_str())); break; } diff --git a/components/contentselector/model/esmfile.cpp b/components/contentselector/model/esmfile.cpp index 75a0adb45e..7c62299048 100644 --- a/components/contentselector/model/esmfile.cpp +++ b/components/contentselector/model/esmfile.cpp @@ -26,7 +26,7 @@ void ContentSelectorModel::EsmFile::setDate(const QDateTime& modified) mModified = modified; } -void ContentSelectorModel::EsmFile::setFormat(int format) +void ContentSelectorModel::EsmFile::setFormat(const QString& format) { mVersion = format; } @@ -51,8 +51,7 @@ QByteArray ContentSelectorModel::EsmFile::encodedData() const QByteArray encodedData; QDataStream stream(&encodedData, QIODevice::WriteOnly); - stream << mFileName << mAuthor << QString::number(mVersion) << mModified.toString() << mPath << mDescription - << mGameFiles; + stream << mFileName << mAuthor << mVersion << mModified.toString() << mPath << mDescription << mGameFiles; return encodedData; } diff --git a/components/contentselector/model/esmfile.hpp b/components/contentselector/model/esmfile.hpp index 5a04ec8b38..a65c778294 100644 --- a/components/contentselector/model/esmfile.hpp +++ b/components/contentselector/model/esmfile.hpp @@ -40,7 +40,7 @@ namespace ContentSelectorModel void setAuthor(const QString& author); void setSize(const int size); void setDate(const QDateTime& modified); - void setFormat(const int format); + void setFormat(const QString& format); void setFilePath(const QString& path); void setGameFiles(const QStringList& gameFiles); void setDescription(const QString& description); @@ -51,7 +51,7 @@ namespace ContentSelectorModel QString fileName() const { return mFileName; } QString author() const { return mAuthor; } QDateTime modified() const { return mModified; } - ESM::FormatVersion formatVersion() const { return mVersion; } + QString formatVersion() const { return mVersion; } QString filePath() const { return mPath; } /// @note Contains file names, not paths. @@ -76,7 +76,7 @@ namespace ContentSelectorModel private: QString mTooltipTemlate = tr( "Author: %1
" - "Version: %2
" + "Format version: %2
" "Modified: %3
" "Path:
%4
" "
Description:
%5
" @@ -85,7 +85,7 @@ namespace ContentSelectorModel QString mFileName; QString mAuthor; QDateTime mModified; - ESM::FormatVersion mVersion = ESM::DefaultFormatVersion; + QString mVersion = QString::number(ESM::DefaultFormatVersion); QString mPath; QStringList mGameFiles; QString mDescription; diff --git a/components/esm/esmcommon.hpp b/components/esm/esmcommon.hpp index e92ae06806..69b877c9c9 100644 --- a/components/esm/esmcommon.hpp +++ b/components/esm/esmcommon.hpp @@ -13,12 +13,6 @@ namespace ESM { - enum Version - { - VER_12 = 0x3f99999a, - VER_13 = 0x3fa66666 - }; - enum RecordFlag { // This flag exists, but is not used to determine if a record has been deleted while loading diff --git a/components/esm3/esmreader.hpp b/components/esm3/esmreader.hpp index bafc89a74c..461f154001 100644 --- a/components/esm3/esmreader.hpp +++ b/components/esm3/esmreader.hpp @@ -53,9 +53,9 @@ namespace ESM * *************************************************************************/ - int getVer() const { return mHeader.mData.version; } + int getVer() const { return mHeader.mData.version.ui; } int getRecordCount() const { return mHeader.mData.records; } - float getFVer() const { return (mHeader.mData.version == VER_12) ? 1.2f : 1.3f; } + float esmVersionF() const { return (mHeader.mData.version.f); } const std::string& getAuthor() const { return mHeader.mData.author; } const std::string& getDesc() const { return mHeader.mData.desc; } const std::vector& getGameFiles() const { return mHeader.mMaster; } diff --git a/components/esm3/esmwriter.cpp b/components/esm3/esmwriter.cpp index 66788aa924..ad64ced0a4 100644 --- a/components/esm3/esmwriter.cpp +++ b/components/esm3/esmwriter.cpp @@ -84,12 +84,12 @@ namespace ESM unsigned int ESMWriter::getVersion() const { - return mHeader.mData.version; + return mHeader.mData.version.ui; } void ESMWriter::setVersion(unsigned int ver) { - mHeader.mData.version = ver; + mHeader.mData.version.ui = ver; } void ESMWriter::setType(int type) diff --git a/components/esm3/loadregn.cpp b/components/esm3/loadregn.cpp index 5148a446c2..63e785882e 100644 --- a/components/esm3/loadregn.cpp +++ b/components/esm3/loadregn.cpp @@ -2,6 +2,7 @@ #include "esmreader.hpp" #include "esmwriter.hpp" +#include namespace ESM { @@ -83,7 +84,7 @@ namespace ESM esm.writeHNOCString("FNAM", mName); - if (esm.getVersion() == VER_12) + if (esm.getVersion() == VER_120) esm.writeHNT("WEAT", mData.mProbabilities, mData.mProbabilities.size() - 2); else esm.writeHNT("WEAT", mData.mProbabilities); diff --git a/components/esm3/loadtes3.cpp b/components/esm3/loadtes3.cpp index b6fbe76553..eeb2d38761 100644 --- a/components/esm3/loadtes3.cpp +++ b/components/esm3/loadtes3.cpp @@ -9,7 +9,7 @@ namespace ESM void Header::blank() { - mData.version = VER_13; + mData.version.ui = VER_130; mData.type = 0; mData.author.clear(); mData.desc.clear(); @@ -26,7 +26,7 @@ namespace ESM if (esm.isNextSub("HEDR")) { esm.getSubHeader(); - esm.getT(mData.version); + esm.getT(mData.version.ui); esm.getT(mData.type); mData.author = esm.getMaybeFixedStringSize(32); mData.desc = esm.getMaybeFixedStringSize(256); diff --git a/components/esm3/loadtes3.hpp b/components/esm3/loadtes3.hpp index 2f7493e15f..54fd303485 100644 --- a/components/esm3/loadtes3.hpp +++ b/components/esm3/loadtes3.hpp @@ -3,6 +3,7 @@ #include +#include "components/esm/common.hpp" #include "components/esm/esmcommon.hpp" #include "components/esm3/formatversion.hpp" @@ -13,11 +14,7 @@ namespace ESM struct Data { - /* File format version. This is actually a float, the supported - versions are 1.2 and 1.3. These correspond to: - 1.2 = 0x3f99999a and 1.3 = 0x3fa66666 - */ - uint32_t version; + ESM::ESMVersion version; int32_t type; // 0=esp, 1=esm, 32=ess (unused) std::string author; // Author's name std::string desc; // File description