diff --git a/tests/client/spawn-position-539.test.ts b/tests/client/spawn-position-539.test.ts index 9d03e48..2950a84 100644 --- a/tests/client/spawn-position-539.test.ts +++ b/tests/client/spawn-position-539.test.ts @@ -140,7 +140,8 @@ describe('Issue #539: player spawn is rendered at the server position inside the it(`${name}: rendered player == server position, on camp floor`, () => { const text = readFileSync(resolve(FIXTURE_DIR, name), 'utf8') // Independent ground truth: plain protocol replay into a bare ClientWorld. - const truth = replayD2CapText(text, { strict: true }).world + const truthResult = replayD2CapText(text, { strict: true }) + const truth = truthResult.world expect(truth.areaId).toBe(ROGUE_ENCAMPMENT) expect(truth.self.x).toBeGreaterThan(0) expect(truth.self.y).toBeGreaterThan(0) @@ -200,7 +201,18 @@ describe('Issue #539: player spawn is rendered at the server position inside the const playerComp = label[(sy - view!.subOriginY) * view!.subWidth + (sx - view!.subOriginX)]! expect(playerComp).toBeGreaterThanOrEqual(0) expect(sizes[playerComp]).toBe(Math.max(...sizes)) - const waypoints = truth.getUnitsByType('object').filter(o => o.classId === ACT1_TOWN_WAYPOINT_CLASS) + // The waypoint is a static object; captures that walk away from it (e.g. 06/07 vendor runs) + // see the server remove it (0x0A) before the capture ends, so take its server UnitAssign + // from anywhere in the capture rather than the final world state. + const waypointIds = new Set() + const waypoints: { readonly x: number; readonly y: number }[] = [] + for (const ev of truthResult.events) { + if (ev.type !== 'UnitAssign') continue + const u = ev.unit + if (u.unitType !== 2 || u.classId !== ACT1_TOWN_WAYPOINT_CLASS || waypointIds.has(u.id)) continue + waypointIds.add(u.id) + waypoints.push({ x: u.x, y: u.y }) + } expect(waypoints.length).toBe(1) const wp = waypoints[0]! let waypointReachable = false