diff --git a/apps/server/src/profile/client-profile.ts b/apps/server/src/profile/client-profile.ts index aeb21e4..0bfc00e 100644 --- a/apps/server/src/profile/client-profile.ts +++ b/apps/server/src/profile/client-profile.ts @@ -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; diff --git a/apps/server/src/profile/profile-appearance.ts b/apps/server/src/profile/profile-appearance.ts index 65b62a4..e9898bf 100644 --- a/apps/server/src/profile/profile-appearance.ts +++ b/apps/server/src/profile/profile-appearance.ts @@ -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]; diff --git a/apps/server/src/saves/save-avatars.ts b/apps/server/src/saves/save-avatars.ts index 15719ce..afb83d8 100644 --- a/apps/server/src/saves/save-avatars.ts +++ b/apps/server/src/saves/save-avatars.ts @@ -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 = { 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(); const languagePaths = source.listFiles(LANGUAGE_PACK); diff --git a/apps/server/src/saves/save-editor.ts b/apps/server/src/saves/save-editor.ts index 5f189ef..a9c18d7 100644 --- a/apps/server/src/saves/save-editor.ts +++ b/apps/server/src/saves/save-editor.ts @@ -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,