Fix cloud settings replies and persist skipped tutorials
Return the unframed BLK expected by the cloud settings client. Allow the basic ground tutorial to be skipped and save the tutorial preference immediately.
This commit is contained in:
1 parent
533a263d6e
commit
7ef442271f
4 files changed
+63
-12
No files matched your search
@@ -5,10 +5,12 @@
|
||||
* condition:t="" means every player has it (the UI scripts ask with hasFeature, which falls
|
||||
* back to the native local_player_has_feature, scripts/user/features.nut).
|
||||
*
|
||||
* AllowedToSkipBaseTutorials: lets the player skip the base tutorials. The stock tutorial
|
||||
* offer (scripts/tutorials/nextTutorialHandler.nut) enables its skip and close buttons only
|
||||
* with this feature (tutorialsData.nut canSkipByFeature). The offline version makes the
|
||||
* tutorial optional (local verification).
|
||||
* AllowedToSkipBaseTutorials / AllowedToSkipBaseTankTutorials: let the player skip or close
|
||||
* every branch's base tutorial offer. `scripts/tutorials/tutorialsData.nut` gates air and naval
|
||||
* base tutorials on `AllowedToSkipBaseTutorials` and ground base tutorials (`lightTank`,
|
||||
* `lightTank_action`) on `AllowedToSkipBaseTankTutorials`; without both, `NextTutorialHandler`
|
||||
* hides its "do not ask me again" checkbox and close button until the tutorial is started once
|
||||
* (local verification).
|
||||
*
|
||||
* PaymentMethods: lets scripts/onlineShop/onlinePurchase.nut offer GJN payment directly
|
||||
* inside the Golden Eagles and Premium Account windows (stock game_settings.blk restricts it
|
||||
@@ -18,7 +20,11 @@ import { ensureBlock, setParam, type BlkBlock } from '@wto/blk';
|
||||
|
||||
export const GAME_SETTINGS_PATH = 'config/game_settings.blk';
|
||||
|
||||
export const OFFLINE_FEATURES: readonly string[] = ['AllowedToSkipBaseTutorials', 'PaymentMethods'];
|
||||
export const OFFLINE_FEATURES: readonly string[] = [
|
||||
'AllowedToSkipBaseTutorials',
|
||||
'AllowedToSkipBaseTankTutorials',
|
||||
'PaymentMethods',
|
||||
];
|
||||
|
||||
/** Give every player the features; returns the ones that were not on for everyone before. */
|
||||
export function enableFeaturesForEveryone(gameSettings: BlkBlock, names: readonly string[]): string[] {
|
||||
|
||||
@@ -18,21 +18,29 @@ import {
|
||||
import { withAccount } from './account-context.ts';
|
||||
import { headerOrPayloadInt, headerOrPayloadString } from './payload-params.ts';
|
||||
|
||||
/** `cln_get_meta_blk`: returns schema, compression negotiation, and saved block versions/hashes. */
|
||||
/**
|
||||
* `cln_get_meta_blk`: returns schema, compression negotiation, and saved block versions/hashes.
|
||||
* `GetMetaHandler::handleResponse` (0x46659c0 -> 0x3280a50) parses the raw HTTP body directly
|
||||
* with `DataBlock::loadFromStream` without stripping the `'i'` char compression marker.
|
||||
*/
|
||||
export function getMetaBlkAction(accounts: AccountStore, cloudSettings: CloudSettingsStore): CharActionHandler {
|
||||
return (context) => withAccount(context, accounts, (account) => ({
|
||||
kind: 'data',
|
||||
kind: 'raw-blk',
|
||||
blk: cloudSettings.buildMetaBlk(account.userId),
|
||||
}));
|
||||
}
|
||||
|
||||
/** `cln_get_general_blk`: returns `ContainerBlk` (`version:i`, `content { ... }`) for a valid `blkType`. */
|
||||
/**
|
||||
* `cln_get_general_blk`: returns `ContainerBlk` (`version:i`, `content { ... }`) for a valid `blkType`.
|
||||
* `LoadingHandler::handleResponse` (0x4667930 -> `ContainerBlk::load` 0x466a9e0 -> 0x3280a50)
|
||||
* likewise reads bare binary BLK directly from the HTTP response buffer.
|
||||
*/
|
||||
export function getGeneralBlkAction(accounts: AccountStore, cloudSettings: CloudSettingsStore): CharActionHandler {
|
||||
return (context) => withAccount(context, accounts, (account) => {
|
||||
const blkType = headerOrPayloadString(context, 'blkType');
|
||||
if (!blkType || !isSupportedGeneralBlkType(blkType)) return { kind: 'error', code: 'BAD_PARAM' };
|
||||
const stored = cloudSettings.loadContainer(account.userId, blkType) ?? buildContainerBlk(1, emptyBlock('content'));
|
||||
return { kind: 'data', blk: stored };
|
||||
return { kind: 'raw-blk', blk: stored };
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
/**
|
||||
* The char service's three kinds of answer (implementation notes; aces.exe 2.61.0.37,
|
||||
* The char service's answer shapes (implementation notes; aces.exe 2.61.0.37,
|
||||
* CharServerClient::handleReqResult at 0x336d590):
|
||||
* - data: HTTP 200, a compression marker and a BLK;
|
||||
* - data: HTTP 200, a compression marker ('i') and a binary BLK (`loadBlkFromAnswer`, 0x336fd60);
|
||||
* - raw-blk: HTTP 200, a bare binary BLK with no compression marker, for `online_storage`
|
||||
* endpoints (`GetMetaHandler` 0x46659c0 and `LoadingHandler` 0x4667930 -> `0x3280a50`);
|
||||
* - json: HTTP 200, UTF-8 JSON for custom JSON actions;
|
||||
* - done: HTTP 200 with a body starting "!OK", for requests that expect no data;
|
||||
* - error: a body starting "!ERROR:" followed by an error code.
|
||||
*/
|
||||
import { formatBlkText, type BlkBlock } from '@wto/blk';
|
||||
import { encodeBlk, formatBlkText, type BlkBlock } from '@wto/blk';
|
||||
import type { ServiceResponse } from '../server/exchange.ts';
|
||||
import { encodeDataAnswer } from './char-payload.ts';
|
||||
|
||||
export type CharAnswer =
|
||||
| { readonly kind: 'data'; readonly blk: BlkBlock }
|
||||
| { readonly kind: 'raw-blk'; readonly blk: BlkBlock }
|
||||
| { readonly kind: 'json'; readonly data: unknown }
|
||||
| { readonly kind: 'done' }
|
||||
| { readonly kind: 'error'; readonly code: string };
|
||||
@@ -19,6 +23,8 @@ export function toResponse(answer: CharAnswer): ServiceResponse {
|
||||
switch (answer.kind) {
|
||||
case 'data':
|
||||
return { status: 200, headers: BINARY, body: encodeDataAnswer(answer.blk), logNotes: { responseText: formatBlkText(answer.blk) } };
|
||||
case 'raw-blk':
|
||||
return { status: 200, headers: BINARY, body: encodeBlk(answer.blk), logNotes: { responseText: formatBlkText(answer.blk) } };
|
||||
case 'json': {
|
||||
const body = JSON.stringify(answer.data);
|
||||
return { status: 200, headers: JSON_HEADERS, body, logNotes: { responseText: body } };
|
||||
|
||||
Reference in new issue
Block a user