Moved the IsEnabled check from computing effective file list to the hook.

This commit is contained in:
Ottermandias 2021-01-28 11:24:08 +01:00
parent 7e51e663ec
commit b987fe53cb
3 changed files with 21 additions and 22 deletions

View file

@ -108,9 +108,6 @@ namespace Penumbra.Mods
{
ResolvedFiles.Clear();
SwappedFiles.Clear();
if (!_plugin.Configuration.IsEnabled)
return;
var registeredFiles = new Dictionary< string, string >();

View file

@ -127,30 +127,33 @@ namespace Penumbra
if( LogAllFiles )
{
PluginLog.Log( "[GetResourceHandler] {0}", gameFsPath );
}
}
if (Plugin.Configuration.IsEnabled)
{
var replacementPath = Plugin.ModManager.ResolveSwappedOrReplacementFilePath( gameFsPath );
var replacementPath = Plugin.ModManager.ResolveSwappedOrReplacementFilePath( gameFsPath );
// path must be < 260 because statically defined array length :(
if( replacementPath == null || replacementPath.Length >= 260 )
{
return CallOriginalHandler( isSync, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown );
}
// path must be < 260 because statically defined array length :(
if( replacementPath == null || replacementPath.Length >= 260 )
{
return CallOriginalHandler( isSync, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown );
}
var cleanPath = replacementPath.Replace( '\\', '/' );
var path = Encoding.ASCII.GetBytes( cleanPath );
var cleanPath = replacementPath.Replace( '\\', '/' );
var path = Encoding.ASCII.GetBytes( cleanPath );
var bPath = stackalloc byte[path.Length + 1];
Marshal.Copy( path, 0, new IntPtr( bPath ), path.Length );
pPath = ( char* )bPath;
var bPath = stackalloc byte[path.Length + 1];
Marshal.Copy( path, 0, new IntPtr( bPath ), path.Length );
pPath = ( char* )bPath;
Crc32.Init();
Crc32.Update( path );
*pResourceHash = Crc32.Checksum;
Crc32.Init();
Crc32.Update( path );
*pResourceHash = Crc32.Checksum;
#if DEBUG
PluginLog.Log( "[GetResourceHandler] resolved {GamePath} to {NewPath}", gameFsPath, replacementPath );
#endif
PluginLog.Log( "[GetResourceHandler] resolved {GamePath} to {NewPath}", gameFsPath, replacementPath );
#endif
}
return CallOriginalHandler( isSync, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown );
}

View file

@ -63,7 +63,6 @@ namespace Penumbra.UI
if( ImGui.Checkbox( LabelEnabled, ref enabled ) )
{
_config.IsEnabled = enabled;
_base.ReloadMods();
_configChanged = true;
}
}