forked from phenom/healer-man
Update Healer Man server
This commit is contained in:
1 parent
39458d5de6
commit
6cc1b9217f
203 files changed
+133929
-31271
No files matched your search
@@ -118,13 +118,31 @@ export function appVersionMeetsMinimum(current: string, minimum: string): boolea
|
||||
return true;
|
||||
}
|
||||
|
||||
type ContentPackFiles = readonly (readonly [string, ContentManifestFile])[];
|
||||
const packFileIndexes = new WeakMap<ContentManifest["files"], ReadonlyMap<string, ContentPackFiles>>();
|
||||
const EMPTY_PACK_FILES: ContentPackFiles = [];
|
||||
|
||||
/** Catalog file maps are immutable; index once instead of scanning during gameplay. */
|
||||
export function filesForContentPack(
|
||||
manifest: ContentManifest,
|
||||
packId: string,
|
||||
): readonly (readonly [string, ContentManifestFile])[] {
|
||||
return Object.entries(manifest.files)
|
||||
.filter(([, entry]) => entry.packId === packId)
|
||||
.sort(([left], [right]) => left.localeCompare(right));
|
||||
let index = packFileIndexes.get(manifest.files);
|
||||
if (!index) {
|
||||
const groups = new Map<string, [string, ContentManifestFile][]>();
|
||||
for (const [logicalPath, entry] of Object.entries(manifest.files)) {
|
||||
let files = groups.get(entry.packId);
|
||||
if (!files) {
|
||||
files = [];
|
||||
groups.set(entry.packId, files);
|
||||
}
|
||||
files.push([logicalPath, entry]);
|
||||
}
|
||||
for (const files of groups.values()) files.sort(([left], [right]) => left.localeCompare(right));
|
||||
index = groups;
|
||||
packFileIndexes.set(manifest.files, index);
|
||||
}
|
||||
return index.get(packId) ?? EMPTY_PACK_FILES;
|
||||
}
|
||||
|
||||
export interface ContentFileIdentity {
|
||||
|
||||
Reference in new issue
Block a user