Skip to content

Commit

Permalink
Various updates
Browse files Browse the repository at this point in the history
- Allow plugin management automatically
- Updates to reading archives from INIs
- Remove version check for light plugin parser
- Add some notes for save file headers
  • Loading branch information
Silarn committed Nov 1, 2023
1 parent 21a6cb2 commit 1a127c6
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 46 deletions.
19 changes: 5 additions & 14 deletions src/gamestarfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,12 @@ QString GameStarfield::description() const

MOBase::VersionInfo GameStarfield::version() const
{
return VersionInfo(0, 5, 0, VersionInfo::RELEASE_BETA);
return VersionInfo(1, 0, 0, VersionInfo::RELEASE_CANDIDATE);
}

QList<PluginSetting> GameStarfield::settings() const
{
return QList<PluginSetting>()
<< PluginSetting("enable_plugin_management",
tr("Turn on plugin management. As of Starfield 1.7.33 this "
"REQUIRES fixing 'plugins.txt' with a SFSE plugin. This "
"will do nothing otherwise."),
false)
<< PluginSetting(
"enable_esp_warning",
tr("Show a warning when ESP plugins are enabled in the load order."),
Expand All @@ -153,8 +148,7 @@ QList<PluginSetting> GameStarfield::settings() const
MappingType GameStarfield::mappings() const
{
MappingType result;
if (m_Organizer->pluginSetting(name(), "enable_plugin_management").toBool() &&
testFilePlugins().isEmpty()) {
if (testFilePlugins().isEmpty()) {
for (const QString& profileFile : {"plugins.txt", "loadorder.txt"}) {
result.push_back({m_Organizer->profilePath() + "/" + profileFile,
localAppFolder() + "/" + gameShortName() + "/" + profileFile,
Expand Down Expand Up @@ -300,16 +294,14 @@ QStringList GameStarfield::CCPlugins() const

IPluginGame::SortMechanism GameStarfield::sortMechanism() const
{
if (m_Organizer->pluginSetting(name(), "enable_plugin_management").toBool() &&
testFilePlugins().isEmpty())
if (testFilePlugins().isEmpty())
return IPluginGame::SortMechanism::LOOT;
return IPluginGame::SortMechanism::NONE;
}

IPluginGame::LoadOrderMechanism GameStarfield::loadOrderMechanism() const
{
if (m_Organizer->pluginSetting(name(), "enable_plugin_management").toBool() &&
testFilePlugins().isEmpty())
if (testFilePlugins().isEmpty())
return IPluginGame::LoadOrderMechanism::PluginsTxt;
return IPluginGame::LoadOrderMechanism::None;
}
Expand Down Expand Up @@ -422,8 +414,7 @@ bool GameStarfield::activeOverlay() const

bool GameStarfield::testFilePresent() const
{
if (m_Organizer->pluginSetting(name(), "enable_plugin_management").toBool() &&
!testFilePlugins().isEmpty())
if (!testFilePlugins().isEmpty())
return true;
return false;
}
Expand Down
43 changes: 23 additions & 20 deletions src/starfielddataarchives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,33 @@ QStringList StarfieldDataArchives::archives(const MOBase::IProfile* profile) con
{
QStringList result;

QString iniFile = m_GamePath.absoluteFilePath("Starfield.ini");
result.append(getArchivesFromKey(iniFile, "SResourceArchiveList"));
result.append(getArchivesFromKey(iniFile, "sResourceIndexFileList"));
result.append(getArchivesFromKey(iniFile, "SResourceArchiveMemoryCacheList"));
result.append(getArchivesFromKey(iniFile, "sResourceStartUpArchiveList"));
result.append(getArchivesFromKey(iniFile, "sResourceEnglishVoiceList"));
QString defaultIniFile = m_GamePath.absoluteFilePath("Starfield.ini");
QString customIniFile =
profile->localSettingsEnabled()
? QDir(profile->absolutePath()).absoluteFilePath("StarfieldCustom.ini")
: m_LocalGameDir.absoluteFilePath("StarfieldCustom.ini");
QStringList archiveSettings = {"SResourceArchiveList", "sResourceIndexFileList",
"SResourceArchiveMemoryCacheList",
"sResourceStartUpArchiveList",
"sResourceEnglishVoiceList"};
for (auto setting : archiveSettings) {
auto archives = getArchivesFromKey(customIniFile, setting, 1023);
if (archives.isEmpty())
archives = getArchivesFromKey(defaultIniFile, setting, 1023);
result.append(archives);
}

return result;
}

void StarfieldDataArchives::writeArchiveList(MOBase::IProfile* profile,
const QStringList& before)
{
QString list = before.join(", ");
{}

QString iniFile =
profile->localSettingsEnabled()
? QDir(profile->absolutePath()).absoluteFilePath("Starfield.ini")
: m_LocalGameDir.absoluteFilePath("Starfield.ini");
if (list.length() > 255) {
int splitIdx = list.lastIndexOf(",", 256);
setArchivesToKey(iniFile, "SResourceArchiveList", list.mid(0, splitIdx));
setArchivesToKey(iniFile, "SResourceArchiveList2", list.mid(splitIdx + 2));
} else {
setArchivesToKey(iniFile, "SResourceArchiveList", list);
}
}
void StarfieldDataArchives::addArchive(MOBase::IProfile* profile, int index,
const QString& archiveName)
{}

void StarfieldDataArchives::removeArchive(MOBase::IProfile* profile,
const QString& archiveName)
{}
4 changes: 4 additions & 0 deletions src/starfielddataarchives.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class StarfieldDataArchives : public GamebryoDataArchives
public:
virtual QStringList vanillaArchives() const override;
virtual QStringList archives(const MOBase::IProfile* profile) const override;
virtual void addArchive(MOBase::IProfile* profile, int index,
const QString& archiveName) override;
virtual void removeArchive(MOBase::IProfile* profile,
const QString& archiveName) override;

protected:
const QDir m_GamePath;
Expand Down
32 changes: 20 additions & 12 deletions src/starfieldsavegame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,26 @@ StarfieldSaveGame::StarfieldSaveGame(QString const& fileName, GameStarfield cons
void StarfieldSaveGame::getData(FileWrapper& file) const
{
file.skip<uint32_t>(); // header version
file.skip<uint64_t>(); // zip start location
file.skip<uint64_t>(); // unknown
file.skip<uint64_t>(); // chunk compressed size array start location
file.skip<uint64_t>(); // unknown (0?)
file.setCompressionType(1);
file.openCompressedData(); // long = start, long = size
// double
// float
// long
// long
// short
return;
/*
* Parse following variables then begin decompressing data
* - 64-bit int = compressed data start location
* - 64-bit int = complete uncompressed data size
*/
file.openCompressedData();
/*
* Remaining headers before start of compressed data:
* - 32-bit float (version? appears to be 2.0)
* - 64-bit int - size of uncompressed chunks (250 KiB)
* - 64-bit int - size of byte rows? (16 bytes) used to determine start of each
* compressed chunk
* - 32-bit int - number of chunks?
* - 'ZIP ' - denotes start of chunk compressed size array
* - compressed size array - array of 32-bit ints containing the compressed size of
* each compressed chunk (see number of chunks above)
*/
}

void StarfieldSaveGame::fetchInformationFields(
Expand Down Expand Up @@ -103,9 +113,7 @@ std::unique_ptr<GamebryoSaveGame::DataFields> StarfieldSaveGame::fetchDataFields
file.readInt(); // plugin info size

fields->Plugins = file.readPlugins();
if (saveGameVersion >= 82) {
fields->LightPlugins = file.readLightPlugins();
}
fields->LightPlugins = file.readLightPlugins();
file.closeCompressedData();
file.close();

Expand Down

0 comments on commit 1a127c6

Please sign in to comment.