/** * Char actions of the online initialisation after sign-in, up to the profile. */ import { emptyBlock, setParam } from '@wto/blk'; import type { AccountStore } from '../../accounts/account-store.ts'; import type { CloudSettingsStore } from '../../cloud-settings/cloud-settings-store.ts'; import { clientProfile } from '../../profile/client-profile.ts'; import type { PlayerProfiles } from '../../profile/player-profiles.ts'; import type { CharActionHandler } from '../char-action.ts'; import { withAccount } from './account-context.ts'; /** * cln_get_initial_meta: server-side metadata the client reads in GameSaveData's initial-meta * handling (aces.exe 0xeb5f60). binaryDataMetainfo lists server-side binary files the client * must fetch and compare by hash; the local server has none, so the list is empty and no * downloads follow. generalBlkMeta carries the cloud-settings schema and saved versions/hashes. */ export function initialMeta(accounts?: AccountStore, cloudSettings?: CloudSettingsStore): CharActionHandler { return (context) => { const meta = emptyBlock(); setParam(meta, 'machineId', { type: 'string', value: 'wto_local_machine' }); setParam(meta, 'bestCompression', { type: 'string', value: 'zstd' }); const account = context.userId !== undefined ? accounts?.byUserId(context.userId) : undefined; const generalBlkMeta = cloudSettings ? cloudSettings.buildMetaBlk(account?.userId, 'generalBlkMeta') : emptyBlock('generalBlkMeta'); meta.blocks.push(emptyBlock('binaryDataMetainfo'), generalBlkMeta); return { kind: 'data', blk: meta }; }; } /** * cln_upd_entitlements_full: the profile request of the online initialisation stage * CHAR_PROFILE_RECEIVED (sent at aces.exe 0x29f920 with headers onLogin and resetToken; the * request body is the client's machine description). The answer is the whole profile: the * job (EconomicSerializeJob, type 4) loads it as a BLK, and EconomicSerializeAction:: * performAction (0x295ef0) reads it into the client's profile with the profile serializer * (0x917740) when it is not empty. */ export function entitlementsFull(profiles: PlayerProfiles, accounts: AccountStore): CharActionHandler { return profileAnswer(profiles, accounts); } /** cln_legacy_get_userdata: the whole profile (ClientEconomicState::loadOnline, aces.exe 0x2a23b0). */ export function legacyUserData(profiles: PlayerProfiles, accounts: AccountStore): CharActionHandler { return profileAnswer(profiles, accounts); } function profileAnswer(profiles: PlayerProfiles, accounts: AccountStore): CharActionHandler { return (context) => withAccount(context, accounts, (account) => ({ kind: 'data', blk: clientProfile(profiles.profileOf(account.userId), account), })); }