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
@@ -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