Skip to content

Commit

Permalink
more mod stuff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Soreepeong committed Jan 10, 2022
1 parent e9bceeb commit 19c4ff0
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 216 deletions.
1 change: 1 addition & 0 deletions XivAlexander/App_ConfigRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ namespace App {
Item<std::vector<std::filesystem::path>> ChainLoadPath_dinput8 = CreateConfigItem<std::vector<std::filesystem::path>>(this, "ChainLoadPath_dinput8");

Item<bool> UseModding = CreateConfigItem(this, "UseModding", false);
Item<bool> CompressModsWheneverPossible = CreateConfigItem(this, "CompressModsWheneverPossible", true);
Item<bool> TtmpFlattenSubdirectoryDisplay = CreateConfigItem(this, "TtmpFlattenSubdirectoryDisplay", false);
Item<bool> TtmpUseSubdirectoryTogglingOnFlattenedView = CreateConfigItem(this, "", false);
Item<bool> TtmpShowDedicatedMenu = CreateConfigItem(this, "TtmpShowDedicatedMenu", false);
Expand Down
14 changes: 9 additions & 5 deletions XivAlexander/App_Misc_VirtualSqPacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ struct App::Misc::VirtualSqPacks::Implementation {
writer.SetSoundEntry(i, Sqex::Sound::ScdWriter::SoundEntry::EmptyEntry());
}
EmptyScd = std::make_shared<Sqex::MemoryRandomAccessStream>(
Sqex::Sqpack::MemoryBinaryEntryProvider("dummy/dummy", std::make_shared<Sqex::MemoryRandomAccessStream>(writer.Export()))
Sqex::Sqpack::MemoryBinaryEntryProvider("dummy/dummy", std::make_shared<Sqex::MemoryRandomAccessStream>(writer.Export()), Config->Runtime.CompressModsWheneverPossible ? Z_BEST_COMPRESSION : Z_NO_COMPRESSION)
.ReadStreamIntoVector<uint8_t>(0));
}

Expand Down Expand Up @@ -782,6 +782,7 @@ struct App::Misc::VirtualSqPacks::Implementation {
exhTable.emplace(pair);

std::string currentCacheKeys("VERSION:3\n");
currentCacheKeys += Config->Runtime.CompressModsWheneverPossible ? "compress:true\n" : "compress:false\n";
{
const auto gameRoot = indexFile.parent_path().parent_path().parent_path();
const auto versionFile = Utils::Win32::Handle::FromCreateFile(gameRoot / "ffxivgame.ver", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0);
Expand Down Expand Up @@ -1375,7 +1376,7 @@ struct App::Misc::VirtualSqPacks::Implementation {

const auto targetPath = cachedDir / entryPathSpec.FullPath;

const auto provider = Sqex::Sqpack::MemoryBinaryEntryProvider(entryPathSpec, std::make_shared<Sqex::MemoryRandomAccessStream>(std::move(*reinterpret_cast<std::vector<uint8_t>*>(&data))));
const auto provider = Sqex::Sqpack::MemoryBinaryEntryProvider(entryPathSpec, std::make_shared<Sqex::MemoryRandomAccessStream>(std::move(*reinterpret_cast<std::vector<uint8_t>*>(&data))), Config->Runtime.CompressModsWheneverPossible ? Z_BEST_COMPRESSION : Z_NO_COMPRESSION);
const auto len = provider.StreamSize();
const auto dv = provider.ReadStreamIntoVector<char>(0, static_cast<SSIZE_T>(len));

Expand Down Expand Up @@ -1584,7 +1585,10 @@ struct App::Misc::VirtualSqPacks::Implementation {
const auto gameRoot = indexPath.parent_path().parent_path().parent_path();
const auto versionFile = Utils::Win32::Handle::FromCreateFile(gameRoot / "ffxivgame.ver", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0);
const auto versionContent = versionFile.Read<char>(0, static_cast<size_t>(versionFile.GetFileSize()));
currentCacheKeys += std::format("SQPACK:{}:{}\n", canonical(gameRoot).wstring(), std::string(versionContent.begin(), versionContent.end()));
currentCacheKeys += std::format("SQPACK:{}:{}:{}\n",
canonical(gameRoot).wstring(),
Config->Runtime.CompressModsWheneverPossible ? "compress" : "nocompress",
std::string(versionContent.begin(), versionContent.end()));
}

if (const auto& configFile = Config->Runtime.OverrideFontConfig.Value(); !configFile.empty()) {
Expand Down Expand Up @@ -1684,9 +1688,9 @@ struct App::Misc::VirtualSqPacks::Implementation {
CharLowerW(&extension[0]);

if (extension == L".tex")
provider = std::make_shared<Sqex::Sqpack::MemoryTextureEntryProvider>(entryPathSpec, stream);
provider = std::make_shared<Sqex::Sqpack::MemoryTextureEntryProvider>(entryPathSpec, stream, Config->Runtime.CompressModsWheneverPossible ? Z_BEST_COMPRESSION : Z_NO_COMPRESSION);
else
provider = std::make_shared<Sqex::Sqpack::MemoryBinaryEntryProvider>(entryPathSpec, stream);
provider = std::make_shared<Sqex::Sqpack::MemoryBinaryEntryProvider>(entryPathSpec, stream, Config->Runtime.CompressModsWheneverPossible ? Z_BEST_COMPRESSION : Z_NO_COMPRESSION);
const auto len = provider->StreamSize();
const auto dv = provider->ReadStreamIntoVector<char>(0, static_cast<SSIZE_T>(len));
progress += stream->StreamSize();
Expand Down
7 changes: 6 additions & 1 deletion XivAlexander/App_Window_MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ void App::Window::MainWindow::SetMenuStates() const {
{
SetMenuState(hMenu, ID_NETWORK_HIGHLATENCYMITIGATION_ENABLE, config.UseNetworkTimingHandler, true);
SetMenuState(hMenu, ID_NETWORK_HIGHLATENCYMITIGATION_MODE_1, config.HighLatencyMitigationMode == HighLatencyMitigationMode::SubtractLatency, true);
SetMenuState(hMenu, ID_NETWORK_HIGHLATENCYMITIGATION_MODE_2, config.HighLatencyMitigationMode == HighLatencyMitigationMode::SimulateRtt, true);
SetMenuState(hMenu, ID_NETWORK_HIGHLATENCYMITIGATION_MODE_2, config.HighLatencyMitigationMode == HighLatencyMitigationMode::SimulateRtt, true, config.FormatStringRes(IDS_MENU_NETWORKLATENCYHANDLEMODE_2, config.ExpectedAnimationLockDurationUs.Value()));
SetMenuState(hMenu, ID_NETWORK_HIGHLATENCYMITIGATION_MODE_3, config.HighLatencyMitigationMode == HighLatencyMitigationMode::SimulateNormalizedRttAndLatency, true);
SetMenuState(hMenu, ID_NETWORK_HIGHLATENCYMITIGATION_USEEARLYPENALTY, config.UseEarlyPenalty, true);
SetMenuState(hMenu, ID_NETWORK_HIGHLATENCYMITIGATION_USELOGGING, config.UseHighLatencyMitigationLogging, true);
Expand All @@ -1014,6 +1014,7 @@ void App::Window::MainWindow::SetMenuStates() const {
SetMenuState(hMenu, ID_MODDING_ENABLE, config.UseModding, true);
SetMenuState(hMenu, ID_MODDING_LOGALLHASHKEYS, config.UseHashTrackerKeyLogging, true);
SetMenuState(hMenu, ID_MODDING_LOGALLFILEACCESS, config.LogAllDataFileRead, true);
SetMenuState(hMenu, ID_MODDING_COMPRESSWHENEVERPOSSIBLE, config.CompressModsWheneverPossible, true);

const auto languageList = config.GetFallbackLanguageList();
SetMenuState(hMenu, ID_MODDING_FALLBACKLANGUAGEPRIORITY_ENTRY1, false, true, config.GetLanguageNameLocalized(languageList[0]));
Expand Down Expand Up @@ -1383,6 +1384,10 @@ void App::Window::MainWindow::OnCommand_Menu_Modding(int menuId) {
config.LogAllDataFileRead = !config.LogAllDataFileRead;
return;

case ID_MODDING_COMPRESSWHENEVERPOSSIBLE:
config.CompressModsWheneverPossible = !config.CompressModsWheneverPossible;
return;

case ID_MODDING_FALLBACKLANGUAGEPRIORITY_ENTRY1: {
auto languageList = config.GetFallbackLanguageList();
languageList.insert(languageList.begin(), languageList[0]);
Expand Down
Loading

0 comments on commit 19c4ff0

Please sign in to comment.