mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-23 22:48:07 -05:00
Use a Dictionary instead of List for Mounting file entries, using their path as key (#3496)
Games with multiple archives can have multiple files with same names through their archives, either for HDD/CD seek optimization with sequential access redundancy or patch versioning We don't even support duplicate file names in archive loading but they'd be added regardless to our list & UI
This commit is contained in:
@@ -63,7 +63,7 @@ public abstract class BaseGameMount
|
|||||||
|
|
||||||
await Mount( new MountContext( this ) );
|
await Mount( new MountContext( this ) );
|
||||||
|
|
||||||
foreach ( var entry in _entries )
|
foreach ( var entry in _entries.Values )
|
||||||
{
|
{
|
||||||
RootFolder.AddResource( entry );
|
RootFolder.AddResource( entry );
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ public abstract class BaseGameMount
|
|||||||
|
|
||||||
Shutdown();
|
Shutdown();
|
||||||
|
|
||||||
foreach ( var entry in _entries )
|
foreach ( var entry in _entries.Values )
|
||||||
{
|
{
|
||||||
entry?.ShutdownInternal();
|
entry?.ShutdownInternal();
|
||||||
}
|
}
|
||||||
@@ -98,19 +98,18 @@ public abstract class BaseGameMount
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly List<ResourceLoader> _entries = [];
|
readonly Dictionary<string, ResourceLoader> _entries = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All of the resources in this game
|
/// All of the resources in this game
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IReadOnlyCollection<ResourceLoader> Resources => _entries.AsReadOnly();
|
public IReadOnlyCollection<ResourceLoader> Resources => _entries.Values;
|
||||||
|
|
||||||
public ResourceFolder RootFolder { get; internal set; }
|
public ResourceFolder RootFolder { get; internal set; }
|
||||||
|
|
||||||
internal void RegisterFileInternal( ResourceLoader entry )
|
internal void RegisterFileInternal( ResourceLoader entry )
|
||||||
{
|
{
|
||||||
_entries.Add( entry );
|
_entries[entry.Path] = entry;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user