@blamnetwork/blf 1.0.0-beta.4 → 1.0.0-beta.5
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 +2 -2
- 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 +14 -5
- package/dist-cjs/chunks/haloreach/v12065_11_08_24_1738_tu1actual/s_blf_chunk_map_variant.js +14 -5
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { c } 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
|
*
|
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;AAO9C,OAAO,EAAE,aAAa,EAAE,MAAM,yFAAyF,CAAC;AACxH,OAAO,EAAE,YAAY,EAAO,MAAM,oBAAoB,CAAC;AAGvD,
|
|
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;AAO9C,OAAO,EAAE,aAAa,EAAE,MAAM,yFAAyF,CAAC;AACxH,OAAO,EAAE,YAAY,EAAO,MAAM,oBAAoB,CAAC;AAGvD,gEAAgE;AAChE,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD;;;;GAIG;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,CAAC,CAAC,MAAM,GAAG,IAAI;IA6BvD,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,GAAG,UAAU;CAoC1C"}
|
|
@@ -37,8 +37,8 @@ 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
|
*
|
|
@@ -73,7 +73,11 @@ let s_blf_chunk_map_variant = (() => {
|
|
|
73
73
|
}
|
|
74
74
|
this.hash = payload.subarray(0, 20);
|
|
75
75
|
this.packed_length = new DataView(payload.buffer, payload.byteOffset + 20, 4).getUint32(0, false);
|
|
76
|
-
const
|
|
76
|
+
const packed_on_disk = payload.subarray(24);
|
|
77
|
+
const decode_length = this.packed_length > 0
|
|
78
|
+
? Math.min(this.packed_length, packed_on_disk.length)
|
|
79
|
+
: packed_on_disk.length;
|
|
80
|
+
const packed_data = packed_on_disk.subarray(0, decode_length);
|
|
77
81
|
const bitstream = c_bitstream_reader.new(packed_data, e_bitstream_byte_order._bitstream_byte_order_big_endian);
|
|
78
82
|
bitstream.begin_reading();
|
|
79
83
|
this.map_variant = new c_map_variant();
|
|
@@ -86,16 +90,21 @@ let s_blf_chunk_map_variant = (() => {
|
|
|
86
90
|
this.map_variant.encode(bitstream);
|
|
87
91
|
bitstream.finish_writing();
|
|
88
92
|
const packed_data = bitstream.get_data();
|
|
93
|
+
if (packed_data.length > map_variant_storage_capacity) {
|
|
94
|
+
throw new BlfError(`packed map variant exceeds storage capacity (${packed_data.length} > ${map_variant_storage_capacity})`);
|
|
95
|
+
}
|
|
96
|
+
const packed_storage = new Uint8Array(map_variant_storage_capacity);
|
|
97
|
+
packed_storage.set(packed_data, 0);
|
|
89
98
|
const length_bytes = new Uint8Array(4);
|
|
90
99
|
new DataView(length_bytes.buffer).setUint32(0, packed_data.length, false);
|
|
91
100
|
const hashable = new Uint8Array(4 + packed_data.length);
|
|
92
101
|
hashable.set(length_bytes, 0);
|
|
93
102
|
hashable.set(packed_data, 4);
|
|
94
103
|
const hash = security_calculate_hash(hashable);
|
|
95
|
-
const payload = new Uint8Array(20 + 4 +
|
|
104
|
+
const payload = new Uint8Array(20 + 4 + map_variant_storage_capacity);
|
|
96
105
|
payload.set(hash, 0);
|
|
97
106
|
payload.set(length_bytes, 20);
|
|
98
|
-
payload.set(
|
|
107
|
+
payload.set(packed_storage, 24);
|
|
99
108
|
this.hash = hash;
|
|
100
109
|
this.packed_length = packed_data.length;
|
|
101
110
|
return payload;
|
|
@@ -40,8 +40,8 @@ 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
|
*
|
|
@@ -76,7 +76,11 @@ let s_blf_chunk_map_variant = (() => {
|
|
|
76
76
|
}
|
|
77
77
|
this.hash = payload.subarray(0, 20);
|
|
78
78
|
this.packed_length = new DataView(payload.buffer, payload.byteOffset + 20, 4).getUint32(0, false);
|
|
79
|
-
const
|
|
79
|
+
const packed_on_disk = payload.subarray(24);
|
|
80
|
+
const decode_length = this.packed_length > 0
|
|
81
|
+
? Math.min(this.packed_length, packed_on_disk.length)
|
|
82
|
+
: packed_on_disk.length;
|
|
83
|
+
const packed_data = packed_on_disk.subarray(0, decode_length);
|
|
80
84
|
const bitstream = bitstream_1.c_bitstream_reader.new(packed_data, bitstream_1.e_bitstream_byte_order._bitstream_byte_order_big_endian);
|
|
81
85
|
bitstream.begin_reading();
|
|
82
86
|
this.map_variant = new scenario_map_variant_1.c_map_variant();
|
|
@@ -89,16 +93,21 @@ let s_blf_chunk_map_variant = (() => {
|
|
|
89
93
|
this.map_variant.encode(bitstream);
|
|
90
94
|
bitstream.finish_writing();
|
|
91
95
|
const packed_data = bitstream.get_data();
|
|
96
|
+
if (packed_data.length > exports.map_variant_storage_capacity) {
|
|
97
|
+
throw new error_1.BlfError(`packed map variant exceeds storage capacity (${packed_data.length} > ${exports.map_variant_storage_capacity})`);
|
|
98
|
+
}
|
|
99
|
+
const packed_storage = new Uint8Array(exports.map_variant_storage_capacity);
|
|
100
|
+
packed_storage.set(packed_data, 0);
|
|
92
101
|
const length_bytes = new Uint8Array(4);
|
|
93
102
|
new DataView(length_bytes.buffer).setUint32(0, packed_data.length, false);
|
|
94
103
|
const hashable = new Uint8Array(4 + packed_data.length);
|
|
95
104
|
hashable.set(length_bytes, 0);
|
|
96
105
|
hashable.set(packed_data, 4);
|
|
97
106
|
const hash = (0, security_functions_1.security_calculate_hash)(hashable);
|
|
98
|
-
const payload = new Uint8Array(20 + 4 +
|
|
107
|
+
const payload = new Uint8Array(20 + 4 + exports.map_variant_storage_capacity);
|
|
99
108
|
payload.set(hash, 0);
|
|
100
109
|
payload.set(length_bytes, 20);
|
|
101
|
-
payload.set(
|
|
110
|
+
payload.set(packed_storage, 24);
|
|
102
111
|
this.hash = hash;
|
|
103
112
|
this.packed_length = packed_data.length;
|
|
104
113
|
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.5",
|
|
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
|
},
|