fix(profile): send a default avatar to the hangar

Include the default pilot icon in client profile replies when a save has no selected icon. Preserve chosen and legacy icons without modifying stored saves.
This commit is contained in:
N0VAN0M4LY committed 2026-11-30 04:58:43 +08:00
1 parent a940861295
commit 0c9340f883
4 files changed
+9 -9

No files matched your search

+3 -3
View File
@@ -10,15 +10,15 @@
*/
import { setParam, type BlkBlock } from '@wto/blk';
import type { Account } from '../accounts/account-store.ts';
import { appearance } from './profile-appearance.ts';
import { appearance, DEFAULT_PILOT_ICON } from './profile-appearance.ts';
import { clearStoreCart } from './profile-store-cart.ts';
import { serverTimeNow } from './server-time.ts';
export function clientProfile(saved: BlkBlock, account: Account): BlkBlock {
const profile = structuredClone(saved);
clearStoreCart(profile);
const pilotIcon = appearance(profile).pilotIcon;
if (pilotIcon !== undefined) setParam(profile, 'pilotIcon', { type: 'string', value: pilotIcon });
const pilotIcon = appearance(profile).pilotIcon || DEFAULT_PILOT_ICON;
setParam(profile, 'pilotIcon', { type: 'string', value: pilotIcon });
setParam(profile, 'charDrivenNick', { type: 'string', value: account.nick });
setParam(profile, 'serverTime', { type: 'int64', value: serverTimeNow() });
return profile;
@@ -11,6 +11,7 @@ import { ensureBlock, findBlock, findParam, setParam, type BlkBlock } from '@wto
const TITLE = 'title';
const APPEARANCE = 'pilotAppearance';
export const DEFAULT_PILOT_ICON = 'cardicon_default';
export const APPEARANCE_FIELDS = ['pilotIcon', 'background', 'frame'] as const;
export type AppearanceField = (typeof APPEARANCE_FIELDS)[number];
+2 -3
View File
@@ -3,10 +3,9 @@ import type { Dataset } from '../game-data/datasets/dataset.ts';
import { parseLocalizedCsvMap, type LocalizedCsvText } from '../game-data/datasets/lang-csv.ts';
import { GameFiles } from '../game-data/game-files.ts';
import { stringField } from '../profile/blk-fields.ts';
import { DEFAULT_PILOT_ICON } from '../profile/profile-appearance.ts';
import type { SaveLocation } from './save-editor.ts';
export const DEFAULT_SAVE_AVATAR = 'cardicon_default';
const IMAGE_PACK = 'ui/images.vromfs.bin';
const LANGUAGE_PACK = 'lang.vromfs.bin';
const AVATAR_IMAGE = /^images\/avatars\/(cardicon_[a-z0-9_]+)\.avif$/;
@@ -28,7 +27,7 @@ const saveAvatarImages: Dataset<AvatarImages> = {
const ids = new Set(unlocks.blocks
.filter((entry) => stringField(entry, 'type') === 'pilot')
.map((entry) => stringField(entry, 'id')));
ids.add(DEFAULT_SAVE_AVATAR);
ids.add(DEFAULT_PILOT_ICON);
const labels = new Map<string, LocalizedCsvText>();
const languagePaths = source.listFiles(LANGUAGE_PACK);
+3 -3
View File
@@ -7,7 +7,7 @@ import { DatasetCache } from '../game-data/datasets/dataset-cache.ts';
import { playerRankThresholds } from '../game-data/datasets/rank-settings.ts';
import { GameFiles } from '../game-data/game-files.ts';
import { intField, stringField } from '../profile/blk-fields.ts';
import { appearance, setAppearance } from '../profile/profile-appearance.ts';
import { appearance, DEFAULT_PILOT_ICON, setAppearance } from '../profile/profile-appearance.ts';
import { balanceOf, setGjnCents, setGoldenEagles, setSilverLions } from '../profile/profile-currency.ts';
import { remainingPremiumDays, setPremiumDays } from '../profile/profile-entitlements.ts';
import { ownedVehicles } from '../profile/profile-hangar.ts';
@@ -17,7 +17,7 @@ import { researchPointsOf } from '../profile/profile-vehicle-research.ts';
import { serverTimeNow } from '../profile/server-time.ts';
import { setUpProfiles } from '../profiles-setup.ts';
import { loadTuning } from '../tuning/tuning.ts';
import { DEFAULT_SAVE_AVATAR, readSaveAvatar } from './save-avatars.ts';
import { readSaveAvatar } from './save-avatars.ts';
export interface SaveLocation {
readonly gameFolder: string;
@@ -37,7 +37,7 @@ function summary(account: Account, profile: BlkBlock | undefined, thresholds: re
const xp = profile ? playerExperience(profile) : 0n;
return {
userId, login, nick, created,
avatar: (profile && appearance(profile).pilotIcon) || DEFAULT_SAVE_AVATAR,
avatar: (profile && appearance(profile).pilotIcon) || DEFAULT_PILOT_ICON,
level: thresholds.length ? thresholds.filter((threshold) => xp >= BigInt(threshold)).length : null,
currencies: profile ? { ...balanceOf(profile), freeRp: freeResearchPoints(profile) } : null,
vehicleCount: profile ? ownedVehicles(profile).size : 0,