dredless 1.3.0 → 1.4.0

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.
@@ -1,3 +1,23 @@
1
+ export {
2
+ buildLauncherConfigData,
3
+ buildLauncherCopyConfigData,
4
+ buildLauncherPasteConfigData,
5
+ buildDoorConfigData,
6
+ buildDoorCopyConfigData,
7
+ buildDoorPasteConfigData,
8
+ buildSpawnPointConfigData,
9
+ buildSpawnPointCopyConfigData,
10
+ buildSpawnPointPasteConfigData,
11
+ normalizeRankMask,
12
+ type AllowedRank,
13
+ type AllowedRanks,
14
+ type RankFilterConfig,
15
+ type LauncherConfig,
16
+ type DoorConfig,
17
+ type DoorClipboardConfig,
18
+ type SpawnPointConfig,
19
+ } from "../../index.js";
20
+
1
21
  export interface NavigationUnitConfig {
2
22
  destination: number;
3
23
  page?: number;
@@ -38,6 +58,11 @@ export const LoaderPriority: {
38
58
  export type LoaderPriority = typeof LoaderPriority[keyof typeof LoaderPriority];
39
59
  export type ClipboardTarget =
40
60
  number
61
+ | "launcher"
62
+ | "door"
63
+ | "spawn"
64
+ | "spawn-point"
65
+ | "spawnPoint"
41
66
  | "loader"
42
67
  | "loader-config"
43
68
  | "loaderConfig"
@@ -1,4 +1,5 @@
1
1
  import {encoder} from "../../constants.js";
2
+ export * from "./machine-config.js";
2
3
 
3
4
  const NAV_UNIT_COMMAND = "config_nav_unit";
4
5
  const GENERATOR_MAZE_PUZZLE_COMMAND = "maze_puzzle";
@@ -117,6 +118,11 @@ function requireLoaderFilterMode(value, name) {
117
118
  }
118
119
 
119
120
  const CLIPBOARD_TARGET_VALUES = new Map([
121
+ ["launcher", 8],
122
+ ["spawn", 9],
123
+ ["spawn-point", 9],
124
+ ["spawnPoint", 9],
125
+ ["door", 10],
120
126
  ["loader", 1],
121
127
  ["loader-config", 1],
122
128
  ["loaderConfig", 1],
@@ -125,7 +125,7 @@ export const MODEL_TABLE_SPECS = new Map([
125
125
  [4, {name: "motion_aux", packedBits: [{bit: 8, offset: 33}], fields: numericFields({1: 20, 2: 24, 4: 28})}],
126
126
  [5, {
127
127
  name: "entity_health",
128
- // The official table starts both bar dimensions at 10 (one world unit).
128
+ // Bar half-width and vertical offset start at 10 (one world unit).
129
129
  // Field values on the wire are deltas relative to these defaults.
130
130
  defaults: {q28: 10, q32: 10},
131
131
  fields: numericFields({1: 20, 2: 24, 4: 28, 8: 32})
@@ -352,7 +352,11 @@ export const MODEL_TABLE_SPECS = new Map([
352
352
  record.q44 = (record.q44 || 0) + reader.readFieldDelta();
353
353
  }
354
354
  }
355
- }]
355
+ }],
356
+ // Append new wire components without shifting stable Dredless table IDs.
357
+ [79, {name: "launcher_config", defaults: {q20: 0, q24: 300}, fields: numericFields({1: 20, 2: 24})}],
358
+ [80, {name: "rank_filter", defaults: {q20: 4}, fields: numericFields({1: 20})}],
359
+ [81, {name: "spawn_point", fields: []}]
356
360
  ]);
357
361
 
358
362
  // Precompute everything about a spec that is fixed at module load. Decoding a
@@ -455,7 +459,10 @@ export const WIRE_TAG_TABLES = new Map([
455
459
  [166, 75],
456
460
  [167, 76],
457
461
  [168, 78],
458
- [169, 77]
462
+ [169, 77],
463
+ [170, 79],
464
+ [171, 80],
465
+ [172, 81]
459
466
  ]);
460
467
 
461
468
  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]);
@@ -823,6 +830,8 @@ export function summarizeHealth(entity, record) {
823
830
  hp,
824
831
  maxHp,
825
832
  ratio: typeof hp === "number" && typeof maxHp === "number" && maxHp !== 0 ? hp / maxHp : null,
833
+ barWidth: (record.q28 ?? 10) / 5,
834
+ barOffsetY: (record.q32 ?? 10) / 10,
826
835
  state: cloneRecord(record)
827
836
  };
828
837
  }
@@ -1208,6 +1217,7 @@ export function summarizeItemCrate(entity, sizeRecord, itemRecord = null, health
1208
1217
  return {
1209
1218
  entity,
1210
1219
  ...itemSummary(itemId, count),
1220
+ boxSprite: Boolean(itemRecord?.q29),
1211
1221
  width: sizeRecord.q20 ?? null,
1212
1222
  height: sizeRecord.q24 ?? null,
1213
1223
  itemState: cloneRecord(itemRecord || healthRecord || {}),
@@ -1388,15 +1398,19 @@ export function normalizeDegrees(value) {
1388
1398
  return ((Number(value) % 360) + 360) % 360;
1389
1399
  }
1390
1400
 
1391
- export function summarizeItemLauncher(entity, typeId, launcherRecord) {
1392
- if (typeId !== ITEM_LAUNCHER_TYPE_ID || !launcherRecord) return null;
1393
- const angleRadians = numberOrNull(launcherRecord.q32 ?? 0, 200);
1401
+ export function summarizeItemLauncher(entity, typeId, launcherRecord, configRecord = null) {
1402
+ if (typeId !== ITEM_LAUNCHER_TYPE_ID || (!launcherRecord && !configRecord)) return null;
1403
+ const angleRadians = configRecord
1404
+ ? (configRecord.q20 ?? 0) / 10 * Math.PI / 180
1405
+ : numberOrNull(launcherRecord.q32 ?? 0, 200);
1394
1406
  return {
1395
1407
  entity,
1396
- angleRaw: launcherRecord.q32 ?? null,
1408
+ angleRaw: configRecord ? configRecord.q20 ?? 0 : launcherRecord.q32 ?? null,
1397
1409
  angleRadians,
1398
1410
  angleDegrees: angleRadians == null ? null : normalizeDegrees((angleRadians * 180) / Math.PI),
1399
- state: cloneRecord(launcherRecord)
1411
+ power: configRecord ? (configRecord.q24 ?? 300) / 10 : null,
1412
+ configState: configRecord ? cloneRecord(configRecord) : null,
1413
+ state: cloneRecord(launcherRecord || {})
1400
1414
  };
1401
1415
  }
1402
1416
 
@@ -1420,24 +1434,31 @@ export function summarizeShieldProjector(entity, projectorRecord) {
1420
1434
  };
1421
1435
  }
1422
1436
 
1423
- export function summarizeSpawnPoint(entity, spawnRecord) {
1424
- const rank = Number.isFinite(Number(spawnRecord?.q20)) ? Number(spawnRecord.q20) : 0;
1437
+ function summarizeRankFilter(legacyRecord, filterRecord, modern = false) {
1438
+ const legacyRank = Number.isFinite(Number(legacyRecord?.q20)) ? Number(legacyRecord.q20) : 0;
1439
+ const rankMask = filterRecord ? (filterRecord.q20 ?? 4) >>> 0
1440
+ : modern ? null : ({0: 7, 1: 6, 3: 4}[legacyRank] ?? 0);
1441
+ return {
1442
+ rankMask,
1443
+ allowedRanks: rankMask == null ? null : ["guest", "crew", "captain"].filter((_, i) => rankMask & (1 << i)),
1444
+ allRanks: rankMask === 0xffffffff,
1445
+ rankState: cloneRecord(filterRecord || legacyRecord || {})
1446
+ };
1447
+ }
1448
+
1449
+ export function summarizeSpawnPoint(entity, spawnRecord, filterRecord = null, markerRecord = null) {
1425
1450
  return {
1426
1451
  entity,
1427
- rank,
1428
- rankName: enumValueName(TEAM_RANK_NAMES, rank),
1429
- state: cloneRecord(spawnRecord || {})
1452
+ ...summarizeRankFilter(spawnRecord, filterRecord, markerRecord != null),
1453
+ state: cloneRecord(markerRecord || spawnRecord || {})
1430
1454
  };
1431
1455
  }
1432
1456
 
1433
- export function summarizeDoor(entity, rankRecord, doorRecord) {
1434
- const rank = Number.isFinite(Number(rankRecord?.q20)) ? Number(rankRecord.q20) : 0;
1457
+ export function summarizeDoor(entity, rankRecord, doorRecord, filterRecord = null) {
1435
1458
  return {
1436
1459
  entity,
1437
- rank,
1438
- rankName: enumValueName(TEAM_RANK_NAMES, rank),
1460
+ ...summarizeRankFilter(rankRecord, filterRecord),
1439
1461
  open: doorRecord?.q21 === 1,
1440
- rankState: cloneRecord(rankRecord || {}),
1441
1462
  state: cloneRecord(doorRecord || {})
1442
1463
  };
1443
1464
  }
@@ -891,7 +891,7 @@ export class ModelState {
891
891
  const thruster = summarizeThruster(entityId, typeId, thrusterRecord);
892
892
  const pusher = summarizePusher(entityId, pusherRecord, loaderFilterSlotsRecord);
893
893
  const pusherBeam = summarizePusherBeam(entityId, pusherBeamRecord);
894
- const launcher = summarizeItemLauncher(entityId, typeId, launcherRecord);
894
+ const launcher = summarizeItemLauncher(entityId, typeId, launcherRecord, rec(79));
895
895
  const loader = (typeId === LOADER_TYPE_ID || (typeId == null && (loaderRecord || loaderFilterRecord || loaderFilterSlotsRecord)))
896
896
  ? summarizeLoader(entityId, loaderRecord, loaderFilterRecord, loaderFilterSlotsRecord, typeId === LOADER_TYPE_ID, itemHolderRecord)
897
897
  : null;
@@ -910,8 +910,9 @@ export class ModelState {
910
910
  const helm = summarizeHelm(entityId, typeId, this.#helmOccupied.get(entityId));
911
911
  const commsStation = summarizeCommsStation(entityId, typeId, commsStationRecord, this.#commsStationOccupied.get(entityId));
912
912
  const sign = typeId === 218 ? summarizeSign(entityId, signRecord) : null;
913
- const spawnPoint = typeId === 219 ? summarizeSpawnPoint(entityId, spawnPointRecord) : null;
914
- const door = typeId === 220 ? summarizeDoor(entityId, spawnPointRecord, doorRecord) : null;
913
+ const spawnPoint = typeId === 219 || rec(81)
914
+ ? summarizeSpawnPoint(entityId, spawnPointRecord, rec(80), rec(81)) : null;
915
+ const door = typeId === 220 ? summarizeDoor(entityId, spawnPointRecord, doorRecord, rec(80)) : null;
915
916
  const shipSize = shipControl && this.isOverworld ? summarizeShipSize(entityId, rec(3)) : null;
916
917
  const hoverOutline = summarizeHoverOutline(entityId, crateSizeRecord);
917
918
  const expandoBox = isExpandoBox ? summarizeExpandoBox(entityId, itemHolderRecord, expandoSizeRecord) : null;