feat(profile): persist notification acknowledgements and hangar preferences
Handle cln_update so acknowledged notifications do not reappear. Persist client preferences and ignore unrelated placeholder blocks.
This commit is contained in:
1 parent
feda31d12a
commit
a2667a16a0
4 files changed
+88
-1
No files matched your search
@@ -39,6 +39,7 @@ import {
|
||||
clanRejectCandidateAction,
|
||||
setClanBestRewardsAction,
|
||||
} from './clan-moderation-actions.ts';
|
||||
import { clientUpdateAction } from './client-update-actions.ts';
|
||||
import { bulkSetGblkAction, getGeneralBlkAction, getMetaBlkAction, setGeneralBlkAction } from './cloud-settings-actions.ts';
|
||||
import { bulkTrainCrews, trainCrew } from './crew-actions.ts';
|
||||
import { purchaseSkillPointsAction, specializeCrewAction, upgradeCrewAction } from './crew-skill-actions.ts';
|
||||
@@ -102,6 +103,7 @@ function coreActionEntries(deps: ActionDependencies): Array<[string, CharActionH
|
||||
['cln_get_initial_meta', initialMeta(deps.accounts, deps.cloudSettings)],
|
||||
['cln_upd_entitlements_full', entitlementsFull(deps.profiles, deps.accounts)],
|
||||
['cln_legacy_get_userdata', legacyUserData(deps.profiles, deps.accounts)],
|
||||
['cln_update', clientUpdateAction(deps.profiles, deps.accounts)],
|
||||
['cln_accept_eula', acceptEula(deps.profiles, deps.accounts)],
|
||||
['cln_set_starting_info', setStartingInfo(deps.profiles, deps.accounts)],
|
||||
['cln_bulk_train_aircraft', bulkTrainCrews(deps.profiles, deps.accounts, deps.crew)],
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* `cln_update` (aces.exe 2.61.0.37 0x29f3ee, job type 3 -> `onUpdateProfile`):
|
||||
* triggered by `save_online_single_job` when the client marks seen user logs as disabled
|
||||
* (`scripts/userLog/userlogUtils.nut` `disableSeenUserlogs`, tag 223) or updates hangar
|
||||
* auto-repair / auto-refill / auto-buy-modifications and map preferences. Answers the whole
|
||||
* updated profile.
|
||||
*/
|
||||
import type { AccountStore } from '../../accounts/account-store.ts';
|
||||
import { applyClientProfileUpdate } from '../../profile/profile-client-settings.ts';
|
||||
import type { PlayerProfiles } from '../../profile/player-profiles.ts';
|
||||
import { ACCEPTED } from '../../research/rule-outcome.ts';
|
||||
import type { CharActionHandler } from '../char-action.ts';
|
||||
import { ruleAction } from './rule-answer.ts';
|
||||
|
||||
export function clientUpdateAction(profiles: PlayerProfiles, accounts: AccountStore): CharActionHandler {
|
||||
return ruleAction(profiles, accounts, (payload) => (profile) => {
|
||||
applyClientProfileUpdate(profile, payload);
|
||||
return ACCEPTED;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Client-writable profile preferences persisted via `cln_update`
|
||||
* (aces.exe 2.61.0.37 `ClientEconomicState::saveOnline` -> `EconomicState::serialize` 0x917870,
|
||||
* mode 0x80 `CHARSRV_GET_FROM_CLIENT`):
|
||||
* - hangar toggles `autoRefillWeapons:b`, `autoRepairAircrafts:b`, `autoBuyModifications:b` (0x918ef0);
|
||||
* - privacy / save metadata `onlineSaveVersion:i`, `allowToBeAddedToContacts:b`, `allowToBeAddedToLB:b` (0x9179d4..0x917a4c);
|
||||
* - `classinessMarkPriorities:i64` (0x92b2cb);
|
||||
* - sub-block `mapPreferences` (0x927530 -> 0x9483d0).
|
||||
*
|
||||
* Empty shell blocks that `saveOnline` (mode 0x20) also emits (`entitlementsInfo{}`,
|
||||
* `pveProgress{}`, `weaponPresets{}` — custom weapon presets use `cln_save_weapon_presets`, and
|
||||
* mode 0x80 skips `weaponPresets` at 0x9677d8) are intentionally ignored so server-authoritative
|
||||
* state is preserved.
|
||||
*/
|
||||
import { ensureBlock, findBlock, findParam, setParam, type BlkBlock } from '@wto/blk';
|
||||
import { disableUserLogs } from './profile-trophies-log.ts';
|
||||
|
||||
const BOOL_SETTINGS = [
|
||||
'autoRefillWeapons',
|
||||
'autoRepairAircrafts',
|
||||
'autoBuyModifications',
|
||||
'allowToBeAddedToContacts',
|
||||
'allowToBeAddedToLB',
|
||||
] as const;
|
||||
|
||||
export function applyClientProfileUpdate(profile: BlkBlock, request: BlkBlock): void {
|
||||
for (const name of BOOL_SETTINGS) {
|
||||
const param = findParam(request, name)?.value;
|
||||
if (param?.type === 'bool') setParam(profile, name, param);
|
||||
}
|
||||
const onlineSaveVer = findParam(request, 'onlineSaveVersion')?.value;
|
||||
if (onlineSaveVer?.type === 'int') setParam(profile, 'onlineSaveVersion', onlineSaveVer);
|
||||
|
||||
const markPriorities = findParam(request, 'classinessMarkPriorities')?.value;
|
||||
if (markPriorities?.type === 'int64') setParam(profile, 'classinessMarkPriorities', markPriorities);
|
||||
|
||||
const mapPreferences = findBlock(request, 'mapPreferences');
|
||||
if (mapPreferences) {
|
||||
const target = ensureBlock(profile, 'mapPreferences');
|
||||
const cloned = structuredClone(mapPreferences);
|
||||
target.params = cloned.params;
|
||||
target.blocks = cloned.blocks;
|
||||
}
|
||||
|
||||
const userlogs = findBlock(request, 'userlogs');
|
||||
if (userlogs) {
|
||||
const idsToDisable = userlogs.blocks
|
||||
.filter((entry) => {
|
||||
const flag = findParam(entry, 'haveToDisable')?.value;
|
||||
return flag?.type === 'bool' && flag.value;
|
||||
})
|
||||
.map((entry) => entry.name);
|
||||
if (idsToDisable.length > 0) disableUserLogs(profile, idsToDisable);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Trophy open counts and UserLog entries in the profile:
|
||||
* - `trophies{ <trophyId>{ count:i=<openCount> } }` (aces.exe 0x92d16b, 0x92d4df);
|
||||
* - `userlogs{ <16-hex-id>{ type:i=<EULT> time:i=<unixSec> roomId:i64=0 body{ ... } } }`
|
||||
* - `userlogs{ <16-hex-id>{ type:i=<EULT> time:i=<unixSec> roomId:i64=0 [disabled:b=yes] body{ ... } } }`
|
||||
* (UserLog::serialize 0x95f160, entry fields 0x95ec30; EULT_OPEN_TROPHY = 30 at 0x1a5599b).
|
||||
*/
|
||||
import { ensureBlock, findBlock, setParam, type BlkBlock, type BlkParam } from '@wto/blk';
|
||||
@@ -52,6 +52,16 @@ export function appendUserLog(profile: BlkBlock, entry: NewUserLogEntry): string
|
||||
return idHex;
|
||||
}
|
||||
|
||||
/** Mark seen user logs as disabled (`cln_update` `haveToDisable:b=yes` -> `disabled:b=yes`, 0x95ed29/0x95ed66). */
|
||||
export function disableUserLogs(profile: BlkBlock, ids: Iterable<string>): void {
|
||||
const logs = findBlock(profile, USERLOGS);
|
||||
if (!logs) return;
|
||||
const targets = new Set(ids);
|
||||
for (const entry of logs.blocks) {
|
||||
if (targets.has(entry.name)) setParam(entry, 'disabled', { type: 'bool', value: true });
|
||||
}
|
||||
}
|
||||
|
||||
/** Keep only the newest `keep` user logs (tuning/limits.jsonc userLogsKept); run on every profile refresh. */
|
||||
export function trimUserLogs(profile: BlkBlock, keep: number): void {
|
||||
const logs = findBlock(profile, USERLOGS);
|
||||
|
||||
Reference in new issue
Block a user