Some small fixes/improvements.

This commit is contained in:
Ottermandias 2023-05-27 13:56:43 +02:00
parent 96aaefd3e2
commit f938531e21
6 changed files with 13 additions and 16 deletions

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Dalamud;
using Dalamud.Logging;

View file

@ -3,7 +3,6 @@ using OtterGui.Classes;
using Penumbra.Meta.Manipulations;
using Penumbra.Mods;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;

View file

@ -325,17 +325,12 @@ public class CollectionCacheManager : IDisposable
/// </summary>
public void CreateNecessaryCaches()
{
var tasks = _active.SpecialAssignments.Select(p => p.Value)
Parallel.ForEach(_active.SpecialAssignments.Select(p => p.Value)
.Concat(_active.Individuals.Select(p => p.Collection))
.Prepend(_active.Current)
.Prepend(_active.Default)
.Prepend(_active.Interface)
.Where(CreateCache)
.Select(c => Task.Run(() => CalculateEffectiveFileListInternal(c)))
.ToArray();
Penumbra.Log.Debug($"Creating {tasks.Length} necessary caches.");
Task.WaitAll(tasks);
.Where(CreateCache), CalculateEffectiveFileListInternal);
}
private void OnModDiscoveryStarted()
@ -349,10 +344,7 @@ public class CollectionCacheManager : IDisposable
}
private void OnModDiscoveryFinished()
{
var tasks = Active.Select(c => Task.Run(() => CalculateEffectiveFileListInternal(c))).ToArray();
Task.WaitAll(tasks);
}
=> Parallel.ForEach(Active, CalculateEffectiveFileListInternal);
/// <summary>
/// Update forced files only on framework.

View file

@ -51,11 +51,13 @@ public class CommandHandler : IDisposable
_collectionEditor = collectionEditor;
framework.RunOnFrameworkThread(() =>
{
_commandManager.RemoveHandler(CommandName);
_commandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
{
HelpMessage = "Without arguments, toggles the main window. Use /penumbra help to get further command help.",
ShowInHelp = true,
});
Penumbra.Log.Information($"Registered {CommandName} with Dalamud.");
});
}

View file

@ -141,6 +141,9 @@ public unsafe partial class CharacterUtility : IDisposable
/// <summary> Return all relevant resources to the default resource. </summary>
public void ResetAll()
{
if (!Ready)
return;
foreach (var list in _lists)
list.Dispose();

View file

@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
@ -86,8 +87,9 @@ public class Penumbra : IDalamudPlugin
if (_characterUtility.Ready)
_residentResources.Reload();
}
catch
catch(Exception ex)
{
Log.Error($"Error constructing Penumbra, Disposing again:\n{ex}");
Dispose();
throw;
}