@blamnetwork/blf 1.0.0-beta.4 → 1.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/haloreach/v12065_11_08_24_1738_tu1actual/s_blf_chunk_map_variant.d.ts +8 -6
- package/dist/chunks/haloreach/v12065_11_08_24_1738_tu1actual/s_blf_chunk_map_variant.d.ts.map +1 -1
- package/dist/chunks/haloreach/v12065_11_08_24_1738_tu1actual/s_blf_chunk_map_variant.js +17 -6
- package/dist-cjs/chunks/haloreach/v12065_11_08_24_1738_tu1actual/s_blf_chunk_map_variant.js +17 -6
- package/package.json +2 -2
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import type { c } from "@craftycodie/cstruct";
|
|
1
|
+
import type { c as CStruct } from "@craftycodie/cstruct";
|
|
2
2
|
import { c_map_variant } from "../../../blam/haloreach/v12065_11_08_24_1738_tu1actual/saved_games/scenario_map_variant";
|
|
3
3
|
import { BLFChunkBase } from "../../../blf_chunk";
|
|
4
|
-
/** Reach map variant chunk packed
|
|
5
|
-
export declare const map_variant_storage_capacity =
|
|
4
|
+
/** Reach map variant chunk packed bitstream storage (bytes). */
|
|
5
|
+
export declare const map_variant_storage_capacity = 28672;
|
|
6
6
|
/**
|
|
7
7
|
* Reach map variant chunk (`mvar` 31.1).
|
|
8
8
|
*
|
|
9
|
-
* Payload layout
|
|
9
|
+
* Payload layout: SHA1 hash + BE `packed_length` + 0x7000 packed storage + 4 zero pad.
|
|
10
|
+
* Hash covers only `packed_length` (4 BE bytes) + the packed bitstream bytes (not 0x7000
|
|
11
|
+
* storage slack or the 4-byte tail pad).
|
|
10
12
|
*/
|
|
11
13
|
export declare class s_blf_chunk_map_variant extends BLFChunkBase {
|
|
12
14
|
hash: Uint8Array;
|
|
13
15
|
packed_length: number;
|
|
14
16
|
map_variant: c_map_variant;
|
|
15
17
|
static create(map_variant: c_map_variant): s_blf_chunk_map_variant;
|
|
16
|
-
read_body(payload: Uint8Array, _endian:
|
|
17
|
-
write_body(_endian:
|
|
18
|
+
read_body(payload: Uint8Array, _endian: CStruct.Endian): void;
|
|
19
|
+
write_body(_endian: CStruct.Endian): Uint8Array;
|
|
18
20
|
}
|
|
19
21
|
//# sourceMappingURL=s_blf_chunk_map_variant.d.ts.map
|
package/dist/chunks/haloreach/v12065_11_08_24_1738_tu1actual/s_blf_chunk_map_variant.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s_blf_chunk_map_variant.d.ts","sourceRoot":"","sources":["../../../../src/chunks/haloreach/v12065_11_08_24_1738_tu1actual/s_blf_chunk_map_variant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"s_blf_chunk_map_variant.d.ts","sourceRoot":"","sources":["../../../../src/chunks/haloreach/v12065_11_08_24_1738_tu1actual/s_blf_chunk_map_variant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAOzD,OAAO,EAAE,aAAa,EAAE,MAAM,yFAAyF,CAAC;AACxH,OAAO,EAAE,YAAY,EAAO,MAAM,oBAAoB,CAAC;AAGvD,gEAAgE;AAChE,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD;;;;;;GAMG;AACH,qBACa,uBAAwB,SAAQ,YAAY;IACvD,IAAI,EAAE,UAAU,CAAsB;IACtC,aAAa,SAAK;IAClB,WAAW,gBAAuB;IAElC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,aAAa,GAAG,uBAAuB;IAMlE,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI;IAiC7D,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,UAAU;CAoChD"}
|
|
@@ -37,12 +37,14 @@ import { security_calculate_hash } from "../../../blam/common/cache/security_fun
|
|
|
37
37
|
import { c_map_variant } from "../../../blam/haloreach/v12065_11_08_24_1738_tu1actual/saved_games/scenario_map_variant";
|
|
38
38
|
import { BLFChunkBase, blf } from "../../../blf_chunk";
|
|
39
39
|
import { BlfError } from "../../../error";
|
|
40
|
-
/** Reach map variant chunk packed
|
|
41
|
-
export const map_variant_storage_capacity =
|
|
40
|
+
/** Reach map variant chunk packed bitstream storage (bytes). */
|
|
41
|
+
export const map_variant_storage_capacity = 0x7000;
|
|
42
42
|
/**
|
|
43
43
|
* Reach map variant chunk (`mvar` 31.1).
|
|
44
44
|
*
|
|
45
|
-
* Payload layout
|
|
45
|
+
* Payload layout: SHA1 hash + BE `packed_length` + 0x7000 packed storage + 4 zero pad.
|
|
46
|
+
* Hash covers only `packed_length` (4 BE bytes) + the packed bitstream bytes (not 0x7000
|
|
47
|
+
* storage slack or the 4-byte tail pad).
|
|
46
48
|
*/
|
|
47
49
|
let s_blf_chunk_map_variant = (() => {
|
|
48
50
|
let _classDecorators = [blf.chunk("mvar", 31.1)];
|
|
@@ -73,7 +75,11 @@ let s_blf_chunk_map_variant = (() => {
|
|
|
73
75
|
}
|
|
74
76
|
this.hash = payload.subarray(0, 20);
|
|
75
77
|
this.packed_length = new DataView(payload.buffer, payload.byteOffset + 20, 4).getUint32(0, false);
|
|
76
|
-
const
|
|
78
|
+
const packed_on_disk = payload.subarray(24);
|
|
79
|
+
const decode_length = this.packed_length > 0
|
|
80
|
+
? Math.min(this.packed_length, map_variant_storage_capacity, packed_on_disk.length)
|
|
81
|
+
: Math.min(map_variant_storage_capacity, packed_on_disk.length);
|
|
82
|
+
const packed_data = packed_on_disk.subarray(0, decode_length);
|
|
77
83
|
const bitstream = c_bitstream_reader.new(packed_data, e_bitstream_byte_order._bitstream_byte_order_big_endian);
|
|
78
84
|
bitstream.begin_reading();
|
|
79
85
|
this.map_variant = new c_map_variant();
|
|
@@ -86,16 +92,21 @@ let s_blf_chunk_map_variant = (() => {
|
|
|
86
92
|
this.map_variant.encode(bitstream);
|
|
87
93
|
bitstream.finish_writing();
|
|
88
94
|
const packed_data = bitstream.get_data();
|
|
95
|
+
if (packed_data.length > map_variant_storage_capacity) {
|
|
96
|
+
throw new BlfError(`packed map variant exceeds storage capacity (${packed_data.length} > ${map_variant_storage_capacity})`);
|
|
97
|
+
}
|
|
98
|
+
const packed_storage = new Uint8Array(map_variant_storage_capacity);
|
|
99
|
+
packed_storage.set(packed_data, 0);
|
|
89
100
|
const length_bytes = new Uint8Array(4);
|
|
90
101
|
new DataView(length_bytes.buffer).setUint32(0, packed_data.length, false);
|
|
91
102
|
const hashable = new Uint8Array(4 + packed_data.length);
|
|
92
103
|
hashable.set(length_bytes, 0);
|
|
93
104
|
hashable.set(packed_data, 4);
|
|
94
105
|
const hash = security_calculate_hash(hashable);
|
|
95
|
-
const payload = new Uint8Array(20 + 4 +
|
|
106
|
+
const payload = new Uint8Array(20 + 4 + map_variant_storage_capacity + 4);
|
|
96
107
|
payload.set(hash, 0);
|
|
97
108
|
payload.set(length_bytes, 20);
|
|
98
|
-
payload.set(
|
|
109
|
+
payload.set(packed_storage, 24);
|
|
99
110
|
this.hash = hash;
|
|
100
111
|
this.packed_length = packed_data.length;
|
|
101
112
|
return payload;
|
|
@@ -40,12 +40,14 @@ const security_functions_1 = require("../../../blam/common/cache/security_functi
|
|
|
40
40
|
const scenario_map_variant_1 = require("../../../blam/haloreach/v12065_11_08_24_1738_tu1actual/saved_games/scenario_map_variant");
|
|
41
41
|
const blf_chunk_1 = require("../../../blf_chunk");
|
|
42
42
|
const error_1 = require("../../../error");
|
|
43
|
-
/** Reach map variant chunk packed
|
|
44
|
-
exports.map_variant_storage_capacity =
|
|
43
|
+
/** Reach map variant chunk packed bitstream storage (bytes). */
|
|
44
|
+
exports.map_variant_storage_capacity = 0x7000;
|
|
45
45
|
/**
|
|
46
46
|
* Reach map variant chunk (`mvar` 31.1).
|
|
47
47
|
*
|
|
48
|
-
* Payload layout
|
|
48
|
+
* Payload layout: SHA1 hash + BE `packed_length` + 0x7000 packed storage + 4 zero pad.
|
|
49
|
+
* Hash covers only `packed_length` (4 BE bytes) + the packed bitstream bytes (not 0x7000
|
|
50
|
+
* storage slack or the 4-byte tail pad).
|
|
49
51
|
*/
|
|
50
52
|
let s_blf_chunk_map_variant = (() => {
|
|
51
53
|
let _classDecorators = [blf_chunk_1.blf.chunk("mvar", 31.1)];
|
|
@@ -76,7 +78,11 @@ let s_blf_chunk_map_variant = (() => {
|
|
|
76
78
|
}
|
|
77
79
|
this.hash = payload.subarray(0, 20);
|
|
78
80
|
this.packed_length = new DataView(payload.buffer, payload.byteOffset + 20, 4).getUint32(0, false);
|
|
79
|
-
const
|
|
81
|
+
const packed_on_disk = payload.subarray(24);
|
|
82
|
+
const decode_length = this.packed_length > 0
|
|
83
|
+
? Math.min(this.packed_length, exports.map_variant_storage_capacity, packed_on_disk.length)
|
|
84
|
+
: Math.min(exports.map_variant_storage_capacity, packed_on_disk.length);
|
|
85
|
+
const packed_data = packed_on_disk.subarray(0, decode_length);
|
|
80
86
|
const bitstream = bitstream_1.c_bitstream_reader.new(packed_data, bitstream_1.e_bitstream_byte_order._bitstream_byte_order_big_endian);
|
|
81
87
|
bitstream.begin_reading();
|
|
82
88
|
this.map_variant = new scenario_map_variant_1.c_map_variant();
|
|
@@ -89,16 +95,21 @@ let s_blf_chunk_map_variant = (() => {
|
|
|
89
95
|
this.map_variant.encode(bitstream);
|
|
90
96
|
bitstream.finish_writing();
|
|
91
97
|
const packed_data = bitstream.get_data();
|
|
98
|
+
if (packed_data.length > exports.map_variant_storage_capacity) {
|
|
99
|
+
throw new error_1.BlfError(`packed map variant exceeds storage capacity (${packed_data.length} > ${exports.map_variant_storage_capacity})`);
|
|
100
|
+
}
|
|
101
|
+
const packed_storage = new Uint8Array(exports.map_variant_storage_capacity);
|
|
102
|
+
packed_storage.set(packed_data, 0);
|
|
92
103
|
const length_bytes = new Uint8Array(4);
|
|
93
104
|
new DataView(length_bytes.buffer).setUint32(0, packed_data.length, false);
|
|
94
105
|
const hashable = new Uint8Array(4 + packed_data.length);
|
|
95
106
|
hashable.set(length_bytes, 0);
|
|
96
107
|
hashable.set(packed_data, 4);
|
|
97
108
|
const hash = (0, security_functions_1.security_calculate_hash)(hashable);
|
|
98
|
-
const payload = new Uint8Array(20 + 4 +
|
|
109
|
+
const payload = new Uint8Array(20 + 4 + exports.map_variant_storage_capacity + 4);
|
|
99
110
|
payload.set(hash, 0);
|
|
100
111
|
payload.set(length_bytes, 20);
|
|
101
|
-
payload.set(
|
|
112
|
+
payload.set(packed_storage, 24);
|
|
102
113
|
this.hash = hash;
|
|
103
114
|
this.packed_length = packed_data.length;
|
|
104
115
|
return payload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blamnetwork/blf",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
4
|
"description": "BLF chunk library for Halo (TypeScript)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist-cjs/index.js",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@automapper/classes": "^8.8.1",
|
|
113
113
|
"@automapper/core": "^8.8.1",
|
|
114
|
-
"@craftycodie/cstruct": "^1.1.
|
|
114
|
+
"@craftycodie/cstruct": "^1.1.1",
|
|
115
115
|
"js-sha1": "^0.7.0",
|
|
116
116
|
"pako": "^2.1.0"
|
|
117
117
|
},
|