Update Healer Man server
This commit is contained in:
1 parent
6114a2295f
commit
69809f7228
593 files changed
+903643
-40774
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { spellDbcEquipmentMetadata } from "./spellDbcEquipmentMetadata.mjs";
|
||||
|
||||
function spellDbc(rows, fieldCount = 71) {
|
||||
const recordSize = fieldCount * 4;
|
||||
const buffer = Buffer.alloc(20 + rows.length * recordSize);
|
||||
buffer.write("WDBC", 0, "ascii");
|
||||
buffer.writeUInt32LE(rows.length, 4);
|
||||
buffer.writeUInt32LE(fieldCount, 8);
|
||||
buffer.writeUInt32LE(recordSize, 12);
|
||||
rows.forEach((row, index) => {
|
||||
const base = 20 + index * recordSize;
|
||||
buffer.writeUInt32LE(row.id, base);
|
||||
buffer.writeInt32LE(row.itemClass, base + 68 * 4);
|
||||
buffer.writeInt32LE(row.subclassMask, base + 69 * 4);
|
||||
buffer.writeUInt32LE(row.inventoryMask, base + 70 * 4);
|
||||
});
|
||||
return buffer;
|
||||
}
|
||||
|
||||
test("reads signed class/subclass fields 68/69 and unsigned inventory mask field 70", () => {
|
||||
const rows = spellDbc([
|
||||
{ id: 1752, itemClass: 2, subclassMask: 0, inventoryMask: 0 },
|
||||
{ id: 78, itemClass: 2, subclassMask: 173_555, inventoryMask: 0 },
|
||||
{ id: 6713, itemClass: -1, subclassMask: 0, inventoryMask: 0 },
|
||||
{ id: 1234, itemClass: 4, subclassMask: -1, inventoryMask: 0x80000000 },
|
||||
]);
|
||||
|
||||
assert.deepEqual(spellDbcEquipmentMetadata(rows), new Map([
|
||||
[1752, { equippedItemClass: 2, equippedItemSubclassMask: 0, equippedItemInventoryMask: 0 }],
|
||||
[78, { equippedItemClass: 2, equippedItemSubclassMask: 173_555, equippedItemInventoryMask: 0 }],
|
||||
[6713, { equippedItemClass: -1, equippedItemSubclassMask: 0, equippedItemInventoryMask: 0 }],
|
||||
[1234, { equippedItemClass: 4, equippedItemSubclassMask: -1, equippedItemInventoryMask: 0x80000000 }],
|
||||
]));
|
||||
});
|
||||
|
||||
test("rejects malformed schemas and duplicate IDs", () => {
|
||||
assert.throws(() => spellDbcEquipmentMetadata(Buffer.from("NOPE")), /not WDBC/);
|
||||
assert.throws(() => spellDbcEquipmentMetadata(spellDbc([], 70)), /unsupported/);
|
||||
assert.throws(() => spellDbcEquipmentMetadata(spellDbc([
|
||||
{ id: 1, itemClass: 0, subclassMask: 0, inventoryMask: 0 },
|
||||
{ id: 1, itemClass: 0, subclassMask: 0, inventoryMask: 0 },
|
||||
])), /repeats spell ID 1/);
|
||||
});
|
||||
Reference in new issue
Block a user