mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: move versions x2
This commit is contained in:
1 parent
af95897bde
commit
83e28b4dac
2 files changed
+32
-23
No files matched your search
+11
-3
@@ -288,7 +288,7 @@ if (allTargets || targets?.includes('tankModels')) {
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
[nations[0]].map(async (nation) => {
|
||||
nations.map(async (nation) => {
|
||||
const tanks = await readXMLDVPL<VehicleDefinitionList>(
|
||||
`${DATA}/${DOI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||
);
|
||||
@@ -299,7 +299,7 @@ if (allTargets || targets?.includes('tankModels')) {
|
||||
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>(
|
||||
`${DATA}/${DOI.tankParameters}/${nation}/${tankIndex}.yaml.dvpl`,
|
||||
@@ -315,7 +315,7 @@ if (allTargets || targets?.includes('tankModels')) {
|
||||
// const scgStream = await SCPGStream.fromDVPLFile(
|
||||
// `${DATA}/${DOI['3d']}/${scgPath}.dvpl`,
|
||||
// );
|
||||
const sc2Data = sc2Stream.consumeSC2();
|
||||
// const sc2Data = sc2Stream.consumeSC2();
|
||||
// const scgData = scgStream.consumeSCG();
|
||||
|
||||
// writeFile(
|
||||
@@ -324,6 +324,14 @@ if (allTargets || targets?.includes('tankModels')) {
|
||||
// typeof value === 'bigint' ? value.toString() : value,
|
||||
// ),
|
||||
// );
|
||||
|
||||
try {
|
||||
sc2Stream.consumeSC2();
|
||||
} catch (error) {
|
||||
if (!(error as Error).message.startsWith('Unhandled KA version')) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ enum KAType {
|
||||
INT16 = 24,
|
||||
UINT16 = 25,
|
||||
ARRAY = 27,
|
||||
TRANSFORM = 29,
|
||||
CUSTOMIZATION_TRANSFORM = 29,
|
||||
}
|
||||
|
||||
enum VertexType {
|
||||
@@ -305,9 +305,7 @@ export class SCPGStream {
|
||||
return { size, fileType };
|
||||
}
|
||||
consumeSC2() {
|
||||
// TODO: HANDLE MORE THAN 1 NODE
|
||||
this.consumeSC2Header();
|
||||
|
||||
return this.consumeKA();
|
||||
}
|
||||
|
||||
@@ -323,11 +321,14 @@ export class SCPGStream {
|
||||
type: KAType = this.consumeUInt8(),
|
||||
stringTable?: Record<number, string>,
|
||||
): unknown {
|
||||
switch (type) {
|
||||
case KAType.INT32:
|
||||
return this.consumeInt32();
|
||||
console.log(KAType[type]);
|
||||
|
||||
case (KAType.STRING, KAType.FILEPATH): {
|
||||
switch (type) {
|
||||
case KAType.NONE:
|
||||
return undefined;
|
||||
|
||||
case KAType.FILEPATH:
|
||||
case KAType.STRING: {
|
||||
const length = this.consumeUInt32();
|
||||
return this.consumeAscii(length);
|
||||
}
|
||||
@@ -377,13 +378,6 @@ export class SCPGStream {
|
||||
case KAType.BOOLEAN:
|
||||
return this.consumeBoolean();
|
||||
|
||||
case KAType.AABBOX3: {
|
||||
const minimum = this.consumeVector3();
|
||||
const maximum = this.consumeVector3();
|
||||
|
||||
return { minimum, maximum };
|
||||
}
|
||||
|
||||
case KAType.VECTOR2:
|
||||
return this.consumeVector2();
|
||||
case KAType.VECTOR3:
|
||||
@@ -391,6 +385,9 @@ export class SCPGStream {
|
||||
case KAType.VECTOR4:
|
||||
return this.consumeVector4();
|
||||
|
||||
case KAType.COLOR:
|
||||
return this.consumeVector4(); // as RGBA
|
||||
|
||||
case KAType.MATRIX2:
|
||||
return this.consumeMatrix2();
|
||||
case KAType.MATRIX3:
|
||||
@@ -398,6 +395,13 @@ export class SCPGStream {
|
||||
case KAType.MATRIX4:
|
||||
return this.consumeMatrix4();
|
||||
|
||||
case KAType.AABBOX3: {
|
||||
const minimum = this.consumeVector3();
|
||||
const maximum = this.consumeVector3();
|
||||
|
||||
return { minimum, maximum };
|
||||
}
|
||||
|
||||
case KAType.FASTNAME: {
|
||||
if (!stringTable) throw new Error('No string table provided');
|
||||
|
||||
@@ -406,7 +410,7 @@ export class SCPGStream {
|
||||
return stringTable[index];
|
||||
}
|
||||
|
||||
case KAType.TRANSFORM: {
|
||||
case KAType.CUSTOMIZATION_TRANSFORM: {
|
||||
if (!stringTable) throw new Error('No string table provided');
|
||||
|
||||
const position = this.consumeVector3();
|
||||
@@ -417,9 +421,6 @@ export class SCPGStream {
|
||||
return { position, scale, rotation, UNCONFIRMED_inset };
|
||||
}
|
||||
|
||||
case KAType.NONE:
|
||||
return undefined;
|
||||
|
||||
default:
|
||||
throw new TypeError(
|
||||
`Unhandled KA type: ${type} (${KAType[type] ?? 'unknown type'})`,
|
||||
@@ -432,7 +433,7 @@ export class SCPGStream {
|
||||
|
||||
return { name, value };
|
||||
}
|
||||
consumeKA<Type>(stringTable?: Record<number, string>) {
|
||||
consumeKA(stringTable?: Record<number, string>) {
|
||||
const header = this.consumeKAHeader();
|
||||
const pairs: Record<string, any> = {};
|
||||
|
||||
@@ -481,7 +482,7 @@ export class SCPGStream {
|
||||
pairs[key] = value;
|
||||
}
|
||||
}
|
||||
} else throw new SyntaxError(`Unhandled KA version: ${header.version}`);
|
||||
} else throw new RangeError(`Unhandled KA version: ${header.version}`);
|
||||
|
||||
return pairs;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user