Close fastfiles handles during update + fixes
This commit is contained in:
parent
b379e17188
commit
f1e261a7b3
@ -1,5 +1 @@
|
||||
require("loading")
|
||||
|
||||
if (Engine.InFrontend()) then
|
||||
require("download")
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ if (game:issingleplayer()) then
|
||||
end
|
||||
|
||||
if (Engine.InFrontend()) then
|
||||
require("shaderdialog")
|
||||
require("shader_dialog")
|
||||
require("gamemodes")
|
||||
require("no_mode_switch")
|
||||
require("disable_useless_things")
|
||||
|
@ -23,6 +23,8 @@ namespace fastfiles
|
||||
utils::hook::detour db_find_xasset_header_hook;
|
||||
game::dvar_t* g_dump_scripts;
|
||||
|
||||
std::vector<HANDLE> fastfile_handles;
|
||||
|
||||
void db_try_load_x_file_internal(const char* zone_name, const int flags)
|
||||
{
|
||||
console::info("Loading fastfile %s\n", zone_name);
|
||||
@ -189,7 +191,13 @@ namespace fastfiles
|
||||
}
|
||||
}
|
||||
|
||||
return CreateFileA(path.data(), 0x80000000, 1u, 0, 3u, 0x60000000u, 0);
|
||||
const auto handle = CreateFileA(path.data(), 0x80000000, 1u, 0, 3u, 0x60000000u, 0);
|
||||
if (handle != reinterpret_cast<HANDLE>(-1))
|
||||
{
|
||||
fastfile_handles.push_back(handle);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
utils::hook::detour sys_createfile_hook;
|
||||
@ -321,6 +329,14 @@ namespace fastfiles
|
||||
}), &callback, includeOverride);
|
||||
}
|
||||
|
||||
void close_fastfile_handles()
|
||||
{
|
||||
for (const auto& handle : fastfile_handles)
|
||||
{
|
||||
CloseHandle(handle);
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
|
@ -10,4 +10,6 @@ namespace fastfiles
|
||||
|
||||
void enum_assets(const game::XAssetType type,
|
||||
const std::function<void(game::XAssetHeader)>& callback, const bool includeOverride);
|
||||
|
||||
void close_fastfile_handles();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "scheduler.hpp"
|
||||
#include "dvars.hpp"
|
||||
#include "updater.hpp"
|
||||
#include "fastfiles.hpp"
|
||||
#include "game/ui_scripting/execution.hpp"
|
||||
|
||||
#include "version.h"
|
||||
@ -508,6 +509,14 @@ namespace updater
|
||||
return data_.garbage_files;
|
||||
});
|
||||
|
||||
update_data.access([](update_data_t& data_)
|
||||
{
|
||||
if (data_.restart_required)
|
||||
{
|
||||
fastfiles::close_fastfile_handles();
|
||||
}
|
||||
});
|
||||
|
||||
for (const auto& file : garbage_files)
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user