Everything sat in packages/: two programs next to the small libraries
they use, and the patch data loose at the root. The programs now live in
apps/ and the shared libraries in packages/:
apps/server the local server (was packages/local-service),
package @wto/server
packages/patcher builds the game copy (was packages/build),
package @wto/patcher
patches/exe exe patch definitions (was exe-patches)
patches/gui GUI script patches (was gui-patches)
Inside the server, the network layer folder becomes transport/ so it is
not server/server/, the entry module is server.ts, and startLocalService
and its types become startServer, ServerOptions and RunningServer. The
health answer names the app wto-server, and the TLS files in the data
folder are server.key and server.crt (made again on the next start).
Comments, logs and tool texts say "local server".
The patcher no longer reaches into the server's folder. It read the
default tuning/store.jsonc by a relative path to register bundle GUIDs
for the multi-vehicle packs, which also ignored the player's overrides
in <data>/tuning/. It now takes the pack ids from its caller; the
server exports multiVehiclePackIds(dataFolder), which reads them the way
the running server does. rebuildGuiPack takes the patch folder from its
caller as well.
The development build moves out of the patcher to
scripts/build-game-copy.ts, since it uses both the server and the
patcher. It needs --data (the folder the server will run with) and
defaults the patch folders and the hook library to this repository.
Checked with the root typecheck, check-patches, check-gui,
check-offsets, the native build, a run of build-game-copy.ts into a
scratch folder (12 exe patches, 35 GUI patches, 496 bundle GUIDs as
before) and a server start from apps/server answering wto-server.
BREAKING CHANGE: Use @wto/server and @wto/patcher from the new workspace paths. Run the development build with scripts/build-game-copy.ts and pass --data.
55 lines
3.1 KiB
TypeScript
55 lines
3.1 KiB
TypeScript
/**
|
|
* Decals from the player's own online client: the player names the web cache folder of an
|
|
* installation they have played online with (<game>/cache/content), and the build copies it
|
|
* into the game copy's cache/content. The offline version never looks for that folder itself.
|
|
*
|
|
* What the copy gives the client (aces.exe 2.61.0.37):
|
|
* - cache/content/ is the web cache root ("ContentProvider::init mount=<game>/cache/content/").
|
|
* - dldata_s.info names the current indexes; when the request for it fails, the client reads
|
|
* the cached copy ("failed to get dlContent index hashes from %s, will fallback local copy",
|
|
* 0xd3eb40), and the local server answers that request with 404.
|
|
* - downloadable_decals.<hash>.blk is the decal index as the CDN served it, with its signature
|
|
* (0xd383e0 checks it and deletes a file that fails). If the file named by dldata_s.info is
|
|
* missing, the newest valid downloadable_decals.*.blk in the folder is used (0xd3f610).
|
|
* - Each decal's texture is fetched through the web cache by its lod0 name (0xd44fc0); the
|
|
* textures the player's client has cached are in the copied folder (assumed, not verified
|
|
* against an online cache: the folder layout below httpCache/ was not examined). Textures it
|
|
* never cached cannot be fetched offline and stay blank.
|
|
*
|
|
* With a player source the build leaves the vromfs index (offline-decal-index.ts) out of
|
|
* char.vromfs.bin, because the client takes the vromfs index first and then skips the web cache.
|
|
*/
|
|
import { cpSync, existsSync, readdirSync, statSync } from 'node:fs';
|
|
import { join, relative, resolve } from 'node:path';
|
|
|
|
export const WEB_CACHE_FOLDER = join('cache', 'content');
|
|
const INDEX_LIST_FILE = 'dldata_s.info';
|
|
const DECALS_INDEX_FILE = /^downloadable_decals\.[a-z2-7]{32}-[a-z2-7]{1,8}\.blk$/;
|
|
|
|
export interface PlayerDecalCache {
|
|
readonly copiedTo: string;
|
|
readonly decalIndexes: readonly string[];
|
|
}
|
|
|
|
/** Check that the folder looks like an online client's web cache; returns the problem or undefined. */
|
|
export function playerDecalCacheProblem(source: string): string | undefined {
|
|
if (!existsSync(source) || !statSync(source).isDirectory()) return `${source} is not a folder`;
|
|
if (!existsSync(join(source, INDEX_LIST_FILE))) return `${source} has no ${INDEX_LIST_FILE} (expected the cache/content folder of an online installation)`;
|
|
if (decalIndexes(source).length === 0) return `${source} has no downloadable_decals.<hash>.blk`;
|
|
return undefined;
|
|
}
|
|
|
|
/** Copy the player's web cache folder into <copy>/cache/content; the source is only read. */
|
|
export function copyPlayerDecalCache(source: string, copyFolder: string): PlayerDecalCache {
|
|
const target = join(copyFolder, WEB_CACHE_FOLDER);
|
|
const from = resolve(source);
|
|
const to = resolve(target);
|
|
if (from === to || !relative(from, to).startsWith('..')) throw new Error(`the decal source ${source} contains the game copy's web cache`);
|
|
cpSync(from, to, { recursive: true, force: true });
|
|
return { copiedTo: target, decalIndexes: decalIndexes(source) };
|
|
}
|
|
|
|
function decalIndexes(folder: string): string[] {
|
|
return readdirSync(folder).filter((name) => DECALS_INDEX_FILE.test(name));
|
|
}
|