Fix some bugs.

This commit is contained in:
Ottermandias 2023-03-31 18:35:45 +02:00
parent a2fd070c86
commit 49f1f7020f
5 changed files with 14 additions and 8 deletions

View file

@ -16,7 +16,7 @@ public partial struct MetaFileInfo
private static partial Regex HousingMeta(); private static partial Regex HousingMeta();
[GeneratedRegex( [GeneratedRegex(
@"chara/(?'Type1'[a-z]*)/(?'Pre1'[a-z])(?'Id1'\d{4})(/obj/(?'Type2'[a-z]*)/(?'Pre2'[a-z])(?'Id2'\d{4}))?/\k'Pre1'\k'Id1'(\k'Pre2'\k'Id2')?(_(?'Slot'[a-z]{3}))?\\.meta", @"chara/(?'Type1'[a-z]*)/(?'Pre1'[a-z])(?'Id1'\d{4})(/obj/(?'Type2'[a-z]*)/(?'Pre2'[a-z])(?'Id2'\d{4}))?/\k'Pre1'\k'Id1'(\k'Pre2'\k'Id2')?(_(?'Slot'[a-z]{3}))?\.meta",
RegexOptions.Compiled | RegexOptions.ExplicitCapture)] RegexOptions.Compiled | RegexOptions.ExplicitCapture)]
private static partial Regex CharaMeta(); private static partial Regex CharaMeta();

View file

@ -98,6 +98,7 @@ public class ModFileCollection : IDisposable
_usedPaths.Remove(oldPath.Item2); _usedPaths.Remove(oldPath.Item2);
if (!gamePath.IsEmpty) if (!gamePath.IsEmpty)
{ {
file.SubModUsage[pathIdx] = (oldPath.Item1, gamePath);
_usedPaths.Add(gamePath); _usedPaths.Add(gamePath);
} }
else else

View file

@ -36,7 +36,7 @@ public class ModFileEditor
_modManager.OptionEditor.OptionSetFiles(mod, option.GroupIdx, option.OptionIdx, dict); _modManager.OptionEditor.OptionSetFiles(mod, option.GroupIdx, option.OptionIdx, dict);
_files.UpdatePaths(mod, option); _files.UpdatePaths(mod, option);
Changes = false;
return num; return num;
} }
@ -125,10 +125,15 @@ public class ModFileEditor
{ {
foreach (var file in files) foreach (var file in files)
{ {
foreach (var (_, path) in file.SubModUsage.Where(p => p.Item1 == option)) for (var i = 0; i < file.SubModUsage.Count; ++i)
{ {
var (opt, path) = file.SubModUsage[i];
if (option != opt)
continue;
_files.RemoveUsedPath(option, file, path); _files.RemoveUsedPath(option, file, path);
Changes = true; Changes = true;
--i;
} }
} }
} }

View file

@ -191,6 +191,7 @@ public class ModCacheManager : IDisposable, IReadOnlyList<ModCache>
_cache.AddRange(Enumerable.Range(0, _modManager.Count - _cache.Count).Select(_ => new ModCache())); _cache.AddRange(Enumerable.Range(0, _modManager.Count - _cache.Count).Select(_ => new ModCache()));
Parallel.ForEach(Enumerable.Range(0, _modManager.Count), idx => { Refresh(_cache[idx], _modManager[idx]); }); Parallel.ForEach(Enumerable.Range(0, _modManager.Count), idx => { Refresh(_cache[idx], _modManager[idx]); });
Count = _modManager.Count;
} }
private void OnIdentifierCreation() private void OnIdentifierCreation()
@ -261,11 +262,10 @@ public class ModCacheManager : IDisposable, IReadOnlyList<ModCache>
if (mod.Index >= _cache.Count) if (mod.Index >= _cache.Count)
_cache.AddRange(Enumerable.Range(0, mod.Index - _cache.Count).Select(_ => new ModCache())); _cache.AddRange(Enumerable.Range(0, mod.Index + 1 - _cache.Count).Select(_ => new ModCache()));
else if (mod.Index >= Count) for (var i = Count; i < mod.Index; ++i)
for (var i = Count; i <= mod.Index; ++i) Refresh(_cache[i], _modManager[i]);
_cache[i].Reset(); Count = mod.Index + 1;
return _cache[mod.Index]; return _cache[mod.Index];
} }
} }