Add GJN balances, the local store, and redemption codes

Support currency and entitlement purchases, including packs, from the
local store and the in-game payment flow. Expose the supported
redemption codes.
This commit is contained in:
N0VAN0M4LY committed 2026-11-25 06:33:41 +08:00
1 parent d95a5d8f0c
commit cfa6c04aa6
26 files changed
+1352 -29

No files matched your search

@@ -9,12 +9,16 @@
* 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).
*
* PaymentMethods: lets scripts/onlineShop/onlinePurchase.nut offer GJN payment directly
* inside the Golden Eagles and Premium Account windows (stock game_settings.blk restricts it
* with PS4Access; implementation notes).
*/
import { ensureBlock, setParam, type BlkBlock } from '@wto/blk';
export const GAME_SETTINGS_PATH = 'config/game_settings.blk';
export const OFFLINE_FEATURES: readonly string[] = ['AllowedToSkipBaseTutorials'];
export const OFFLINE_FEATURES: readonly string[] = ['AllowedToSkipBaseTutorials', '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[] {
+37 -8
View File
@@ -12,24 +12,53 @@
* Only the `network` block is touched: the rest of settings.blk is engine configuration, not
* server addresses.
*/
import { findBlock } from '@wto/blk';
import { ensureBlock, findBlock, setParam, type BlkBlock } from '@wto/blk';
import { redirectAddresses, type AddressChange } from './network/address-rewrite.ts';
import type { LocalEndpoint } from './network/local-endpoint.ts';
import { editPackBlk } from './pack-edit.ts';
import { editPackBlks } from './pack-edit.ts';
export const ENGINE_SETTINGS_PATH = 'config/settings.blk';
export const GUI_CONFIG_PATH = 'config/gui.blk';
const NETWORK_BLOCK = 'network';
/**
* GUIDs added to config/gui.blk bundles/guid so scripts/onlineShop/entitlementsInfo.nut
* requests GJN prices for GJN-priced Premium Account tiers alongside the stock eagles* packs
*.
*/
export const EXTRA_STORE_BUNDLE_GUIDS: ReadonlyArray<readonly [entitlement: string, guid: string]> = [
['wto_prem_20d', 'A1E00020-5754-4F46-8F00-000000000020'],
['wto_prem_60d', 'A1E00060-5754-4F46-8F00-000000000060'],
['wto_prem_180d', 'A1E00180-5754-4F46-8F00-000000000180'],
];
export interface MainPackResult {
readonly pack: Uint8Array;
readonly addresses: readonly AddressChange[];
}
export function rebuildMainPack(stockPack: Uint8Array, endpoint: LocalEndpoint): MainPackResult {
const { pack, report } = editPackBlk(stockPack, ENGINE_SETTINGS_PATH, (root) => {
const network = findBlock(root, NETWORK_BLOCK);
if (!network) throw new Error(`${ENGINE_SETTINGS_PATH} has no "${NETWORK_BLOCK}" block; this game build differs from the verified ones`);
return redirectAddresses(network, endpoint, [NETWORK_BLOCK]);
});
return { pack, addresses: report };
let addresses: AddressChange[] = [];
const pack = editPackBlks(stockPack, [
{
path: ENGINE_SETTINGS_PATH,
edit: (root) => {
const network = findBlock(root, NETWORK_BLOCK);
if (!network) throw new Error(`${ENGINE_SETTINGS_PATH} has no "${NETWORK_BLOCK}" block; this game build differs from the verified ones`);
addresses = redirectAddresses(network, endpoint, [NETWORK_BLOCK]);
},
},
{
path: GUI_CONFIG_PATH,
edit: (root) => registerStoreBundleGuids(root),
},
]);
return { pack, addresses };
}
function registerStoreBundleGuids(guiRoot: BlkBlock): void {
const guidBlock = ensureBlock(ensureBlock(guiRoot, 'bundles'), 'guid');
for (const [entitlement, guid] of EXTRA_STORE_BUNDLE_GUIDS) {
setParam(guidBlock, entitlement, { type: 'string', value: guid });
}
}
@@ -27,6 +27,8 @@ export function redirectNetworkConfig(root: BlkBlock, endpoint: LocalEndpoint):
function configureEnvironment(environment: BlkBlock, endpoint: LocalEndpoint): void {
setParam(environment, 'enableSslCertCheck', { type: 'bool', value: false });
// Open the local web store directly without SSO redirection to login.gaijin.net.
setParam(environment, 'webstoreURL', { type: 'string', value: `http://${endpoint.host}:${endpoint.port}/store` });
const login = ensureBlock(environment, 'yuplay');
for (const [key, value] of loginOverrides(endpoint)) setParam(login, key, { type: 'string', value });
}