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

@ -109,9 +109,6 @@ namespace Penumbra.Mods
ResolvedFiles.Clear(); ResolvedFiles.Clear();
SwappedFiles.Clear(); SwappedFiles.Clear();
if (!_plugin.Configuration.IsEnabled)
return;
var registeredFiles = new Dictionary< string, string >(); var registeredFiles = new Dictionary< string, string >();
foreach( var (mod, settings) in Mods.GetOrderedAndEnabledModListWithSettings( _plugin.Configuration.InvertModListOrder ) ) foreach( var (mod, settings) in Mods.GetOrderedAndEnabledModListWithSettings( _plugin.Configuration.InvertModListOrder ) )

View file

@ -129,28 +129,31 @@ namespace Penumbra
PluginLog.Log( "[GetResourceHandler] {0}", gameFsPath ); PluginLog.Log( "[GetResourceHandler] {0}", gameFsPath );
} }
var replacementPath = Plugin.ModManager.ResolveSwappedOrReplacementFilePath( gameFsPath ); if (Plugin.Configuration.IsEnabled)
// 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 replacementPath = Plugin.ModManager.ResolveSwappedOrReplacementFilePath( gameFsPath );
}
var cleanPath = replacementPath.Replace( '\\', '/' ); // path must be < 260 because statically defined array length :(
var path = Encoding.ASCII.GetBytes( cleanPath ); if( replacementPath == null || replacementPath.Length >= 260 )
{
return CallOriginalHandler( isSync, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown );
}
var bPath = stackalloc byte[path.Length + 1]; var cleanPath = replacementPath.Replace( '\\', '/' );
Marshal.Copy( path, 0, new IntPtr( bPath ), path.Length ); var path = Encoding.ASCII.GetBytes( cleanPath );
pPath = ( char* )bPath;
Crc32.Init(); var bPath = stackalloc byte[path.Length + 1];
Crc32.Update( path ); Marshal.Copy( path, 0, new IntPtr( bPath ), path.Length );
*pResourceHash = Crc32.Checksum; pPath = ( char* )bPath;
Crc32.Init();
Crc32.Update( path );
*pResourceHash = Crc32.Checksum;
#if DEBUG #if DEBUG
PluginLog.Log( "[GetResourceHandler] resolved {GamePath} to {NewPath}", gameFsPath, replacementPath ); PluginLog.Log( "[GetResourceHandler] resolved {GamePath} to {NewPath}", gameFsPath, replacementPath );
#endif #endif
}
return CallOriginalHandler( isSync, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown ); 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 ) ) if( ImGui.Checkbox( LabelEnabled, ref enabled ) )
{ {
_config.IsEnabled = enabled; _config.IsEnabled = enabled;
_base.ReloadMods();
_configChanged = true; _configChanged = true;
} }
} }