fix(protocol): preserve all system face catalog groups
Decode every group in the third face panel and allow IDs absent from the catalog to use the small-face wire format. Keep animation resources dependent on authoritative catalog metadata. Fixes #482
This commit is contained in:
4 files changed
+35
-43
No files matched your search
@@ -123,31 +123,21 @@ export namespace FetchSysFaces {
|
||||
export const deserialize = (_ctx: Deps, body: OidbFetchSysFacesResp): SysFacePackEntry[] => {
|
||||
const packs: SysFacePackEntry[] = [];
|
||||
|
||||
// common + special-big share the same content shape.
|
||||
// All panels contain repeated groups, including unnamed/hidden groups.
|
||||
for (const [source, content] of [
|
||||
['common', body.commonFace],
|
||||
['special-big', body.specialBigFace],
|
||||
['magic', body.specialMagicFace],
|
||||
] as const) {
|
||||
for (const list of content?.emojiList ?? []) {
|
||||
const packIndex = packs.length;
|
||||
packs.push({
|
||||
packName: list.emojiPackName ?? '',
|
||||
packName: list.emojiPackName || (source === 'magic' ? 'MagicFace' : ''),
|
||||
emojis: emojisToEntries(list.emojiDetail ?? [], source, packIndex),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// QQ returns magic faces as a single unnamed bundle. Keep a stable local
|
||||
// name so callers can identify the group across refreshes.
|
||||
const magicEmojis = body.specialMagicFace?.field1?.emojiList ?? [];
|
||||
if (magicEmojis.length > 0) {
|
||||
const packIndex = packs.length;
|
||||
packs.push({
|
||||
packName: 'MagicFace',
|
||||
emojis: emojisToEntries(magicEmojis, 'magic', packIndex),
|
||||
});
|
||||
}
|
||||
|
||||
return packs;
|
||||
};
|
||||
|
||||
|
||||
@@ -46,12 +46,9 @@ interface IndexedCatalog {
|
||||
overlapCount: number;
|
||||
}
|
||||
|
||||
/** Pure classification once an authoritative entry is known. */
|
||||
/** Use animation metadata when available; any numeric id has a small-face encoding. */
|
||||
export function faceWireFor(entry: SysFaceEntry | null | undefined, faceId: number): FaceWire {
|
||||
if (!entry) {
|
||||
throw new Error(`QQ system face id ${faceId} is absent from the current catalog`);
|
||||
}
|
||||
if (isSuperFaceEntry(entry)) {
|
||||
if (entry && isSuperFaceEntry(entry)) {
|
||||
if (entry.aniStickerPackId == null
|
||||
|| entry.aniStickerId == null
|
||||
|| entry.aniStickerType == null) {
|
||||
@@ -133,8 +130,7 @@ export class SysFaceStore {
|
||||
return matches;
|
||||
}
|
||||
|
||||
/** Synchronous classification for callers that already established catalog
|
||||
* readiness. Unknown ids fail instead of guessing a QQ wire shape. */
|
||||
/** Synchronous classification, including IDs no longer listed in a panel. */
|
||||
classify(faceId: number): FaceWire {
|
||||
return faceWireFor(this.lookup(faceId), faceId);
|
||||
}
|
||||
@@ -226,7 +222,7 @@ export class SysFaceStore {
|
||||
async resolveWire(sender: OidbSender, faceId: number): Promise<FaceWire> {
|
||||
const entry = await this.resolve(sender, faceId);
|
||||
if (!entry) {
|
||||
throw new Error(`QQ system face id ${faceId} is absent from the current catalog`);
|
||||
log.debug('system face id %d is not listed in the catalog; sending its small representation', faceId);
|
||||
}
|
||||
return faceWireFor(entry, faceId);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user