UNPKG

homm3-parsers

Version:

Collection of binary parsers able to parse various file formats related to Heroes of Might and Magic III

28 lines 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const binary_markup_1 = require("binary-markup"); const common_bml_1 = require("./common.bml"); const object_1 = require("./enums/object"); const artifact_1 = require("./enums/artifact"); const objects_1 = require("../../helpers/objects"); const creature_1 = require("./enums/creature"); const alignment_1 = require("./enums/alignment"); const objectSubType = binary_markup_1.branch(binary_markup_1.ctx `objectType`, { [object_1.ObjectType.Artifact]: binary_markup_1.enums(binary_markup_1.uint32, artifact_1.artifactEnum), [object_1.ObjectType.Creature]: binary_markup_1.enums(binary_markup_1.uint32, creature_1.creatureEnum), [object_1.ObjectType.RandomDwellingAlignment]: binary_markup_1.enums(binary_markup_1.uint32, alignment_1.alignmentEnum), }, binary_markup_1.uint32); const entry = binary_markup_1.struct(common_bml_1.hommString `header`, // The passable and active arrays are bitfields representing an 8x6 tile // region where bit 1 marks passable and bit 0 impassable. Counting goes // from left to right downwards towards the bottom right corner. This means // that first bit in passable[0] is [x-7, y-5] from bottom right corner and // last bit in passable[5] is the bottom right corner. binary_markup_1.bytes(6) `passable`, binary_markup_1.bytes(6) `active`, binary_markup_1.uint16 `allowedLandscapes`, binary_markup_1.uint16 `landscapeGroup`, binary_markup_1.enums(binary_markup_1.uint32, object_1.objectTypeEnum) `objectType`, binary_markup_1.computed((context) => { const type = context.get(`objectType`); return objects_1.getMetaType(type); }) `metaType`, objectSubType `objectSubType`, binary_markup_1.enums(binary_markup_1.uint8, object_1.objectGroupEnum) `objectGroup`, binary_markup_1.uint8 `above`, binary_markup_1.skip(16)); exports.objectAttributes = binary_markup_1.struct( // binary_markup_1.uint32 `count`, binary_markup_1.array(entry, binary_markup_1.ctx `count`) `entries`); //# sourceMappingURL=objectAttributes.bml.js.map