Read rank thresholds and available avatar artwork from the selected copy. Persist avatar selections in the player profile and preserve free research points when a level changes.
26 lines
1.2 KiB
TypeScript
26 lines
1.2 KiB
TypeScript
/**
|
|
* The profile as the char service hands it to the client: the saved profile plus the
|
|
* account data and server clock the char server attaches on the wire.
|
|
*
|
|
* charDrivenNick: the client reads the player's nick from this top-level string when it
|
|
* loads a profile (name looked up at aces.exe 2.61.0.37 0x8fe0aa, value stored at 0x91874d).
|
|
*
|
|
* serverTime:i64: the char server's clock; without it the client
|
|
* takes the server time as 0 and every expiry and time limit is wrong.
|
|
*/
|
|
import { setParam, type BlkBlock } from '@wto/blk';
|
|
import type { Account } from '../accounts/account-store.ts';
|
|
import { appearance } 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 });
|
|
setParam(profile, 'charDrivenNick', { type: 'string', value: account.nick });
|
|
setParam(profile, 'serverTime', { type: 'int64', value: serverTimeNow() });
|
|
return profile;
|
|
}
|