dredless 1.1.4 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/MACHINES.md CHANGED
@@ -349,3 +349,8 @@ name have been removed. Raw encoded values remain in `.state.state` (`q40` for
349
349
  the indicator, `q56` for resources).
350
350
 
351
351
  Summary progress, counts, health, occupancy, and raw model records vary by component; use the component's [declared summary](../src/index.d.ts) rather than assuming all machines share a progress scale or health convention.
352
+
353
+ Cargo ejector rendering state uses table 49 `q20 / 100` for `progress`,
354
+ `q24` for the signed `direction` offset, `q28 / 100` for `extension`, and
355
+ `q33` for `noMount`. `active` reports a nonzero cycle or extension; it is
356
+ not the mount flag. The summary also exposes the raw `state`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dredless",
3
- "version": "1.1.4",
3
+ "version": "1.2.2",
4
4
  "description": "A fully-featured and from-scratch headless drednot.io client implementation written in pure js.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/certainhuman/dredless#readme",
package/src/index.d.ts CHANGED
@@ -1567,8 +1567,15 @@ export interface CargoEjectorSummary {
1567
1567
  entity: number;
1568
1568
  typeId: number;
1569
1569
  typeName: string | null;
1570
- progress: number | null;
1571
- active: boolean | null;
1570
+ /** Animation cycle in renderer units (q20 / 100). */
1571
+ progress: number;
1572
+ /** Signed lateral offset used by the ejector arm. */
1573
+ direction: number;
1574
+ extension: number;
1575
+ noMount: boolean;
1576
+ /** Whether the cycle or arm extension is nonzero; not a replicated flag. */
1577
+ active: boolean;
1578
+ state: ModelRecord;
1572
1579
  }
1573
1580
 
1574
1581
  export interface EntityContentsSummary {
@@ -2378,6 +2385,8 @@ export interface PlayerSummary {
2378
2385
  cheats: { noclip: boolean; sandboxBuild: boolean };
2379
2386
  /** Shared item effect flag, including active rocket/hover pack exhaust. */
2380
2387
  itemEffectActive: boolean;
2388
+ /** Current world velocity from motion table 4, in world units per second. */
2389
+ velocity: { x: number; y: number } | null;
2381
2390
  animation: PlayerAnimationSummary;
2382
2391
  appearance: PlayerAppearanceSummary | null;
2383
2392
  actionPreview: PlayerActionPreviewSummary | null;
@@ -74,7 +74,7 @@ export function peekStreamInt(reader) {
74
74
  result += (byte & 0x7f) * (2 ** shift);
75
75
  if ((byte & 0x80) === 0) {
76
76
  return {
77
- value: (result & 1) === 0 ? result / 2 : -((result + 1) / 2),
77
+ value: result % 2 === 0 ? result / 2 : -Math.floor(result / 2),
78
78
  offset
79
79
  };
80
80
  }
@@ -123,7 +123,13 @@ export const MODEL_TABLE_SPECS = new Map([
123
123
  [2, {name: "numeric_pair", ...TWO_FIELD_SPEC}],
124
124
  [3, {name: "gate_width", fields: numericFields({1: 20, 2: 24, 4: 28, 8: 32, 16: 36, 32: 40})}],
125
125
  [4, {name: "motion_aux", packedBits: [{bit: 8, offset: 33}], fields: numericFields({1: 20, 2: 24, 4: 28})}],
126
- [5, {name: "entity_health", fields: numericFields({1: 20, 2: 24, 4: 28, 8: 32})}],
126
+ [5, {
127
+ name: "entity_health",
128
+ // The official table starts both bar dimensions at 10 (one world unit).
129
+ // Field values on the wire are deltas relative to these defaults.
130
+ defaults: {q28: 10, q32: 10},
131
+ fields: numericFields({1: 20, 2: 24, 4: 28, 8: 32})
132
+ }],
127
133
  [6, {name: "item_holder", ...TWO_FIELD_SPEC}],
128
134
  [7, {
129
135
  name: "entity_type",
@@ -228,6 +234,12 @@ export const MODEL_TABLE_SPECS = new Map([
228
234
  }],
229
235
  [26, {name: "numeric_single", fields: numericFields({1: 20})}],
230
236
  [31, {name: "numeric_single", fields: numericFields({1: 20})}],
237
+ [32, {
238
+ // Wire 95 has values; treating it as a marker swallows following removals.
239
+ name: "numeric_triplet",
240
+ defaults: {q28: 10},
241
+ fields: numericFields({1: 20, 2: 24, 4: 28})
242
+ }],
231
243
  [37, {name: "loose_item_marker", packedBits: [{bit: 2, offset: 29}], fields: numericFields({1: 20, 4: 24})}],
232
244
  [38, {name: "flag_state", packedBits: [{bit: 1, offset: 21}], fields: []}],
233
245
  [39, {name: "comms_transmit", ...TWO_FIELD_SPEC}],
@@ -254,6 +266,8 @@ export const MODEL_TABLE_SPECS = new Map([
254
266
  }],
255
267
  [54, {
256
268
  name: "starter_cannon",
269
+ // Wire deltas start with both barrels fully extended and capacity 16.
270
+ defaults: {q36: 50, q44: 16, q48: 50},
257
271
  fields: numericFields({1: 20, 2: 32, 4: 24, 8: 28, 16: 44, 32: 36, 64: 48, 128: 52, 256: 40, 512: 56, 1024: 60})
258
272
  }],
259
273
  [55, {
@@ -428,7 +442,7 @@ export const WIRE_TAG_TABLES = new Map([
428
442
  [169, 77]
429
443
  ]);
430
444
 
431
- export const MASK_ONLY_TABLES = new Set([13, 22, 23, 27, 28, 30, 32, 36, 40, 46, 48, 52, 58, 64, 65, 66, 68, 73, 74]);
445
+ export const MASK_ONLY_TABLES = new Set([13, 22, 23, 27, 28, 30, 36, 40, 46, 48, 52, 58, 64, 65, 66, 68, 73, 74]);
432
446
 
433
447
  export const ENTITY_FOOTPRINTS = new Map([
434
448
  [240, {width: 2, height: 2}],
@@ -655,12 +669,21 @@ export function summarizeFabricator(entity, record, itemHolderRecord = null, typ
655
669
 
656
670
  export function summarizeCargoEjector(entity, typeId, record) {
657
671
  if (typeId !== 223) return null;
672
+ // Official DTS -> component sync (1014): q20/100 is the cycle,
673
+ // q24 is the signed lateral offset, q28/100 is arm extension, and
674
+ // q33 suppresses the hull mount. The flag is not an active bit.
675
+ const progress = numberOrNull(record?.q20, 100) ?? 0;
676
+ const extension = numberOrNull(record?.q28, 100) ?? 0;
658
677
  return {
659
678
  entity,
660
679
  typeId,
661
680
  typeName: entityNameFromType(typeId),
662
- progress: boundedProgress(record?.q24 ?? null),
663
- active: record?.q33 == null ? null : Boolean(record.q33)
681
+ progress,
682
+ direction: record?.q24 ?? 0,
683
+ extension,
684
+ noMount: Boolean(record?.q33),
685
+ active: progress > 0 || extension > 0,
686
+ state: cloneRecord(record)
664
687
  };
665
688
  }
666
689
 
@@ -927,7 +950,7 @@ export function botClassFromState({health, table2Record, smallRecord, combatReco
927
950
  }
928
951
 
929
952
  export function isCowardBossState({health}) {
930
- return health?.state?.q28 === 70 && health?.state?.q32 === 78;
953
+ return health?.state?.q28 === 80 && health?.state?.q32 === 88;
931
954
  }
932
955
 
933
956
  export function isOrangeFoolBotState({combatRecord}) {
@@ -937,8 +960,8 @@ export function isOrangeFoolBotState({combatRecord}) {
937
960
  export function isZombieBossBotState({health, table2Record, combatRecord}) {
938
961
  return (
939
962
  combatRecord?.q20 === -430233088 &&
940
- health?.state?.q28 === 30 &&
941
- health?.state?.q32 === 166 &&
963
+ health?.state?.q28 === 40 &&
964
+ health?.state?.q32 === 176 &&
942
965
  table2Record?.q20 === 320 &&
943
966
  table2Record?.q24 === -900
944
967
  );
@@ -947,39 +970,39 @@ export function isZombieBossBotState({health, table2Record, combatRecord}) {
947
970
  export function isRedSentryBotState({health, table2Record, combatRecord}) {
948
971
  return (
949
972
  combatRecord?.q20 === 508251904 && combatRecord?.q72 === 2 ||
950
- health?.state?.q28 === 70 && health?.state?.q32 === 166 && table2Record?.q20 === 320 && table2Record?.q24 === -900
973
+ health?.state?.q28 === 80 && health?.state?.q32 === 176 && table2Record?.q20 === 320 && table2Record?.q24 === -900
951
974
  );
952
975
  }
953
976
 
954
977
  export function isBlueRusherBotState({health, table2Record, combatRecord}) {
955
978
  return (
956
979
  combatRecord?.q20 === 1113052928 && combatRecord?.q72 === 2 ||
957
- health?.state?.q28 === 30 && health?.state?.q32 === 34 && table2Record?.q20 === 80 && table2Record?.q24 === -900
980
+ health?.state?.q28 === 40 && health?.state?.q32 === 44 && table2Record?.q20 === 80 && table2Record?.q24 === -900
958
981
  );
959
982
  }
960
983
 
961
984
  export function isRedSniperBotState({health, table2Record}) {
962
- return health?.state?.q28 === 35 && health?.state?.q32 === 89 && table2Record?.q20 === 180 && table2Record?.q24 === -900;
985
+ return health?.state?.q28 === 45 && health?.state?.q32 === 99 && table2Record?.q20 === 180 && table2Record?.q24 === -900;
963
986
  }
964
987
 
965
988
  export function isYellowHunterBotState({health, table2Record, combatRecord}) {
966
989
  return (
967
990
  combatRecord?.q20 === -775665152 && combatRecord?.q72 === 4 && combatRecord?.q44 === -944515328 ||
968
- health?.state?.q28 === 30 && health?.state?.q32 === 56 && table2Record?.q20 === 120 && table2Record?.q24 === -900
991
+ health?.state?.q28 === 40 && health?.state?.q32 === 66 && table2Record?.q20 === 120 && table2Record?.q24 === -900
969
992
  );
970
993
  }
971
994
 
972
995
  export function isAquaShielderBotState({health, table2Record, combatRecord}) {
973
996
  return (
974
997
  combatRecord?.q20 === 13697024 && combatRecord?.q24 === 1 ||
975
- health?.state?.q28 === 50 && health?.state?.q32 === 122 && table2Record?.q20 === 240 && table2Record?.q24 === -900
998
+ health?.state?.q28 === 60 && health?.state?.q32 === 132 && table2Record?.q20 === 240 && table2Record?.q24 === -900
976
999
  );
977
1000
  }
978
1001
 
979
1002
  export function isLazerEnthusiastBotState({health, table2Record, table10Record, beamRecord}) {
980
1003
  return (
981
- health?.state?.q28 === 140 &&
982
- health?.state?.q32 === 155 &&
1004
+ health?.state?.q28 === 150 &&
1005
+ health?.state?.q32 === 165 &&
983
1006
  table2Record?.q20 === 300 &&
984
1007
  table2Record?.q24 === -900 &&
985
1008
  Boolean(table10Record) &&
@@ -989,8 +1012,8 @@ export function isLazerEnthusiastBotState({health, table2Record, table10Record,
989
1012
 
990
1013
  export function isYellowMineGuardBotState({health, smallRecord, combatRecord, table2Record}) {
991
1014
  return (
992
- health?.state?.q28 === 30 &&
993
- health?.state?.q32 === 33 &&
1015
+ health?.state?.q28 === 40 &&
1016
+ health?.state?.q32 === 43 &&
994
1017
  smallRecord?.q20 === 78 &&
995
1018
  smallRecord?.q24 === 78 &&
996
1019
  combatRecord?.q24 === -995542016 &&
@@ -999,11 +1022,11 @@ export function isYellowMineGuardBotState({health, smallRecord, combatRecord, ta
999
1022
  }
1000
1023
 
1001
1024
  export function isShieldHelperBotState({health, table2Record}) {
1002
- return health?.state?.q28 === 30 && health?.state?.q32 === 33 && health?.maxHp === 1000 && !table2Record;
1025
+ return health?.state?.q28 === 40 && health?.state?.q32 === 43 && health?.maxHp === 1000 && !table2Record;
1003
1026
  }
1004
1027
 
1005
1028
  export function isShieldMasterBotState({health, table2Record}) {
1006
- return health?.state?.q28 === 190 && health?.state?.q32 === 210 && health?.maxHp === 15000 && Boolean(table2Record);
1029
+ return health?.state?.q28 === 200 && health?.state?.q32 === 220 && health?.maxHp === 15000 && Boolean(table2Record);
1007
1030
  }
1008
1031
 
1009
1032
  export function botIdentifierFromState({combatRecord, motionRecord, smallRecord}) {
@@ -1083,7 +1106,9 @@ export function summarizeShipControl(entity, record) {
1083
1106
  tankValues
1084
1107
  },
1085
1108
  warp: warpTicks == null ? null : {
1086
- active: record.q28 === 3,
1109
+ // Native ship status uses the positive warp timer (q84 / 20).
1110
+ // q28 is thrust Y and does not indicate a warp state.
1111
+ active: warpTicks > 0,
1087
1112
  ticks: warpTicks,
1088
1113
  elapsedSeconds: warpElapsedSeconds,
1089
1114
  durationSeconds: warpDurationSeconds,
@@ -1483,7 +1508,7 @@ function summarizePlayerAppearance(record, player) {
1483
1508
  };
1484
1509
  }
1485
1510
 
1486
- export function summarizePlayer(entity, record, previewRecord = null, blueprintItems = [], appearanceRecord = null, localPlayerEntity = null) {
1511
+ export function summarizePlayer(entity, record, previewRecord = null, blueprintItems = [], appearanceRecord = null, localPlayerEntity = null, motionRecord = null) {
1487
1512
  if (!record) return null;
1488
1513
  const rawHeldItemId = record.q28 == null ? null : Number(record.q28);
1489
1514
  const heldItemId = Number.isFinite(rawHeldItemId) && rawHeldItemId !== 0 ? rawHeldItemId : null;
@@ -1511,6 +1536,12 @@ export function summarizePlayer(entity, record, previewRecord = null, blueprintI
1511
1536
  sandboxBuild: Boolean(record.q108)
1512
1537
  },
1513
1538
  itemEffectActive: Boolean(record.q111),
1539
+ // Official motion component sync (1013): q20 is metadata;
1540
+ // q24/q28 are world velocity, quantized in twentieths.
1541
+ velocity: motionRecord ? {
1542
+ x: (motionRecord.q24 ?? 0) / 20,
1543
+ y: (motionRecord.q28 ?? 0) / 20
1544
+ } : null,
1514
1545
  animation: {
1515
1546
  facing: record.q20 ?? 1,
1516
1547
  orientation: record.q24 ?? 0,
@@ -29,7 +29,10 @@ export class ModelReader {
29
29
 
30
30
  readStreamInt() {
31
31
  const raw = this.readUnsigned();
32
- return (raw & 1) === 0 ? raw / 2 : -((raw + 1) / 2);
32
+ // The client uses sign/magnitude varints, including entity-ID deltas.
33
+ // Odd 2*n+1 decodes to -n (not the zigzag value -n-1).
34
+ const magnitude = Math.floor(raw / 2);
35
+ return raw % 2 === 0 ? magnitude : -magnitude;
33
36
  }
34
37
 
35
38
  readFieldDelta() {
@@ -878,7 +878,7 @@ export class ModelState {
878
878
  const shieldGenerator = typeId === 256 ? summarizeShieldGenerator(entityId, shieldRecord, itemHolderRecord, shieldGeneratorBoostRecord) : null;
879
879
  const shieldProjector = typeId === 257 ? summarizeShieldProjector(entityId, shieldProjectorRecord) : null;
880
880
  const blueprintPreview = summarizeBlueprintPreview(entityId, blueprintPreviewRecord, transformRecord);
881
- const player = summarizePlayer(entityId, playerRecord, rec(14), this.#blueprintPreviewItems(), rec(56), this.#localPlayerEntity);
881
+ const player = summarizePlayer(entityId, playerRecord, rec(14), this.#blueprintPreviewItems(), rec(56), this.#localPlayerEntity, rec(4));
882
882
  const shipControl = summarizeShipControl(entityId, shipControlRecord);
883
883
  const helm = summarizeHelm(entityId, typeId, this.#helmOccupied.get(entityId));
884
884
  const commsStation = summarizeCommsStation(entityId, typeId, commsStationRecord, this.#commsStationOccupied.get(entityId));
@@ -1107,14 +1107,10 @@ export class ModelState {
1107
1107
  if (delta === 0) break;
1108
1108
  entity += delta;
1109
1109
  removals.push(entity);
1110
- // Delete only from tables the entity actually appears in when the derived
1111
- // index is available; fall back to a full scan otherwise.
1112
- const known = this._derived?.entityTableIds?.get(entity);
1113
- if (known) {
1114
- for (const tableId of known) this.tables.get(tableId)?.delete(entity);
1115
- } else {
1116
- for (const records of this.tables.values()) records.delete(entity);
1117
- }
1110
+ // The derived membership index describes the previous apply(), so it
1111
+ // can miss component tables added earlier in this same packet (or
1112
+ // in a partially decoded section). A removal must clear every table.
1113
+ for (const records of this.tables.values()) records.delete(entity);
1118
1114
  this.#helmOccupied.delete(entity);
1119
1115
  this.#commsStationOccupied.delete(entity);
1120
1116
  this.#navigationUnitAutoWarp.delete(entity);