feat(inventory): add external inventory, marketplace, and supply chests

Define external inventory items and support GJN purchases, recycling,
and supply chest drops.
This commit is contained in:
N0VAN0M4LY committed 2026-11-25 07:19:07 +08:00
1 parent 129d796095
commit 415f78e761
27 files changed
+2538 -15

No files matched your search

+7 -1
View File
@@ -10,12 +10,13 @@
* native/wto-net/build.ps1, and its settings wto_ws.cfg). The stock folder is only read.
* The launcher will run the same steps at every launch, with the port the player chose.
*/
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { parseArgs } from 'node:util';
import { rebuildCharPack } from './char-pack.ts';
import { patchExecutable } from './executable.ts';
import { assertWritableCopy, GAME_FILES } from './game-copy.ts';
import { rebuildGuiPack } from './gui-pack.ts';
import { rebuildMainPack } from './main-pack.ts';
import { localEndpoint } from './network/local-endpoint.ts';
import { NETWORK_HOOK_LIBRARY, networkHookSettings } from './network/network-hook.ts';
@@ -63,8 +64,12 @@ function main(): number {
console.log(`settings.blk: ${mainPack.addresses.length} address(es) now point to ${endpoint.host}:${endpoint.port}`);
for (const change of mainPack.addresses) console.log(` ${change.path}: ${change.before} -> ${change.after}`);
const guiPack = rebuildGuiPack(readFileSync(join(values.game, GAME_FILES.guiPack)), endpoint);
console.log('gui.vromfs.bin: local URLs bypass external SSO redirect');
writeOutput(values.out, GAME_FILES.charPack, charPack.pack);
writeOutput(values.out, GAME_FILES.mainPack, mainPack.pack);
writeOutput(values.out, GAME_FILES.guiPack, guiPack);
writeOutput(values.out, GAME_FILES.executable, executable.executable);
const executableFolder = dirname(GAME_FILES.executable);
writeOutput(values.out, join(executableFolder, NETWORK_HOOK_LIBRARY), readFileSync(hookLibraryPath));
@@ -76,6 +81,7 @@ function main(): number {
function writeOutput(folder: string, relativePath: string, content: Uint8Array): void {
const path = join(folder, relativePath);
mkdirSync(dirname(path), { recursive: true });
rmSync(path, { force: true });
writeFileSync(path, content);
console.log(`wrote ${path}`);
}
+1
View File
@@ -9,6 +9,7 @@ import { join, resolve, sep } from 'node:path';
export const GAME_FILES = {
charPack: 'char.vromfs.bin',
mainPack: 'aces.vromfs.bin',
guiPack: 'gui.vromfs.bin',
executable: join('win64', 'aces.exe'),
} as const;
+33
View File
@@ -0,0 +1,33 @@
/**
* Rebuild gui.vromfs.bin so local loopback URLs open directly in the player's browser
* instead of routing through Gaijin's external SSO login endpoint.
*
* Why a client pack edit is required:
* scripts/inventory/inventoryclient.nut getMarketplaceBaseUrl() prepends `auto_login` to
* marketplaceURL. In scripts/onlineshop/url.nut, `auto_login` invokes native SsoLoggedUrlAction
* (yu_sessionProc.cpp:951), which constructs a hardcoded `https://login.gaijin.net/sso/LoginByStoken`
* URL (no option override in YuSession::setOptionStringSync) and hands it to shell_launch().
* Because the external OS browser does not load wto_ws.dll, it connects to the real
* login.gaijin.net; and returning an error from getShortToken falls back to a base64-encoded
* notAuthUrl that shell_launch() cannot open. Skipping `auto_login` when the target URL is the
* local service endpoint lets every local web UI (/store, /trade.gaijin.net) open directly.
*/
import { getFile, putFile, readArchive, writeArchive } from '@wto/vromfs';
import type { LocalEndpoint } from './network/local-endpoint.ts';
export const URL_SCRIPT_PATH = 'scripts/onlineshop/url.nut';
const STOCK_AUTO_LOGIN_LINE = ' let shouldLogin = isInArray(URL_TAG_AUTO_LOGIN, urlTags)';
export function rebuildGuiPack(stockPack: Uint8Array, endpoint: LocalEndpoint): Uint8Array {
const archive = readArchive(stockPack);
const source = Buffer.from(getFile(archive, URL_SCRIPT_PATH)).toString('utf8');
if (!source.includes(STOCK_AUTO_LOGIN_LINE)) {
throw new Error(`${URL_SCRIPT_PATH} does not contain the expected auto_login check; this game build differs from the verified ones`);
}
const localPrefix = `://${endpoint.host}:${endpoint.port}`;
const replacement = `${STOCK_AUTO_LOGIN_LINE} && url.indexof("${localPrefix}") == null`;
const updated = source.replace(STOCK_AUTO_LOGIN_LINE, replacement);
putFile(archive, URL_SCRIPT_PATH, Buffer.from(updated, 'utf8'));
return writeArchive(archive);
}
+1
View File
@@ -6,6 +6,7 @@
export { NETWORK_CONFIG_PATH, rebuildCharPack, type CharPackResult } from './char-pack.ts';
export { patchExecutable, type ExecutableResult } from './executable.ts';
export { assertWritableCopy, GAME_FILES } from './game-copy.ts';
export { URL_SCRIPT_PATH, rebuildGuiPack } from './gui-pack.ts';
export { ENGINE_SETTINGS_PATH, rebuildMainPack, type MainPackResult } from './main-pack.ts';
export { redirectAddresses, type AddressChange } from './network/address-rewrite.ts';
export { hostPort, localEndpoint, localUrl, type LocalEndpoint } from './network/local-endpoint.ts';