From 9e7547a1cdc81778da46dbbed6e255c3941894fa Mon Sep 17 00:00:00 2001 From: Guillaume Jacquemin Date: Sun, 29 Oct 2023 16:46:08 +0100 Subject: [PATCH] SaveTool: fix an issue with the file watcher. Closes #32. --- src/SaveTool/SaveTool_FileWatcher.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/SaveTool/SaveTool_FileWatcher.cpp b/src/SaveTool/SaveTool_FileWatcher.cpp index 59b1f61..c35b233 100644 --- a/src/SaveTool/SaveTool_FileWatcher.cpp +++ b/src/SaveTool/SaveTool_FileWatcher.cpp @@ -49,7 +49,9 @@ SaveTool::handleFileAction(efsw::WatchID watch_id, return; } // TODO: actually do something when config files will finally be handled - if(!Utility::String::endsWith(filename, Utility::format("Profile{}.sav", _currentProfile->account()).data())) { + if(!Utility::String::endsWith(filename, Utility::format("Profile{}.sav", _currentProfile->account()).data()) && + filename.find("Unit") == std::string::npos) + { return; } @@ -83,7 +85,8 @@ SaveTool::fileUpdateEvent(SDL_Event& event) { } if(event.user.code == FileMoved) { - old_filename = Containers::String{static_cast(event.user.data2), std::strlen(static_cast(event.user.data2)), nullptr}; + old_filename = Containers::String{static_cast(event.user.data2), + std::strlen(static_cast(event.user.data2)), nullptr}; old_index = ((old_filename[_currentProfile->isDemo() ? 8 : 4] - 0x30) * 10) + (old_filename[_currentProfile->isDemo() ? 9 : 5] - 0x30); } @@ -125,8 +128,8 @@ SaveTool::fileUpdateEvent(SDL_Event& event) { } else { if(_modifiedBySaveTool && _currentMass->filename() == filename) { - auto handle = CreateFileW(Utility::Unicode::widen(Containers::StringView{filename}), GENERIC_READ, 0, - nullptr, OPEN_EXISTING, 0, nullptr); + auto handle = CreateFileW(Utility::Unicode::widen(Containers::StringView{filename}), + GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, nullptr); if(handle && handle != INVALID_HANDLE_VALUE) { CloseHandle(handle); _modifiedBySaveTool = false;