mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: final compatibility
This commit is contained in:
1 parent
dc01eff812
commit
d18cf625d0
2 files changed
+25
-45
No files matched your search
+9
-27
@@ -298,43 +298,25 @@ if (allTargets || targets?.includes('tankModels')) {
|
|||||||
const nationVehicleId = tank.id;
|
const nationVehicleId = tank.id;
|
||||||
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
|
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
|
||||||
|
|
||||||
// if (id !== 817) continue;
|
console.log(`Building model ${id} @ ${nation}/${tankIndex}`);
|
||||||
// console.log(`Building model ${id} @ ${nation}/${tankIndex}`);
|
|
||||||
|
|
||||||
const parameters = await readYAMLDVPL<TankParameters>(
|
const parameters = await readYAMLDVPL<TankParameters>(
|
||||||
`${DATA}/${DOI.tankParameters}/${nation}/${tankIndex}.yaml.dvpl`,
|
`${DATA}/${DOI.tankParameters}/${nation}/${tankIndex}.yaml.dvpl`,
|
||||||
);
|
);
|
||||||
const sc2Path = parameters.resourcesPath.blitzModelPath;
|
const sc2Path = parameters.resourcesPath.blitzModelPath;
|
||||||
// const scgPath = parameters.resourcesPath.blitzModelPath.replace(
|
const scgPath = parameters.resourcesPath.blitzModelPath.replace(
|
||||||
// /\.sc2$/,
|
/\.sc2$/,
|
||||||
// '.scg',
|
'.scg',
|
||||||
// );
|
);
|
||||||
const sc2Stream = await SCPGStream.fromDVPLFile(
|
const sc2Stream = await SCPGStream.fromDVPLFile(
|
||||||
`${DATA}/${DOI['3d']}/${sc2Path}.dvpl`,
|
`${DATA}/${DOI['3d']}/${sc2Path}.dvpl`,
|
||||||
);
|
);
|
||||||
// const scgStream = await SCPGStream.fromDVPLFile(
|
const scgStream = await SCPGStream.fromDVPLFile(
|
||||||
// `${DATA}/${DOI['3d']}/${scgPath}.dvpl`,
|
`${DATA}/${DOI['3d']}/${scgPath}.dvpl`,
|
||||||
// );
|
);
|
||||||
const sc2Data = sc2Stream.consumeSC2();
|
const sc2Data = sc2Stream.consumeSC2();
|
||||||
// const scgData = scgStream.consumeSCG();
|
const scgData = scgStream.consumeSCG();
|
||||||
|
|
||||||
// writeFile(
|
|
||||||
// `test.json`,
|
|
||||||
// JSON.stringify(sc2Data, (key, value) =>
|
|
||||||
// typeof value === 'bigint' ? value.toString() : value,
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// console.log('Committing tank icons...');
|
|
||||||
// await commitMultipleFiles(
|
|
||||||
// 'tresabhi',
|
|
||||||
// 'blitzkrieg-assets',
|
|
||||||
// 'main',
|
|
||||||
// 'tank icons',
|
|
||||||
// changes,
|
|
||||||
// true,
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
@@ -123,6 +123,9 @@ export class SCPGStream {
|
|||||||
skip(size: number) {
|
skip(size: number) {
|
||||||
this.index += size;
|
this.index += size;
|
||||||
}
|
}
|
||||||
|
back(size: number) {
|
||||||
|
this.skip(-size);
|
||||||
|
}
|
||||||
read(size: number) {
|
read(size: number) {
|
||||||
return this.buffer.subarray(this.index, this.index + size);
|
return this.buffer.subarray(this.index, this.index + size);
|
||||||
}
|
}
|
||||||
@@ -147,9 +150,6 @@ export class SCPGStream {
|
|||||||
consumeAscii(size: number) {
|
consumeAscii(size: number) {
|
||||||
return this.consume(size).toString('ascii');
|
return this.consume(size).toString('ascii');
|
||||||
}
|
}
|
||||||
consumeUtf16(size: number) {
|
|
||||||
return this.consume(size).toString('utf16le');
|
|
||||||
}
|
|
||||||
|
|
||||||
consumeInt8() {
|
consumeInt8() {
|
||||||
return this.consume(1).readInt8();
|
return this.consume(1).readInt8();
|
||||||
@@ -290,12 +290,12 @@ export class SCPGStream {
|
|||||||
version: this.consumeUInt32(),
|
version: this.consumeUInt32(),
|
||||||
nodeCount: this.consumeUInt32(),
|
nodeCount: this.consumeUInt32(),
|
||||||
};
|
};
|
||||||
const version = this.consumeKA();
|
const versionTags = this.consumeKA();
|
||||||
const descriptor = this.consumeSC2Descriptor(header.version);
|
const descriptor = this.consumeSC2Descriptor();
|
||||||
|
|
||||||
return { header, version, descriptor };
|
return { header, versionTags, descriptor };
|
||||||
}
|
}
|
||||||
consumeSC2Descriptor(version: number) {
|
consumeSC2Descriptor() {
|
||||||
const size = this.consumeUInt32();
|
const size = this.consumeUInt32();
|
||||||
const fileType = this.consumeUInt32();
|
const fileType = this.consumeUInt32();
|
||||||
|
|
||||||
@@ -309,7 +309,6 @@ export class SCPGStream {
|
|||||||
return this.consumeKA();
|
return this.consumeKA();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: change return type
|
|
||||||
consumeKAValue(
|
consumeKAValue(
|
||||||
type: KAType = this.consumeUInt8(),
|
type: KAType = this.consumeUInt8(),
|
||||||
stringTable?: Record<number, string>,
|
stringTable?: Record<number, string>,
|
||||||
@@ -320,9 +319,14 @@ export class SCPGStream {
|
|||||||
|
|
||||||
case KAType.FILEPATH:
|
case KAType.FILEPATH:
|
||||||
case KAType.STRING: {
|
case KAType.STRING: {
|
||||||
|
if (stringTable) {
|
||||||
|
const id = this.consumeUInt32();
|
||||||
|
return stringTable[id];
|
||||||
|
} else {
|
||||||
const length = this.consumeUInt32();
|
const length = this.consumeUInt32();
|
||||||
return this.consumeAscii(length);
|
return this.consumeAscii(length);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case KAType.BYTE_ARRAY: {
|
case KAType.BYTE_ARRAY: {
|
||||||
const length = this.consumeUInt32();
|
const length = this.consumeUInt32();
|
||||||
@@ -395,9 +399,7 @@ export class SCPGStream {
|
|||||||
|
|
||||||
case KAType.FASTNAME: {
|
case KAType.FASTNAME: {
|
||||||
if (!stringTable) throw new Error('No string table provided');
|
if (!stringTable) throw new Error('No string table provided');
|
||||||
|
|
||||||
const index = this.consumeUInt32();
|
const index = this.consumeUInt32();
|
||||||
|
|
||||||
return stringTable[index];
|
return stringTable[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,14 +425,8 @@ export class SCPGStream {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
consumeKAV1Pair(stringTable?: Record<number, string>) {
|
|
||||||
const name = this.consumeKAValue(undefined, stringTable) as string;
|
|
||||||
const value = this.consumeKAValue(undefined, stringTable);
|
|
||||||
|
|
||||||
return { name, value };
|
|
||||||
}
|
|
||||||
consumeKA(stringTable?: Record<number, string>) {
|
consumeKA(stringTable?: Record<number, string>) {
|
||||||
this.consumeAscii(2); // "KA"
|
this.skip(2); // "KA"
|
||||||
const version = this.consumeUInt16();
|
const version = this.consumeUInt16();
|
||||||
const pairs: Record<string, any> = {};
|
const pairs: Record<string, any> = {};
|
||||||
|
|
||||||
@@ -438,7 +434,9 @@ export class SCPGStream {
|
|||||||
const count = this.consumeUInt32();
|
const count = this.consumeUInt32();
|
||||||
|
|
||||||
for (let index = 0; index < count; index++) {
|
for (let index = 0; index < count; index++) {
|
||||||
const { name, value } = this.consumeKAV1Pair();
|
const name = this.consumeKAValue(undefined, stringTable) as string;
|
||||||
|
const value = this.consumeKAValue(undefined, stringTable);
|
||||||
|
|
||||||
pairs[name] = value;
|
pairs[name] = value;
|
||||||
}
|
}
|
||||||
} else if (version === 0x0002) {
|
} else if (version === 0x0002) {
|
||||||
|
|||||||
Reference in new issue
Block a user