@blamnetwork/blf 1.0.0-alpha.1 → 1.0.0-alpha.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/README.md +9 -9
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/c_game_engine_survival_variant.d.ts +2 -1
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/c_game_engine_survival_variant.d.ts.map +1 -1
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/c_game_engine_survival_variant.js +4 -3
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/game_engine_enums.d.ts +45 -0
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/game_engine_enums.d.ts.map +1 -0
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/game_engine_enums.js +60 -0
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/index.d.ts +1 -0
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/index.d.ts.map +1 -1
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/index.js +1 -0
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/index.d.ts +1 -0
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/index.d.ts.map +1 -1
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/index.js +1 -0
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_actions.d.ts +16 -14
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_actions.d.ts.map +1 -1
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_actions.js +61 -55
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_conditions.d.ts +2 -1
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_conditions.d.ts.map +1 -1
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_conditions.js +4 -3
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_enums.d.ts +170 -0
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_enums.d.ts.map +1 -0
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_enums.js +191 -0
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_references.d.ts +5 -3
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_references.d.ts.map +1 -1
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_references.js +11 -9
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_text.d.ts +2 -1
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_text.d.ts.map +1 -1
- package/dist/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_text.js +6 -5
- package/dist/blf_chunk.js +11 -11
- package/dist-cjs/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/c_game_engine_survival_variant.js +4 -3
- package/dist-cjs/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/game_engine_enums.js +64 -0
- package/dist-cjs/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/index.js +1 -0
- package/dist-cjs/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/index.js +1 -0
- package/dist-cjs/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_actions.js +61 -55
- package/dist-cjs/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_conditions.js +4 -3
- package/dist-cjs/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_enums.js +195 -0
- package/dist-cjs/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_references.js +15 -10
- package/dist-cjs/blam/haloreach/v12065_11_08_24_1738_tu1actual/game/megalogamengine/megalogamengine_text.js +6 -5
- package/dist-cjs/blf_chunk.js +11 -11
- package/package.json +2 -5
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.c_dynamic_string = exports.c_replaceable_token = exports.c_player_filter_modifier = void 0;
|
|
4
4
|
const error_1 = require("../../../../../error");
|
|
5
|
+
const megalogamengine_enums_1 = require("./megalogamengine_enums");
|
|
5
6
|
const megalogamengine_references_1 = require("./megalogamengine_references");
|
|
6
7
|
function requireField(value, message) {
|
|
7
8
|
if (value === undefined) {
|
|
@@ -10,12 +11,12 @@ function requireField(value, message) {
|
|
|
10
11
|
return value;
|
|
11
12
|
}
|
|
12
13
|
class c_player_filter_modifier {
|
|
13
|
-
m_type =
|
|
14
|
+
m_type = megalogamengine_enums_1.e_player_filter_type.no_one;
|
|
14
15
|
m_player;
|
|
15
16
|
m_variable;
|
|
16
17
|
decode(bitstream) {
|
|
17
|
-
this.m_type = bitstream.
|
|
18
|
-
if (this.m_type ===
|
|
18
|
+
this.m_type = bitstream.read_enum("type", 3, megalogamengine_enums_1.e_player_filter_type);
|
|
19
|
+
if (this.m_type === megalogamengine_enums_1.e_player_filter_type.specific_player) {
|
|
19
20
|
const player = new megalogamengine_references_1.c_player_reference();
|
|
20
21
|
const variable = new megalogamengine_references_1.c_custom_variable_reference();
|
|
21
22
|
player.decode(bitstream);
|
|
@@ -25,8 +26,8 @@ class c_player_filter_modifier {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
encode(bitstream) {
|
|
28
|
-
bitstream.
|
|
29
|
-
if (this.m_type ===
|
|
29
|
+
bitstream.write_enum(this.m_type, 3);
|
|
30
|
+
if (this.m_type === megalogamengine_enums_1.e_player_filter_type.specific_player) {
|
|
30
31
|
requireField(this.m_player, "m_player does not exist.").encode(bitstream);
|
|
31
32
|
requireField(this.m_variable, "m_variable does not exist.").encode(bitstream);
|
|
32
33
|
}
|
package/dist-cjs/blf_chunk.js
CHANGED
|
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "getBlfChunkMeta", { enumerable: true, get: funct
|
|
|
18
18
|
/** Default {@link BLFChunk.read} / {@link BLFChunk.write}. */
|
|
19
19
|
class BLFChunkBase {
|
|
20
20
|
read(bytes, endian) {
|
|
21
|
-
const header = cstruct_1.c.read(s_blf_header_1.s_blf_header, bytes.subarray(0, cstruct_1.c.
|
|
21
|
+
const header = cstruct_1.c.read(s_blf_header_1.s_blf_header, bytes.subarray(0, cstruct_1.c.sizeof(s_blf_header_1.s_blf_header)), endian);
|
|
22
22
|
const meta = (0, decorators_1.getBlfChunkMeta)(this);
|
|
23
23
|
if (header.signature !== meta.signature ||
|
|
24
24
|
header.major !== meta.major ||
|
|
@@ -28,13 +28,13 @@ class BLFChunkBase {
|
|
|
28
28
|
if (bytes.length < header.chunk_length) {
|
|
29
29
|
throw new error_1.BlfError(`BLF chunk buffer too short: chunk_length ${header.chunk_length}, got ${bytes.length}`);
|
|
30
30
|
}
|
|
31
|
-
const payload = bytes.subarray(cstruct_1.c.
|
|
31
|
+
const payload = bytes.subarray(cstruct_1.c.sizeof(s_blf_header_1.s_blf_header), header.chunk_length);
|
|
32
32
|
this.read_body(payload, endian);
|
|
33
33
|
}
|
|
34
34
|
write(endian) {
|
|
35
35
|
const body = this.write_body(endian);
|
|
36
36
|
const { signature, major, minor } = (0, decorators_1.getBlfChunkMeta)(this);
|
|
37
|
-
const header_bytes = cstruct_1.c.write(s_blf_header_1.s_blf_header, s_blf_header_1.s_blf_header.create(signature, body.length + cstruct_1.c.
|
|
37
|
+
const header_bytes = cstruct_1.c.write(s_blf_header_1.s_blf_header, s_blf_header_1.s_blf_header.create(signature, body.length + cstruct_1.c.sizeof(s_blf_header_1.s_blf_header), major, minor), endian);
|
|
38
38
|
const out = new Uint8Array(header_bytes.length + body.length);
|
|
39
39
|
out.set(header_bytes, 0);
|
|
40
40
|
out.set(body, header_bytes.length);
|
|
@@ -50,7 +50,7 @@ class CStructBLFChunk extends BLFChunkBase {
|
|
|
50
50
|
read_body(payload, endian) {
|
|
51
51
|
const ctor = this.constructor;
|
|
52
52
|
const info = this;
|
|
53
|
-
const size = cstruct_1.c.
|
|
53
|
+
const size = cstruct_1.c.sizeof(ctor);
|
|
54
54
|
if (payload.length < size) {
|
|
55
55
|
throw new error_1.BlfError(`Cannot read ${info.signature} chunk: need at least ${size} bytes, got ${payload.length}`);
|
|
56
56
|
}
|
|
@@ -63,11 +63,11 @@ class CStructBLFChunk extends BLFChunkBase {
|
|
|
63
63
|
}
|
|
64
64
|
exports.CStructBLFChunk = CStructBLFChunk;
|
|
65
65
|
function tryReadHeader(buffer, byte_offset, endian) {
|
|
66
|
-
if (byte_offset + cstruct_1.c.
|
|
66
|
+
if (byte_offset + cstruct_1.c.sizeof(s_blf_header_1.s_blf_header) > buffer.length) {
|
|
67
67
|
return null;
|
|
68
68
|
}
|
|
69
69
|
try {
|
|
70
|
-
return cstruct_1.c.read(s_blf_header_1.s_blf_header, buffer.subarray(byte_offset, byte_offset + cstruct_1.c.
|
|
70
|
+
return cstruct_1.c.read(s_blf_header_1.s_blf_header, buffer.subarray(byte_offset, byte_offset + cstruct_1.c.sizeof(s_blf_header_1.s_blf_header)), endian);
|
|
71
71
|
}
|
|
72
72
|
catch {
|
|
73
73
|
return null;
|
|
@@ -75,22 +75,22 @@ function tryReadHeader(buffer, byte_offset, endian) {
|
|
|
75
75
|
}
|
|
76
76
|
function isChunkLengthValid(chunk_length, byte_offset, buffer_length) {
|
|
77
77
|
return (Number.isInteger(chunk_length) &&
|
|
78
|
-
chunk_length >= cstruct_1.c.
|
|
78
|
+
chunk_length >= cstruct_1.c.sizeof(s_blf_header_1.s_blf_header) &&
|
|
79
79
|
byte_offset + chunk_length <= buffer_length);
|
|
80
80
|
}
|
|
81
81
|
function loadChunkAt(buffer, byte_offset, header, chunk, endian) {
|
|
82
82
|
const chunk_end = byte_offset + header.chunk_length;
|
|
83
|
-
const payload = buffer.subarray(byte_offset + cstruct_1.c.
|
|
83
|
+
const payload = buffer.subarray(byte_offset + cstruct_1.c.sizeof(s_blf_header_1.s_blf_header), chunk_end);
|
|
84
84
|
chunk.read_body(payload, endian);
|
|
85
85
|
}
|
|
86
86
|
/** Walk a BLF file sequentially until `chunk` is found, then read it in place. */
|
|
87
87
|
function find_chunk(buffer, chunk, endian) {
|
|
88
88
|
const meta = (0, decorators_1.getBlfChunkMeta)(chunk);
|
|
89
89
|
let offset = 0;
|
|
90
|
-
while (offset + cstruct_1.c.
|
|
90
|
+
while (offset + cstruct_1.c.sizeof(s_blf_header_1.s_blf_header) <= buffer.length) {
|
|
91
91
|
let header;
|
|
92
92
|
try {
|
|
93
|
-
header = cstruct_1.c.read(s_blf_header_1.s_blf_header, buffer.subarray(offset, offset + cstruct_1.c.
|
|
93
|
+
header = cstruct_1.c.read(s_blf_header_1.s_blf_header, buffer.subarray(offset, offset + cstruct_1.c.sizeof(s_blf_header_1.s_blf_header)), endian);
|
|
94
94
|
}
|
|
95
95
|
catch {
|
|
96
96
|
return false;
|
|
@@ -112,7 +112,7 @@ function find_chunk(buffer, chunk, endian) {
|
|
|
112
112
|
/** Scan every byte offset for `chunk`, then read it in place when found. */
|
|
113
113
|
function search_for_chunk(buffer, chunk, endian) {
|
|
114
114
|
const meta = (0, decorators_1.getBlfChunkMeta)(chunk);
|
|
115
|
-
const last_offset = buffer.length - cstruct_1.c.
|
|
115
|
+
const last_offset = buffer.length - cstruct_1.c.sizeof(s_blf_header_1.s_blf_header);
|
|
116
116
|
const sig = meta.signature;
|
|
117
117
|
const sig0 = endian === "little" ? sig.charCodeAt(3) : sig.charCodeAt(0);
|
|
118
118
|
const sig1 = endian === "little" ? sig.charCodeAt(2) : sig.charCodeAt(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blamnetwork/blf",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.5",
|
|
4
4
|
"description": "BLF chunk library for Halo (TypeScript)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist-cjs/index.js",
|
|
@@ -72,10 +72,7 @@
|
|
|
72
72
|
"halo",
|
|
73
73
|
"haloreach",
|
|
74
74
|
"halo3",
|
|
75
|
-
"halo3odst"
|
|
76
|
-
"chunks",
|
|
77
|
-
"binary",
|
|
78
|
-
"fileshare"
|
|
75
|
+
"halo3odst"
|
|
79
76
|
],
|
|
80
77
|
"license": "MIT",
|
|
81
78
|
"publishConfig": {
|