mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: rename to cdon
This commit is contained in:
1 parent
901f1bfe42
commit
9cfa2357b0
12 files changed
+49
-49
No files matched your search
Vendored
+1
-1
@@ -13,10 +13,10 @@
|
|||||||
"bepaint",
|
"bepaint",
|
||||||
"BINORMAL",
|
"BINORMAL",
|
||||||
"Binormals",
|
"Binormals",
|
||||||
"BKON",
|
|
||||||
"bkwd",
|
"bkwd",
|
||||||
"blitzstars",
|
"blitzstars",
|
||||||
"Camo",
|
"Camo",
|
||||||
|
"CDON",
|
||||||
"classname",
|
"classname",
|
||||||
"cleandist",
|
"cleandist",
|
||||||
"cockroackdb",
|
"cockroackdb",
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
# Blitzkrieg Object Notation
|
# Cedilla Object Notation
|
||||||
|
|
||||||
A compact binary representation similar to JSON objects. This documentation uses some funky (yet concise) syntax I developed (don't worry, my C++ isn't that bad!).
|
A compact binary representation similar to JSON objects. This documentation uses some funky (yet concise) syntax I developed (don't worry, my C++ isn't that bad!).
|
||||||
|
|
||||||
1. JSON compressed as BKON, written directly to disk (a direct 50% reduction).
|
1. JSON compressed as CDON, written directly to disk (a direct 50% reduction).
|
||||||
2. BKON further compressed with LZ4 (a clean 90% reduction).
|
2. CDON further compressed with LZ4 (a clean 90% reduction).
|
||||||
3. The raw JSON file as fetched from a random data source.
|
3. The raw JSON file as fetched from a random data source.
|
||||||
4. BKON decompressed once again to JSON. Note that this file is a little larger than the original JSON file as it contains a lot more decimal places due to float precision (this shouldn't affect the size in memory).
|
4. CDON decompressed once again to JSON. Note that this file is a little larger than the original JSON file as it contains a lot more decimal places due to float precision (this shouldn't affect the size in memory).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ struct String {
|
|||||||
## Reading
|
## Reading
|
||||||
|
|
||||||
- Everything is little endian
|
- Everything is little endian
|
||||||
- Magic is always `"BKON"`
|
- Magic is always `"CDON"`
|
||||||
- The index of fast strings must be read as mentioned by the fast string format
|
- The index of fast strings must be read as mentioned by the fast string format
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@@ -915,27 +915,27 @@ export async function definitions(production: boolean) {
|
|||||||
{
|
{
|
||||||
content: superCompress(tankDefinitions),
|
content: superCompress(tankDefinitions),
|
||||||
encoding: 'base64',
|
encoding: 'base64',
|
||||||
path: 'definitions/tanks.bkon.lz4',
|
path: 'definitions/tanks.cdon.lz4',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: superCompress(modelDefinitions),
|
content: superCompress(modelDefinitions),
|
||||||
encoding: 'base64',
|
encoding: 'base64',
|
||||||
path: 'definitions/models.bkon.lz4',
|
path: 'definitions/models.cdon.lz4',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: superCompress(equipmentDefinitions),
|
content: superCompress(equipmentDefinitions),
|
||||||
encoding: 'base64',
|
encoding: 'base64',
|
||||||
path: 'definitions/equipment.bkon.lz4',
|
path: 'definitions/equipment.cdon.lz4',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: superCompress(consumableDefinitions),
|
content: superCompress(consumableDefinitions),
|
||||||
encoding: 'base64',
|
encoding: 'base64',
|
||||||
path: 'definitions/consumables.bkon.lz4',
|
path: 'definitions/consumables.cdon.lz4',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: superCompress(provisionDefinitions),
|
content: superCompress(provisionDefinitions),
|
||||||
encoding: 'base64',
|
encoding: 'base64',
|
||||||
path: 'definitions/provisions.bkon.lz4',
|
path: 'definitions/provisions.cdon.lz4',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
production,
|
production,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
import { fetchBkonLz4 } from './fetchBkonLz4';
|
import { fetchCdonLz4 } from './fetchCdonLz4';
|
||||||
|
|
||||||
export type TankFilterDefinitionCategory = 'clip';
|
export type TankFilterDefinitionCategory = 'clip';
|
||||||
|
|
||||||
@@ -34,6 +34,6 @@ export interface ConsumableDefinitions {
|
|||||||
[key: string]: ConsumableEntry;
|
[key: string]: ConsumableEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const consumableDefinitions = fetchBkonLz4<ConsumableDefinitions>(
|
export const consumableDefinitions = fetchCdonLz4<ConsumableDefinitions>(
|
||||||
asset('definitions/consumables.bkon.lz4'),
|
asset('definitions/consumables.cdon.lz4'),
|
||||||
);
|
);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
import { fetchBkonLz4 } from './fetchBkonLz4';
|
import { fetchCdonLz4 } from './fetchCdonLz4';
|
||||||
|
|
||||||
type EquipmentOptions = [number, number];
|
type EquipmentOptions = [number, number];
|
||||||
|
|
||||||
@@ -22,6 +22,6 @@ export interface EquipmentDefinitions {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const equipmentDefinitions = fetchBkonLz4<EquipmentDefinitions>(
|
export const equipmentDefinitions = fetchCdonLz4<EquipmentDefinitions>(
|
||||||
asset('definitions/equipment.bkon.lz4'),
|
asset('definitions/equipment.cdon.lz4'),
|
||||||
);
|
);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { superDecompress } from './superDecompress';
|
import { superDecompress } from './superDecompress';
|
||||||
|
|
||||||
export async function fetchBkonLz4<Type>(url: string) {
|
export async function fetchCdonLz4<Type>(url: string) {
|
||||||
return await fetch(url, {
|
return await fetch(url, {
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
}).then(async (response) => {
|
}).then(async (response) => {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Vector3Tuple } from 'three';
|
import { Vector3Tuple } from 'three';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
import { fetchBkonLz4 } from './fetchBkonLz4';
|
import { fetchCdonLz4 } from './fetchCdonLz4';
|
||||||
|
|
||||||
export type ModelDefinitions = Record<number, ModelDefinition>;
|
export type ModelDefinitions = Record<number, ModelDefinition>;
|
||||||
|
|
||||||
@@ -54,6 +54,6 @@ export interface PitchLimits {
|
|||||||
transition?: number;
|
transition?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const modelDefinitions = fetchBkonLz4<ModelDefinitions>(
|
export const modelDefinitions = fetchCdonLz4<ModelDefinitions>(
|
||||||
asset('definitions/models.bkon.lz4'),
|
asset('definitions/models.cdon.lz4'),
|
||||||
);
|
);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
import { TankFilterDefinition } from './consumableDefinitions';
|
import { TankFilterDefinition } from './consumableDefinitions';
|
||||||
import { fetchBkonLz4 } from './fetchBkonLz4';
|
import { fetchCdonLz4 } from './fetchCdonLz4';
|
||||||
|
|
||||||
export interface ProvisionEntry {
|
export interface ProvisionEntry {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -14,6 +14,6 @@ export interface ProvisionDefinitions {
|
|||||||
[key: string]: ProvisionEntry;
|
[key: string]: ProvisionEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const provisionDefinitions = fetchBkonLz4<ProvisionDefinitions>(
|
export const provisionDefinitions = fetchCdonLz4<ProvisionDefinitions>(
|
||||||
asset('definitions/provisions.bkon.lz4'),
|
asset('definitions/provisions.cdon.lz4'),
|
||||||
);
|
);
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { compress } from 'lz4js';
|
import { compress } from 'lz4js';
|
||||||
import { BkonWriteStream } from '../streams/bkon';
|
import { CdonWriteStream } from '../streams/cdon';
|
||||||
|
|
||||||
export function superCompress(object: any) {
|
export function superCompress(object: any) {
|
||||||
const write = new BkonWriteStream().bkon(object);
|
const write = new CdonWriteStream().cdon(object);
|
||||||
const compressed = compress(write.buffer);
|
const compressed = compress(write.buffer);
|
||||||
return Buffer.from(compressed).toString('base64');
|
return Buffer.from(compressed).toString('base64');
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { decompress } from 'lz4js';
|
import { decompress } from 'lz4js';
|
||||||
import { BkonReadStream } from '../streams/bkon';
|
import { CdonReadStream } from '../streams/cdon';
|
||||||
|
|
||||||
export function superDecompress<Type>(buffer: Buffer) {
|
export function superDecompress<Type>(buffer: Buffer) {
|
||||||
const decompressed = Buffer.from(decompress(buffer));
|
const decompressed = Buffer.from(decompress(buffer));
|
||||||
const read = new BkonReadStream(decompressed);
|
const read = new CdonReadStream(decompressed);
|
||||||
return read.bkon() as Type;
|
return read.cdon() as Type;
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ import { deburr } from 'lodash';
|
|||||||
import { Vector2Tuple } from 'three';
|
import { Vector2Tuple } from 'three';
|
||||||
import { TankType, TreeType } from '../../components/Tanks';
|
import { TankType, TreeType } from '../../components/Tanks';
|
||||||
import { asset } from './asset';
|
import { asset } from './asset';
|
||||||
import { fetchBkonLz4 } from './fetchBkonLz4';
|
import { fetchCdonLz4 } from './fetchCdonLz4';
|
||||||
|
|
||||||
export type ShellType = 'ap' | 'ap_cr' | 'hc' | 'he';
|
export type ShellType = 'ap' | 'ap_cr' | 'hc' | 'he';
|
||||||
|
|
||||||
@@ -118,8 +118,8 @@ export const GUN_TYPE_NAMES: Record<GunDefinition['type'], string> = {
|
|||||||
autoReloader: 'Auto reloader',
|
autoReloader: 'Auto reloader',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const tankDefinitions = fetchBkonLz4<TankDefinitions>(
|
export const tankDefinitions = fetchCdonLz4<TankDefinitions>(
|
||||||
asset('definitions/tanks.bkon.lz4'),
|
asset('definitions/tanks.cdon.lz4'),
|
||||||
);
|
);
|
||||||
|
|
||||||
const entries = new Promise<TankDefinition[]>(async (resolve) => {
|
const entries = new Promise<TankDefinition[]>(async (resolve) => {
|
||||||
|
|||||||
@@ -26,17 +26,17 @@ enum FastStringFormat {
|
|||||||
Format32,
|
Format32,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BkonValue =
|
export type CdonValue =
|
||||||
| null
|
| null
|
||||||
| boolean
|
| boolean
|
||||||
| number
|
| number
|
||||||
| bigint
|
| bigint
|
||||||
| string
|
| string
|
||||||
| BkonValue[]
|
| CdonValue[]
|
||||||
| { [key: string]: BkonValue };
|
| { [key: string]: CdonValue };
|
||||||
|
|
||||||
export class BkonReadStream extends ReadStream {
|
export class CdonReadStream extends ReadStream {
|
||||||
bkon() {
|
cdon() {
|
||||||
this.magic();
|
this.magic();
|
||||||
const header = this.header();
|
const header = this.header();
|
||||||
const body = this.body(header.fastStringFormat, header.stringTable);
|
const body = this.body(header.fastStringFormat, header.stringTable);
|
||||||
@@ -46,8 +46,8 @@ export class BkonReadStream extends ReadStream {
|
|||||||
magic() {
|
magic() {
|
||||||
const magic = this.utf8(4);
|
const magic = this.utf8(4);
|
||||||
|
|
||||||
if (magic !== 'BKON') {
|
if (magic !== 'CDON') {
|
||||||
throw new Error(`Invalid Bkon magic number: "${magic}"`);
|
throw new Error(`Invalid Cdon magic number: "${magic}"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ export class BkonReadStream extends ReadStream {
|
|||||||
value(
|
value(
|
||||||
fastStringFormat: FastStringFormat,
|
fastStringFormat: FastStringFormat,
|
||||||
stringTable: Record<number, string>,
|
stringTable: Record<number, string>,
|
||||||
): BkonValue {
|
): CdonValue {
|
||||||
const type = this.uint8() as ValueType;
|
const type = this.uint8() as ValueType;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -177,7 +177,7 @@ export class BkonReadStream extends ReadStream {
|
|||||||
const values = times(count, () =>
|
const values = times(count, () =>
|
||||||
this.value(fastStringFormat, stringTable),
|
this.value(fastStringFormat, stringTable),
|
||||||
);
|
);
|
||||||
const object: Record<string, BkonValue> = {};
|
const object: Record<string, CdonValue> = {};
|
||||||
|
|
||||||
keys.forEach((string, index) => (object[string] = values[index]));
|
keys.forEach((string, index) => (object[string] = values[index]));
|
||||||
|
|
||||||
@@ -190,8 +190,8 @@ export class BkonReadStream extends ReadStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BkonWriteStream extends WriteStream {
|
export class CdonWriteStream extends WriteStream {
|
||||||
bkon(object: BkonValue) {
|
cdon(object: CdonValue) {
|
||||||
this.magic();
|
this.magic();
|
||||||
const header = this.header(object);
|
const header = this.header(object);
|
||||||
this.body(header.fastStringFormat, object, header.stringTable);
|
this.body(header.fastStringFormat, object, header.stringTable);
|
||||||
@@ -200,7 +200,7 @@ export class BkonWriteStream extends WriteStream {
|
|||||||
|
|
||||||
body(
|
body(
|
||||||
fastStringFormat: FastStringFormat,
|
fastStringFormat: FastStringFormat,
|
||||||
object: BkonValue,
|
object: CdonValue,
|
||||||
stringTable: Map<string, number>,
|
stringTable: Map<string, number>,
|
||||||
) {
|
) {
|
||||||
this.value(fastStringFormat, object, stringTable);
|
this.value(fastStringFormat, object, stringTable);
|
||||||
@@ -209,7 +209,7 @@ export class BkonWriteStream extends WriteStream {
|
|||||||
|
|
||||||
value(
|
value(
|
||||||
fastStringFormat: FastStringFormat,
|
fastStringFormat: FastStringFormat,
|
||||||
object: BkonValue,
|
object: CdonValue,
|
||||||
stringTable: Map<string, number>,
|
stringTable: Map<string, number>,
|
||||||
) {
|
) {
|
||||||
if (object === null || object === undefined) {
|
if (object === null || object === undefined) {
|
||||||
@@ -303,12 +303,12 @@ export class BkonWriteStream extends WriteStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header(object: BkonValue) {
|
header(object: CdonValue) {
|
||||||
this.uint16(1);
|
this.uint16(1);
|
||||||
return this.stringTable(object);
|
return this.stringTable(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
stringTable(object: BkonValue) {
|
stringTable(object: CdonValue) {
|
||||||
const stringTable = this.buildStringTable(
|
const stringTable = this.buildStringTable(
|
||||||
this.collectStringCounts(object, new Map()),
|
this.collectStringCounts(object, new Map()),
|
||||||
);
|
);
|
||||||
@@ -343,7 +343,7 @@ export class BkonWriteStream extends WriteStream {
|
|||||||
return stringTable;
|
return stringTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
collectStringCounts(object: BkonValue, stringCounts: Map<string, number>) {
|
collectStringCounts(object: CdonValue, stringCounts: Map<string, number>) {
|
||||||
if (typeof object === 'string') {
|
if (typeof object === 'string') {
|
||||||
if (stringCounts.has(object)) {
|
if (stringCounts.has(object)) {
|
||||||
stringCounts.set(object, stringCounts.get(object)! + 1);
|
stringCounts.set(object, stringCounts.get(object)! + 1);
|
||||||
@@ -367,6 +367,6 @@ export class BkonWriteStream extends WriteStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
magic() {
|
magic() {
|
||||||
this.utf8('BKON');
|
this.utf8('CDON');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user