diff --git a/src/parsers/ActionParser.ts b/src/parsers/ActionParser.ts index 8dff0e5..f2d50c1 100644 --- a/src/parsers/ActionParser.ts +++ b/src/parsers/ActionParser.ts @@ -110,6 +110,10 @@ type RemoveUnitFromBuildingQueue = { itemId: number[]; }; +type PreSubselectionAction = { + id: 0x1a; +}; + export type W3MMDAction = { id: 0x6b; filename: string; @@ -123,6 +127,7 @@ export type Action = | UnitBuildingAbilityActionTargetPositionTargetObjectId | GiveItemToUnitAciton | UnitBuildingAbilityActionTwoTargetPositions + | PreSubselectionAction | ChangeSelectionAction | AssignGroupHotkeyAction | SelectGroupHotkeyAction @@ -314,6 +319,10 @@ export default class ActionParser extends StatefulBufferParser { const objectId2 = this.readUInt32LE(); return { id: actionId, itemId, objectId1, objectId2 }; } + case 0x1a: { + return { id: actionId }; + } + case 0x1b: { this.skip(9); return null; diff --git a/test/replays/132/replays.test.ts b/test/replays/132/replays.test.ts index 4d2cd1a..4990a8b 100644 --- a/test/replays/132/replays.test.ts +++ b/test/replays/132/replays.test.ts @@ -81,6 +81,22 @@ it("parse is a promise that resolves with parser output", async () => { expect(metadataCallback).toHaveBeenCalledTimes(1); }); +it("emits 0x1A player actions", async () => { + const Parser = new W3GReplay(); + let amountOf0x1AActions = 0; + Parser.on("gamedatablock", (block: GameDataBlock) => { + if (block.id === 0x1f) { + for (const cmdBlock of block.commandBlocks) { + amountOf0x1AActions += cmdBlock.actions.filter( + (action) => action.id === 0x1a + ).length; + } + } + }); + await Parser.parse(path.resolve(__dirname, "netease_132.nwg")); + expect(amountOf0x1AActions).toBeGreaterThan(0); +}); + it("handles truncated player names in reforged replays", async () => { const test = await Parser.parse( path.resolve(__dirname, "reforged_truncated_playernames.w3g")