feat(cosmetics): save decal and attachment layouts
Handle cln_save_decals and cln_save_attachables and return the complete updated layout block for the affected resource type.
This commit is contained in:
1 parent
c448ed94a7
commit
6d8a3af37a
3 files changed
+58
No files matched your search
@@ -6,6 +6,7 @@ import type { CharActionHandler } from '../char-action.ts';
|
||||
import { acceptEula } from './agreement-actions.ts';
|
||||
import { bulkTrainCrews, trainCrew } from './crew-actions.ts';
|
||||
import { buyAllModificationsAction, buyModificationAction, buySparesAction, enableModificationsAction } from './modification-actions.ts';
|
||||
import { saveDecorLayoutsAction } from './decor-layout-actions.ts';
|
||||
import { entitlementsFull, initialMeta, legacyUserData } from './online-init-actions.ts';
|
||||
import { priceEx } from './price-actions.ts';
|
||||
import { buyAircraft, buySlot } from './purchase-actions.ts';
|
||||
@@ -37,5 +38,7 @@ export function actionTable(deps: ActionDependencies): ReadonlyMap<string, CharA
|
||||
['cln_buy_all_modification', buyAllModificationsAction(deps.profiles, deps.accounts, deps.research)],
|
||||
['cln_buy_spare_aircrafts', buySparesAction(deps.profiles, deps.accounts, deps.research)],
|
||||
['cln_enable_modifications', enableModificationsAction(deps.profiles, deps.accounts)],
|
||||
['cln_save_decals', saveDecorLayoutsAction(deps.profiles, deps.accounts, 'decals')],
|
||||
['cln_save_attachables', saveDecorLayoutsAction(deps.profiles, deps.accounts, 'attachables')],
|
||||
]);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Saving decal and attachable layouts. Both are sent by native functions
|
||||
* whose job types are not profile updates: cln_save_decals is type 0x1f (aces.exe 0x2a1910),
|
||||
* cln_save_attachables type 0x20 (0x2a1c30); the client takes the whole answer as its decals or
|
||||
* attachables block (GameSaveData::onAsyncEconTransComplete 0xeb7a14 / 0xeb7a45). So each answers
|
||||
* the full block of its kind after storing the request.
|
||||
*
|
||||
* Request (lab round 21): <vehicle>{ <skin>{ ... } }
|
||||
*/
|
||||
import type { AccountStore } from '../../accounts/account-store.ts';
|
||||
import { decorLayouts, saveDecorLayouts, type DecorLayoutKind } from '../../profile/profile-decor-layouts.ts';
|
||||
import type { PlayerProfiles } from '../../profile/player-profiles.ts';
|
||||
import type { CharActionHandler } from '../char-action.ts';
|
||||
import { withAccount } from './account-context.ts';
|
||||
|
||||
export function saveDecorLayoutsAction(profiles: PlayerProfiles, accounts: AccountStore, kind: DecorLayoutKind): CharActionHandler {
|
||||
return (context) => withAccount(context, accounts, (account) => {
|
||||
const changes = context.payload;
|
||||
if (!changes) return { kind: 'error', code: 'BAD_PARAMS' };
|
||||
const profile = profiles.update(account.userId, (saved) => saveDecorLayouts(saved, kind, changes));
|
||||
return { kind: 'data', blk: decorLayouts(profile, kind) };
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user