feat: some sketchy code

This commit is contained in:
TresAbhi committed 2025-04-05 02:07:35 +00:00
1 parent 2a4375c718
commit ad2aaa7bf8
4 files changed
+13 -11

No files matched your search

@@ -5,11 +5,15 @@ const WINDOWS_APPS = 'C:/Program Files/WindowsApps';
const wotbPackageRegex = /7458BE2C\..+_\d+(\.\d+)+_x64__.+/; const wotbPackageRegex = /7458BE2C\..+_\d+(\.\d+)+_x64__.+/;
const isDepot = argv.includes('--depot'); const isDepot = argv.includes('--depot');
const isManual = argv.includes('--manual');
let data: string; let data: string;
let compressed: boolean; let compressed: boolean;
if (isDepot) { if (isManual) {
data = '../../temp/game/Data';
compressed = true;
} else if (isDepot) {
const [installationVersion] = await readdir(`../../depots/444202`); const [installationVersion] = await readdir(`../../depots/444202`);
data = `../../depots/444202/${installationVersion}/Data`; data = `../../depots/444202/${installationVersion}/Data`;
compressed = true; compressed = true;
@@ -28,8 +28,7 @@ export async function tankModels() {
console.log(`Building models for ${nation}`); console.log(`Building models for ${nation}`);
await Promise.all( for (const [tankKey, tank] of Object.entries(tanks.root)) {
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
if (tankKey.includes('tutorial_bot')) return; if (tankKey.includes('tutorial_bot')) return;
const id = toUniqueId(nation, tank.id); const id = toUniqueId(nation, tank.id);
@@ -46,8 +45,7 @@ export async function tankModels() {
path: `3d/tanks/models/${id}.glb`, path: `3d/tanks/models/${id}.glb`,
content: Buffer.from(await nodeIO.writeBinary(model)), content: Buffer.from(await nodeIO.writeBinary(model)),
}); });
}), }
);
await commitAssets(`tank models ${nation}`, changes); await commitAssets(`tank models ${nation}`, changes);
} }
@@ -1,11 +1,10 @@
import { readFile } from 'fs/promises'; import { readFile } from 'fs/promises';
import { DATA_COMPRESSED } from '../../buildAssets/constants';
import { readDVPL } from './readDVPL'; import { readDVPL } from './readDVPL';
export async function readDVPLFile(file: string) { export async function readDVPLFile(file: string) {
if (DATA_COMPRESSED && !file.endsWith('.dvpl')) { const path = `${file}${file.endsWith('.dvpl') ? '' : '.dvpl'}`;
return readDVPL(await readFile(`${file}.dvpl`)); const content = await readFile(path);
} const dvpl = readDVPL(content);
return readFile(file); return dvpl;
} }
@@ -10,7 +10,7 @@ export async function readTexture(path: string, mutation?: TextureMutation) {
const resolvedTexturePath = isDds const resolvedTexturePath = isDds
? ddsTexturePath ? ddsTexturePath
: ddsTexturePath.replace('.dds', '.pvr'); : ddsTexturePath.replace('.dds', '.pvr');
const decompressedDvpl = await readDVPLFile(resolvedTexturePath); const decompressedDvpl = await readDVPLFile(`${resolvedTexturePath}.dvpl`);
const raw = isDds const raw = isDds
? await new DdsReadStream(decompressedDvpl.buffer as ArrayBuffer).dds() ? await new DdsReadStream(decompressedDvpl.buffer as ArrayBuffer).dds()
@@ -75,4 +75,5 @@ export async function readTexture(path: string, mutation?: TextureMutation) {
default: default:
return await sharp(raw.data, { raw }).jpeg().toBuffer(); return await sharp(raw.data, { raw }).jpeg().toBuffer();
} }
} }