mdx-m3-viewer
Version:
A browser WebGL model viewer. Mainly focused on models of the games Warcraft 3 and Starcraft 2.
45 lines • 1.33 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("./constants");
/**
* A MPQ hash.
*/
class MpqHash {
constructor() {
this.nameA = 0xFFFFFFFF;
this.nameB = 0xFFFFFFFF;
this.locale = 0xFFFF;
this.platform = 0xFFFF;
this.blockIndex = constants_1.HASH_ENTRY_EMPTY;
}
load(bytes) {
const localePlatform = bytes[2];
this.nameA = bytes[0];
this.nameB = bytes[1];
this.locale = localePlatform & 0x0000FFFF;
this.platform = localePlatform >>> 16;
this.blockIndex = bytes[3];
}
copy(hash) {
this.nameA = hash.nameA;
this.nameB = hash.nameB;
this.locale = hash.locale;
this.platform = hash.platform;
this.blockIndex = hash.blockIndex;
}
save(bytes) {
bytes[0] = this.nameA;
bytes[1] = this.nameB;
bytes[2] = (this.locale << 16) | this.platform;
bytes[3] = this.blockIndex;
}
delete() {
this.nameA = 0xFFFFFFFF;
this.nameB = 0xFFFFFFFF;
this.locale = 0xFFFF;
this.platform = 0xFFFF;
this.blockIndex = constants_1.HASH_ENTRY_DELETED;
}
}
exports.default = MpqHash;
//# sourceMappingURL=hash.js.map