fix(profile): persist vehicle camouflage, loadout, and trim preferences

Accept the full client-writable hangar/<vehicle> field set emitted by AircraftInfo::serialize (mode 0x20/0x80) in cln_update for owned vehicles: lastSkin, lastWeapon, lastBullets0..5 (strings), and aileronTrim/elevatorTrim/rudderTrim (finite reals). Ownership and server-authoritative hangar fields remain untouched, matching the stock chard guard (2.61.0.37 0x938081) and serializer (2.61.0.37 0x940510, 2.61.0.58 0x942f80).

Extends the camouflage persistence fix from PR #17 to cover weapon presets, ammo belts, and flight trims reported on the same cln_update path. Verified root and launcher typecheck and SaveStore + clientProfile round-trip persistence. In-game acceptance is pending.

Co-authored-by: duduyagame <[email protected]>
This commit is contained in:
N0VAN0M4LYandduduyagame committed 2026-12-04 17:47:09 +08:00
1 parent bc35cc89ab
commit f2e73c1cfe
3 files changed
+52 -2

No files matched your search

@@ -2,7 +2,9 @@
* `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. On returning from
* auto-repair / auto-refill / auto-buy-modifications, map preferences, and per-vehicle
* preferences (`hangar/<vehicle>` `lastSkin`, `lastWeapon`, `lastBullets0..5`, and flight
* trims `aileronTrim`/`elevatorTrim`/`rudderTrim`). On returning from
* a stock training mission, the client also reports completion in `missionAwards` while
* `pveProgress` is empty. Answers the whole updated profile.
*/
@@ -5,7 +5,14 @@
* - 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).
* - sub-block `mapPreferences` (0x927530 -> 0x9483d0);
* - per-vehicle `hangar/<vehicle>` client preferences (`AircraftInfo::serialize` mode 0x20/0x80,
* owned vehicles only per the stock chard guard at 0x938081):
* - `lastSkin:t` (2.61.0.37 0x940fbc/0x94111b, 2.61.0.58 0x943a2f/0x943b8e);
* - `lastWeapon:t` (2.61.0.37 0x940ff4/0x941084, 2.61.0.58 0x943a67/0x943af7);
* - `lastBullets0..5:t` (2.61.0.37 0x94078d..0x940914 / 0x940b2c..0x940f8d, 2.61.0.58 0x943200..0x94393e);
* - `aileronTrim:r`, `elevatorTrim:r`, `rudderTrim:r` (2.61.0.37 0x941682..0x941720 / 0x9411e7..0x9412db,
* 2.61.0.58 0x943c7a..0x944119).
*
* Empty shell blocks that `saveOnline` (mode 0x20) also emits (`entitlementsInfo{}`,
* `pveProgress{}`, `weaponPresets{}` — custom weapon presets use `cln_save_weapon_presets`, and
@@ -13,6 +20,7 @@
* state is preserved.
*/
import { ensureBlock, findBlock, findParam, setParam, type BlkBlock } from '@wto/blk';
import { updateOwnedVehicle } from './profile-hangar.ts';
import { disableUserLogs } from './profile-trophies-log.ts';
const BOOL_SETTINGS = [
@@ -23,6 +31,23 @@ const BOOL_SETTINGS = [
'allowToBeAddedToLB',
] as const;
const VEHICLE_STRING_SETTINGS = [
'lastSkin',
'lastWeapon',
'lastBullets0',
'lastBullets1',
'lastBullets2',
'lastBullets3',
'lastBullets4',
'lastBullets5',
] as const;
const VEHICLE_TRIM_SETTINGS = [
'aileronTrim',
'elevatorTrim',
'rudderTrim',
] as const;
/**
* Whether hangar ammunition/expendable auto-refill is enabled (`EconomicState` +0xe979).
* Defaults to `true` when absent from `profile.blk`, matching `aces.exe` 0x90b6a0 and 0x918ef0.
@@ -57,6 +82,10 @@ export function applyClientProfileUpdate(profile: BlkBlock, request: BlkBlock):
target.blocks = cloned.blocks;
}
for (const vehicle of findBlock(request, 'hangar')?.blocks ?? []) {
applyVehicleClientSettings(profile, vehicle);
}
const userlogs = findBlock(request, 'userlogs');
if (userlogs) {
const idsToDisable = userlogs.blocks
@@ -68,3 +97,16 @@ export function applyClientProfileUpdate(profile: BlkBlock, request: BlkBlock):
if (idsToDisable.length > 0) disableUserLogs(profile, idsToDisable);
}
}
function applyVehicleClientSettings(profile: BlkBlock, vehicle: BlkBlock): void {
updateOwnedVehicle(profile, vehicle.name, (entry) => {
for (const name of VEHICLE_STRING_SETTINGS) {
const param = findParam(vehicle, name)?.value;
if (param?.type === 'string') setParam(entry, name, param);
}
for (const name of VEHICLE_TRIM_SETTINGS) {
const param = findParam(vehicle, name)?.value;
if (param?.type === 'real' && Number.isFinite(param.value)) setParam(entry, name, param);
}
});
}
@@ -31,6 +31,12 @@ export function addOwnedVehicle(profile: BlkBlock, vehicle: string): void {
if (!hangar.blocks.some((owned) => owned.name === vehicle)) hangar.blocks.push({ name: vehicle, params: [], blocks: [] });
}
/** Update an owned vehicle's hangar entry in place; ignores vehicles the player does not own. */
export function updateOwnedVehicle(profile: BlkBlock, vehicle: string, update: (entry: BlkBlock) => void): void {
const entry = ownedVehicle(profile, vehicle);
if (entry) update(entry);
}
/** The stock client uses the base rank until it has a non-negative selection. */
export function vehicleMrankDelta(profile: BlkBlock, vehicle: string): number {
return Math.max(0, intField(ownedVehicle(profile, vehicle), MRANK_DELTA));